X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectTarget.cpp;h=0b5b01d6b78a3e096eba04df7aa9882af4cc896e;hb=65158353d1ecbed0032752863c6c4eb96b1a084a;hp=dedf8e77b193ce3f78bea9e67db1082752722af2;hpb=3c72a71fbf6de96333a641051a20c6bf8b3a5df3;p=l2e.git diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index dedf8e7..0b5b01d 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -11,30 +11,27 @@ #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) { +void SelectTarget::OnEnterState(Application &c, SDL_Surface *screen) { ctrl = &c; } -void SelectTarget::ExitState(Application &c, SDL_Surface *screen) { +void SelectTarget::OnExitState(Application &c, SDL_Surface *screen) { ctrl = 0; } -void SelectTarget::ResumeState(Application &ctrl, SDL_Surface *screen) { +void SelectTarget::OnResumeState(Application &ctrl, SDL_Surface *screen) { } -void SelectTarget::PauseState(Application &ctrl, SDL_Surface *screen) { +void SelectTarget::OnPauseState(Application &ctrl, SDL_Surface *screen) { } @@ -44,7 +41,7 @@ void SelectTarget::Resize(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 @@ -89,24 +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 - Vector cursorOffset(0, 0); - 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); - 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); } } }