Use extension methods to get game metadata

This commit is contained in:
Timothy Baldridge 2019-12-09 15:46:03 -07:00
parent ba556be994
commit df4dcfa761
8 changed files with 14 additions and 14 deletions

View File

@ -73,7 +73,7 @@ namespace Compression.BSA.Test
var state = new NexusDownloader.State
{
ModID = info.Item2.ToString(),
GameName = GameRegistry.Games[info.Item1].NexusName,
GameName = info.Item1.MetaData().NexusName,
FileID = file.file_id.ToString()
};
state.Download(src);

View File

@ -322,13 +322,13 @@ namespace Wabbajack.Lib.NexusApi
public GetModFilesResponse GetModFiles(Game game, int modid)
{
var url = $"https://api.nexusmods.com/v1/games/{GameRegistry.Games[game].NexusName}/mods/{modid}/files.json";
var url = $"https://api.nexusmods.com/v1/games/{game.MetaData().NexusName}/mods/{modid}/files.json";
return GetCached<GetModFilesResponse>(url);
}
public List<MD5Response> GetModInfoFromMD5(Game game, string md5Hash)
{
var url = $"https://api.nexusmods.com/v1/games/{GameRegistry.Games[game].NexusName}/mods/md5_search/{md5Hash}.json";
var url = $"https://api.nexusmods.com/v1/games/{game.MetaData().NexusName}/mods/md5_search/{md5Hash}.json";
return Get<List<MD5Response>>(url);
}

View File

@ -14,7 +14,7 @@ namespace Wabbajack.Lib.NexusApi
public static string GetModURL(Game game, string argModId)
{
return $"https://nexusmods.com/{GameRegistry.Games[game].NexusName}/mods/{argModId}";
return $"https://nexusmods.com/{game.MetaData().NexusName}/mods/{argModId}";
}
public static string FixupSummary(string argSummary)

View File

@ -140,7 +140,7 @@ namespace Wabbajack.Lib.Validation
}
});
var nexus = NexusApi.NexusApiUtils.ConvertGameName(GameRegistry.Games[modlist.GameType].NexusName);
var nexus = NexusApi.NexusApiUtils.ConvertGameName(modlist.GameType.MetaData().NexusName);
modlist.Archives
.Where(a => a.State is NexusDownloader.State)

View File

@ -50,7 +50,7 @@ namespace Wabbajack.Lib
Game = game;
GamePath = gamePath;
GameName = GameRegistry.Games[game].NexusName;
GameName = game.MetaData().NexusName;
VortexFolder = vortexFolder;
DownloadsFolder = downloadsFolder;
StagingFolder = stagingFolder;
@ -261,7 +261,7 @@ namespace Wabbajack.Lib
Directory.EnumerateFiles(GamePath, "vortex.deployment.json", SearchOption.AllDirectories)
.Where(File.Exists)
.Do(f => deploymentFile = f);
var currentGame = GameRegistry.Games[Game];
var currentGame = Game.MetaData();
if (currentGame.AdditionalFolders != null && currentGame.AdditionalFolders.Count != 0)
currentGame.AdditionalFolders.Do(f => Directory.EnumerateFiles(f, "vortex.deployment.json", SearchOption.AllDirectories)
.Where(File.Exists)
@ -300,7 +300,7 @@ namespace Wabbajack.Lib
/// </summary>
private void AddExternalFolder()
{
var currentGame = GameRegistry.Games[Game];
var currentGame = Game.MetaData();
if (currentGame.AdditionalFolders == null || currentGame.AdditionalFolders.Count == 0) return;
currentGame.AdditionalFolders.Do(f =>
{
@ -472,13 +472,13 @@ namespace Wabbajack.Lib
public static string RetrieveDownloadLocation(Game game, string vortexFolderPath = null)
{
vortexFolderPath = vortexFolderPath ?? TypicalVortexFolder();
return Path.Combine(vortexFolderPath, "downloads", GameRegistry.Games[game].NexusName);
return Path.Combine(vortexFolderPath, "downloads", game.MetaData().NexusName);
}
public static string RetrieveStagingLocation(Game game, string vortexFolderPath = null)
{
vortexFolderPath = vortexFolderPath ?? TypicalVortexFolder();
var gameName = GameRegistry.Games[game].NexusName;
var gameName = game.MetaData().NexusName;
return Path.Combine(vortexFolderPath, gameName, "mods");
}
@ -508,7 +508,7 @@ namespace Wabbajack.Lib
public static bool IsActiveVortexGame(Game g)
{
return GameRegistry.Games[g].SupportedModManager == ModManager.Vortex && !GameRegistry.Games[g].Disabled;
return g.MetaData().SupportedModManager == ModManager.Vortex && !GameRegistry.Games[g].Disabled;
}
}

View File

@ -29,7 +29,7 @@ namespace Wabbajack.Lib
IgnoreMissingFiles = true;
#endif
GameInfo = GameRegistry.Games[ModList.GameType];
GameInfo = ModList.GameType.MetaData();
}
protected override bool _Begin()

View File

@ -112,7 +112,7 @@ namespace Wabbajack.Test
new List<string>
{
"[General]",
$"gameName={GameRegistry.Games[game].MO2ArchiveName}",
$"gameName={game.MetaData().MO2ArchiveName}",
$"modID={modid}",
$"fileID={file.file_id}"
});

View File

@ -46,7 +46,7 @@ namespace Wabbajack.Test
File.WriteAllLines(Path.Combine(MO2Folder, "ModOrganizer.ini"), new []
{
"[General]",
$"gameName={GameRegistry.Games[Game].MO2Name}",
$"gameName={Game.MetaData().MO2Name}",
$"gamePath={GameFolder.Replace("\\", "\\\\")}",
$"download_directory={DownloadsFolder}"
});