openxr_action_map_editor.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /**************************************************************************/
  2. /* openxr_action_map_editor.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "openxr_action_map_editor.h"
  31. #include "core/config/project_settings.h"
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_settings.h"
  34. #include "editor/gui/editor_bottom_panel.h"
  35. #include "editor/gui/editor_file_dialog.h"
  36. #include "editor/themes/editor_scale.h"
  37. HashMap<String, String> OpenXRActionMapEditor::interaction_profile_editors;
  38. HashMap<String, String> OpenXRActionMapEditor::binding_modifier_editors;
  39. void OpenXRActionMapEditor::_bind_methods() {
  40. ClassDB::bind_method("_add_action_set_editor", &OpenXRActionMapEditor::_add_action_set_editor);
  41. ClassDB::bind_method("_add_interaction_profile_editor", &OpenXRActionMapEditor::_add_interaction_profile_editor);
  42. ClassDB::bind_method(D_METHOD("_add_action_set", "name"), &OpenXRActionMapEditor::_add_action_set);
  43. ClassDB::bind_method(D_METHOD("_remove_action_set", "name"), &OpenXRActionMapEditor::_remove_action_set);
  44. ClassDB::bind_method(D_METHOD("_do_add_action_set_editor", "action_set_editor"), &OpenXRActionMapEditor::_do_add_action_set_editor);
  45. ClassDB::bind_method(D_METHOD("_do_remove_action_set_editor", "action_set_editor"), &OpenXRActionMapEditor::_do_remove_action_set_editor);
  46. ClassDB::bind_method(D_METHOD("_do_add_interaction_profile_editor", "interaction_profile_editor"), &OpenXRActionMapEditor::_do_add_interaction_profile_editor);
  47. ClassDB::bind_method(D_METHOD("_do_remove_interaction_profile_editor", "interaction_profile_editor"), &OpenXRActionMapEditor::_do_remove_interaction_profile_editor);
  48. ClassDB::bind_static_method("OpenXRActionMapEditor", D_METHOD("register_interaction_profile_editor", "interaction_profile_path", "editor_class"), &OpenXRActionMapEditor::register_interaction_profile_editor);
  49. ClassDB::bind_static_method("OpenXRActionMapEditor", D_METHOD("register_binding_modifier_editor", "binding_modifier_class", "editor_class"), &OpenXRActionMapEditor::register_binding_modifier_editor);
  50. }
  51. void OpenXRActionMapEditor::_notification(int p_what) {
  52. switch (p_what) {
  53. case NOTIFICATION_ENTER_TREE:
  54. case NOTIFICATION_THEME_CHANGED: {
  55. for (int i = 0; i < tabs->get_child_count(); i++) {
  56. Control *tab = Object::cast_to<Control>(tabs->get_child(i));
  57. if (tab) {
  58. tab->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
  59. }
  60. }
  61. } break;
  62. case NOTIFICATION_READY: {
  63. _create_action_sets();
  64. _create_interaction_profiles();
  65. } break;
  66. }
  67. }
  68. OpenXRActionSetEditor *OpenXRActionMapEditor::_add_action_set_editor(Ref<OpenXRActionSet> p_action_set) {
  69. ERR_FAIL_COND_V(p_action_set.is_null(), nullptr);
  70. OpenXRActionSetEditor *action_set_editor = memnew(OpenXRActionSetEditor(action_map, p_action_set));
  71. action_set_editor->connect("remove", callable_mp(this, &OpenXRActionMapEditor::_on_remove_action_set));
  72. action_set_editor->connect("action_removed", callable_mp(this, &OpenXRActionMapEditor::_on_action_removed));
  73. actionsets_vb->add_child(action_set_editor);
  74. return action_set_editor;
  75. }
  76. void OpenXRActionMapEditor::_create_action_sets() {
  77. if (action_map.is_valid()) {
  78. Array action_sets = action_map->get_action_sets();
  79. for (int i = 0; i < action_sets.size(); i++) {
  80. Ref<OpenXRActionSet> action_set = action_sets[i];
  81. _add_action_set_editor(action_set);
  82. }
  83. }
  84. }
  85. OpenXRInteractionProfileEditorBase *OpenXRActionMapEditor::_add_interaction_profile_editor(Ref<OpenXRInteractionProfile> p_interaction_profile) {
  86. ERR_FAIL_COND_V(p_interaction_profile.is_null(), nullptr);
  87. String profile_path = p_interaction_profile->get_interaction_profile_path();
  88. // need to instance the correct editor for our profile
  89. OpenXRInteractionProfileEditorBase *new_profile_editor = nullptr;
  90. if (interaction_profile_editors.has(profile_path)) {
  91. Object *new_editor = ClassDB::instantiate(interaction_profile_editors[profile_path]);
  92. if (new_editor) {
  93. new_profile_editor = Object::cast_to<OpenXRInteractionProfileEditorBase>(new_editor);
  94. if (!new_profile_editor) {
  95. WARN_PRINT("Interaction profile editor type mismatch for " + profile_path);
  96. memfree(new_editor);
  97. }
  98. }
  99. }
  100. if (!new_profile_editor) {
  101. // instance generic editor
  102. new_profile_editor = memnew(OpenXRInteractionProfileEditor);
  103. }
  104. // now add it in..
  105. ERR_FAIL_NULL_V(new_profile_editor, nullptr);
  106. new_profile_editor->setup(action_map, p_interaction_profile);
  107. tabs->add_child(new_profile_editor);
  108. new_profile_editor->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
  109. tabs->set_tab_button_icon(tabs->get_tab_count() - 1, get_theme_icon(SNAME("close"), SNAME("TabBar")));
  110. if (!new_profile_editor->tooltip.is_empty()) {
  111. tabs->set_tab_tooltip(tabs->get_tab_count() - 1, new_profile_editor->tooltip);
  112. }
  113. return new_profile_editor;
  114. }
  115. void OpenXRActionMapEditor::_create_interaction_profiles() {
  116. if (action_map.is_valid()) {
  117. Array new_interaction_profiles = action_map->get_interaction_profiles();
  118. for (int i = 0; i < new_interaction_profiles.size(); i++) {
  119. Ref<OpenXRInteractionProfile> interaction_profile = new_interaction_profiles[i];
  120. _add_interaction_profile_editor(interaction_profile);
  121. }
  122. }
  123. }
  124. OpenXRActionSetEditor *OpenXRActionMapEditor::_add_action_set(String p_name) {
  125. ERR_FAIL_COND_V(action_map.is_null(), nullptr);
  126. Ref<OpenXRActionSet> new_action_set;
  127. // add our new action set
  128. new_action_set.instantiate();
  129. new_action_set->set_name(p_name);
  130. new_action_set->set_localized_name(p_name);
  131. action_map->add_action_set(new_action_set);
  132. action_map->set_edited(true);
  133. // update our editor right away
  134. OpenXRActionSetEditor *action_set_editor = _add_action_set_editor(new_action_set);
  135. undo_redo->create_action(TTR("Add action set"));
  136. undo_redo->add_do_method(this, "_do_add_action_set_editor", action_set_editor);
  137. undo_redo->add_undo_method(this, "_do_remove_action_set_editor", action_set_editor);
  138. undo_redo->commit_action(false);
  139. return action_set_editor;
  140. }
  141. void OpenXRActionMapEditor::_remove_action_set(String p_name) {
  142. ERR_FAIL_COND(action_map.is_null());
  143. Ref<OpenXRActionSet> action_set = action_map->find_action_set(p_name);
  144. ERR_FAIL_COND(action_set.is_null());
  145. for (int i = 0; i < actionsets_vb->get_child_count(); i++) {
  146. OpenXRActionSetEditor *action_set_editor = Object::cast_to<OpenXRActionSetEditor>(actionsets_vb->get_child(i));
  147. if (action_set_editor && action_set_editor->get_action_set() == action_set) {
  148. _on_remove_action_set(action_set_editor);
  149. }
  150. }
  151. }
  152. void OpenXRActionMapEditor::_on_add_action_set() {
  153. ERR_FAIL_COND(action_map.is_null());
  154. String new_name = "New";
  155. int count = 0;
  156. while (action_map->find_action_set(new_name).is_valid()) {
  157. new_name = "New_" + itos(count++);
  158. }
  159. OpenXRActionSetEditor *new_action_set_editor = _add_action_set(new_name);
  160. // Make sure our action set is the current tab
  161. tabs->set_current_tab(0);
  162. callable_mp(this, &OpenXRActionMapEditor::_set_focus_on_action_set).call_deferred(new_action_set_editor);
  163. }
  164. void OpenXRActionMapEditor::_set_focus_on_action_set(OpenXRActionSetEditor *p_action_set_editor) {
  165. // Scroll down to our new entry
  166. actionsets_scroll->ensure_control_visible(p_action_set_editor);
  167. // Set focus on this entry
  168. p_action_set_editor->set_focus_on_entry();
  169. }
  170. void OpenXRActionMapEditor::_on_remove_action_set(Object *p_action_set_editor) {
  171. ERR_FAIL_COND(action_map.is_null());
  172. OpenXRActionSetEditor *action_set_editor = Object::cast_to<OpenXRActionSetEditor>(p_action_set_editor);
  173. ERR_FAIL_NULL(action_set_editor);
  174. ERR_FAIL_COND(action_set_editor->get_parent() != actionsets_vb);
  175. Ref<OpenXRActionSet> action_set = action_set_editor->get_action_set();
  176. ERR_FAIL_COND(action_set.is_null());
  177. // Remove all actions first.
  178. action_set_editor->remove_all_actions();
  179. // Make sure we update our interaction profiles.
  180. for (int i = 0; i < tabs->get_tab_count(); i++) {
  181. // First tab won't be an interaction profile editor, but being thorough..
  182. OpenXRInteractionProfileEditorBase *interaction_profile_editor = Object::cast_to<OpenXRInteractionProfileEditorBase>(tabs->get_tab_control(i));
  183. if (interaction_profile_editor) {
  184. interaction_profile_editor->remove_all_for_action_set(action_set);
  185. }
  186. }
  187. // And now we can remove our action set.
  188. undo_redo->create_action(TTR("Remove action set"));
  189. undo_redo->add_do_method(this, "_do_remove_action_set_editor", action_set_editor);
  190. undo_redo->add_undo_method(this, "_do_add_action_set_editor", action_set_editor);
  191. undo_redo->commit_action(true);
  192. action_map->set_edited(true);
  193. }
  194. void OpenXRActionMapEditor::_on_action_removed(Ref<OpenXRAction> p_action) {
  195. for (int i = 0; i < tabs->get_tab_count(); i++) {
  196. // First tab won't be an interaction profile editor, but being thorough..
  197. OpenXRInteractionProfileEditorBase *interaction_profile_editor = Object::cast_to<OpenXRInteractionProfileEditorBase>(tabs->get_tab_control(i));
  198. if (interaction_profile_editor) {
  199. interaction_profile_editor->remove_all_for_action(p_action);
  200. }
  201. }
  202. }
  203. void OpenXRActionMapEditor::_on_add_interaction_profile() {
  204. ERR_FAIL_COND(action_map.is_null());
  205. PackedStringArray already_selected;
  206. for (int i = 0; i < action_map->get_interaction_profile_count(); i++) {
  207. already_selected.push_back(action_map->get_interaction_profile(i)->get_interaction_profile_path());
  208. }
  209. select_interaction_profile_dialog->open(already_selected);
  210. }
  211. void OpenXRActionMapEditor::_on_interaction_profile_selected(const String p_path) {
  212. ERR_FAIL_COND(action_map.is_null());
  213. Ref<OpenXRInteractionProfile> new_profile;
  214. new_profile.instantiate();
  215. new_profile->set_interaction_profile_path(p_path);
  216. action_map->add_interaction_profile(new_profile);
  217. action_map->set_edited(true);
  218. OpenXRInteractionProfileEditorBase *interaction_profile_editor = _add_interaction_profile_editor(new_profile);
  219. undo_redo->create_action(TTR("Add interaction profile"));
  220. undo_redo->add_do_method(this, "_do_add_interaction_profile_editor", interaction_profile_editor);
  221. undo_redo->add_undo_method(this, "_do_remove_interaction_profile_editor", interaction_profile_editor);
  222. undo_redo->commit_action(false);
  223. tabs->set_current_tab(tabs->get_tab_count() - 1);
  224. }
  225. void OpenXRActionMapEditor::_load_action_map(const String p_path, bool p_create_new_if_missing) {
  226. Error err = OK;
  227. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
  228. if (da->file_exists(p_path)) {
  229. action_map = ResourceLoader::load(p_path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
  230. if (err != OK) {
  231. EditorNode::get_singleton()->show_warning(vformat(TTR("Error loading %s: %s."), edited_path, error_names[err]));
  232. edited_path = "";
  233. header_label->set_text("");
  234. return;
  235. }
  236. } else if (p_create_new_if_missing) {
  237. action_map.instantiate();
  238. action_map->create_default_action_sets();
  239. action_map->set_path(p_path);
  240. // Save it immediately
  241. err = ResourceSaver::save(action_map, p_path);
  242. if (err != OK) {
  243. // Show warning but continue.
  244. EditorNode::get_singleton()->show_warning(vformat(TTR("Error saving file %s: %s"), edited_path, error_names[err]));
  245. }
  246. }
  247. edited_path = p_path;
  248. header_label->set_text(TTR("OpenXR Action map:") + " " + edited_path.get_file());
  249. }
  250. void OpenXRActionMapEditor::_on_save_action_map() {
  251. Error err = ResourceSaver::save(action_map, edited_path);
  252. if (err != OK) {
  253. EditorNode::get_singleton()->show_warning(vformat(TTR("Error saving file %s: %s"), edited_path, error_names[err]));
  254. return;
  255. }
  256. // TODO should clear undo/redo history
  257. // out with the old
  258. _clear_action_map();
  259. _create_action_sets();
  260. _create_interaction_profiles();
  261. }
  262. void OpenXRActionMapEditor::_on_reset_to_default_layout() {
  263. // TODO should clear undo/redo history
  264. // out with the old
  265. _clear_action_map();
  266. // create a new one
  267. action_map.unref();
  268. action_map.instantiate();
  269. action_map->create_default_action_sets();
  270. action_map->set_edited(true);
  271. _create_action_sets();
  272. _create_interaction_profiles();
  273. }
  274. void OpenXRActionMapEditor::_on_tabs_tab_changed(int p_tab) {
  275. }
  276. void OpenXRActionMapEditor::_on_tab_button_pressed(int p_tab) {
  277. OpenXRInteractionProfileEditorBase *interaction_profile_editor = Object::cast_to<OpenXRInteractionProfileEditorBase>(tabs->get_tab_control(p_tab));
  278. ERR_FAIL_NULL(interaction_profile_editor);
  279. undo_redo->create_action(TTR("Remove interaction profile"));
  280. undo_redo->add_do_method(this, "_do_remove_interaction_profile_editor", interaction_profile_editor);
  281. undo_redo->add_undo_method(this, "_do_add_interaction_profile_editor", interaction_profile_editor);
  282. undo_redo->commit_action(true);
  283. action_map->set_edited(true);
  284. }
  285. void OpenXRActionMapEditor::_do_add_action_set_editor(OpenXRActionSetEditor *p_action_set_editor) {
  286. Ref<OpenXRActionSet> action_set = p_action_set_editor->get_action_set();
  287. ERR_FAIL_COND(action_set.is_null());
  288. action_map->add_action_set(action_set);
  289. actionsets_vb->add_child(p_action_set_editor);
  290. }
  291. void OpenXRActionMapEditor::_do_remove_action_set_editor(OpenXRActionSetEditor *p_action_set_editor) {
  292. Ref<OpenXRActionSet> action_set = p_action_set_editor->get_action_set();
  293. ERR_FAIL_COND(action_set.is_null());
  294. actionsets_vb->remove_child(p_action_set_editor);
  295. action_map->remove_action_set(action_set);
  296. }
  297. void OpenXRActionMapEditor::_do_add_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor) {
  298. Ref<OpenXRInteractionProfile> interaction_profile = p_interaction_profile_editor->get_interaction_profile();
  299. ERR_FAIL_COND(interaction_profile.is_null());
  300. action_map->add_interaction_profile(interaction_profile);
  301. tabs->add_child(p_interaction_profile_editor);
  302. tabs->set_tab_button_icon(tabs->get_tab_count() - 1, get_theme_icon(SNAME("close"), SNAME("TabBar")));
  303. tabs->set_current_tab(tabs->get_tab_count() - 1);
  304. }
  305. void OpenXRActionMapEditor::_do_remove_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor) {
  306. Ref<OpenXRInteractionProfile> interaction_profile = p_interaction_profile_editor->get_interaction_profile();
  307. ERR_FAIL_COND(interaction_profile.is_null());
  308. tabs->remove_child(p_interaction_profile_editor);
  309. action_map->remove_interaction_profile(interaction_profile);
  310. }
  311. void OpenXRActionMapEditor::open_action_map(String p_path) {
  312. EditorNode::get_bottom_panel()->make_item_visible(this);
  313. // out with the old...
  314. _clear_action_map();
  315. // now load in our new action map
  316. _load_action_map(p_path);
  317. _create_action_sets();
  318. _create_interaction_profiles();
  319. }
  320. void OpenXRActionMapEditor::_clear_action_map() {
  321. while (actionsets_vb->get_child_count() > 0) {
  322. Node *child = actionsets_vb->get_child(0);
  323. actionsets_vb->remove_child(child);
  324. child->queue_free();
  325. }
  326. for (int i = tabs->get_tab_count() - 1; i >= 0; --i) {
  327. // First tab won't be an interaction profile editor, but being thorough..
  328. OpenXRInteractionProfileEditorBase *interaction_profile_editor = Object::cast_to<OpenXRInteractionProfileEditorBase>(tabs->get_tab_control(i));
  329. if (interaction_profile_editor) {
  330. tabs->remove_child(interaction_profile_editor);
  331. interaction_profile_editor->queue_free();
  332. }
  333. }
  334. }
  335. void OpenXRActionMapEditor::register_interaction_profile_editor(const String &p_for_path, const String &p_editor_class) {
  336. interaction_profile_editors[p_for_path] = p_editor_class;
  337. }
  338. void OpenXRActionMapEditor::register_binding_modifier_editor(const String &p_binding_modifier_class, const String &p_editor_class) {
  339. binding_modifier_editors[p_binding_modifier_class] = p_editor_class;
  340. }
  341. String OpenXRActionMapEditor::get_binding_modifier_editor_class(const String &p_binding_modifier_class) {
  342. if (binding_modifier_editors.has(p_binding_modifier_class)) {
  343. return binding_modifier_editors[p_binding_modifier_class];
  344. }
  345. return OpenXRBindingModifierEditor::get_class_static();
  346. }
  347. OpenXRActionMapEditor::OpenXRActionMapEditor() {
  348. undo_redo = EditorUndoRedoManager::get_singleton();
  349. set_custom_minimum_size(Size2(0.0, 300.0));
  350. top_hb = memnew(HBoxContainer);
  351. add_child(top_hb);
  352. header_label = memnew(Label);
  353. header_label->set_text(String(TTR("Action Map")));
  354. header_label->set_clip_text(true);
  355. header_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  356. top_hb->add_child(header_label);
  357. add_action_set = memnew(Button);
  358. add_action_set->set_text(TTR("Add Action Set"));
  359. add_action_set->set_tooltip_text(TTR("Add an action set."));
  360. add_action_set->connect(SceneStringName(pressed), callable_mp(this, &OpenXRActionMapEditor::_on_add_action_set));
  361. top_hb->add_child(add_action_set);
  362. add_interaction_profile = memnew(Button);
  363. add_interaction_profile->set_text(TTR("Add profile"));
  364. add_interaction_profile->set_tooltip_text(TTR("Add an interaction profile."));
  365. add_interaction_profile->connect(SceneStringName(pressed), callable_mp(this, &OpenXRActionMapEditor::_on_add_interaction_profile));
  366. top_hb->add_child(add_interaction_profile);
  367. VSeparator *vseparator = memnew(VSeparator);
  368. top_hb->add_child(vseparator);
  369. save_as = memnew(Button);
  370. save_as->set_text(TTR("Save"));
  371. save_as->set_tooltip_text(TTR("Save this OpenXR action map."));
  372. save_as->connect(SceneStringName(pressed), callable_mp(this, &OpenXRActionMapEditor::_on_save_action_map));
  373. top_hb->add_child(save_as);
  374. _default = memnew(Button);
  375. _default->set_text(TTR("Reset to Default"));
  376. _default->set_tooltip_text(TTR("Reset to default OpenXR action map."));
  377. _default->connect(SceneStringName(pressed), callable_mp(this, &OpenXRActionMapEditor::_on_reset_to_default_layout));
  378. top_hb->add_child(_default);
  379. tabs = memnew(TabContainer);
  380. tabs->set_h_size_flags(SIZE_EXPAND_FILL);
  381. tabs->set_v_size_flags(SIZE_EXPAND_FILL);
  382. tabs->set_theme_type_variation("TabContainerOdd");
  383. tabs->connect("tab_changed", callable_mp(this, &OpenXRActionMapEditor::_on_tabs_tab_changed));
  384. tabs->connect("tab_button_pressed", callable_mp(this, &OpenXRActionMapEditor::_on_tab_button_pressed));
  385. add_child(tabs);
  386. actionsets_scroll = memnew(ScrollContainer);
  387. actionsets_scroll->set_h_size_flags(SIZE_EXPAND_FILL);
  388. actionsets_scroll->set_v_size_flags(SIZE_EXPAND_FILL);
  389. actionsets_scroll->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
  390. tabs->add_child(actionsets_scroll);
  391. actionsets_scroll->set_name(TTR("Action Sets"));
  392. actionsets_vb = memnew(VBoxContainer);
  393. actionsets_vb->set_h_size_flags(SIZE_EXPAND_FILL);
  394. actionsets_scroll->add_child(actionsets_vb);
  395. select_interaction_profile_dialog = memnew(OpenXRSelectInteractionProfileDialog);
  396. select_interaction_profile_dialog->connect("interaction_profile_selected", callable_mp(this, &OpenXRActionMapEditor::_on_interaction_profile_selected));
  397. add_child(select_interaction_profile_dialog);
  398. // Our Action map editor is only shown if openxr is enabled in project settings
  399. // So load our action map and if it doesn't exist, create it right away.
  400. _load_action_map(GLOBAL_GET("xr/openxr/default_action_map"), true);
  401. }
  402. OpenXRActionMapEditor::~OpenXRActionMapEditor() {
  403. }