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