summaryrefslogtreecommitdiff
path: root/editor/editor_settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_settings.cpp')
-rw-r--r--editor/editor_settings.cpp81
1 files changed, 44 insertions, 37 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 07af60d634..3bc85e8468 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -29,23 +29,23 @@
/*************************************************************************/
#include "editor_settings.h"
-#include "editor_node.h"
-#include "io/compression.h"
-#include "io/config_file.h"
-#include "io/file_access_memory.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "io/translation_loader_po.h"
-#include "os/dir_access.h"
-#include "os/file_access.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "project_settings.h"
+#include "core/io/compression.h"
+#include "core/io/config_file.h"
+#include "core/io/file_access_memory.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/io/translation_loader_po.h"
+#include "core/os/dir_access.h"
+#include "core/os/file_access.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
+#include "core/version.h"
+#include "editor/editor_node.h"
+#include "editor/translations.gen.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/viewport.h"
-#include "translations.gen.h"
-#include "version.h"
Ref<EditorSettings> EditorSettings::singleton = NULL;
@@ -93,6 +93,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
emit_signal("settings_changed");
return true;
}
+
bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
@@ -216,6 +217,12 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
return p_default;
}
+Variant _EDITOR_GET(const String &p_var) {
+
+ ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has(p_var), Variant())
+ return EditorSettings::get_singleton()->get(p_var);
+}
+
static Dictionary _get_builtin_script_templates() {
Dictionary templates;
@@ -246,13 +253,14 @@ static void _create_script_templates(const String &p_path) {
dir->change_dir(p_path);
for (int i = 0; i < keys.size(); i++) {
if (!dir->file_exists(keys[i])) {
- file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE);
- ERR_FAIL_COND(!file);
+ Error err = file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE);
+ ERR_FAIL_COND(err != OK);
file->store_string(templates[keys[i]]);
file->close();
}
}
+ memdelete(dir);
memdelete(file);
}
@@ -266,7 +274,6 @@ void EditorSettings::create() {
String config_path;
String config_dir;
- //String config_file="editor_settings.xml";
Ref<ConfigFile> extra_config = memnew(ConfigFile);
String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
@@ -280,6 +287,7 @@ void EditorSettings::create() {
self_contained = true;
extra_config->load(exe_path + "/_sc_");
}
+ memdelete(d);
if (self_contained) {
// editor is self contained
@@ -562,7 +570,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("interface/quit_confirmation", true);
set("interface/theme/preset", 0);
- hints["interface/theme/preset"] = PropertyInfo(Variant::INT, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Grey,Godot 2,Arc,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/theme/preset"] = PropertyInfo(Variant::INT, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Grey,Godot 2,Arc,Light,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("interface/theme/icon_and_font_color", 0);
+ hints["interface/theme/icon_and_font_color"] = PropertyInfo(Variant::INT, "interface/theme/icon_and_font_color", PROPERTY_HINT_ENUM, "Auto,Dark,Light", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
set("interface/theme/base_color", Color::html("#323b4f"));
hints["interface/theme/highlight_color"] = PropertyInfo(Variant::COLOR, "interface/theme/highlight_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
set("interface/theme/highlight_color", Color::html("#699ce8"));
@@ -583,7 +593,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("filesystem/directories/autoscan_project_path", "");
hints["filesystem/directories/autoscan_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/autoscan_project_path", PROPERTY_HINT_GLOBAL_DIR);
- set("filesystem/directories/default_project_path", "");
+ set("filesystem/directories/default_project_path", OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS));
hints["filesystem/directories/default_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/default_project_path", PROPERTY_HINT_GLOBAL_DIR);
set("filesystem/directories/default_project_export_path", "");
hints["global/default_project_export_path"] = PropertyInfo(Variant::STRING, "global/default_project_export_path", PROPERTY_HINT_GLOBAL_DIR);
@@ -593,6 +603,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Default");
set("text_editor/theme/line_spacing", 4);
+ set("text_editor/theme/adapted_code_editor_background_color", true);
_load_default_text_editor_theme();
@@ -615,6 +626,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/line_numbers/line_length_guideline_column", 80);
hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 10");
+ set("text_editor/open_scripts/smooth_scrolling", true);
+ set("text_editor/open_scripts/v_scroll_speed", 80);
set("text_editor/open_scripts/show_members_overview", true);
set("text_editor/files/trim_trailing_whitespace_on_save", false);
@@ -635,7 +648,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/files/maximum_recent_files", 20);
hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 0");
- //set("docks/scene_tree/display_old_action_buttons",false);
set("docks/scene_tree/start_create_dialog_fully_expanded", false);
set("docks/scene_tree/draw_relationship_lines", false);
set("docks/scene_tree/relationship_line_color", Color::html("464646"));
@@ -663,6 +675,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("editors/3d/emulate_3_button_mouse", false);
set("editors/3d/warped_mouse_panning", true);
+ set("editors/3d/orbit_sensitivity", 0.4);
+ set("editors/3d/freelook_inertia", 3);
+
set("editors/3d/freelook_base_speed", 1);
set("editors/3d/freelook_activation_modifier", 0);
@@ -681,9 +696,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("editors/2d/pan_speed", 20);
set("editors/poly_editor/point_grab_radius", 8);
+ set("editors/poly_editor/show_previous_outline", true);
set("run/window_placement/rect", 1);
- hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Default,Centered,Custom Position,Force Maximized,Force Full Screen");
+ hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen");
String screen_hints = TTR("Default (Same as Editor)");
for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) {
screen_hints += ",Monitor " + itos(i + 1);
@@ -694,8 +710,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("filesystem/on_save/compress_binary_resources", true);
set("filesystem/on_save/save_modified_external_resources", true);
- //set("filesystem/on_save/save_paths_as_relative",false);
- //set("filesystem/on_save/save_paths_without_extension",false);
set("text_editor/tools/create_signal_callbacks", true);
@@ -721,11 +735,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("filesystem/import/pvrtc_texture_tool", "");
#ifdef WINDOWS_ENABLED
- hints["filesystem/import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "*.exe");
+ hints["filesystem/import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "filesystem/import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "*.exe");
#else
- hints["import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "");
+ hints["filesystem/import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "filesystem/import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "");
#endif
- // TODO: Rename to "filesystem/import/pvrtc_fast_conversion" to match other names?
set("filesystem/import/pvrtc_fast_conversion", false);
set("run/auto_save/save_before_running", true);
@@ -800,10 +813,7 @@ void EditorSettings::notify_changes() {
_THREAD_SAFE_METHOD_
- SceneTree *sml = NULL;
-
- if (OS::get_singleton()->get_main_loop())
- sml = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
+ SceneTree *sml = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
if (!sml) {
return;
@@ -843,9 +853,9 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) {
hints[p_hint.name] = p_hint;
}
-void EditorSettings::set_favorite_dirs(const Vector<String> &p_favorites) {
+void EditorSettings::set_favorite_dirs(const Vector<String> &p_favorites_dirs) {
- favorite_dirs = p_favorites;
+ favorite_dirs = p_favorites_dirs;
FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"), FileAccess::WRITE);
if (f) {
for (int i = 0; i < favorite_dirs.size(); i++)
@@ -859,9 +869,9 @@ Vector<String> EditorSettings::get_favorite_dirs() const {
return favorite_dirs;
}
-void EditorSettings::set_recent_dirs(const Vector<String> &p_recent) {
+void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) {
- recent_dirs = p_recent;
+ recent_dirs = p_recent_dirs;
FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"), FileAccess::WRITE);
if (f) {
for (int i = 0; i < recent_dirs.size(); i++)
@@ -1144,7 +1154,6 @@ void EditorSettings::_bind_methods() {
EditorSettings::EditorSettings() {
- //singleton=this;
last_order = 0;
optimize_save = true;
save_changed_setting = true;
@@ -1174,8 +1183,6 @@ EditorSettings::EditorSettings() {
}
EditorSettings::~EditorSettings() {
-
- //singleton=NULL;
}
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {