From 3251171a5c022942ac265539e6bceb39ceb6efb9 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sat, 26 Jun 2021 21:18:51 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Leverage=20'Point'=20in=20?= =?UTF-8?q?'xpbar.DrawBar'=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/qol/xpbar.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index 31f81c4fb..bc21d9b13 100644 --- a/Source/qol/xpbar.cpp +++ b/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(fullBar), yPos }, fade, SilverGradient); + DrawEndCap(out, position + Displacement { static_cast(fullBar), 0 }, fade, SilverGradient); } bool CheckXPBarInfo()