Skip to content

Commit

Permalink
Handle Game Channel IDs
Browse files Browse the repository at this point in the history
Currently the ChannelIDs get enforced only when importing the game, updating the game, and when the config.ini is intialized
  • Loading branch information
bagusnl committed Dec 8, 2023
1 parent fc35d5e commit 5e269f6
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ internal class GameVersionBase : IGameVersionCheck
private const string _defaultIniProfileSection = "launcher";
private const string _defaultIniVersionSection = "General";
private string _defaultGameDirPath { get => Path.Combine(LauncherConfig.AppGameFolder, GamePreset.ProfileName, GamePreset.GameDirectoryName); }


private readonly int gameChannelID = new PresetConfigV2().ChannelID;
private readonly int gameSubChannelID = new PresetConfigV2().SubChannelID;

private IniSection _defaultIniProfile
{
get => new IniSection()
{
{ "cps", new IniValue() },
{ "channel", new IniValue("1") },
{ "sub_channel", new IniValue("1") },
{ "channel", new IniValue(gameChannelID) },
{ "sub_channel", new IniValue(gameSubChannelID) },
{ "game_install_path", new IniValue(_defaultGameDirPath.Replace('\\', '/')) },
{ "game_start_name", new IniValue(GamePreset.GameExecutableName) },
{ "is_first_exit", new IniValue(false) },
Expand All @@ -38,23 +41,23 @@ private IniSection _defaultIniProfileBilibili
get => new IniSection()
{
{ "cps", new IniValue("bilibili") },
{ "channel", new IniValue("14") },
{ "sub_channel", new IniValue("0") },
{ "channel", new IniValue(gameChannelID) },
{ "sub_channel", new IniValue(gameSubChannelID) },
{ "game_install_path", new IniValue(_defaultGameDirPath.Replace('\\', '/')) },
{ "game_start_name", new IniValue(GamePreset.GameExecutableName) },
{ "is_first_exit", new IniValue(false) },
{ "exit_type", new IniValue(2) }
};
}

private IniSection _defaultIniVersion
{
get => new IniSection()
{
{ "channel", new IniValue(1) },
{ "channel", new IniValue(gameChannelID) },
{ "cps", new IniValue() },
{ "game_version", new IniValue() },
{ "sub_channel", new IniValue(1) },
{ "sub_channel", new IniValue(gameSubChannelID) },
{ "sdk_version", new IniValue() }
};
}
Expand All @@ -63,10 +66,10 @@ private IniSection _defaultIniVersionBilibili
{
get => new IniSection()
{
{ "channel", new IniValue(14) },
{ "channel", new IniValue(gameChannelID) },
{ "cps", new IniValue("bilibili") },
{ "game_version", new IniValue() },
{ "sub_channel", new IniValue(0) },
{ "sub_channel", new IniValue(gameSubChannelID) },
{ "sdk_version", new IniValue() }
};
}
Expand All @@ -93,7 +96,11 @@ protected string GameIniVersionPath
public string GameDirPath
{
get => Path.GetDirectoryName(GameIniVersionPath);
set => UpdateGamePath(value, false);
set
{
UpdateGamePath(value, false);
UpdateGameChannels(true);
}
}
public string GameDirAppDataPath
{
Expand Down Expand Up @@ -153,7 +160,11 @@ protected GameVersion? GameVersionInstalled
// If not, then return as null
return null;
}
set => UpdateGameVersion(value ?? GameVersionAPI);
set
{
UpdateGameVersion(value ?? GameVersionAPI);
UpdateGameChannels(true);
}
}

protected GameVersion? PluginVersionInstalled
Expand Down Expand Up @@ -395,6 +406,7 @@ public void UpdateGameVersionToLatest(bool saveValue = true)
if (saveValue)
{
SaveGameIni(GameIniVersionPath, GameIniVersion);
UpdateGameChannels(true);
}
}

Expand All @@ -407,6 +419,18 @@ public void UpdateGameVersion(GameVersion version, bool saveValue = true)
}
}

public void UpdateGameChannels(bool saveValue = true)
{
GameIniVersion[_defaultIniVersionSection]["channel"] = gameChannelID;
GameIniVersion[_defaultIniVersionSection]["sub_channel"] = gameSubChannelID;

if (GamePreset.ZoneName == "Bilibili")
GameIniVersion[_defaultIniVersionSection]["cps"] = "bilibili";

if (saveValue)
SaveGameIni(GameIniVersionPath, GameIniVersion);
}

