Tweak the "Auto" editor setting hints to be more indicative

This affects the editor scale and font hinting settings which will now
display their automatically chosen value in parentheses.

(cherry picked from commit 57654508c9)
This commit is contained in:
Hugo Locurcio 2021-01-18 02:39:46 +01:00 committed by Rémi Verschelde
parent 158314c0b9
commit 314dd32d88
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 29 additions and 2 deletions

View file

@ -5766,6 +5766,8 @@ EditorNode::EditorNode() {
switch (display_scale) { switch (display_scale) {
case 0: { case 0: {
// Try applying a suitable display scale automatically. // Try applying a suitable display scale automatically.
// The code below is adapted in `editor/editor_settings.cpp` and `editor/project_manager.cpp`.
// Make sure to update those when modifying the code below.
#ifdef OSX_ENABLED #ifdef OSX_ENABLED
editor_set_scale(OS::get_singleton()->get_screen_max_scale()); editor_set_scale(OS::get_singleton()->get_screen_max_scale());
#else #else

View file

@ -317,7 +317,26 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Editor // Editor
_initial_set("interface/editor/display_scale", 0); _initial_set("interface/editor/display_scale", 0);
hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, "Auto,75%,100%,125%,150%,175%,200%,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); // Display what the Auto display scale setting effectively corresponds to.
// The code below is adapted in `editor/editor_node.cpp` and `editor/project_manager.cpp`.
// Make sure to update those when modifying the code below.
#ifdef OSX_ENABLED
float scale = OS::get_singleton()->get_screen_max_scale();
#else
const int screen = OS::get_singleton()->get_current_screen();
float scale;
if (OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).y >= 1400) {
// hiDPI display.
scale = 2.0;
} else if (OS::get_singleton()->get_screen_size(screen).y <= 800) {
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
// Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75;
} else {
scale = 1.0;
}
#endif
hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, vformat("Auto (%d%%),75%%,100%%,125%%,150%%,175%%,200%%,Custom", Math::round(scale * 100)), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/custom_display_scale", 1.0f); _initial_set("interface/editor/custom_display_scale", 1.0f);
hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/main_font_size", 14); _initial_set("interface/editor/main_font_size", 14);
@ -326,7 +345,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT); hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/font_antialiased", true); _initial_set("interface/editor/font_antialiased", true);
_initial_set("interface/editor/font_hinting", 0); _initial_set("interface/editor/font_hinting", 0);
hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto,None,Light,Normal", PROPERTY_USAGE_DEFAULT); #ifdef OSX_ENABLED
hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto (None),None,Light,Normal", PROPERTY_USAGE_DEFAULT);
#else
hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto (Light),None,Light,Normal", PROPERTY_USAGE_DEFAULT);
#endif
_initial_set("interface/editor/main_font", ""); _initial_set("interface/editor/main_font", "");
hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/main_font_bold", ""); _initial_set("interface/editor/main_font_bold", "");

View file

@ -2436,6 +2436,8 @@ ProjectManager::ProjectManager() {
switch (display_scale) { switch (display_scale) {
case 0: { case 0: {
// Try applying a suitable display scale automatically. // Try applying a suitable display scale automatically.
// The code below is adapted in `editor/editor_settings.cpp` and `editor/editor_node.cpp`.
// Make sure to update those when modifying the code below.
#ifdef OSX_ENABLED #ifdef OSX_ENABLED
editor_set_scale(OS::get_singleton()->get_screen_max_scale()); editor_set_scale(OS::get_singleton()->get_screen_max_scale());
#else #else