From 40c728269c786ac4841af5dd57fa179becb9040a Mon Sep 17 00:00:00 2001 From: penev92 Date: Sun, 7 Feb 2021 19:44:25 +0200 Subject: [PATCH] Added a scale slider for models in the AssetBrowser --- .../Widgets/Logic/AssetBrowserLogic.cs | 10 ++++++++++ OpenRA.Mods.Common/Widgets/ModelWidget.cs | 2 +- mods/common/chrome/assetbrowser.yaml | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index e2522b87a0..8dcf2fd52a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -53,6 +53,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic bool isLoadError = false; int currentFrame; WRot modelOrientation; + float modelScale; [ObjectCreator.UseCtor] public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, WorldRenderer worldRenderer) @@ -106,10 +107,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic { modelWidget.GetVoxel = () => currentVoxel; currentPalette = modelWidget.Palette; + modelScale = modelWidget.Scale; modelWidget.GetPalette = () => currentPalette; modelWidget.GetPlayerPalette = () => currentPalette; modelWidget.GetRotation = () => modelOrientation; modelWidget.IsVisible = () => !isVideoLoaded && !isLoadError && currentVoxel != null; + modelWidget.GetScale = () => modelScale; } var errorLabelWidget = panel.GetOrNull("ERROR"); @@ -285,6 +288,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic yawSlider.GetValue = () => modelOrientation.Yaw.Angle; } + var modelScaleSlider = panel.GetOrNull("MODEL_SCALE_SLIDER"); + if (modelScaleSlider != null) + { + modelScaleSlider.OnChange += x => modelScale = x; + modelScaleSlider.GetValue = () => modelScale; + } + var assetBrowserModData = modData.Manifest.Get(); allowedSpriteExtensions = assetBrowserModData.SpriteExtensions; allowedModelExtensions = assetBrowserModData.ModelExtensions; diff --git a/OpenRA.Mods.Common/Widgets/ModelWidget.cs b/OpenRA.Mods.Common/Widgets/ModelWidget.cs index 1ae691478c..69662e4e54 100644 --- a/OpenRA.Mods.Common/Widgets/ModelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ModelWidget.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets public string PlayerPalette = "player"; public string NormalsPalette = "normals"; public string ShadowPalette = "shadow"; - public float Scale = 12f; + public float Scale = 10f; public int LightPitch = 142; public int LightYaw = 682; public float[] LightAmbientColor = new float[] { 0.6f, 0.6f, 0.6f }; diff --git a/mods/common/chrome/assetbrowser.yaml b/mods/common/chrome/assetbrowser.yaml index 3dba0dd42f..8d4917c300 100644 --- a/mods/common/chrome/assetbrowser.yaml +++ b/mods/common/chrome/assetbrowser.yaml @@ -233,6 +233,21 @@ Background@ASSETBROWSER_PANEL: Height: 20 MinimumValue: 1 MaximumValue: 1023 + Label@MODEL_SCALE: + X: 150 + Y: 30 + Width: 40 + Height: 25 + Font: TinyBold + Align: Left + Text: Scale + Slider@MODEL_SCALE_SLIDER: + X: 190 + Y: 32 + Width: 100 + Height: 20 + MinimumValue: 10 + MaximumValue: 64 Button@CLOSE_BUTTON: Key: escape X: PARENT_RIGHT - 180