diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/export/export_plugin.cpp | 16 | ||||
-rw-r--r-- | platform/ios/export/export_plugin.cpp | 14 | ||||
-rw-r--r-- | platform/macos/display_server_macos.h | 3 | ||||
-rw-r--r-- | platform/macos/display_server_macos.mm | 32 | ||||
-rw-r--r-- | platform/uwp/export/export_plugin.cpp | 6 | ||||
-rw-r--r-- | platform/web/export/export_plugin.cpp | 16 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 63 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 3 |
8 files changed, 128 insertions, 25 deletions
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index cdffee9318..4eb516fb63 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -2225,17 +2225,16 @@ String EditorExportPlatformAndroid::get_apksigner_path(int p_target_sdk, bool p_ } bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const { - String err; - bool valid = false; - const bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); - #ifdef MODULE_MONO_ENABLED - err += TTR("Exporting to Android is currently not supported in Godot 4 when using C#/.NET. Use Godot 3 to target Android with C#/Mono instead.") + "\n"; - err += TTR("If this project does not use C#, use a non-C# editor build to export the project.") + "\n"; // Don't check for additional errors, as this particular error cannot be resolved. - r_error = err; + r_error += TTR("Exporting to Android is currently not supported in Godot 4 when using C#/.NET. Use Godot 3 to target Android with C#/Mono instead.") + "\n"; + r_error += TTR("If this project does not use C#, use a non-C# editor build to export the project.") + "\n"; return false; -#endif +#else + + String err; + bool valid = false; + const bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build"); // Look for export templates (first official, and if defined custom templates). @@ -2366,6 +2365,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito } return valid; +#endif // !MODULE_MONO_ENABLED } bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const { diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 35dc058808..544bfb71e0 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -1925,16 +1925,15 @@ Error EditorExportPlatformIOS::_export_project_helper(const Ref<EditorExportPres } bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const { - String err; - bool valid = false; - #ifdef MODULE_MONO_ENABLED - err += TTR("Exporting to iOS is currently not supported in Godot 4 when using C#/.NET. Use Godot 3 to target iOS with C#/Mono instead.") + "\n"; - err += TTR("If this project does not use C#, use a non-C# editor build to export the project.") + "\n"; // Don't check for additional errors, as this particular error cannot be resolved. - r_error = err; + r_error += TTR("Exporting to iOS is currently not supported in Godot 4 when using C#/.NET. Use Godot 3 to target iOS with C#/Mono instead.") + "\n"; + r_error += TTR("If this project does not use C#, use a non-C# editor build to export the project.") + "\n"; return false; -#endif +#else + + String err; + bool valid = false; // Look for export templates (first official, and if defined custom templates). @@ -1962,6 +1961,7 @@ bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExp } return valid; +#endif // !MODULE_MONO_ENABLED } bool EditorExportPlatformIOS::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const { diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index aef45e534f..e5e0e53bfb 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -328,6 +328,9 @@ public: virtual void clipboard_set(const String &p_text) override; virtual String clipboard_get() const override; + virtual Ref<Image> clipboard_get_image() const override; + virtual bool clipboard_has() const override; + virtual bool clipboard_has_image() const override; virtual int get_screen_count() const override; virtual int get_primary_screen() const override; diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index ac0659ee7f..d64bb5211e 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -44,6 +44,7 @@ #include "core/io/marshalls.h" #include "core/math/geometry_2d.h" #include "core/os/keyboard.h" +#include "drivers/png/png_driver_common.h" #include "main/main.h" #include "scene/resources/atlas_texture.h" #include "scene/resources/image_texture.h" @@ -2271,6 +2272,37 @@ String DisplayServerMacOS::clipboard_get() const { return ret; } +Ref<Image> DisplayServerMacOS::clipboard_get_image() const { + Ref<Image> image; + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + NSString *result = [pasteboard availableTypeFromArray:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, NSPasteboardTypePNG, nil]]; + if (!result) { + return image; + } + NSData *data = [pasteboard dataForType:result]; + if (!data) { + return image; + } + NSBitmapImageRep *bitmap = [NSBitmapImageRep imageRepWithData:data]; + NSData *pngData = [bitmap representationUsingType:NSPNGFileType properties:@{}]; + image.instantiate(); + PNGDriverCommon::png_to_image((const uint8_t *)pngData.bytes, pngData.length, false, image); + return image; +} + +bool DisplayServerMacOS::clipboard_has() const { + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + NSArray *classArray = [NSArray arrayWithObject:[NSString class]]; + NSDictionary *options = [NSDictionary dictionary]; + return [pasteboard canReadObjectForClasses:classArray options:options]; +} + +bool DisplayServerMacOS::clipboard_has_image() const { + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + NSString *result = [pasteboard availableTypeFromArray:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, NSPasteboardTypePNG, nil]]; + return result; +} + int DisplayServerMacOS::get_screen_count() const { _THREAD_SAFE_METHOD_ diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp index 016a87e31d..c92520b755 100644 --- a/platform/uwp/export/export_plugin.cpp +++ b/platform/uwp/export/export_plugin.cpp @@ -136,7 +136,7 @@ bool EditorExportPlatformUWP::has_valid_export_configuration(const Ref<EditorExp // contributors can still test the pipeline if/when we can build it again. r_error = "The UWP platform is currently not supported in Godot 4.\n"; return false; -#endif +#else String err; bool valid = false; @@ -176,6 +176,7 @@ bool EditorExportPlatformUWP::has_valid_export_configuration(const Ref<EditorExp } return valid; +#endif // DEV_ENABLED } bool EditorExportPlatformUWP::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const { @@ -185,7 +186,7 @@ bool EditorExportPlatformUWP::has_valid_project_configuration(const Ref<EditorEx // contributors can still test the pipeline if/when we can build it again. r_error = "The UWP platform is currently not supported in Godot 4.\n"; return false; -#endif +#else String err; bool valid = true; @@ -259,6 +260,7 @@ bool EditorExportPlatformUWP::has_valid_project_configuration(const Ref<EditorEx r_error = err; return valid; +#endif // DEV_ENABLED } Error EditorExportPlatformUWP::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 415390f740..38e2714d9f 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -360,17 +360,16 @@ Ref<Texture2D> EditorExportPlatformWeb::get_logo() const { } bool EditorExportPlatformWeb::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const { - String err; - bool valid = false; - bool extensions = (bool)p_preset->get("variant/extensions_support"); - #ifdef MODULE_MONO_ENABLED - err += TTR("Exporting to Web is currently not supported in Godot 4 when using C#/.NET. Use Godot 3 to target Web with C#/Mono instead.") + "\n"; - err += TTR("If this project does not use C#, use a non-C# editor build to export the project.") + "\n"; // Don't check for additional errors, as this particular error cannot be resolved. - r_error = err; + r_error += TTR("Exporting to Web is currently not supported in Godot 4 when using C#/.NET. Use Godot 3 to target Web with C#/Mono instead.") + "\n"; + r_error += TTR("If this project does not use C#, use a non-C# editor build to export the project.") + "\n"; return false; -#endif +#else + + String err; + bool valid = false; + bool extensions = (bool)p_preset->get("variant/extensions_support"); // Look for export templates (first official, and if defined custom templates). bool dvalid = exists_export_template(_get_template_name(extensions, true), &err); @@ -397,6 +396,7 @@ bool EditorExportPlatformWeb::has_valid_export_configuration(const Ref<EditorExp } return valid; +#endif // !MODULE_MONO_ENABLED } bool EditorExportPlatformWeb::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const { diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index c664752c2f..c073d6f028 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -34,6 +34,7 @@ #include "core/config/project_settings.h" #include "core/io/marshalls.h" +#include "drivers/png/png_driver_common.h" #include "main/main.h" #include "scene/resources/atlas_texture.h" @@ -468,6 +469,68 @@ String DisplayServerWindows::clipboard_get() const { return ret; } +Ref<Image> DisplayServerWindows::clipboard_get_image() const { + Ref<Image> image; + if (!windows.has(last_focused_window)) { + return image; // No focused window? + } + if (!OpenClipboard(windows[last_focused_window].hWnd)) { + ERR_FAIL_V_MSG(image, "Unable to open clipboard."); + } + UINT png_format = RegisterClipboardFormatA("PNG"); + if (png_format && IsClipboardFormatAvailable(png_format)) { + HANDLE png_handle = GetClipboardData(png_format); + if (png_handle) { + size_t png_size = GlobalSize(png_handle); + uint8_t *png_data = (uint8_t *)GlobalLock(png_handle); + image.instantiate(); + + PNGDriverCommon::png_to_image(png_data, png_size, false, image); + + GlobalUnlock(png_handle); + } + } else if (IsClipboardFormatAvailable(CF_DIB)) { + HGLOBAL mem = GetClipboardData(CF_DIB); + if (mem != NULL) { + BITMAPINFO *ptr = static_cast<BITMAPINFO *>(GlobalLock(mem)); + + if (ptr != NULL) { + BITMAPINFOHEADER *info = &ptr->bmiHeader; + PackedByteArray pba; + + for (LONG y = info->biHeight - 1; y > -1; y--) { + for (LONG x = 0; x < info->biWidth; x++) { + tagRGBQUAD *rgbquad = ptr->bmiColors + (info->biWidth * y) + x; + pba.append(rgbquad->rgbRed); + pba.append(rgbquad->rgbGreen); + pba.append(rgbquad->rgbBlue); + pba.append(rgbquad->rgbReserved); + } + } + image.instantiate(); + image->create_from_data(info->biWidth, info->biHeight, false, Image::Format::FORMAT_RGBA8, pba); + + GlobalUnlock(mem); + } + } + } + + CloseClipboard(); + + return image; +} + +bool DisplayServerWindows::clipboard_has() const { + return (IsClipboardFormatAvailable(CF_TEXT) || + IsClipboardFormatAvailable(CF_UNICODETEXT) || + IsClipboardFormatAvailable(CF_OEMTEXT)); +} + +bool DisplayServerWindows::clipboard_has_image() const { + UINT png_format = RegisterClipboardFormatA("PNG"); + return ((png_format && IsClipboardFormatAvailable(png_format)) || IsClipboardFormatAvailable(CF_DIB)); +} + typedef struct { int count; int screen; diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index bd47dee9ec..59c4442604 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -522,6 +522,9 @@ public: virtual void clipboard_set(const String &p_text) override; virtual String clipboard_get() const override; + virtual Ref<Image> clipboard_get_image() const override; + virtual bool clipboard_has() const override; + virtual bool clipboard_has_image() const override; virtual int get_screen_count() const override; virtual int get_primary_screen() const override; |