gdnative_library_editor_plugin.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*************************************************************************/
  2. /* gdnative_library_editor_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
  31. #define GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
  32. #ifdef TOOLS_ENABLED
  33. #include "editor/editor_node.h"
  34. #include "gdnative.h"
  35. class GDNativeLibraryEditor : public Control {
  36. GDCLASS(GDNativeLibraryEditor, Control);
  37. struct NativePlatformConfig {
  38. String name;
  39. String library_extension;
  40. List<String> entries;
  41. };
  42. struct TargetConfig {
  43. String library;
  44. Array dependencies;
  45. };
  46. enum ItemButton {
  47. BUTTON_SELECT_LIBRARY,
  48. BUTTON_CLEAR_LIBRARY,
  49. BUTTON_SELECT_DEPENDENCES,
  50. BUTTON_CLEAR_DEPENDENCES,
  51. BUTTON_ERASE_ENTRY,
  52. BUTTON_MOVE_UP,
  53. BUTTON_MOVE_DOWN,
  54. };
  55. Tree *tree;
  56. OptionButton *filter;
  57. EditorFileDialog *file_dialog;
  58. ConfirmationDialog *new_architecture_dialog;
  59. LineEdit *new_architecture_input;
  60. Set<String> collapsed_items;
  61. String showing_platform;
  62. Ref<GDNativeLibrary> library;
  63. Map<String, NativePlatformConfig> platforms;
  64. Map<String, TargetConfig> entry_configs;
  65. protected:
  66. static void _bind_methods();
  67. void _update_tree();
  68. void _on_item_button(Object *item, int column, int id);
  69. void _on_library_selected(const String &file);
  70. void _on_dependencies_selected(const PoolStringArray &files);
  71. void _on_filter_selected(int id);
  72. void _on_item_collapsed(Object *p_item);
  73. void _on_item_activated();
  74. void _on_create_new_entry();
  75. void _set_target_value(const String &section, const String &target, Variant file);
  76. void _erase_entry(const String &platform, const String &entry);
  77. void _move_entry(const String &platform, const String &entry, int dir);
  78. void _translate_to_config_file();
  79. public:
  80. void edit(Ref<GDNativeLibrary> p_library);
  81. GDNativeLibraryEditor();
  82. };
  83. class GDNativeLibraryEditorPlugin : public EditorPlugin {
  84. GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin);
  85. GDNativeLibraryEditor *library_editor;
  86. EditorNode *editor;
  87. Button *button;
  88. public:
  89. virtual String get_name() const { return "GDNativeLibrary"; }
  90. bool has_main_screen() const { return false; }
  91. virtual void edit(Object *p_node);
  92. virtual bool handles(Object *p_node) const;
  93. virtual void make_visible(bool p_visible);
  94. GDNativeLibraryEditorPlugin(EditorNode *p_node);
  95. };
  96. #endif
  97. #endif // GDNATIVE_LIBRARY_EDITOR_PLUGIN_H