1 #include "CapsuleChangeMenu.h"
3 #include "CapsuleMenu.h"
5 #include "../app/Application.h"
6 #include "../app/Input.h"
7 #include "../common/Inventory.h"
8 #include "../common/Item.h"
9 #include "../common/GameConfig.h"
10 #include "../common/GameState.h"
11 #include "../graphics/Font.h"
12 #include "../graphics/Frame.h"
15 using common::Capsule;
16 using common::Inventory;
18 using geometry::Vector;
20 using graphics::Frame;
24 CapsuleChangeMenu::CapsuleChangeMenu(CapsuleMenu *parent)
30 void CapsuleChangeMenu::OnEnterState(SDL_Surface *) {
34 void CapsuleChangeMenu::OnExitState(SDL_Surface *) {
38 void CapsuleChangeMenu::OnResumeState(SDL_Surface *) {
42 void CapsuleChangeMenu::OnPauseState(SDL_Surface *) {
47 void CapsuleChangeMenu::OnResize(int width, int height) {
52 void CapsuleChangeMenu::HandleEvents(const Input &input) {
53 if (input.JustPressed(Input::ACTION_B)) {
58 void CapsuleChangeMenu::UpdateWorld(float deltaT) {
62 void CapsuleChangeMenu::Render(SDL_Surface *screen) {
63 const Font &font(*parent->Res().statusFont);
64 const Vector<int> offset((screen->w - Width()) / 2, (screen->h - Height()) / 2);
65 const Vector<int> capsuleOffset(
67 12 * font.CharHeight());
68 const Vector<int> infoOffset(
69 12 * font.CharWidth(),
70 2 * font.CharHeight() - font.CharHeight() / 8);
71 // TODO: wheel offset: top left, center, or center bottom?
72 const Vector<int> wheelOffset;
73 const Vector<int> menuOffset(
75 24 * font.CharHeight() - font.CharHeight() / 8);
77 parent->RenderBackground(screen);
78 parent->RenderCapsule(screen, offset + capsuleOffset);
79 parent->RenderInfo(screen, offset + infoOffset);
80 parent->RenderWheel(screen, offset + wheelOffset);
81 parent->RenderMenu(screen, offset + menuOffset);
85 int CapsuleChangeMenu::Width() const {
86 return parent->Width();
89 int CapsuleChangeMenu::Height() const {
90 return parent->Height();
93 const Capsule &CapsuleChangeMenu::GetCapsule() const {
94 return parent->GetCapsule();