]> git.localhorst.tv Git - l2e.git/commitdiff
added capsule change menu stub
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 5 Dec 2012 19:55:47 +0000 (20:55 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 5 Dec 2012 19:55:47 +0000 (20:55 +0100)
l2e.cbp
src/menu/CapsuleChangeMenu.cpp [new file with mode: 0644]
src/menu/CapsuleChangeMenu.h [new file with mode: 0644]
src/menu/CapsuleMenu.cpp
src/menu/fwd.h

diff --git a/l2e.cbp b/l2e.cbp
index f0f5b2f8c886ae49e2ac5a08461b89a390ba5aae..98e7ee16832b0180c72a3fb5eba645e8e985af26 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\CapsuleChangeMenu.cpp" />
+               <Unit filename="src\menu\CapsuleChangeMenu.h" />
+               <Unit filename="src\menu\CapsuleFeedMenu.cpp" />
+               <Unit filename="src\menu\CapsuleFeedMenu.h" />
                <Unit filename="src\menu\CapsuleMenu.cpp" />
                <Unit filename="src\menu\CapsuleMenu.h" />
                <Unit filename="src\menu\ChangeHero.cpp" />
diff --git a/src/menu/CapsuleChangeMenu.cpp b/src/menu/CapsuleChangeMenu.cpp
new file mode 100644 (file)
index 0000000..3b161ad
--- /dev/null
@@ -0,0 +1,97 @@
+#include "CapsuleChangeMenu.h"
+
+#include "CapsuleMenu.h"
+#include "Resources.h"
+#include "../app/Application.h"
+#include "../app/Input.h"
+#include "../common/Inventory.h"
+#include "../common/Item.h"
+#include "../common/GameConfig.h"
+#include "../common/GameState.h"
+#include "../graphics/Font.h"
+#include "../graphics/Frame.h"
+
+using app::Input;
+using common::Capsule;
+using common::Inventory;
+using common::Item;
+using geometry::Vector;
+using graphics::Font;
+using graphics::Frame;
+
+namespace menu {
+
+CapsuleChangeMenu::CapsuleChangeMenu(CapsuleMenu *parent)
+: parent(parent) {
+
+}
+
+
+void CapsuleChangeMenu::OnEnterState(SDL_Surface *) {
+
+}
+
+void CapsuleChangeMenu::OnExitState(SDL_Surface *) {
+
+}
+
+void CapsuleChangeMenu::OnResumeState(SDL_Surface *) {
+
+}
+
+void CapsuleChangeMenu::OnPauseState(SDL_Surface *) {
+
+}
+
+
+void CapsuleChangeMenu::OnResize(int width, int height) {
+
+}
+
+
+void CapsuleChangeMenu::HandleEvents(const Input &input) {
+       if (input.JustPressed(Input::ACTION_B)) {
+               Ctrl().PopState();
+       }
+}
+
+void CapsuleChangeMenu::UpdateWorld(float deltaT) {
+
+}
+
+void CapsuleChangeMenu::Render(SDL_Surface *screen) {
+       const Font &font(*parent->Res().statusFont);
+       const Vector<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
+       const Vector<int> capsuleOffset(
+                       6 * font.CharWidth(),
+                       12 * font.CharHeight());
+       const Vector<int> infoOffset(
+                       12 * font.CharWidth(),
+                       2 * font.CharHeight() - font.CharHeight() / 8);
+       // TODO: wheel offset: top left, center, or center bottom?
+       const Vector<int> wheelOffset;
+       const Vector<int> menuOffset(
+                               font.CharWidth(),
+                               24 * font.CharHeight() - font.CharHeight() / 8);
+
+       parent->RenderBackground(screen);
+       parent->RenderCapsule(screen, offset + capsuleOffset);
+       parent->RenderInfo(screen, offset + infoOffset);
+       parent->RenderWheel(screen, offset + wheelOffset);
+       parent->RenderMenu(screen, offset + menuOffset);
+}
+
+
+int CapsuleChangeMenu::Width() const {
+       return parent->Width();
+}
+
+int CapsuleChangeMenu::Height() const {
+       return parent->Height();
+}
+
+const Capsule &CapsuleChangeMenu::GetCapsule() const {
+       return parent->GetCapsule();
+}
+
+}
diff --git a/src/menu/CapsuleChangeMenu.h b/src/menu/CapsuleChangeMenu.h
new file mode 100644 (file)
index 0000000..3727813
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef MENU_CAPSULECHANGEMENU_H_
+#define MENU_CAPSULECHANGEMENU_H_
+
+#include "fwd.h"
+#include "../app/State.h"
+#include "../common/fwd.h"
+#include "../geometry/Vector.h"
+
+namespace menu {
+
+class CapsuleMenu;
+
+class CapsuleChangeMenu
+: public app::State {
+
+public:
+       explicit CapsuleChangeMenu(CapsuleMenu *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 LoadInventory();
+
+private:
+       CapsuleMenu *parent;
+
+};
+
+}
+
+#endif /* MENU_CAPSULECHANGEMENU_H_ */
index 6d0fba8f0a68a3b518428d557e3df494e8f29379..22d0ad7129b757606ab580e55f1d0cb7844d057d 100644 (file)
@@ -1,5 +1,6 @@
 #include "CapsuleMenu.h"
 
+#include "CapsuleChangeMenu.h"
 #include "CapsuleFeedMenu.h"
 #include "PartyMenu.h"
 #include "Resources.h"
@@ -68,7 +69,7 @@ void CapsuleMenu::HandleEvents(const Input &input) {
                                menu.SetSelected();
                                break;
                        case CHOICE_CHANGE:
-                               // push change menu
+                               Ctrl().PushState(new CapsuleChangeMenu(this));
                                menu.SetSelected();
                                break;
                        case CHOICE_NAME:
index 15e0f83b7bedf492332329168a65bfc48f3b33e4..1a3460b100be2be7ce78ca93a11ed9d7c2b85bc0 100644 (file)
@@ -3,6 +3,7 @@
 
 namespace menu {
 
+class CapsuleChangeMenu;
 class CapsuleFeedMenu;
 class CapsuleMenu;
 class ChangeHero;