1.Merge latest master change.
2.Fix Rendered event logic 3.Improvement of VirtualKeyboard
This commit is contained in:
parent
27423f0468
commit
47b5a24345
|
@ -7,6 +7,8 @@ using StardewValley.Menus;
|
|||
using System.Reflection;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using static StardewModdingAPI.Mods.VirtualKeyboard.ModConfig;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||
{
|
||||
|
@ -48,7 +50,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
}
|
||||
this.transparency = buttonDefine.transparency;
|
||||
|
||||
helper.Events.Display.RenderingHud += this.OnRenderingHud;
|
||||
helper.Events.Display.Rendered += this.OnRendered;
|
||||
helper.Events.Input.ButtonReleased += this.EventInputButtonReleased;
|
||||
helper.Events.Input.ButtonPressed += this.EventInputButtonPressed;
|
||||
|
||||
|
@ -118,22 +120,18 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
{
|
||||
if (this.buttonKey == SButton.RightWindows)
|
||||
{
|
||||
Game1.activeClickableMenu = new NamingMenu(command =>
|
||||
{
|
||||
KeyboardInput.Show("Command", "", "", false).ContinueWith<string>(delegate (Task<string> s) {
|
||||
string command;
|
||||
command = s.Result;
|
||||
if (command.Length > 0)
|
||||
{
|
||||
object score = this.GetSCore(this.helper);
|
||||
object sgame = score.GetType().GetField("GameInstance", BindingFlags.Public | BindingFlags.Instance)?.GetValue(score);
|
||||
ConcurrentQueue<string> commandQueue = sgame.GetType().GetProperty("CommandQueue", BindingFlags.Public | BindingFlags.Instance)?.GetValue(sgame) as ConcurrentQueue<string>;
|
||||
commandQueue?.Enqueue(command);
|
||||
Game1.activeClickableMenu.exitThisMenu();
|
||||
}
|
||||
|
||||
}, "Command", "")
|
||||
{
|
||||
randomButton = new ClickableTextureComponent(new Rectangle(-100, -100, 0, 0),
|
||||
Game1.mobileSpriteSheet, new Rectangle(87, 22, 20, 20), 4f, false)
|
||||
};
|
||||
return command;
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.buttonKey == SButton.RightControl)
|
||||
|
@ -158,7 +156,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
/// <summary>Raised before drawing the HUD (item toolbar, clock, etc) to the screen.</summary>
|
||||
/// <param name="sender">The event sender.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
private void OnRenderingHud(object sender, EventArgs e)
|
||||
private void OnRendered(object sender, EventArgs e)
|
||||
{
|
||||
if (!this.hidden)
|
||||
{
|
||||
|
@ -167,7 +165,22 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
{
|
||||
scale *= 0.5f;
|
||||
}
|
||||
IClickableMenu.drawButtonWithText(Game1.spriteBatch, Game1.smallFont, this.alias, this.buttonRectangle.X, this.buttonRectangle.Y, this.buttonRectangle.Width, this.buttonRectangle.Height, Color.BurlyWood * scale);
|
||||
System.Reflection.FieldInfo matrixField = Game1.spriteBatch.GetType().GetField("_matrix", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
object originMatrix = matrixField.GetValue(Game1.spriteBatch);
|
||||
Game1.spriteBatch.End();
|
||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Microsoft.Xna.Framework.Matrix.CreateScale(1f));
|
||||
IClickableMenu.drawTextureBoxWithIconAndText(Game1.spriteBatch, Game1.smallFont, Game1.mouseCursors, new Rectangle(0x100, 0x100, 10, 10), null, new Rectangle(0, 0, 1, 1),
|
||||
this.alias, this.buttonRectangle.X, this.buttonRectangle.Y, this.buttonRectangle.Width, this.buttonRectangle.Height, Color.BurlyWood * scale, 4f,
|
||||
true, false, true, false, false, false, false); // Remove bold to fix the text position issue
|
||||
Game1.spriteBatch.End();
|
||||
if(originMatrix != null)
|
||||
{
|
||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, (Matrix)originMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
{
|
||||
public Toggle vToggle = new Toggle(new Rect(36, 12, 64, 64));
|
||||
public VirtualButton[] buttons { get; set;} = new VirtualButton[] {
|
||||
new VirtualButton(SButton.Q, new Rect(192, 80, 90, 90), 0.5f),
|
||||
new VirtualButton(SButton.I, new Rect(288, 80, 90, 90), 0.5f),
|
||||
new VirtualButton(SButton.O, new Rect(384, 80, 90, 90), 0.5f),
|
||||
new VirtualButton(SButton.P, new Rect(480, 80, 90, 90), 0.5f)
|
||||
new VirtualButton(SButton.Q, new Rect(190, 80, 90, 90), 0.5f),
|
||||
new VirtualButton(SButton.I, new Rect(290, 80, 90, 90), 0.5f),
|
||||
new VirtualButton(SButton.O, new Rect(390, 80, 90, 90), 0.5f),
|
||||
new VirtualButton(SButton.P, new Rect(490, 80, 90, 90), 0.5f)
|
||||
};
|
||||
public VirtualButton[] buttonsExtend { get; set; } = new VirtualButton[] {
|
||||
new VirtualButton(SButton.MouseRight, new Rect(192, 170, 162, 90), 0.5f, "RightMouse"),
|
||||
new VirtualButton(SButton.RightWindows, new Rect(362, 170, 162, 90), 0.5f, "Command"),
|
||||
new VirtualButton(SButton.RightControl, new Rect(532, 170, 162, 90), 0.5f, "Console")
|
||||
new VirtualButton(SButton.MouseRight, new Rect(190, 170, 162, 90), 0.5f, "RightMouse"),
|
||||
new VirtualButton(SButton.RightWindows, new Rect(360, 170, 162, 90), 0.5f, "Command"),
|
||||
new VirtualButton(SButton.RightControl, new Rect(530, 170, 162, 90), 0.5f, "Console")
|
||||
};
|
||||
internal class VirtualButton {
|
||||
public SButton key;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
this.virtualToggleButton = new ClickableTextureComponent(new Rectangle(Game1.toolbarPaddingX + 64, 12, 128, 128), this.texture, new Rectangle(0, 0, 16, 16), 5.75f, false);
|
||||
helper.WriteConfig(this.modConfig);
|
||||
|
||||
this.helper.Events.Display.RenderingHud += this.OnRenderingHUD;
|
||||
this.helper.Events.Display.Rendered += this.OnRendered;
|
||||
this.helper.Events.Input.ButtonPressed += this.VirtualToggleButtonPressed;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
return false;
|
||||
}
|
||||
|
||||
private void OnRenderingHUD(object sender, EventArgs e)
|
||||
private void OnRendered(object sender, EventArgs e)
|
||||
{
|
||||
if (this.isDefault)
|
||||
{
|
||||
|
@ -131,7 +131,21 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
|||
}
|
||||
if (!Game1.eventUp && Game1.activeClickableMenu is GameMenu == false && Game1.activeClickableMenu is ShopMenu == false)
|
||||
scale = 0.25f;
|
||||
|
||||
System.Reflection.FieldInfo matrixField = Game1.spriteBatch.GetType().GetField("_matrix", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
object originMatrix = matrixField.GetValue(Game1.spriteBatch);
|
||||
Game1.spriteBatch.End();
|
||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Microsoft.Xna.Framework.Matrix.CreateScale(1f));
|
||||
this.virtualToggleButton.draw(Game1.spriteBatch, Color.White * scale, 0.000001f);
|
||||
Game1.spriteBatch.End();
|
||||
if (originMatrix != null)
|
||||
{
|
||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, (Matrix)originMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace StardewModdingAPI
|
|||
** Public
|
||||
****/
|
||||
/// <summary>SMAPI's current semantic version.</summary>
|
||||
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.2.0.3", allowNonStandard: true);
|
||||
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.3.0.1", allowNonStandard: true);
|
||||
|
||||
/// <summary>The minimum supported version of Stardew Valley.</summary>
|
||||
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.1");
|
||||
|
|
|
@ -1887,7 +1887,6 @@ label_168:
|
|||
string s = content.LoadString("Strings\\StringsFromCSFiles:DayTimeMoneyBox.cs.10378");
|
||||
SpriteText.drawStringWithScrollBackground(spriteBatch, s, 96, 32);
|
||||
}
|
||||
events.Rendered.RaiseEmpty();
|
||||
_spriteBatchEnd.Invoke();
|
||||
this.drawOverlays(spriteBatch);
|
||||
this.renderScreenBuffer(BlendState.Opaque, toBuffer);
|
||||
|
@ -1927,10 +1926,19 @@ label_168:
|
|||
DrawDialogueBoxForPinchZoom.Invoke();
|
||||
DrawUnscaledActiveClickableMenuForPinchZoom.Invoke();
|
||||
DrawNativeScaledActiveClickableMenuForPinchZoom.Invoke();
|
||||
if(IsActiveClickableMenuNativeScaled)
|
||||
SpriteBatchBegin.Invoke(NativeZoomLevel);
|
||||
else
|
||||
SpriteBatchBegin.Invoke(1f);
|
||||
events.Rendered.RaiseEmpty();
|
||||
_spriteBatchEnd.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpriteBatchBegin.Invoke(1f);
|
||||
events.Rendered.RaiseEmpty();
|
||||
_spriteBatchEnd.Invoke();
|
||||
}
|
||||
SpriteBatchBegin.Invoke(Game1.options.zoomLevel);
|
||||
events.Rendered.RaiseEmpty();
|
||||
_spriteBatchEnd.Invoke();
|
||||
if (_drawHUD.GetValue() && hudMessages.Count > 0 && (!eventUp || isFestival()))
|
||||
{
|
||||
SetSpriteBatchBeginNextID("A-F");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using StardewModdingAPI.Framework;
|
||||
using StardewModdingAPI.Internal.ConsoleWriting;
|
||||
using StardewValley;
|
||||
|
@ -64,12 +66,12 @@ namespace StardewModdingAPI
|
|||
}
|
||||
else if (this.commandButton.bounds.Contains(x, y))
|
||||
{
|
||||
Game1.activeClickableMenu = new NamingMenu(this.textBoxEnter, "Command", "")
|
||||
{
|
||||
randomButton = new ClickableTextureComponent(new Rectangle(-100, -100, 0, 0), Game1.mobileSpriteSheet, new Rectangle(87, 22, 20, 20), 4f, false)
|
||||
};
|
||||
this.isVisible = false;
|
||||
Game1.playSound("bigDeSelect");
|
||||
KeyboardInput.Show("Command", "", "", false).ContinueWith<string>(delegate (Task<string> s) {
|
||||
string str;
|
||||
str = s.Result;
|
||||
this.textBoxEnter(str);
|
||||
return str;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -88,14 +90,14 @@ namespace StardewModdingAPI
|
|||
if (command.EndsWith(";"))
|
||||
{
|
||||
command = command.TrimEnd(';');
|
||||
this.isVisible = false;
|
||||
Game1.activeClickableMenu = null;
|
||||
Game1.playSound("bigDeSelect");
|
||||
SGame.instance.CommandQueue.Enqueue(command);
|
||||
this.exitThisMenu();
|
||||
return;
|
||||
}
|
||||
SGame.instance.CommandQueue.Enqueue(command);
|
||||
}
|
||||
this.isVisible = true;
|
||||
Game1.activeClickableMenu = this;
|
||||
}
|
||||
|
||||
public override void leftClickHeld(int x, int y)
|
||||
|
|
|
@ -349,7 +349,6 @@
|
|||
<Compile Include="IMultiplayerHelper.cs" />
|
||||
<Compile Include="IMultiplayerPeer.cs" />
|
||||
<Compile Include="IMultiplayerPeerMod.cs" />
|
||||
<Compile Include="InputStatus.cs" />
|
||||
<Compile Include="IReflectedField.cs" />
|
||||
<Compile Include="IReflectedMethod.cs" />
|
||||
<Compile Include="IReflectedProperty.cs" />
|
||||
|
@ -373,6 +372,7 @@
|
|||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SButton.cs" />
|
||||
<Compile Include="SButtonState.cs" />
|
||||
<Compile Include="SemanticVersion.cs" />
|
||||
<Compile Include="SGameConsole.cs" />
|
||||
<Compile Include="SMainActivity.cs" />
|
||||
|
|
Loading…
Reference in New Issue