editor_export_godot3.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*************************************************************************/
  2. /* editor_export_godot3.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 EDITOR_EXPORT_GODOT3_H
  31. #define EDITOR_EXPORT_GODOT3_H
  32. #include "editor/editor_file_system.h"
  33. #include "io/export_data.h"
  34. #include "scene/main/node.h"
  35. class EditorExportGodot3 {
  36. Map<String, int> pack_names;
  37. HashMap<Variant, int, VariantHasher> pack_values;
  38. int _pack_name(const String &p_name) {
  39. if (pack_names.has(p_name)) {
  40. return pack_names[p_name];
  41. }
  42. int idx = pack_names.size();
  43. pack_names[p_name] = idx;
  44. return idx;
  45. }
  46. int _pack_value(const Variant &p_value) {
  47. if (pack_values.has(p_value)) {
  48. return pack_values[p_value];
  49. }
  50. int idx = pack_values.size();
  51. pack_values[p_value] = idx;
  52. return idx;
  53. }
  54. Map<String, String> globals_rename_map;
  55. Map<String, String> prop_rename_map;
  56. Map<String, String> type_rename_map;
  57. Map<String, String> signal_rename_map;
  58. Map<String, String> resource_replace_map;
  59. String _replace_resource(const String &p_res) {
  60. if (resource_replace_map.has(p_res))
  61. return resource_replace_map[p_res];
  62. else
  63. return p_res;
  64. }
  65. Error _get_property_as_text(const Variant &p_variant, String &p_string);
  66. void _save_text(const String &p_path, ExportData &resource);
  67. void _save_binary_property(const Variant &p_property, FileAccess *f);
  68. void _save_binary(const String &p_path, ExportData &resource);
  69. void _save_config(const String &p_path);
  70. void _rename_properties(const String &p_type, List<ExportData::PropertyData> *p_props);
  71. void _add_new_properties(const String &p_type, List<ExportData::PropertyData> *p_props);
  72. void _convert_resources(ExportData &resource);
  73. void _unpack_packed_scene(ExportData &resource);
  74. void _pack_packed_scene(ExportData &resource);
  75. Error _convert_script(const String &p_path, const String &p_target_path, bool mark_converted_lines);
  76. void _find_files(EditorFileSystemDirectory *p_dir, List<String> *r_files);
  77. public:
  78. Error export_godot3(const String &p_path, bool convert_scripts, bool mark_converted_lines);
  79. EditorExportGodot3();
  80. };
  81. #endif // EDITOR_EXPORT_GODOT3_H