]> git.localhorst.tv Git - l2e.git/commitdiff
added capsule menu stub
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 4 Dec 2012 20:15:33 +0000 (21:15 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 4 Dec 2012 20:15:33 +0000 (21:15 +0100)
l2e.cbp
src/menu/CapsuleMenu.cpp [new file with mode: 0644]
src/menu/CapsuleMenu.h [new file with mode: 0644]
src/menu/PartyMenu.cpp
src/menu/Resources.cpp
src/menu/Resources.h
src/menu/fwd.h
test-data/capsulebg.png [new file with mode: 0644]
test-data/test.l2s

diff --git a/l2e.cbp b/l2e.cbp
index d3ab9a3cb48382c683e63742c73dddcaa3cd0c37..f0f5b2f8c886ae49e2ac5a08461b89a390ba5aae 100644 (file)
--- a/l2e.cbp
+++ b/l2e.cbp
                <Unit filename="src\map\Trigger.cpp" />
                <Unit filename="src\map\Trigger.h" />
                <Unit filename="src\map\fwd.h" />
+               <Unit filename="src\menu\CapsuleMenu.cpp" />
+               <Unit filename="src\menu\CapsuleMenu.h" />
                <Unit filename="src\menu\ChangeHero.cpp" />
                <Unit filename="src\menu\ChangeHero.h" />
                <Unit filename="src\menu\ConfigMenu.cpp" />
diff --git a/src/menu/CapsuleMenu.cpp b/src/menu/CapsuleMenu.cpp
new file mode 100644 (file)
index 0000000..c85091b
--- /dev/null
@@ -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<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
+
+       RenderBackground(screen);
+}
+
+void CapsuleMenu::RenderBackground(SDL_Surface *screen) const {
+       parent->Res().capsulebg->Render(screen, Vector<int>(), Vector<int>(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 (file)
index 0000000..ad20b25
--- /dev/null
@@ -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<int> menu;
+
+};
+
+}
+
+#endif /* MENU_CAPSULEMENU_H_ */
index 20a2a8ee567dd74b37734699f1577a71d42ca6d9..f3176b3f70981aa4fe66c942b3d4ea4bd9d6aa8c 100644 (file)
@@ -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));
index 79aecf6ea1f424df934a2118cf87631f46f908fa..9b725d04149fffb86160fbf43628b71070f2a1fb 100644 (file)
@@ -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) {
index 9ea26e665000270d0b024e7ef5eaa550cd9b07b3..47e46256f668fbcf2f8db6425c66c9908c059747 100644 (file)
@@ -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();
index 466e34b846ddddc7da6961d947adfef8b7d5070a..8f689ae8abda0d0eeb8dc32c4c50d0e1905d34e2 100644 (file)
@@ -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 (file)
index 0000000..884e33b
Binary files /dev/null and b/test-data/capsulebg.png differ
index 616249a26b677e07ee86566c8c6d8029814744cf..98553dff786bb759b0110353ed08f50ee677ef91 100644 (file)
@@ -698,6 +698,7 @@ export MenuResources menuResources {
                colGap: 32,
                cursor: menuCursor,
                font: menuFont,
+               disabledFont: menuInactiveFont,
                wrapX: true,
                wrapY: true
        },
@@ -836,5 +837,22 @@ export MenuResources menuResources {
                cursor: menuCursor,
                font: menuFont
        },
-       scenarioMenuHeadline: "SCENARIO ITEM"
+       scenarioMenuHeadline: "SCENARIO ITEM",
+       capsulebg: Texture {
+               image: :"capsulebg.png",
+               size: <64, 64>
+       },
+       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"
 }