]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectAttackType.cpp
cached some of the battle coordinates
[l2e.git] / src / battle / states / SelectAttackType.cpp
index 31a0be0e2e853a6ddb90e623156d3621486981e8..b4f5dcc73f69a071bc4877d682dc27d2c52da2c4 100644 (file)
@@ -1,10 +1,3 @@
-/*
- * SelectAttackType.cpp
- *
- *  Created on: Aug 7, 2012
- *      Author: holy
- */
-
 #include "SelectAttackType.h"
 
 #include "SelectIkari.h"
 #include "../../app/Application.h"
 #include "../../app/Input.h"
 #include "../../common/Item.h"
+#include "../../math/Vector.h"
 
 #include <stdexcept>
 
 using app::Application;
 using app::Input;
 using common::Item;
-using geometry::Vector;
+using math::Vector;
 
 namespace battle {
 
-void SelectAttackType::OnEnterState(Application &c, SDL_Surface *screen) {
-
+void SelectAttackType::OnEnterState(SDL_Surface *screen) {
+       OnResize(screen->w, screen->h);
 }
 
-void SelectAttackType::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectAttackType::OnExitState(SDL_Surface *screen) {
 
 }
 
-void SelectAttackType::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectAttackType::OnResumeState(SDL_Surface *screen) {
        if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
                battle->ActiveHero().GetAttackChoice().SetType(battle->GetAttackTypeMenu().Selected());
                battle->NextHero();
        }
        if (battle->AttackSelectionDone()) {
                // pass through
-               ctrl.PopState();
+               Ctrl().PopState();
        }
 }
 
-void SelectAttackType::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectAttackType::OnPauseState(SDL_Surface *screen) {
 
 }
 
 
 void SelectAttackType::OnResize(int width, int height) {
-
+       Vector<int> offset(battle->ScreenOffset());
+       Vector<int> position(
+                       (battle->Width() - battle->GetAttackTypeMenu().Width()) / 2,
+                       battle->Height() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2);
+       menuOffset = offset + position;
 }
 
 
@@ -121,23 +119,19 @@ void SelectAttackType::HandleEvents(const Input &input) {
        }
 }
 
-void SelectAttackType::UpdateWorld(float deltaT) {
+void SelectAttackType::UpdateWorld(Uint32 deltaT) {
 
 }
 
 void SelectAttackType::Render(SDL_Surface *screen) {
-       Vector<int> offset(battle->CalculateScreenOffset(screen));
-       battle->RenderBackground(screen, offset);
-       battle->RenderMonsters(screen, offset);
-       battle->RenderHeroTags(screen, offset);
-       RenderMenu(screen, offset);
+       battle->RenderBackground(screen);
+       battle->RenderMonsters(screen);
+       battle->RenderHeroTags(screen);
+       RenderMenu(screen);
 }
 
-void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
-       Vector<int> position(
-                       (battle->Width() - battle->GetAttackTypeMenu().Width()) / 2,
-                       battle->Height() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2);
-       battle->GetAttackTypeMenu().Render(screen, position + offset);
+void SelectAttackType::RenderMenu(SDL_Surface *screen) {
+       battle->GetAttackTypeMenu().Render(screen, menuOffset);
 }
 
 }