From 2ac13815e45214510a7193d8ada52596b9a6b86c Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Mar 2021 19:47:37 -0700 Subject: [PATCH] Remove textrect attribute from textboxclass Instead of duplicating the same variables over and over again, Graphics::drawgui() can just make its own SDL_Rect. It's not that hard. As far as I can tell, textrect was always being properly kept up to date by the time Graphics::drawgui() got around to rendering (textboxclass::resize() keeps being called a LOT), so this shouldn't be a noticeable change from the user perspective. --- desktop_version/src/Graphics.cpp | 3 ++- desktop_version/src/Textbox.cpp | 8 -------- desktop_version/src/Textbox.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 4596c87b..4b6cea70 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -855,8 +855,9 @@ void Graphics::drawgui(void) } else { + SDL_Rect textrect = {textbox[i].xp, textbox[i].yp, textbox[i].w, textbox[i].h}; - FillRect(backBuffer,textbox[i].textrect, textbox[i].r/6, textbox[i].g/6, textbox[i].b / 6 ); + FillRect(backBuffer, textrect, textbox[i].r/6, textbox[i].g/6, textbox[i].b / 6 ); drawcoloredtile(textbox[i].xp, textbox[i].yp, 40, textbox[i].r, textbox[i].g, textbox[i].b); drawcoloredtile(textbox[i].xp+textbox[i].w-8, textbox[i].yp, 42, textbox[i].r, textbox[i].g, textbox[i].b); diff --git a/desktop_version/src/Textbox.cpp b/desktop_version/src/Textbox.cpp index 47df3aca..0e79c1c1 100644 --- a/desktop_version/src/Textbox.cpp +++ b/desktop_version/src/Textbox.cpp @@ -21,10 +21,6 @@ textboxclass::textboxclass(void) tg = 0; tb = 0; max = 0; - textrect.x = 0; - textrect.y = 0; - textrect.w = 0; - textrect.h = 0; } void textboxclass::centerx(void) @@ -121,10 +117,6 @@ void textboxclass::resize(void) lw = max; w = (max +2) * 8; h = (line.size() + 2) * 8; - textrect.x = xp; - textrect.y = yp; - textrect.w = w; - textrect.h = h; } void textboxclass::addline(std::string t) diff --git a/desktop_version/src/Textbox.h b/desktop_version/src/Textbox.h index 99dc76aa..8909f07d 100644 --- a/desktop_version/src/Textbox.h +++ b/desktop_version/src/Textbox.h @@ -35,7 +35,6 @@ public: int xp, yp, lw, w, h; int r,g,b; int tr,tg,tb; - SDL_Rect textrect; int timer; float tl;