4 * Created on: Aug 7, 2012
8 #include "SelectMoveAction.h"
11 #include "SelectAttackType.h"
12 #include "SwapHeroes.h"
13 #include "../BattleState.h"
14 #include "../MoveMenu.h"
15 #include "../../app/Application.h"
16 #include "../../app/Input.h"
18 using app::Application;
20 using geometry::Vector;
24 void SelectMoveAction::OnEnterState(SDL_Surface *screen) {
28 void SelectMoveAction::OnExitState(SDL_Surface *screen) {
32 void SelectMoveAction::OnResumeState(SDL_Surface *screen) {
36 void SelectMoveAction::OnPauseState(SDL_Surface *screen) {
41 void SelectMoveAction::OnResize(int width, int height) {
46 void SelectMoveAction::HandleEvents(const Input &input) {
47 if (input.IsDown(Input::PAD_UP)) {
48 battle->GetMoveMenu().Select(MoveMenu::CHANGE);
49 } else if (input.IsDown(Input::PAD_DOWN)) {
50 battle->GetMoveMenu().Select(MoveMenu::RUN);
52 battle->GetMoveMenu().Select(MoveMenu::ATTACK);
55 if (input.JustPressed(Input::ACTION_A)) {
56 switch (battle->GetMoveMenu().Selected()) {
57 case MoveMenu::ATTACK:
58 Ctrl().ChangeState(new SelectAttackType(battle));
61 case MoveMenu::CHANGE:
62 Ctrl().PushState(new SwapHeroes(battle, this));
65 Ctrl().ChangeState(new RunState(battle));
71 void SelectMoveAction::UpdateWorld(float deltaT) {
75 void SelectMoveAction::Render(SDL_Surface *screen) {
76 Vector<int> offset(battle->CalculateScreenOffset(screen));
77 battle->RenderBackground(screen, offset);
78 battle->RenderMonsters(screen, offset);
79 battle->RenderHeroTags(screen, offset);
80 RenderMenu(screen, offset);
83 void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
85 (battle->Width() - battle->GetMoveMenu().Width()) / 2,
86 battle->Height() - battle->GetMoveMenu().Height() - battle->GetMoveMenu().Height() / 2);
87 battle->GetMoveMenu().Render(screen, position + offset);