public void UpdatePluginVersion(GameVersion version, bool saveValue = true)
{
// If the plugin is empty, ignore it
Expand Down
17 changes: 8 additions & 9 deletions CollapseLauncher/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
},
"ImageEx": {
"type": "Direct",
"requested": "[2.0.0, )",
"resolved": "2.0.0",
"contentHash": "kp894Xue0YIflPIao+bEEB65si250ne1sFqDd4aA7pTjQn4TGScuopojx/73vfRKcEsxgclbWjEAlKqGSYqiQA==",
"requested": "[2.1.1, )",
"resolved": "2.1.1",
"contentHash": "aYLuAjSv96ERPpdlLw2EhCaE9S6jx48hnyhZbZpp4ptl1HqbTSPa0ilmD2ERvr81i2U6MaaoQ3MPaiUK/HNHkQ==",
"dependencies": {
"Microsoft.WindowsAppSDK": "1.0.0"
}
Expand All @@ -96,12 +96,6 @@
"Microsoft.WindowsAppSDK": "1.4.231115000"
}
},
"Microsoft.NETCore.Platforms": {
"type": "Direct",
"requested": "[8.0.0-preview.7.23375.6, )",
"resolved": "8.0.0-preview.7.23375.6",
"contentHash": "ym5B/aglUc4K5kkiBOOgsm7EETjenJBbMchAHvcXpfFPmrdTrhnLKC1Tvx5Qnz5kHvhloyCNTpGQvWIpxvINHg=="
},
"Microsoft.Windows.CsWinRT": {
"type": "Direct",
"requested": "[2.0.4, )",
Expand Down Expand Up @@ -376,6 +370,11 @@
"resolved": "4.7.0",
"contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA=="
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "TMBuzAHpTenGbGgk0SMTwyEkyijY/Eae4ZGsFNYJvAr/LDn1ku3Etp3FPxChmDp5HHF3kzJuoaa08N0xjqAJfQ=="
},
"Microsoft.NETCore.Targets": {
"type": "Transitive",
"resolved": "1.1.3",
Expand Down
53 changes: 28 additions & 25 deletions Hi3Helper.Core/Classes/Preset/Classes/PresetConfigV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,31 +515,34 @@ private bool CheckInnerGameConfig(in string GamePath)
#nullable disable
public string GameExecutableName { get; set; }
#nullable enable
public string? GameDispatchURL { get; set; }
public string[]? GameSupportedLanguages { get; set; }
public string[]? GameDispatchArrayURL { get; set; }
public string? GameDispatchChannelName { get; set; }
public string? GameDispatchDefaultName { get; set; }
public string? GameDispatchURLTemplate { get; set; }
public string? GameGatewayURLTemplate { get; set; }
public string? GameGatewayDefault { get; set; }
public AudioLanguageType GameDefaultCVLanguage { get; set; }
public string? ProtoDispatchKey { get; set; }
public bool? IsGenshin { get; set; }
public bool? IsConvertible { get; set; }
public bool IsHideSocMedDesc { get; set; } = true;
public List<string>? ConvertibleTo { get; set; }
public GameType GameType { get; set; } = GameType.Unknown;
public GameType FallbackGameType { get; set; } = GameType.Unknown;
public GameVendorType VendorType { get; set; } = GameVendorType.miHoYo;
public bool? UseRightSideProgress { get; set; }
public bool LauncherSpriteURLMultiLang { get; set; }
public string? LauncherSpriteURLMultiLangFallback { get; set; }
public string? LauncherPluginURL { get; set; }
public string? LauncherSpriteURL { get; set; }
public string? LauncherResourceURL { get; set; }
public string? DispatcherKey { get; set; }
public int? DispatcherKeyBitLength { get; set; }
public string? GameDispatchURL { get; set; }
public string[]? GameSupportedLanguages { get; set; }
public string[]? GameDispatchArrayURL { get; set; }
public string? GameDispatchChannelName { get; set; }
public string? GameDispatchDefaultName { get; set; }
public string? GameDispatchURLTemplate { get; set; }
public string? GameGatewayURLTemplate { get; set; }
public string? GameGatewayDefault { get; set; }
public AudioLanguageType GameDefaultCVLanguage { get; set; }
public string? ProtoDispatchKey { get; set; }
public bool? IsGenshin { get; set; }
public bool? IsConvertible { get; set; }
public bool IsHideSocMedDesc { get; set; } = true;
public List<string>? ConvertibleTo { get; set; }
public GameType GameType { get; set; } = GameType.Unknown;
public GameType FallbackGameType { get; set; } = GameType.Unknown;
public GameVendorType VendorType { get; set; } = GameVendorType.miHoYo;
public int LauncherID { get; set; }
public int ChannelID { get; set; }
public int SubChannelID { get; set; }
public bool? UseRightSideProgress { get; set; }
public bool LauncherSpriteURLMultiLang { get; set; }
public string? LauncherSpriteURLMultiLangFallback { get; set; }
public string? LauncherPluginURL { get; set; }
public string? LauncherSpriteURL { get; set; }
public string? LauncherResourceURL { get; set; }
public string? DispatcherKey { get; set; }
public int? DispatcherKeyBitLength { get; set; }
#if DEBUG
public bool? IsRepairEnabled = true;
public bool? IsCacheUpdateEnabled = true;
Expand Down

0 comments on commit 5e269f6

Please sign in to comment.