mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
refine game service
This commit is contained in:
@@ -30,6 +30,22 @@ internal sealed class IniParameter : IniElement
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置值
|
||||
/// </summary>
|
||||
/// <param name="value">值</param>
|
||||
/// <returns>是否修改了值</returns>
|
||||
public bool Set(string value)
|
||||
{
|
||||
if (Value != value)
|
||||
{
|
||||
Value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -131,7 +131,7 @@ internal sealed partial class GameService : IGameService
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool SetMultiChannel(LaunchScheme scheme)
|
||||
public bool SetChannelOptions(LaunchScheme scheme)
|
||||
{
|
||||
string gamePath = appOptions.GamePath;
|
||||
string configPath = Path.Combine(Path.GetDirectoryName(gamePath)!, ConfigFileName);
|
||||
@@ -165,22 +165,12 @@ internal sealed partial class GameService : IGameService
|
||||
{
|
||||
if (parameter.Key == "channel")
|
||||
{
|
||||
string channel = scheme.Channel.ToString("D");
|
||||
if (parameter.Value != channel)
|
||||
{
|
||||
parameter.Value = channel;
|
||||
changed = true;
|
||||
}
|
||||
changed = parameter.Set(scheme.Channel.ToString("D"));
|
||||
}
|
||||
|
||||
if (parameter.Key == "sub_channel")
|
||||
{
|
||||
string subChannel = scheme.SubChannel.ToString("D");
|
||||
if (parameter.Value != subChannel)
|
||||
{
|
||||
parameter.Value = subChannel;
|
||||
changed = true;
|
||||
}
|
||||
changed = parameter.Set(scheme.SubChannel.ToString("D"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ internal interface IGameService
|
||||
/// </summary>
|
||||
/// <param name="scheme">方案</param>
|
||||
/// <returns>是否更改了ini文件</returns>
|
||||
bool SetMultiChannel(LaunchScheme scheme);
|
||||
bool SetChannelOptions(LaunchScheme scheme);
|
||||
|
||||
/// <summary>
|
||||
/// 检测账号
|
||||
|
||||
@@ -182,7 +182,7 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
|
||||
{
|
||||
try
|
||||
{
|
||||
if (gameService.SetMultiChannel(SelectedScheme))
|
||||
if (gameService.SetChannelOptions(SelectedScheme))
|
||||
{
|
||||
// Channel changed, we need to change local file.
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
|
||||
Reference in New Issue
Block a user