| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 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 |
}; |