Skip to content

Commit 4580131

Browse files
committed
v2.0.1
Add shortcut key to mods.json, add dow mod installer icon to desktop, transform tyranids mod into zip file, removed progress bar
1 parent f4d393f commit 4580131

File tree

3 files changed

+74
-38
lines changed

3 files changed

+74
-38
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ I personally use this app to ease the set up process for the 7+ group of friends
1111
## Usage
1212

1313
1. Download the latest version of Dow Mod Installer from the [releases page](https://github.com/kwilson21/DoW_Mod_Installer/releases)
14-
2. Extract `DoW Mod Installer-1.0.0-win.zip` into a folder
14+
2. Extract `DoW Mod Installer-2.0.1-win.zip` into a folder
1515
3. Run `DoW Mod Installer.exe` as administrator
1616
4. Make sure your DoW directory is correct, if not search for the correct directory
1717
5. Download and search for each individual mod file
@@ -32,6 +32,7 @@ Users are free to modify the `mods.json` with their own mods, which they can the
3232
| `download_link` | `string` | A downlink link to the mod |
3333
| `extract_locations` | `list of string` | A list of locations in the DoW Directory to extract to |
3434
| `modifiers` | `list of string` | A list of values to be passed directly to 7zip as a command line argument when extracting the mod see the [7zip command line documentation](https://sevenzip.osdn.jp/chm/cmdline/index.htm) for more info. |
35+
| `shortcut` | `string` | A file name used to create a shortcut on the user's desktop |
3536

3637
## Authors
3738

mods.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
},
66
{
77
"file_name": "DoW_Mod_Manager_v2.0.1.zip",
8-
"download_link": "https://github.com/Fragjacker/DoW-Mod-Manager/releases/download/v2.0.1/DoW_Mod_Manager_v2.0.1.zip"
8+
"download_link": "https://github.com/Fragjacker/DoW-Mod-Manager/releases/download/v2.0.1/DoW_Mod_Manager_v2.0.1.zip",
9+
"shortcut": "DoW Mod Manager v2.0.1.exe"
910
},
1011
{
1112
"file_name": "Red_I_Map_Compilation_Revision_III.zip",
@@ -47,7 +48,7 @@
4748
"download_link": "https://www.mediafire.com/file/uuoa4a8x1fvxovf/ChaosDaemons2.0.2.zip/file"
4849
},
4950
{
50-
"file_name": "Tyranid_Mod_0.5b2_Installer.exe",
51-
"download_link": "https://www.moddb.com/mods/tyranid-mod/downloads/tyranid-mod-v05b2-for-soulstorm"
51+
"file_name": "Tyranid_Mod_0.5b2_Installer.zip",
52+
"download_link": "https://www.mediafire.com/file/8c0ue9ytbky1rur/Tyranid_Mod_0.5b2_Installer.zip/file"
5253
}
5354
]

renderer/components/Mods.jsx

Lines changed: 68 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import isArchive from "is-archive";
1515
import { isEmpty } from "lodash";
1616
import { ToastContainer, toast } from "react-toastify";
1717
import "react-toastify/dist/ReactToastify.css";
18+
import path from "path";
19+
import os from "os";
1820

1921
import electron from "electron";
2022
const unhandled =
@@ -69,40 +71,47 @@ export default function Mods() {
6971
streams: [],
7072
});
7173
const [installing, setInstalling] = useState(false);
72-
const [percent, setPercent] = useState(0);
74+
// const [percent, setPercent] = useState(0);
7375
const [installed, setInstalled] = useState(false);
7476

7577
const isProd = process.env.NODE_ENV === "production";
76-
let pathTo7zip = `${process.cwd()}\\resources\\app.asar.unpacked\\node_modules\\7zip-bin${
78+
let pathTo7zip = path.join(
79+
process.cwd(),
80+
"resources\\app.asar.unpacked\\node_modules\\7zip-bin",
7781
sevenBin.path7za
78-
}`;
82+
);
7983

8084
if (!isProd) {
81-
pathTo7zip = `${process.cwd()}\\node_modules\\7zip-bin${sevenBin.path7za}`;
85+
pathTo7zip = path.join(
86+
process.cwd(),
87+
"node_modules\\7zip-bin",
88+
sevenBin.path7za
89+
);
8290
}
8391

