1 | /**************************************************************************/ |
2 | /* sprite_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 | #ifndef SPRITE_2D_EDITOR_PLUGIN_H |
32 | #define SPRITE_2D_EDITOR_PLUGIN_H |
33 | |
34 | #include "editor/editor_plugin.h" |
35 | #include "scene/2d/sprite_2d.h" |
36 | #include "scene/gui/spin_box.h" |
37 | |
38 | class AcceptDialog; |
39 | class ConfirmationDialog; |
40 | class ; |
41 | |
42 | class Sprite2DEditor : public Control { |
43 | GDCLASS(Sprite2DEditor, Control); |
44 | |
45 | enum { |
46 | , |
47 | , |
48 | , |
49 | |
50 | }; |
51 | |
52 | Menu ; |
53 | |
54 | Sprite2D *node = nullptr; |
55 | |
56 | MenuButton *options = nullptr; |
57 | |
58 | ConfirmationDialog *outline_dialog = nullptr; |
59 | |
60 | AcceptDialog *err_dialog = nullptr; |
61 | |
62 | ConfirmationDialog *debug_uv_dialog = nullptr; |
63 | Control *debug_uv = nullptr; |
64 | Vector<Vector2> uv_lines; |
65 | Vector<Vector<Vector2>> outline_lines; |
66 | Vector<Vector<Vector2>> computed_outline_lines; |
67 | Vector<Vector2> computed_vertices; |
68 | Vector<Vector2> computed_uv; |
69 | Vector<int> computed_indices; |
70 | |
71 | SpinBox *simplification = nullptr; |
72 | SpinBox *grow_pixels = nullptr; |
73 | SpinBox *shrink_pixels = nullptr; |
74 | Button *update_preview = nullptr; |
75 | |
76 | void (int p_option); |
77 | |
78 | //void _create_uv_lines(); |
79 | friend class Sprite2DEditorPlugin; |
80 | |
81 | void _debug_uv_draw(); |
82 | void _update_mesh_data(); |
83 | |
84 | void _create_node(); |
85 | void _convert_to_mesh_2d_node(); |
86 | void _convert_to_polygon_2d_node(); |
87 | void _create_collision_polygon_2d_node(); |
88 | void _create_light_occluder_2d_node(); |
89 | |
90 | void _add_as_sibling_or_child(Node *p_own_node, Node *p_new_node); |
91 | |
92 | protected: |
93 | void _node_removed(Node *p_node); |
94 | void _notification(int p_what); |
95 | static void _bind_methods(); |
96 | |
97 | public: |
98 | void edit(Sprite2D *p_sprite); |
99 | Sprite2DEditor(); |
100 | }; |
101 | |
102 | class Sprite2DEditorPlugin : public EditorPlugin { |
103 | GDCLASS(Sprite2DEditorPlugin, EditorPlugin); |
104 | |
105 | Sprite2DEditor *sprite_editor = nullptr; |
106 | |
107 | public: |
108 | virtual String get_name() const override { return "Sprite2D" ; } |
109 | bool has_main_screen() const override { return false; } |
110 | virtual void edit(Object *p_object) override; |
111 | virtual bool handles(Object *p_object) const override; |
112 | virtual void make_visible(bool p_visible) override; |
113 | |
114 | Sprite2DEditorPlugin(); |
115 | ~Sprite2DEditorPlugin(); |
116 | }; |
117 | |
118 | #endif // SPRITE_2D_EDITOR_PLUGIN_H |
119 | |