From: Daniel Karbach Date: Wed, 5 Dec 2012 20:30:19 +0000 (+0100) Subject: added capsule name menu stub X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=59c735f03e5959ab6a32afac1603f1e371786ed7;p=l2e.git added capsule name menu stub --- diff --git a/l2e.cbp b/l2e.cbp index 98e7ee1..18f6b88 100644 --- a/l2e.cbp +++ b/l2e.cbp @@ -194,6 +194,8 @@ + + diff --git a/src/menu/CapsuleChangeMenu.h b/src/menu/CapsuleChangeMenu.h index 3727813..5ac40fb 100644 --- a/src/menu/CapsuleChangeMenu.h +++ b/src/menu/CapsuleChangeMenu.h @@ -35,8 +35,6 @@ private: const common::Capsule &GetCapsule() const; - void LoadInventory(); - private: CapsuleMenu *parent; diff --git a/src/menu/CapsuleMenu.cpp b/src/menu/CapsuleMenu.cpp index 22d0ad7..ab32a1b 100644 --- a/src/menu/CapsuleMenu.cpp +++ b/src/menu/CapsuleMenu.cpp @@ -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 index 0000000..14acd46 --- /dev/null +++ b/src/menu/CapsuleNameMenu.cpp @@ -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 + +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 offset((screen->w - Width()) / 2, (screen->h - Height()) / 2); + const Vector nameOffset( + 4 * font.CharWidth(), + 4 * font.CharHeight() - font.CharHeight() / 8); + const Vector 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 &offset) const { + const Font &font(*parent->Res().normalFont); + const Frame &frame(*parent->Res().statusFrame); + const Vector labelOffset(2 * font.CharWidth(), font.CharHeight()); + const Vector namebgOffset(8 * font.CharWidth(), 0); + const Vector 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 &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 index 0000000..0021da4 --- /dev/null +++ b/src/menu/CapsuleNameMenu.h @@ -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 &offset) const; + void RenderAlphabet(SDL_Surface *screen, const geometry::Vector &offset) const; + +private: + CapsuleMenu *parent; + int cursor; + char buffer[6]; + +}; + +} + +#endif /* MENU_CAPSULENAMEMENU_H_ */ diff --git a/src/menu/fwd.h b/src/menu/fwd.h index 1a3460b..59322d1 100644 --- a/src/menu/fwd.h +++ b/src/menu/fwd.h @@ -6,6 +6,7 @@ namespace menu { class CapsuleChangeMenu; class CapsuleFeedMenu; class CapsuleMenu; +class CapsuleNameMenu; class ChangeHero; class ConfigMenu; class EquipMenu;