mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-18 03:12:18 +12:00
minor cleanup to alias resolution
This commit is contained in:
parent
1c8ae4e604
commit
223da16d7f
|
@ -120,11 +120,11 @@ namespace ModAssistant
|
|||
|
||||
resp = await HttpClient.GetAsync(Utils.Constants.BeatModsAlias);
|
||||
body = await resp.Content.ReadAsStringAsync();
|
||||
object jsonObject = JsonSerializer.DeserializeObject(body);
|
||||
Dictionary<string, string[]> aliases = JsonSerializer.Deserialize<Dictionary<string, string[]>>(body);
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
GameVersion = GetGameVersion(versions, jsonObject);
|
||||
GameVersion = GetGameVersion(versions, aliases);
|
||||
|
||||
GameVersionsBox.ItemsSource = versions;
|
||||
GameVersionsBox.SelectedValue = GameVersion;
|
||||
|
@ -157,7 +157,7 @@ namespace ModAssistant
|
|||
}
|
||||
}
|
||||
|
||||
private string GetGameVersion(List<string> versions, object aliases)
|
||||
private string GetGameVersion(List<string> versions, Dictionary<string, string[]> aliases)
|
||||
{
|
||||
string version = Utils.GetVersion();
|
||||
if (!string.IsNullOrEmpty(version) && versions.Contains(version))
|
||||
|
@ -190,25 +190,21 @@ namespace ModAssistant
|
|||
return versions[0];
|
||||
}
|
||||
|
||||
private string CheckAliases(List<string> versions, object aliases, string detectedVersion)
|
||||
private string CheckAliases(List<string> versions, Dictionary<string, string[]> aliasesDict, string detectedVersion)
|
||||
{
|
||||
Dictionary<string, object> Objects = (Dictionary<string, object>)aliases;
|
||||
Dictionary<string, List<string>> aliases = aliasesDict.ToDictionary(x => x.Key, x => x.Value.ToList());
|
||||
foreach (string version in versions)
|
||||
{
|
||||
object x;
|
||||
if (Objects.TryGetValue(version, out x))
|
||||
if (aliases.TryGetValue(version, out var x))
|
||||
{
|
||||
object[] aliasArray = (object[])x;
|
||||
foreach (object alias in aliasArray)
|
||||
if (x.Contains(detectedVersion))
|
||||
{
|
||||
if (alias.ToString() == detectedVersion)
|
||||
{
|
||||
GameVersionOverride = detectedVersion;
|
||||
return version;
|
||||
}
|
||||
GameVersionOverride = detectedVersion;
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue