From 8776a9fa9f6f328d54061e205f25b6b32ce3d7df Mon Sep 17 00:00:00 2001 From: wixoa Date: Thu, 28 Sep 2023 12:30:14 -0400 Subject: [PATCH] Add support for `zoom-mode` on map controls (#1473) --- OpenDreamClient/Interface/Controls/ControlMap.cs | 15 +++++++++++++++ .../Interface/Descriptors/ControlDescriptors.cs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/OpenDreamClient/Interface/Controls/ControlMap.cs b/OpenDreamClient/Interface/Controls/ControlMap.cs index c163b1d364..4d9ba1d91a 100644 --- a/OpenDreamClient/Interface/Controls/ControlMap.cs +++ b/OpenDreamClient/Interface/Controls/ControlMap.cs @@ -16,6 +16,21 @@ public sealed class ControlMap : InterfaceControl { public ControlMap(ControlDescriptor controlDescriptor, ControlWindow window) : base(controlDescriptor, window) { } + protected override void UpdateElementDescriptor() { + base.UpdateElementDescriptor(); + + ControlDescriptorMap mapDescriptor = (ControlDescriptorMap)ElementDescriptor; + + Viewport.StretchMode = mapDescriptor.ZoomMode switch { + "blur" => ScalingViewportStretchMode.Bilinear, + "distort" => ScalingViewportStretchMode.Nearest, + + // TODO: "tries to keep the look of individual pixels, + // but will adjust to non-integer zooms (like 1.1x) by blending neighboring pixels" + "normal" or _ => ScalingViewportStretchMode.Nearest + }; + } + public void UpdateViewRange(ViewRange view) { Viewport.ViewportSize = (Math.Max(view.Width, 1) * 32, Math.Max(view.Height, 1) * 32); } diff --git a/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs b/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs index 748150c46d..147aaa40ea 100644 --- a/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs +++ b/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs @@ -138,6 +138,8 @@ public sealed partial class ControlDescriptorInfo : ControlDescriptor { } public sealed partial class ControlDescriptorMap : ControlDescriptor { + [DataField("zoom-mode")] + public string ZoomMode = "normal"; } public sealed partial class ControlDescriptorBrowser : ControlDescriptor {