X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectItem.cpp;h=fe6ce7b3ba7dc9fa8e1addc5382883012317e3d0;hb=3f8fac16c7ae2cbe7da47b98aba9b558825723e7;hp=bd09da664e204891b6a8b3aeeaf86b05e3b174db;hpb=f6e55f72530b2d01fbbe8f5745f830d17231c2c4;p=l2e.git diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index bd09da6..fe6ce7b 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -13,28 +13,25 @@ #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Item.h" -#include "../../geometry/Point.h" -#include "../../geometry/operators.h" #include "../../graphics/Frame.h" using app::Application; using app::Input; using common::Item; -using geometry::Point; using geometry::Vector; using graphics::Frame; namespace battle { -void SelectItem::EnterState(Application &c, SDL_Surface *screen) { - ctrl = &c; +void SelectItem::OnEnterState(Application &c, SDL_Surface *screen) { + } -void SelectItem::ExitState(Application &c, SDL_Surface *screen) { - ctrl = 0; +void SelectItem::OnExitState(Application &c, SDL_Surface *screen) { + } -void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) { +void SelectItem::OnResumeState(Application &ctrl, SDL_Surface *screen) { if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM); battle->ActiveHero().GetAttackChoice().SetItem(battle->ItemMenu().Selected()); @@ -42,12 +39,12 @@ void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) { } } -void SelectItem::PauseState(Application &ctrl, SDL_Surface *screen) { +void SelectItem::OnPauseState(Application &ctrl, SDL_Surface *screen) { } -void SelectItem::Resize(int width, int height) { +void SelectItem::OnResize(int width, int height) { } @@ -61,26 +58,25 @@ void SelectItem::HandleEvents(const Input &input) { if (item->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); } else { - ac.Selection().SelectEnemies(); + ac.Selection().SelectMonsters(); } if (item->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::ITEM); - // TODO: remove item from inventory ac.SetItem(item); battle->NextHero(); - ctrl->PopState(); + Ctrl().PopState(); } else { if (item->GetTargetingMode().TargetsSingle()) { ac.Selection().SetSingle(); } else { ac.Selection().SetMultiple(); } - ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor)); + Ctrl().PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor)); } } } if (input.JustPressed(Input::ACTION_B)) { - ctrl->PopState(); // return control to parent + Ctrl().PopState(); // return control to parent } if (input.JustPressed(Input::PAD_UP)) { battle->ItemMenu().PreviousRow(); @@ -110,7 +106,7 @@ void SelectItem::Render(SDL_Surface *screen) { void SelectItem::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Point position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderSize()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); @@ -118,7 +114,7 @@ void SelectItem::RenderFrame(SDL_Surface *screen, const Vector &offset) { void SelectItem::RenderHeadline(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight()); res.normalFont->DrawString(res.itemMenuHeadline, screen, position + offset); @@ -126,7 +122,7 @@ void SelectItem::RenderHeadline(SDL_Surface *screen, const Vector &offset) void SelectItem::RenderMenu(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight()); battle->ItemMenu().Draw(screen, position + offset);