X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectItem.cpp;h=85ea773ce4d2420ecbbb2ecdf223585f44497358;hb=092a2dd175a4001a495c84ee85211734fb928c83;hp=4c197ff3c362b42e05e7099b1413c1cc9d2c5cff;hpb=fde7b27297882a7f033641df92e732abd137b532;p=l2e.git diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index 4c197ff..85ea773 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -13,41 +13,39 @@ #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Item.h" -#include "../../geometry/Point.h" -#include "../../geometry/operators.h" #include "../../graphics/Frame.h" +#include "../../math/Vector.h" using app::Application; using app::Input; using common::Item; -using geometry::Point; -using geometry::Vector; +using math::Vector; using graphics::Frame; namespace battle { -void SelectItem::EnterState(Application &c, SDL_Surface *screen) { - ctrl = &c; +void SelectItem::OnEnterState(SDL_Surface *screen) { + } -void SelectItem::ExitState(Application &c, SDL_Surface *screen) { - ctrl = 0; +void SelectItem::OnExitState(SDL_Surface *screen) { + } -void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) { +void SelectItem::OnResumeState(SDL_Surface *screen) { if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) { battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM); battle->ActiveHero().GetAttackChoice().SetItem(battle->ItemMenu().Selected()); - ctrl.PopState(); + Ctrl().PopState(); } } -void SelectItem::PauseState(Application &ctrl, SDL_Surface *screen) { +void SelectItem::OnPauseState(SDL_Surface *screen) { } -void SelectItem::Resize(int width, int height) { +void SelectItem::OnResize(int width, int height) { } @@ -65,22 +63,21 @@ void SelectItem::HandleEvents(const Input &input) { } 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(); @@ -96,7 +93,7 @@ void SelectItem::HandleEvents(const Input &input) { } } -void SelectItem::UpdateWorld(float deltaT) { +void SelectItem::UpdateWorld(Uint32 deltaT) { } @@ -110,7 +107,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 +115,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 +123,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);