From: Daniel Karbach Date: Wed, 31 Oct 2012 21:09:41 +0000 (+0100) Subject: added experience display in status screen X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=9429393ba3d875a12049dc9efeb4720fd9583e23;p=l2e.git added experience display in status screen --- diff --git a/src/main.cpp b/src/main.cpp index 1587d60..69b4e87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -336,6 +336,10 @@ int main(int argc, char **argv) { menuResources.gutLabel = "GUT"; menuResources.mgrLabel = "MGR"; + menuResources.ipLabel = "IP"; + menuResources.experienceLabel = "NOW EXP"; + menuResources.nextLevelLabel = "NEXT LEVEL"; + InitScreen screen(width, height); app::State *state(0); diff --git a/src/menu/Resources.cpp b/src/menu/Resources.cpp index 79e5951..646c049 100644 --- a/src/menu/Resources.cpp +++ b/src/menu/Resources.cpp @@ -43,7 +43,11 @@ Resources::Resources() , aglLabel(0) , intLabel(0) , gutLabel(0) -, mgrLabel(0) { +, mgrLabel(0) + +, ipLabel(0) +, experienceLabel(0) +, nextLevelLabel(0) { } diff --git a/src/menu/Resources.h b/src/menu/Resources.h index 0b3b435..64198f8 100644 --- a/src/menu/Resources.h +++ b/src/menu/Resources.h @@ -50,6 +50,10 @@ struct Resources { const char *gutLabel; const char *mgrLabel; + const char *ipLabel; + const char *experienceLabel; + const char *nextLevelLabel; + Resources(); }; diff --git a/src/menu/StatusMenu.cpp b/src/menu/StatusMenu.cpp index c56e796..f155c16 100644 --- a/src/menu/StatusMenu.cpp +++ b/src/menu/StatusMenu.cpp @@ -85,12 +85,16 @@ void StatusMenu::Render(SDL_Surface *screen) { Vector equipOffset( 17 * parent->Res().statusFont->CharWidth(), 4 * parent->Res().statusFont->CharHeight() - parent->Res().statusFont->CharHeight() / 8); + Vector experienceOffset( + 11 * parent->Res().statusFont->CharWidth(), + 17 * 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)); RenderStats(screen, offset + statsOffset); RenderEquipment(screen, offset + equipOffset); + RenderExperience(screen, experienceOffset); } int StatusMenu::Width() const { @@ -106,7 +110,7 @@ void StatusMenu::RenderStatus(SDL_Surface *screen, const Vector &offset) co } void StatusMenu::RenderStats(SDL_Surface *screen, const Vector &offset) const { - const Stats &stats(parent->Game().state->party[cursor]->GetStats()); + const Stats &stats(GetHero().GetStats()); Vector lineBreak(0, parent->Res().statusFont->CharHeight()); Vector position(offset); @@ -140,7 +144,7 @@ void StatusMenu::RenderStatsLine(const char *label, int number, SDL_Surface *scr } void StatusMenu::RenderEquipment(SDL_Surface *screen, const Vector &offset) const { - const Hero &hero(*parent->Game().state->party[cursor]); + const Hero &hero(GetHero()); Vector lineBreak(0, 2 * parent->Res().statusFont->CharHeight()); Vector position(offset); @@ -175,6 +179,14 @@ void StatusMenu::RenderEquipmentLine(const Item *item, SDL_Surface *screen, cons } } +void StatusMenu::RenderExperience(SDL_Surface *screen, const geometry::Vector &offset) const { + const Font &font(*parent->Res().statusFont); + font.DrawStringRight(parent->Res().experienceLabel, screen, offset, 10); + + Vector numberOffset(offset.X(), offset.Y() + font.CharHeight()); + font.DrawNumberRight(GetHero().Experience(), screen, numberOffset, 7); +} + void StatusMenu::NextHero() { cursor = (cursor + 1) % parent->Game().state->partySize; @@ -184,4 +196,8 @@ void StatusMenu::PreviousHero() { cursor = (cursor + parent->Game().state->partySize - 1) % parent->Game().state->partySize; } +const Hero &StatusMenu::GetHero() const { + return *parent->Game().state->party[cursor]; +} + } diff --git a/src/menu/StatusMenu.h b/src/menu/StatusMenu.h index 61082d4..51c169a 100644 --- a/src/menu/StatusMenu.h +++ b/src/menu/StatusMenu.h @@ -41,11 +41,15 @@ private: void NextHero(); void PreviousHero(); + const common::Hero &GetHero() const; + void RenderStatus(SDL_Surface *screen, const geometry::Vector &offset) const; void RenderStats(SDL_Surface *screen, const geometry::Vector &offset) const; void RenderStatsLine(const char *label, int number, SDL_Surface *screen, const geometry::Vector &position) const; void RenderEquipment(SDL_Surface *screen, const geometry::Vector &offset) const; void RenderEquipmentLine(const common::Item *, SDL_Surface *screen, const geometry::Vector &position) const; + /// @param offset the top right corner! + void RenderExperience(SDL_Surface *screen, const geometry::Vector &offset) const; private: PartyMenu *parent;