summaryrefslogtreecommitdiff
path: root/editor/plugins/sprite_editor_plugin.h
blob: 17aa3eb1f9de28e8d1373254751d797b7bc4b214 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SPRITE_EDITOR_PLUGIN_H
#define SPRITE_EDITOR_PLUGIN_H

#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/sprite.h"
#include "scene/gui/spin_box.h"

class SpriteEditor : public Control {

	GDCLASS(SpriteEditor, Control);

	enum Menu {
		MENU_OPTION_CREATE_MESH_2D,
	};

	Sprite *node;

	MenuButton *options;

	ConfirmationDialog *outline_dialog;

	AcceptDialog *err_dialog;

	ConfirmationDialog *debug_uv_dialog;
	Control *debug_uv;
	Vector<Vector2> uv_lines;

	Vector<Vector2> computed_vertices;
	Vector<Vector2> computed_uv;
	Vector<int> computed_indices;

	SpinBox *simplification;
	SpinBox *island_merging;
	Button *update_preview;

	void _menu_option(int p_option);

	//void _create_uv_lines();
	friend class SpriteEditorPlugin;

	void _debug_uv_draw();
	void _update_mesh_data();
	void _create_mesh_node();

protected:
	void _node_removed(Node *p_node);
	static void _bind_methods();

public:
	void edit(Sprite *p_sprite);
	SpriteEditor();
};

class SpriteEditorPlugin : public EditorPlugin {

	GDCLASS(SpriteEditorPlugin, EditorPlugin);

	SpriteEditor *sprite_editor;
	EditorNode *editor;

public:
	virtual String get_name() const { return "Sprite"; }
	bool has_main_screen() const { return false; }
	virtual void edit(Object *p_object);
	virtual bool handles(Object *p_object) const;
	virtual void make_visible(bool p_visible);

	SpriteEditorPlugin(EditorNode *p_node);
	~SpriteEditorPlugin();
};

#endif // SPRITE_EDITOR_PLUGIN_H