export.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*************************************************************************/
  2. /* export.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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. #include "editor/editor_export.h"
  31. #include "editor/editor_settings.h"
  32. #include "os/file_access.h"
  33. #include "os/os.h"
  34. #include "platform/windows/logo.gen.h"
  35. class EditorExportPlatformWindows : public EditorExportPlatformPC {
  36. public:
  37. virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
  38. virtual void get_export_options(List<ExportOption> *r_options);
  39. };
  40. Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  41. Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, p_path, p_flags);
  42. if (err != OK) {
  43. return err;
  44. }
  45. String rcedit_path = EditorSettings::get_singleton()->get("export/windows/rcedit");
  46. String icon_path = p_preset->get("application/icon");
  47. String file_verion = p_preset->get("application/file_version");
  48. String product_version = p_preset->get("application/product_version");
  49. String company_name = p_preset->get("application/company_name");
  50. String product_name = p_preset->get("application/product_name");
  51. String file_description = p_preset->get("application/file_description");
  52. String copyright = p_preset->get("application/copyright");
  53. String trademarks = p_preset->get("application/trademarks");
  54. String comments = p_preset->get("application/comments");
  55. if (rcedit_path == String()) {
  56. return OK;
  57. }
  58. if (!FileAccess::exists(rcedit_path)) {
  59. return ERR_FILE_NOT_FOUND;
  60. }
  61. List<String> args;
  62. args.push_back(p_path);
  63. if (icon_path != String()) {
  64. args.push_back("--set-icon");
  65. args.push_back(icon_path);
  66. }
  67. if (file_verion != String()) {
  68. args.push_back("--set-file-version");
  69. args.push_back(file_verion);
  70. }
  71. if (product_version != String()) {
  72. args.push_back("--set-product-version");
  73. args.push_back(product_version);
  74. }
  75. if (company_name != String()) {
  76. args.push_back("--set-version-string");
  77. args.push_back("CompanyName");
  78. args.push_back(company_name);
  79. }
  80. if (product_name != String()) {
  81. args.push_back("--set-version-string");
  82. args.push_back("ProductName");
  83. args.push_back(product_name);
  84. }
  85. if (file_description != String()) {
  86. args.push_back("--set-version-string");
  87. args.push_back("FileDescription");
  88. args.push_back(file_description);
  89. }
  90. if (copyright != String()) {
  91. args.push_back("--set-version-string");
  92. args.push_back("LegalCopyright");
  93. args.push_back(copyright);
  94. }
  95. if (trademarks != String()) {
  96. args.push_back("--set-version-string");
  97. args.push_back("LegalTrademarks");
  98. args.push_back(trademarks);
  99. }
  100. OS::get_singleton()->execute(rcedit_path, args, true);
  101. return OK;
  102. }
  103. void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) {
  104. EditorExportPlatformPC::get_export_options(r_options);
  105. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_GLOBAL_FILE, "*.ico"), String()));
  106. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version"), String()));
  107. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version"), String()));
  108. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name"), String()));
  109. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name"), String()));
  110. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), String()));
  111. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), String()));
  112. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/trademarks"), String()));
  113. }
  114. void register_windows_exporter() {
  115. EDITOR_DEF("export/windows/rcedit", "");
  116. EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/rcedit", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
  117. Ref<EditorExportPlatformWindows> platform;
  118. platform.instance();
  119. Ref<Image> img = memnew(Image(_windows_logo));
  120. Ref<ImageTexture> logo;
  121. logo.instance();
  122. logo->create_from_image(img);
  123. platform->set_logo(logo);
  124. platform->set_name("Windows Desktop");
  125. platform->set_extension("exe");
  126. platform->set_release_32("windows_32_release.exe");
  127. platform->set_debug_32("windows_32_debug.exe");
  128. platform->set_release_64("windows_64_release.exe");
  129. platform->set_debug_64("windows_64_debug.exe");
  130. platform->set_os_name("Windows");
  131. EditorExport::get_singleton()->add_export_platform(platform);
  132. }