1.Add auto hidden feature to Virtual Keyboard
2.Bug fix 3.Disable smapi update check
This commit is contained in:
parent
ffd5fa7832
commit
bce7021668
|
@ -2,7 +2,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||||
{
|
{
|
||||||
class ModConfig
|
class ModConfig
|
||||||
{
|
{
|
||||||
public Toggle vToggle = new Toggle(new Rect(36, 12, 64, 64));
|
public Toggle vToggle { get; set; } = new Toggle(new Rect(36, 12, 64, 64), true);
|
||||||
public VirtualButton[] buttons { get; set;} = new VirtualButton[] {
|
public VirtualButton[] buttons { get; set;} = new VirtualButton[] {
|
||||||
new VirtualButton(SButton.Q, new Rect(190, 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.I, new Rect(290, 80, 90, 90), 0.5f),
|
||||||
|
@ -16,11 +16,11 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||||
new VirtualButton(SButton.RightControl, new Rect(630, 170, 162, 90), 0.5f, "Console")
|
new VirtualButton(SButton.RightControl, new Rect(630, 170, 162, 90), 0.5f, "Console")
|
||||||
};
|
};
|
||||||
internal class VirtualButton {
|
internal class VirtualButton {
|
||||||
public SButton key;
|
public SButton key { get;set; }
|
||||||
public Rect rectangle;
|
public Rect rectangle { get; set; }
|
||||||
public float transparency;
|
public float transparency { get; set; } = 0.5f;
|
||||||
public string alias;
|
public string alias { get; set; } = null;
|
||||||
public string command;
|
public string command { get; set; } = null;
|
||||||
public VirtualButton(SButton key, Rect rectangle, float transparency, string alias = null, string command = null)
|
public VirtualButton(SButton key, Rect rectangle, float transparency, string alias = null, string command = null)
|
||||||
{
|
{
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -32,12 +32,14 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||||
}
|
}
|
||||||
internal class Toggle
|
internal class Toggle
|
||||||
{
|
{
|
||||||
public Rect rectangle;
|
public Rect rectangle { get; set; }
|
||||||
|
public bool autoHidden { get; set; } = true;
|
||||||
//public float scale;
|
//public float scale;
|
||||||
|
|
||||||
public Toggle(Rect rectangle)
|
public Toggle(Rect rectangle, bool autoHidden)
|
||||||
{
|
{
|
||||||
this.rectangle = rectangle;
|
this.rectangle = rectangle;
|
||||||
|
this.autoHidden = autoHidden;
|
||||||
//this.scale = scale;
|
//this.scale = scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||||
private readonly IMonitor Monitor;
|
private readonly IMonitor Monitor;
|
||||||
|
|
||||||
private int enabledStage = 0;
|
private int enabledStage = 0;
|
||||||
|
private bool autoHidden = true;
|
||||||
private bool isDefault = true;
|
private bool isDefault = true;
|
||||||
private ClickableTextureComponent virtualToggleButton;
|
private ClickableTextureComponent virtualToggleButton;
|
||||||
|
|
||||||
|
@ -37,14 +38,31 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||||
|
|
||||||
if (this.modConfig.vToggle.rectangle.X != 36 || this.modConfig.vToggle.rectangle.Y != 12)
|
if (this.modConfig.vToggle.rectangle.X != 36 || this.modConfig.vToggle.rectangle.Y != 12)
|
||||||
this.isDefault = false;
|
this.isDefault = false;
|
||||||
|
this.autoHidden = this.modConfig.vToggle.autoHidden;
|
||||||
|
|
||||||
this.virtualToggleButton = new ClickableTextureComponent(new Rectangle(Game1.toolbarPaddingX + 64, 12, 128, 128), this.texture, new Rectangle(0, 0, 16, 16), 5.75f, false);
|
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);
|
helper.WriteConfig(this.modConfig);
|
||||||
|
|
||||||
this.helper.Events.Display.Rendered += this.OnRendered;
|
this.helper.Events.Display.Rendered += this.OnRendered;
|
||||||
|
this.helper.Events.Display.MenuChanged += this.OnMenuChanged;
|
||||||
this.helper.Events.Input.ButtonPressed += this.VirtualToggleButtonPressed;
|
this.helper.Events.Input.ButtonPressed += this.VirtualToggleButtonPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMenuChanged(object sender, MenuChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if(this.autoHidden && e.NewMenu != null) {
|
||||||
|
foreach (var keys in this.keyboard)
|
||||||
|
{
|
||||||
|
keys.hidden = true;
|
||||||
|
}
|
||||||
|
foreach (var keys in this.keyboardExtend)
|
||||||
|
{
|
||||||
|
keys.hidden = true;
|
||||||
|
}
|
||||||
|
this.enabledStage = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void VirtualToggleButtonPressed(object sender, ButtonPressedEventArgs e)
|
private void VirtualToggleButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
Vector2 screenPixels = e.Cursor.ScreenPixels;
|
Vector2 screenPixels = e.Cursor.ScreenPixels;
|
||||||
|
@ -80,7 +98,7 @@ namespace StardewModdingAPI.Mods.VirtualKeyboard
|
||||||
keys.hidden = true;
|
keys.hidden = true;
|
||||||
}
|
}
|
||||||
this.enabledStage = 0;
|
this.enabledStage = 0;
|
||||||
if (Game1.activeClickableMenu is IClickableMenu menu)
|
if (Game1.activeClickableMenu is IClickableMenu menu && !(Game1.activeClickableMenu is DialogueBox))
|
||||||
{
|
{
|
||||||
menu.exitThisMenu();
|
menu.exitThisMenu();
|
||||||
Toolbar.toolbarPressed = true;
|
Toolbar.toolbarPressed = true;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"Name": "VirtualKeyboard",
|
"Name": "VirtualKeyboard",
|
||||||
"Author": "MartyrPher",
|
"Author": "SMAPI",
|
||||||
"Version": "3.1.0",
|
"Version": "3.2.2",
|
||||||
"MinimumApiVersion": "3.1.0",
|
"MinimumApiVersion": "3.4.0",
|
||||||
"Description": "A much needed Virtual Keyboard for SMAPI Android.",
|
"Description": "A much needed Virtual Keyboard for SMAPI Android.",
|
||||||
"UniqueID": "VirtualKeyboard",
|
"UniqueID": "VirtualKeyboard",
|
||||||
"EntryDll": "VirtualKeyboard.dll",
|
"EntryDll": "VirtualKeyboard.dll",
|
||||||
|
|
|
@ -627,6 +627,7 @@ namespace StardewModdingAPI.Framework
|
||||||
this.Monitor.Log("Checking for updates...", LogLevel.Trace);
|
this.Monitor.Log("Checking for updates...", LogLevel.Trace);
|
||||||
|
|
||||||
// check SMAPI version
|
// check SMAPI version
|
||||||
|
#if DO_ANDROID_SMAPI_UPDATE_CHECK
|
||||||
ISemanticVersion updateFound = null;
|
ISemanticVersion updateFound = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -658,7 +659,7 @@ namespace StardewModdingAPI.Framework
|
||||||
// show update message on next launch
|
// show update message on next launch
|
||||||
if (updateFound != null)
|
if (updateFound != null)
|
||||||
File.WriteAllText(Constants.UpdateMarker, updateFound.ToString());
|
File.WriteAllText(Constants.UpdateMarker, updateFound.ToString());
|
||||||
|
#endif
|
||||||
// check mod versions
|
// check mod versions
|
||||||
if (mods.Any())
|
if (mods.Any())
|
||||||
{
|
{
|
||||||
|
@ -1296,8 +1297,8 @@ namespace StardewModdingAPI.Framework
|
||||||
errors.Add($"{file.Name} file couldn't be read"); // should never happen, since we're iterating files that exist
|
errors.Add($"{file.Name} file couldn't be read"); // should never happen, since we're iterating files that exist
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(data != null)
|
||||||
translations[locale] = data;
|
translations[locale] = data;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace StardewModdingAPI.Patches
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (value.tapToMove == null)
|
if (value != null && value.tapToMove == null)
|
||||||
{
|
{
|
||||||
if (value.map != null)
|
if (value.map != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Android.Runtime;
|
|
||||||
using Android.Views;
|
|
||||||
using Android.Widget;
|
|
||||||
using Java.Lang;
|
using Java.Lang;
|
||||||
|
using Microsoft.AppCenter.Crashes;
|
||||||
|
|
||||||
namespace StardewModdingAPI
|
namespace StardewModdingAPI
|
||||||
{
|
{
|
||||||
|
@ -17,21 +9,29 @@ namespace StardewModdingAPI
|
||||||
{
|
{
|
||||||
public static void AlertMessage(string message, string title = "Error")
|
public static void AlertMessage(string message, string title = "Error")
|
||||||
{
|
{
|
||||||
Handler handler = new Handler((msg) => throw new RuntimeException());
|
try
|
||||||
Dialog dialog = new AlertDialog.Builder(SMainActivity.Instance)
|
|
||||||
.SetTitle(title)
|
|
||||||
.SetMessage(message)
|
|
||||||
.SetCancelable(false)
|
|
||||||
.SetPositiveButton("OK", (senderAlert, arg) => { handler.SendEmptyMessage(0); }).Create();
|
|
||||||
if (!SMainActivity.Instance.IsFinishing)
|
|
||||||
{
|
{
|
||||||
dialog.Show();
|
Handler handler = new Handler((msg) => throw new RuntimeException());
|
||||||
try
|
Dialog dialog = new AlertDialog.Builder(SMainActivity.Instance)
|
||||||
|
.SetTitle(title)
|
||||||
|
.SetMessage(message)
|
||||||
|
.SetCancelable(false)
|
||||||
|
.SetPositiveButton("OK", (senderAlert, arg) => { handler.SendEmptyMessage(0); }).Create();
|
||||||
|
if (!SMainActivity.Instance.IsFinishing)
|
||||||
{
|
{
|
||||||
|
dialog.Show();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Looper.Prepare();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Crashes.TrackError(e);
|
||||||
|
}
|
||||||
Looper.Loop();
|
Looper.Loop();
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>TRACE;DEBUG;ANDROID_TARGET_SAMSUNG</DefineConstants>
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
|
|
@ -104,6 +104,9 @@ namespace StardewModdingAPI
|
||||||
SAlertDialogUtil.AlertMessage(System.IO.File.ReadAllText(errorLog.AbsolutePath), "Crash Detected");
|
SAlertDialogUtil.AlertMessage(System.IO.File.ReadAllText(errorLog.AbsolutePath), "Crash Detected");
|
||||||
}
|
}
|
||||||
Type[] services = new Type[] { typeof(Microsoft.AppCenter.Analytics.Analytics), typeof(Microsoft.AppCenter.Crashes.Crashes) };
|
Type[] services = new Type[] { typeof(Microsoft.AppCenter.Analytics.Analytics), typeof(Microsoft.AppCenter.Crashes.Crashes) };
|
||||||
|
CustomProperties properties = new CustomProperties();
|
||||||
|
properties.Set("SMAPI", Constants.ApiVersion.ToString());
|
||||||
|
AppCenter.SetCustomProperties(properties);
|
||||||
AppCenter.Start(Constants.MicrosoftAppSecret, services);
|
AppCenter.Start(Constants.MicrosoftAppSecret, services);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
Loading…
Reference in New Issue