]> git.localhorst.tv Git - l2e.git/blobdiff - src/menu/StatusMenu.cpp
implemented item dropping
[l2e.git] / src / menu / StatusMenu.cpp
index aea11b9cda0ffd9888b0aea38982281ed6247cc3..3a9b38f3489f58fc0b282c8e9108e948afb8d536 100644 (file)
@@ -18,6 +18,7 @@
 #include "../common/Item.h"
 #include "../common/Stats.h"
 #include "../graphics/Font.h"
+#include "../graphics/Frame.h"
 
 using app::Input;
 using common::Hero;
@@ -25,13 +26,16 @@ using common::Item;
 using common::Stats;
 using geometry::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,16 +62,30 @@ 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) {
@@ -90,7 +108,13 @@ void StatusMenu::Render(SDL_Surface *screen) {
                        17 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8);
        Vector<int> 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<int> ikariOffset(
+                       17 * parent->Res().statusFont->CharWidth(),
+                       17 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8);
+       Vector<int> 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);
@@ -99,6 +123,8 @@ void StatusMenu::Render(SDL_Surface *screen) {
        RenderEquipment(screen, offset + equipOffset);
        RenderExperience(screen, experienceOffset);
        RenderNextLevel(screen, nextLevelOffset);
+       RenderIkari(screen, ikariOffset);
+       RenderMenu(screen, menuOffset);
 }
 
 int StatusMenu::Width() const {
@@ -199,6 +225,31 @@ void StatusMenu::RenderNextLevel(SDL_Surface *screen, const geometry::Vector<int
        font.DrawNumberRight(GetHero().NextLevel(), screen, numberOffset, 7);
 }
 
+void StatusMenu::RenderIkari(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
+       const Font &font(*parent->Res().statusFont);
+       font.DrawString(parent->Res().ipLabel, screen, offset, 5);
+
+       Vector<int> numberOffset(offset.X() + 5 * font.CharWidth(), offset.Y());
+       font.DrawNumber(GetHero().RelativeIP(100), screen, numberOffset, 3);
+
+       Vector<int> percentOffset(offset.X() + 8 * font.CharWidth(), offset.Y());
+       font.DrawChar('%', screen, percentOffset);
+}
+
+void StatusMenu::RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
+       const Font &font(*parent->Res().normalFont);
+       const Frame &frame(*parent->Res().statusFrame);
+
+       Vector<int> 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<int> menuFrameOffset(10 * font.CharWidth(), 0);
+       Vector<int> 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;