Skip to content

Commit

Permalink
Option for legacy mouse scroll behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Feb 19, 2024
1 parent fa3729e commit b11317c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CentrED/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class ConfigRoot
public string ActiveProfile = "";
public string ServerConfigPath = "cedserver.xml";
public bool PreferTexMaps;
public bool LegacyMouseScroll;
public Dictionary<string, WindowState> Layout = new();
}

Expand Down
11 changes: 9 additions & 2 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,20 @@ public void Update(GameTime gameTime, bool isActive, bool processMouse, bool pro
return;
Metrics.Start("UpdateMap");
var mouseState = Mouse.GetState();
var keyState = Keyboard.GetState();
if (isActive && processMouse)
{
if (mouseState.ScrollWheelValue != _prevMouseState.ScrollWheelValue)
{
var delta = (mouseState.ScrollWheelValue - _prevMouseState.ScrollWheelValue) / 1200f;
Camera.ZoomIn(delta);
if(Config.Instance.LegacyMouseScroll ^ (keyState.IsKeyDown(Keys.LeftControl) || keyState.IsKeyDown(Keys.RightControl)))
{
if (Selected != null)
Selected.Tile.Z += (sbyte)(delta * 10);
}
else {
Camera.ZoomIn(delta);
}
}
if (mouseState.RightButton == ButtonState.Pressed)
{
Expand Down Expand Up @@ -494,7 +502,6 @@ public void Update(GameTime gameTime, bool isActive, bool processMouse, bool pro

if (isActive && processKeyboard)
{
var keyState = Keyboard.GetState();
var delta = keyState.IsKeyDown(Keys.LeftShift) ? 30 : 10;

foreach (var key in keyState.GetPressedKeys())
Expand Down
2 changes: 2 additions & 0 deletions CentrED/UI/Windows/OptionsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ protected override void InternalDraw()
{
CEDGame.MapManager.Reset();
}
ImGui.Checkbox("Legacy mouse scroll behavior", ref Config.Instance.LegacyMouseScroll);
UIManager.Tooltip("Mouse scroll up/down: elevate tile\nCtrl + Mouse scroll up/down: Zoom in/out");
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Virtual Layer"))
Expand Down

0 comments on commit b11317c

Please sign in to comment.