Skip to content

Commit

Permalink
Replace float scale with int scale
Browse files Browse the repository at this point in the history
  • Loading branch information
NyakoFox committed Aug 27, 2024
1 parent 2bc2f31 commit db611bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions desktop_version/src/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,11 +1989,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;
Expand Down
5 changes: 3 additions & 2 deletions desktop_version/src/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions desktop_version/src/Touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace touch
{
std::vector<VVV_Finger> fingers;
TouchButton buttons[NUM_TOUCH_BUTTONS];
float scale;
int scale;

int get_rect(TouchButton* button, SDL_Rect* rect)
{
Expand All @@ -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++)
{
Expand Down
2 changes: 1 addition & 1 deletion desktop_version/src/Touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace touch
{
extern std::vector<VVV_Finger> fingers;
extern TouchButton buttons[NUM_TOUCH_BUTTONS];
extern float scale;
extern int scale;

void refresh_buttons(void);
void reset(void);
Expand Down

0 comments on commit db611bd

Please sign in to comment.