From 1b236d5ec7ea10ae39f6ac9d353043172338f8de Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 3 Sep 2021 15:31:59 -0700 Subject: [PATCH] Clean up style of drawtextbox/drawpixeltextbox All parameters are now made const, to aid in the reader in knowing that they aren't ever changed. Useless comments have been removed and been replaced with helpful comments. Useless parentheses have been removed. Spacing has been made consistent. Declarations and code are no longer mixed. --- desktop_version/src/Graphics.cpp | 50 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index a8692c4e..ba1713c0 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1289,45 +1289,63 @@ void Graphics::drawcrewman( int x, int y, int t, bool act, bool noshift /*=false } } -void Graphics::drawpixeltextbox( int x, int y, int w, int h, int r, int g, int b ) -{ - //given these parameters, draw a textbox with a pixel width +void Graphics::drawpixeltextbox( + const int x, + const int y, + const int w, + const int h, + const int r, + const int g, + const int b +) { + int k; - //madrect.x = x; madrect.y = y; madrect.w = w; madrect.h = h; - FillRect(backBuffer,x,y,w,h, r/6, g/6, b/6 ); + FillRect(backBuffer, x, y, w, h, r/6, g/6, b/6); - for (int k = 0; k < w/8-2; k++) + /* Horizontal tiles */ + for (k = 0; k < w/8 - 2; ++k) { - drawcoloredtile(x + 8 + (k * 8), y, 41, r, g, b); - drawcoloredtile(x + 8 + (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); } if (w % 8 != 0) { + /* Fill in horizontal gap */ drawcoloredtile(x + w - 16, y, 41, r, g, b); drawcoloredtile(x + w - 16, y + h - 8, 46, r, g, b); } - for (int k = 0; k < h/8-2; k++) + /* Vertical tiles */ + for (k = 0; k < h/8 - 2; ++k) { - 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 + 8 + k*8, 43, r, g, b); + drawcoloredtile(x + w - 8, y + 8 + k*8, 44, r, g, b); } if (h % 8 != 0) { + /* Fill in vertical gap */ drawcoloredtile(x, y + h - 16, 43, r, g, b); drawcoloredtile(x + w - 8, y + h - 16, 44, r, g, b); } + /* Corners */ drawcoloredtile(x, y, 40, r, g, b); - drawcoloredtile(x + (w) - 8, y, 42, r, g, b); - drawcoloredtile(x, y + (h) - 8, 45, r, g, b); - drawcoloredtile(x + (w) - 8, y + (h) - 8, 47, r, g, b); + drawcoloredtile(x + w - 8, y, 42, r, g, b); + drawcoloredtile(x, y + h - 8, 45, r, g, b); + drawcoloredtile(x + w - 8, y + h - 8, 47, r, g, b); } -void Graphics::drawtextbox( int x, int y, int w, int h, int r, int g, int b ) -{ +void Graphics::drawtextbox( + const int x, + const int y, + const int w, + const int h, + const int r, + const int g, + const int b +) { return drawpixeltextbox(x, y, w*8, h*8, r, g, b); }