localization_editor.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* localization_editor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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 LOCALIZATION_EDITOR_H
  31. #define LOCALIZATION_EDITOR_H
  32. #include "core/object/undo_redo.h"
  33. #include "editor_file_dialog.h"
  34. #include "scene/gui/tree.h"
  35. class LocalizationEditor : public VBoxContainer {
  36. GDCLASS(LocalizationEditor, VBoxContainer);
  37. enum LocaleFilter {
  38. SHOW_ALL_LOCALES,
  39. SHOW_ONLY_SELECTED_LOCALES,
  40. };
  41. Tree *translation_list;
  42. EditorFileDialog *translation_file_open;
  43. Button *translation_res_option_add_button;
  44. EditorFileDialog *translation_res_file_open_dialog;
  45. EditorFileDialog *translation_res_option_file_open_dialog;
  46. Tree *translation_remap;
  47. Tree *translation_remap_options;
  48. Tree *translation_filter;
  49. bool translation_locales_list_created;
  50. OptionButton *translation_locale_filter_mode;
  51. Vector<TreeItem *> translation_filter_treeitems;
  52. Vector<int> translation_locales_idxs_remap;
  53. Label *ts_name;
  54. Label *ts_data_status;
  55. Label *ts_data_info;
  56. Button *ts_install;
  57. Tree *translation_pot_list;
  58. EditorFileDialog *pot_file_open_dialog;
  59. EditorFileDialog *pot_generate_dialog;
  60. UndoRedo *undo_redo;
  61. bool updating_translations;
  62. String localization_changed;
  63. void _translation_file_open();
  64. void _translation_add(const PackedStringArray &p_paths);
  65. void _translation_delete(Object *p_item, int p_column, int p_button);
  66. void _translation_res_file_open();
  67. void _translation_res_add(const PackedStringArray &p_paths);
  68. void _translation_res_delete(Object *p_item, int p_column, int p_button);
  69. void _translation_res_select();
  70. void _translation_res_option_file_open();
  71. void _translation_res_option_add(const PackedStringArray &p_paths);
  72. void _translation_res_option_changed();
  73. void _translation_res_option_delete(Object *p_item, int p_column, int p_button);
  74. void _translation_filter_option_changed();
  75. void _translation_filter_mode_changed(int p_mode);
  76. void _pot_add(const PackedStringArray &p_paths);
  77. void _pot_delete(Object *p_item, int p_column, int p_button);
  78. void _pot_file_open();
  79. void _pot_generate_open();
  80. void _pot_generate(const String &p_file);
  81. void _update_pot_file_extensions();
  82. void _install_ts_data();
  83. protected:
  84. void _notification(int p_what);
  85. static void _bind_methods();
  86. public:
  87. void add_translation(const String &p_translation);
  88. void update_translations();
  89. LocalizationEditor();
  90. };
  91. #endif // LOCALIZATION_EDITOR_H