Skip to content

Commit

Permalink
Merge pull request #124 from BUTR/dev
Browse files Browse the repository at this point in the history
Release 1.0.13
  • Loading branch information
Aragas committed Jun 9, 2024
2 parents 407d297 + f14495e commit 52f6c86
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 56 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.13
* Added mandatory folders for manual game path hint
* Fixed undefined tools bug
---------------------------------------------------------------------------------------------------
Version: 1.0.12
* Fixed undefined gameId bug
* Reusing localization from BLSE
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "game-mount-and-blade-ii-bannerlord-butr",
"version": "1.0.12",
"version": "1.0.13",
"description": "A Vortex extension for Mount and Blade II: Bannerlord mod management.",
"author": "BUTR Team & Nexus Mods",
"license": "GPL-3.0+",
Expand Down
2 changes: 1 addition & 1 deletion src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class BannerlordGame implements types.IGame {
gog: GOG_IDS.map((x) => ({ id: x })),
epic: [{ id: EPICAPP_ID }],
};
public requiredFiles: string[] = [];
public requiredFiles: string[] = ['bin', 'Modules'];
public parameters: string[] = [];
public requiresCleanup = true;
public details: { [key: string]: unknown } = {
Expand Down
72 changes: 36 additions & 36 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ const main = (context: types.IExtensionContext): boolean => {
return SaveManager.getInstance(context.api, getLauncherManager);
};

context.registerReducer([`settings`, GAME_ID], reducer);
context.registerReducer(/*path:*/ [`settings`, GAME_ID], /*spec:*/ reducer);

context.registerSettings(
`Interface`,
Settings,
(): ISettingsProps => ({
/*title:*/ `Interface`,
/*element:*/ Settings,
/*props?:*/ (): ISettingsProps => ({
getLocalizationManager: getLocalizationManager,
onSetSortOnDeploy: (profileId: string, sort: boolean) =>
context.api.store?.dispatch(actionsSettings.setSortOnDeploy(profileId, sort)),
Expand All @@ -56,10 +56,10 @@ const main = (context: types.IExtensionContext): boolean => {
onSetBetaSorting: (profileId: string, betaSorting: boolean) =>
context.api.store?.dispatch(actionsSettings.setBetaSorting(profileId, betaSorting)),
}),
() => {
/*visible?:*/ () => {
return selectors.activeGameId(context.api.getState()) === GAME_ID;
},
51
/*priority?:*/ 51
);

context.registerGame(new BannerlordGame(context.api, getLauncherManager, getLocalizationManager));
Expand All @@ -80,60 +80,60 @@ const main = (context: types.IExtensionContext): boolean => {
}
*/

context.registerLoadOrder(getLoadOrderManager());
context.registerLoadOrder(/*gameInfo:*/ getLoadOrderManager());

context.registerMainPage(
'savegame',
'Saves',
SaveList,
new SavePageOptions(context, getLauncherManager, getSaveManager, getLocalizationManager)
/*icon:*/ 'savegame',
/*title:*/ 'Saves',
/*element:*/ SaveList,
/*options:*/ new SavePageOptions(context, getLauncherManager, getSaveManager, getLocalizationManager)
);

context.registerInstaller(
'bannerlord-blse-installer',
30,
toBluebird(testBLSE),
toBluebird((files: string[]) => installBLSE(context.api, files))
/*id:*/ 'bannerlord-blse-installer',
/*priority:*/ 30,
/*testSupported:*/ toBluebird(testBLSE),
/*install:*/ toBluebird((files: string[]) => installBLSE(context.api, files))
);
context.registerModType(
'bannerlord-blse',
30,
(gameId) => gameId === GAME_ID,
(game) => getInstallPathBLSE(context.api, game),
toBluebird(isModTypeBLSE)
/*id:*/ 'bannerlord-blse',
/*priority:*/ 30,
/*isSupported:*/ (gameId) => gameId === GAME_ID,
/*getPath:*/ (game) => getInstallPathBLSE(context.api, game),
/*test:*/ toBluebird(isModTypeBLSE)
);

context.registerInstaller(
`bannerlord-module-installer`,
25,
toBluebird(async (files: string[], gameId: string) => {
/*id:*/ `bannerlord-module-installer`,
/*priority:*/ 25,
/*testSupported:*/ toBluebird(async (files: string[], gameId: string) => {
const launcherManager = getLauncherManager();
return await launcherManager.testModule(files, gameId);
}),
toBluebird(async (files: string[], destinationPath: string) => {
/*install:*/ toBluebird(async (files: string[], destinationPath: string) => {
const launcherManager = getLauncherManager();
return await launcherManager.installModule(files, destinationPath);
})
);
context.registerModType(
'bannerlord-module',
25,
(gameId) => gameId === GAME_ID,
(game) => getInstallPathModule(context.api, game),
toBluebird(isModTypeModule)
/*id:*/ 'bannerlord-module',
/*priority:*/ 25,
/*isSupported:*/ (gameId) => gameId === GAME_ID,
/*getPath:*/ (game) => getInstallPathModule(context.api, game),
/*test:*/ toBluebird(isModTypeModule)
);

context.registerAction(
`fb-load-order-icons`,
200,
`loot-sort`,
{},
`Auto Sort`,
(_instanceIds?: string[]): boolean | void => {
/*group:*/ `fb-load-order-icons`,
/*position:*/ 200,
/*iconOrComponent:*/ `loot-sort`,
/*options:*/ {},
/*titleOrProps?:*/ `Auto Sort`,
/*actionOrCondition?:*/ (_instanceIds?: string[]): boolean | void => {
const launcherManager = getLauncherManager();
launcherManager.autoSort();
},
(_instanceIds?: string[]): boolean => {
/*condition?:*/ (_instanceIds?: string[]): boolean => {
const state = context.api.getState();
const gameId = selectors.activeGameId(state);
return gameId === GAME_ID;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/blse/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const deployBLSE = async (api: types.IExtensionApi): Promise<void> => {
await util.toPromise((cb) => api.events.emit('start-quick-discovery', () => cb(null)));

const discovery = selectors.currentGameDiscovery(api.getState());
const tool = discovery.tools?.['blse-cli'];
const tool = discovery?.tools?.['blse-cli'];
if (tool) {
api.store?.dispatch(actions.setPrimaryTool(GAME_ID, tool.id));
}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/settings/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { hasSettings, hasSettingsBannerlord } from '..';

export const getSortOnDeployFromSettings = (state: unknown, profileId: string) => {
export const getSortOnDeployFromSettings = (state: object, profileId: string) => {
if (!hasSettings(state)) {
return null;
}
Expand All @@ -12,7 +12,7 @@ export const getSortOnDeployFromSettings = (state: unknown, profileId: string) =
return state.settings.mountandblade2bannerlord?.sortOnDeploy?.[profileId];
};

export const getFixCommonIssuesFromSettings = (state: unknown, profileId: string) => {
export const getFixCommonIssuesFromSettings = (state: object, profileId: string) => {
if (!hasSettings(state)) {
return null;
}
Expand All @@ -24,7 +24,7 @@ export const getFixCommonIssuesFromSettings = (state: unknown, profileId: string
return state.settings.mountandblade2bannerlord?.fixCommonIssues?.[profileId];
};

export const getBetaSortingFromSettings = (state: unknown, profileId: string) => {
export const getBetaSortingFromSettings = (state: object, profileId: string) => {
if (!hasSettings(state)) {
return null;
}
Expand All @@ -36,7 +36,7 @@ export const getBetaSortingFromSettings = (state: unknown, profileId: string) =>
return state.settings.mountandblade2bannerlord?.betaSorting?.[profileId];
};

export const getSaveFromSettings = (state: unknown, profileId: string) => {
export const getSaveFromSettings = (state: object, profileId: string) => {
if (!hasSettings(state)) {
return null;
}
Expand Down
19 changes: 8 additions & 11 deletions src/utils/vortex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { BLSE_CLI_EXE, GAME_ID, XBOX_ID } from '../common';
import {
ISettingsWithBannerlord,
ISettingsInterfaceWithPrimaryTool,
IStatePersistent,
IStatePersistentWithLoadOrder,
GetLocalizationManager,
GetLauncherManager,
Expand All @@ -31,22 +30,20 @@ type RequiresLauncherResult = {
addInfo?: unknown;
};

export const hasPersistentLoadOrder = (persistent: IStatePersistent): persistent is IStatePersistentWithLoadOrder => {
return typeof (persistent as never)[nameof<IStatePersistentWithLoadOrder>('loadOrder')] === 'object';
export const hasPersistentLoadOrder = (persistent: object): persistent is IStatePersistentWithLoadOrder => {
return nameof<IStatePersistentWithLoadOrder>('loadOrder') in persistent;
};

export const hasSettings = (hasSettings: unknown): hasSettings is HasSettings => {
return typeof (hasSettings as never)[nameof<HasSettings>('settings')] === 'object';
export const hasSettings = (hasSettings: object): hasSettings is HasSettings => {
return nameof<HasSettings>('settings') in hasSettings;
};

export const hasSettingsBannerlord = (settings: types.ISettings): settings is ISettingsWithBannerlord => {
return typeof (settings as never)[GAME_ID] === 'object';
export const hasSettingsBannerlord = (settings: object): settings is ISettingsWithBannerlord => {
return GAME_ID in settings;
};

export const hasSettingsInterfacePrimaryTool = (
settings: types.ISettingsInterface
): settings is ISettingsInterfaceWithPrimaryTool => {
return typeof (settings as never)[nameof<ISettingsInterfaceWithPrimaryTool>('primaryTool')] === 'object';
export const hasSettingsInterfacePrimaryTool = (settings: object): settings is ISettingsInterfaceWithPrimaryTool => {
return nameof<ISettingsInterfaceWithPrimaryTool>('primaryTool') in settings;
};

const launchGameStore = async (api: types.IExtensionApi, store: string): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/vortexLauncherManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export class VortexLauncherManager {
const params = gameParameters.filter((x) => x !== ' ' && x.length > 0).join(' ');

const discovery = selectors.currentGameDiscovery(this._api.getState());
const cliTools = Object.values(discovery.tools ?? {}).filter((tool) => tool.id && tool.id.endsWith('-cli'));
const cliTools = Object.values(discovery?.tools ?? {}).filter((tool) => tool.id && tool.id.endsWith('-cli'));
const batchedActions = cliTools.map((tool) =>
actions.addDiscoveredTool(GAME_ID, tool.id, { ...tool, parameters: [params] }, true)
);
Expand Down Expand Up @@ -419,7 +419,7 @@ export class VortexLauncherManager {
private getInstallPath = (): string => {
const state = this._api.getState();
const discovery = selectors.currentGameDiscovery(state);
return discovery.path ?? '';
return discovery?.path ?? '';
};
/**
* Callback
Expand Down

0 comments on commit 52f6c86

Please sign in to comment.