From d56312246e38eb649c8fcc9809892d4defbb41ac Mon Sep 17 00:00:00 2001 From: RMBGAME Date: Tue, 21 Nov 2023 15:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Misc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/settings_v4_app.json | 43 ++++++++ .../Abstractions/ISteamIdleSettings.cs | 63 ++++++++++++ .../Settings/SteamIdleSettings.cs | 98 +++++++++++++++++++ .../UI/ViewModels/IdleCardPageViewModel.cs | 35 +++---- .../ViewModels/IdleCardPageViewModel.props.cs | 8 +- .../UI/Views/Pages/IdleCardPage.axaml | 3 + 6 files changed, 229 insertions(+), 21 deletions(-) create mode 100644 src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/Abstractions/ISteamIdleSettings.cs create mode 100644 src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/SteamIdleSettings.cs diff --git a/build/settings_v4_app.json b/build/settings_v4_app.json index ab844dc226c..80013fc671a 100644 --- a/build/settings_v4_app.json +++ b/build/settings_v4_app.json @@ -964,6 +964,49 @@ } ], "Usings": "" + }, + "SteamIdleSettings": { + "ClassFilePath": "..\\src\\BD.WTTS.Client.Plugins.SteamIdleCard\\Settings", + "InterfaceFilePath": "..\\src\\BD.WTTS.Client.Plugins.SteamIdleCard\\Settings\\Abstractions", + "Properties": [ + { + "TypeName": "ConcurrentDictionary", + "PropertyName": "AccountRemarks", + "DefaultValue": "new()", + "DefaultValueIsConst": false, + "Summary": "账号备注字典", + "IsRegionOrEndregion": null, + "IsValueType": null + }, + { + "TypeName": "IReadOnlyCollection", + "PropertyName": "DisableAuthorizedDevice", + "DefaultValue": "Array.Empty()", + "DefaultValueIsConst": false, + "Summary": "Steam 家庭共享临时禁用", + "IsRegionOrEndregion": null, + "IsValueType": null + }, + { + "TypeName": "HashSet", + "PropertyName": "EnablePlatforms", + "DefaultValue": "new()", + "DefaultValueIsConst": false, + "Summary": "启用的账号平台集合", + "IsRegionOrEndregion": null, + "IsValueType": null + }, + { + "TypeName": "ConcurrentDictionary", + "PropertyName": "PlatformSettings", + "DefaultValue": "new()", + "DefaultValueIsConst": false, + "Summary": "账号平台设置集合", + "IsRegionOrEndregion": null, + "IsValueType": null + } + ], + "Usings": "" } } } \ No newline at end of file diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/Abstractions/ISteamIdleSettings.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/Abstractions/ISteamIdleSettings.cs new file mode 100644 index 00000000000..af8f6440c36 --- /dev/null +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/Abstractions/ISteamIdleSettings.cs @@ -0,0 +1,63 @@ +#nullable enable +#pragma warning disable IDE0079 // 请删除不必要的忽略 +#pragma warning disable SA1634 // File header should show copyright +#pragma warning disable CS8601 // 引用类型赋值可能为 null。 +#pragma warning disable CS0108 // 成员隐藏继承的成员;缺少关键字 new +//------------------------------------------------------------------------------ +// +// 此代码由包 BD.Common.Settings.V4.SourceGenerator.Tools 源生成。 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +// ReSharper disable once CheckNamespace +namespace BD.WTTS.Settings.Abstractions; + +public partial interface ISteamIdleSettings +{ + static ISteamIdleSettings? Instance + => Ioc.Get_Nullable>()?.CurrentValue; + + /// + /// 账号备注字典 + /// + ConcurrentDictionary? AccountRemarks { get; set; } + + /// + /// Steam 家庭共享临时禁用 + /// + IReadOnlyCollection? DisableAuthorizedDevice { get; set; } + + /// + /// 启用的账号平台集合 + /// + HashSet? EnablePlatforms { get; set; } + + /// + /// 账号平台设置集合 + /// + ConcurrentDictionary? PlatformSettings { get; set; } + + /// + /// 账号备注字典的默认值 + /// + static readonly ConcurrentDictionary DefaultAccountRemarks = new(); + + /// + /// Steam 家庭共享临时禁用的默认值 + /// + static readonly IReadOnlyCollection DefaultDisableAuthorizedDevice = Array.Empty(); + + /// + /// 启用的账号平台集合的默认值 + /// + static readonly HashSet DefaultEnablePlatforms = new(); + + /// + /// 账号平台设置集合的默认值 + /// + static readonly ConcurrentDictionary DefaultPlatformSettings = new(); + +} diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/SteamIdleSettings.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/SteamIdleSettings.cs new file mode 100644 index 00000000000..d84aeabd21a --- /dev/null +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/Settings/SteamIdleSettings.cs @@ -0,0 +1,98 @@ +#nullable enable +#pragma warning disable IDE0079 // 请删除不必要的忽略 +#pragma warning disable SA1634 // File header should show copyright +#pragma warning disable CS8601 // 引用类型赋值可能为 null。 +#pragma warning disable CS0108 // 成员隐藏继承的成员;缺少关键字 new +//------------------------------------------------------------------------------ +// +// 此代码由包 BD.Common.Settings.V4.SourceGenerator.Tools 源生成。 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +using static BD.WTTS.Settings.Abstractions.ISteamIdleSettings; + +// ReSharper disable once CheckNamespace +namespace BD.WTTS.Settings; + +[JsonSourceGenerationOptions(WriteIndented = true, IgnoreReadOnlyProperties = true)] +[JsonSerializable(typeof(SteamIdleSettings_))] +internal partial class SteamIdleSettingsContext : JsonSerializerContext +{ + static SteamIdleSettingsContext? instance; + + public static SteamIdleSettingsContext Instance + => instance ??= new SteamIdleSettingsContext(ISettings.GetDefaultOptions()); +} + +[MPObj, MP2Obj(SerializeLayout.Explicit)] +public sealed partial class SteamIdleSettings_ : ISteamIdleSettings, ISettings, ISettings +{ + public const string Name = nameof(SteamIdleSettings); + + static string ISettings.Name => Name; + + static JsonSerializerContext ISettings.JsonSerializerContext + => SteamIdleSettingsContext.Instance; + + static JsonTypeInfo ISettings.JsonTypeInfo + => SteamIdleSettingsContext.Instance.SteamIdleSettings_; + + static JsonTypeInfo ISettings.JsonTypeInfo + => SteamIdleSettingsContext.Instance.SteamIdleSettings_; + + /// + /// 账号备注字典 + /// + [MPKey(0), MP2Key(0), JsonPropertyOrder(0)] + public ConcurrentDictionary? AccountRemarks { get; set; } = ISteamIdleSettings.DefaultAccountRemarks; + + /// + /// Steam 家庭共享临时禁用 + /// + [MPKey(1), MP2Key(1), JsonPropertyOrder(1)] + public IReadOnlyCollection? DisableAuthorizedDevice { get; set; } = ISteamIdleSettings.DefaultDisableAuthorizedDevice; + + /// + /// 启用的账号平台集合 + /// + [MPKey(2), MP2Key(2), JsonPropertyOrder(2)] + public HashSet? EnablePlatforms { get; set; } = ISteamIdleSettings.DefaultEnablePlatforms; + + /// + /// 账号平台设置集合 + /// + [MPKey(3), MP2Key(3), JsonPropertyOrder(3)] + public ConcurrentDictionary? PlatformSettings { get; set; } = ISteamIdleSettings.DefaultPlatformSettings; + +} + +public static partial class SteamIdleSettings +{ + /// + /// 账号备注字典 + /// + public static SettingsProperty, SteamIdleSettings_> AccountRemarks { get; } + = new(DefaultAccountRemarks); + + /// + /// Steam 家庭共享临时禁用 + /// + public static SettingsProperty, SteamIdleSettings_> DisableAuthorizedDevice { get; } + = new(DefaultDisableAuthorizedDevice); + + /// + /// 启用的账号平台集合 + /// + public static SettingsProperty, SteamIdleSettings_> EnablePlatforms { get; } + = new(DefaultEnablePlatforms); + + /// + /// 账号平台设置集合 + /// + public static SettingsProperty, SteamIdleSettings_> PlatformSettings { get; } + = new(DefaultPlatformSettings); + +} diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs index 8fbe7f378d1..dd0de8c7870 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.cs @@ -94,28 +94,29 @@ public async Task IdleRunStartOrStop_Click() IsLoaing = false; } - //if (!RunLoaingState) - //{ - // RunLoaingState = true; - - if (!RunState) + if (!RunLoaingState) { - //await SteamConnectService.Current.RefreshGamesListAsync(); - RunState = await ReadyToGoIdle(); + RunLoaingState = true; + + if (!RunState) + { + //await SteamConnectService.Current.RefreshGamesListAsync(); + RunState = await ReadyToGoIdle(); + } + else + { + RunState = false; + StopIdle(); + RunOrStopAutoNext(false); + } + + RunLoaingState = false; + //Toast.Show(ToastIcon.Success, Strings.Idle_OperationSuccess); } else { - RunState = false; - StopIdle(); - RunOrStopAutoNext(false); + Toast.Show(ToastIcon.Warning, Strings.Idle_LoaingTips); } - //RunLoaingState = false; - //Toast.Show(ToastIcon.Success, Strings.Idle_OperationSuccess); - //} - //else - //{ - // Toast.Show(ToastIcon.Warning, Strings.Idle_LoaingTips); - //} } /// diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs index 105d2d2ba33..658492c3915 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/ViewModels/IdleCardPageViewModel.props.cs @@ -18,8 +18,8 @@ public sealed partial class IdleCardPageViewModel [Reactive] public bool IsLoaing { get; set; } - //[Reactive] - //public bool RunLoaingState { get; set; } + [Reactive] + public bool RunLoaingState { get; set; } [Reactive] public bool RunState { get; set; } @@ -87,13 +87,13 @@ public sealed partial class IdleCardPageViewModel /// 最少游戏时间 hours /// [Reactive] - private double MinRunTime { get; set; } = 2; + public double MinRunTime { get; set; } = 2; /// /// 自动切换游戏时间间隔 ms /// [Reactive] - private double SwitchTime { get; set; } = 500; + public double SwitchTime { get; set; } = 500; #endregion } diff --git a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml index 50b88cfbd3f..6c08b883c2c 100644 --- a/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml +++ b/src/BD.WTTS.Client.Plugins.SteamIdleCard/UI/Views/Pages/IdleCardPage.axaml @@ -433,6 +433,9 @@ Orientation="Vertical" Spacing="6"> + + 123 +