From 35969dfd85ba0c2eb606e5062e1a7c5d340e2a64 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 9 Nov 2021 23:52:46 +0100 Subject: [PATCH] Fix texture refs in platform settings to be SoftObjectReferences instead of raw Guid --- Source/Editor/Utilities/EditorUtilities.h | 14 ++++++++ .../Android/AndroidPlatformSettings.h | 9 +++-- .../Engine/Platform/GDK/GDKPlatformSettings.h | 33 ++++++++++--------- .../Platform/Linux/LinuxPlatformSettings.h | 9 +++-- .../Windows/WindowsPlatformSettings.h | 9 +++-- 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/Source/Editor/Utilities/EditorUtilities.h b/Source/Editor/Utilities/EditorUtilities.h index a5f129c1b..357c96546 100644 --- a/Source/Editor/Utilities/EditorUtilities.h +++ b/Source/Editor/Utilities/EditorUtilities.h @@ -3,6 +3,7 @@ #pragma once #include "Engine/Core/Common.h" +#include "Engine/Scripting/SoftObjectReference.h" enum class PixelFormat : unsigned; enum class DirectorySearchOption; @@ -34,6 +35,19 @@ public: static bool ExportApplicationImage(const Guid& iconId, int32 width, int32 height, PixelFormat format, const String& path, ApplicationImageType type = ApplicationImageType::Icon); static bool ExportApplicationImage(const TextureData& icon, int32 width, int32 height, PixelFormat format, const String& path); + template + static bool GetApplicationImage(const SoftObjectReference& image, TextureData& imageData, ApplicationImageType type = ApplicationImageType::Icon) + { + const Guid imageId = image.GetID(); + return GetApplicationImage(imageId, imageData, type); + } + template + static bool ExportApplicationImage(const SoftObjectReference& icon, int32 width, int32 height, PixelFormat format, const String& path, ApplicationImageType type = ApplicationImageType::Icon) + { + const Guid iconId = icon.GetID(); + return ExportApplicationImage(iconId, width, height, format, path, type); + } + public: static bool FindWDKBin(String& outputWdkBinPath); diff --git a/Source/Engine/Platform/Android/AndroidPlatformSettings.h b/Source/Engine/Platform/Android/AndroidPlatformSettings.h index 15959bbc5..eeb55ecd4 100644 --- a/Source/Engine/Platform/Android/AndroidPlatformSettings.h +++ b/Source/Engine/Platform/Android/AndroidPlatformSettings.h @@ -5,6 +5,9 @@ #if PLATFORM_ANDROID || USE_EDITOR #include "Engine/Core/Config/PlatformSettingsBase.h" +#include "Engine/Scripting/SoftObjectReference.h" + +class Texture; /// /// Android platform settings. @@ -27,10 +30,10 @@ public: Array Permissions; /// - /// Custom icon texture (asset id) to use for the application (overrides the default one). + /// Custom icon texture to use for the application (overrides the default one). /// - API_FIELD(Attributes="EditorOrder(1030), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Other\")") - Guid OverrideIcon; + API_FIELD(Attributes="EditorOrder(1030), EditorDisplay(\"Other\")") + SoftObjectReference OverrideIcon; public: diff --git a/Source/Engine/Platform/GDK/GDKPlatformSettings.h b/Source/Engine/Platform/GDK/GDKPlatformSettings.h index f64925f58..5fedc7ddb 100644 --- a/Source/Engine/Platform/GDK/GDKPlatformSettings.h +++ b/Source/Engine/Platform/GDK/GDKPlatformSettings.h @@ -6,6 +6,9 @@ #include "Engine/Core/Config/PlatformSettingsBase.h" #include "Engine/Core/Math/Color.h" +#include "Engine/Scripting/SoftObjectReference.h" + +class Texture; /// /// GDK platform settings. @@ -28,34 +31,34 @@ public: String PublisherDisplayName; /// - /// Application small logo texture of size 150x150 px (asset id). + /// Application small logo texture of size 150x150 px. /// - API_FIELD(Attributes="EditorOrder(200), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Visuals\")") - Guid Square150x150Logo; + API_FIELD(Attributes="EditorOrder(200), EditorDisplay(\"Visuals\")") + SoftObjectReference Square150x150Logo; /// - /// Application large logo texture of size 480x480 px (asset id). + /// Application large logo texture of size 480x480 px. /// - API_FIELD(Attributes="EditorOrder(205), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Visuals\")") - Guid Square480x480Logo; + API_FIELD(Attributes="EditorOrder(205), EditorDisplay(\"Visuals\")") + SoftObjectReference Square480x480Logo; /// - /// Application small logo texture of size 44x44 px (asset id). + /// Application small logo texture of size 44x44 px. /// - API_FIELD(Attributes="EditorOrder(210), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Visuals\")") - Guid Square44x44Logo; + API_FIELD(Attributes="EditorOrder(210), EditorDisplay(\"Visuals\")") + SoftObjectReference Square44x44Logo; /// - /// Application splash screen texture (asset id). + /// Application splash screen texture. /// - API_FIELD(Attributes="EditorOrder(220), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Visuals\")") - Guid SplashScreenImage; + API_FIELD(Attributes="EditorOrder(220), EditorDisplay(\"Visuals\")") + SoftObjectReference SplashScreenImage; /// - /// Application store logo texture (asset id). + /// Application store logo texture. /// - API_FIELD(Attributes="EditorOrder(230), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Visuals\")") - Guid StoreLogo; + API_FIELD(Attributes="EditorOrder(230), EditorDisplay(\"Visuals\")") + SoftObjectReference StoreLogo; /// /// Application background color. diff --git a/Source/Engine/Platform/Linux/LinuxPlatformSettings.h b/Source/Engine/Platform/Linux/LinuxPlatformSettings.h index 7da0ec406..406ec3905 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatformSettings.h +++ b/Source/Engine/Platform/Linux/LinuxPlatformSettings.h @@ -5,6 +5,9 @@ #if PLATFORM_LINUX || USE_EDITOR #include "Engine/Core/Config/PlatformSettingsBase.h" +#include "Engine/Scripting/SoftObjectReference.h" + +class Texture; /// /// Linux platform settings. @@ -51,10 +54,10 @@ public: bool ForceSingleInstance = false; /// - /// Custom icon texture (asset id) to use for the application (overrides the default one). + /// Custom icon texture to use for the application (overrides the default one). /// - API_FIELD(Attributes="EditorOrder(1030), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Other\")") - Guid OverrideIcon; + API_FIELD(Attributes="EditorOrder(1030), EditorDisplay(\"Other\")") + SoftObjectReference OverrideIcon; /// /// Enables support for Vulkan. Disabling it reduces compiled shaders count. diff --git a/Source/Engine/Platform/Windows/WindowsPlatformSettings.h b/Source/Engine/Platform/Windows/WindowsPlatformSettings.h index 48a39444a..8fca04611 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatformSettings.h +++ b/Source/Engine/Platform/Windows/WindowsPlatformSettings.h @@ -5,6 +5,9 @@ #if PLATFORM_WINDOWS || USE_EDITOR #include "Engine/Core/Config/PlatformSettingsBase.h" +#include "Engine/Scripting/SoftObjectReference.h" + +class Texture; /// /// Windows platform settings. @@ -51,10 +54,10 @@ public: bool ForceSingleInstance = false; /// - /// Custom icon texture (asset id) to use for the application (overrides the default one). + /// Custom icon texture to use for the application (overrides the default one). /// - API_FIELD(Attributes="EditorOrder(1030), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.AssetRefEditor\"), AssetReference(typeof(Texture)), EditorDisplay(\"Other\")") - Guid OverrideIcon; + API_FIELD(Attributes="EditorOrder(1030), EditorDisplay(\"Other\")") + SoftObjectReference OverrideIcon; /// /// Enables support for DirectX 12. Disabling it reduces compiled shaders count.