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

diff --git a/l2e.cbp b/l2e.cbp
index 98e7ee16832b0180c72a3fb5eba645e8e985af26..18f6b88828d0bc64223ba20a802b7cf2761efc2d 100644 (file)
--- a/l2e.cbp
+++ b/l2e.cbp
                <Unit filename="src\menu\CapsuleChangeMenu.h" />
                <Unit filename="src\menu\CapsuleFeedMenu.cpp" />
                <Unit filename="src\menu\CapsuleFeedMenu.h" />
+               <Unit filename="src\menu\CapsuleNameMenu.cpp" />
+               <Unit filename="src\menu\CapsuleNameMenu.h" />
                <Unit filename="src\menu\CapsuleMenu.cpp" />
                <Unit filename="src\menu\CapsuleMenu.h" />
                <Unit filename="src\menu\ChangeHero.cpp" />
index 37278136ae7f9f8606008600bcfdb5e8104d89af..5ac40fbc734c3f6efc84d57eca5406354d1b3fb7 100644 (file)
@@ -35,8 +35,6 @@ private:
 
        const common::Capsule &GetCapsule() const;
 
-       void LoadInventory();
-
 private:
        CapsuleMenu *parent;
 
index 22d0ad7129b757606ab580e55f1d0cb7844d057d..ab32a1bcb2260b3b2a51d57d6cda58958ed23362 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "CapsuleChangeMenu.h"
 #include "CapsuleFeedMenu.h"
+#include "CapsuleNameMenu.h"
 #include "PartyMenu.h"
 #include "Resources.h"
 #include "../app/Application.h"
@@ -73,7 +74,7 @@ void CapsuleMenu::HandleEvents(const Input &input) {
                                menu.SetSelected();
                                break;
                        case CHOICE_NAME:
-                               // push name menu
+                               Ctrl().PushState(new CapsuleNameMenu(this));
                                menu.SetSelected();
                                break;
                }
diff --git a/src/menu/CapsuleNameMenu.cpp b/src/menu/CapsuleNameMenu.cpp
new file mode 100644 (file)
index 0000000..14acd46
--- /dev/null
@@ -0,0 +1,114 @@
+#include "CapsuleNameMenu.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"
+
+#include <cstring>
+
+using app::Input;
+using common::Capsule;
+using common::Inventory;
+using common::Item;
+using geometry::Vector;
+using graphics::Font;
+using graphics::Frame;
+
+namespace menu {
+
+CapsuleNameMenu::CapsuleNameMenu(CapsuleMenu *parent)
+: parent(parent)
+, cursor(5) {
+       std::strncpy(buffer, GetCapsule().Name(), 6);
+       buffer[5] = '\0';
+}
+
+
+void CapsuleNameMenu::OnEnterState(SDL_Surface *) {
+
+}
+
+void CapsuleNameMenu::OnExitState(SDL_Surface *) {
+
+}
+
+void CapsuleNameMenu::OnResumeState(SDL_Surface *) {
+
+}
+
+void CapsuleNameMenu::OnPauseState(SDL_Surface *) {
+
+}
+
+
+void CapsuleNameMenu::OnResize(int width, int height) {
+
+}
+
+
+void CapsuleNameMenu::HandleEvents(const Input &input) {
+       if (input.JustPressed(Input::START)) {
+               Ctrl().PopState();
+       }
+}
+
+void CapsuleNameMenu::UpdateWorld(float deltaT) {
+
+}
+
+void CapsuleNameMenu::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> nameOffset(
+                       4 * font.CharWidth(),
+                       4 * font.CharHeight() - font.CharHeight() / 8);
+       const Vector<int> alphaOffset(
+                       4 * font.CharWidth(),
+                       7 * font.CharHeight() - font.CharHeight() / 8);
+
+       parent->RenderBackground(screen);
+       RenderName(screen, offset + nameOffset);
+       RenderAlphabet(screen, offset + alphaOffset);
+}
+
+void CapsuleNameMenu::RenderName(SDL_Surface *screen, const Vector<int> &offset) const {
+       const Font &font(*parent->Res().normalFont);
+       const Frame &frame(*parent->Res().statusFrame);
+       const Vector<int> labelOffset(2 * font.CharWidth(), font.CharHeight());
+       const Vector<int> namebgOffset(8 * font.CharWidth(), 0);
+       const Vector<int> nameOffset(13 * font.CharWidth(), font.CharHeight());
+
+       frame.Draw(screen, offset, 8 * font.CharWidth(), 3 * font.CharHeight());
+       font.DrawString(parent->Res().capsuleNameLabel, screen, offset + labelOffset, 5);
+       frame.Draw(screen, offset + namebgOffset, 16 * font.CharWidth(), 3 * font.CharHeight());
+       font.DrawString(buffer, screen, offset + nameOffset, 5);
+}
+
+void CapsuleNameMenu::RenderAlphabet(SDL_Surface *screen, const Vector<int> &offset) const {
+       const Font &font(*parent->Res().normalFont);
+       const Frame &frame(*parent->Res().statusFrame);
+
+       frame.Draw(screen, offset, 24 * font.CharWidth(), 17 * font.CharHeight());
+}
+
+
+int CapsuleNameMenu::Width() const {
+       return parent->Width();
+}
+
+int CapsuleNameMenu::Height() const {
+       return parent->Height();
+}
+
+const Capsule &CapsuleNameMenu::GetCapsule() const {
+       return parent->GetCapsule();
+}
+
+}
diff --git a/src/menu/CapsuleNameMenu.h b/src/menu/CapsuleNameMenu.h
new file mode 100644 (file)
index 0000000..0021da4
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef MENU_CAPSULENAMEMENU_H_
+#define MENU_CAPSULENAMEMENU_H_
+
+#include "fwd.h"
+#include "../app/State.h"
+#include "../common/fwd.h"
+#include "../geometry/Vector.h"
+
+namespace menu {
+
+class CapsuleMenu;
+
+class CapsuleNameMenu
+: public app::State {
+
+public:
+       explicit CapsuleNameMenu(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();
+
+       void RenderName(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
+       void RenderAlphabet(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
+
+private:
+       CapsuleMenu *parent;
+       int cursor;
+       char buffer[6];
+
+};
+
+}
+
+#endif /* MENU_CAPSULENAMEMENU_H_ */
index 1a3460b100be2be7ce78ca93a11ed9d7c2b85bc0..59322d1a68287f14b6abbd461462b635ca05488b 100644 (file)
@@ -6,6 +6,7 @@ namespace menu {
 class CapsuleChangeMenu;
 class CapsuleFeedMenu;
 class CapsuleMenu;
+class CapsuleNameMenu;
 class ChangeHero;
 class ConfigMenu;
 class EquipMenu;