Skip to content

Commit

Permalink
Merge pull request #128 from Nexus-Mods/w3-friendly-lo-entry-names
Browse files Browse the repository at this point in the history
W3: adding user friendly names to the load order entries
  • Loading branch information
insomnious authored Jul 31, 2024
2 parents 5f05eb2 + 145ba11 commit 92100a0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
8 changes: 8 additions & 0 deletions game-witcher3/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.6.7]

- Added user friendly names to the load order entries.

## [1.6.5-6]

- Removed dlc load order entries.

## [1.6.4] - 2024-06-12

- Fixed incorrect detection of load order entry names for mixed mods
Expand Down
2 changes: 1 addition & 1 deletion game-witcher3/info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Game: The Witcher 3",
"author": "Black Tree Gaming Ltd.",
"version": "1.6.6",
"version": "1.6.7",
"description": "Support for The Witcher 3"
}
21 changes: 18 additions & 3 deletions game-witcher3/loadOrder.js

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions game-witcher3/loadOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,32 @@ class TW3LoadOrder implements types.ILoadOrderGameInfo {
if (activeProfile?.id === undefined) {
return Promise.resolve([]);
}
const findName = (val: string) => this.readableNames?.[val] || val;
const findName = (entry: { name: string, VK?: string }) => {
if (this.readableNames?.[entry.name] !== undefined) {
return this.readableNames[entry.name];
}

if (entry.VK === undefined) {
return entry.name;
}

const state = this.mApi.getState();
const mods: { [modId: string]: types.IMod } = util.getSafe(state, ['persistent', 'mods', GAME_ID], {});
const mod: types.IMod = mods[entry.VK];
if (mod === undefined) {
return entry.name;
}

return `${util.renderModName(mod)} (${entry.name})`;
};

try {
const unsorted: { [key: string]: any } = await IniStructure.getInstance(this.mApi, () => this.mPriorityManager).readStructure();
const entries = Object.keys(unsorted).sort((a, b) => unsorted[a].Priority - unsorted[b].Priority).reduce((accum, iter, idx) => {
const entry = unsorted[iter];
accum[iter.startsWith(LOCKED_PREFIX) ? 'locked' : 'regular'].push({
id: iter,
name: findName(iter),
name: findName({ name: iter, VK: entry.VK }),
enabled: entry.Enabled === '1',
modId: entry?.VK ?? iter,
locked: iter.startsWith(LOCKED_PREFIX),
Expand Down

0 comments on commit 92100a0

Please sign in to comment.