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