🐛Fix CustomSteamPath

This commit is contained in:
SongSongSo
2023-05-23 15:12:39 +08:00
parent 962aa5ae36
commit 9df1ca7054
8 changed files with 29 additions and 126 deletions
@@ -14,8 +14,8 @@
mc:Ignorable="d">
<StackPanel Margin="15" Spacing="5">
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam,Mode=OneWay,Source={x:Static s:ResourceService.Current}}" Margin="0 0 0 5"/>
<spp:OptionsDisplayItem Header="Steam 路径"
Description="{ReflectionBinding Source={x:Static ms:SteamSettings.SteamProgramPath},Path=Value,Mode=OneWay}">
<spp:OptionsDisplayItem Header="{ReflectionBinding Path=Res.Settings_Steam_Path,Mode=OneWay,Source={x:Static s:ResourceService.Current}}"
Description="{ReflectionBinding Source={x:Static ms:SteamSettings.CustomSteamPath},Path=Value,Mode=OneWay}">
<spp:OptionsDisplayItem.Icon>
<ui:FontIcon Glyph="&#xE756;" FontFamily="Segoe Fluent Icons"/>
</spp:OptionsDisplayItem.Icon>
+9
View File
@@ -5374,6 +5374,15 @@ namespace BD.WTTS.Client.Resources {
}
}
/// <summary>
/// 查找类似 Steam 路径 的本地化字符串。
/// </summary>
public static string Settings_Steam_Path {
get {
return ResourceManager.GetString("Settings_Steam_Path", resourceCulture);
}
}
/// <summary>
/// 查找类似 以管理员权限运行 Steam 的本地化字符串。
/// </summary>
@@ -2422,4 +2422,7 @@ AAAAA-BBBBB-CCCC3</value>
<data name="CommunityFix_OnRunCatch" xml:space="preserve">
<value>启动网络加速失败</value>
</data>
<data name="Settings_Steam_Path" xml:space="preserve">
<value>Steam 路径</value>
</data>
</root>
@@ -16,7 +16,7 @@ public interface ISteamSettings
string SteamSkin { get; set; }
/// <summary>
/// Steam 程序路径
/// Steam 默认程序路径
/// </summary>
string SteamProgramPath { get; set; }
@@ -6,7 +6,7 @@ public class SettingsProperty<TValue, [DynamicallyAccessedMembers(DynamicallyAcc
{
readonly Action<TSettings, TValue?> setter;
readonly Func<TSettings, TValue?> getter;
readonly IDisposable? disposable;
IDisposable? disposable;
readonly IOptionsMonitor<TSettings> monitor;
TValue? value;
bool disposedValue;
@@ -1,118 +0,0 @@
//#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
//// ReSharper disable once CheckNamespace
//namespace BD.WTTS.Settings;
///// <summary>
///// Steam 设置
///// </summary>
//public sealed class SteamSettings : SettingsHost2<SteamSettings>
//{
// private static readonly ISteamService _service = Ioc.Get<ISteamService>();
// static SteamSettings()
// {
// if (!IApplication.IsDesktop()) return;
// IsRunSteamMinimized.ValueChanged += IsRunSteamMinimized_ValueChanged;
// IsRunSteamNoCheckUpdate.ValueChanged += IsRunSteamNoCheckUpdate_ValueChanged;
// IsRunSteamChina.ValueChanged += IsRunSteamChina_ValueChanged;
// }
// static void IsRunSteamNoCheckUpdate_ValueChanged(object? sender, ValueChangedEventArgs<bool> e)
// {
// if (e.NewValue)
// SteamStratParameter.Value += " -noverifyfiles";
// else if (SteamStratParameter.Value != null)
// SteamStratParameter.Value = SteamStratParameter.Value.Replace("-noverifyfiles", "").Trim();
// }
// static void IsRunSteamMinimized_ValueChanged(object? sender, ValueChangedEventArgs<bool> e)
// {
// if (e.NewValue)
// SteamStratParameter.Value += " -silent";
// else if (SteamStratParameter.Value != null)
// SteamStratParameter.Value = SteamStratParameter.Value.Replace("-silent", "").Trim();
// }
// static void IsRunSteamChina_ValueChanged(object? sender, ValueChangedEventArgs<bool> e)
// {
// if (e.NewValue)
// SteamStratParameter.Value += " -steamchina";
// else if (SteamStratParameter.Value != null)
// SteamStratParameter.Value = SteamStratParameter.Value.Replace("-steamchina", "").Trim();
// }
// static readonly SerializableProperty<string?>? _SteamStratParameter = IApplication.IsDesktop() ?
// GetProperty<string?>(defaultValue: null) : null;
// /// <summary>
// /// Steam 启动参数
// /// </summary>
// public static SerializableProperty<string?> SteamStratParameter => _SteamStratParameter ?? throw new PlatformNotSupportedException();
// //static readonly SerializableProperty<string>? _SteamSkin = IApplication.IsDesktop() ? GetProperty(defaultValue: string.Empty, autoSave: true) : null;
// ///// <summary>
// ///// Steam 皮肤
// ///// </summary>
// //[SupportedOSPlatform("Windows")]
// //[SupportedOSPlatform("macOS")]
// //[SupportedOSPlatform("Linux")]
// //public static SerializableProperty<string> SteamSkin => _SteamSkin ?? throw new PlatformNotSupportedException();
// static readonly SerializableProperty<string>? _SteamProgramPath = IApplication.IsDesktop() ? GetProperty(defaultValue: _service.SteamProgramPath) : null;
// public static SerializableProperty<string> SteamProgramPath => (_CustomSteamPath == null || _CustomSteamPath.Value == null) ? _SteamProgramPath ?? throw new PlatformNotSupportedException() : _CustomSteamPath;
// static readonly SerializableProperty<string>? _CustomSteamPath = IApplication.IsDesktop() ? GetProperty<string>(null, true, "CustomSteamPath") : null;
// public static SerializableProperty<string> CustomSteamPath => _CustomSteamPath ?? throw new PlatformNotSupportedException();
// static readonly SerializableProperty<bool>? _IsAutoRunSteam = IApplication.IsDesktop() ? GetProperty(defaultValue: false) : null;
// /// <summary>
// /// 自动运行 Steam
// /// </summary>
// public static SerializableProperty<bool> IsAutoRunSteam => _IsAutoRunSteam ?? throw new PlatformNotSupportedException();
// static readonly SerializableProperty<bool>? _IsRunSteamMinimized = IApplication.IsDesktop() ? GetProperty(defaultValue: false) : null;
// /// <summary>
// /// Steam 启动时最小化到托盘
// /// </summary>
// public static SerializableProperty<bool> IsRunSteamMinimized => _IsRunSteamMinimized ?? throw new PlatformNotSupportedException();
// static readonly SerializableProperty<bool>? _IsRunSteamNoCheckUpdate = IApplication.IsDesktop() ? GetProperty(defaultValue: false) : null;
// /// <summary>
// /// Steam 启动时不检查更新
// /// </summary>
// public static SerializableProperty<bool> IsRunSteamNoCheckUpdate => _IsRunSteamNoCheckUpdate ?? throw new PlatformNotSupportedException();
// static readonly SerializableProperty<bool>? _IsRunSteamChina = IApplication.IsDesktop() ? GetProperty(defaultValue: false) : null;
// /// <summary>
// /// Steam 启动时模拟为蒸汽平台(Steam国服)启动
// /// </summary>
// public static SerializableProperty<bool> IsRunSteamChina => _IsRunSteamChina ?? throw new PlatformNotSupportedException();
// static readonly SerializableProperty<bool>? _IsEnableSteamLaunchNotification = IApplication.IsDesktop() ? GetProperty(defaultValue: true) : null;
// /// <summary>
// /// 检测到 Steam 登录时弹出消息通知
// /// </summary>
// public static SerializableProperty<bool> IsEnableSteamLaunchNotification => _IsEnableSteamLaunchNotification ?? throw new PlatformNotSupportedException();
// /// <summary>
// /// Steam 下载完成执行任务
// /// </summary>
// public static SerializableProperty<OSExitMode>? DownloadCompleteSystemEndMode = IApplication.IsDesktop() ? GetProperty(defaultValue: OSExitMode.Sleep) : null;
// static readonly SerializableProperty<bool>? _IsRunSteamAdministrator = IApplication.IsDesktop() ? GetProperty(defaultValue: true) : null;
// /// <summary>
// /// 以管理员权限运行 Steam
// /// </summary>
// public static SerializableProperty<bool> IsRunSteamAdministrator => _IsRunSteamAdministrator ?? throw new PlatformNotSupportedException();
//}
//#endif
@@ -63,7 +63,7 @@ partial class SteamSettings_ : ISettings<SteamSettings_>
[SettingsGeneration]
public static class SteamSettings
{
//private static readonly ISteamService _service = Ioc.Get<ISteamService>();
static readonly ISteamService steamService = Ioc.Get<ISteamService>();
static SteamSettings()
{
@@ -104,10 +104,18 @@ public static class SteamSettings
public static SettingsProperty<string, SteamSettings_> SteamSkin { get; } = new();
/// <inheritdoc cref="ISteamSettings.SteamProgramPath"/>
public static SettingsProperty<string, SteamSettings_> SteamProgramPath = new();
public static SettingsProperty<string, SteamSettings_> SteamProgramPath = new()
{
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
Value = steamService.SteamProgramPath,
#endif
};
/// <inheritdoc cref="ISteamSettings.CustomSteamPath"/>
public static SettingsProperty<string, SteamSettings_> CustomSteamPath { get; } = new();
public static SettingsProperty<string, SteamSettings_> CustomSteamPath { get; } = new()
{
Value = (CustomSteamPath == null || CustomSteamPath.Value == null) ? SteamProgramPath.Value : CustomSteamPath.Value,
};
/// <inheritdoc cref="ISteamSettings.IsAutoRunSteam"/>
public static SettingsProperty<bool, SteamSettings_> IsAutoRunSteam { get; } = new();
@@ -61,7 +61,8 @@ public sealed partial class SettingsPageViewModel : TabItemViewModel
var openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Steam|steam.exe";
openFileDialog.ShowDialog();
SteamSettings.SteamProgramPath.Value = openFileDialog.FileName;
if (openFileDialog.FileName == string.Empty) return;
SteamSettings.CustomSteamPath.Value = openFileDialog.FileName;
}
#endif