Browse Source

♻️ Leverage 'Point' in 'xpbar.DrawBar' function

pull/2753/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
3251171a5c
  1. 18
      Source/qol/xpbar.cpp

18
Source/qol/xpbar.cpp

@ -31,11 +31,11 @@ constexpr int BackHeight = 9;
Art xpbarArt;
void DrawBar(const Surface &out, int x, int y, int width, const ColorGradient &gradient)
void DrawBar(const Surface &out, Point screenPosition, int width, const ColorGradient &gradient)
{
UnsafeDrawHorizontalLine(out, { x, y + 1 }, width, gradient[gradient.size() * 3 / 4 - 1]);
UnsafeDrawHorizontalLine(out, { x, y + 2 }, width, gradient[gradient.size() - 1]);
UnsafeDrawHorizontalLine(out, { x, y + 3 }, width, gradient[gradient.size() / 2 - 1]);
UnsafeDrawHorizontalLine(out, screenPosition + Displacement { 0, 1 }, width, gradient[gradient.size() * 3 / 4 - 1]);
UnsafeDrawHorizontalLine(out, screenPosition + Displacement { 0, 2 }, width, gradient[gradient.size() - 1]);
UnsafeDrawHorizontalLine(out, screenPosition + Displacement { 0, 3 }, width, gradient[gradient.size() / 2 - 1]);
}
void DrawEndCap(const Surface &out, Point point, int idx, const ColorGradient &gradient)
@ -73,9 +73,7 @@ void DrawXPBar(const Surface &out)
const auto &player = Players[MyPlayerId];
const Point back = { PANEL_LEFT + PANEL_WIDTH / 2 - 155, PANEL_TOP + PANEL_HEIGHT - 11 };
const int xPos = back.x + 3;
const int yPos = back.y + 2;
const Point position = back + Displacement { 3, 2 };
DrawArt(out, back, &xpbarArt);
@ -83,7 +81,7 @@ void DrawXPBar(const Surface &out)
if (charLevel == MAXCHARLEVEL - 1) {
// Draw a nice golden bar for max level characters.
DrawBar(out, xPos, yPos, BarWidth, GoldGradient);
DrawBar(out, position, BarWidth, GoldGradient);
return;
}
@ -103,10 +101,10 @@ void DrawXPBar(const Surface &out)
const uint64_t fade = (prevXpDelta1 - lastFullPx) * (SilverGradient.size() - 1) / onePx;
// Draw beginning of bar full brightness
DrawBar(out, xPos, yPos, fullBar, SilverGradient);
DrawBar(out, position, fullBar, SilverGradient);
// End pixels appear gradually
DrawEndCap(out, { xPos + static_cast<int>(fullBar), yPos }, fade, SilverGradient);
DrawEndCap(out, position + Displacement { static_cast<int>(fullBar), 0 }, fade, SilverGradient);
}
bool CheckXPBarInfo()

Loading…
Cancel
Save