]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectTarget.cpp
removed useless comments
[l2e.git] / src / battle / states / SelectTarget.cpp
index c0ff6cca585a0ef143e316c10dbe73df16fb2ff8..800c2335e53460cda706440e1ae0bcefc7de8858 100644 (file)
@@ -1,45 +1,36 @@
-/*
- * SelectTarget.cpp
- *
- *  Created on: Aug 9, 2012
- *      Author: holy
- */
-
 #include "SelectTarget.h"
 
 #include "SelectAttackType.h"
 #include "../BattleState.h"
 #include "../../app/Application.h"
 #include "../../app/Input.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
+#include "../../math/Vector.h"
 
 using app::Application;
 using app::Input;
-using geometry::Point;
-using geometry::Vector;
+using math::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) {
 
 }
 
@@ -47,11 +38,11 @@ void SelectTarget::Resize(int width, int height) {
 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 +51,7 @@ void SelectTarget::HandleEvents(const Input &input) {
                        selection->Unselect();
                } else {
                        selection->UnselectAll();
-                       ctrl->PopState(); // return control to parent
+                       Ctrl().PopState(); // return control to parent
                }
        }
 
@@ -78,7 +69,7 @@ void SelectTarget::HandleEvents(const Input &input) {
        }
 }
 
-void SelectTarget::UpdateWorld(float deltaT) {
+void SelectTarget::UpdateWorld(Uint32 deltaT) {
 
 }
 
@@ -88,28 +79,24 @@ void SelectTarget::Render(SDL_Surface *screen) {
        RenderCursors(screen, offset);
 }
 
-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<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);
+void SelectTarget::RenderCursors(SDL_Surface *screen, const math::Vector<int> &offset) {
+       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<Vector<int> > positions;
+       if (selection->TargetsMonsters()) {
+               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) {
+               for (vector<Vector<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);
                        }
                }
        }