project_settings_editor.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*************************************************************************/
  2. /* project_settings_editor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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 PROJECT_SETTINGS_EDITOR_H
  31. #define PROJECT_SETTINGS_EDITOR_H
  32. #include "core/undo_redo.h"
  33. #include "editor/editor_autoload_settings.h"
  34. #include "editor/editor_data.h"
  35. #include "editor/editor_plugin_settings.h"
  36. #include "editor/editor_sectioned_inspector.h"
  37. #include "editor/shader_globals_editor.h"
  38. #include "scene/gui/dialogs.h"
  39. #include "scene/gui/tab_container.h"
  40. class ProjectSettingsEditor : public AcceptDialog {
  41. GDCLASS(ProjectSettingsEditor, AcceptDialog);
  42. enum InputType {
  43. INPUT_KEY,
  44. INPUT_KEY_PHYSICAL,
  45. INPUT_JOY_BUTTON,
  46. INPUT_JOY_MOTION,
  47. INPUT_MOUSE_BUTTON
  48. };
  49. enum LocaleFilter {
  50. SHOW_ALL_LOCALES,
  51. SHOW_ONLY_SELECTED_LOCALES,
  52. };
  53. TabContainer *tab_container;
  54. Timer *timer;
  55. InputType add_type;
  56. String add_at;
  57. int edit_idx;
  58. EditorData *data;
  59. UndoRedo *undo_redo;
  60. SectionedInspector *globals_editor;
  61. HBoxContainer *search_bar;
  62. Button *search_button;
  63. LineEdit *search_box;
  64. HBoxContainer *add_prop_bar;
  65. AcceptDialog *message;
  66. LineEdit *category;
  67. LineEdit *property;
  68. OptionButton *type;
  69. PopupMenu *popup_add;
  70. ConfirmationDialog *press_a_key;
  71. bool press_a_key_physical;
  72. Label *press_a_key_label;
  73. ConfirmationDialog *device_input;
  74. OptionButton *device_id;
  75. OptionButton *device_index;
  76. Label *device_index_label;
  77. MenuButton *popup_copy_to_feature;
  78. ShaderGlobalsEditor *shaders_global_variables_editor;
  79. LineEdit *action_name;
  80. Button *action_add;
  81. Label *action_add_error;
  82. Tree *input_editor;
  83. bool setting;
  84. bool updating_translations;
  85. Ref<InputEventKey> last_wait_for_key;
  86. EditorFileDialog *translation_file_open;
  87. Tree *translation_list;
  88. Button *translation_res_option_add_button;
  89. EditorFileDialog *translation_res_file_open;
  90. EditorFileDialog *translation_res_option_file_open;
  91. Tree *translation_remap;
  92. Tree *translation_remap_options;
  93. Tree *translation_filter;
  94. bool translation_locales_list_created;
  95. OptionButton *translation_locale_filter_mode;
  96. Vector<TreeItem *> translation_filter_treeitems;
  97. Vector<int> translation_locales_idxs_remap;
  98. EditorAutoloadSettings *autoload_settings;
  99. EditorPluginSettings *plugin_settings;
  100. void _item_selected(const String &);
  101. void _item_adds(String);
  102. void _item_add();
  103. void _item_del();
  104. void _update_actions();
  105. void _save();
  106. void _add_item(int p_item, Ref<InputEvent> p_exiting_event = Ref<InputEvent>());
  107. void _edit_item(Ref<InputEvent> p_exiting_event);
  108. void _action_check(String p_action);
  109. void _action_adds(String);
  110. void _action_add();
  111. void _device_input_add();
  112. void _item_checked(const String &p_item, bool p_check);
  113. void _action_selected();
  114. void _action_edited();
  115. void _action_activated();
  116. void _action_button_pressed(Object *p_obj, int p_column, int p_id);
  117. void _wait_for_key(const Ref<InputEvent> &p_event);
  118. void _press_a_key_confirm();
  119. void _show_last_added(const Ref<InputEvent> &p_event, const String &p_name);
  120. void _settings_prop_edited(const String &p_name);
  121. void _settings_changed();
  122. void _copy_to_platform(int p_which);
  123. void _translation_file_open();
  124. void _translation_add(const String &p_path);
  125. void _translation_delete(Object *p_item, int p_column, int p_button);
  126. void _update_translations();
  127. void _translation_res_file_open();
  128. void _translation_res_add(const String &p_path);
  129. void _translation_res_delete(Object *p_item, int p_column, int p_button);
  130. void _translation_res_select();
  131. void _translation_res_option_file_open();
  132. void _translation_res_option_add(const String &p_path);
  133. void _translation_res_option_changed();
  134. void _translation_res_option_delete(Object *p_item, int p_column, int p_button);
  135. void _translation_filter_option_changed();
  136. void _translation_filter_mode_changed(int p_mode);
  137. void _toggle_search_bar(bool p_pressed);
  138. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  139. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  140. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  141. void _copy_to_platform_about_to_show();
  142. ProjectSettingsEditor();
  143. static ProjectSettingsEditor *singleton;
  144. Label *restart_label;
  145. TextureRect *restart_icon;
  146. PanelContainer *restart_container;
  147. ToolButton *restart_close_button;
  148. void _editor_restart_request();
  149. void _editor_restart();
  150. void _editor_restart_close();
  151. protected:
  152. void _unhandled_input(const Ref<InputEvent> &p_event);
  153. void _notification(int p_what);
  154. static void _bind_methods();
  155. int _get_current_device();
  156. void _set_current_device(int i_device);
  157. String _get_device_string(int i_device);
  158. public:
  159. void add_translation(const String &p_translation);
  160. static ProjectSettingsEditor *get_singleton() { return singleton; }
  161. void popup_project_settings();
  162. void set_plugins_page();
  163. void update_plugins();
  164. EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; }
  165. TabContainer *get_tabs();
  166. void queue_save();
  167. ProjectSettingsEditor(EditorData *p_data);
  168. };
  169. #endif // PROJECT_SETTINGS_EDITOR_H