123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- #include "core/os/file_access.h"
- #include "core/os/os.h"
- #include "editor/editor_export.h"
- #include "editor/editor_settings.h"
- #include "platform/windows/logo.gen.h"
- class EditorExportPlatformWindows : public EditorExportPlatformPC {
- public:
- virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
- virtual void get_export_options(List<ExportOption> *r_options);
- };
- Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, p_path, p_flags);
- if (err != OK) {
- return err;
- }
- String rcedit_path = EditorSettings::get_singleton()->get("export/windows/rcedit");
- if (rcedit_path == String()) {
- return OK;
- }
- if (!FileAccess::exists(rcedit_path)) {
- ERR_PRINTS("Could not find rcedit executable at " + rcedit_path + ", aborting.");
- return ERR_FILE_NOT_FOUND;
- }
- #ifndef WINDOWS_ENABLED
-
- String wine_path = EditorSettings::get_singleton()->get("export/windows/wine");
- if (wine_path != String() && !FileAccess::exists(wine_path)) {
- ERR_PRINTS("Could not find wine executable at " + wine_path + ", aborting.");
- return ERR_FILE_NOT_FOUND;
- }
- if (wine_path == String()) {
- wine_path = "wine";
- }
- #endif
- String icon_path = p_preset->get("application/icon");
- String file_verion = p_preset->get("application/file_version");
- String product_version = p_preset->get("application/product_version");
- String company_name = p_preset->get("application/company_name");
- String product_name = p_preset->get("application/product_name");
- String file_description = p_preset->get("application/file_description");
- String copyright = p_preset->get("application/copyright");
- String trademarks = p_preset->get("application/trademarks");
- String comments = p_preset->get("application/comments");
- List<String> args;
- args.push_back(p_path);
- if (icon_path != String()) {
- args.push_back("--set-icon");
- args.push_back(icon_path);
- }
- if (file_verion != String()) {
- args.push_back("--set-file-version");
- args.push_back(file_verion);
- }
- if (product_version != String()) {
- args.push_back("--set-product-version");
- args.push_back(product_version);
- }
- if (company_name != String()) {
- args.push_back("--set-version-string");
- args.push_back("CompanyName");
- args.push_back(company_name);
- }
- if (product_name != String()) {
- args.push_back("--set-version-string");
- args.push_back("ProductName");
- args.push_back(product_name);
- }
- if (file_description != String()) {
- args.push_back("--set-version-string");
- args.push_back("FileDescription");
- args.push_back(file_description);
- }
- if (copyright != String()) {
- args.push_back("--set-version-string");
- args.push_back("LegalCopyright");
- args.push_back(copyright);
- }
- if (trademarks != String()) {
- args.push_back("--set-version-string");
- args.push_back("LegalTrademarks");
- args.push_back(trademarks);
- }
- #ifdef WINDOWS_ENABLED
- OS::get_singleton()->execute(rcedit_path, args, true);
- #else
-
- args.push_front(rcedit_path);
- OS::get_singleton()->execute(wine_path, args, true);
- #endif
- return OK;
- }
- void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) {
- EditorExportPlatformPC::get_export_options(r_options);
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_GLOBAL_FILE, "*.ico"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/trademarks"), ""));
- }
- void register_windows_exporter() {
- EDITOR_DEF("export/windows/rcedit", "");
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/rcedit", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
- #ifndef WINDOWS_ENABLED
-
- EDITOR_DEF("export/windows/wine", "");
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/wine", PROPERTY_HINT_GLOBAL_FILE));
- #endif
- Ref<EditorExportPlatformWindows> platform;
- platform.instance();
- Ref<Image> img = memnew(Image(_windows_logo));
- Ref<ImageTexture> logo;
- logo.instance();
- logo->create_from_image(img);
- platform->set_logo(logo);
- platform->set_name("Windows Desktop");
- platform->set_extension("exe");
- platform->set_release_32("windows_32_release.exe");
- platform->set_debug_32("windows_32_debug.exe");
- platform->set_release_64("windows_64_release.exe");
- platform->set_debug_64("windows_64_debug.exe");
- platform->set_os_name("Windows");
- EditorExport::get_singleton()->add_export_platform(platform);
- }
|