Replace float scale with int scale

This commit is contained in:
NyakoFox 2024-04-11 19:58:49 -03:00
parent 9e0c6ce76c
commit adff52940c
4 changed files with 10 additions and 9 deletions

View File

@ -1989,11 +1989,11 @@ static void menuactionpress(void)
music.playef(Sound_CRY); music.playef(Sound_CRY);
break; break;
case 1: case 1:
touch::scale += 0.5; touch::scale += 5;
music.playef(Sound_VIRIDIAN); music.playef(Sound_VIRIDIAN);
if (touch::scale > 2) if (touch::scale > 20)
{ {
touch::scale = 0.5; touch::scale = 5;
} }
game.savestatsandsettings_menu(); game.savestatsandsettings_menu();
break; break;

View File

@ -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); 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]; 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", vformat_buf(buffer, sizeof(buffer), loc::gettext("Current scale: {scale}.{extra}x"), "scale:int, extra:int",
(int)touch::scale, (int) scale,
(int)((float)((float)touch::scale - (int)touch::scale) * 10) (int) ((float) ((float) scale - (int) scale) * 10)
); );
font::print(PR_CEN, -1, 75, buffer, tr, tg, tb); font::print(PR_CEN, -1, 75, buffer, tr, tg, tb);
break; break;

View File

@ -15,7 +15,7 @@ namespace touch
{ {
std::vector<VVV_Finger> fingers; std::vector<VVV_Finger> fingers;
TouchButton buttons[NUM_TOUCH_BUTTONS]; TouchButton buttons[NUM_TOUCH_BUTTONS];
float scale; int scale;
int get_rect(TouchButton* button, SDL_Rect* rect) int get_rect(TouchButton* button, SDL_Rect* rect)
{ {
@ -35,12 +35,12 @@ namespace touch
int scale_x = rect.w / SCREEN_WIDTH_PIXELS; int scale_x = rect.w / SCREEN_WIDTH_PIXELS;
int scale_y = rect.h / SCREEN_HEIGHT_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) void init(void)
{ {
scale = 1; scale = 10;
for (int i = 0; i < NUM_TOUCH_BUTTONS; i++) for (int i = 0; i < NUM_TOUCH_BUTTONS; i++)
{ {

View File

@ -46,7 +46,7 @@ namespace touch
{ {
extern std::vector<VVV_Finger> fingers; extern std::vector<VVV_Finger> fingers;
extern TouchButton buttons[NUM_TOUCH_BUTTONS]; extern TouchButton buttons[NUM_TOUCH_BUTTONS];
extern float scale; extern int scale;
void refresh_buttons(void); void refresh_buttons(void);
void reset(void); void reset(void);