From 10a8d3a83e7ad6815bc9f752922239ef32073a5e Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 4 Dec 2012 21:15:33 +0100 Subject: [PATCH] added capsule menu stub --- l2e.cbp | 2 + src/menu/CapsuleMenu.cpp | 86 +++++++++++++++++++++++++++++++++++++++ src/menu/CapsuleMenu.h | 47 +++++++++++++++++++++ src/menu/PartyMenu.cpp | 8 +++- src/menu/Resources.cpp | 28 +++++++++++++ src/menu/Resources.h | 14 +++++++ src/menu/fwd.h | 1 + test-data/capsulebg.png | Bin 0 -> 355 bytes test-data/test.l2s | 20 ++++++++- 9 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 src/menu/CapsuleMenu.cpp create mode 100644 src/menu/CapsuleMenu.h create mode 100644 test-data/capsulebg.png diff --git a/l2e.cbp b/l2e.cbp index d3ab9a3..f0f5b2f 100644 --- a/l2e.cbp +++ b/l2e.cbp @@ -190,6 +190,8 @@ + + diff --git a/src/menu/CapsuleMenu.cpp b/src/menu/CapsuleMenu.cpp new file mode 100644 index 0000000..c85091b --- /dev/null +++ b/src/menu/CapsuleMenu.cpp @@ -0,0 +1,86 @@ +#include "CapsuleMenu.h" + +#include "PartyMenu.h" +#include "Resources.h" +#include "../app/Application.h" +#include "../app/Input.h" +#include "../common/GameConfig.h" +#include "../common/GameState.h" +#include "../common/Stats.h" +#include "../graphics/Font.h" +#include "../graphics/Frame.h" +#include "../graphics/Texture.h" + +using app::Input; +using common::Capsule; +using common::Stats; +using geometry::Vector; +using graphics::Font; +using graphics::Frame; + +namespace menu { + +CapsuleMenu::CapsuleMenu(PartyMenu *parent) +: parent(parent) +, menu(*parent->Res().capsuleMenuProperties) { + menu.Add(parent->Res().capsuleFeedLabel, 0); + menu.Add(parent->Res().capsuleChangeLabel, 1); + menu.Add(parent->Res().capsuleNameLabel, 2); +} + + +void CapsuleMenu::OnEnterState(SDL_Surface *) { + +} + +void CapsuleMenu::OnExitState(SDL_Surface *) { + +} + +void CapsuleMenu::OnResumeState(SDL_Surface *) { + +} + +void CapsuleMenu::OnPauseState(SDL_Surface *) { + +} + + +void CapsuleMenu::OnResize(int width, int height) { + +} + + +void CapsuleMenu::HandleEvents(const Input &input) { + if (input.JustPressed(Input::ACTION_B)) { + Ctrl().PopState(); + } +} + +void CapsuleMenu::UpdateWorld(float deltaT) { + +} + +void CapsuleMenu::Render(SDL_Surface *screen) { + Vector offset((screen->w - Width()) / 2, (screen->h - Height()) / 2); + + RenderBackground(screen); +} + +void CapsuleMenu::RenderBackground(SDL_Surface *screen) const { + parent->Res().capsulebg->Render(screen, Vector(), Vector(screen->w, screen->h)); +} + +int CapsuleMenu::Width() const { + return parent->Width(); +} + +int CapsuleMenu::Height() const { + return parent->Height(); +} + +const Capsule &CapsuleMenu::GetCapsule() const { + return *parent->Game().state->capsule; +} + +} diff --git a/src/menu/CapsuleMenu.h b/src/menu/CapsuleMenu.h new file mode 100644 index 0000000..ad20b25 --- /dev/null +++ b/src/menu/CapsuleMenu.h @@ -0,0 +1,47 @@ +#ifndef MENU_CAPSULEMENU_H_ +#define MENU_CAPSULEMENU_H_ + +#include "fwd.h" +#include "../app/State.h" +#include "../common/fwd.h" +#include "../geometry/Vector.h" +#include "../graphics/Menu.h" + +namespace menu { + +class CapsuleMenu +: public app::State { + +public: + explicit CapsuleMenu(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); + + const common::Capsule &GetCapsule() const; + + void RenderBackground(SDL_Surface *screen) const; + +private: + PartyMenu *parent; + graphics::Menu menu; + +}; + +} + +#endif /* MENU_CAPSULEMENU_H_ */ diff --git a/src/menu/PartyMenu.cpp b/src/menu/PartyMenu.cpp index 20a2a8e..f3176b3 100644 --- a/src/menu/PartyMenu.cpp +++ b/src/menu/PartyMenu.cpp @@ -1,5 +1,6 @@ #include "PartyMenu.h" +#include "CapsuleMenu.h" #include "ChangeHero.h" #include "ConfigMenu.h" #include "EquipMenu.h" @@ -40,7 +41,7 @@ PartyMenu::PartyMenu(GameConfig *game) mainMenu.Add(Res().mainMenuStatusText, 4); mainMenu.Add(Res().mainMenuSpellText, 1); mainMenu.Add(Res().mainMenuChangeText, 5); - mainMenu.Add(Res().mainMenuCapsuleText, 2); + mainMenu.Add(Res().mainMenuCapsuleText, 2, game->state->capsule); mainMenu.Add(Res().mainMenuConfigText, 6); mainMenu.Add(Res().mainMenuEquipmentText, 3); mainMenu.Add(Res().mainMenuScenarioText, 7); @@ -98,6 +99,11 @@ void PartyMenu::HandleEvents(const Input &input) { Ctrl().PushState(new SelectHero(this, this, this, OnSpellSelect)); break; case MENU_ITEM_CAPSULE: + if (game->state->capsule) { + Ctrl().PushState(new CapsuleMenu(this)); + } else { + // noise and blur + } break; case MENU_ITEM_EQUIP: Ctrl().PushState(new SelectHero(this, this, this, OnEquipSelect)); diff --git a/src/menu/Resources.cpp b/src/menu/Resources.cpp index 79aecf6..9b725d0 100644 --- a/src/menu/Resources.cpp +++ b/src/menu/Resources.cpp @@ -98,6 +98,20 @@ Resources::Resources() , scenarioMenuProperties(0) , scenarioMenuHeadline(0) +, capsulebg(0) + +, capsuleMenuProperties(0) + +, capsuleFeedLabel(0) +, capsuleChangeLabel(0) +, capsuleNameLabel(0) +, capsuleClassLabel(0) +, capsuleAlignmentLabel(0) +, capsuleTribeLabel(0) +, capsuleAttack1Label(0) +, capsuleAttack2Label(0) +, capsuleAttack3Label(0) + { } @@ -185,6 +199,20 @@ void Resources::CreateTypeDescription() { td.AddField("scenarioMenu", FieldDescription(((char *)&r.scenarioMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the scenario menu")); td.AddField("scenarioMenuHeadline", FieldDescription(((char *)&r.scenarioMenuHeadline) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + + td.AddField("capsulebg", FieldDescription(((char *)&r.capsulebg) - ((char *)&r), Texture::TYPE_ID).SetReferenced().SetDescription("background texture for the capsule menus")); + + td.AddField("capsuleMenu", FieldDescription(((char *)&r.capsuleMenuProperties) - ((char *)&r), MenuProperties::TYPE_ID).SetReferenced().SetDescription("properties of the capsule main menu (the bottom bar)")); + + td.AddField("capsuleFeedLabel", FieldDescription(((char *)&r.capsuleFeedLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleChangeLabel", FieldDescription(((char *)&r.capsuleChangeLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleNameLabel", FieldDescription(((char *)&r.capsuleNameLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleClassLabel", FieldDescription(((char *)&r.capsuleClassLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleAlignmentLabel", FieldDescription(((char *)&r.capsuleAlignmentLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleTribeLabel", FieldDescription(((char *)&r.capsuleTribeLabel) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleAttack1Label", FieldDescription(((char *)&r.capsuleAttack1Label) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleAttack2Label", FieldDescription(((char *)&r.capsuleAttack2Label) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); + td.AddField("capsuleAttack3Label", FieldDescription(((char *)&r.capsuleAttack3Label) - ((char *)&r), Interpreter::STRING_ID).SetReferenced()); } void Resources::Construct(void *data) { diff --git a/src/menu/Resources.h b/src/menu/Resources.h index 9ea26e6..47e4625 100644 --- a/src/menu/Resources.h +++ b/src/menu/Resources.h @@ -88,6 +88,20 @@ struct Resources { graphics::MenuProperties *scenarioMenuProperties; const char *scenarioMenuHeadline; + graphics::Texture *capsulebg; + + graphics::MenuProperties *capsuleMenuProperties; + + const char *capsuleFeedLabel; + const char *capsuleChangeLabel; + const char *capsuleNameLabel; + const char *capsuleClassLabel; + const char *capsuleAlignmentLabel; + const char *capsuleTribeLabel; + const char *capsuleAttack1Label; + const char *capsuleAttack2Label; + const char *capsuleAttack3Label; + Resources(); static void CreateTypeDescription(); diff --git a/src/menu/fwd.h b/src/menu/fwd.h index 466e34b..8f689ae 100644 --- a/src/menu/fwd.h +++ b/src/menu/fwd.h @@ -3,6 +3,7 @@ namespace menu { +class CapsuleMenu; class ChangeHero; class ConfigMenu; class EquipMenu; diff --git a/test-data/capsulebg.png b/test-data/capsulebg.png new file mode 100644 index 0000000000000000000000000000000000000000..884e33b1a2ac4228fb2ea658fe4f5bd3a8add56a GIT binary patch literal 355 zcmV-p0i6DcP)_Cu| z1(L03cY!3OY$RI(lCJ + }, + capsuleMenu: MenuProperties { + cols: 3, + rows: 1 + }, + capsuleFeedLabel: "FEED", + capsuleChangeLabel: "CHANGE", + capsuleNameLabel: "NAME", + capsuleClassLabel: "CLASS", + capsuleAlignmentLabel: "ALI.", + capsuleTribeLabel: "TRIBE", + capsuleAttack1Label: "SP.1", + capsuleAttack2Label: "SP.2", + capsuleAttack3Label: "SP.3" } -- 2.39.2