editor_settings.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*************************************************************************/
  2. /* editor_settings.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef EDITOR_SETTINGS_H
  30. #define EDITOR_SETTINGS_H
  31. #include "object.h"
  32. #include "resource.h"
  33. #include "os/thread_safe.h"
  34. class EditorPlugin;
  35. class EditorSettings : public Resource {
  36. OBJ_TYPE( EditorSettings, Resource );
  37. private:
  38. _THREAD_SAFE_CLASS_
  39. public:
  40. struct Plugin {
  41. EditorPlugin *instance;
  42. String path;
  43. String name;
  44. String author;
  45. String version;
  46. String description;
  47. bool installs;
  48. String script;
  49. Vector<String> install_files;
  50. };
  51. private:
  52. Map<String,Plugin> plugins;
  53. struct VariantContainer {
  54. int order;
  55. Variant variant;
  56. bool hide_from_editor;
  57. VariantContainer(){ order=0; hide_from_editor=false; }
  58. VariantContainer(const Variant& p_variant, int p_order) { variant=p_variant; order=p_order; hide_from_editor=false; }
  59. };
  60. HashMap<String,PropertyInfo> hints;
  61. int last_order;
  62. HashMap<String,VariantContainer> props;
  63. String resource_path;
  64. bool _set(const StringName& p_name, const Variant& p_value);
  65. bool _get(const StringName& p_name,Variant &r_ret) const;
  66. void _get_property_list(List<PropertyInfo> *p_list) const;
  67. static Ref<EditorSettings> singleton;
  68. String config_file_path;
  69. String settings_path;
  70. Ref<Resource> clipboard;
  71. EditorPlugin *_load_plugin_editor(const String& p_path);
  72. Error _load_plugin(const String& p_path,Plugin& plugin);
  73. void _load_defaults();
  74. protected:
  75. static void _bind_methods();
  76. public:
  77. enum {
  78. NOTIFICATION_EDITOR_SETTINGS_CHANGED=10000
  79. };
  80. bool has(String p_var) const;
  81. static EditorSettings *get_singleton();
  82. void erase(String p_var);
  83. String get_settings_path() const;
  84. const Map<String,Plugin>& get_plugins() const { return plugins; }
  85. void scan_plugins();
  86. void enable_plugins();
  87. void raise_order(const String& p_name);
  88. static void create();
  89. static void save();
  90. static void destroy();
  91. void notify_changes();
  92. void set_plugin_enabled(const String& p_plugin,bool p_enabled);
  93. bool is_plugin_enabled(const String& p_plugin);
  94. void load_installed_plugin(const String& p_plugin);
  95. void set_resource_clipboard(const Ref<Resource>& p_resource) { clipboard=p_resource; }
  96. Ref<Resource> get_resource_clipboard() const { return clipboard; }
  97. void add_property_hint(const PropertyInfo& p_hint);
  98. EditorSettings();
  99. ~EditorSettings();
  100. };
  101. //not a macro any longer
  102. #define EDITOR_DEF(m_var,m_val) _EDITOR_DEF(m_var,Variant(m_val))
  103. Variant _EDITOR_DEF( const String& p_var, const Variant& p_default);
  104. #endif // EDITOR_SETTINGS_H