atlas_merging_dialog.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**************************************************************************/
  2. /* atlas_merging_dialog.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. #ifndef ATLAS_MERGING_DIALOG_H
  31. #define ATLAS_MERGING_DIALOG_H
  32. #include "editor/editor_properties.h"
  33. #include "scene/gui/dialogs.h"
  34. #include "scene/gui/item_list.h"
  35. #include "scene/gui/texture_rect.h"
  36. #include "scene/resources/2d/tile_set.h"
  37. class EditorFileDialog;
  38. class EditorPropertyVector2i;
  39. class AtlasMergingDialog : public ConfirmationDialog {
  40. GDCLASS(AtlasMergingDialog, ConfirmationDialog);
  41. private:
  42. int commited_actions_count = 0;
  43. bool delete_original_atlases = true;
  44. Ref<TileSetAtlasSource> merged;
  45. LocalVector<HashMap<Vector2i, Vector2i>> merged_mapping;
  46. Ref<TileSet> tile_set;
  47. // Settings.
  48. int next_line_after_column = 30;
  49. // GUI.
  50. ItemList *atlas_merging_atlases_list = nullptr;
  51. EditorPropertyVector2i *texture_region_size_editor_property = nullptr;
  52. EditorPropertyInteger *columns_editor_property = nullptr;
  53. TextureRect *preview = nullptr;
  54. Label *select_2_atlases_label = nullptr;
  55. EditorFileDialog *editor_file_dialog = nullptr;
  56. Button *merge_button = nullptr;
  57. void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing);
  58. void _generate_merged(const Vector<Ref<TileSetAtlasSource>> &p_atlas_sources, int p_max_columns);
  59. void _update_texture();
  60. void _merge_confirmed(const String &p_path);
  61. protected:
  62. virtual void ok_pressed() override;
  63. virtual void cancel_pressed() override;
  64. virtual void custom_action(const String &) override;
  65. bool _set(const StringName &p_name, const Variant &p_value);
  66. bool _get(const StringName &p_name, Variant &r_ret) const;
  67. void _notification(int p_what);
  68. public:
  69. void update_tile_set(Ref<TileSet> p_tile_set);
  70. AtlasMergingDialog();
  71. };
  72. #endif // ATLAS_MERGING_DIALOG_H