From a5debbd3515e2167ab6fa370ce6d520d2877b407 Mon Sep 17 00:00:00 2001 From: Xadhoom <> Date: Mon, 26 Apr 2021 20:37:51 +0000 Subject: [PATCH] xp bar: show correct exp value, remove unnecessary info --- Source/qol/xpbar.cpp | 45 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index fd272bb4c..5aa9cf5f8 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -76,12 +76,7 @@ void DrawXPBar(const CelOutputBuffer &out) const int charLevel = player._pLevel; - if (charLevel == MAXCHARLEVEL - 1) { - // Draw a nice golden bar for max level characters. - DrawBar(out, xPos, yPos, BAR_WIDTH, GOLD_GRADIENT); - - return; - } + const ColorGradient& gradient = (charLevel == MAXCHARLEVEL - 1) ? GOLD_GRADIENT : SILVER_GRADIENT; const int prevXp = ExpLvlsTbl[charLevel - 1]; if (player._pExperience < prevXp) @@ -95,13 +90,13 @@ void DrawXPBar(const CelOutputBuffer &out) uint64_t onePx = prevXpDelta / BAR_WIDTH + 1; uint64_t lastFullPx = fullBar * prevXpDelta / BAR_WIDTH; - const uint64_t fade = (prevXpDelta_1 - lastFullPx) * (SILVER_GRADIENT.size() - 1) / onePx; + const uint64_t fade = (prevXpDelta_1 - lastFullPx) * (gradient.size() - 1) / onePx; // Draw beginning of bar full brightness - DrawBar(out, xPos, yPos, fullBar, SILVER_GRADIENT); + DrawBar(out, xPos, yPos, fullBar, gradient); // End pixels appear gradually - DrawEndCap(out, xPos + fullBar, yPos, fade, SILVER_GRADIENT); + DrawEndCap(out, xPos + fullBar, yPos, fade, gradient); } bool CheckXPBarInfo() @@ -119,34 +114,22 @@ bool CheckXPBarInfo() const int charLevel = player._pLevel; - sprintf(tempstr, _("Level %d"), charLevel); - AddPanelString(tempstr, true); - - if (charLevel == MAXCHARLEVEL - 1) { - // Show a maximum level indicator for max level players. - infoclr = COL_GOLD; - - sprintf(tempstr, _("Experience: ")); - PrintWithSeparator(tempstr + SDL_arraysize("Experience: ") - 1, ExpLvlsTbl[charLevel - 1]); - AddPanelString(tempstr, true); - - AddPanelString(_("Maximum Level"), true); - - return true; - } - infoclr = COL_WHITE; + sprintf(tempstr, _("Level %d"), charLevel); + AddPanelString(tempstr, true); sprintf(tempstr, _("Experience: ")); PrintWithSeparator(tempstr + SDL_arraysize("Experience: ") - 1, player._pExperience); AddPanelString(tempstr, true); - sprintf(tempstr, _("Next Level: ")); - PrintWithSeparator(tempstr + SDL_arraysize("Next Level: ") - 1, ExpLvlsTbl[charLevel]); - AddPanelString(tempstr, true); - - sprintf(PrintWithSeparator(tempstr, ExpLvlsTbl[charLevel] - player._pExperience), _(" to Level %d"), charLevel + 1); - AddPanelString(tempstr, true); + if (charLevel != (MAXCHARLEVEL - 1)) { + auto difference = ExpLvlsTbl[charLevel] - player._pExperience; + sprintf(tempstr, _("Next level: ")); + PrintWithSeparator(tempstr + SDL_arraysize("Next level: ") - 1, ExpLvlsTbl[charLevel]); + AddPanelString(tempstr, true); + sprintf(PrintWithSeparator(tempstr, difference), _(" to level %d"), charLevel + 1); + AddPanelString(tempstr, true); + } return true; }