From: Daniel Karbach Date: Wed, 5 Dec 2012 19:55:47 +0000 (+0100) Subject: added capsule change menu stub X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=5bbf6cd4a9b9d51ca9f21a360d1ba039d4642614;p=l2e.git added capsule change menu stub --- diff --git a/l2e.cbp b/l2e.cbp index f0f5b2f..98e7ee1 100644 --- a/l2e.cbp +++ b/l2e.cbp @@ -190,6 +190,10 @@ + + + + diff --git a/src/menu/CapsuleChangeMenu.cpp b/src/menu/CapsuleChangeMenu.cpp new file mode 100644 index 0000000..3b161ad --- /dev/null +++ b/src/menu/CapsuleChangeMenu.cpp @@ -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 offset((screen->w - Width()) / 2, (screen->h - Height()) / 2); + const Vector capsuleOffset( + 6 * font.CharWidth(), + 12 * font.CharHeight()); + const Vector infoOffset( + 12 * font.CharWidth(), + 2 * font.CharHeight() - font.CharHeight() / 8); + // TODO: wheel offset: top left, center, or center bottom? + const Vector wheelOffset; + const Vector 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 index 0000000..3727813 --- /dev/null +++ b/src/menu/CapsuleChangeMenu.h @@ -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_ */ diff --git a/src/menu/CapsuleMenu.cpp b/src/menu/CapsuleMenu.cpp index 6d0fba8..22d0ad7 100644 --- a/src/menu/CapsuleMenu.cpp +++ b/src/menu/CapsuleMenu.cpp @@ -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: diff --git a/src/menu/fwd.h b/src/menu/fwd.h index 15e0f83..1a3460b 100644 --- a/src/menu/fwd.h +++ b/src/menu/fwd.h @@ -3,6 +3,7 @@ namespace menu { +class CapsuleChangeMenu; class CapsuleFeedMenu; class CapsuleMenu; class ChangeHero;