summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/config/project_settings.cpp225
-rw-r--r--core/config/project_settings.h12
-rw-r--r--core/input/input.cpp16
-rw-r--r--core/input/input_event.cpp33
-rw-r--r--core/input/input_event.h4
-rw-r--r--core/input/input_map.cpp528
-rw-r--r--core/input/input_map.h11
-rw-r--r--core/io/resource_loader.cpp4
-rw-r--r--core/object/object.h1
-rw-r--r--core/string/translation.cpp12
10 files changed, 567 insertions, 279 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index b4ca31d77a..c872ae2162 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -32,6 +32,7 @@
#include "core/core_bind.h"
#include "core/core_string_names.h"
+#include "core/input/input_map.h"
#include "core/io/file_access_network.h"
#include "core/io/file_access_pack.h"
#include "core/io/marshalls.h"
@@ -124,6 +125,11 @@ void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restar
props[p_name].restart_if_changed = p_restart;
}
+void ProjectSettings::set_as_basic(const String &p_name, bool p_basic) {
+ ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
+ props[p_name].basic = p_basic;
+}
+
void ProjectSettings::set_ignore_value_in_docs(const String &p_name, bool p_ignore) {
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
#ifdef DEBUG_METHODS_ENABLED
@@ -269,6 +275,10 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
}
+ if (v->basic) {
+ vc.flags |= PROPERTY_USAGE_EDITOR_BASIC_SETTING;
+ }
+
if (v->restart_if_changed) {
vc.flags |= PROPERTY_USAGE_RESTART_IF_CHANGED;
}
@@ -278,7 +288,7 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
String prop_info_name = E->get().name;
int dot = prop_info_name.find(".");
- if (dot != -1) {
+ if (dot != -1 && !custom_prop_info.has(prop_info_name)) {
prop_info_name = prop_info_name.substr(0, dot);
}
@@ -908,7 +918,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
}
}
-Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed, bool p_ignore_value_in_docs) {
+Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed, bool p_ignore_value_in_docs, bool p_basic) {
Variant ret;
if (!ProjectSettings::get_singleton()->has_setting(p_var)) {
ProjectSettings::get_singleton()->set(p_var, p_default);
@@ -917,6 +927,7 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restar
ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
ProjectSettings::get_singleton()->set_builtin_order(p_var);
+ ProjectSettings::get_singleton()->set_as_basic(p_var, p_basic);
ProjectSettings::get_singleton()->set_restart_if_changed(p_var, p_restart_if_changed);
ProjectSettings::get_singleton()->set_ignore_value_in_docs(p_var, p_ignore_value_in_docs);
return ret;
@@ -1047,29 +1058,47 @@ void ProjectSettings::_bind_methods() {
ClassDB::bind_method(D_METHOD("save_custom", "file"), &ProjectSettings::_save_custom_bnd);
}
+void ProjectSettings::_add_builtin_input_map() {
+ if (InputMap::get_singleton()) {
+ OrderedHashMap<String, List<Ref<InputEvent>>> builtins = InputMap::get_singleton()->get_builtins();
+
+ for (OrderedHashMap<String, List<Ref<InputEvent>>>::Element E = builtins.front(); E; E = E.next()) {
+ Array events;
+
+ // Convert list of input events into array
+ for (List<Ref<InputEvent>>::Element *I = E.get().front(); I; I = I->next()) {
+ events.push_back(I->get());
+ }
+
+ Dictionary action;
+ action["deadzone"] = Variant(0.5f);
+ action["events"] = events;
+
+ String action_name = "input/" + E.key();
+ GLOBAL_DEF(action_name, action);
+ input_presets.push_back(action_name);
+ }
+ }
+}
+
ProjectSettings::ProjectSettings() {
// Initialization of engine variables should be done in the setup() method,
// so that the values can be overridden from project.godot or project.binary.
singleton = this;
- Array events;
- Dictionary action;
- Ref<InputEventKey> key;
- Ref<InputEventJoypadButton> joyb;
-
- GLOBAL_DEF("application/config/name", "");
- GLOBAL_DEF("application/config/description", "");
+ GLOBAL_DEF_BASIC("application/config/name", "");
+ GLOBAL_DEF_BASIC("application/config/description", "");
custom_prop_info["application/config/description"] = PropertyInfo(Variant::STRING, "application/config/description", PROPERTY_HINT_MULTILINE_TEXT);
- GLOBAL_DEF("application/run/main_scene", "");
+ GLOBAL_DEF_BASIC("application/run/main_scene", "");
custom_prop_info["application/run/main_scene"] = PropertyInfo(Variant::STRING, "application/run/main_scene", PROPERTY_HINT_FILE, "*.tscn,*.scn,*.res");
GLOBAL_DEF("application/run/disable_stdout", false);
GLOBAL_DEF("application/run/disable_stderr", false);
GLOBAL_DEF("application/config/use_custom_user_dir", false);
GLOBAL_DEF("application/config/custom_user_dir_name", "");
GLOBAL_DEF("application/config/project_settings_override", "");
- GLOBAL_DEF("audio/default_bus_layout", "res://default_bus_layout.tres");
- custom_prop_info["audio/default_bus_layout"] = PropertyInfo(Variant::STRING, "audio/default_bus_layout", PROPERTY_HINT_FILE, "*.tres");
+ GLOBAL_DEF_BASIC("audio/buses/default_bus_layout", "res://default_bus_layout.tres");
+ custom_prop_info["audio/buses/default_bus_layout"] = PropertyInfo(Variant::STRING, "audio/buses/default_bus_layout", PROPERTY_HINT_FILE, "*.tres");
PackedStringArray extensions = PackedStringArray();
extensions.push_back("gd");
@@ -1078,172 +1107,16 @@ ProjectSettings::ProjectSettings() {
}
extensions.push_back("shader");
- GLOBAL_DEF("editor/search_in_file_extensions", extensions);
- custom_prop_info["editor/search_in_file_extensions"] = PropertyInfo(Variant::PACKED_STRING_ARRAY, "editor/search_in_file_extensions");
-
- GLOBAL_DEF("editor/script_templates_search_path", "res://script_templates");
- custom_prop_info["editor/script_templates_search_path"] = PropertyInfo(Variant::STRING, "editor/script_templates_search_path", PROPERTY_HINT_DIR);
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_ENTER);
- events.push_back(key);
- key.instance();
- key->set_keycode(KEY_KP_ENTER);
- events.push_back(key);
- key.instance();
- key->set_keycode(KEY_SPACE);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_A);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_accept", action);
- input_presets.push_back("input/ui_accept");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_SPACE);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_Y);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_select", action);
- input_presets.push_back("input/ui_select");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_ESCAPE);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_B);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_cancel", action);
- input_presets.push_back("input/ui_cancel");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_TAB);
- events.push_back(key);
- action["events"] = events;
- GLOBAL_DEF("input/ui_focus_next", action);
- input_presets.push_back("input/ui_focus_next");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_TAB);
- key->set_shift(true);
- events.push_back(key);
- action["events"] = events;
- GLOBAL_DEF("input/ui_focus_prev", action);
- input_presets.push_back("input/ui_focus_prev");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_LEFT);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_DPAD_LEFT);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_left", action);
- input_presets.push_back("input/ui_left");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_RIGHT);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_DPAD_RIGHT);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_right", action);
- input_presets.push_back("input/ui_right");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_UP);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_DPAD_UP);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_up", action);
- input_presets.push_back("input/ui_up");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_DOWN);
- events.push_back(key);
- joyb.instance();
- joyb->set_button_index(JOY_BUTTON_DPAD_DOWN);
- events.push_back(joyb);
- action["events"] = events;
- GLOBAL_DEF("input/ui_down", action);
- input_presets.push_back("input/ui_down");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_PAGEUP);
- events.push_back(key);
- action["events"] = events;
- GLOBAL_DEF("input/ui_page_up", action);
- input_presets.push_back("input/ui_page_up");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_PAGEDOWN);
- events.push_back(key);
- action["events"] = events;
- GLOBAL_DEF("input/ui_page_down", action);
- input_presets.push_back("input/ui_page_down");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_HOME);
- events.push_back(key);
- action["events"] = events;
- GLOBAL_DEF("input/ui_home", action);
- input_presets.push_back("input/ui_home");
-
- action = Dictionary();
- action["deadzone"] = Variant(0.5f);
- events = Array();
- key.instance();
- key->set_keycode(KEY_END);
- events.push_back(key);
- action["events"] = events;
- GLOBAL_DEF("input/ui_end", action);
- input_presets.push_back("input/ui_end");
+ GLOBAL_DEF("editor/script/search_in_file_extensions", extensions);
+ custom_prop_info["editor/script/search_in_file_extensions"] = PropertyInfo(Variant::PACKED_STRING_ARRAY, "editor/script/search_in_file_extensions");
+
+ GLOBAL_DEF("editor/script/templates_search_path", "res://script_templates");
+ custom_prop_info["editor/script/templates_search_path"] = PropertyInfo(Variant::STRING, "editor/script/templates_search_path", PROPERTY_HINT_DIR);
+
+ _add_builtin_input_map();
custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
- custom_prop_info["rendering/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
+ custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
GLOBAL_DEF("physics/2d/run_on_thread", false);
GLOBAL_DEF("physics/3d/run_on_thread", false);
diff --git a/core/config/project_settings.h b/core/config/project_settings.h
index 645506f302..ed8fb19fa0 100644
--- a/core/config/project_settings.h
+++ b/core/config/project_settings.h
@@ -58,6 +58,7 @@ protected:
struct VariantContainer {
int order = 0;
bool persist = false;
+ bool basic = false;
Variant variant;
Variant initial;
bool hide_from_editor = false;
@@ -115,6 +116,9 @@ protected:
Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false);
+ void _add_builtin_input_map();
+
+protected:
static void _bind_methods();
public:
@@ -128,6 +132,7 @@ public:
String globalize_path(const String &p_path) const;
void set_initial_value(const String &p_name, const Variant &p_value);
+ void set_as_basic(const String &p_name, bool p_basic);
void set_restart_if_changed(const String &p_name, bool p_restart);
void set_ignore_value_in_docs(const String &p_name, bool p_ignore);
bool get_ignore_value_in_docs(const String &p_name) const;
@@ -174,11 +179,16 @@ public:
};
//not a macro any longer
-Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed = false, bool p_ignore_value_in_docs = false);
+Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed = false, bool p_ignore_value_in_docs = false, bool p_basic = false);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value)
#define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true)
#define GLOBAL_DEF_NOVAL(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, true)
#define GLOBAL_DEF_RST_NOVAL(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true, true)
#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var)
+#define GLOBAL_DEF_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, false, true)
+#define GLOBAL_DEF_RST_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true, false, true)
+#define GLOBAL_DEF_NOVAL_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, true, true)
+#define GLOBAL_DEF_RST_NOVAL_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true, true, true)
+
#endif // PROJECT_SETTINGS_H
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 48e573626d..90d96e3876 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -604,21 +604,21 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
}
}
- for (const Map<StringName, InputMap::Action>::Element *E = InputMap::get_singleton()->get_action_map().front(); E; E = E->next()) {
- if (InputMap::get_singleton()->event_is_action(p_event, E->key())) {
+ for (OrderedHashMap<StringName, InputMap::Action>::ConstElement E = InputMap::get_singleton()->get_action_map().front(); E; E = E.next()) {
+ if (InputMap::get_singleton()->event_is_action(p_event, E.key())) {
// If not echo and action pressed state has changed
- if (!p_event->is_echo() && is_action_pressed(E->key(), false) != p_event->is_action_pressed(E->key())) {
+ if (!p_event->is_echo() && is_action_pressed(E.key(), false) != p_event->is_action_pressed(E.key())) {
Action action;
action.physics_frame = Engine::get_singleton()->get_physics_frames();
action.process_frame = Engine::get_singleton()->get_process_frames();
- action.pressed = p_event->is_action_pressed(E->key());
+ action.pressed = p_event->is_action_pressed(E.key());
action.strength = 0.0f;
action.raw_strength = 0.0f;
- action.exact = InputMap::get_singleton()->event_is_action(p_event, E->key(), true);
- action_state[E->key()] = action;
+ action.exact = InputMap::get_singleton()->event_is_action(p_event, E.key(), true);
+ action_state[E.key()] = action;
}
- action_state[E->key()].strength = p_event->get_action_strength(E->key());
- action_state[E->key()].raw_strength = p_event->get_action_raw_strength(E->key());
+ action_state[E.key()].strength = p_event->get_action_strength(E.key());
+ action_state[E.key()].raw_strength = p_event->get_action_raw_strength(E.key());
}
}
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index b1c8f1ad66..c6910d2b1f 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -384,6 +384,31 @@ String InputEventKey::to_string() {
return vformat("InputEventKey: keycode=%s mods=%s physical=%s pressed=%s echo=%s", kc, mods, physical, p, e);
}
+Ref<InputEventKey> InputEventKey::create_reference(uint32_t p_keycode) {
+ Ref<InputEventKey> ie;
+ ie.instance();
+ ie->set_keycode(p_keycode & KEY_CODE_MASK);
+ ie->set_unicode(p_keycode & KEY_CODE_MASK);
+
+ if (p_keycode & KEY_MASK_SHIFT) {
+ ie->set_shift(true);
+ }
+ if (p_keycode & KEY_MASK_ALT) {
+ ie->set_alt(true);
+ }
+ if (p_keycode & KEY_MASK_CTRL) {
+ ie->set_control(true);
+ }
+ if (p_keycode & KEY_MASK_CMD) {
+ ie->set_command(true);
+ }
+ if (p_keycode & KEY_MASK_META) {
+ ie->set_metakey(true);
+ }
+
+ return ie;
+}
+
bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
Ref<InputEventKey> key = p_event;
if (key.is_null()) {
@@ -1011,6 +1036,14 @@ String InputEventJoypadButton::to_string() {
return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure));
}
+Ref<InputEventJoypadButton> InputEventJoypadButton::create_reference(int p_btn_index) {
+ Ref<InputEventJoypadButton> ie;
+ ie.instance();
+ ie->set_button_index(p_btn_index);
+
+ return ie;
+}
+
void InputEventJoypadButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index);
ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventJoypadButton::get_button_index);
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 1ce1fad9c2..df81b9fc75 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -260,6 +260,8 @@ public:
virtual String as_text() const override;
virtual String to_string() override;
+ static Ref<InputEventKey> create_reference(uint32_t p_keycode_with_modifier_masks);
+
InputEventKey() {}
};
@@ -406,6 +408,8 @@ public:
virtual String as_text() const override;
virtual String to_string() override;
+ static Ref<InputEventJoypadButton> create_reference(int p_btn_index);
+
InputEventJoypadButton() {}
};
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index c03e64eaf4..b31c431ead 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -88,8 +88,8 @@ List<StringName> InputMap::get_actions() const {
return actions;
}
- for (Map<StringName, Action>::Element *E = input_map.front(); E; E = E->next()) {
- actions.push_back(E->key());
+ for (OrderedHashMap<StringName, Action>::Element E = input_map.front(); E; E = E.next()) {
+ actions.push_back(E.key());
}
return actions;
@@ -179,12 +179,12 @@ Array InputMap::_action_get_events(const StringName &p_action) {
}
const List<Ref<InputEvent>> *InputMap::action_get_events(const StringName &p_action) {
- const Map<StringName, Action>::Element *E = input_map.find(p_action);
+ const OrderedHashMap<StringName, Action>::Element E = input_map.find(p_action);
if (!E) {
return nullptr;
}
- return &E->get().inputs;
+ return &E.get().inputs;
}
bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match) const {
@@ -192,7 +192,7 @@ bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName
}
bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength) const {
- Map<StringName, Action>::Element *E = input_map.find(p_action);
+ OrderedHashMap<StringName, Action>::Element E = input_map.find(p_action);
ERR_FAIL_COND_V_MSG(!E, false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
Ref<InputEventAction> input_event_action = p_event;
@@ -209,7 +209,7 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
bool pressed;
float strength;
float raw_strength;
- List<Ref<InputEvent>>::Element *event = _find_event(E->get(), p_event, p_exact_match, &pressed, &strength, &raw_strength);
+ List<Ref<InputEvent>>::Element *event = _find_event(E.get(), p_event, p_exact_match, &pressed, &strength, &raw_strength);
if (event != nullptr) {
if (p_pressed != nullptr) {
*p_pressed = pressed;
@@ -226,7 +226,7 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
}
}
-const Map<StringName, InputMap::Action> &InputMap::get_action_map() const {
+const OrderedHashMap<StringName, InputMap::Action> &InputMap::get_action_map() const {
return input_map;
}
@@ -260,84 +260,444 @@ void InputMap::load_from_project_settings() {
}
}
+struct _BuiltinActionDisplayName {
+ const char *name;
+ const char *display_name;
+};
+
+static const _BuiltinActionDisplayName _builtin_action_display_names[] = {
+ /* clang-format off */
+ { "ui_accept", TTRC("Accept") },
+ { "ui_select", TTRC("Select") },
+ { "ui_cancel", TTRC("Cancel") },
+ { "ui_focus_next", TTRC("Focus Next") },
+ { "ui_focus_prev", TTRC("Focus Prev") },
+ { "ui_left", TTRC("Left") },
+ { "ui_right", TTRC("Right") },
+ { "ui_up", TTRC("Up") },
+ { "ui_down", TTRC("Down") },
+ { "ui_page_up", TTRC("Page Up") },
+ { "ui_page_down", TTRC("Page Down") },
+ { "ui_home", TTRC("Home") },
+ { "ui_end", TTRC("End") },
+ { "ui_cut", TTRC("Cut") },
+ { "ui_copy", TTRC("Copy") },
+ { "ui_paste", TTRC("Paste") },
+ { "ui_undo", TTRC("Undo") },
+ { "ui_redo", TTRC("Redo") },
+ { "ui_text_completion_query", TTRC("Completion Query") },
+ { "ui_text_newline", TTRC("New Line") },
+ { "ui_text_newline_blank", TTRC("New Blank Line") },
+ { "ui_text_newline_above", TTRC("New Line Above") },
+ { "ui_text_indent", TTRC("Indent") },
+ { "ui_text_dedent", TTRC("Dedent") },
+ { "ui_text_backspace", TTRC("Backspace") },
+ { "ui_text_backspace_word", TTRC("Backspace Word") },
+ { "ui_text_backspace_word.OSX", TTRC("Backspace Word") },
+ { "ui_text_backspace_all_to_left", TTRC("Backspace all to Left") },
+ { "ui_text_backspace_all_to_left.OSX", TTRC("Backspace all to Left") },
+ { "ui_text_delete", TTRC("Delete") },
+ { "ui_text_delete_word", TTRC("Delete Word") },
+ { "ui_text_delete_word.OSX", TTRC("Delete Word") },
+ { "ui_text_delete_all_to_right", TTRC("Delete all to Right") },
+ { "ui_text_delete_all_to_right.OSX", TTRC("Delete all to Right") },
+ { "ui_text_caret_left", TTRC("Caret Left") },
+ { "ui_text_caret_word_left", TTRC("Caret Word Left") },
+ { "ui_text_caret_word_left.OSX", TTRC("Caret Word Left") },
+ { "ui_text_caret_right", TTRC("Caret Right") },
+ { "ui_text_caret_word_right", TTRC("Caret Word Right") },
+ { "ui_text_caret_word_right.OSX", TTRC("Caret Word Right") },
+ { "ui_text_caret_up", TTRC("Caret Up") },
+ { "ui_text_caret_down", TTRC("Caret Down") },
+ { "ui_text_caret_line_start", TTRC("Caret Line Start") },
+ { "ui_text_caret_line_start.OSX", TTRC("Caret Line Start") },
+ { "ui_text_caret_line_end", TTRC("Caret Line End") },
+ { "ui_text_caret_line_end.OSX", TTRC("Caret Line End") },
+ { "ui_text_caret_page_up", TTRC("Caret Page Up") },
+ { "ui_text_caret_page_down", TTRC("Caret Page Down") },
+ { "ui_text_caret_document_start", TTRC("Caret Document Start") },
+ { "ui_text_caret_document_start.OSX", TTRC("Caret Document Start") },
+ { "ui_text_caret_document_end", TTRC("Caret Document End") },
+ { "ui_text_caret_document_end.OSX", TTRC("Caret Document End") },
+ { "ui_text_scroll_up", TTRC("Scroll Up") },
+ { "ui_text_scroll_up.OSX", TTRC("Scroll Up") },
+ { "ui_text_scroll_down", TTRC("Scroll Down") },
+ { "ui_text_scroll_down.OSX", TTRC("Scroll Down") },
+ { "ui_text_select_all", TTRC("Select All") },
+ { "ui_text_toggle_insert_mode", TTRC("Toggle Insert Mode") },
+ { "ui_graph_duplicate", TTRC("Duplicate Nodes") },
+ { "ui_graph_delete", TTRC("Delete Nodes") },
+ { "ui_filedialog_up_one_level", TTRC("Go Up One Level") },
+ { "ui_filedialog_refresh", TTRC("Refresh") },
+ { "ui_filedialog_show_hidden", TTRC("Show Hidden") },
+ { "ui_swap_input_direction ", TTRC("Swap Input Direction") },
+ { "", TTRC("")}
+ /* clang-format on */
+};
+
+String InputMap::get_builtin_display_name(const String &p_name) const {
+ int len = sizeof(_builtin_action_display_names) / sizeof(_BuiltinActionDisplayName);
+
+ for (int i = 0; i < len; i++) {
+ if (_builtin_action_display_names[i].name == p_name) {
+ return RTR(_builtin_action_display_names[i].display_name);
+ }
+ }
+
+ return p_name;
+}
+
+const OrderedHashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
+ // Return cache if it has already been built.
+ if (default_builtin_cache.size()) {
+ return default_builtin_cache;
+ }
+
+ List<Ref<InputEvent>> inputs;
+ inputs.push_back(InputEventKey::create_reference(KEY_ENTER));
+ inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER));
+ inputs.push_back(InputEventKey::create_reference(KEY_SPACE));
+ default_builtin_cache.insert("ui_accept", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_Y));
+ inputs.push_back(InputEventKey::create_reference(KEY_SPACE));
+ default_builtin_cache.insert("ui_select", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_ESCAPE));
+ default_builtin_cache.insert("ui_cancel", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_TAB));
+ default_builtin_cache.insert("ui_focus_next", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_TAB | KEY_MASK_SHIFT));
+ default_builtin_cache.insert("ui_focus_prev", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_LEFT));
+ inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_LEFT));
+ default_builtin_cache.insert("ui_left", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_RIGHT));
+ inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_RIGHT));
+ default_builtin_cache.insert("ui_right", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_UP));
+ inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_UP));
+ default_builtin_cache.insert("ui_up", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DOWN));
+ inputs.push_back(InputEventJoypadButton::create_reference(JOY_BUTTON_DPAD_DOWN));
+ default_builtin_cache.insert("ui_down", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_PAGEUP));
+ default_builtin_cache.insert("ui_page_up", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_PAGEDOWN));
+ default_builtin_cache.insert("ui_page_down", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_HOME));
+ default_builtin_cache.insert("ui_home", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_END));
+ default_builtin_cache.insert("ui_end", inputs);
+
+ // ///// UI basic Shortcuts /////
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_X | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_SHIFT));
+ default_builtin_cache.insert("ui_cut", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_C | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_INSERT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_copy", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_V | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_INSERT | KEY_MASK_SHIFT));
+ default_builtin_cache.insert("ui_paste", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_Z | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_undo", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_Y | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_Z | KEY_MASK_CMD | KEY_MASK_SHIFT));
+ default_builtin_cache.insert("ui_redo", inputs);
+
+ // ///// UI Text Input Shortcuts /////
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_SPACE | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_completion_query", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_TAB));
+ default_builtin_cache.insert("ui_text_completion_accept", inputs);
+
+ // Newlines
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_ENTER));
+ inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER));
+ default_builtin_cache.insert("ui_text_newline", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+
+ inputs.push_back(InputEventKey::create_reference(KEY_ENTER | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_newline_blank", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_ENTER | KEY_MASK_SHIFT | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_KP_ENTER | KEY_MASK_SHIFT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_newline_above", inputs);
+
+ // Indentation
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_TAB));
+ default_builtin_cache.insert("ui_text_indent", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_TAB | KEY_MASK_SHIFT));
+ default_builtin_cache.insert("ui_text_dedent", inputs);
+
+ // Text Backspace and Delete
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE));
+ default_builtin_cache.insert("ui_text_backspace", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_backspace_word", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_ALT));
+ default_builtin_cache.insert("ui_text_backspace_word.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ default_builtin_cache.insert("ui_text_backspace_all_to_left", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_backspace_all_to_left.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DELETE));
+ default_builtin_cache.insert("ui_text_delete", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_delete_word", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_ALT));
+ default_builtin_cache.insert("ui_text_delete_word.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ default_builtin_cache.insert("ui_text_delete_all_to_right", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DELETE | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_delete_all_to_right.OSX", inputs);
+
+ // Text Caret Movement Left/Right
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_LEFT));
+ default_builtin_cache.insert("ui_text_caret_left", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_LEFT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_word_left", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_LEFT | KEY_MASK_ALT));
+ default_builtin_cache.insert("ui_text_caret_word_left.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_RIGHT));
+ default_builtin_cache.insert("ui_text_caret_right", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_RIGHT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_word_right", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_RIGHT | KEY_MASK_ALT));
+ default_builtin_cache.insert("ui_text_caret_word_right.OSX", inputs);
+
+ // Text Caret Movement Up/Down
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_UP));
+ default_builtin_cache.insert("ui_text_caret_up", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DOWN));
+ default_builtin_cache.insert("ui_text_caret_down", inputs);
+
+ // Text Caret Movement Line Start/End
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_HOME));
+ default_builtin_cache.insert("ui_text_caret_line_start", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_A | KEY_MASK_CTRL));
+ inputs.push_back(InputEventKey::create_reference(KEY_LEFT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_line_start.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_END));
+ default_builtin_cache.insert("ui_text_caret_line_end", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_E | KEY_MASK_CTRL));
+ inputs.push_back(InputEventKey::create_reference(KEY_RIGHT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_line_end.OSX", inputs);
+ // Text Caret Movement Page Up/Down
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_PAGEUP));
+ default_builtin_cache.insert("ui_text_caret_page_up", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_PAGEDOWN));
+ default_builtin_cache.insert("ui_text_caret_page_down", inputs);
+
+ // Text Caret Movement Document Start/End
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_HOME | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_document_start", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_UP | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_document_start.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_END | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_document_end", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DOWN | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_caret_document_end.OSX", inputs);
+
+ // Text Scrolling
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_UP | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_scroll_up", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_UP | KEY_MASK_CMD | KEY_MASK_ALT));
+ default_builtin_cache.insert("ui_text_scroll_up.OSX", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DOWN | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_scroll_down", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DOWN | KEY_MASK_CMD | KEY_MASK_ALT));
+ default_builtin_cache.insert("ui_text_scroll_down.OSX", inputs);
+
+ // Text Misc
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_A | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_text_select_all", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_INSERT));
+ default_builtin_cache.insert("ui_text_toggle_insert_mode", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_MENU));
+ default_builtin_cache.insert("ui_menu", inputs);
+
+ // ///// UI Graph Shortcuts /////
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_D | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_graph_duplicate", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_DELETE));
+ default_builtin_cache.insert("ui_graph_delete", inputs);
+
+ // ///// UI File Dialog Shortcuts /////
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_BACKSPACE));
+ default_builtin_cache.insert("ui_filedialog_up_one_level", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_F5));
+ default_builtin_cache.insert("ui_filedialog_refresh", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_H));
+ default_builtin_cache.insert("ui_filedialog_show_hidden", inputs);
+
+ inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(KEY_QUOTELEFT | KEY_MASK_CMD));
+ default_builtin_cache.insert("ui_swap_input_direction", inputs);
+
+ return default_builtin_cache;
+}
+
void InputMap::load_default() {
- Ref<InputEventKey> key;
-
- add_action("ui_accept");
- key.instance();
- key->set_keycode(KEY_ENTER);
- action_add_event("ui_accept", key);
-
- key.instance();
- key->set_keycode(KEY_KP_ENTER);
- action_add_event("ui_accept", key);
-
- key.instance();
- key->set_keycode(KEY_SPACE);
- action_add_event("ui_accept", key);
-
- add_action("ui_select");
- key.instance();
- key->set_keycode(KEY_SPACE);
- action_add_event("ui_select", key);
-
- add_action("ui_cancel");
- key.instance();
- key->set_keycode(KEY_ESCAPE);
- action_add_event("ui_cancel", key);
-
- add_action("ui_focus_next");
- key.instance();
- key->set_keycode(KEY_TAB);
- action_add_event("ui_focus_next", key);
-
- add_action("ui_focus_prev");
- key.instance();
- key->set_keycode(KEY_TAB);
- key->set_shift(true);
- action_add_event("ui_focus_prev", key);
-
- add_action("ui_left");
- key.instance();
- key->set_keycode(KEY_LEFT);
- action_add_event("ui_left", key);
-
- add_action("ui_right");
- key.instance();
- key->set_keycode(KEY_RIGHT);
- action_add_event("ui_right", key);
-
- add_action("ui_up");
- key.instance();
- key->set_keycode(KEY_UP);
- action_add_event("ui_up", key);
-
- add_action("ui_down");
- key.instance();
- key->set_keycode(KEY_DOWN);
- action_add_event("ui_down", key);
-
- add_action("ui_page_up");
- key.instance();
- key->set_keycode(KEY_PAGEUP);
- action_add_event("ui_page_up", key);
-
- add_action("ui_page_down");
- key.instance();
- key->set_keycode(KEY_PAGEDOWN);
- action_add_event("ui_page_down", key);
-
- add_action("ui_home");
- key.instance();
- key->set_keycode(KEY_HOME);
- action_add_event("ui_home", key);
-
- add_action("ui_end");
- key.instance();
- key->set_keycode(KEY_END);
- action_add_event("ui_end", key);
-
- //set("display/window/handheld/orientation", "landscape");
+ OrderedHashMap<String, List<Ref<InputEvent>>> builtins = get_builtins();
+
+ // List of Builtins which have an override for OSX.
+ Vector<String> osx_builtins;
+ for (OrderedHashMap<String, List<Ref<InputEvent>>>::Element E = builtins.front(); E; E = E.next()) {
+ if (String(E.key()).ends_with(".OSX")) {
+ // Strip .OSX from name: some_input_name.OSX -> some_input_name
+ osx_builtins.push_back(String(E.key()).split(".")[0]);
+ }
+ }
+
+ for (OrderedHashMap<String, List<Ref<InputEvent>>>::Element E = builtins.front(); E; E = E.next()) {
+ String fullname = E.key();
+ String name = fullname.split(".")[0];
+ String override_for = fullname.split(".").size() > 1 ? fullname.split(".")[1] : "";
+
+#ifdef APPLE_STYLE_KEYS
+ if (osx_builtins.has(name) && override_for != "OSX") {
+ // Name has osx builtin but this particular one is for non-osx systems - so skip.
+ continue;
+ }
+#else
+ if (override_for == "OSX") {
+ // Override for OSX - not needed on non-osx platforms.
+ continue;
+ }
+#endif
+
+ add_action(name);
+
+ List<Ref<InputEvent>> inputs = E.get();
+ for (List<Ref<InputEvent>>::Element *I = inputs.front(); I; I = I->next()) {
+ Ref<InputEventKey> iek = I->get();
+
+ // For the editor, only add keyboard actions.
+ if (iek.is_valid()) {
+ action_add_event(fullname, I->get());
+ }
+ }
+ }
}
InputMap::InputMap() {
diff --git a/core/input/input_map.h b/core/input/input_map.h
index 28c692c7ba..99c71e1e53 100644
--- a/core/input/input_map.h
+++ b/core/input/input_map.h
@@ -33,6 +33,8 @@
#include "core/input/input_event.h"
#include "core/object/class_db.h"
+#include "core/object/object.h"
+#include "core/templates/ordered_hash_map.h"
class InputMap : public Object {
GDCLASS(InputMap, Object);
@@ -52,7 +54,8 @@ public:
private:
static InputMap *singleton;
- mutable Map<StringName, Action> input_map;
+ mutable OrderedHashMap<StringName, Action> input_map;
+ OrderedHashMap<String, List<Ref<InputEvent>>> default_builtin_cache;
List<Ref<InputEvent>>::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool p_exact_match = false, bool *p_pressed = nullptr, float *p_strength = nullptr, float *p_raw_strength = nullptr) const;
@@ -81,10 +84,14 @@ public:
bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match = false) const;
bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match = false, bool *p_pressed = nullptr, float *p_strength = nullptr, float *p_raw_strength = nullptr) const;
- const Map<StringName, Action> &get_action_map() const;
+ const OrderedHashMap<StringName, Action> &get_action_map() const;
void load_from_project_settings();
void load_default();
+ String get_builtin_display_name(const String &p_name) const;
+ // Use an Ordered Map so insertion order is preserved. We want the elements to be 'grouped' somewhat.
+ const OrderedHashMap<String, List<Ref<InputEvent>>> &get_builtins();
+
InputMap();
};
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 588af0f0ae..b34a083f1e 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -968,11 +968,11 @@ void ResourceLoader::reload_translation_remaps() {
}
void ResourceLoader::load_translation_remaps() {
- if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
+ if (!ProjectSettings::get_singleton()->has_setting("internationalization/locale/translation_remaps")) {
return;
}
- Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
diff --git a/core/object/object.h b/core/object/object.h
index ea3ee6b9cc..029478873d 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -126,6 +126,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 25, // Used in inspector to increment property when keyed in animation player
PROPERTY_USAGE_DEFERRED_SET_RESOURCE = 1 << 26, // when loading, the resource for this property can be set at the end of loading
PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 1 << 27, // For Object properties, instantiate them when creating in editor.
+ PROPERTY_USAGE_EDITOR_BASIC_SETTING = 1 << 28, //for project or editor settings, show when basic settings are selected
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 5337d46aa3..0901944360 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -1191,14 +1191,14 @@ bool TranslationServer::_load_translations(const String &p_from) {
}
void TranslationServer::setup() {
- String test = GLOBAL_DEF("locale/test", "");
+ String test = GLOBAL_DEF("internationalization/locale/test", "");
test = test.strip_edges();
if (test != "") {
set_locale(test);
} else {
set_locale(OS::get_singleton()->get_locale());
}
- fallback = GLOBAL_DEF("locale/fallback", "en");
+ fallback = GLOBAL_DEF("internationalization/locale/fallback", "en");
#ifdef TOOLS_ENABLED
{
String options = "";
@@ -1210,7 +1210,7 @@ void TranslationServer::setup() {
options += locale_list[idx];
idx++;
}
- ProjectSettings::get_singleton()->set_custom_property_info("locale/fallback", PropertyInfo(Variant::STRING, "locale/fallback", PROPERTY_HINT_ENUM, options));
+ ProjectSettings::get_singleton()->set_custom_property_info("internationalization/locale/fallback", PropertyInfo(Variant::STRING, "internationalization/locale/fallback", PROPERTY_HINT_ENUM, options));
}
#endif
}
@@ -1307,11 +1307,11 @@ void TranslationServer::_bind_methods() {
void TranslationServer::load_translations() {
String locale = get_locale();
- _load_translations("locale/translations"); //all
- _load_translations("locale/translations_" + locale.substr(0, 2));
+ _load_translations("internationalization/locale/translations"); //all
+ _load_translations("internationalization/locale/translations_" + locale.substr(0, 2));
if (locale.substr(0, 2) != locale) {
- _load_translations("locale/translations_" + locale);
+ _load_translations("internationalization/locale/translations_" + locale);
}
}