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

feat: adapt ca85609 from MAO for the base engine #2612

Merged
merged 4 commits into from
Feb 22, 2025

Conversation

TimtyG
Copy link
Contributor

@TimtyG TimtyG commented Feb 22, 2025

This PR introduces mouse scroll functionality for zooming in and out of the game world.

Copy link
Member

@lodicolo lodicolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies to multiple files (SettingsWindow, Strings, GameDatabase):

It would be preferable if on UI controls/preferences that this property is consistently after or before the original property/configuration name to keep parts of the same feature together.

{
Globals.Database.WorldZoom = Graphics.MinimumWorldScale;
if (wrap)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine the 2 if statements

Comment on lines 62 to 64
Globals.Database.WorldZoom = Graphics.MinimumWorldScale;
}
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set nextZoom instead, and don't return

Comment on lines 45 to 49
if (wrap)
{
Globals.Database.WorldZoom = Graphics.MaximumWorldScale;
}
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as in HandleZoomIn

{
Core.Input.HandleZoomOut(false);
}
_lastZoomTime = DateTime.Now;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache DateTime.Now in a local variable instead of calling it twice


{

if ((InputHandler.HoveredControl == null || !InputHandler.HoveredControl.IsVisibleInTree)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this block scrolling on the canvas?

Shouldn't this or group include (InputHandler.HoveredControl is Canvas canvas && canvas == canvas.Canvas)?

@@ -2089,6 +2089,9 @@ public partial struct Settings
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString EnableLighting = @"Enable Light Effects";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString EnableMouseScrollZoom = @"Enable Mouse Scroll Zoom";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be Enable scrolling to change World Scale in game so that it's clear that it's the same feature

@@ -158,6 +161,7 @@ public virtual void SavePreferences()
SavePreference(nameof(FullScreen), FullScreen);
SavePreference(nameof(ShowFPSCounter), ShowFPSCounter);
SavePreference(nameof(EnableLighting), EnableLighting);
SavePreference(nameof(EnableMouseScrollZoom), EnableMouseScrollZoom);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be named EnableScrollingWorldZoom to match the original feature's preference name

@@ -237,6 +237,9 @@ private void CheckMouseButton(Keys modifier, ButtonState bs, MouseButton mb)
}
}

private const double ZoomDelayInMilliseconds = 300;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to private static readonly TimeSpan ZoomDelay = TimeSpan.FromMilliseconds(300);

var deltaV = Math.Sign(mMouseVScroll - scrlVValue);

var now = DateTime.Now;
if ((now - _lastZoomTime).TotalMilliseconds >= ZoomDelayInMilliseconds)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the above change this becomes now - _lastZoomTime >= ZoomDelay

Comment on lines 268 to 275
if (deltaV < 0)
{
Core.Input.HandleZoomIn(false);
}
else
{
Core.Input.HandleZoomOut(false);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these lines missing an indent or is this just the GitHub UI displaying it incorrectly?

@lodicolo lodicolo merged commit 25cedf3 into AscensionGameDev:main Feb 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants