]> git.localhorst.tv Git - l2e.git/commitdiff
added hero's stats in status screen
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 23 Oct 2012 21:04:27 +0000 (23:04 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 23 Oct 2012 21:04:27 +0000 (23:04 +0200)
src/main.cpp
src/menu/Resources.cpp
src/menu/Resources.h
src/menu/StatusMenu.cpp
src/menu/StatusMenu.h

index 93727fda784fd4da6a4914d131b81c34db0c2959..1587d60c34223b7f5beb00bd4c3e2293f4027582 100644 (file)
@@ -328,6 +328,14 @@ int main(int argc, char **argv) {
                graphics::Sprite shoulderNav(IMG_Load("test-data/shoulder-nav.png"), 160, 16);
                menuResources.shoulderNav = &shoulderNav;
 
+               menuResources.atpLabel = "ATP";
+               menuResources.dfpLabel = "DFP";
+               menuResources.strLabel = "STR";
+               menuResources.aglLabel = "AGL";
+               menuResources.intLabel = "INT";
+               menuResources.gutLabel = "GUT";
+               menuResources.mgrLabel = "MGR";
+
                InitScreen screen(width, height);
 
                app::State *state(0);
index 166fbf70368f15a42dd8eac25a9d66184db5bfe1..79e59515b9ab905861e9840954890cf01837987e 100644 (file)
@@ -35,7 +35,15 @@ Resources::Resources()
 
 , noEquipmentText(0)
 
-, shoulderNav(0) {
+, shoulderNav(0)
+
+, atpLabel(0)
+, dfpLabel(0)
+, strLabel(0)
+, aglLabel(0)
+, intLabel(0)
+, gutLabel(0)
+, mgrLabel(0) {
 
 }
 
index eb6181658eec266ae7185883e1698e97c7892db6..0b3b435f7019e80dc8e1f4f860c7ed9ce3bab1de 100644 (file)
@@ -42,6 +42,14 @@ struct Resources {
 
        graphics::Sprite *shoulderNav;
 
+       const char *atpLabel;
+       const char *dfpLabel;
+       const char *strLabel;
+       const char *aglLabel;
+       const char *intLabel;
+       const char *gutLabel;
+       const char *mgrLabel;
+
        Resources();
 
 };
index e46a1dd1fbc9d2f11d36d4399286af0cc6a8e200..c56e796f13f5fe4fc21652657f5d7919d198674e 100644 (file)
 #include "../common/GameState.h"
 #include "../common/Hero.h"
 #include "../common/Item.h"
+#include "../common/Stats.h"
 #include "../graphics/Font.h"
 
 using app::Input;
 using common::Hero;
 using common::Item;
+using common::Stats;
 using geometry::Vector;
 using graphics::Font;
 
@@ -78,13 +80,17 @@ void StatusMenu::Render(SDL_Surface *screen) {
                        5 * parent->Res().statusFont->CharWidth(),
                        parent->Res().statusFont->CharHeight());
        Vector<int> statsOffset(
+                       4 * parent->Res().statusFont->CharWidth(),
+                       8 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8);
+       Vector<int> equipOffset(
                        17 * parent->Res().statusFont->CharWidth(),
                        4 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8);
 
        parent->RenderBackground(screen);
        parent->Res().shoulderNav->Draw(screen, offset + shoulderNavOffset);
        RenderStatus(screen, offset + parent->StatusOffset(0));
-       RenderEquipment(screen, offset + statsOffset);
+       RenderStats(screen, offset + statsOffset);
+       RenderEquipment(screen, offset + equipOffset);
 }
 
 int StatusMenu::Width() const {
@@ -99,7 +105,41 @@ void StatusMenu::RenderStatus(SDL_Surface *screen, const Vector<int> &offset) co
        parent->GetHeroStatus(cursor).Render(screen, offset);
 }
 
-void StatusMenu::RenderEquipment(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
+void StatusMenu::RenderStats(SDL_Surface *screen, const Vector<int> &offset) const {
+       const Stats &stats(parent->Game().state->party[cursor]->GetStats());
+       Vector<int> lineBreak(0, parent->Res().statusFont->CharHeight());
+
+       Vector<int> position(offset);
+       RenderStatsLine(parent->Res().atpLabel, stats.Attack(), screen, position);
+
+       position += lineBreak;
+       RenderStatsLine(parent->Res().dfpLabel, stats.Defense(), screen, position);
+
+       position += lineBreak;
+       RenderStatsLine(parent->Res().strLabel, stats.Strength(), screen, position);
+
+       position += lineBreak;
+       RenderStatsLine(parent->Res().aglLabel, stats.Agility(), screen, position);
+
+       position += lineBreak;
+       RenderStatsLine(parent->Res().intLabel, stats.Intelligence(), screen, position);
+
+       position += lineBreak;
+       RenderStatsLine(parent->Res().gutLabel, stats.Gut(), screen, position);
+
+       position += lineBreak;
+       RenderStatsLine(parent->Res().mgrLabel, stats.MagicResistance(), screen, position);
+}
+
+void StatusMenu::RenderStatsLine(const char *label, int number, SDL_Surface *screen, const Vector<int> &position) const {
+       const Font &font(*parent->Res().statusFont);
+       const Vector<int> numberOffset(4 * font.CharWidth(), 0);
+
+       font.DrawString(label, screen, position, 3);
+       font.DrawNumber(number, screen, position + numberOffset, 3);
+}
+
+void StatusMenu::RenderEquipment(SDL_Surface *screen, const Vector<int> &offset) const {
        const Hero &hero(*parent->Game().state->party[cursor]);
        Vector<int> lineBreak(0, 2 * parent->Res().statusFont->CharHeight());
 
index 4330b99662219db731291e386a3799a05975c13f..61082d4d95903d94b21413a6ba2f14c1854d3612 100644 (file)
@@ -42,6 +42,8 @@ private:
        void PreviousHero();
 
        void RenderStatus(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
+       void RenderStats(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
+       void RenderStatsLine(const char *label, int number, SDL_Surface *screen, const geometry::Vector<int> &position) const;
        void RenderEquipment(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
        void RenderEquipmentLine(const common::Item *, SDL_Surface *screen, const geometry::Vector<int> &position) const;