X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbattle%2Fstates%2FSelectItem.cpp;h=e4ccc14527d95ca4ea5bbd2665b4284195500c1c;hb=087783315ac5955c17bb3b051c9351f321653df6;hp=0aaf7a36a79776ee9023a7162115aa7e49704a42;hpb=eb2ad5ffd08128d31af32f3929a3295fcfa251e9;p=l2e.git diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index 0aaf7a3..e4ccc14 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -17,6 +17,13 @@ using graphics::Frame; namespace battle { +SelectItem::SelectItem(Battle *battle, SelectAttackType *parent) +: battle(battle) +, parent(parent) { + +} + + void SelectItem::OnEnterState(SDL_Surface *screen) { OnResize(screen->w, screen->h); } @@ -28,7 +35,7 @@ void SelectItem::OnExitState(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()); + battle->ActiveHero().GetAttackChoice().SetItem(parent->ItemMenu().Selected()); Ctrl().PopState(); } } @@ -39,14 +46,14 @@ void SelectItem::OnPauseState(SDL_Surface *screen) { void SelectItem::OnResize(int width, int height) { - const Vector offset = battle->ScreenOffset(); + const Vector offset = parent->ScreenOffset(); - const Resources &res = battle->Res(); + const Resources &res = parent->Res(); const Frame &frame = *res.selectFrame; framePosition = offset + frame.BorderSize(); frameSize = Vector( - battle->Width() - 2 * frame.BorderWidth(), + parent->Width() - 2 * frame.BorderWidth(), res.normalFont->CharHeight() * 13); headlinePosition = offset + Vector( @@ -61,9 +68,9 @@ void SelectItem::OnResize(int width, int height) { void SelectItem::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { - if (battle->ItemMenu().SelectedIsEnabled()) { + if (parent->ItemMenu().SelectedIsEnabled()) { AttackChoice &ac(battle->ActiveHero().GetAttackChoice()); - const Item *item(battle->ItemMenu().Selected()); + const Item *item(parent->ItemMenu().Selected()); ac.Selection().Reset(); if (item->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); @@ -81,7 +88,7 @@ void SelectItem::HandleEvents(const Input &input) { } else { ac.Selection().SetMultiple(); } - Ctrl().PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor)); + Ctrl().PushState(new SelectTarget(battle, parent, &ac.Selection(), parent->Res().itemTargetCursor)); } } } @@ -89,16 +96,16 @@ void SelectItem::HandleEvents(const Input &input) { Ctrl().PopState(); // return control to parent } if (input.JustPressed(Input::PAD_UP)) { - battle->ItemMenu().PreviousRow(); + parent->ItemMenu().PreviousRow(); } if (input.JustPressed(Input::PAD_RIGHT)) { - battle->ItemMenu().NextItem(); + parent->ItemMenu().NextItem(); } if (input.JustPressed(Input::PAD_DOWN)) { - battle->ItemMenu().NextRow(); + parent->ItemMenu().NextRow(); } if (input.JustPressed(Input::PAD_LEFT)) { - battle->ItemMenu().PreviousItem(); + parent->ItemMenu().PreviousItem(); } } @@ -114,17 +121,17 @@ void SelectItem::Render(SDL_Surface *screen) { } void SelectItem::RenderFrame(SDL_Surface *screen) { - const Frame &frame = *battle->Res().selectFrame; + const Frame &frame = *parent->Res().selectFrame; frame.Draw(screen, framePosition, frameSize.X(), frameSize.Y()); } void SelectItem::RenderHeadline(SDL_Surface *screen) { - const Resources &res = battle->Res(); + const Resources &res = parent->Res(); res.normalFont->DrawString(res.itemMenuHeadline, screen, headlinePosition); } void SelectItem::RenderMenu(SDL_Surface *screen) { - battle->ItemMenu().Draw(screen, menuPosition); + parent->ItemMenu().Draw(screen, menuPosition); } }