]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/ConfigMenu.cpp
renamed namespace geometry -> math
[l2e.git] / src / menu / ConfigMenu.cpp
index 62eed325d0ff33b40ebe2b1d29bf3e714fc64d43..e96c76bad7351226cc75e5bddaa96354f42095e6 100644 (file)
@@ -1,21 +1,17 @@
-/*
- * ConfigMenu.cpp
- *
- *  Created on: Nov 29, 2012
- *      Author: holy
- */
-
 #include "ConfigMenu.h"
 
 #include "PartyMenu.h"
 #include "Resources.h"
+#include "../app/Application.h"
+#include "../app/Input.h"
 #include "../common/GameConfig.h"
 #include "../common/GameState.h"
 #include "../graphics/Font.h"
 #include "../graphics/Frame.h"
 
 using app::Input;
-using geometry::Vector;
+using common::GameState;
+using math::Vector;
 using graphics::Font;
 using graphics::Frame;
 
@@ -72,6 +68,34 @@ void ConfigMenu::HandleEvents(const Input &input) {
        if (input.JustPressed(Input::PAD_UP)) {
                configMenu.PreviousRow();
        }
+
+       GameState &state(*parent->Game().state);
+       int *property(0);
+       int mod(0);
+       switch (configMenu.Selected()) {
+               case 0:
+                       property = &state.messageSpeed;
+                       mod = 3;
+                       break;
+               case 1:
+                       property = &state.battleCursor;
+                       mod = 2;
+                       break;
+               case 2:
+                       property = &state.statusCursor;
+                       mod = 2;
+                       break;
+               case 3:
+                       property = &state.music;
+                       mod = 2;
+                       break;
+       }
+       if (input.JustPressed(Input::ACTION_A) || input.JustPressed(Input::PAD_RIGHT)) {
+               *property = (*property + 1) % mod;
+       }
+       if (input.JustPressed(Input::PAD_LEFT)) {
+               *property = (*property + mod - 1) % mod;
+       }
 }
 
 void ConfigMenu::UpdateWorld(float deltaT) {
@@ -91,7 +115,7 @@ void ConfigMenu::Render(SDL_Surface *screen) {
        RenderMenu(screen, offset + menuOffset);
 }
 
-void ConfigMenu::RenderHeadline(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
+void ConfigMenu::RenderHeadline(SDL_Surface *screen, const math::Vector<int> &offset) const {
        const Font &font(*parent->Res().normalFont);
        const Frame &frame(*parent->Res().statusFrame);
        const Vector<int> textOffset(
@@ -101,14 +125,90 @@ void ConfigMenu::RenderHeadline(SDL_Surface *screen, const geometry::Vector<int>
        font.DrawString(parent->Res().mainMenuConfigText, screen, offset + textOffset, 6);
 }
 
-void ConfigMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
-       const Font &font(*parent->Res().normalFont);
-       const Frame &frame(*parent->Res().statusFrame);
+void ConfigMenu::RenderMenu(SDL_Surface *screen, const math::Vector<int> &offset) const {
+       const Resources &res(parent->Res());
+       const Font &font(*res.normalFont);
+       const Font &inactiveFont(*res.inactiveFont);
+       const Frame &frame(*res.statusFrame);
+       const GameState &state(*parent->Game().state);
        const Vector<int> menuOffset(
                        3 * font.CharWidth(), 2 * font.CharHeight());
 
        frame.Draw(screen, offset, 30 * font.CharWidth(), 14 * font.CharHeight());
        configMenu.Draw(screen, offset + menuOffset);
+
+       Vector<int> lineOffset(
+                       menuOffset.X() + configMenu.Width() + 2 * font.CharWidth(),
+                       menuOffset.Y());
+       Vector<int> colOffset(lineOffset);
+
+       if (state.messageSpeed == GameState::MESSAGE_SPEED_FAST) {
+               font.DrawString(res.configMessageSpeedFast, screen, offset + colOffset);
+               colOffset.X() += font.StringWidth(res.configMessageSpeedFast) + font.CharWidth();
+       } else {
+               inactiveFont.DrawString(res.configMessageSpeedFast, screen, offset + colOffset);
+               colOffset.X() += inactiveFont.StringWidth(res.configMessageSpeedFast) + inactiveFont.CharWidth();
+       }
+       if (state.messageSpeed == GameState::MESSAGE_SPEED_NORMAL) {
+               font.DrawString(res.configMessageSpeedNormal, screen, offset + colOffset);
+               colOffset.X() += font.StringWidth(res.configMessageSpeedNormal) + font.CharWidth();
+       } else {
+               inactiveFont.DrawString(res.configMessageSpeedNormal, screen, offset + colOffset);
+               colOffset.X() += inactiveFont.StringWidth(res.configMessageSpeedNormal) + inactiveFont.CharWidth();
+       }
+       if (state.messageSpeed == GameState::MESSAGE_SPEED_SLOW) {
+               font.DrawString(res.configMessageSpeedSlow, screen, offset + colOffset);
+       } else {
+               inactiveFont.DrawString(res.configMessageSpeedSlow, screen, offset + colOffset);
+       }
+
+       lineOffset.Y() += configMenu.RowHeight();
+       colOffset = lineOffset;
+
+       if (state.battleCursor == GameState::CURSOR_CLEAR) {
+               font.DrawString(res.configCursorClear, screen, offset + colOffset);
+               colOffset.X() += font.StringWidth(res.configCursorClear) + 2 * font.CharWidth();
+       } else {
+               inactiveFont.DrawString(res.configCursorClear, screen, offset + colOffset);
+               colOffset.X() += inactiveFont.StringWidth(res.configCursorClear) + 2 * inactiveFont.CharWidth();
+       }
+       if (state.battleCursor == GameState::CURSOR_MEMORY) {
+               font.DrawString(res.configCursorMemory, screen, offset + colOffset);
+       } else {
+               inactiveFont.DrawString(res.configCursorMemory, screen, offset + colOffset);
+       }
+
+       lineOffset.Y() += configMenu.RowHeight();
+       colOffset = lineOffset;
+
+       if (state.statusCursor == GameState::CURSOR_CLEAR) {
+               font.DrawString(res.configCursorClear, screen, offset + colOffset);
+               colOffset.X() += font.StringWidth(res.configCursorClear) + 2 * font.CharWidth();
+       } else {
+               inactiveFont.DrawString(res.configCursorClear, screen, offset + colOffset);
+               colOffset.X() += inactiveFont.StringWidth(res.configCursorClear) + 2 * inactiveFont.CharWidth();
+       }
+       if (state.statusCursor == GameState::CURSOR_MEMORY) {
+               font.DrawString(res.configCursorMemory, screen, offset + colOffset);
+       } else {
+               inactiveFont.DrawString(res.configCursorMemory, screen, offset + colOffset);
+       }
+
+       lineOffset.Y() += configMenu.RowHeight();
+       colOffset = lineOffset;
+
+       if (state.music == GameState::MUSIC_STEREO) {
+               font.DrawString(res.configMusicStereo, screen, offset + colOffset);
+               colOffset.X() += font.StringWidth(res.configMusicStereo) + font.CharWidth();
+       } else {
+               inactiveFont.DrawString(res.configMusicStereo, screen, offset + colOffset);
+               colOffset.X() += inactiveFont.StringWidth(res.configMusicStereo) + inactiveFont.CharWidth();
+       }
+       if (state.music == GameState::MUSIC_MONO) {
+               font.DrawString(res.configMusicMono, screen, offset + colOffset);
+       } else {
+               inactiveFont.DrawString(res.configMusicMono, screen, offset + colOffset);
+       }
 }
 
 }