Debian Codegraph @

editor/scene/2d/particles_2d_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* particles_2d_editor_plugin.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 "editor/scene/particles_editor_plugin.h"
34
35 class EditorFileDialog;
36 class MarginContainer;
37 class LineEdit;
38
39 class Particles2DEditorPlugin : public ParticlesEditorPlugin {
40 GDCLASS(Particles2DEditorPlugin, ParticlesEditorPlugin);
41
42 protected:
43 enum {
44 MENU_LOAD_EMISSION_MASK = 100,
45 };
46
47 HashSet<ObjectID> selected_particles;
48
49 enum EmissionMode {
50 EMISSION_MODE_SOLID,
51 EMISSION_MODE_BORDER,
52 EMISSION_MODE_BORDER_DIRECTED
53 };
54
55 enum MaskMode {
56 MASK_MODE_SOLID,
57 MASK_MODE_BORDER,
58 };
59
60 enum DirectionMode {
61 DIRECTION_MODE_NONE,
62 DIRECTION_MODE_GENERATE,
63 DIRECTION_MODE_TEXTURE,
64 };
65
66 enum TextureType {
67 TEXTURE_TYPE_MASK,
68 TEXTURE_TYPE_DIRECTION,
69 };
70
71 EditorFileDialog *file_dialog = nullptr;
72 ConfirmationDialog *emission_mask_dialog = nullptr;
73 OptionButton *emission_mask_mode = nullptr;
74 OptionButton *emission_direction_mode = nullptr;
75 CheckBox *emission_mask_centered = nullptr;
76 CheckBox *emission_mask_colors = nullptr;
77 LineEdit *mask_img_path_line_edit = nullptr;
78 LineEdit *direction_img_path_line_edit = nullptr;
79 HBoxContainer *direction_img_hbox = nullptr;
80 Label *direction_img_label = nullptr;
81 Button *mask_browse_button = nullptr;
82 Button *direction_browse_button = nullptr;
83 Label *error_message = nullptr;
84 TextureType browsing_texture_type = TEXTURE_TYPE_MASK;
85
86 virtual void _menu_callback(int p_idx) override;
87 virtual void _add_menu_options(PopupMenu *p_menu) override;
88
89 void _validate_textures();
90 void _mask_img_path_line_edit_text_changed(const String &p_text);
91 void _direction_img_path_line_edit_text_changed(const String &p_text);
92 void _emission_mask_mode_item_changed(int p_idx) const;
93 void _emission_direction_mode_item_changed(int p_idx);
94 void _browse_mask_texture_pressed();
95 void _browse_direction_texture_pressed();
96 void _file_selected(const String &p_file);
97 void _process_emission_masks(PackedVector2Array &r_valid_positions, PackedVector2Array &r_valid_normals, PackedByteArray &r_valid_colors, Vector2i &r_image_size);
98 virtual void _generate_emission_mask() = 0;
99 void _notification(int p_what);
100 void _theme_changed();
101 void _set_show_gizmos(Node *p_node, bool p_show);
102 void _selection_changed();
103 void _node_removed(Node *p_node);
104
105 public:
106 Particles2DEditorPlugin();
107 };
108
109 class GPUParticles2DEditorPlugin : public Particles2DEditorPlugin {
110 GDCLASS(GPUParticles2DEditorPlugin, Particles2DEditorPlugin);
111
112 enum {
113 MENU_GENERATE_VISIBILITY_RECT = 200,
114 };
115
116 ConfirmationDialog *generate_visibility_rect = nullptr;
117 SpinBox *generate_seconds = nullptr;
118
119 void _generate_visibility_rect();
120
121 protected:
122 void _menu_callback(int p_idx) override;
123 void _add_menu_options(PopupMenu *p_menu) override;
124
125 Node *_convert_particles() override;
126
127 void _generate_emission_mask() override;
128
129 public:
130 GPUParticles2DEditorPlugin();
131 };
132
133 class CPUParticles2DEditorPlugin : public Particles2DEditorPlugin {
134 GDCLASS(CPUParticles2DEditorPlugin, Particles2DEditorPlugin);
135
136 protected:
137 Node *_convert_particles() override;
138
139 void _generate_emission_mask() override;
140
141 public:
142 CPUParticles2DEditorPlugin();
143 };