SysParams

This commit is contained in:
辉鸭蛋
2024-12-23 23:32:25 +08:00
parent 6fbae881de
commit 839343cebf
5 changed files with 41 additions and 1 deletions

View File

@@ -66,7 +66,8 @@ public class KeyMouseRecorderJsonLine
Height = rect.Height,
RecordDpi = TaskContext.Instance().DpiScale,
StartTime = $"{startTime:yyyy-MM-dd HH:mm:ss:ffff}",
StartTimeUnixTimestamp = (startTime - new DateTime(1970, 1, 1)).TotalNanoseconds.ToString("F0")
StartTimeUnixTimestamp = (startTime - new DateTime(1970, 1, 1)).TotalNanoseconds.ToString("F0"),
SysParams = RecordContext.Instance.SysParams
};
var infoJson = JsonSerializer.Serialize(Info, JsonOptions);
File.WriteAllText(Path.Combine(path, $"{folderName}.json"), infoJson);

View File

@@ -28,4 +28,6 @@ public class KeyMouseScriptInfo
public string StartTime { get; set; } = string.Empty;
public string StartTimeUnixTimestamp { get; set; } = string.Empty;
public SysParams? SysParams { get; set; }
}

View File

@@ -0,0 +1,10 @@
using BetterGenshinImpact.Model;
namespace BetterGenshinImpact.Core.Recorder.Model;
public class RecordContext : Singleton<RecordContext>
{
public SysParams SysParams { get; set; } = new();
}

View File

@@ -0,0 +1,24 @@
using BetterGenshinImpact.Helpers;
namespace BetterGenshinImpact.Core.Recorder.Model;
public class SysParams
{
/// <summary>
/// 提高指针精确度 是否启用
/// </summary>
public bool EnhancePointerPrecision { get; set; }
public SysParams()
{
var (mouseThreshold1, mouseThreshold2, mouseThreshold3) = EnvironmentUtil.GetMouse();
if (mouseThreshold3 > 0)
{
EnhancePointerPrecision = true;
}
else
{
EnhancePointerPrecision = false;
}
}
}

View File

@@ -17,6 +17,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using BetterGenshinImpact.Core.Recorder.Model;
using BetterGenshinImpact.Helpers;
using Wpf.Ui;
using Wpf.Ui.Controls;
@@ -90,6 +91,8 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
[RelayCommand]
public async Task OnStartRecord()
{
var s = RecordContext.Instance.SysParams; // 提前实例化,避免延迟
Debug.WriteLine(s.EnhancePointerPrecision);
if (!TaskContext.Instance().IsInitialized)
{
Toast.Warning("请先在启动页,启动截图器再使用本功能");