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.cpp80
1 files changed, 49 insertions, 31 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 1953270b08..25406055f2 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -139,10 +139,10 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "shortcuts") {
Array arr;
- for (const Map<String, Ref<Shortcut>>::Element *E = shortcuts.front(); E; E = E->next()) {
- Ref<Shortcut> sc = E->get();
+ for (const KeyValue<String, Ref<Shortcut>> &E : shortcuts) {
+ Ref<Shortcut> sc = E.value;
- if (builtin_action_overrides.has(E->key())) {
+ if (builtin_action_overrides.has(E.key)) {
// This shortcut was auto-generated from built in actions: don't save.
continue;
}
@@ -158,19 +158,19 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
}
}
- arr.push_back(E->key());
+ arr.push_back(E.key);
arr.push_back(sc->get_event());
}
r_ret = arr;
return true;
} else if (p_name == "builtin_action_overrides") {
Array actions_arr;
- for (Map<String, List<Ref<InputEvent>>>::Element *E = builtin_action_overrides.front(); E; E = E->next()) {
- List<Ref<InputEvent>> events = E->get();
+ for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtin_action_overrides) {
+ List<Ref<InputEvent>> events = E.value;
// TODO: skip actions which are the same as the builtin.
Dictionary action_dict;
- action_dict["name"] = E->key();
+ action_dict["name"] = E.key;
Array events_arr;
for (List<Ref<InputEvent>>::Element *I = events.front(); I; I = I->next()) {
@@ -411,6 +411,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/automatically_open_screenshots", true);
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/single_window_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
_initial_set("interface/editor/hide_console_window", false);
+ _initial_set("interface/editor/mouse_extra_buttons_navigate_history", true);
_initial_set("interface/editor/save_each_scene_on_quit", true); // Regression
// Inspector
@@ -459,6 +460,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// FileSystem
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "docks/filesystem/thumbnail_size", 64, "32,128,16")
_initial_set("docks/filesystem/always_show_folders", true);
+ _initial_set("docks/filesystem/textfile_extensions", "txt,md,cfg,ini,log,json,yml,yaml,toml");
// Property editor
_initial_set("docks/property_editor/auto_refresh_interval", 0.2); //update 5 times per second by default
@@ -592,18 +594,16 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/3d/navigation/warped_mouse_panning", true);
// 3D: Navigation feel
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/orbit_sensitivity", 0.4, "0.0,2,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/orbit_inertia", 0.05, "0.0,1,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/translation_inertia", 0.15, "0.0,1,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/zoom_inertia", 0.075, "0.0,1,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/manipulation_orbit_inertia", 0.075, "0.0,1,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/manipulation_translation_inertia", 0.075, "0.0,1,0.01")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/orbit_sensitivity", 0.25, "0.01,2,0.001")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/orbit_inertia", 0.0, "0,1,0.001")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/translation_inertia", 0.05, "0,1,0.001")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/navigation_feel/zoom_inertia", 0.05, "0,1,0.001")
// 3D: Freelook
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/freelook/freelook_navigation_scheme", 0, "Default,Partially Axis-Locked (id Tech),Fully Axis-Locked (Minecraft)")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/freelook/freelook_sensitivity", 0.4, "0.0,2,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/freelook/freelook_inertia", 0.1, "0.0,1,0.01")
- EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/freelook/freelook_base_speed", 5.0, "0.0,10,0.01")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/freelook/freelook_sensitivity", 0.25, "0.01,2,0.001")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/freelook/freelook_inertia", 0.0, "0,1,0.001")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/3d/freelook/freelook_base_speed", 5.0, "0,10,0.01")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/freelook/freelook_activation_modifier", 0, "None,Shift,Alt,Meta,Ctrl")
_initial_set("editors/3d/freelook/freelook_speed_zoom_link", false);
@@ -712,7 +712,7 @@ void EditorSettings::_load_godot2_text_editor_theme() {
_initial_set("text_editor/theme/highlighting/background_color", Color(0.13, 0.12, 0.15));
_initial_set("text_editor/theme/highlighting/completion_background_color", Color(0.17, 0.16, 0.2));
_initial_set("text_editor/theme/highlighting/completion_selected_color", Color(0.26, 0.26, 0.27));
- _initial_set("text_editor/theme/highlighting/completion_existing_color", Color(0.13, 0.87, 0.87, 0.87));
+ _initial_set("text_editor/theme/highlighting/completion_existing_color", Color(0.87, 0.87, 0.87, 0.13));
_initial_set("text_editor/theme/highlighting/completion_scroll_color", Color(1, 1, 1));
_initial_set("text_editor/theme/highlighting/completion_font_color", Color(0.67, 0.67, 0.67));
_initial_set("text_editor/theme/highlighting/text_color", Color(0.67, 0.67, 0.67));
@@ -1411,7 +1411,7 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
// If there was no override, check the default builtins to see if it has an InputEvent for the provided name.
if (sc.is_null()) {
- const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins().find(p_name);
+ const OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name);
if (builtin_default) {
sc.instantiate();
sc->set_event(builtin_default.get().front()->get());
@@ -1429,8 +1429,8 @@ Ref<Shortcut> EditorSettings::get_shortcut(const String &p_name) const {
}
void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
- for (const Map<String, Ref<Shortcut>>::Element *E = shortcuts.front(); E; E = E->next()) {
- r_shortcuts->push_back(E->key());
+ for (const KeyValue<String, Ref<Shortcut>> &E : shortcuts) {
+ r_shortcuts->push_back(E.key);
}
}
@@ -1446,6 +1446,23 @@ Ref<Shortcut> ED_GET_SHORTCUT(const String &p_path) {
return sc;
}
+void ED_SHORTCUT_OVERRIDE(const String &p_path, const String &p_feature, Key p_keycode) {
+ Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
+ ERR_FAIL_COND_MSG(!sc.is_valid(), "Used ED_SHORTCUT_OVERRIDE with invalid shortcut: " + p_path + ".");
+
+ // Only add the override if the OS supports the provided feature.
+ if (OS::get_singleton()->has_feature(p_feature)) {
+ Ref<InputEventKey> ie;
+ if (p_keycode) {
+ ie = InputEventKey::create_reference(p_keycode);
+ }
+
+ // Directly override the existing shortcut.
+ sc->set_event(ie);
+ sc->set_meta("original", ie);
+ }
+}
+
Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode) {
#ifdef OSX_ENABLED
// Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS
@@ -1456,14 +1473,7 @@ Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keyc
Ref<InputEventKey> ie;
if (p_keycode) {
- ie.instantiate();
-
- ie->set_unicode(p_keycode & KEY_CODE_MASK);
- ie->set_keycode(p_keycode & KEY_CODE_MASK);
- ie->set_shift_pressed(bool(p_keycode & KEY_MASK_SHIFT));
- ie->set_alt_pressed(bool(p_keycode & KEY_MASK_ALT));
- ie->set_ctrl_pressed(bool(p_keycode & KEY_MASK_CTRL));
- ie->set_meta_pressed(bool(p_keycode & KEY_MASK_META));
+ ie = InputEventKey::create_reference(p_keycode);
}
if (!EditorSettings::get_singleton()) {
@@ -1504,15 +1514,23 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr
// Check if the provided event array is same as built-in. If it is, it does not need to be added to the overrides.
// Note that event order must also be the same.
bool same_as_builtin = true;
- OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins().find(p_name);
+ OrderedHashMap<String, List<Ref<InputEvent>>>::ConstElement builtin_default = InputMap::get_singleton()->get_builtins_with_feature_overrides_applied().find(p_name);
if (builtin_default) {
List<Ref<InputEvent>> builtin_events = builtin_default.get();
- if (p_events.size() == builtin_events.size()) {
+ // In the editor we only care about key events.
+ List<Ref<InputEventKey>> builtin_key_events;
+ for (Ref<InputEventKey> iek : builtin_events) {
+ if (iek.is_valid()) {
+ builtin_key_events.push_back(iek);
+ }
+ }
+
+ if (p_events.size() == builtin_key_events.size()) {
int event_idx = 0;
// Check equality of each event.
- for (const Ref<InputEvent> &E : builtin_events) {
+ for (const Ref<InputEventKey> &E : builtin_key_events) {
if (!E->is_match(p_events[event_idx])) {
same_as_builtin = false;
break;