]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectTarget.cpp
removed direct access to battle's monsters vector
[l2e.git] / src / battle / states / SelectTarget.cpp
index dedf8e77b193ce3f78bea9e67db1082752722af2..8fe31cd60dad1e1953c3460d86f4998870158969 100644 (file)
@@ -44,7 +44,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
@@ -90,7 +90,8 @@ void SelectTarget::Render(SDL_Surface *screen) {
 
 void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector<int> &offset) {
        // TODO: this should be related to the enemy's width
-       Vector<int> cursorOffset(0, 0);
+       // offset the cursor by 1/8th to the left and bottom
+       Vector<int> cursorOffset(cursorIcon->Width() / -8, cursorIcon->Height() / 8);
        Vector<int> indicatorOffset(0, 0);
        vector<Point<int> > positions;
        if (selection->TargetsEnemies()) {
@@ -98,8 +99,10 @@ void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector<int
                        positions.push_back(*i);
                }
        } else {
-               for (vector<Hero>::size_type i(0), end(battle->Heroes().size()); i < end; ++i) {
+               for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
                        Vector<int> 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);
                }
        }