fix JustTp

This commit is contained in:
辉鸭蛋 2024-10-04 14:24:42 +08:00
parent 66f15488e1
commit 160e45c75a
5 changed files with 45 additions and 14 deletions

View File

@ -10,7 +10,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon>Assets\Images\logo.ico</ApplicationIcon>
<AssemblyName>BetterGI</AssemblyName>
<AssemblyVersion>0.34.4</AssemblyVersion>
<AssemblyVersion>0.34.5</AssemblyVersion>
<Platforms>x64</Platforms>
<DebugType>embedded</DebugType>
</PropertyGroup>

View File

@ -9,6 +9,15 @@ public class KeyMouseScriptInfo
public string Description { get; set; } = string.Empty;
public string? Author { get; set; }
public string? Version { get; set; }
/// <summary>
/// 制作时 BetterGI 的版本,用于兼容性检查
/// </summary>
public string? BgiVersion { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }

View File

@ -62,14 +62,35 @@ public class EngineExtend
public static void AddAllGlobalMethod(IScriptEngine engine)
{
// 获取GlobalMethod类的所有静态方法
var methods = typeof(GlobalMethod).GetMethods(BindingFlags.Static | BindingFlags.Public);
// // 获取GlobalMethod类的所有静态方法
// var methods = typeof(GlobalMethod).GetMethods(BindingFlags.Static | BindingFlags.Public);
//
// foreach (var method in methods)
// {
// // 使用方法名首字母小写作为HostObject的名称
// var methodName = char.ToLowerInvariant(method.Name[0]) + method.Name[1..];
// engine.AddHostObject(methodName, method);
// }
foreach (var method in methods)
{
// 使用方法名首字母小写作为HostObject的名称
var methodName = char.ToLowerInvariant(method.Name[0]) + method.Name[1..];
engine.AddHostObject(methodName, method);
}
#pragma warning disable CS8974 // Converting method group to non-delegate type
engine.AddHostObject("sleep", GlobalMethod.Sleep);
engine.AddHostObject("keyDown", GlobalMethod.KeyDown);
engine.AddHostObject("keyUp", GlobalMethod.KeyUp);
engine.AddHostObject("keyPress", GlobalMethod.KeyPress);
engine.AddHostObject("setGameMetrics", GlobalMethod.SetGameMetrics);
engine.AddHostObject("moveMouseBy", GlobalMethod.MoveMouseBy);
engine.AddHostObject("moveMouseTo", GlobalMethod.MoveMouseTo);
engine.AddHostObject("click", GlobalMethod.Click);
engine.AddHostObject("leftButtonClick", GlobalMethod.LeftButtonClick);
engine.AddHostObject("leftButtonDown", GlobalMethod.LeftButtonDown);
engine.AddHostObject("leftButtonUp", GlobalMethod.LeftButtonUp);
engine.AddHostObject("rightButtonClick", GlobalMethod.RightButtonClick);
engine.AddHostObject("rightButtonDown", GlobalMethod.RightButtonDown);
engine.AddHostObject("rightButtonUp", GlobalMethod.RightButtonUp);
engine.AddHostObject("middleButtonClick", GlobalMethod.MiddleButtonClick);
engine.AddHostObject("middleButtonDown", GlobalMethod.MiddleButtonDown);
engine.AddHostObject("middleButtonUp", GlobalMethod.MiddleButtonUp);
engine.AddHostObject("captureGameRegion", GlobalMethod.CaptureGameRegion);
#pragma warning restore CS8974 // Converting method group to non-delegate type
}
}

View File

@ -34,6 +34,6 @@ public partial class ScriptGroup : ObservableObject
public static ScriptGroup FromJson(string json)
{
return JsonSerializer.Deserialize<ScriptGroup>(json, ConfigService.JsonOptions) ?? throw new Exception("解析配置组JSON配置失败");
return Newtonsoft.Json.JsonConvert.DeserializeObject<ScriptGroup>(json) ?? throw new Exception("解析配置组JSON配置失败");
}
}

View File

@ -342,10 +342,11 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
};
uiMessageBox.ShowDialogAsync();
// foreach (var group in ScriptGroups)
// {
// WriteScriptGroup(group);
// }
// 由于 JsScriptSettingsObject 的存在,这里只能手动再次保存配置
foreach (var group in ScriptGroups)
{
WriteScriptGroup(group);
}
}
else
{