Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for zoom-mode on map controls #1473

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading