]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectTarget.cpp
moved monster's position to Monster
[l2e.git] / src / battle / states / SelectTarget.cpp
index 9c50991bf00c26b9deb34acc83b61f3b4f4b7152..591da6753972350cf1eb9f0f44041a8df2023368 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,26 +90,23 @@ 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
-       // 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<int> cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height());
+       // offset the indicator by 1/8th to the right and top
+       Vector<int> indicatorOffset(cursorOffset + Vector<int>(cursorIcon->Width() / 8, cursorIcon->Height() / -8));
        vector<Point<int> > positions;
        if (selection->TargetsEnemies()) {
-               for (vector<Point<int> >::const_iterator i(battle->MonsterPositions().begin()), end(battle->MonsterPositions().end()); i != end; ++i) {
-                       positions.push_back(*i);
+               for (int i(0), end(battle->MaxMonsters()); i < end; ++i) {
+                       positions.push_back(battle->MonsterAt(i).Position());
                }
        } else {
-               for (vector<Hero>::size_type i(0), end(battle->Heroes().size()); 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);
+               for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
+                       positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset());
                }
        }
        if (flipFlop) {
                for (vector<Point<int> >::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);
                        }
                }
        }