From fabf8451e7690fd36cd1e49ed5c3b9b516a0abad Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 02:24:04 +0200 Subject: [PATCH] - use Fill to draw Strife's health bars. --- src/g_statusbar/shared_sbar.cpp | 7 ++++- .../static/zscript/statusbar/strife_sbar.txt | 29 +++++++------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 3bced97dc..f6b0644cc 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -2000,7 +2000,12 @@ void DBaseStatusBar::Fill(PalEntry color, double x, double y, double w, double h x += orgx; y += orgy; } - screen->Dim(color, float(Alpha), int(x), int(y), int(w), int(h)); + int x1 = int(x); + int y1 = int(y); + int ww = int(x + w - x1); // account for scaling to non-integers. Truncating the values separately would fail for cases like + int hh = int(y + h - y1); // y=3.5, height = 5.5 where adding both values gives a larger integer than adding the two integers. + + screen->Dim(color, float(Alpha), x1, y1, ww, hh); } diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index fc1862698..148b1e237 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -202,32 +202,23 @@ class StrifeStatusBar : BaseStatusBar private void FillBar(double x, double y, double start, double stopp, Color color1, Color color2) { - Vector2 virt = Scaled? (320., 200.) : (screen.GetWidth(), screen.GetHeight()); - Vector2 pos, sizev; - - start *=2; - stopp *=2; - - [pos, sizev] = screen.VirtualToRealCoords((ST_X + x + start, ST_Y + y), (stopp - start, 1), virt, true, Scaled); - screen.Dim(color1, 1.0, pos.X + 0.5, pos.Y + 0.5, sizev.X + 0.5, sizev.Y + 0.5); - - [pos, sizev] = screen.VirtualToRealCoords((ST_X + x + start, ST_Y + y + 1), (stopp - start, 1), virt, true, Scaled); - screen.Dim(color2, 1.0, pos.X + 0.5, pos.Y + 0.5, sizev.X + 0.5, sizev.Y + 0.5); + Fill(color1, x, y, (stopp-start)*2, 1); + Fill(color2, x, y+1, (stopp-start)*2, 1); } protected void DrawHealthBar(int health, int x, int y) { - Color green1 = Color(180, 228, 128); // light green - Color green2 = Color(128, 180, 80); // dark green + Color green1 = Color(255, 180, 228, 128); // light green + Color green2 = Color(255, 128, 180, 80); // dark green - Color blue1 = Color(196, 204, 252); // light blue - Color blue2 = Color(148, 152, 200); // dark blue + Color blue1 = Color(255, 196, 204, 252); // light blue + Color blue2 = Color(255, 148, 152, 200); // dark blue - Color gold1 = Color(224, 188, 0); // light gold - Color gold2 = Color(208, 128, 0); // dark gold + Color gold1 = Color(255, 224, 188, 0); // light gold + Color gold2 = Color(255, 208, 128, 0); // dark gold - Color red1 = Color(216, 44, 44); // light red - Color red2 = Color(172, 28, 28); // dark red + Color red1 = Color(255, 216, 44, 44); // light red + Color red2 = Color(255, 172, 28, 28); // dark red if (health == 999) {