4 * Created on: Nov 29, 2012
8 #include "ConfigMenu.h"
10 #include "PartyMenu.h"
11 #include "Resources.h"
12 #include "../common/GameConfig.h"
13 #include "../common/GameState.h"
14 #include "../graphics/Font.h"
15 #include "../graphics/Frame.h"
18 using geometry::Vector;
20 using graphics::Frame;
24 ConfigMenu::ConfigMenu(PartyMenu *parent)
30 void ConfigMenu::OnEnterState(SDL_Surface *) {
34 void ConfigMenu::OnExitState(SDL_Surface *) {
38 void ConfigMenu::OnResumeState(SDL_Surface *) {
42 void ConfigMenu::OnPauseState(SDL_Surface *) {
47 void ConfigMenu::OnResize(int width, int height) {
52 int ConfigMenu::Width() const {
53 return parent->Width();
56 int ConfigMenu::Height() const {
57 return parent->Height();
61 void ConfigMenu::HandleEvents(const Input &input) {
62 if (input.JustPressed(Input::ACTION_B)) {
67 void ConfigMenu::UpdateWorld(float deltaT) {
71 void ConfigMenu::Render(SDL_Surface *screen) {
72 const Font &font(*parent->Res().normalFont);
73 const Vector<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
74 const Vector<int> headlineOffset(
75 font.CharWidth(), 2 * font.CharHeight() - font.CharHeight() / 8);
76 const Vector<int> menuOffset(
77 font.CharWidth(), 5 * font.CharHeight() - font.CharHeight() / 8);
79 parent->RenderBackground(screen);
80 RenderHeadline(screen, offset + headlineOffset);
81 RenderMenu(screen, offset + menuOffset);
84 void ConfigMenu::RenderHeadline(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
85 const Font &font(*parent->Res().normalFont);
86 const Frame &frame(*parent->Res().statusFrame);
87 const Vector<int> textOffset(
88 2 * font.CharWidth(), font.CharHeight());
90 frame.Draw(screen, offset, 10 * font.CharWidth(), 3 * font.CharHeight());
91 font.DrawString(parent->Res().mainMenuConfigText, screen, offset + textOffset, 6);
94 void ConfigMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
95 const Font &font(*parent->Res().normalFont);
96 const Frame &frame(*parent->Res().statusFrame);
98 frame.Draw(screen, offset, 30 * font.CharWidth(), 14 * font.CharHeight());