1 /*************************************************************************/
2 /*  multimesh_editor_plugin.h                                            */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
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 MULTIMESH_EDITOR_PLUGIN_H
32 #define MULTIMESH_EDITOR_PLUGIN_H
33 
34 #include "editor/editor_node.h"
35 #include "editor/editor_plugin.h"
36 #include "scene/3d/multimesh_instance.h"
37 #include "scene/gui/spin_box.h"
38 
39 class MultiMeshEditor : public Control {
40 
41 	GDCLASS(MultiMeshEditor, Control);
42 
43 	friend class MultiMeshEditorPlugin;
44 
45 	AcceptDialog *err_dialog;
46 	MenuButton *options;
47 	MultiMeshInstance *_last_pp_node;
48 	bool browsing_source;
49 
50 	Panel *panel;
51 	MultiMeshInstance *node;
52 
53 	LineEdit *surface_source;
54 	LineEdit *mesh_source;
55 
56 	SceneTreeDialog *std;
57 
58 	ConfirmationDialog *populate_dialog;
59 	OptionButton *populate_axis;
60 	HSlider *populate_rotate_random;
61 	HSlider *populate_tilt_random;
62 	SpinBox *populate_scale_random;
63 	SpinBox *populate_scale;
64 	SpinBox *populate_amount;
65 
66 	enum Menu {
67 
68 		MENU_OPTION_POPULATE
69 	};
70 
71 	void _browsed(const NodePath &p_path);
72 	void _menu_option(int);
73 	void _populate();
74 	void _browse(bool p_source);
75 
76 protected:
77 	void _node_removed(Node *p_node);
78 	static void _bind_methods();
79 
80 public:
81 	void edit(MultiMeshInstance *p_multimesh);
82 	MultiMeshEditor();
83 };
84 
85 class MultiMeshEditorPlugin : public EditorPlugin {
86 
87 	GDCLASS(MultiMeshEditorPlugin, EditorPlugin);
88 
89 	MultiMeshEditor *multimesh_editor;
90 	EditorNode *editor;
91 
92 public:
get_name()93 	virtual String get_name() const { return "MultiMesh"; }
has_main_screen()94 	bool has_main_screen() const { return false; }
95 	virtual void edit(Object *p_object);
96 	virtual bool handles(Object *p_object) const;
97 	virtual void make_visible(bool p_visible);
98 
99 	MultiMeshEditorPlugin(EditorNode *p_node);
100 	~MultiMeshEditorPlugin();
101 };
102 
103 #endif // MULTIMESH_EDITOR_PLUGIN_H
104