Add missing setting callbacks for display_density_factor (#15273)

This commit is contained in:
grorp 2024-10-12 22:34:39 +02:00 committed by GitHub
parent 2188adc0f9
commit 5532248cd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 14 deletions

@ -72,6 +72,7 @@ ClientLauncher::~ClientLauncher()
{ {
delete input; delete input;
g_settings->deregisterChangedCallback("dpi_change_notifier", setting_changed_callback, this); g_settings->deregisterChangedCallback("dpi_change_notifier", setting_changed_callback, this);
g_settings->deregisterChangedCallback("display_density_factor", setting_changed_callback, this);
g_settings->deregisterChangedCallback("gui_scaling", setting_changed_callback, this); g_settings->deregisterChangedCallback("gui_scaling", setting_changed_callback, this);
delete g_fontengine; delete g_fontengine;
@ -133,6 +134,7 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
guienv = m_rendering_engine->get_gui_env(); guienv = m_rendering_engine->get_gui_env();
config_guienv(); config_guienv();
g_settings->registerChangedCallback("dpi_change_notifier", setting_changed_callback, this); g_settings->registerChangedCallback("dpi_change_notifier", setting_changed_callback, this);
g_settings->registerChangedCallback("display_density_factor", setting_changed_callback, this);
g_settings->registerChangedCallback("gui_scaling", setting_changed_callback, this); g_settings->registerChangedCallback("gui_scaling", setting_changed_callback, this);
g_fontengine = new FontEngine(guienv); g_fontengine = new FontEngine(guienv);

@ -33,10 +33,20 @@ FontEngine *g_fontengine = nullptr;
/** callback to be used on change of font size setting */ /** callback to be used on change of font size setting */
static void font_setting_changed(const std::string &name, void *userdata) static void font_setting_changed(const std::string &name, void *userdata)
{ {
if (g_fontengine) static_cast<FontEngine *>(userdata)->readSettings();
g_fontengine->readSettings();
} }
static const char *settings[] = {
"font_size", "font_bold", "font_italic", "font_size_divisible_by",
"mono_font_size", "mono_font_size_divisible_by",
"font_shadow", "font_shadow_alpha",
"font_path", "font_path_bold", "font_path_italic", "font_path_bold_italic",
"mono_font_path", "mono_font_path_bold", "mono_font_path_italic",
"mono_font_path_bold_italic",
"fallback_font_path",
"dpi_change_notifier", "display_density_factor", "gui_scaling",
};
/******************************************************************************/ /******************************************************************************/
FontEngine::FontEngine(gui::IGUIEnvironment* env) : FontEngine::FontEngine(gui::IGUIEnvironment* env) :
m_env(env) m_env(env)
@ -51,24 +61,16 @@ FontEngine::FontEngine(gui::IGUIEnvironment* env) :
readSettings(); readSettings();
const char *settings[] = {
"font_size", "font_bold", "font_italic", "font_size_divisible_by",
"mono_font_size", "mono_font_size_divisible_by",
"font_shadow", "font_shadow_alpha",
"font_path", "font_path_bold", "font_path_italic", "font_path_bold_italic",
"mono_font_path", "mono_font_path_bold", "mono_font_path_italic",
"mono_font_path_bold_italic",
"fallback_font_path",
"dpi_change_notifier", "gui_scaling",
};
for (auto name : settings) for (auto name : settings)
g_settings->registerChangedCallback(name, font_setting_changed, NULL); g_settings->registerChangedCallback(name, font_setting_changed, this);
} }
/******************************************************************************/ /******************************************************************************/
FontEngine::~FontEngine() FontEngine::~FontEngine()
{ {
for (auto name : settings)
g_settings->deregisterChangedCallback(name, font_setting_changed, this);
cleanCache(); cleanCache();
} }

@ -61,6 +61,7 @@ Hud::Hud(Client *client, LocalPlayer *player,
readScalingSetting(); readScalingSetting();
g_settings->registerChangedCallback("dpi_change_notifier", setting_changed_callback, this); g_settings->registerChangedCallback("dpi_change_notifier", setting_changed_callback, this);
g_settings->registerChangedCallback("display_density_factor", setting_changed_callback, this);
g_settings->registerChangedCallback("hud_scaling", setting_changed_callback, this); g_settings->registerChangedCallback("hud_scaling", setting_changed_callback, this);
for (auto &hbar_color : hbar_colors) for (auto &hbar_color : hbar_colors)
@ -170,6 +171,7 @@ void Hud::readScalingSetting()
Hud::~Hud() Hud::~Hud()
{ {
g_settings->deregisterChangedCallback("dpi_change_notifier", setting_changed_callback, this); g_settings->deregisterChangedCallback("dpi_change_notifier", setting_changed_callback, this);
g_settings->deregisterChangedCallback("display_density_factor", setting_changed_callback, this);
g_settings->deregisterChangedCallback("hud_scaling", setting_changed_callback, this); g_settings->deregisterChangedCallback("hud_scaling", setting_changed_callback, this);
if (m_selection_mesh) if (m_selection_mesh)