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)
26 , configMenu(*parent->Res().configMenuProperties) {
27 configMenu.Add(parent->Res().configMessageSpeedLabel, 0);
28 configMenu.Add(parent->Res().configBattleCursorLabel, 1);
29 configMenu.Add(parent->Res().configStatusCursorLabel, 2);
30 configMenu.Add(parent->Res().configMusicLabel, 3);
34 void ConfigMenu::OnEnterState(SDL_Surface *) {
38 void ConfigMenu::OnExitState(SDL_Surface *) {
42 void ConfigMenu::OnResumeState(SDL_Surface *) {
46 void ConfigMenu::OnPauseState(SDL_Surface *) {
51 void ConfigMenu::OnResize(int width, int height) {
56 int ConfigMenu::Width() const {
57 return parent->Width();
60 int ConfigMenu::Height() const {
61 return parent->Height();
65 void ConfigMenu::HandleEvents(const Input &input) {
66 if (input.JustPressed(Input::ACTION_B)) {
69 if (input.JustPressed(Input::PAD_DOWN)) {
72 if (input.JustPressed(Input::PAD_UP)) {
73 configMenu.PreviousRow();
77 void ConfigMenu::UpdateWorld(float deltaT) {
81 void ConfigMenu::Render(SDL_Surface *screen) {
82 const Font &font(*parent->Res().normalFont);
83 const Vector<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
84 const Vector<int> headlineOffset(
85 font.CharWidth(), 2 * font.CharHeight() - font.CharHeight() / 8);
86 const Vector<int> menuOffset(
87 font.CharWidth(), 5 * font.CharHeight() - font.CharHeight() / 8);
89 parent->RenderBackground(screen);
90 RenderHeadline(screen, offset + headlineOffset);
91 RenderMenu(screen, offset + menuOffset);
94 void ConfigMenu::RenderHeadline(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
95 const Font &font(*parent->Res().normalFont);
96 const Frame &frame(*parent->Res().statusFrame);
97 const Vector<int> textOffset(
98 2 * font.CharWidth(), font.CharHeight());
100 frame.Draw(screen, offset, 10 * font.CharWidth(), 3 * font.CharHeight());
101 font.DrawString(parent->Res().mainMenuConfigText, screen, offset + textOffset, 6);
104 void ConfigMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
105 const Font &font(*parent->Res().normalFont);
106 const Frame &frame(*parent->Res().statusFrame);
107 const Vector<int> menuOffset(
108 3 * font.CharWidth(), 2 * font.CharHeight());
110 frame.Draw(screen, offset, 30 * font.CharWidth(), 14 * font.CharHeight());
111 configMenu.Draw(screen, offset + menuOffset);