From 827b3e430bc2ab22df6446e6bd85641b1a5b043f Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Mar 2021 13:38:25 -0700 Subject: [PATCH 1/4] Outline textboxless textboxes In case they get drawn against a non-contrasting background, it's still useful to keep them readable by outlining them. This could happen if someone were to use the Game Complete gamestate sequence in a custom level (or presses R during Game Complete). --- desktop_version/src/Graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index a4e7c8eb..5e4c99b6 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -860,7 +860,7 @@ void Graphics::drawgui(void) { for (size_t j = 0; j < textbox[i].line.size(); j++) { - Print(textbox[i].xp + 8, yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow); + bprint(textbox[i].xp + 8, yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow); } } else From f7173027ce499c8cec300c5d611fe66d430221ec Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Mar 2021 14:26:59 -0700 Subject: [PATCH 2/4] Add Graphics::bigbprint() It's just like bigprint() except it duplicates some of the calculations because I didn't want to make a bigprintoff() function which would duplicate even more code. I'm beginning to think these text printing functions are completely horrible to work with... --- desktop_version/src/Graphics.cpp | 22 ++++++++++++++++++++++ desktop_version/src/Graphics.h | 1 + 2 files changed, 23 insertions(+) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 5e4c99b6..1fe39b9d 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -541,6 +541,28 @@ void Graphics::bigprint( int _x, int _y, std::string _s, int r, int g, int b, b } } +void Graphics::bigbprint(int x, int y, std::string s, int r, int g, int b, bool cen, int sc) +{ + if (!notextoutline) + { + bigprint(x, y - sc, s, 0, 0, 0, cen, sc); + if (cen) + { + int x_cen = VVV_max(160 - (len(s) / 2) * sc, 0); + bigprint(x_cen - sc, y, s, 0, 0, 0, false, sc); + bigprint(x_cen + sc, y, s, 0, 0, 0, false, sc); + } + else + { + bigprint(x - sc, y, s, 0, 0, 0, cen, sc); + bigprint(x + sc, y, s, 0, 0, 0, cen, sc); + } + bigprint(x, y + sc, s, 0, 0, 0, cen, sc); + } + + bigprint(x, y, s, r, g, b, cen, sc); +} + int Graphics::len(std::string t) { int bfontpos = 0; diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index af41b09b..045c17dd 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -144,6 +144,7 @@ public: int len(std::string t); void bigprint( int _x, int _y, std::string _s, int r, int g, int b, bool cen = false, int sc = 2 ); + void bigbprint(int x, int y, std::string s, int r, int g, int b, bool cen = false, int sc = 2); void drawspritesetcol(int x, int y, int t, int c); From 6538d1e5ddfae1dd54fa8b6bc30095e4d76803f3 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Mar 2021 14:28:04 -0700 Subject: [PATCH 3/4] Add Graphics::bigrprint() Same as bigbprint(), we duplicate some of the calculations because it's better than duplicating another text printing function. --- desktop_version/src/Graphics.cpp | 24 ++++++++++++++++++++++++ desktop_version/src/Graphics.h | 1 + 2 files changed, 25 insertions(+) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 1fe39b9d..4d9e4dac 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -3177,6 +3177,30 @@ void Graphics::bigrprint(int x, int y, std::string& t, int r, int g, int b, bool } } +void Graphics::bigbrprint(int x, int y, std::string& s, int r, int g, int b, bool cen, float sc) +{ + if (!notextoutline) + { + int x_o = x / sc - len(s); + bigrprint(x, y - sc, s, 0, 0, 0, cen, sc); + if (cen) + { + x_o = VVV_max(160 - (len(s) / 2) * sc, 0); + bigprint(x_o - sc, y, s, 0, 0, 0, false, sc); + bigprint(x_o + sc, y, s, 0, 0, 0, false, sc); + } + else + { + x_o *= sc; + bigprint(x_o - sc, y, s, 0, 0, 0, false, sc); + bigprint(x_o + sc, y, s, 0, 0, 0, false, sc); + } + bigrprint(x, y + sc, s, 0, 0, 0, cen, sc); + } + + bigrprint(x, y, s, r, g, b, cen, sc); +} + void Graphics::drawtele(int x, int y, int t, Uint32 c) { setcolreal(getRGB(16,16,16)); diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 045c17dd..247c465c 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -169,6 +169,7 @@ public: void drawtrophytext(void); void bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen = false, float sc = 2); + void bigbrprint(int x, int y, std::string& t, int r, int g, int b, bool cen = false, float sc = 2); void drawtele(int x, int y, int t, Uint32 c); From ef091de23e28ff3383c40256c94c53b12310618d Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Mar 2021 14:29:03 -0700 Subject: [PATCH 4/4] Outline all gravitron text This includes all text from the Gravitron and Super Gravitron. This is to make the text more readable if they are placed in weird situations - for example, in custom levels, where the background these texts get placed on could be anything (custom level makers are crazy!). --- desktop_version/src/Render.cpp | 60 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 782fcb5d..96f2150d 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1527,56 +1527,56 @@ void gamerender(void) if (game.swngame == 0) { std::string tempstring = help.timestring(game.swntimer); - graphics.bigprint( -1, 20, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, 20, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); } else if (game.swngame == 1) { if (game.swnmessage == 0) { std::string tempstring = help.timestring(game.swntimer); - graphics.Print( 10, 10, "Current Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); - graphics.bigprint( 25, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); + graphics.bprint( 10, 10, "Current Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); + graphics.bigbprint( 25, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); tempstring = help.timestring(game.swnrecord); - graphics.Print( 240, 10, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); - graphics.bigrprint( 300, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); + graphics.bprint( 240, 10, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); + graphics.bigbrprint( 300, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); switch(game.swnbestrank) { case 0: - graphics.Print( -1, 204, "Next Trophy at 5 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "Next Trophy at 5 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; case 1: - graphics.Print( -1, 204, "Next Trophy at 10 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "Next Trophy at 10 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; case 2: - graphics.Print( -1, 204, "Next Trophy at 15 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "Next Trophy at 15 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; case 3: - graphics.Print( -1, 204, "Next Trophy at 20 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "Next Trophy at 20 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; case 4: - graphics.Print( -1, 204, "Next Trophy at 30 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "Next Trophy at 30 seconds", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; case 5: - graphics.Print( -1, 204, "Next Trophy at 1 minute", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "Next Trophy at 1 minute", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; case 6: - graphics.Print( -1, 204, "All Trophies collected!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bprint( -1, 204, "All Trophies collected!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); break; } } else if (game.swnmessage == 1) { std::string tempstring = help.timestring(game.swntimer); - graphics.Print( 10, 10, "Current Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); - graphics.bigprint( 25, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); + graphics.bprint( 10, 10, "Current Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); + graphics.bigbprint( 25, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); tempstring = help.timestring(game.swnrecord); if (int(game.deathseq / 5) % 2 == 1) { - graphics.Print( 240, 10, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); - graphics.bigrprint( 300, 24, tempstring, 128 - (help.glow), 220 - (help.glow), 128 - (help.glow / 2), false, 2); + graphics.bprint( 240, 10, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); + graphics.bigbrprint( 300, 24, tempstring, 128 - (help.glow), 220 - (help.glow), 128 - (help.glow / 2), false, 2); - graphics.bigprint( -1, 200, "New Record!", 128 - (help.glow), 220 - (help.glow), 128 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, 200, "New Record!", 128 - (help.glow), 220 - (help.glow), 128 - (help.glow / 2), true, 2); } } else if (game.swnmessage >= 2) @@ -1584,19 +1584,19 @@ void gamerender(void) game.swnmessage--; if (game.swnmessage == 2) game.swnmessage = 0; std::string tempstring = help.timestring(game.swntimer); - graphics.Print( 10, 10, "Current Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); - graphics.bigprint( 25, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); + graphics.bprint( 10, 10, "Current Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); + graphics.bigbprint( 25, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); tempstring = help.timestring(game.swnrecord); - graphics.Print( 240, 10, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); - graphics.bigrprint( 300, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); + graphics.bprint( 240, 10, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false); + graphics.bigbrprint( 300, 24, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), false, 2); if (int(game.swnmessage / 5) % 2 == 1) { - graphics.bigprint( -1, 200, "New Trophy!", 220 - (help.glow), 128 - (help.glow), 128 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, 200, "New Trophy!", 220 - (help.glow), 128 - (help.glow), 128 - (help.glow / 2), true, 2); } } - graphics.Print( 20, 228, "[Press ENTER to stop]", 160 - (help.glow/2), 160 - (help.glow/2), 160 - (help.glow/2), true); + graphics.bprint( 20, 228, "[Press ENTER to stop]", 160 - (help.glow/2), 160 - (help.glow/2), 160 - (help.glow/2), true); } else if(game.swngame==2) { @@ -1614,24 +1614,24 @@ void gamerender(void) y1 = 10; y2 = 30; } - graphics.bigprint( -1, y1, "Survive for", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); - graphics.bigprint( -1, y2, "60 seconds!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, y1, "Survive for", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, y2, "60 seconds!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); } } else if(game.swngame==7) { if (game.swndelay >= 60) { - graphics.bigprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); std::string tempstring = help.timestring(game.swnrecord); - graphics.Print( 240, 190, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); - graphics.bigrprint( 300, 205, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); + graphics.bprint( 240, 190, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true); + graphics.bigbrprint( 300, 205, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); } else if (int(game.swndelay / 10) % 2 == 1) { - graphics.bigprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); - graphics.bigprint( -1, 200, "GO!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 3); + graphics.bigbprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2); + graphics.bigbprint( -1, 200, "GO!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 3); } } }