make hdpi manually configurable in project settings

also added hidpi support to project manager
This commit is contained in:
Juan Linietsky 2016-06-05 18:43:45 -03:00
parent 8d497301d4
commit 684a1207c0
5 changed files with 38 additions and 3 deletions

View File

@ -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"));

View File

@ -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;
}

View File

@ -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)

View File

@ -493,6 +493,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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);

View File

@ -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> theme = Ref<Theme>( 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!="") {