Minor preparations for being able to dynamically update UI scale

A lot of things in the game does not adapt to this quite yet
This commit is contained in:
ROllerozxa 2026-02-16 20:26:42 +01:00
commit 24de6fb825
3 changed files with 28 additions and 2 deletions

View file

@ -1280,8 +1280,7 @@ tproject_init(void)
setup_opengl_settings();
settings.save();
_tms.xppcm *= settings["uiscale"]->v.f;
_tms.yppcm *= settings["uiscale"]->v.f;
P.update_uiscale(settings["uiscale"]->v.f);
#ifdef NO_UI
settings["render_gui"]->set(false);
@ -1989,6 +1988,26 @@ principia::add_action(int id, void *data)
SDL_UnlockMutex(P.action_mutex);
}
static bool has_updated_uiscale = false;
static float base_xppcm = 0.f;
static float base_yppcm = 0.f;
void principia::update_uiscale(float scale) {
if (!has_updated_uiscale) {
base_xppcm = _tms.xppcm;
base_yppcm = _tms.yppcm;
}
_tms.xppcm = base_xppcm * scale;
_tms.yppcm = base_yppcm * scale;
if (!has_updated_uiscale) {
has_updated_uiscale = true;
} else {
tproject_window_size_changed();
}
}
tvec3
principia::get_light_normal()
{

View file

@ -195,6 +195,8 @@ extern class principia
};
tvec3 get_light_normal();
void update_uiscale(float new_uiscale);
} P;
struct principia_action

View file

@ -4955,6 +4955,11 @@ save_settings()
save_setting_row(r);
}
#if 0
// TODO: Dynamic update of UI scale without restart
P.update_uiscale(settings["uiscale"]->v.f);
#endif
sm::load_settings();
strcpy(tmp, get_cb_val(settings_shadow_res));