-
Notifications
You must be signed in to change notification settings - Fork 54
/
index.js
91 lines (79 loc) · 2.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const Promise = require('bluebird');
const path = require('path');
const { fs, selectors, util } = require('vortex-api');
const GAME_ID = 'conanexiles';
const STEAMAPP_ID = 440900;
const STOP_PATTERNS = ['[^/]*\\.pak$'];
function toWordExp(input) {
return '(^|/)' + input + '(/|$)';
}
function queryPath() {
return util.GameStoreHelper.findByAppId([STEAMAPP_ID])
.then(game => game.gamePath);
}
function modlistPath(gamePath) {
return path.join(gamePath, 'ConanSandbox', 'Mods', 'modlist.txt');
}
function queryModPath() {
return path.join('ConanSandbox', 'Mods');
}
async function setup(discovery) {
await fs.ensureDirWritableAsync(path.join(discovery.path, queryModPath()));
}
async function writeLoadOrder(api, order) {
try {
const state = api.getState();
const discovery = selectors.discoveryByGame(state, GAME_ID);
if (discovery.path === undefined) {
return;
}
const stagingPath = selectors.installPathForGame(state, GAME_ID);
const paths = [];
await Promise.all(Object.keys(order)
.sort((lhs, rhs) => order[lhs].pos - order[rhs].pos)
.map(async modId => {
const files = await fs.readdirAsync(path.join(stagingPath, modId));
files
.filter(name => path.extname(name).toLowerCase() === '.pak')
.forEach(name => paths.push(path.join(stagingPath, modId, name)));
}));
await util.writeFileAtomic(modlistPath(discovery.path), paths.join('\n'));
} catch (err) {
api.showErrorNotification('Failed to write mod list', err);
}
}
function main(context) {
context.registerGame({
id: GAME_ID,
name: 'Conan Exiles',
logo: 'gameart.jpg',
mergeMods: true,
queryPath,
queryModPath,
executable: () => path.join('ConanSandbox', 'Binaries', 'Win64', 'ConanSandbox.exe'),
requiredFiles: ['ConanSandbox.exe'],
setup,
environment: {
SteamAPPId: STEAMAPP_ID.toString(),
},
details: {
steamAppId: STEAMAPP_ID,
stopPattern: STOP_PATTERNS.map(toWordExp),
},
compatible: {
nulldeployment: true
}
});
context.registerLoadOrderPage({
gameId: GAME_ID,
createInfoPanel: (props) =>
context.api.translate('Please refer to mod descriptions from mod authors to determine the right order. '
+ 'If you can\'t find any suggestions for a mod, it probably doesn\'t matter.'),
gameArtURL: `${__dirname}/gameart.jpg`,
callback: (loadOrder) => writeLoadOrder(context.api, loadOrder),
});
return true;
}
module.exports = {
default: main
};