Use the correct nexus game id

Instead of the internal vortex game id.
This commit is contained in:
Tyler Hallada 2022-03-23 21:56:29 -04:00
parent d67e75af4a
commit 01a58f45cf
2 changed files with 13 additions and 2 deletions

View File

@ -31,5 +31,8 @@
},
"dependencies": {
"url-loader": "^4.1.1"
},
"config": {
"extensionName": "Modmapper integration"
}
}

View File

@ -16,6 +16,11 @@ const excludedPlugins = [
"Dragonborn.esm",
].map(s => s.toLowerCase());
const gameIdConversions = {
'skyrimse': 'skyrimspecialedition',
'skyrimvr': 'skyrimspecialedition',
};
const modmapperModUrl = (gameId: string, modId: number): string => `${modMapperBase}?mod=${modId}&game=${gameId}`;
const modmapperPluginUrl = (hash: string): string => `${modMapperBase}?plugin=${hash}`;
@ -41,8 +46,11 @@ function main(context: IExtensionContext) {
const mod = util.getSafe(state, ['persistent', 'mods', gameId, instanceIds[0]], undefined);
// could not find the mod in the state.
if (!mod) return;
// Is this mod from gather the info about the mod.
const game: string = mod.attributes?.downloadGame;
// Get nexus game id for the mod.
const downloadGame: string = mod.attributes?.downloadGame;
const knownGames = util.getSafe(state, ['session', 'gameMode', 'known'], []);
const game = knownGames.find(g => g.id === downloadGame)?.details?.nexusPageId ?? gameIdConversions[downloadGame] ?? downloadGame;
const modId: number = mod.attributes?.modId;
return util.opn(modmapperModUrl(game, modId)).catch((err) => log('error', 'Could not open web page', err));
},