Merge pull request #17706 from Calinou/overhaul-hidpi-settings

Overhaul the display scaling editor settings
This commit is contained in:
Rémi Verschelde 2018-03-23 14:12:20 +01:00 committed by GitHub
commit fd79de01c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 26 deletions

View File

@ -4864,18 +4864,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;
}
}