mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
feat: 挂机
This commit is contained in:
@@ -72,6 +72,7 @@ namespace MaaWpfGui.Constants
|
||||
public const string PeekScreen = "PeekScreen";
|
||||
public const string CustomizationMaster = "CustomizationMaster";
|
||||
public const string Martian = "Martian";
|
||||
public const string AfkWatcher = "AfkWatcher";
|
||||
|
||||
public const string RecruitNoSixStar = "RecruitNoSixStar";
|
||||
public const string RecruitNoSixStarStreak = "RecruitNoSixStarStreak";
|
||||
|
||||
@@ -344,6 +344,8 @@ namespace MaaWpfGui.Helper
|
||||
Humor(id: AchievementIds.Martian, isHidden: true), // 90 天没更新
|
||||
Humor(id: AchievementIds.RecruitNoSixStar, target: 100), // 公招中累计 100 次没出现六星tag
|
||||
Humor(id: AchievementIds.RecruitNoSixStarStreak, target: 100, isHidden: true), // 公招中连续 100 次没出现六星tag
|
||||
Humor(id: AchievementIds.AfkWatcher), // 窗口尺寸最小化后长时间不操作
|
||||
|
||||
#endregion
|
||||
|
||||
#region BUG 相关
|
||||
|
||||
@@ -1256,5 +1256,9 @@ C:\\leidian\\LDPlayer9。\n
|
||||
<system:String x:Key="Achievement.CdnTorture.Description">比宇宙更远的地方,是 Github 的服务器。</system:String>
|
||||
<system:String x:Key="Achievement.CdnTorture.Conditions">下载资源失败超过 3 次</system:String>
|
||||
|
||||
<system:String x:Key="Achievement.AfkWatcher.Title">摇人挂机党</system:String>
|
||||
<system:String x:Key="Achievement.AfkWatcher.Description">你是在挂机,还是忘了关?</system:String>
|
||||
<system:String x:Key="Achievement.AfkWatcher.Conditions">窗口最小化后长时间不操作</system:String>
|
||||
|
||||
<!-- !Achievement -->
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace MaaWpfGui.Services.Managers
|
||||
|
||||
bool useTrayIcon = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.UseTray, bool.TrueString));
|
||||
SetUseTrayIcon(useTrayIcon);
|
||||
|
||||
_previousState = GetWindowState();
|
||||
if (_previousState == WindowState.Minimized)
|
||||
{
|
||||
_minimizedSince = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -101,6 +107,7 @@ namespace MaaWpfGui.Services.Managers
|
||||
}
|
||||
|
||||
private WindowState? _previousState = null;
|
||||
private DateTime? _minimizedSince = null;
|
||||
|
||||
/// <summary>
|
||||
/// Handle the main window's state changed event
|
||||
@@ -116,9 +123,24 @@ namespace MaaWpfGui.Services.Managers
|
||||
ChangeVisibility(currentState != WindowState.Minimized);
|
||||
}
|
||||
|
||||
// 触发事件:从 Minimized 恢复
|
||||
if (_previousState is null || (_previousState == WindowState.Minimized && currentState != WindowState.Minimized))
|
||||
// 检测进入 Minimized
|
||||
if (_previousState != WindowState.Minimized && currentState == WindowState.Minimized)
|
||||
{
|
||||
_minimizedSince = DateTime.Now;
|
||||
}
|
||||
|
||||
// 触发事件:从 Minimized 恢复
|
||||
if (_previousState == WindowState.Minimized && currentState != WindowState.Minimized)
|
||||
{
|
||||
if (_minimizedSince != null)
|
||||
{
|
||||
var duration = DateTime.Now - _minimizedSince.Value;
|
||||
if (duration.TotalHours >= 1)
|
||||
{
|
||||
AchievementTrackerHelper.Instance.Unlock(AchievementIds.AfkWatcher);
|
||||
}
|
||||
}
|
||||
|
||||
WindowRestored?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user