4 * Created on: Oct 21, 2012
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"
21 using common::GameConfig;
22 using geometry::Vector;
26 PartyMenu::PartyMenu(GameConfig *game)
28 for (int i(0); i < 4; ++i) {
29 status[i].SetHero(game->state->party[i]);
30 status[i].SetResources(game->menuResources);
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()));
37 PartyMenu::~PartyMenu() {
42 void PartyMenu::OnEnterState(SDL_Surface *) {
46 void PartyMenu::OnExitState(SDL_Surface *) {
50 void PartyMenu::OnResumeState(SDL_Surface *) {
54 void PartyMenu::OnPauseState(SDL_Surface *) {
59 void PartyMenu::OnResize(int width, int height) {
64 void PartyMenu::HandleEvents(const Input &input) {
65 if (input.JustPressed(Input::ACTION_B)) {
71 void PartyMenu::UpdateWorld(float deltaT) {
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));
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);
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());
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());
97 Resources &PartyMenu::Res() {
98 return *game->menuResources;
101 const Resources &PartyMenu::Res() const {
102 return *game->menuResources;