diff --git a/package.json b/package.json
index b807d5d..7d68842 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "wh3mm",
"productName": "wh3mm",
- "version": "1.33.1",
+ "version": "1.34.0",
"description": "WH3 Mod Manager",
"main": ".webpack/main",
"scripts": {
diff --git a/src/Sidebar.tsx b/src/Sidebar.tsx
index ab3928f..5da97d0 100644
--- a/src/Sidebar.tsx
+++ b/src/Sidebar.tsx
@@ -2,7 +2,14 @@ import Creatable from "react-select/creatable";
import Select, { ActionMeta, SingleValue } from "react-select";
import React, { useCallback, useEffect, useState } from "react";
import { useAppDispatch, useAppSelector } from "./hooks";
-import { addPreset, deletePreset, replacePreset, selectPreset, setFilter } from "./appSlice";
+import {
+ addPreset,
+ deletePreset,
+ replacePreset,
+ selectPreset,
+ setFilter,
+ createOnGameStartPreset,
+} from "./appSlice";
import { Tooltip } from "flowbite-react";
import { UpdateNotification } from "./UpdateNotification";
import OptionsDrawer from "./OptionsDrawer";
@@ -39,6 +46,7 @@ const Sidebar = React.memo(() => {
const lastSelectedPreset: Preset | null = useAppSelector((state) => state.app.lastSelectedPreset);
const playGameClicked = () => {
+ dispatch(createOnGameStartPreset());
window.api?.startGame(mods, {
isMakeUnitsGeneralsEnabled,
isSkipIntroMoviesEnabled,
diff --git a/src/TopBar.tsx b/src/TopBar.tsx
index 7da4e35..5e04591 100644
--- a/src/TopBar.tsx
+++ b/src/TopBar.tsx
@@ -6,6 +6,8 @@ const TopBar = memo(() => {
const mods = useAppSelector((state) => state.app.currentPreset.mods);
const alwaysEnabledMods = useAppSelector((state) => state.app.alwaysEnabledMods);
const hiddenMods = useAppSelector((state) => state.app.hiddenMods);
+ const startArgs = useAppSelector((state) => state.app.startArgs);
+ const isHardwareAccelerationDisabled = startArgs.some((arg) => arg == "-nogpu");
const enabledMods = mods.filter(
(iterMod) => iterMod.isEnabled || alwaysEnabledMods.find((mod) => mod.name === iterMod.name)
@@ -15,7 +17,8 @@ const TopBar = memo(() => {
);
const title =
`WH3 Mod Manager v${appPackage.version}: ${enabledMods.length} mods enabled` +
- (hiddenAndEnabledMods.length > 0 ? ` (${hiddenAndEnabledMods.length} of those hidden)` : "");
+ (hiddenAndEnabledMods.length > 0 ? ` (${hiddenAndEnabledMods.length} of those hidden)` : "") +
+ ((isHardwareAccelerationDisabled && " nogpu") || "");
return (
diff --git a/src/appData.ts b/src/appData.ts
index 1262f00..76d683e 100644
--- a/src/appData.ts
+++ b/src/appData.ts
@@ -15,6 +15,7 @@ interface AppData {
dataPack?: Pack;
overwrittenDataPackedFiles: Record;
enabledMods: Mod[];
+ startArgs: string[];
}
export type AppFolderPaths = { gamePath: string; contentFolder: string };
@@ -33,4 +34,5 @@ export default {
currentlyReadingModPaths: [],
overwrittenDataPackedFiles: {},
enabledMods: [],
+ startArgs: [],
} as AppData;
diff --git a/src/appSlice.ts b/src/appSlice.ts
index 0cb9e15..12c20a9 100644
--- a/src/appSlice.ts
+++ b/src/appSlice.ts
@@ -46,6 +46,7 @@ const appSlice = createSlice({
appFolderPaths: { gamePath: "", contentFolder: "" },
isSetAppFolderPathsDone: false,
overwrittenDataPackedFiles: {},
+ startArgs: [],
} as AppState,
reducers: {
toggleMod: (state: AppState, action: PayloadAction) => {
@@ -109,7 +110,7 @@ const appSlice = createSlice({
state.dataFromConfig.currentPreset.mods
.filter((mod) => mod !== undefined)
- .map((mod) => {
+ .forEach((mod) => {
const existingMod = state.currentPreset.mods.find((statelyMod) => statelyMod.name == mod.name);
if (existingMod) {
existingMod.isEnabled = mod.isEnabled;
@@ -118,6 +119,14 @@ const appSlice = createSlice({
}
});
}
+
+ const appStartIndex = state.presets.findIndex((preset) => preset.name === "On App Start");
+ const newPreset = { name: "On App Start", mods: [...state.currentPreset.mods] };
+ if (appStartIndex != -1) {
+ state.presets.splice(appStartIndex, 1, newPreset);
+ } else {
+ state.presets.push(newPreset);
+ }
},
addMod: (state: AppState, action: PayloadAction) => {
const mod = action.payload;
@@ -298,6 +307,18 @@ const appSlice = createSlice({
state.presets.push(newPreset);
state.lastSelectedPreset = newPreset;
},
+ createOnGameStartPreset: (state: AppState) => {
+ const appStartIndex = state.presets.findIndex((preset) => preset.name === "On Last Game Launch");
+ const newPreset = {
+ name: "On Last Game Launch",
+ mods: [...state.currentPreset.mods],
+ };
+ if (appStartIndex != -1) {
+ state.presets.splice(appStartIndex, 1, newPreset);
+ } else {
+ state.presets.push(newPreset);
+ }
+ },
selectPreset: (state: AppState, action: PayloadAction<[string, PresetSelection]>) => {
const [name, presetSelection] = action.payload;
@@ -463,6 +484,9 @@ const appSlice = createSlice({
setIsDev: (state: AppState, action: PayloadAction) => {
state.isDev = action.payload;
},
+ setStartArgs: (state: AppState, action: PayloadAction) => {
+ state.startArgs = action.payload;
+ },
createdMergedPack: (state: AppState, action: PayloadAction) => {
const path = action.payload;
state.newMergedPacks.push({ path, creationTime: Date.now() });
@@ -499,6 +523,7 @@ export const {
disableAll,
addPreset,
selectPreset,
+ createOnGameStartPreset,
replacePreset,
deletePreset,
setFilter,
@@ -513,6 +538,7 @@ export const {
toggleAreThumbnailsEnabled,
toggleIsClosedOnPlay,
setIsDev,
+ setStartArgs,
setPackHeaderData,
toggleMakeUnitsGenerals,
toggleIsScriptLoggingEnabled,
diff --git a/src/index.d.ts b/src/index.d.ts
index 460b07d..8d53ff6 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -83,6 +83,7 @@ declare global {
isClosedOnPlay: boolean;
isAuthorEnabled: boolean;
isDev: boolean;
+ startArgs: string[];
isMakeUnitsGeneralsEnabled: boolean;
isScriptLoggingEnabled: boolean;
isSkipIntroMoviesEnabled: boolean;
diff --git a/src/index.ts b/src/index.ts
index 7ec6b13..8cd5a18 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -52,6 +52,14 @@ const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
+ console.log("ARGVS:", process.argv);
+ appData.startArgs = process.argv.slice(1);
+
+ if (process.argv.find((arg) => arg == "-nogpu")) {
+ console.log("DISABLED HARDWARE ACCELERATION");
+ app.disableHardwareAcceleration();
+ }
+
process.noAsar = true;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
@@ -956,6 +964,7 @@ if (!gotTheLock) {
ipcMain.on("sendApiExists", async () => {
mainWindow?.webContents.send("handleLog", "API now exists");
mainWindow?.webContents.send("setIsDev", isDev);
+ mainWindow?.webContents.send("setStartArgs", appData.startArgs);
});
};
diff --git a/src/preload.ts b/src/preload.ts
index a2b378c..46c4710 100644
--- a/src/preload.ts
+++ b/src/preload.ts
@@ -33,6 +33,8 @@ const api = {
ipcRenderer.on("createdMergedPack", callback),
setIsDev: (callback: (event: Electron.IpcRendererEvent, isDev: boolean) => void) =>
ipcRenderer.on("setIsDev", callback),
+ setStartArgs: (callback: (event: Electron.IpcRendererEvent, startArgs: string[]) => void) =>
+ ipcRenderer.on("setStartArgs", callback),
packsInSave: (callback: (event: Electron.IpcRendererEvent, packNames: string[]) => void) =>
ipcRenderer.on("packsInSave", callback),
sendApiExists: () => ipcRenderer.send("sendApiExists"),
diff --git a/src/renderer.ts b/src/renderer.ts
index 5c6b87e..ac7dc46 100644
--- a/src/renderer.ts
+++ b/src/renderer.ts
@@ -21,6 +21,7 @@ import {
setOverwrittenDataPackedFiles,
setDataModLastChangedLocal,
selectDBTable,
+ setStartArgs,
} from "./appSlice";
import store from "./store";
import { PackCollisions } from "./packFileTypes";
@@ -70,6 +71,11 @@ window.api?.setIsDev((event, isDev) => {
store.dispatch(setIsDev(isDev));
});
+window.api?.setStartArgs((event, startArgs) => {
+ console.log("Start args are:", startArgs);
+ store.dispatch(setStartArgs(startArgs));
+});
+
window.api?.packsInSave((event, packNames: string[]) => {
console.log("packs in save: ", packNames);
store.dispatch(enableModsByName(packNames));