| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  tile_set_editor.h                                                     */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the        */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including    */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
					
						
							|  |  |  | /* the following conditions:                                              */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be         */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.        */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef TILE_SET_EDITOR_H
 | 
					
						
							|  |  |  | #define TILE_SET_EDITOR_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-06 14:43:03 +02:00
										 |  |  | #include "atlas_merging_dialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-02-12 02:46:22 +01:00
										 |  |  | #include "scene/gui/tab_bar.h"
 | 
					
						
							| 
									
										
										
										
											2021-03-16 02:27:53 -04:00
										 |  |  | #include "scene/resources/2d/tile_set.h"
 | 
					
						
							| 
									
										
										
										
											2021-07-06 14:43:03 +02:00
										 |  |  | #include "tile_proxies_manager_dialog.h"
 | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | #include "tile_set_atlas_source_editor.h"
 | 
					
						
							| 
									
										
										
										
											2021-05-18 15:40:52 +02:00
										 |  |  | #include "tile_set_scenes_collection_source_editor.h"
 | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-14 18:25:51 +02:00
										 |  |  | class AcceptDialog; | 
					
						
							|  |  |  | class SpinBox; | 
					
						
							| 
									
										
										
										
											2023-07-15 20:58:52 +02:00
										 |  |  | class HBoxContainer; | 
					
						
							|  |  |  | class SplitContainer; | 
					
						
							| 
									
										
										
										
											2023-07-14 18:25:51 +02:00
										 |  |  | class EditorFileDialog; | 
					
						
							|  |  |  | class EditorInspectorPlugin; | 
					
						
							| 
									
										
										
										
											2023-07-10 15:36:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-15 20:58:52 +02:00
										 |  |  | class TileSetEditor : public Control { | 
					
						
							|  |  |  | 	GDCLASS(TileSetEditor, Control); | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static TileSetEditor *singleton; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-09-06 13:26:19 +01:00
										 |  |  | 	bool read_only = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 	Ref<TileSet> tile_set; | 
					
						
							|  |  |  | 	bool tile_set_changed_needs_update = false; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	HSplitContainer *split_container = nullptr; | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 13:55:44 -03:00
										 |  |  | 	// TabBar.
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	HBoxContainer *tile_set_toolbar = nullptr; | 
					
						
							|  |  |  | 	TabBar *tabs_bar = nullptr; | 
					
						
							| 
									
										
										
										
											2021-09-29 17:48:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Tiles.
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Label *no_source_selected_label = nullptr; | 
					
						
							|  |  |  | 	TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr; | 
					
						
							|  |  |  | 	TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr; | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-01 10:22:41 +01:00
										 |  |  | 	void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); | 
					
						
							|  |  |  | 	bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; | 
					
						
							| 
									
										
										
										
											2023-07-19 10:38:08 -03:00
										 |  |  | 	void _load_texture_files(const Vector<String> &p_paths); | 
					
						
							| 
									
										
										
										
											2021-11-01 10:22:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-06 14:43:03 +02:00
										 |  |  | 	void _update_sources_list(int force_selected_id = -1); | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-06 14:43:03 +02:00
										 |  |  | 	// Sources management.
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Button *sources_delete_button = nullptr; | 
					
						
							|  |  |  | 	MenuButton *sources_add_button = nullptr; | 
					
						
							|  |  |  | 	MenuButton *source_sort_button = nullptr; | 
					
						
							|  |  |  | 	MenuButton *sources_advanced_menu_button = nullptr; | 
					
						
							|  |  |  | 	ItemList *sources_list = nullptr; | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 	Ref<Texture2D> missing_texture_texture; | 
					
						
							|  |  |  | 	void _source_selected(int p_source_index); | 
					
						
							|  |  |  | 	void _source_delete_pressed(); | 
					
						
							| 
									
										
										
										
											2021-07-06 14:43:03 +02:00
										 |  |  | 	void _source_add_id_pressed(int p_id_pressed); | 
					
						
							|  |  |  | 	void _sources_advanced_menu_id_pressed(int p_id_pressed); | 
					
						
							| 
									
										
										
										
											2021-11-10 02:27:37 +01:00
										 |  |  | 	void _set_source_sort(int p_sort); | 
					
						
							| 
									
										
										
										
											2021-07-06 14:43:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-10 15:36:00 +02:00
										 |  |  | 	EditorFileDialog *texture_file_dialog = nullptr; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	AtlasMergingDialog *atlas_merging_dialog = nullptr; | 
					
						
							|  |  |  | 	TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr; | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-01 17:32:36 +02:00
										 |  |  | 	bool first_edit = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-29 17:48:27 +02:00
										 |  |  | 	// Patterns.
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	ItemList *patterns_item_list = nullptr; | 
					
						
							|  |  |  | 	Label *patterns_help_label = nullptr; | 
					
						
							| 
									
										
										
										
											2021-09-29 17:48:27 +02:00
										 |  |  | 	void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event); | 
					
						
							|  |  |  | 	void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture); | 
					
						
							|  |  |  | 	bool select_last_pattern = false; | 
					
						
							|  |  |  | 	void _update_patterns_list(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-15 20:58:52 +02:00
										 |  |  | 	// Expanded editor.
 | 
					
						
							|  |  |  | 	PanelContainer *expanded_area = nullptr; | 
					
						
							|  |  |  | 	Control *expanded_editor = nullptr; | 
					
						
							|  |  |  | 	ObjectID expanded_editor_parent; | 
					
						
							|  |  |  | 	LocalVector<SplitContainer *> disable_on_expand; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 	void _tile_set_changed(); | 
					
						
							| 
									
										
										
										
											2021-09-29 17:48:27 +02:00
										 |  |  | 	void _tab_changed(int p_tab_changed); | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-15 13:25:58 -03:00
										 |  |  | 	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); | 
					
						
							|  |  |  | 	void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value); | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	void _notification(int p_what); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void edit(Ref<TileSet> p_tile_set); | 
					
						
							| 
									
										
										
										
											2021-09-29 17:48:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-15 20:58:52 +02:00
										 |  |  | 	void add_expanded_editor(Control *p_editor); | 
					
						
							|  |  |  | 	void remove_expanded_editor(); | 
					
						
							|  |  |  | 	void register_split(SplitContainer *p_split); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 15:41:39 +02:00
										 |  |  | 	TileSetEditor(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-14 18:25:51 +02:00
										 |  |  | class TileSourceInspectorPlugin : public EditorInspectorPlugin { | 
					
						
							|  |  |  | 	GDCLASS(TileSourceInspectorPlugin, EditorInspectorPlugin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	AcceptDialog *id_edit_dialog = nullptr; | 
					
						
							|  |  |  | 	Label *id_label = nullptr; | 
					
						
							|  |  |  | 	SpinBox *id_input = nullptr; | 
					
						
							|  |  |  | 	Object *edited_source = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _show_id_edit_dialog(Object *p_for_source); | 
					
						
							|  |  |  | 	void _confirm_change_id(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual bool can_handle(Object *p_object) override; | 
					
						
							|  |  |  | 	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; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-23 23:41:51 +02:00
										 |  |  | #endif // TILE_SET_EDITOR_H
 |