Debian Codegraph @

editor/animation/animation_library_editor.h

raw symbols SCIP
1 /**************************************************************************/
2 /* animation_library_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 "core/io/config_file.h"
34 #include "core/templates/vector.h"
35 #include "editor/plugins/editor_plugin.h"
36 #include "scene/animation/animation_mixer.h"
37 #include "scene/gui/dialogs.h"
38 #include "scene/gui/tree.h"
39
40 class AnimationMixer;
41 class EditorFileDialog;
42
43 class AnimationLibraryEditor : public AcceptDialog {
44 GDCLASS(AnimationLibraryEditor, AcceptDialog)
45
46 enum {
47 LIB_BUTTON_ADD,
48 LIB_BUTTON_LOAD,
49 LIB_BUTTON_PASTE,
50 LIB_BUTTON_FILE,
51 LIB_BUTTON_DELETE,
52 };
53 enum {
54 ANIM_BUTTON_COPY,
55 ANIM_BUTTON_FILE,
56 ANIM_BUTTON_DELETE,
57 };
58
59 enum FileMenuAction {
60 FILE_MENU_SAVE_LIBRARY,
61 FILE_MENU_SAVE_AS_LIBRARY,
62 FILE_MENU_MAKE_LIBRARY_UNIQUE,
63 FILE_MENU_EDIT_LIBRARY,
64
65 FILE_MENU_SAVE_ANIMATION,
66 FILE_MENU_SAVE_AS_ANIMATION,
67 FILE_MENU_MAKE_ANIMATION_UNIQUE,
68 FILE_MENU_EDIT_ANIMATION,
69 };
70
71 enum FileDialogAction {
72 FILE_DIALOG_ACTION_OPEN_LIBRARY,
73 FILE_DIALOG_ACTION_SAVE_LIBRARY,
74 FILE_DIALOG_ACTION_OPEN_ANIMATION,
75 FILE_DIALOG_ACTION_SAVE_ANIMATION,
76 };
77
78 FileDialogAction file_dialog_action = FILE_DIALOG_ACTION_OPEN_ANIMATION;
79
80 StringName file_dialog_animation;
81 StringName file_dialog_library;
82
83 Button *new_library_button = nullptr;
84 Button *load_library_button = nullptr;
85
86 AcceptDialog *error_dialog = nullptr;
87 bool adding_animation = false;
88 StringName adding_animation_to_library;
89 EditorFileDialog *file_dialog = nullptr;
90 ConfirmationDialog *add_library_dialog = nullptr;
91 LineEdit *add_library_name = nullptr;
92 Label *add_library_validate = nullptr;
93 PopupMenu *file_popup = nullptr;
94
95 Tree *tree = nullptr;
96
97 AnimationMixer *mixer = nullptr;
98
99 void _add_library();
100 void _add_library_validate(const String &p_name);
101 void _add_library_confirm();
102 void _load_library();
103 void _load_file(const String &p_path);
104 void _load_files(const PackedStringArray &p_paths);
105
106 void _save_mixer_lib_folding(TreeItem *p_item);
107 Vector<uint64_t> _load_mixer_libs_folding();
108 void _load_config_libs_folding(Vector<uint64_t> &p_lib_ids, ConfigFile *p_config, String p_section);
109 String _get_mixer_signature() const;
110
111 void _item_renamed();
112 void _button_pressed(TreeItem *p_item, int p_column, int p_id, MouseButton p_button);
113
114 void _file_popup_selected(int p_id);
115
116 bool updating = false;
117
118 protected:
119 void _notification(int p_what);
120 void _update_editor(Object *p_mixer);
121 virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
122 static void _bind_methods();
123
124 public:
125 void set_animation_mixer(Object *p_mixer);
126 void show_dialog();
127 void update_tree();
128 AnimationLibraryEditor();
129 };