X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectTarget.cpp;h=1961738623a30a1c9f3ec2f90c340c3a651f4dbe;hb=5ca18f73987fb3935ab34654cbbecf5eca4704cb;hp=9c50991bf00c26b9deb34acc83b61f3b4f4b7152;hpb=4356621a6440ac915dd0d2dfc70d2c17c3ff321a;p=l2e.git diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index 9c50991..1961738 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -11,47 +11,44 @@ #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; using std::vector; namespace battle { -void SelectTarget::EnterState(Application &c, SDL_Surface *screen) { - ctrl = &c; +void SelectTarget::OnEnterState(SDL_Surface *screen) { + } -void SelectTarget::ExitState(Application &c, SDL_Surface *screen) { - ctrl = 0; +void SelectTarget::OnExitState(SDL_Surface *screen) { + } -void SelectTarget::ResumeState(Application &ctrl, SDL_Surface *screen) { +void SelectTarget::OnResumeState(SDL_Surface *screen) { } -void SelectTarget::PauseState(Application &ctrl, SDL_Surface *screen) { +void SelectTarget::OnPauseState(SDL_Surface *screen) { } -void SelectTarget::Resize(int width, int height) { +void SelectTarget::OnResize(int width, int height) { } -void SelectTarget::HandleInput(const Input &input) { +void SelectTarget::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { if (selection->CurrentIsSelected()) { - ctrl->PopState(); // return control to parent + Ctrl().PopState(); // return control to parent } else { selection->Select(); if (selection->SelectSingle()) { - ctrl->PopState(); // return control to parent + Ctrl().PopState(); // return control to parent } } } @@ -60,7 +57,7 @@ void SelectTarget::HandleInput(const Input &input) { selection->Unselect(); } else { selection->UnselectAll(); - ctrl->PopState(); // return control to parent + Ctrl().PopState(); // return control to parent } } @@ -89,27 +86,23 @@ void SelectTarget::Render(SDL_Surface *screen) { } void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector &offset) { - // TODO: this should be related to the enemy's width - // offset the cursor by 1/8th to the left and bottom - Vector cursorOffset(cursorIcon->Width() / -8, cursorIcon->Height() / 8); - Vector indicatorOffset(0, 0); - vector > positions; - if (selection->TargetsEnemies()) { - for (vector >::const_iterator i(battle->MonsterPositions().begin()), end(battle->MonsterPositions().end()); i != end; ++i) { - positions.push_back(*i); + Vector cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height()); + // offset the indicator by 1/8th to the right and top + Vector indicatorOffset(cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8)); + vector > positions; + if (selection->TargetsMonsters()) { + for (int i(0), end(battle->MaxMonsters()); i < end; ++i) { + positions.push_back(battle->MonsterAt(i).Position()); } } else { - for (vector::size_type i(0), end(battle->Heroes().size()); i < end; ++i) { - Vector positionCorrection(cursorIcon->Width() / 2, battle->HeroTagAt(i).HeroSprite()->Height() - cursorIcon->Height() / 2); - // indicator offsets are inverted for heroes - positionCorrection -= cursorOffset; - positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset() + positionCorrection); + for (int i(0), end(battle->NumHeroes()); i < end; ++i) { + positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset()); } } if (flipFlop) { - for (vector >::size_type i(0); i < positions.size(); ++i) { + for (vector >::size_type i(0); i < positions.size(); ++i) { if (selection->IsSelected(i)) { - cursorIcon->DrawTopRight(screen, positions[i] + offset); + cursorIcon->DrawTopRight(screen, positions[i] + indicatorOffset + offset); } } }