Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not override window setting defaults #12022

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,16 +797,19 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
return OK;
}

Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_override_default) {

Variant ret;
if (ProjectSettings::get_singleton()->has_setting(p_var)) {
ret = ProjectSettings::get_singleton()->get(p_var);
} else {
ProjectSettings::get_singleton()->set(p_var, p_default);
p_override_default = true;
ret = p_default;
}
ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
if (p_override_default) {
ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
}
ProjectSettings::get_singleton()->set_builtin_order(p_var);
return ret;
}
Expand Down
5 changes: 3 additions & 2 deletions core/project_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ class ProjectSettings : public Object {
};

//not a macro any longer
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value)
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_override_default);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true)
#define GLOBAL_DEF_MISSING(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false)
#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var)

#endif
22 changes: 13 additions & 9 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,19 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
}

GLOBAL_DEF("display/window/size/width", video_mode.width);
GLOBAL_DEF("display/window/size/height", video_mode.height);
GLOBAL_DEF("display/window/dpi/allow_hidpi", false);
GLOBAL_DEF("display/window/size/fullscreen", video_mode.fullscreen);
GLOBAL_DEF("display/window/size/resizable", video_mode.resizable);
GLOBAL_DEF("display/window/size/borderless", video_mode.borderless_window);
use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", use_vsync);
GLOBAL_DEF("display/window/size/test_width", 0);
GLOBAL_DEF("display/window/size/test_height", 0);
// these settings may have been retrieved above, we should not
// override their defaults with retrieved values
GLOBAL_DEF_MISSING("display/window/size/width", video_mode.width);
GLOBAL_DEF_MISSING("display/window/size/height", video_mode.height);
GLOBAL_DEF_MISSING("display/window/dpi/allow_hidpi", false);
GLOBAL_DEF_MISSING("display/window/dpi/allow_hidpi", false);
GLOBAL_DEF_MISSING("display/window/size/fullscreen", video_mode.fullscreen);
GLOBAL_DEF_MISSING("display/window/size/resizable", video_mode.resizable);
GLOBAL_DEF_MISSING("display/window/size/borderless", video_mode.borderless_window);
use_vsync = GLOBAL_DEF_MISSING("display/window/vsync/use_vsync", use_vsync);
GLOBAL_DEF_MISSING("display/window/size/test_width", 0);
GLOBAL_DEF_MISSING("display/window/size/test_height", 0);

GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2);
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3);

Expand Down