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/Texture.h"
20 using common::GameConfig;
21 using geometry::Vector;
25 PartyMenu::PartyMenu(GameConfig *game)
27 for (int i(0); i < 4; ++i) {
28 status[i].SetHero(game->state->party[i]);
29 status[i].SetResources(game->menuResources);
31 status[1].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), 0));
32 status[2].SetPosition(Vector<int>(0, status[0].Height() + Res().normalFont->CharHeight()));
33 status[3].SetPosition(Vector<int>(status[0].Width() + Res().normalFont->CharWidth(), status[0].Height() + Res().normalFont->CharHeight()));
36 PartyMenu::~PartyMenu() {
41 void PartyMenu::OnEnterState(SDL_Surface *) {
45 void PartyMenu::OnExitState(SDL_Surface *) {
49 void PartyMenu::OnResumeState(SDL_Surface *) {
53 void PartyMenu::OnPauseState(SDL_Surface *) {
58 void PartyMenu::OnResize(int width, int height) {
63 void PartyMenu::HandleEvents(const Input &input) {
64 if (input.JustPressed(Input::ACTION_B)) {
70 void PartyMenu::UpdateWorld(float deltaT) {
74 void PartyMenu::Render(SDL_Surface *screen) {
75 Res().menubg->Render(screen, Vector<int>(), Vector<int>(screen->w, screen->h));
76 RenderHeros(screen, Vector<int>());
79 void PartyMenu::RenderHeros(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
80 for (int i(0); i < 4; ++i) {
81 status[i].Render(screen, offset);
86 Resources &PartyMenu::Res() {
87 return *game->menuResources;
90 const Resources &PartyMenu::Res() const {
91 return *game->menuResources;