Merge pull request #389 from YonKuma/suppressmouse
add code to suppress mouse clicks
This commit is contained in:
commit
c0c65ec6dd
|
@ -56,11 +56,11 @@ namespace StardewModdingAPI.Events
|
||||||
public void SuppressButton(SButton button)
|
public void SuppressButton(SButton button)
|
||||||
{
|
{
|
||||||
// keyboard
|
// keyboard
|
||||||
if (this.Button.TryGetKeyboard(out Keys key))
|
if (button.TryGetKeyboard(out Keys key))
|
||||||
Game1.oldKBState = new KeyboardState(Game1.oldKBState.GetPressedKeys().Union(new[] { key }).ToArray());
|
Game1.oldKBState = new KeyboardState(Game1.oldKBState.GetPressedKeys().Union(new[] { key }).ToArray());
|
||||||
|
|
||||||
// controller
|
// controller
|
||||||
else if (this.Button.TryGetController(out Buttons controllerButton))
|
else if (button.TryGetController(out Buttons controllerButton))
|
||||||
{
|
{
|
||||||
var newState = GamePad.GetState(PlayerIndex.One);
|
var newState = GamePad.GetState(PlayerIndex.One);
|
||||||
var thumbsticks = Game1.oldPadState.ThumbSticks;
|
var thumbsticks = Game1.oldPadState.ThumbSticks;
|
||||||
|
@ -127,6 +127,34 @@ namespace StardewModdingAPI.Events
|
||||||
|
|
||||||
Game1.oldPadState = new GamePadState(thumbsticks, triggers, buttons, dpad);
|
Game1.oldPadState = new GamePadState(thumbsticks, triggers, buttons, dpad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mouse
|
||||||
|
else if (button == SButton.MouseLeft)
|
||||||
|
{
|
||||||
|
Game1.oldMouseState = new MouseState(
|
||||||
|
Game1.oldMouseState.X,
|
||||||
|
Game1.oldMouseState.Y,
|
||||||
|
Game1.oldMouseState.ScrollWheelValue,
|
||||||
|
ButtonState.Pressed,
|
||||||
|
Game1.oldMouseState.MiddleButton,
|
||||||
|
Game1.oldMouseState.RightButton,
|
||||||
|
Game1.oldMouseState.XButton1,
|
||||||
|
Game1.oldMouseState.XButton2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (button == SButton.MouseRight)
|
||||||
|
{
|
||||||
|
Game1.oldMouseState = new MouseState(
|
||||||
|
Game1.oldMouseState.X,
|
||||||
|
Game1.oldMouseState.Y,
|
||||||
|
Game1.oldMouseState.ScrollWheelValue,
|
||||||
|
Game1.oldMouseState.LeftButton,
|
||||||
|
Game1.oldMouseState.MiddleButton,
|
||||||
|
ButtonState.Pressed,
|
||||||
|
Game1.oldMouseState.XButton1,
|
||||||
|
Game1.oldMouseState.XButton2
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue