Skip to content

Commit

Permalink
Add support for zoom-mode on map controls
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Sep 27, 2023
1 parent 16f26ce commit 78f3731
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions OpenDreamClient/Interface/Controls/ControlMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 78f3731

Please sign in to comment.