tile_set_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*************************************************************************/
  2. /* tile_set_editor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 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. #ifndef TILE_SET_EDITOR_H
  31. #define TILE_SET_EDITOR_H
  32. #include "atlas_merging_dialog.h"
  33. #include "scene/gui/box_container.h"
  34. #include "scene/gui/tab_bar.h"
  35. #include "scene/resources/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. class EditorUndoRedoManager;
  40. class TileSetEditor : public VBoxContainer {
  41. GDCLASS(TileSetEditor, VBoxContainer);
  42. static TileSetEditor *singleton;
  43. private:
  44. Ref<TileSet> tile_set;
  45. bool tile_set_changed_needs_update = false;
  46. HSplitContainer *split_container = nullptr;
  47. // TabBar.
  48. HBoxContainer *tile_set_toolbar = nullptr;
  49. TabBar *tabs_bar = nullptr;
  50. // Tiles.
  51. Label *no_source_selected_label = nullptr;
  52. TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr;
  53. TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
  54. Ref<EditorUndoRedoManager> undo_redo;
  55. void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  56. bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  57. void _update_sources_list(int force_selected_id = -1);
  58. // Sources management.
  59. Button *sources_delete_button = nullptr;
  60. MenuButton *sources_add_button = nullptr;
  61. MenuButton *source_sort_button = nullptr;
  62. MenuButton *sources_advanced_menu_button = nullptr;
  63. ItemList *sources_list = nullptr;
  64. Ref<Texture2D> missing_texture_texture;
  65. void _source_selected(int p_source_index);
  66. void _source_delete_pressed();
  67. void _source_add_id_pressed(int p_id_pressed);
  68. void _sources_advanced_menu_id_pressed(int p_id_pressed);
  69. void _set_source_sort(int p_sort);
  70. AtlasMergingDialog *atlas_merging_dialog = nullptr;
  71. TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr;
  72. // Patterns.
  73. ItemList *patterns_item_list = nullptr;
  74. Label *patterns_help_label = nullptr;
  75. void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);
  76. void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture);
  77. bool select_last_pattern = false;
  78. void _update_patterns_list();
  79. void _tile_set_changed();
  80. void _tab_changed(int p_tab_changed);
  81. void _move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos);
  82. void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value);
  83. protected:
  84. void _notification(int p_what);
  85. static void _bind_methods();
  86. public:
  87. _FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }
  88. void edit(Ref<TileSet> p_tile_set);
  89. TileSetEditor();
  90. ~TileSetEditor();
  91. };
  92. #endif // TILE_SET_EDITOR_H