]> git.localhorst.tv Git - l2e.git/blob - src/battle/states/SelectMoveAction.cpp
converted equipment from explicit members to array
[l2e.git] / src / battle / states / SelectMoveAction.cpp
1 /*
2  * SelectMoveAction.cpp
3  *
4  *  Created on: Aug 7, 2012
5  *      Author: holy
6  */
7
8 #include "SelectMoveAction.h"
9
10 #include "RunState.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"
17
18 using app::Application;
19 using app::Input;
20 using geometry::Vector;
21
22 namespace battle {
23
24 void SelectMoveAction::OnEnterState(SDL_Surface *screen) {
25
26 }
27
28 void SelectMoveAction::OnExitState(SDL_Surface *screen) {
29
30 }
31
32 void SelectMoveAction::OnResumeState(SDL_Surface *screen) {
33
34 }
35
36 void SelectMoveAction::OnPauseState(SDL_Surface *screen) {
37
38 }
39
40
41 void SelectMoveAction::OnResize(int width, int height) {
42
43 }
44
45
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);
51         } else {
52                 battle->GetMoveMenu().Select(MoveMenu::ATTACK);
53         }
54
55         if (input.JustPressed(Input::ACTION_A)) {
56                 switch (battle->GetMoveMenu().Selected()) {
57                         case MoveMenu::ATTACK:
58                                 Ctrl().ChangeState(new SelectAttackType(battle));
59                                 battle->NextHero();
60                                 break;
61                         case MoveMenu::CHANGE:
62                                 Ctrl().PushState(new SwapHeroes(battle, this));
63                                 break;
64                         case MoveMenu::RUN:
65                                 Ctrl().ChangeState(new RunState(battle));
66                                 break;
67                 }
68         }
69 }
70
71 void SelectMoveAction::UpdateWorld(float deltaT) {
72
73 }
74
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);
81 }
82
83 void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
84         Vector<int> position(
85                         (battle->Width() - battle->GetMoveMenu().Width()) / 2,
86                         battle->Height() - battle->GetMoveMenu().Height() - battle->GetMoveMenu().Height() / 2);
87         battle->GetMoveMenu().Render(screen, position + offset);
88 }
89
90 }