From b26ccd914d6109fa1492c6734745049db2b294d8 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 1 Oct 2021 20:59:55 -0700 Subject: [PATCH] Simplify flipme text box position correction It now looks more like the FLIP macro in Render.cpp: The y-position is simply the height of the area the object is being flipped in, minus the y-position itself, minus the height of the object. So: flipped_yp = constant - yp - height This is just a mathematical simplification of the existing statement, which is: flipped_yp = yp + 2 * (constant/2 - yp) - height Using algebra, the 2 distributes into the parentheses, so flipped_yp = yp + constant - 2 * yp - height And the two `yp`s add together, so flipped_yp = constant - yp - height It's more readable this way. Also I am using a named constant instead of a hardcoded one. --- 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 2edaf056..995780a9 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -990,7 +990,7 @@ void Graphics::drawgui(void) yp = textboxes[i].yp; if (flipmode && textboxes[i].flipme) { - yp += 2 * (120 - yp) - 8 * (textboxes[i].lines.size() + 2); + yp = SCREEN_HEIGHT_PIXELS - yp - 8 * (textboxes[i].lines.size() + 2); } if (textboxes[i].r == 0 && textboxes[i].g == 0 && textboxes[i].b == 0)