Path: blob/master/editor/scene/2d/particles_2d_editor_plugin.h
21409 views
/**************************************************************************/1/* particles_2d_editor_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/scene/particles_editor_plugin.h"3334class EditorFileDialog;35class MarginContainer;36class LineEdit;3738class Particles2DEditorPlugin : public ParticlesEditorPlugin {39GDCLASS(Particles2DEditorPlugin, ParticlesEditorPlugin);4041protected:42enum {43MENU_LOAD_EMISSION_MASK = 100,44};4546HashSet<ObjectID> selected_particles;4748enum EmissionMode {49EMISSION_MODE_SOLID,50EMISSION_MODE_BORDER,51EMISSION_MODE_BORDER_DIRECTED52};5354enum MaskMode {55MASK_MODE_SOLID,56MASK_MODE_BORDER,57};5859enum DirectionMode {60DIRECTION_MODE_NONE,61DIRECTION_MODE_GENERATE,62DIRECTION_MODE_TEXTURE,63};6465enum TextureType {66TEXTURE_TYPE_MASK,67TEXTURE_TYPE_DIRECTION,68};6970EditorFileDialog *file_dialog = nullptr;71ConfirmationDialog *emission_mask_dialog = nullptr;72OptionButton *emission_mask_mode = nullptr;73OptionButton *emission_direction_mode = nullptr;74CheckBox *emission_mask_centered = nullptr;75CheckBox *emission_mask_colors = nullptr;76LineEdit *mask_img_path_line_edit = nullptr;77LineEdit *direction_img_path_line_edit = nullptr;78HBoxContainer *direction_img_hbox = nullptr;79Label *direction_img_label = nullptr;80Button *mask_browse_button = nullptr;81Button *direction_browse_button = nullptr;82Label *error_message = nullptr;83TextureType browsing_texture_type = TEXTURE_TYPE_MASK;8485virtual void _menu_callback(int p_idx) override;86virtual void _add_menu_options(PopupMenu *p_menu) override;8788void _validate_textures();89void _mask_img_path_line_edit_text_changed(const String &p_text);90void _direction_img_path_line_edit_text_changed(const String &p_text);91void _emission_mask_mode_item_changed(int p_idx) const;92void _emission_direction_mode_item_changed(int p_idx);93void _browse_mask_texture_pressed();94void _browse_direction_texture_pressed();95void _file_selected(const String &p_file);96void _process_emission_masks(PackedVector2Array &r_valid_positions, PackedVector2Array &r_valid_normals, PackedByteArray &r_valid_colors, Vector2i &r_image_size);97virtual void _generate_emission_mask() = 0;98void _notification(int p_what);99void _theme_changed();100void _set_show_gizmos(Node *p_node, bool p_show);101void _selection_changed();102void _node_removed(Node *p_node);103104public:105Particles2DEditorPlugin();106};107108class GPUParticles2DEditorPlugin : public Particles2DEditorPlugin {109GDCLASS(GPUParticles2DEditorPlugin, Particles2DEditorPlugin);110111enum {112MENU_GENERATE_VISIBILITY_RECT = 200,113};114115ConfirmationDialog *generate_visibility_rect = nullptr;116SpinBox *generate_seconds = nullptr;117118void _generate_visibility_rect();119120protected:121void _menu_callback(int p_idx) override;122void _add_menu_options(PopupMenu *p_menu) override;123124Node *_convert_particles() override;125126void _generate_emission_mask() override;127128public:129GPUParticles2DEditorPlugin();130};131132class CPUParticles2DEditorPlugin : public Particles2DEditorPlugin {133GDCLASS(CPUParticles2DEditorPlugin, Particles2DEditorPlugin);134135protected:136Node *_convert_particles() override;137138void _generate_emission_mask() override;139140public:141CPUParticles2DEditorPlugin();142};143144145