From: Daniel Karbach Date: Thu, 29 Nov 2012 13:34:42 +0000 (+0100) Subject: added basic config menu X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=1852ed1ca9ccfb63183fec12efeeaccc211a9f72;p=l2e.git added basic config menu --- diff --git a/src/main.cpp b/src/main.cpp index 22a354e..68446d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -441,6 +441,28 @@ int main(int argc, char **argv) { menuResources.equipMenuRemoveAllLabel = "REMOVE ALL"; menuResources.equipMenuDropLabel = "DROP"; + graphics::MenuProperties configMenuProperties; + configMenuProperties.cols = 1; + configMenuProperties.rows = 4; + configMenuProperties.charsPerEntry = 8; + configMenuProperties.rowGap = 32; + configMenuProperties.cursor = &menuCursor; + configMenuProperties.font = &menuFont; + configMenuProperties.wrapY = true; + menuResources.configMenuProperties = &configMenuProperties; + + menuResources.configMessageSpeedLabel = "MESSAGE\n SPEED"; + menuResources.configMessageSpeedFast = "FAST"; + menuResources.configMessageSpeedNormal = "NORMAL"; + menuResources.configMessageSpeedSlow = "SLOW"; + menuResources.configBattleCursorLabel = "BATTLE\n CURSOR"; + menuResources.configStatusCursorLabel = "STATUS\n CURSOR"; + menuResources.configCursorClear = "CLEAR"; + menuResources.configCursorMemory = "MEMORY"; + menuResources.configMusicLabel = "MUSIC"; + menuResources.configMusicStereo = "STEREO"; + menuResources.configMusicMono = "MONO"; + InitScreen screen(width, height); app::State *state(0); diff --git a/src/menu/ConfigMenu.cpp b/src/menu/ConfigMenu.cpp index 1e27973..62eed32 100644 --- a/src/menu/ConfigMenu.cpp +++ b/src/menu/ConfigMenu.cpp @@ -22,8 +22,12 @@ using graphics::Frame; namespace menu { ConfigMenu::ConfigMenu(PartyMenu *parent) -: parent(parent) { - +: parent(parent) +, configMenu(*parent->Res().configMenuProperties) { + configMenu.Add(parent->Res().configMessageSpeedLabel, 0); + configMenu.Add(parent->Res().configBattleCursorLabel, 1); + configMenu.Add(parent->Res().configStatusCursorLabel, 2); + configMenu.Add(parent->Res().configMusicLabel, 3); } @@ -62,6 +66,12 @@ void ConfigMenu::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_B)) { Ctrl().PopState(); } + if (input.JustPressed(Input::PAD_DOWN)) { + configMenu.NextRow(); + } + if (input.JustPressed(Input::PAD_UP)) { + configMenu.PreviousRow(); + } } void ConfigMenu::UpdateWorld(float deltaT) { @@ -94,8 +104,11 @@ void ConfigMenu::RenderHeadline(SDL_Surface *screen, const geometry::Vector void ConfigMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector &offset) const { const Font &font(*parent->Res().normalFont); const Frame &frame(*parent->Res().statusFrame); + const Vector menuOffset( + 3 * font.CharWidth(), 2 * font.CharHeight()); frame.Draw(screen, offset, 30 * font.CharWidth(), 14 * font.CharHeight()); + configMenu.Draw(screen, offset + menuOffset); } } diff --git a/src/menu/ConfigMenu.h b/src/menu/ConfigMenu.h index c3f96f0..8bb81f4 100644 --- a/src/menu/ConfigMenu.h +++ b/src/menu/ConfigMenu.h @@ -11,6 +11,7 @@ #include "fwd.h" #include "../app/State.h" #include "../geometry/Vector.h" +#include "../graphics/Menu.h" namespace menu { @@ -42,6 +43,7 @@ private: private: PartyMenu *parent; + graphics::Menu configMenu; }; diff --git a/src/menu/Resources.cpp b/src/menu/Resources.cpp index 8b36b25..14158f3 100644 --- a/src/menu/Resources.cpp +++ b/src/menu/Resources.cpp @@ -72,7 +72,20 @@ Resources::Resources() , equipMenuStrongestLabel(0) , equipMenuRemoveLabel(0) , equipMenuRemoveAllLabel(0) -, equipMenuDropLabel(0) { +, equipMenuDropLabel(0) + +, configMenuProperties(0) +, configMessageSpeedLabel(0) +, configMessageSpeedFast(0) +, configMessageSpeedNormal(0) +, configMessageSpeedSlow(0) +, configBattleCursorLabel(0) +, configStatusCursorLabel(0) +, configCursorClear(0) +, configCursorMemory(0) +, configMusicLabel(0) +, configMusicStereo(0) +, configMusicMono(0) { } diff --git a/src/menu/Resources.h b/src/menu/Resources.h index acc99ad..8778cb5 100644 --- a/src/menu/Resources.h +++ b/src/menu/Resources.h @@ -79,6 +79,19 @@ struct Resources { const char *equipMenuRemoveAllLabel; const char *equipMenuDropLabel; + graphics::MenuProperties *configMenuProperties; + const char *configMessageSpeedLabel; + const char *configMessageSpeedFast; + const char *configMessageSpeedNormal; + const char *configMessageSpeedSlow; + const char *configBattleCursorLabel; + const char *configStatusCursorLabel; + const char *configCursorClear; + const char *configCursorMemory; + const char *configMusicLabel; + const char *configMusicStereo; + const char *configMusicMono; + Resources(); };