Files
better-genshin-impact/BetterGenshinImpact/GameTask/TaskContext.cs
2023-12-31 14:37:44 +08:00

71 lines
1.7 KiB
C#

using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.GameTask.Model;
using BetterGenshinImpact.Genshin.Settings;
using BetterGenshinImpact.Helpers;
using BetterGenshinImpact.Service;
using System;
namespace BetterGenshinImpact.GameTask
{
/// <summary>
/// 任务上下文
/// </summary>
public class TaskContext
{
private static TaskContext? _uniqueInstance;
private static readonly object Locker = new();
private TaskContext()
{
}
public static TaskContext Instance()
{
if (_uniqueInstance == null)
{
lock (Locker)
{
_uniqueInstance ??= new TaskContext();
}
}
return _uniqueInstance;
}
public void Init(IntPtr hWnd)
{
GameHandle = hWnd;
SystemInfo = new SystemInfo(hWnd);
DpiScale = DpiHelper.ScaleY;
//MaskWindowHandle = new WindowInteropHelper(MaskWindow.Instance()).Handle;
IsInitialized = true;
}
public bool IsInitialized { get; set; }
public IntPtr GameHandle { get; set; }
//public IntPtr MaskWindowHandle { get; set; }
public float DpiScale { get; set; }
public SystemInfo SystemInfo { get; set; }
public AllConfig Config
{
get
{
if (ConfigService.Config == null)
{
throw new Exception("Config未初始化");
}
return ConfigService.Config;
}
}
public SettingsContainer? GameSettings { get; set; }
}
}