Skip to content

Commit

Permalink
SettingsHost2
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Jul 28, 2021
1 parent f268c1a commit 7f0cee6
Show file tree
Hide file tree
Showing 15 changed files with 698 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/mileston
* [CefSharp](https://github.com/cefsharp/CefSharp)
* [ZXing.Net](https://github.com/micjahn/ZXing.Net)
* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile)
* [QRCoder](https://github.com/codebude/QRCoder)
* [React](https://github.com/facebook/react)
* [Ant Design](https://github.com/ant-design/ant-design)
* [Ant Design Blazor](https://github.com/ant-design-blazor/ant-design-blazor)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
* [CefSharp](https://github.com/cefsharp/CefSharp)
* [ZXing.Net](https://github.com/micjahn/ZXing.Net)
* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile)
* [QRCoder](https://github.com/codebude/QRCoder)
* [React](https://github.com/facebook/react)
* [Ant Design](https://github.com/ant-design/ant-design)
* [Ant Design Blazor](https://github.com/ant-design-blazor/ant-design-blazor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace System.Application.Models.Settings
{
public static class GameLibrarySettings
{
public static readonly Lazy<ReadOnlyCollection<uint>> DefaultIgnoreList = new Lazy<ReadOnlyCollection<uint>>(new ReadOnlyCollection<uint>(new List<uint>
public static readonly Lazy<ReadOnlyCollection<uint>> DefaultIgnoreList = new(new ReadOnlyCollection<uint>(new List<uint>
{
5,
7,
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Desktop/Models/Settings/SettingsHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected SerializableProperty<T> Cache<T>(Func<string, SerializableProperty<T>>
{
var key = CategoryName + "." + propertyName;

if (cachedProperties.TryGetValue(key, out object obj) && obj is SerializableProperty<T> property1)
if (cachedProperties.TryGetValue(key, out var obj) && obj is SerializableProperty<T> property1)
return property1;

var property = create(key);
Expand Down Expand Up @@ -83,7 +83,7 @@ public static void Save()
}
}

public class Providers
public static class Providers
{
public static string LocalFilePath => Path.Combine(IOPath.AppDataDirectory, SettingsHost.ConfigName);

Expand Down
23 changes: 23 additions & 0 deletions src/ST.Client.Desktop/Models/Settings2/ASFSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Application.Serialization;

namespace System.Application.Models.Settings
{
public sealed class ASFSettings : SettingsHost2<ASFSettings>
{
static ASFSettings()
{
}

/// <summary>
/// ASF路径
/// </summary>
public static SerializableProperty<string> ArchiSteamFarmExePath { get; }
= GetProperty(defaultValue: string.Empty, autoSave: true);

/// <summary>
/// 程序启动时自动运行ASF
/// </summary>
public static SerializableProperty<bool> AutoRunArchiSteamFarm { get; }
= GetProperty(defaultValue: false, autoSave: true);
}
}
175 changes: 175 additions & 0 deletions src/ST.Client.Desktop/Models/Settings2/GameLibrarySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
using System.Application.Serialization;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace System.Application.Models.Settings
{
public sealed class GameLibrarySettings : SettingsHost2<GameLibrarySettings>
{
public static readonly Lazy<ReadOnlyCollection<uint>> DefaultIgnoreList = new(new ReadOnlyCollection<uint>(new uint[]
{
5,
7,
8,
90,
92,
205,
211,
215,
218,
310,
364,
459,
480,
513,
563,
564,
575,
629,
635,
640,
644,
740,
745,
753,
760,
761,
764,
765,
766,
767,
1007,
1213,
1255,
1260,
1273,
2145,
2403,
4270,
4940,
8680,
8710,
8730,
8770,
12250,
12750,
13180,
13260,
16830,
16864,
16865,
16871,
16872,
16879,
17505,
17515,
17525,
17535,
17555,
17575,
17585,
17705,
43110,
61800,
61810,
61820,
61830,
104700,
201700,
224220,
232610,
375350,
245550,
254000,
254020,
254040,
259280,
285050,
312710,
314700,
321040,
329950,
331710,
344750,
354850,
368900,
373110,
383030,
385200,
388870,
392050,
392870,
395980,
397620,
399580,
407730,
407740,
407750,
410590,
410700,
416270,
428430,
431270,
432150,
447880,
449630,
457930,
457940,
460660,
461570,
462370,
463620,
473580,
473620,
473630,
473640,
473650,
486340,
488200,
491250,
492240,
496600,
501690,
505440,
509840,
516230,
516700,
524440,
526790,
528210,
533710,
545950,
546450,
559500,
559940,
562020,
576080,
576440,
581620,
592490,
603770,
603780,
605470,
654310,
700580
}));

/// <summary>
/// 隐藏的游戏列表
/// </summary>
public static SerializableProperty<Dictionary<uint, string?>> HideGameList { get; }
= GetProperty(defaultValue: new Dictionary<uint, string?>(), autoSave: true);

/// <summary>
/// 挂时长游戏列表
/// </summary>
public static SerializableProperty<Dictionary<uint, string?>> AFKAppList { get; }
= GetProperty(defaultValue: new Dictionary<uint, string?>(), autoSave: true);

/// <summary>
/// 启用自动挂机
/// </summary>
public static SerializableProperty<bool> IsAutoAFKApps { get; }
= GetProperty(defaultValue: true, autoSave: true);
}
}
78 changes: 78 additions & 0 deletions src/ST.Client.Desktop/Models/Settings2/GeneralSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System.Application.Serialization;
using System.Application.Services;
using System.Collections.Generic;
using System.Properties;

namespace System.Application.Models.Settings
{
public sealed class GeneralSettings : SettingsHost2<GeneralSettings>
{
static GeneralSettings()
{
#if !__MOBILE__
WindowsStartupAutoRun.ValueChanged += WindowsStartupAutoRun_ValueChanged;
//CreateDesktopShortcut.ValueChanged += CreateDesktopShortcut_ValueChanged;
#endif
}

#if !__MOBILE__
private static void WindowsStartupAutoRun_ValueChanged(object? sender, ValueChangedEventArgs<bool> e)
{
DI.Get<IDesktopPlatformService>().SetBootAutoStart(e.NewValue, ThisAssembly.AssemblyTrademark);
}

public static void InitWindowsStartupAutoRun()
{
WindowsStartupAutoRun_ValueChanged(null, new(default, WindowsStartupAutoRun.Value));
}

/// <summary>
/// 程序是否开机自启动
/// </summary>
public static SerializableProperty<bool> WindowsStartupAutoRun { get; }
= GetProperty(defaultValue: false, autoSave: true);

///// <summary>
///// 创建桌面快捷方式
///// </summary>
//public static SerializableProperty<bool> CreateDesktopShortcut { get; }
// = new SerializableProperty<bool>(GetKey(), Providers.Roaming, false) { AutoSave = true };

/// <summary>
/// 程序启动时最小化
/// </summary>
public static SerializableProperty<bool> IsStartupAppMinimized { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 是否显示起始页
/// </summary>
public static SerializableProperty<bool> IsShowStartPage { get; }
= GetProperty(defaultValue: true, autoSave: true);

/// <summary>
/// 启用游戏列表本地缓存
/// </summary>
public static SerializableProperty<bool> IsSteamAppListLocalCache { get; }
= GetProperty(defaultValue: true, autoSave: true);
#endif

/// <summary>
/// 自动检查更新
/// </summary>
public static SerializableProperty<bool> IsAutoCheckUpdate { get; }
= GetProperty(defaultValue: true, autoSave: true);

/// <summary>
/// 启用错误日志记录
/// </summary>
public static SerializableProperty<bool> IsEnableLogRecord { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 用户设置的文本阅读器提供商,根据平台值不同,值格式为 枚举字符串 或 程序路径
/// </summary>
public static SerializableProperty<IReadOnlyDictionary<Platform, string>> TextReaderProvider { get; }
= GetProperty(defaultValue: (IReadOnlyDictionary<Platform, string>?)null, autoSave: true);
}
}
69 changes: 69 additions & 0 deletions src/ST.Client.Desktop/Models/Settings2/ProxySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Application.Serialization;
using System.Collections.Generic;
using System.Net;

namespace System.Application.Models.Settings
{
public sealed class ProxySettings : SettingsHost2<ProxySettings>
{
/// <summary>
/// 启用脚本自动检查更新
/// </summary>
public static SerializableProperty<bool> IsAutoCheckScriptUpdate { get; }
= GetProperty(defaultValue: true, autoSave: true);

/// <summary>
/// 启用GOG插件代理
/// </summary>
public static SerializableProperty<bool> IsProxyGOG { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 启用windows系统代理模式
/// </summary>
public static SerializableProperty<bool> EnableWindowsProxy { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 启用代理脚本
/// </summary>
public static SerializableProperty<bool> IsEnableScript { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 程序启动时自动启动代理
/// </summary>
public static SerializableProperty<bool> ProgramStartupRunProxy { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 是否只针对Steam内置浏览器启用脚本
/// </summary>
public static SerializableProperty<bool> IsOnlyWorkSteamBrowser { get; }
= GetProperty(defaultValue: false, autoSave: true);

/// <summary>
/// 代理服务启用状态
/// </summary>
public static SerializableProperty<IReadOnlyCollection<string>> SupportProxyServicesStatus { get; }
= GetProperty(defaultValue: (IReadOnlyCollection<string>)new List<string>(), autoSave: false);

/// <summary>
/// 系统代理模式端口
/// </summary>
public static SerializableProperty<int> SystemProxyPortId { get; }
= GetProperty(defaultValue: 26501, autoSave: false);

/// <summary>
/// 系统代理模式IP
/// </summary>
public static SerializableProperty<string> SystemProxyIp { get; }
= GetProperty(defaultValue: IPAddress.Loopback.ToString(), autoSave: false);

/// <summary>
/// 脚本启用状态
/// </summary>
public static SerializableProperty<IReadOnlyCollection<int>> ScriptsStatus { get; }
= GetProperty(defaultValue: (IReadOnlyCollection<int>)new List<int>(), autoSave: true);
}
}
Loading

0 comments on commit 7f0cee6

Please sign in to comment.