From 88eca13eb3539aa43e0bc2863f2f2fb3250d4188 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 12 Oct 2023 22:28:40 +0200 Subject: [PATCH] Add default font bundling (optional) and setup UI Style to match editor logic #641 --- Source/Editor/Cooker/Steps/DeployDataStep.cpp | 2 +- Source/Editor/Options/OptionsModule.cs | 6 ++--- Source/Engine/Core/Config/BuildSettings.h | 24 ++++++------------- Source/Engine/Scripting/Scripting.cs | 21 ++++++++++++---- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Source/Editor/Cooker/Steps/DeployDataStep.cpp b/Source/Editor/Cooker/Steps/DeployDataStep.cpp index c9bbc016e..727363846 100644 --- a/Source/Editor/Cooker/Steps/DeployDataStep.cpp +++ b/Source/Editor/Cooker/Steps/DeployDataStep.cpp @@ -360,7 +360,7 @@ bool DeployDataStep::Perform(CookingData& data) data.AddRootEngineAsset(PRE_INTEGRATED_GF_ASSET_NAME); data.AddRootEngineAsset(SMAA_AREA_TEX); data.AddRootEngineAsset(SMAA_SEARCH_TEX); - if (data.Configuration != BuildConfiguration::Release) + if (!buildSettings.SkipDefaultFonts) data.AddRootEngineAsset(TEXT("Editor/Fonts/Roboto-Regular")); // Register custom assets (eg. plugins) diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index c2d744239..07e899c5e 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -244,11 +244,11 @@ namespace FlaxEditor.Options CollectionBackgroundColor = Color.FromBgra(0x14CCCCCC), ProgressNormal = Color.FromBgra(0xFF0ad328), - Statusbar = new Style.StatusbarStyle() + Statusbar = new Style.StatusbarStyle { PlayMode = Color.FromBgra(0xFF2F9135), Failed = Color.FromBgra(0xFF9C2424), - Loading = Color.FromBgra(0xFF2D2D30) + Loading = Color.FromBgra(0xFF2D2D30), }, // Fonts @@ -271,7 +271,7 @@ namespace FlaxEditor.Options Scale = Editor.Icons.Scale32, Scalar = Editor.Icons.Scalar32, - SharedTooltip = new Tooltip() + SharedTooltip = new Tooltip(), }; style.DragWindow = style.BackgroundSelected * 0.7f; diff --git a/Source/Engine/Core/Config/BuildSettings.h b/Source/Engine/Core/Config/BuildSettings.h index 318c304e0..d6cef8c89 100644 --- a/Source/Engine/Core/Config/BuildSettings.h +++ b/Source/Engine/Core/Config/BuildSettings.h @@ -3,7 +3,6 @@ #pragma once #include "Engine/Core/Config/Settings.h" -#include "Engine/Serialization/Serialization.h" #include "Engine/Content/Asset.h" #include "Engine/Content/AssetReference.h" #include "Engine/Content/SceneReference.h" @@ -14,6 +13,7 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API BuildSettings : public SettingsBase { DECLARE_SCRIPTING_TYPE_MINIMAL(BuildSettings); + API_AUTO_SERIALIZATION(); public: /// @@ -76,6 +76,12 @@ public: API_FIELD(Attributes="EditorOrder(2010), EditorDisplay(\"Content\")") bool ShadersGenerateDebugData = false; + /// + /// If checked, skips bundling default engine fonts for UI. Use if to reduce build size if you don't use default engine fonts but custom ones only. + /// + API_FIELD(Attributes="EditorOrder(2100), EditorDisplay(\"Content\")") + bool SkipDefaultFonts = false; + /// /// If checked, .NET Runtime won't be packaged with a game and will be required by user to be installed on system upon running game build. Available only on supported platforms such as Windows, Linux and macOS. /// @@ -93,20 +99,4 @@ public: /// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use. /// static BuildSettings* Get(); - - // [SettingsBase] - void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override - { - DESERIALIZE(MaxAssetsPerPackage); - DESERIALIZE(MaxPackageSizeMB); - DESERIALIZE(ContentKey); - DESERIALIZE(ForDistribution); - DESERIALIZE(SkipPackaging); - DESERIALIZE(AdditionalAssets); - DESERIALIZE(AdditionalAssetFolders); - DESERIALIZE(ShadersNoOptimize); - DESERIALIZE(ShadersGenerateDebugData); - DESERIALIZE(SkipDotnetPackaging); - DESERIALIZE(SkipUnusedDotnetLibsPackaging); - } }; diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs index 8347fe7f8..67ba854e0 100644 --- a/Source/Engine/Scripting/Scripting.cs +++ b/Source/Engine/Scripting/Scripting.cs @@ -278,19 +278,30 @@ namespace FlaxEngine BackgroundNormal = Color.FromBgra(0xFF3F3F46), BorderNormal = Color.FromBgra(0xFF54545C), TextBoxBackground = Color.FromBgra(0xFF333337), - ProgressNormal = Color.FromBgra(0xFF0ad328), TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46), CollectionBackgroundColor = Color.FromBgra(0x14CCCCCC), - SharedTooltip = new Tooltip(), - Statusbar = new Style.StatusbarStyle() + ProgressNormal = Color.FromBgra(0xFF0ad328), + Statusbar = new Style.StatusbarStyle { PlayMode = Color.FromBgra(0xFF2F9135), Failed = Color.FromBgra(0xFF9C2424), - Loading = Color.FromBgra(0xFF2D2D30) - } + Loading = Color.FromBgra(0xFF2D2D30), + }, + + SharedTooltip = new Tooltip(), }; style.DragWindow = style.BackgroundSelected * 0.7f; + // Use optionally bundled default font (matches Editor) + var defaultFont = Content.LoadAsyncInternal("Editor/Fonts/Roboto-Regular"); + if (defaultFont) + { + style.FontTitle = defaultFont.CreateFont(18); + style.FontLarge = defaultFont.CreateFont(14); + style.FontMedium = defaultFont.CreateFont(9); + style.FontSmall = defaultFont.CreateFont(9); + } + Style.Current = style; }