Skip to content

Commit f422c76

Browse files
committed
挂卡支持黑名单游戏自动排除
1 parent cd85ff7 commit f422c76

6 files changed

Lines changed: 256 additions & 32 deletions

File tree

src/BD.WTTS.Client.Plugins.SteamIdleCard/Models/IdleApp.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ namespace BD.WTTS.Models;
55

66
public class IdleApp : ReactiveObject
77
{
8+
private bool isBlacklisted;
9+
private bool isPrivateGame;
10+
811
public SteamApp App { get; }
912

1013
public Badge Badge { get; }
@@ -45,6 +48,50 @@ public string? Tags
4548
}
4649
}
4750

51+
public bool IsBlacklisted
52+
{
53+
get => isBlacklisted;
54+
set
55+
{
56+
if (isBlacklisted != value)
57+
{
58+
this.RaiseAndSetIfChanged(ref isBlacklisted, value);
59+
this.RaisePropertyChanged(nameof(IsExcludedFromIdle));
60+
this.RaisePropertyChanged(nameof(ExcludedReasonText));
61+
}
62+
}
63+
}
64+
65+
public bool IsPrivateGame
66+
{
67+
get => isPrivateGame;
68+
set
69+
{
70+
if (isPrivateGame != value)
71+
{
72+
this.RaiseAndSetIfChanged(ref isPrivateGame, value);
73+
this.RaisePropertyChanged(nameof(IsExcludedFromIdle));
74+
this.RaisePropertyChanged(nameof(ExcludedReasonText));
75+
}
76+
}
77+
}
78+
79+
public bool IsExcludedFromIdle => IsBlacklisted || IsPrivateGame;
80+
81+
public string ExcludedReasonText
82+
{
83+
get
84+
{
85+
if (IsPrivateGame && IsBlacklisted)
86+
return "私密游戏(不掉卡) + 已拉黑";
87+
if (IsPrivateGame)
88+
return "私密游戏(不掉卡)";
89+
if (IsBlacklisted)
90+
return "已拉黑";
91+
return string.Empty;
92+
}
93+
}
94+
4895
public IdleApp(Badge badge)
4996
{
5097
Badge = badge;

src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/Abstractions/ISteamIdleSettings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ static ISteamIdleSettings? Instance
5555
/// </summary>
5656
double RefreshBadgesTime { get; set; }
5757

58+
/// <summary>
59+
/// 挂卡黑名单游戏列表
60+
/// </summary>
61+
Dictionary<uint, string?>? BlacklistAppList { get; set; }
62+
5863
/// <summary>
5964
/// 挂卡状态更新时间的默认值
6065
/// </summary>
@@ -90,4 +95,9 @@ static ISteamIdleSettings? Instance
9095
/// </summary>
9196
static readonly double DefaultRefreshBadgesTime = 6;
9297

98+
/// <summary>
99+
/// 挂卡黑名单游戏列表的默认值
100+
/// </summary>
101+
static readonly Dictionary<uint, string?> DefaultBlacklistAppList = [];
102+
93103
}

src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/SteamIdleSettings.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ static JsonTypeInfo<SteamIdleSettings_> ISettings<SteamIdleSettings_>.JsonTypeIn
8585
[MPKey(6), MP2Key(6), JsonPropertyOrder(6)]
8686
public double RefreshBadgesTime { get; set; } = ISteamIdleSettings.DefaultRefreshBadgesTime;
8787

88+
/// <summary>
89+
/// 挂卡黑名单游戏列表
90+
/// </summary>
91+
[MPKey(7), MP2Key(7), JsonPropertyOrder(7)]
92+
public Dictionary<uint, string?>? BlacklistAppList { get; set; } = ISteamIdleSettings.DefaultBlacklistAppList;
93+
8894
}
8995

9096
public static partial class SteamIdleSettings
@@ -131,4 +137,10 @@ public static partial class SteamIdleSettings
131137
public static SettingsStructProperty<double, SteamIdleSettings_> RefreshBadgesTime { get; }
132138
= new(DefaultRefreshBadgesTime);
133139

140+
/// <summary>
141+
/// 挂卡黑名单游戏列表
142+
/// </summary>
143+
public static SettingsProperty<uint, string?, Dictionary<uint, string?>, SteamIdleSettings_> BlacklistAppList { get; }
144+
= new(DefaultBlacklistAppList);
145+
134146
}

0 commit comments

Comments
 (0)