From a47b25a3a6631c8136fec6585a92b8756c68d243 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Thu, 29 Nov 2012 13:56:31 +0100 Subject: [PATCH] added config menu dummy --- src/menu/ConfigMenu.cpp | 101 ++++++++++++++++++++++++++++++++++++++++ src/menu/ConfigMenu.h | 50 ++++++++++++++++++++ src/menu/PartyMenu.cpp | 2 + src/menu/fwd.h | 1 + 4 files changed, 154 insertions(+) create mode 100644 src/menu/ConfigMenu.cpp create mode 100644 src/menu/ConfigMenu.h diff --git a/src/menu/ConfigMenu.cpp b/src/menu/ConfigMenu.cpp new file mode 100644 index 0000000..1e27973 --- /dev/null +++ b/src/menu/ConfigMenu.cpp @@ -0,0 +1,101 @@ +/* + * ConfigMenu.cpp + * + * Created on: Nov 29, 2012 + * Author: holy + */ + +#include "ConfigMenu.h" + +#include "PartyMenu.h" +#include "Resources.h" +#include "../common/GameConfig.h" +#include "../common/GameState.h" +#include "../graphics/Font.h" +#include "../graphics/Frame.h" + +using app::Input; +using geometry::Vector; +using graphics::Font; +using graphics::Frame; + +namespace menu { + +ConfigMenu::ConfigMenu(PartyMenu *parent) +: parent(parent) { + +} + + +void ConfigMenu::OnEnterState(SDL_Surface *) { + +} + +void ConfigMenu::OnExitState(SDL_Surface *) { + +} + +void ConfigMenu::OnResumeState(SDL_Surface *) { + +} + +void ConfigMenu::OnPauseState(SDL_Surface *) { + +} + + +void ConfigMenu::OnResize(int width, int height) { + +} + + +int ConfigMenu::Width() const { + return parent->Width(); +} + +int ConfigMenu::Height() const { + return parent->Height(); +} + + +void ConfigMenu::HandleEvents(const Input &input) { + if (input.JustPressed(Input::ACTION_B)) { + Ctrl().PopState(); + } +} + +void ConfigMenu::UpdateWorld(float deltaT) { + +} + +void ConfigMenu::Render(SDL_Surface *screen) { + const Font &font(*parent->Res().normalFont); + const Vector offset((screen->w - Width()) / 2, (screen->h - Height()) / 2); + const Vector headlineOffset( + font.CharWidth(), 2 * font.CharHeight() - font.CharHeight() / 8); + const Vector menuOffset( + font.CharWidth(), 5 * font.CharHeight() - font.CharHeight() / 8); + + parent->RenderBackground(screen); + RenderHeadline(screen, offset + headlineOffset); + RenderMenu(screen, offset + menuOffset); +} + +void ConfigMenu::RenderHeadline(SDL_Surface *screen, const geometry::Vector &offset) const { + const Font &font(*parent->Res().normalFont); + const Frame &frame(*parent->Res().statusFrame); + const Vector textOffset( + 2 * font.CharWidth(), font.CharHeight()); + + frame.Draw(screen, offset, 10 * font.CharWidth(), 3 * font.CharHeight()); + font.DrawString(parent->Res().mainMenuConfigText, screen, offset + textOffset, 6); +} + +void ConfigMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector &offset) const { + const Font &font(*parent->Res().normalFont); + const Frame &frame(*parent->Res().statusFrame); + + frame.Draw(screen, offset, 30 * font.CharWidth(), 14 * font.CharHeight()); +} + +} diff --git a/src/menu/ConfigMenu.h b/src/menu/ConfigMenu.h new file mode 100644 index 0000000..c3f96f0 --- /dev/null +++ b/src/menu/ConfigMenu.h @@ -0,0 +1,50 @@ +/* + * ConfigMenu.h + * + * Created on: Nov 29, 2012 + * Author: holy + */ + +#ifndef MENU_CONFIGMENU_H_ +#define MENU_CONFIGMENU_H_ + +#include "fwd.h" +#include "../app/State.h" +#include "../geometry/Vector.h" + +namespace menu { + +class ConfigMenu +: public app::State { + +public: + explicit ConfigMenu(PartyMenu *parent); + +public: + virtual void HandleEvents(const app::Input &); + virtual void UpdateWorld(float deltaT); + virtual void Render(SDL_Surface *); + +public: + int Width() const; + int Height() const; + +private: + virtual void OnEnterState(SDL_Surface *screen); + virtual void OnExitState(SDL_Surface *screen); + virtual void OnResumeState(SDL_Surface *screen); + virtual void OnPauseState(SDL_Surface *screen); + + virtual void OnResize(int width, int height); + + void RenderHeadline(SDL_Surface *screen, const geometry::Vector &offset) const; + void RenderMenu(SDL_Surface *screen, const geometry::Vector &offset) const; + +private: + PartyMenu *parent; + +}; + +} + +#endif /* MENU_CONFIGMENU_H_ */ diff --git a/src/menu/PartyMenu.cpp b/src/menu/PartyMenu.cpp index bda6331..99e86d1 100644 --- a/src/menu/PartyMenu.cpp +++ b/src/menu/PartyMenu.cpp @@ -8,6 +8,7 @@ #include "PartyMenu.h" #include "ChangeHero.h" +#include "ConfigMenu.h" #include "EquipMenu.h" #include "InventoryMenu.h" #include "Resources.h" @@ -114,6 +115,7 @@ void PartyMenu::HandleEvents(const Input &input) { Ctrl().PushState(new ChangeHero(this)); break; case MENU_ITEM_CONFIG: + Ctrl().PushState(new ConfigMenu(this)); break; case MENU_ITEM_SCENARIO: break; diff --git a/src/menu/fwd.h b/src/menu/fwd.h index 40d0163..b0ad85a 100644 --- a/src/menu/fwd.h +++ b/src/menu/fwd.h @@ -11,6 +11,7 @@ namespace menu { class ChangeHero; +class ConfigMenu; class EquipMenu; class HeroStatus; class InventoryMenu; -- 2.39.2