Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/2d/tiles/tile_set_editor.h
9906 views
1
/**************************************************************************/
2
/* tile_set_editor.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
#pragma once
32
33
#include "atlas_merging_dialog.h"
34
#include "scene/gui/tab_bar.h"
35
#include "scene/resources/2d/tile_set.h"
36
#include "tile_proxies_manager_dialog.h"
37
#include "tile_set_atlas_source_editor.h"
38
#include "tile_set_scenes_collection_source_editor.h"
39
40
class AcceptDialog;
41
class SpinBox;
42
class HBoxContainer;
43
class SplitContainer;
44
class EditorFileDialog;
45
class EditorInspectorPlugin;
46
47
class TileSetEditor : public MarginContainer {
48
GDCLASS(TileSetEditor, MarginContainer);
49
50
static TileSetEditor *singleton;
51
52
private:
53
bool read_only = false;
54
55
Ref<TileSet> tile_set;
56
bool tile_set_changed_needs_update = false;
57
HSplitContainer *split_container = nullptr;
58
59
// TabBar.
60
HBoxContainer *tile_set_toolbar = nullptr;
61
TabBar *tabs_bar = nullptr;
62
63
// Tiles.
64
Label *no_source_selected_label = nullptr;
65
TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr;
66
TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
67
68
void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
69
bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
70
void _load_texture_files(const Vector<String> &p_paths);
71
72
void _update_sources_list(int force_selected_id = -1);
73
74
// Sources management.
75
Button *sources_delete_button = nullptr;
76
MenuButton *sources_add_button = nullptr;
77
MenuButton *source_sort_button = nullptr;
78
MenuButton *sources_advanced_menu_button = nullptr;
79
ItemList *sources_list = nullptr;
80
Ref<Texture2D> missing_texture_texture;
81
void _source_selected(int p_source_index);
82
void _source_delete_pressed();
83
void _source_add_id_pressed(int p_id_pressed);
84
void _sources_advanced_menu_id_pressed(int p_id_pressed);
85
void _set_source_sort(int p_sort);
86
87
EditorFileDialog *texture_file_dialog = nullptr;
88
AtlasMergingDialog *atlas_merging_dialog = nullptr;
89
TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr;
90
91
bool first_edit = true;
92
93
// Patterns.
94
ItemList *patterns_item_list = nullptr;
95
Label *patterns_help_label = nullptr;
96
void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);
97
void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture);
98
bool select_last_pattern = false;
99
void _update_patterns_list();
100
101
// Expanded editor.
102
PanelContainer *expanded_area = nullptr;
103
Control *expanded_editor = nullptr;
104
ObjectID expanded_editor_parent;
105
LocalVector<SplitContainer *> disable_on_expand;
106
107
void _tile_set_changed();
108
void _tab_changed(int p_tab_changed);
109
110
void _move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos);
111
void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value);
112
113
protected:
114
void _notification(int p_what);
115
116
public:
117
_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }
118
119
void edit(Ref<TileSet> p_tile_set);
120
121
void add_expanded_editor(Control *p_editor);
122
void remove_expanded_editor();
123
void register_split(SplitContainer *p_split);
124
125
TileSetEditor();
126
};
127
128
class TileSourceInspectorPlugin : public EditorInspectorPlugin {
129
GDCLASS(TileSourceInspectorPlugin, EditorInspectorPlugin);
130
131
AcceptDialog *id_edit_dialog = nullptr;
132
Label *id_label = nullptr;
133
SpinBox *id_input = nullptr;
134
Object *edited_source = nullptr;
135
136
void _show_id_edit_dialog(Object *p_for_source);
137
void _confirm_change_id();
138
139
public:
140
virtual bool can_handle(Object *p_object) override;
141
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
142
};
143
144