X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmenu%2FStatusMenu.cpp;h=41f848f82dde590cf55c6c872e7cd4469b1ccc7f;hb=092a2dd175a4001a495c84ee85211734fb928c83;hp=b0377033b50f1920258332595586325382a368c3;hpb=b9448180c2cf0ecc75865e57d83db63d4fe3e8a5;p=l2e.git diff --git a/src/menu/StatusMenu.cpp b/src/menu/StatusMenu.cpp index b037703..41f848f 100644 --- a/src/menu/StatusMenu.cpp +++ b/src/menu/StatusMenu.cpp @@ -1,10 +1,3 @@ -/* - * StatusMenu.cpp - * - * Created on: Oct 22, 2012 - * Author: holy - */ - #include "StatusMenu.h" #include "HeroStatus.h" @@ -18,20 +11,25 @@ #include "../common/Item.h" #include "../common/Stats.h" #include "../graphics/Font.h" +#include "../graphics/Frame.h" +#include "../math/Vector.h" using app::Input; using common::Hero; using common::Item; using common::Stats; -using geometry::Vector; +using math::Vector; using graphics::Font; +using graphics::Frame; namespace menu { StatusMenu::StatusMenu(PartyMenu *parent, int cursor) : parent(parent) -, cursor(cursor) { - +, cursor(cursor) +, menu(*parent->Res().statusMenuProperties) { + menu.Add(parent->Res().nextLabel, 0); + menu.Add(parent->Res().returnLabel, 1); } @@ -58,19 +56,33 @@ void StatusMenu::OnResize(int width, int height) { void StatusMenu::HandleEvents(const Input &input) { - if (input.JustPressed(Input::ACTION_B)) { - Ctrl().PopState(); - } - if (input.JustPressed(Input::SHOULDER_RIGHT)) { NextHero(); } if (input.JustPressed(Input::SHOULDER_LEFT)) { PreviousHero(); } + + if (input.JustPressed(Input::PAD_LEFT)) { + menu.PreviousItem(); + } + if (input.JustPressed(Input::PAD_RIGHT)) { + menu.NextItem(); + } + + if (input.JustPressed(Input::ACTION_A)) { + if (menu.Selected() == 0) { + NextHero(); + } else if (menu.Selected() == 1) { + Ctrl().PopState(); + } + } + if (input.JustPressed(Input::ACTION_B)) { + Ctrl().PopState(); + } } -void StatusMenu::UpdateWorld(float deltaT) { +void StatusMenu::UpdateWorld(Uint32 deltaT) { } @@ -90,10 +102,13 @@ void StatusMenu::Render(SDL_Surface *screen) { 17 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8); Vector nextLevelOffset( 11 * parent->Res().statusFont->CharWidth(), - 19 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8); + 20 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8); Vector ikariOffset( 17 * parent->Res().statusFont->CharWidth(), 17 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8); + Vector menuOffset( + parent->Res().statusFont->CharWidth(), + 23 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8); parent->RenderBackground(screen); parent->Res().shoulderNav->Draw(screen, offset + shoulderNavOffset); @@ -103,6 +118,7 @@ void StatusMenu::Render(SDL_Surface *screen) { RenderExperience(screen, experienceOffset); RenderNextLevel(screen, nextLevelOffset); RenderIkari(screen, ikariOffset); + RenderMenu(screen, menuOffset); } int StatusMenu::Width() const { @@ -156,22 +172,10 @@ void StatusMenu::RenderEquipment(SDL_Surface *screen, const Vector &offset) Vector lineBreak(0, 2 * parent->Res().statusFont->CharHeight()); Vector position(offset); - RenderEquipmentLine(hero.Weapon(), screen, position); - - position += lineBreak; - RenderEquipmentLine(hero.Armor(), screen, position); - - position += lineBreak; - RenderEquipmentLine(hero.Shield(), screen, position); - - position += lineBreak; - RenderEquipmentLine(hero.Helmet(), screen, position); - - position += lineBreak; - RenderEquipmentLine(hero.Ring(), screen, position); - - position += lineBreak; - RenderEquipmentLine(hero.Jewel(), screen, position); + for (int i = 0; i < Hero::EQUIP_COUNT; ++i) { + RenderEquipmentLine(hero.Equipment(Hero::EquipSlot(i)), screen, position); + position += lineBreak; + } } void StatusMenu::RenderEquipmentLine(const Item *item, SDL_Surface *screen, const Vector &position) const { @@ -187,7 +191,7 @@ void StatusMenu::RenderEquipmentLine(const Item *item, SDL_Surface *screen, cons } } -void StatusMenu::RenderExperience(SDL_Surface *screen, const geometry::Vector &offset) const { +void StatusMenu::RenderExperience(SDL_Surface *screen, const math::Vector &offset) const { const Font &font(*parent->Res().statusFont); font.DrawStringRight(parent->Res().experienceLabel, screen, offset, 10); @@ -195,7 +199,7 @@ void StatusMenu::RenderExperience(SDL_Surface *screen, const geometry::Vector &offset) const { +void StatusMenu::RenderNextLevel(SDL_Surface *screen, const math::Vector &offset) const { const Font &font(*parent->Res().statusFont); font.DrawStringRight(parent->Res().nextLevelLabel, screen, offset, 10); @@ -203,7 +207,7 @@ void StatusMenu::RenderNextLevel(SDL_Surface *screen, const geometry::Vector &offset) const { +void StatusMenu::RenderIkari(SDL_Surface *screen, const math::Vector &offset) const { const Font &font(*parent->Res().statusFont); font.DrawString(parent->Res().ipLabel, screen, offset, 5); @@ -214,6 +218,20 @@ void StatusMenu::RenderIkari(SDL_Surface *screen, const geometry::Vector &o font.DrawChar('%', screen, percentOffset); } +void StatusMenu::RenderMenu(SDL_Surface *screen, const math::Vector &offset) const { + const Font &font(*parent->Res().normalFont); + const Frame &frame(*parent->Res().statusFrame); + + Vector labelOffset(2 * font.CharWidth(), font.CharHeight()); + frame.Draw(screen, offset, 10 * font.CharWidth(), 3 * font.CharHeight()); + font.DrawString(parent->Res().mainMenuStatusText, screen, offset + labelOffset); + + Vector menuFrameOffset(10 * font.CharWidth(), 0); + Vector menuOffset(13 * font.CharWidth(), font.CharHeight()); + frame.Draw(screen, offset + menuFrameOffset, 20 * font.CharWidth(), 3 * font.CharHeight()); + menu.Draw(screen, offset + menuOffset); +} + void StatusMenu::NextHero() { cursor = (cursor + 1) % parent->Game().state->partySize;