From b3f7c174eacfa0180a2c67579e56e5a2ea6658a4 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 29 Apr 2020 23:46:50 -0700 Subject: [PATCH] Fix special text box images sometimes flashing These special images are the crewmates, Level Complete, and Game Complete images. They flashed depending on if you were lucky and happened to got your delta-timesteps just right when text boxes were fading in and out. Honestly, I'm surprised text box fading in/out hasn't ran into this issue before. It's insane luck that this issue hasn't occurred before or anything. Well, anyways, to fix this, there's now an attribute `allowspecial` on text boxes, and an optional parameter of the same name for Graphics::createtextbox(). This attribute is the only thing that will let these special text box images render. And any createtextbox()es that utilize these special images have been updated accordingly. --- desktop_version/src/Game.cpp | 44 ++++++++++++++++---------------- desktop_version/src/Graphics.cpp | 27 ++++++++++---------- desktop_version/src/Graphics.h | 2 +- desktop_version/src/Textbox.cpp | 1 + desktop_version/src/Textbox.h | 2 ++ 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 44db5e7e..3d68b0ff 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -2398,11 +2398,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 180, 165, 165, 255); + graphics.createtextbox("", -1, 180, 165, 165, 255, true); } else { - graphics.createtextbox("", -1, 12, 165, 165, 255); + graphics.createtextbox("", -1, 12, 165, 165, 255, true); } //graphics.addline(" Level Complete! "); graphics.addline(" "); @@ -2422,11 +2422,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 104, 175,174,174); + graphics.createtextbox("", -1, 104, 175,174,174, true); } else { - graphics.createtextbox("", -1, 64+8+16, 175,174,174); + graphics.createtextbox("", -1, 64+8+16, 175,174,174, true); } graphics.addline(" You have rescued "); graphics.addline(" a crew member! "); @@ -2515,11 +2515,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 180, 165, 165, 255); + graphics.createtextbox("", -1, 180, 165, 165, 255, true); } else { - graphics.createtextbox("", -1, 12, 165, 165, 255); + graphics.createtextbox("", -1, 12, 165, 165, 255, true); } //graphics.addline(" Level Complete! "); graphics.addline(" "); @@ -2539,11 +2539,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 104, 174,175,174); + graphics.createtextbox("", -1, 104, 174,175,174, true); } else { - graphics.createtextbox("", -1, 64+8+16, 174,175,174); + graphics.createtextbox("", -1, 64+8+16, 174,175,174, true); } graphics.addline(" You have rescued "); graphics.addline(" a crew member! "); @@ -2631,11 +2631,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 180, 165, 165, 255); + graphics.createtextbox("", -1, 180, 165, 165, 255, true); } else { - graphics.createtextbox("", -1, 12, 165, 165, 255); + graphics.createtextbox("", -1, 12, 165, 165, 255, true); } //graphics.addline(" Level Complete! "); graphics.addline(" "); @@ -2655,11 +2655,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 104, 174,174,175); + graphics.createtextbox("", -1, 104, 174,174,175, true); } else { - graphics.createtextbox("", -1, 64+8+16, 174,174,175); + graphics.createtextbox("", -1, 64+8+16, 174,174,175, true); } graphics.addline(" You have rescued "); graphics.addline(" a crew member! "); @@ -2748,11 +2748,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 180, 165, 165, 255); + graphics.createtextbox("", -1, 180, 165, 165, 255, true); } else { - graphics.createtextbox("", -1, 12, 165, 165, 255); + graphics.createtextbox("", -1, 12, 165, 165, 255, true); } //graphics.addline(" Level Complete! "); graphics.addline(" "); @@ -2772,11 +2772,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 104, 175,175,174); + graphics.createtextbox("", -1, 104, 175,175,174, true); } else { - graphics.createtextbox("", -1, 64+8+16, 175,175,174); + graphics.createtextbox("", -1, 64+8+16, 175,175,174, true); } graphics.addline(" You have rescued "); graphics.addline(" a crew member! "); @@ -2883,11 +2883,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 180, 165, 165, 255); + graphics.createtextbox("", -1, 180, 165, 165, 255, true); } else { - graphics.createtextbox("", -1, 12, 165, 165, 255); + graphics.createtextbox("", -1, 12, 165, 165, 255, true); } //graphics.addline(" Level Complete! "); graphics.addline(" "); @@ -2907,11 +2907,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 104, 175,174,175); + graphics.createtextbox("", -1, 104, 175,174,175, true); } else { - graphics.createtextbox("", -1, 64+8+16, 175,174,175); + graphics.createtextbox("", -1, 64+8+16, 175,174,175, true); } graphics.addline(" You have rescued "); graphics.addline(" a crew member! "); @@ -3179,11 +3179,11 @@ void Game::updatestate() if (graphics.flipmode) { - graphics.createtextbox("", -1, 180, 164, 165, 255); + graphics.createtextbox("", -1, 180, 164, 165, 255, true); } else { - graphics.createtextbox("", -1, 12, 164, 165, 255); + graphics.createtextbox("", -1, 12, 164, 165, 255, true); } graphics.addline(" "); graphics.addline(""); diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 5650f38c..e33b73e2 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -667,7 +667,7 @@ void Graphics::drawgui() } } - if ((textbox[i].yp == 12 || textbox[i].yp == 180) && textbox[i].r == 165) + if ((textbox[i].yp == 12 || textbox[i].yp == 180) && textbox[i].r == 165 && textbox[i].allowspecial) { if (flipmode) { @@ -678,7 +678,7 @@ void Graphics::drawgui() drawimage(0, 0, 12, true); } } - else if ((textbox[i].yp == 12 || textbox[i].yp == 180) && textbox[i].g == 165) + else if ((textbox[i].yp == 12 || textbox[i].yp == 180) && textbox[i].g == 165 && textbox[i].allowspecial) { if (flipmode) { @@ -691,27 +691,27 @@ void Graphics::drawgui() } if (flipmode) { - if (textbox[i].r == 175 && textbox[i].g == 175) + if (textbox[i].r == 175 && textbox[i].g == 175 && textbox[i].allowspecial) { //purple guy drawsprite(80 - 6, 64 + 48 + 4, 6, 220- help.glow/4 - int(fRandom()*20), 120- help.glow/4, 210 - help.glow/4); } - else if (textbox[i].r == 175 && textbox[i].b == 175) + else if (textbox[i].r == 175 && textbox[i].b == 175 && textbox[i].allowspecial) { //red guy drawsprite(80 - 6, 64 + 48+ 4, 6, 255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4); } - else if (textbox[i].r == 175) + else if (textbox[i].r == 175 && textbox[i].allowspecial) { //green guy drawsprite(80 - 6, 64 + 48 + 4, 6, 120 - help.glow / 4 - int(fRandom() * 20), 220 - help.glow / 4, 120 - help.glow / 4); } - else if (textbox[i].g == 175) + else if (textbox[i].g == 175 && textbox[i].allowspecial) { //yellow guy drawsprite(80 - 6, 64 + 48+ 4, 6, 220- help.glow/4 - int(fRandom()*20), 210 - help.glow/4, 120- help.glow/4); } - else if (textbox[i].b == 175) + else if (textbox[i].b == 175 && textbox[i].allowspecial) { //blue guy drawsprite(80 - 6, 64 + 48+ 4, 6, 75, 75, 255- help.glow/4 - int(fRandom()*20)); @@ -719,27 +719,27 @@ void Graphics::drawgui() } else { - if (textbox[i].r == 175 && textbox[i].g == 175) + if (textbox[i].r == 175 && textbox[i].g == 175 && textbox[i].allowspecial) { //purple guy drawsprite(80 - 6, 64 + 32 + 4, 0, 220- help.glow/4 - int(fRandom()*20), 120- help.glow/4, 210 - help.glow/4); } - else if (textbox[i].r == 175 && textbox[i].b == 175) + else if (textbox[i].r == 175 && textbox[i].b == 175 && textbox[i].allowspecial) { //red guy drawsprite(80 - 6, 64 + 32 + 4, 0, 255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4); } - else if (textbox[i].r == 175) + else if (textbox[i].r == 175 && textbox[i].allowspecial) { //green guy drawsprite(80 - 6, 64 + 32 + 4, 0, 120 - help.glow / 4 - int(fRandom() * 20), 220 - help.glow / 4, 120 - help.glow / 4); } - else if (textbox[i].g == 175) + else if (textbox[i].g == 175 && textbox[i].allowspecial) { //yellow guy drawsprite(80 - 6, 64 + 32 + 4, 0, 220- help.glow/4 - int(fRandom()*20), 210 - help.glow/4, 120- help.glow/4); } - else if (textbox[i].b == 175) + else if (textbox[i].b == 175 && textbox[i].allowspecial) { //blue guy drawsprite(80 - 6, 64 + 32 + 4, 0, 75, 75, 255- help.glow/4 - int(fRandom()*20)); @@ -1065,7 +1065,7 @@ void Graphics::textboxadjust() } -void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int g/*= 255*/, int b /*= 255*/ ) +void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int g/*= 255*/, int b /*= 255*/, bool allowspecial/*= false*/ ) { m = textbox.size(); @@ -1079,6 +1079,7 @@ void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int text.yp = yp; text.initcol(r, g, b); text.resize(); + text.allowspecial = allowspecial; textbox.push_back(text); } } diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index a3d44443..e8f1423c 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -53,7 +53,7 @@ public: void setwarprect(int a, int b, int c, int d); - void createtextbox(std::string t, int xp, int yp, int r= 255, int g= 255, int b = 255); + void createtextbox(std::string t, int xp, int yp, int r= 255, int g= 255, int b = 255, bool allowspecial = false); void textboxcenter(); diff --git a/desktop_version/src/Textbox.cpp b/desktop_version/src/Textbox.cpp index 692185c3..8d63781a 100644 --- a/desktop_version/src/Textbox.cpp +++ b/desktop_version/src/Textbox.cpp @@ -12,6 +12,7 @@ textboxclass::textboxclass() prev_tl = 0; tm = 0; timer = 0; + allowspecial = false; } void textboxclass::centerx() diff --git a/desktop_version/src/Textbox.h b/desktop_version/src/Textbox.h index 4b084c73..75b3092d 100644 --- a/desktop_version/src/Textbox.h +++ b/desktop_version/src/Textbox.h @@ -45,6 +45,8 @@ public: int max; + bool allowspecial; + }; #endif /* TEXTBOX_H */