refine game service

This commit is contained in:
Lightczx
2023-05-14 22:43:50 +08:00
parent 46f58730dc
commit 5fe38f305b
4 changed files with 21 additions and 15 deletions

View File

@@ -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()
{

View File

@@ -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"));
}
}
}

View File

@@ -90,7 +90,7 @@ internal interface IGameService
/// </summary>
/// <param name="scheme">方案</param>
/// <returns>是否更改了ini文件</returns>
bool SetMultiChannel(LaunchScheme scheme);
bool SetChannelOptions(LaunchScheme scheme);
/// <summary>
/// 检测账号

View File

@@ -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();