]> git.localhorst.tv Git - l2e.git/blob - src/menu/PartyMenu.cpp
4949bfaa73453a546062bf121de197f287794077
[l2e.git] / src / menu / PartyMenu.cpp
1 /*
2  * PartyMenu.cpp
3  *
4  *  Created on: Oct 21, 2012
5  *      Author: holy
6  */
7
8 #include "PartyMenu.h"
9
10 #include "Resources.h"
11 #include "../app/Application.h"
12 #include "../app/Input.h"
13 #include "../common/GameConfig.h"
14 #include "../common/GameState.h"
15 #include "../geometry/Vector.h"
16 #include "../graphics/Font.h"
17 #include "../graphics/Frame.h"
18 #include "../graphics/Texture.h"
19
20 using app::Input;
21 using common::GameConfig;
22 using geometry::Vector;
23
24 namespace menu {
25
26 PartyMenu::PartyMenu(GameConfig *game)
27 : game(game) {
28         for (int i(0); i < 4; ++i) {
29                 status[i].SetHero(game->state->party[i]);
30                 status[i].SetResources(game->menuResources);
31         }
32         status[1].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), 0));
33         status[2].SetPosition(Vector<int>(0, status[0].Height() + Res().normalFont->CharHeight()));
34         status[3].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), status[0].Height() + Res().normalFont->CharHeight()));
35 }
36
37 PartyMenu::~PartyMenu() {
38
39 }
40
41
42 void PartyMenu::OnEnterState(SDL_Surface *) {
43
44 }
45
46 void PartyMenu::OnExitState(SDL_Surface *) {
47
48 }
49
50 void PartyMenu::OnResumeState(SDL_Surface *) {
51
52 }
53
54 void PartyMenu::OnPauseState(SDL_Surface *) {
55
56 }
57
58
59 void PartyMenu::OnResize(int width, int height) {
60
61 }
62
63
64 void PartyMenu::HandleEvents(const Input &input) {
65         if (input.JustPressed(Input::ACTION_B)) {
66                 Ctrl().PopState();
67                 return;
68         }
69 }
70
71 void PartyMenu::UpdateWorld(float deltaT) {
72
73 }
74
75 void PartyMenu::Render(SDL_Surface *screen) {
76         Res().menubg->Render(screen, Vector<int>(), Vector<int>(screen->w, screen->h));
77         RenderHeros(screen, Vector<int>(Res().normalFont->CharWidth(), 2 * Res().normalFont->CharHeight()));
78         RenderMenu(screen, Vector<int>(8 * Res().normalFont->CharWidth(), 13 * Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 8));
79         RenderInfo(screen, Vector<int>(14 * Res().normalFont->CharWidth(), 21 * Res().normalFont->CharHeight() + Res().normalFont->CharHeight() / 8));
80 }
81
82 void PartyMenu::RenderHeros(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
83         for (int i(0); i < 4; ++i) {
84                 status[i].Render(screen, offset);
85         }
86 }
87
88 void PartyMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
89         Res().statusFrame->Draw(screen, offset, 23 * Res().normalFont->CharWidth(), 8 * Res().normalFont->CharHeight());
90 }
91
92 void PartyMenu::RenderInfo(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
93         Res().statusFrame->Draw(screen, offset, 17 * Res().normalFont->CharWidth(), 5 * Res().normalFont->CharHeight());
94 }
95
96
97 Resources &PartyMenu::Res() {
98         return *game->menuResources;
99 }
100
101 const Resources &PartyMenu::Res() const {
102         return *game->menuResources;
103 }
104
105 }