Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/openxr/editor/openxr_action_map_editor.h
10278 views
1
/**************************************************************************/
2
/* openxr_action_map_editor.h */
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
31
#pragma once
32
33
#include "../action_map/openxr_action_map.h"
34
#include "openxr_action_set_editor.h"
35
#include "openxr_interaction_profile_editor.h"
36
#include "openxr_select_interaction_profile_dialog.h"
37
38
#include "core/templates/hash_map.h"
39
#include "editor/editor_undo_redo_manager.h"
40
#include "editor/plugins/editor_plugin.h"
41
#include "scene/gui/box_container.h"
42
#include "scene/gui/button.h"
43
#include "scene/gui/label.h"
44
#include "scene/gui/scroll_container.h"
45
#include "scene/gui/tab_container.h"
46
47
class OpenXRActionMapEditor : public VBoxContainer {
48
GDCLASS(OpenXRActionMapEditor, VBoxContainer);
49
50
private:
51
static HashMap<String, String> interaction_profile_editors; // interaction profile path, interaction profile editor
52
static HashMap<String, String> binding_modifier_editors; // binding modifier class, binding modifiers editor
53
54
EditorUndoRedoManager *undo_redo;
55
String edited_path;
56
Ref<OpenXRActionMap> action_map;
57
58
HBoxContainer *top_hb = nullptr;
59
Label *header_label = nullptr;
60
Button *add_action_set = nullptr;
61
Button *add_interaction_profile = nullptr;
62
Button *load = nullptr;
63
Button *save_as = nullptr;
64
Button *_default = nullptr;
65
TabContainer *tabs = nullptr;
66
ScrollContainer *actionsets_scroll = nullptr;
67
VBoxContainer *actionsets_vb = nullptr;
68
OpenXRSelectInteractionProfileDialog *select_interaction_profile_dialog = nullptr;
69
70
OpenXRActionSetEditor *_add_action_set_editor(Ref<OpenXRActionSet> p_action_set);
71
void _create_action_sets();
72
OpenXRInteractionProfileEditorBase *_add_interaction_profile_editor(Ref<OpenXRInteractionProfile> p_interaction_profile);
73
void _create_interaction_profiles();
74
75
OpenXRActionSetEditor *_add_action_set(String p_name);
76
void _remove_action_set(String p_name);
77
78
void _on_add_action_set();
79
void _set_focus_on_action_set(OpenXRActionSetEditor *p_action_set_editor);
80
void _on_remove_action_set(Object *p_action_set_editor);
81
void _on_action_removed(Ref<OpenXRAction> p_action);
82
83
void _on_add_interaction_profile();
84
void _on_interaction_profile_selected(const String p_path);
85
86
void _load_action_map(const String p_path, bool p_create_new_if_missing = false);
87
void _on_save_action_map();
88
void _on_reset_to_default_layout();
89
90
void _on_tabs_tab_changed(int p_tab);
91
void _on_tab_button_pressed(int p_tab);
92
93
protected:
94
static void _bind_methods();
95
void _notification(int p_what);
96
97
void _clear_action_map();
98
99
// used for undo/redo
100
void _do_add_action_set_editor(OpenXRActionSetEditor *p_action_set_editor);
101
void _do_remove_action_set_editor(OpenXRActionSetEditor *p_action_set_editor);
102
void _do_add_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor);
103
void _do_remove_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor);
104
105
public:
106
static void register_interaction_profile_editor(const String &p_for_path, const String &p_editor_class);
107
static void register_binding_modifier_editor(const String &p_binding_modifier_class, const String &p_editor_class);
108
static String get_binding_modifier_editor_class(const String &p_binding_modifier_class);
109
110
void open_action_map(String p_path);
111
112
OpenXRActionMapEditor();
113
};
114
115