1 #include "SelectMoveAction.h"
4 #include "SelectAttackType.h"
5 #include "SwapHeroes.h"
6 #include "../BattleState.h"
7 #include "../MoveMenu.h"
8 #include "../../app/Application.h"
9 #include "../../app/Input.h"
10 #include "../../math/Vector.h"
12 using app::Application;
18 SelectMoveAction::SelectMoveAction(Battle *battle, BattleState *parent)
25 void SelectMoveAction::OnEnterState(SDL_Surface *screen) {
26 OnResize(screen->w, screen->h);
29 void SelectMoveAction::OnExitState(SDL_Surface *screen) {
33 void SelectMoveAction::OnResumeState(SDL_Surface *screen) {
37 void SelectMoveAction::OnPauseState(SDL_Surface *screen) {
42 void SelectMoveAction::OnResize(int width, int height) {
43 position = parent->ScreenOffset() + Vector<int>(
44 (parent->Width() - parent->GetMoveMenu().Width()) / 2,
45 parent->Height() - parent->GetMoveMenu().Height() - parent->GetMoveMenu().Height() / 2);
49 void SelectMoveAction::HandleEvents(const Input &input) {
50 if (input.IsDown(Input::PAD_UP)) {
51 parent->GetMoveMenu().Select(MoveMenu::CHANGE);
52 } else if (input.IsDown(Input::PAD_DOWN)) {
53 parent->GetMoveMenu().Select(MoveMenu::RUN);
55 parent->GetMoveMenu().Select(MoveMenu::ATTACK);
58 if (input.JustPressed(Input::ACTION_A)) {
59 switch (parent->GetMoveMenu().Selected()) {
60 case MoveMenu::ATTACK:
61 Ctrl().ChangeState(new SelectAttackType(battle, parent));
64 case MoveMenu::CHANGE:
65 Ctrl().PushState(new SwapHeroes(battle, this));
68 Ctrl().ChangeState(new RunState(parent));
74 void SelectMoveAction::UpdateWorld(Uint32 deltaT) {
78 void SelectMoveAction::Render(SDL_Surface *screen) {
79 parent->RenderBackground(screen);
80 parent->RenderMonsters(screen);
81 parent->RenderHeroTags(screen);
85 void SelectMoveAction::RenderMenu(SDL_Surface *screen) {
86 parent->GetMoveMenu().Render(screen, position);
90 const Resources &SelectMoveAction::Res() const {
94 const Vector<int> &SelectMoveAction::ScreenOffset() const {
95 return parent->ScreenOffset();
98 const HeroTag &SelectMoveAction::HeroTagAt(int index) const {
99 return parent->HeroTagAt(index);
102 const Vector<int> &SelectMoveAction::HeroTagPositionAt(int index) const {
103 return parent->HeroTagPositionAt(index);