diff --git a/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj b/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj
index c46d6db9..a38c40bd 100644
--- a/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj
+++ b/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj
@@ -5,7 +5,7 @@
StardewModdingAPI.Mods.SaveBackup
net45
latest
- C:\Users\Chris\source\repos\SMAPI\bin\Debug\Mods\SaveBackup\
+
false
x86
diff --git a/src/SMAPI.Mods.VirtualKeyboard/KeyButton.cs b/src/SMAPI.Mods.VirtualKeyboard/KeyButton.cs
index 1dd7ce7f..1c3487ab 100644
--- a/src/SMAPI.Mods.VirtualKeyboard/KeyButton.cs
+++ b/src/SMAPI.Mods.VirtualKeyboard/KeyButton.cs
@@ -1,10 +1,12 @@
using System;
+using System.Collections.Concurrent;
using Microsoft.Xna.Framework;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Menus;
-using static StardewModdingAPI.Mods.VirtualKeyboard.ModConfig;
using System.Reflection;
+using Microsoft.Xna.Framework.Input;
+using static StardewModdingAPI.Mods.VirtualKeyboard.ModConfig;
namespace StardewModdingAPI.Mods.VirtualKeyboard
{
@@ -50,8 +52,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
helper.Events.Input.ButtonReleased += this.EventInputButtonReleased;
helper.Events.Input.ButtonPressed += this.EventInputButtonPressed;
- MainActivity activity = this.helper.Reflection.GetField(typeof(MainActivity), "instance").GetValue();
- object score = activity.GetType().GetField("core", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(activity);
+ 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);
@@ -61,9 +62,16 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
this.RaiseButtonReleased = this.buttonReleased.GetType().GetMethod("Raise", BindingFlags.Public | BindingFlags.Instance);
}
+ private object GetSCore(IModHelper helper)
+ {
+ MainActivity activity = this.helper.Reflection.GetField(typeof(MainActivity), "instance").GetValue();
+ object score = activity.GetType().GetField("core", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(activity);
+ return score;
+ }
+
private bool shouldTrigger(Vector2 screenPixels)
{
- if (this.buttonRectangle.Contains(screenPixels.X * Game1.options.zoomLevel, screenPixels.Y * Game1.options.zoomLevel))
+ if (this.buttonRectangle.Contains(screenPixels.X * Game1.options.zoomLevel, screenPixels.Y * Game1.options.zoomLevel) && !this.hidden)
{
if (!this.hidden)
Toolbar.toolbarPressed = true;
@@ -80,7 +88,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
}
Vector2 screenPixels = e.Cursor.ScreenPixels;
- if (this.shouldTrigger(screenPixels) && !this.hidden)
+ if (this.shouldTrigger(screenPixels))
{
object inputState = e.GetType().GetField("InputState", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(e);
@@ -108,6 +116,31 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
Vector2 screenPixels = e.Cursor.ScreenPixels;
if (this.shouldTrigger(screenPixels))
{
+ if (this.buttonKey == SButton.RightWindows)
+ {
+ Game1.activeClickableMenu = new NamingMenu(command =>
+ {
+ if (command.Length > 0)
+ {
+ object score = this.GetSCore(this.helper);
+ object sgame = score.GetType().GetField("GameInstance", BindingFlags.Public | BindingFlags.Instance)?.GetValue(score);
+ ConcurrentQueue commandQueue = sgame.GetType().GetProperty("CommandQueue", BindingFlags.Public | BindingFlags.Instance)?.GetValue(sgame) as ConcurrentQueue;
+ 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;
+ }
+ if (this.buttonKey == SButton.RightControl)
+ {
+ SGameConsole.Instance.Show();
+ 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
@@ -127,9 +160,14 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
/// The event arguments.
private void OnRenderingHud(object sender, EventArgs e)
{
- if (!Game1.eventUp && !this.hidden && Game1.activeClickableMenu is GameMenu == false && Game1.activeClickableMenu is ShopMenu == false && Game1.activeClickableMenu is IClickableMenu == false)
+ if (!this.hidden)
{
- IClickableMenu.drawButtonWithText(Game1.spriteBatch, Game1.smallFont, this.alias, this.buttonRectangle.X, this.buttonRectangle.Y, this.buttonRectangle.Width, this.buttonRectangle.Height, Color.BurlyWood * this.transparency);
+ float scale = this.transparency;
+ if (!Game1.eventUp && Game1.activeClickableMenu is GameMenu == false && Game1.activeClickableMenu is ShopMenu == false && Game1.activeClickableMenu is IClickableMenu == false)
+ {
+ 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);
}
}
}
diff --git a/src/SMAPI.Mods.VirtualKeyboard/ModConfig.cs b/src/SMAPI.Mods.VirtualKeyboard/ModConfig.cs
index 352a54b4..d1cf4b29 100644
--- a/src/SMAPI.Mods.VirtualKeyboard/ModConfig.cs
+++ b/src/SMAPI.Mods.VirtualKeyboard/ModConfig.cs
@@ -1,27 +1,20 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.Xna.Framework;
-using StardewValley;
-using StardewValley.Menus;
-
namespace StardewModdingAPI.Mods.VirtualKeyboard
{
class ModConfig
{
- public Toggle vToggle = new Toggle(new Rectangle(36, 12, 64, 64));
-
- public VirtualButton[] buttons { get; set; } = new VirtualButton[] {
- new VirtualButton(SButton.Q, new Rect(192, 150, 90, 90, 6), 0.5f),
- new VirtualButton(SButton.I, new Rect(288, 150, 90, 90, 6), 0.5f),
- new VirtualButton(SButton.O, new Rect(384, 150, 90, 90, 6), 0.5f),
- new VirtualButton(SButton.P, new Rect(480, 150, 90, 90, 6), 0.5f),
- new VirtualButton(SButton.MouseRight, new Rect(580, 150, 150, 90, 6), 0.5f, "RightMouse")
+ 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)
};
- internal class VirtualButton
- {
+ 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")
+ };
+ internal class VirtualButton {
public SButton key;
public Rect rectangle;
public float transparency;
@@ -34,13 +27,12 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
this.alias = alias;
}
}
-
internal class Toggle
{
- public Rectangle rectangle;
+ public Rect rectangle;
//public float scale;
- public Toggle(Rectangle rectangle)
+ public Toggle(Rect rectangle)
{
this.rectangle = rectangle;
//this.scale = scale;
@@ -52,15 +44,13 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
public int Y;
public int Width;
public int Height;
- public int Padding;
- public Rect(int x, int y, int width, int height, int padding)
+ public Rect(int x, int y, int width, int height)
{
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
- this.Padding = padding;
}
}
}
diff --git a/src/SMAPI.Mods.VirtualKeyboard/ModEntry.cs b/src/SMAPI.Mods.VirtualKeyboard/ModEntry.cs
index 06ac1de8..e9434b36 100644
--- a/src/SMAPI.Mods.VirtualKeyboard/ModEntry.cs
+++ b/src/SMAPI.Mods.VirtualKeyboard/ModEntry.cs
@@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
using StardewModdingAPI;
-using StardewValley;
-using StardewValley.Tools;
namespace StardewModdingAPI.Mods.VirtualKeyboard
{
- public class ModEntry : Mod
+ class ModEntry : Mod
{
public override void Entry(IModHelper helper)
{
diff --git a/src/SMAPI.Mods.VirtualKeyboard/VirtualToggle.cs b/src/SMAPI.Mods.VirtualKeyboard/VirtualToggle.cs
index ee6da9d3..4164cb6e 100644
--- a/src/SMAPI.Mods.VirtualKeyboard/VirtualToggle.cs
+++ b/src/SMAPI.Mods.VirtualKeyboard/VirtualToggle.cs
@@ -13,11 +13,12 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
private readonly IModHelper helper;
private readonly IMonitor Monitor;
- private bool enabled = false;
+ private int enabledStage = 0;
private bool isDefault = true;
private ClickableTextureComponent virtualToggleButton;
private List keyboard = new List();
+ private List keyboardExtend = new List();
private ModConfig modConfig;
private Texture2D texture;
@@ -30,6 +31,8 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
this.modConfig = helper.ReadConfig();
for (int i = 0; i < this.modConfig.buttons.Length; i++)
this.keyboard.Add(new KeyButton(helper, this.modConfig.buttons[i], this.Monitor));
+ for (int i = 0; i < this.modConfig.buttonsExtend.Length; i++)
+ this.keyboardExtend.Add(new KeyButton(helper, this.modConfig.buttonsExtend[i], this.Monitor));
if (this.modConfig.vToggle.rectangle.X != 36 || this.modConfig.vToggle.rectangle.Y != 12)
this.isDefault = false;
@@ -44,30 +47,48 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
private void VirtualToggleButtonPressed(object sender, ButtonPressedEventArgs e)
{
Vector2 screenPixels = e.Cursor.ScreenPixels;
- if (!this.enabled && this.shouldTrigger(screenPixels))
+ if (this.shouldTrigger(screenPixels))
{
- this.hiddenKeys(true, false);
- }
- else if (this.enabled && this.shouldTrigger(screenPixels))
- {
- this.hiddenKeys(false, true);
- if (Game1.activeClickableMenu is IClickableMenu menu)
+ switch (this.enabledStage)
{
- menu.exitThisMenu();
- Toolbar.toolbarPressed = true;
+ case 0:
+ foreach (var keys in this.keyboard)
+ {
+ keys.hidden = false;
+ }
+ foreach (var keys in this.keyboardExtend)
+ {
+ keys.hidden = true;
+ }
+ this.enabledStage = 1;
+ break;
+ case 1 when this.keyboardExtend.Count > 0:
+ foreach (var keys in this.keyboardExtend)
+ {
+ keys.hidden = false;
+ }
+ this.enabledStage = 2;
+ break;
+ default:
+ foreach (var keys in this.keyboard)
+ {
+ keys.hidden = true;
+ }
+ foreach (var keys in this.keyboardExtend)
+ {
+ keys.hidden = true;
+ }
+ this.enabledStage = 0;
+ if (Game1.activeClickableMenu is IClickableMenu menu)
+ {
+ menu.exitThisMenu();
+ Toolbar.toolbarPressed = true;
+ }
+ break;
}
}
}
- private void hiddenKeys(bool enabled, bool hidden)
- {
- this.enabled = enabled;
- foreach (var keys in this.keyboard)
- {
- keys.hidden = hidden;
- }
- }
-
private bool shouldTrigger(Vector2 screenPixels)
{
if (this.virtualToggleButton.containsPoint((int)(screenPixels.X * Game1.options.zoomLevel), (int)(screenPixels.Y * Game1.options.zoomLevel)))
@@ -104,12 +125,13 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
}
float scale = 1f;
- if (!this.enabled)
+ if (this.enabledStage == 0)
{
scale = 0.5f;
}
- if(!Game1.eventUp && Game1.activeClickableMenu is GameMenu == false && Game1.activeClickableMenu is ShopMenu == false)
- this.virtualToggleButton.draw(Game1.spriteBatch, Color.White * scale, 0.000001f);
+ if (!Game1.eventUp && Game1.activeClickableMenu is GameMenu == false && Game1.activeClickableMenu is ShopMenu == false)
+ scale = 0.25f;
+ this.virtualToggleButton.draw(Game1.spriteBatch, Color.White * scale, 0.000001f);
}
}
}
diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj
index 611e45d6..7e932ed2 100644
--- a/src/SMAPI/SMAPI.csproj
+++ b/src/SMAPI/SMAPI.csproj
@@ -16,7 +16,7 @@
Resources\Resource.designer.cs
Off
false
- v10.0
+ v9.0
true
@@ -83,9 +83,6 @@
..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\xTile.dll
-
- ..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\TMXTile.dll
-
@@ -239,10 +236,6 @@
-
-
-
-