sprite_frames_editor_plugin.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*************************************************************************/
  2. /* sprite_frames_editor_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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 SPRITE_FRAMES_EDITOR_PLUGIN_H
  31. #define SPRITE_FRAMES_EDITOR_PLUGIN_H
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_plugin.h"
  34. #include "scene/2d/animated_sprite.h"
  35. #include "scene/gui/dialogs.h"
  36. #include "scene/gui/file_dialog.h"
  37. #include "scene/gui/split_container.h"
  38. #include "scene/gui/tree.h"
  39. class SpriteFramesEditor : public PanelContainer {
  40. GDCLASS(SpriteFramesEditor, PanelContainer);
  41. Button *load;
  42. Button *_delete;
  43. Button *copy;
  44. Button *paste;
  45. Button *empty;
  46. Button *empty2;
  47. Button *move_up;
  48. Button *move_down;
  49. ItemList *tree;
  50. bool loading_scene;
  51. int sel;
  52. HSplitContainer *split;
  53. Button *new_anim;
  54. Button *remove_anim;
  55. Tree *animations;
  56. SpinBox *anim_speed;
  57. CheckButton *anim_loop;
  58. EditorFileDialog *file;
  59. AcceptDialog *dialog;
  60. SpriteFrames *frames;
  61. StringName edited_anim;
  62. void _load_pressed();
  63. void _load_scene_pressed();
  64. void _file_load_request(const PoolVector<String> &p_path, int p_at_pos = -1);
  65. void _copy_pressed();
  66. void _paste_pressed();
  67. void _empty_pressed();
  68. void _empty2_pressed();
  69. void _delete_pressed();
  70. void _up_pressed();
  71. void _down_pressed();
  72. void _update_library(bool p_skip_selector = false);
  73. void _animation_select();
  74. void _animation_name_edited();
  75. void _animation_add();
  76. void _animation_remove();
  77. void _animation_loop_changed();
  78. void _animation_fps_changed(double p_value);
  79. bool updating;
  80. UndoRedo *undo_redo;
  81. bool _is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const;
  82. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  83. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  84. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  85. protected:
  86. void _notification(int p_what);
  87. void _gui_input(Ref<InputEvent> p_event);
  88. static void _bind_methods();
  89. public:
  90. void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
  91. void edit(SpriteFrames *p_frames);
  92. SpriteFramesEditor();
  93. };
  94. class SpriteFramesEditorPlugin : public EditorPlugin {
  95. GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
  96. SpriteFramesEditor *frames_editor;
  97. EditorNode *editor;
  98. Button *button;
  99. public:
  100. virtual String get_name() const { return "SpriteFrames"; }
  101. bool has_main_screen() const { return false; }
  102. virtual void edit(Object *p_object);
  103. virtual bool handles(Object *p_object) const;
  104. virtual void make_visible(bool p_visible);
  105. SpriteFramesEditorPlugin(EditorNode *p_node);
  106. ~SpriteFramesEditorPlugin();
  107. };
  108. #endif // SPRITE_FRAMES_EDITOR_PLUGIN_H