From 1eb3e73c008dfbd68bce2dac2c498e31fe206b1f Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 3 Sep 2021 14:59:00 -0700 Subject: [PATCH] drawpixeltextbox: Don't use unneeded variables `w` and `h` are provided alongside `w2` and `h2`. `w2` and `h2` are in blocks of 8, while `w` and `h` are in pixels. Therefore, `w2` and `h2` can just be figured out by diving `w` and `h` by 8. Also, `xo` and `yo` were used to slide the horizontal/vertical tiling of the text box a bit into one set of corners, so the horizontal/vertical tiling wouldn't visibly overlap with the other corners, if using default textures. This requires hardcoding it for each width/height of text box, which isn't something that's generalizable. Also, it results in corners that look weird if the corners have custom textures that don't adhere to the same shape as default textures. In the next commit I'll fix the non-multiple-of-8 text box dimensions differently. Can't do it in this commit or the diff looks weird (at least with my diff algorithm). --- desktop_version/src/Graphics.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 3e9a1853..cc1658a3 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1296,16 +1296,16 @@ void Graphics::drawpixeltextbox( int x, int y, int w, int h, int w2, int h2, int //madrect.x = x; madrect.y = y; madrect.w = w; madrect.h = h; FillRect(backBuffer,x,y,w,h, r/6, g/6, b/6 ); - for (int k = 0; k < w2-2; k++) + for (int k = 0; k < w/8-2; k++) { - drawcoloredtile(x + 8-xo + (k * 8), y, 41, r, g, b); - drawcoloredtile(x + 8-xo + (k * 8), y + (h) - 8, 46, r, g, b); + drawcoloredtile(x + 8 + (k * 8), y, 41, r, g, b); + drawcoloredtile(x + 8 + (k * 8), y + (h) - 8, 46, r, g, b); } - for (int k = 0; k < h2-2; k++) + for (int k = 0; k < h/8-2; k++) { - drawcoloredtile(x, y + 8-yo + (k * 8), 43, r, g, b); - drawcoloredtile(x + (w) - 8, y + 8-yo + (k * 8), 44, r, g, b); + drawcoloredtile(x, y + 8 + (k * 8), 43, r, g, b); + drawcoloredtile(x + (w) - 8, y + 8 + (k * 8), 44, r, g, b); } drawcoloredtile(x, y, 40, r, g, b);