From 684a1207c0a08889be7024d5851c224877557053 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 5 Jun 2016 18:43:45 -0300 Subject: [PATCH] make hdpi manually configurable in project settings also added hidpi support to project manager --- tools/editor/editor_node.cpp | 13 +++++++++++++ tools/editor/editor_scale.cpp | 9 ++++++++- tools/editor/editor_scale.h | 2 +- tools/editor/editor_settings.cpp | 2 ++ tools/editor/project_manager.cpp | 15 ++++++++++++++- 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 72d5e496d91..4d92ffcc508 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -5256,6 +5256,19 @@ EditorNode::EditorNode() { // load settings if (!EditorSettings::get_singleton()) EditorSettings::create(); + { + int dpi_mode = EditorSettings::get_singleton()->get("global/hdpi_mode"); + print_line("DPI MODE: "+itos(dpi_mode)); + if (dpi_mode==0) { + editor_set_hidpi( OS::get_singleton()->get_screen_dpi(0) > 150 ); + } else if (dpi_mode==2) { + editor_set_hidpi(true); + } else { + editor_set_hidpi(false); + } + } + + ResourceLoader::set_abort_on_missing_resources(false); FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp index ecb1e1816fd..c332acc0ca1 100644 --- a/tools/editor/editor_scale.cpp +++ b/tools/editor/editor_scale.cpp @@ -1,7 +1,14 @@ #include "editor_scale.h" #include "os/os.h" +static bool editor_hidpi=false; + +void editor_set_hidpi(bool p_hidpi) { + + editor_hidpi=p_hidpi; +} + bool editor_is_hidpi() { - return OS::get_singleton()->get_screen_dpi(0) > 150; + return editor_hidpi; } diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h index 0f0e90595c3..a60cf00f0a8 100644 --- a/tools/editor/editor_scale.h +++ b/tools/editor/editor_scale.h @@ -1,7 +1,7 @@ #ifndef EDITOR_SCALE_H #define EDITOR_SCALE_H - +void editor_set_hidpi(bool p_hidpi); bool editor_is_hidpi(); #define EDSCALE (editor_is_hidpi() ? 2 : 1) diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 9dd00688c99..8b1b73d5d7b 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -493,6 +493,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { hints["global/editor_language"]=PropertyInfo(Variant::STRING,"global/editor_language",PROPERTY_HINT_ENUM,lang_hint,PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); } + set("global/hdpi_mode",0); + hints["global/hdpi_mode"]=PropertyInfo(Variant::INT,"global/hdpi_mode",PROPERTY_HINT_ENUM,"Auto,LoDPI,HiDPI",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); set("global/show_script_in_scene_tabs",false); set("global/font_size",14); hints["global/font_size"]=PropertyInfo(Variant::INT,"global/font_size",PROPERTY_HINT_RANGE,"10,40,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index af57d5264ed..ca5e1ab0f3f 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -45,8 +45,9 @@ #include "io/resource_saver.h" #include "editor_icons.h" +#include "editor_fonts.h" - +#include "editor_scale.h" class NewProjectDialog : public ConfirmationDialog { @@ -829,6 +830,17 @@ ProjectManager::ProjectManager() { if (!EditorSettings::get_singleton()) EditorSettings::create(); + { + int dpi_mode = EditorSettings::get_singleton()->get("global/hdpi_mode"); + if (dpi_mode==0) { + editor_set_hidpi( OS::get_singleton()->get_screen_dpi(0) > 150 ); + } else if (dpi_mode==2) { + editor_set_hidpi(true); + } else { + editor_set_hidpi(false); + } + } + FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); set_area_as_parent_rect(); @@ -836,6 +848,7 @@ ProjectManager::ProjectManager() { Ref theme = Ref( memnew( Theme ) ); set_theme(theme); editor_register_icons(theme); + editor_register_fonts(theme); String global_font = EditorSettings::get_singleton()->get("global/font"); if (global_font!="") {