1.Compatibility fix
2.Fix potential error on rewriter. 3.Update virtual keyboard for upcoming SMAPI3.4 feature
This commit is contained in:
parent
f217392dab
commit
4c6fd76f0b
|
@ -58,12 +58,6 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
|
||||
object score = this.GetSCore(this.helper);
|
||||
object eventManager = score.GetType().GetField("EventManager", BindingFlags.Public | BindingFlags.Instance).GetValue(score);
|
||||
|
||||
this.buttonPressed = eventManager.GetType().GetField("ButtonPressed", BindingFlags.Public | BindingFlags.Instance).GetValue(eventManager);
|
||||
this.buttonReleased = eventManager.GetType().GetField("ButtonReleased", BindingFlags.Public | BindingFlags.Instance).GetValue(eventManager);
|
||||
|
||||
this.RaiseButtonPressed = this.buttonPressed.GetType().GetMethod("Raise", BindingFlags.Public | BindingFlags.Instance);
|
||||
this.RaiseButtonReleased = this.buttonReleased.GetType().GetMethod("Raise", BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
private object GetSCore(IModHelper helper)
|
||||
|
@ -73,9 +67,9 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
return score;
|
||||
}
|
||||
|
||||
private bool shouldTrigger(Vector2 screenPixels)
|
||||
private bool shouldTrigger(Vector2 screenPixels, SButton button)
|
||||
{
|
||||
if (this.buttonRectangle.Contains(screenPixels.X * Game1.options.zoomLevel, screenPixels.Y * Game1.options.zoomLevel) && !this.hidden)
|
||||
if (this.buttonRectangle.Contains(screenPixels.X * Game1.options.zoomLevel, screenPixels.Y * Game1.options.zoomLevel) && !this.hidden && button == SButton.MouseLeft)
|
||||
{
|
||||
if (!this.hidden)
|
||||
Toolbar.toolbarPressed = true;
|
||||
|
@ -92,21 +86,12 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
}
|
||||
|
||||
Vector2 screenPixels = e.Cursor.ScreenPixels;
|
||||
if (this.shouldTrigger(screenPixels))
|
||||
if (this.shouldTrigger(screenPixels, e.Button))
|
||||
{
|
||||
object inputState = e.GetType().GetField("InputState", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(e);
|
||||
|
||||
object buttonPressedEventArgs = Activator.CreateInstance(typeof(ButtonPressedEventArgs), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { this.buttonKey, e.Cursor, inputState }, null);
|
||||
try
|
||||
{
|
||||
this.raisingPressed = true;
|
||||
|
||||
this.RaiseButtonPressed.Invoke(this.buttonPressed, new object[] { buttonPressedEventArgs });
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.raisingPressed = false;
|
||||
}
|
||||
object input = this.helper.Reflection.GetField<object>(typeof(Game1), "input").GetValue();
|
||||
this.raisingPressed = true;
|
||||
input.GetType().GetMethod("OverrideButton").Invoke(input, new object[] { this.buttonKey, true });
|
||||
this.raisingPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +103,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
}
|
||||
|
||||
Vector2 screenPixels = e.Cursor.ScreenPixels;
|
||||
if (this.shouldTrigger(screenPixels))
|
||||
if (this.shouldTrigger(screenPixels, e.Button))
|
||||
{
|
||||
if (this.buttonKey == SButton.RightWindows)
|
||||
{
|
||||
|
@ -143,17 +128,10 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
this.SendCommand(this.command);
|
||||
return;
|
||||
}
|
||||
object inputState = e.GetType().GetField("InputState", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(e);
|
||||
object buttonReleasedEventArgs = Activator.CreateInstance(typeof(ButtonReleasedEventArgs), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { this.buttonKey, e.Cursor, inputState }, null);
|
||||
try
|
||||
{
|
||||
this.raisingReleased = true;
|
||||
this.RaiseButtonReleased.Invoke(this.buttonReleased, new object[] { buttonReleasedEventArgs });
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.raisingReleased = false;
|
||||
}
|
||||
object input = this.helper.Reflection.GetField<object>(typeof(Game1), "input").GetValue();
|
||||
this.raisingReleased = true;
|
||||
input.GetType().GetMethod("OverrideButton").Invoke(input, new object[] { this.buttonKey, false });
|
||||
this.raisingReleased = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace StardewModdingAPI
|
|||
** Public
|
||||
****/
|
||||
/// <summary>SMAPI's current semantic version.</summary>
|
||||
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.3.2.0", allowNonStandard: true);
|
||||
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.3.2.1", allowNonStandard: true);
|
||||
|
||||
/// <summary>The minimum supported version of Stardew Valley.</summary>
|
||||
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.5");
|
||||
|
|
|
@ -81,5 +81,16 @@ namespace StardewModdingAPI.Framework.RewriteFacades
|
|||
{
|
||||
panScreen(x, y, 0);
|
||||
}
|
||||
|
||||
public static void removeSquareDebrisFromTile(int tileX, int tileY)
|
||||
{
|
||||
Game1.currentLocation.debris.debrisNetCollection.Filter(debris => {
|
||||
if ((debris.debrisType == 2) && (((int)(debris.Chunks[0].position.X / 64f)) == tileX))
|
||||
{
|
||||
return (debris.chunkFinalYLevel / 0x40) != tileY;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,19 +36,26 @@ namespace StardewModdingAPI.Framework.RewriteFacades
|
|||
[SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Windows.")]
|
||||
public new void drawHorizontalPartition(SpriteBatch b, int yPosition, bool small = false, int red = -1, int green = -1, int blue = -1)
|
||||
{
|
||||
this.drawMobileHorizontalPartition(b, 0, yPosition, 64, small);
|
||||
base.drawMobileHorizontalPartition(b, 0, yPosition, 64, small);
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Windows.")]
|
||||
public new void drawVerticalUpperIntersectingPartition(SpriteBatch b, int xPosition, int partitionHeight, int red = -1, int green = -1, int blue = -1)
|
||||
{
|
||||
this.drawVerticalUpperIntersectingPartition(b, xPosition, partitionHeight);
|
||||
base.drawVerticalUpperIntersectingPartition(b, xPosition, partitionHeight);
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Windows.")]
|
||||
public new void drawVerticalIntersectingPartition(SpriteBatch b, int xPosition, int yPosition, int red = -1, int green = -1, int blue = -1)
|
||||
{
|
||||
this.drawVerticalIntersectingPartition(b, xPosition, yPosition);
|
||||
base.drawVerticalIntersectingPartition(b, xPosition, yPosition);
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Windows.")]
|
||||
public new void drawVerticalPartition(SpriteBatch b, int xPosition, bool small = false, int red = -1, int green = -1, int blue = -1)
|
||||
{
|
||||
base.drawVerticalPartition(b, xPosition, small);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue