Browse Source

xp bar: show correct exp value, remove unnecessary info

maxexp
Xadhoom 5 years ago
parent
commit
a5debbd351
  1. 45
      Source/qol/xpbar.cpp

45
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;
}

Loading…
Cancel
Save