Overhaul the display scaling editor settings

This adds more scaling options, in addition to a custom scaling option
which allows any scale between 0.75 and 3.0 to be used.
This commit is contained in:
Hugo Locurcio 2018-03-22 20:20:42 +01:00
parent cc34406b5d
commit 61bf0d10d5
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
3 changed files with 78 additions and 26 deletions

View file

@ -4797,18 +4797,43 @@ EditorNode::EditorNode() {
FileAccess::set_backup_save(EDITOR_GET("filesystem/on_save/safe_save_on_backup_then_rename"));
{
int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode");
if (dpi_mode == 0) {
const int screen = OS::get_singleton()->get_current_screen();
editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} else if (dpi_mode == 1) {
editor_set_scale(0.75);
} else if (dpi_mode == 2) {
editor_set_scale(1.0);
} else if (dpi_mode == 3) {
editor_set_scale(1.5);
} else if (dpi_mode == 4) {
editor_set_scale(2.0);
int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
float custom_display_scale = EditorSettings::get_singleton()->get("interface/editor/custom_display_scale");
switch (display_scale) {
case 0: {
// Try applying a suitable display scale automatically
const int screen = OS::get_singleton()->get_current_screen();
editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} break;
case 1: {
editor_set_scale(0.75);
} break;
case 2: {
editor_set_scale(1.0);
} break;
case 3: {
editor_set_scale(1.25);
} break;
case 4: {
editor_set_scale(1.5);
} break;
case 5: {
editor_set_scale(1.75);
} break;
case 6: {
editor_set_scale(2.0);
} break;
default: {
editor_set_scale(custom_display_scale);
} break;
}
}

View file

@ -283,8 +283,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["interface/editor/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
}
_initial_set("interface/editor/hidpi_mode", 0);
hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_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);
_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.75,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/scene_tabs/show_script_button", false);
_initial_set("interface/editor/main_font_size", 14);
hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);

View file

@ -1517,18 +1517,43 @@ ProjectManager::ProjectManager() {
EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
{
int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode");
if (dpi_mode == 0) {
const int screen = OS::get_singleton()->get_current_screen();
editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} else if (dpi_mode == 1) {
editor_set_scale(0.75);
} else if (dpi_mode == 2) {
editor_set_scale(1.0);
} else if (dpi_mode == 3) {
editor_set_scale(1.5);
} else if (dpi_mode == 4) {
editor_set_scale(2.0);
int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
float custom_display_scale = EditorSettings::get_singleton()->get("interface/editor/custom_display_scale");
switch (display_scale) {
case 0: {
// Try applying a suitable display scale automatically
const int screen = OS::get_singleton()->get_current_screen();
editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} break;
case 1: {
editor_set_scale(0.75);
} break;
case 2: {
editor_set_scale(1.0);
} break;
case 3: {
editor_set_scale(1.25);
} break;
case 4: {
editor_set_scale(1.5);
} break;
case 5: {
editor_set_scale(1.75);
} break;
case 6: {
editor_set_scale(2.0);
} break;
default: {
editor_set_scale(custom_display_scale);
} break;
}
}