From a53addecdeb0f3134a8cee98ca4bc0ca2981bdcc Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Thu, 11 Apr 2024 19:58:49 -0300 Subject: [PATCH] Replace float scale with int scale --- desktop_version/src/Input.cpp | 6 +++--- desktop_version/src/Render.cpp | 5 +++-- desktop_version/src/Touch.cpp | 6 +++--- desktop_version/src/Touch.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 0ee8e4af..b25ad02d 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1995,11 +1995,11 @@ static void menuactionpress(void) music.playef(Sound_CRY); break; case 1: - touch::scale += 0.5; + touch::scale += 5; music.playef(Sound_VIRIDIAN); - if (touch::scale > 2) + if (touch::scale > 20) { - touch::scale = 0.5; + touch::scale = 5; } game.savestatsandsettings_menu(); break; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b54f8b39..d6bd6b0b 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -784,9 +784,10 @@ static void menurender(void) font::print_wrap(PR_CEN, -1, 65, loc::gettext("Change the scale of the UI buttons."), tr, tg, tb); char buffer[SCREEN_WIDTH_CHARS + 1]; + float scale = (float)touch::scale / 10.0; vformat_buf(buffer, sizeof(buffer), loc::gettext("Current scale: {scale}.{extra}x"), "scale:int, extra:int", - (int)touch::scale, - (int)((float)((float)touch::scale - (int)touch::scale) * 10) + (int) scale, + (int) ((float) ((float) scale - (int) scale) * 10) ); font::print(PR_CEN, -1, 75, buffer, tr, tg, tb); break; diff --git a/desktop_version/src/Touch.cpp b/desktop_version/src/Touch.cpp index 52106a34..7552bdeb 100644 --- a/desktop_version/src/Touch.cpp +++ b/desktop_version/src/Touch.cpp @@ -15,7 +15,7 @@ namespace touch { std::vector fingers; TouchButton buttons[NUM_TOUCH_BUTTONS]; - float scale; + int scale; int get_rect(TouchButton* button, SDL_Rect* rect) { @@ -35,12 +35,12 @@ namespace touch int scale_x = rect.w / SCREEN_WIDTH_PIXELS; int scale_y = rect.h / SCREEN_HEIGHT_PIXELS; - return SDL_ceil(SDL_min(scale_x, scale_y) * scale); + return SDL_ceil(SDL_min(scale_x, scale_y) * ((float) scale / 10.f)); } void init(void) { - scale = 1; + scale = 10; for (int i = 0; i < NUM_TOUCH_BUTTONS; i++) { diff --git a/desktop_version/src/Touch.h b/desktop_version/src/Touch.h index 614eb1a4..ce9188d2 100644 --- a/desktop_version/src/Touch.h +++ b/desktop_version/src/Touch.h @@ -46,7 +46,7 @@ namespace touch { extern std::vector fingers; extern TouchButton buttons[NUM_TOUCH_BUTTONS]; - extern float scale; + extern int scale; void refresh_buttons(void); void reset(void);