8492
const installMod = (installStream) => {
8593
let { streams, modsToInstall } = installStream;
8694
const mod = modsToInstall.pop();
8795
const idx = configurations.installed_mods.findIndex((e) => e === mod);
96+
const temp = mod.file_path.split("\\");
97+
const file_path = temp[temp.length - 1];
8898

8999
if (fs.existsSync(configurations.dow_directory)) {
90-
if (mod.file_name.endsWith(".exe")) {
91-
child.execFileSync(mod.file_path);
100+
if (file_path.endsWith(".exe")) {
101+
const res = child.execFileSync(mod.file_path);
92102

93-
setPercent(
94-
Math.round((idx / configurations.installed_mods.length) * 100) +
95-
percent
96-
);
97-
} else if (!isArchive(mod.file_name)) {
98-
toast(`Incompatible file type!: ${mod.file_name}`);
103+
// setPercent(
104+
// Math.floor((idx + 1 / configurations.installed_mods.length) * 100)
105+
// );
106+
} else if (!isArchive(file_path)) {
107+
toast(`Incompatible file type!: ${file_path}`);
99108
} else if ("extract_locations" in mod) {
100109
mod.extract_locations.forEach((loc) => {
101110
const modifiers = "modifiers" in mod ? mod.modifiers : [];
102111
streams.push(
103112
extractFull(
104113
mod.file_path,
105-
`${configurations.dow_directory}/${loc}`,
114+
path.join(configurations.dow_directory, loc),
106115
{
107116
$bin: pathTo7zip,
108117
$raw: ["-aoa", ...modifiers],
@@ -135,23 +144,33 @@ export default function Mods() {
135144
throw err;
136145
});
137146

138-
stream.on("progress", (progress) => {
139-
const newPercent =
140-
Math.round(
141-
(progress.percent / 100) *
142-
(((-installStream.modsToInstall.length +
143-
installStream.modsToInstall.length +
144-
1) /
145-
configurations.installed_mods.length) *
146-
100)
147-
) + percent;
148-
if (newPercent !== percent) setPercent(newPercent);
149-
});
147+
// stream.on("progress", (progress) => {
148+
// const max = (idx / configurations.installed_mods.length) * 100;
149+
// const min = percent;
150+
// const percentage = progress.percent;
151+
152+
// const newPercent = Math.floor((percentage * (max - min)) / 100 + min);
153+
154+
// setPercent(newPercent);
155+
// });
150156

151157
stream.on("end", () => {
152-
const idx = streams.findIndex((s) => s === stream);
153-
streams[idx].done = true;
158+
const _idx = streams.findIndex((s) => s === stream);
159+
streams[_idx].done = true;
154160
setInstallStream({ ...installStream, streams });
161+
if ("shortcut" in mod && (electron.remote || false)) {
162+
const res = electron.shell.writeShortcutLink(
163+
path.join(
164+
os.homedir(),
165+
"Desktop",
166+
mod.shortcut.replace("exe", "lnk")
167+
),
168+
{
169+
target: path.join(configurations.dow_directory, mod.shortcut),
170+
}
171+
);
172+
if (!res) toast(`Unable to create shortcut for ${mod.shortcut}`);
173+
}
155174
});
156175
});
157176

@@ -175,7 +194,7 @@ export default function Mods() {
175194
setInstalled(true);
176195
}
177196
}
178-
}, [installing, percent, installStream]);
197+
}, [installing, installStream]);
179198

180199
const handleModSearch = (item) => {
181200
if (typeof window !== "undefined") {
@@ -255,9 +274,15 @@ export default function Mods() {
255274
<Row align="bottom" gutter={12} style={{ margin: "0 auto" }}>
256275
<Col flex="auto">
257276
{item.file_path && fs.existsSync(item.file_path) ? (
258-
<CheckCircleTwoTone style={{ fontSize: "28px" }} />
277+
<CheckCircleTwoTone
278+
twoToneColor="#52c41a"
279+
style={{ fontSize: "28px" }}
280+
/>
259281
) : (
260-
<ExclamationCircleTwoTone style={{ fontSize: "28px" }} />
282+
<ExclamationCircleTwoTone
283+
twoToneColor="#eb2f96"
284+
style={{ fontSize: "28px" }}
285+
/>
261286
)}
262287
</Col>
263288
<Col>
@@ -282,23 +307,32 @@ export default function Mods() {
282307
</List.Item>
283308
)}
284309
/>
285-
{(installing || installed) && (
310+
{/* {(installing || installed) && (
286311
<Progress type="circle" percent={percent} />
287-
)}
312+
)} */}
288313
{configurations.installed_mods.every((mod) =>
289314
fs.existsSync(mod.file_path)
290315
) && (
291316
<Button
292317
type="primary"
293318
shape="round"
294319
size="large"
295-
icon={<DownloadOutlined />}
320+
icon={!installed && <DownloadOutlined />}
296321
onClick={() => handleInstall()}
297322
loading={installing}
323+
disabled={installed}
298324
>
299-
{installing && !installed ? "Installing Mods..." : "Install Mods"}
325+
{installed
326+
? " Mods installed"
327+
: [installing ? "Installing Mods..." : "Install Mods"]}
300328
</Button>
301329
)}
330+
{installed && (
331+
<CheckCircleTwoTone
332+
style={{ fontSize: "28px" }}
333+
twoToneColor="#52c41a"
334+
/>
335+
)}
302336
</Space>
303337
</Fragment>
304338
);

0 commit comments

Comments
 (0)