summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Input/MouseStateBuilder.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-09-07 13:06:27 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-09-07 13:06:27 -0400
commit5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83 (patch)
tree0a42305174eb84561a584549cd685c5e95670f36 /src/SMAPI/Framework/Input/MouseStateBuilder.cs
parent8da88b8fe5b41739c5cd0df3280b9770fc7f10a4 (diff)
parentf9fac11028354f15d786d5b854608edb10716f79 (diff)
downloadSMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.gz
SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.bz2
SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Input/MouseStateBuilder.cs')
-rw-r--r--src/SMAPI/Framework/Input/MouseStateBuilder.cs39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/SMAPI/Framework/Input/MouseStateBuilder.cs b/src/SMAPI/Framework/Input/MouseStateBuilder.cs
index 1cc16ca9..a1ac5492 100644
--- a/src/SMAPI/Framework/Input/MouseStateBuilder.cs
+++ b/src/SMAPI/Framework/Input/MouseStateBuilder.cs
@@ -13,51 +13,42 @@ namespace StardewModdingAPI.Framework.Input
private MouseState? State;
/// <summary>The current button states.</summary>
- private IDictionary<SButton, ButtonState> ButtonStates;
+ private readonly IDictionary<SButton, ButtonState> ButtonStates;
/// <summary>The mouse wheel scroll value.</summary>
- private int ScrollWheelValue;
+ private readonly int ScrollWheelValue;
/*********
** Accessors
*********/
/// <summary>The X cursor position.</summary>
- public int X { get; private set; }
+ public int X { get; }
/// <summary>The Y cursor position.</summary>
- public int Y { get; private set; }
+ public int Y { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- /// <param name="state">The initial state, or <c>null</c> to get the latest state.</param>
- public MouseStateBuilder(MouseState? state = null)
+ /// <param name="state">The initial state.</param>
+ public MouseStateBuilder(MouseState state)
{
- this.Reset(state);
- }
-
- /// <summary>Reset the tracked state.</summary>
- /// <param name="state">The state from which to reset, or <c>null</c> to get the latest state.</param>
- public MouseStateBuilder Reset(MouseState? state = null)
- {
- this.State = state ??= Mouse.GetState();
+ this.State = state;
this.ButtonStates = new Dictionary<SButton, ButtonState>
{
- [SButton.MouseLeft] = state.Value.LeftButton,
- [SButton.MouseMiddle] = state.Value.MiddleButton,
- [SButton.MouseRight] = state.Value.RightButton,
- [SButton.MouseX1] = state.Value.XButton1,
- [SButton.MouseX2] = state.Value.XButton2
+ [SButton.MouseLeft] = state.LeftButton,
+ [SButton.MouseMiddle] = state.MiddleButton,
+ [SButton.MouseRight] = state.RightButton,
+ [SButton.MouseX1] = state.XButton1,
+ [SButton.MouseX2] = state.XButton2
};
- this.X = state.Value.X;
- this.Y = state.Value.Y;
- this.ScrollWheelValue = state.Value.ScrollWheelValue;
-
- return this;
+ this.X = state.X;
+ this.Y = state.Y;
+ this.ScrollWheelValue = state.ScrollWheelValue;
}
/// <summary>Override the states for a set of buttons.</summary>