Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
insomnious committed Jan 21, 2025
2 parents f936bee + 230bda7 commit 1bc2a0b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/extensions/file_based_loadorder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,13 @@ export default function init(context: IExtensionContext) {

context.registerActionCheck('SET_FB_LOAD_ORDER', (state, action: any) => {
const { profileId, loadOrder } = action.payload;
if (!loadOrder || !Array.isArray(loadOrder)) {
log('error', 'invalid load order', loadOrder);
}
const profile = selectors.profileById(state, profileId);
if (updateSet && profile !== undefined) {
updateSet.init(profile.gameId, loadOrder.map((lo, idx) => ({ ...lo, index: idx })));
const gameId = profile?.gameId ?? selectors.activeGameId(state);
if (updateSet && gameId) {
updateSet.init(gameId, (loadOrder ?? []).map((lo, idx) => ({ ...lo, index: idx })));
}
return undefined;
});
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/gamemode_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ function init(context: IExtensionContext): boolean {
context.registerModType = registerModType;

context.registerGameInfoProvider('game-path', 0, 1000,
['path'], (game: IGame & IDiscoveryResult) => (game.path === undefined)
['path'], (game: IGame & IDiscoveryResult) => (game.path == null || typeof game.path !== 'string')
? Promise.resolve({})
: Promise.resolve({
path: { title: 'Path', value: path.normalize(game.path), type: 'url' },
Expand All @@ -633,7 +633,7 @@ function init(context: IExtensionContext): boolean {
const discoveredGames = context.api.store.getState().settings.gameMode.discovered;
let gamePath = getSafe(discoveredGames, [instanceIds[0], 'path'], undefined);

if (gamePath !== undefined) {
if (gamePath != null) {
if (!gamePath.endsWith(path.sep)) {
gamePath += path.sep;
}
Expand Down
30 changes: 26 additions & 4 deletions src/extensions/mod_management/views/ModList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ interface IConnectedProps extends IModProps {
downloadPath: string;
showDropzone: boolean;
autoInstall: boolean;
// some mod actions are not allowed while installing dependencies/collections
// e.g. combining a mod with other patch mods while the collection is still installing.
suppressModActions: boolean;
}

interface IActionProps {
Expand Down Expand Up @@ -1473,19 +1476,27 @@ class ModList extends ComponentEx<IProps, IComponentState> {
}

private canBeCombined = (modIds: string[]) => {
const { t, mods } = this.props;
const { t, mods, suppressModActions } = this.props;

const notInstalled = modIds.find(modId => mods[modId] === undefined);
if (notInstalled !== undefined) {
return t('You can only combine installed mods') ;
}

if (suppressModActions) {
return t('Try again after installing dependencies');
}

return true;
}

private combine = (modIds: string[]) => {
const { gameMode } = this.props;
const { gameMode, suppressModActions } = this.props;
const { api } = this.context;

if (suppressModActions) {
api.showErrorNotification('Try again after installing dependencies', 'Mod actions are currently disabled', { allowReport: false });
return;
}
return combineMods(api, gameMode, modIds);
}

Expand Down Expand Up @@ -1530,10 +1541,20 @@ class ModList extends ComponentEx<IProps, IComponentState> {

const empty = {};

const shouldSuppressModActions = (state: IState): boolean => {
const suppressOnActivities = ['conflicts', 'installing_dependencies', 'deployment', 'purging'];
const isActivityRunning = (activity: string) =>
getSafe(state, ['session', 'base', 'activity', 'mods'], []).includes(activity) // purge/deploy
|| getSafe(state, ['session', 'base', 'activity', activity], []).length > 0; // installing_dependencies
const suppressingActivities = suppressOnActivities.filter(activity => isActivityRunning(activity));
const suppressing = suppressingActivities.length > 0;
return suppressing;
}

function mapStateToProps(state: IState): IConnectedProps {
const profile = selectors.activeProfile(state);
const gameMode = selectors.activeGameId(state);

const suppressModActions = shouldSuppressModActions(state);
return {
mods: getSafe(state, ['persistent', 'mods', gameMode], empty),
modState: getSafe(profile, ['modState'], empty),
Expand All @@ -1545,6 +1566,7 @@ function mapStateToProps(state: IState): IConnectedProps {
downloadPath: selectors.downloadPath(state),
showDropzone: state.settings.mods.showDropzone,
autoInstall: state.settings.automation.install,
suppressModActions,
};
}

Expand Down

0 comments on commit 1bc2a0b

Please sign in to comment.