Skip to content

Commit

Permalink
added a way to export to clipboard a list of enabled mods' names
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazbot committed Mar 24, 2023
1 parent dc6f1d3 commit 6d0d337
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wh3mm",
"productName": "wh3mm",
"version": "1.31.0",
"version": "1.32.0",
"description": "WH3 Mod Manager",
"main": ".webpack/main",
"scripts": {
Expand Down
19 changes: 17 additions & 2 deletions src/OptionsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const cleanData = () => {
window.api?.cleanData();
};

const exportModNamesToClipboard = (enabledMods: Mod[]) => {
window.api?.exportModNamesToClipboard(enabledMods);
};

type OptionType = {
value: string;
label: string;
Expand Down Expand Up @@ -233,17 +237,28 @@ const OptionsDrawer = memo(() => {
</div>

<h6 className="mt-10">Share mods</h6>
<p className="mb-4 text-sm text-gray-500 dark:text-gray-400">
<p className="mb-2 text-sm text-gray-500 dark:text-gray-400">
Share current mod list with other people for multiplayer.
</p>
<div className="flex mt-2 w-full">
<button
className="make-tooltip-w-full inline-block px-6 py-2.5 bg-purple-600 text-white font-medium text-xs leading-tight rounded shadow-md hover:bg-purple-700 hover:shadow-lg focus:bg-purple-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-purple-800 active:shadow-lg transition duration-150 ease-in-out m-auto w-[70%]"
className="make-tooltip-w-full inline-block px-6 py-2 bg-purple-600 text-white font-medium text-xs leading-tight rounded shadow-md hover:bg-purple-700 hover:shadow-lg focus:bg-purple-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-purple-800 active:shadow-lg transition duration-150 ease-in-out m-auto w-[70%]"
onClick={() => setIsShowingShareMods(true)}
>
<span className="uppercase">Share Mod List</span>
</button>
</div>
<p className="mt-3 text-sm text-gray-500 dark:text-gray-400">
Copy names of enabled mods to clipboard.
</p>
<div className="flex mt-2 w-full">
<button
className="make-tooltip-w-full inline-block px-6 py-2 bg-purple-600 text-white font-medium text-xs leading-tight rounded shadow-md hover:bg-purple-700 hover:shadow-lg focus:bg-purple-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-purple-800 active:shadow-lg transition duration-150 ease-in-out m-auto w-[70%]"
onClick={() => exportModNamesToClipboard(enabledMods)}
>
<span className="uppercase">Copy Mod List</span>
</button>
</div>

<h6 className="mt-10">For Modders</h6>
<p className="mb-1 text-sm text-gray-500 dark:text-gray-400">Keep these in sync for MP.</p>
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare global {
interface api {
startGame: (mods: Mod[], startGameOptions: StartGameOptions, saveName?: string) => void;
exportModsToClipboard: (mods: Mod[]) => void;
exportModNamesToClipboard: (mods: Mod[]) => void;
subscribeToMods: (ids: string[]) => void;
openFolderInExplorer: (path: string) => void;
openInSteam: (url: string) => void;
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,13 @@ if (!gotTheLock) {
clipboard.writeText(exportedMods);
});

ipcMain.on("exportModNamesToClipboard", async (event, mods: Mod[]) => {
const sortedMods = sortByNameAndLoadOrder(mods);
clipboard.writeText(
sortedMods.map((mod) => (mod.humanName != "" && mod.humanName) || mod.name).join("\n")
);
});

ipcMain.on(
"startGame",
async (event, mods: Mod[], startGameOptions: StartGameOptions, saveName?: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const api: api = {
startGame: (mods: Mod[], startGameOptions: StartGameOptions, name?: string) =>
ipcRenderer.send("startGame", mods, startGameOptions, name),
exportModsToClipboard: (mods: Mod[]) => ipcRenderer.send("exportModsToClipboard", mods),
exportModNamesToClipboard: (mods: Mod[]) => ipcRenderer.send("exportModNamesToClipboard", mods),
subscribeToMods: (ids: string[]) => ipcRenderer.send("subscribeToMods", ids),
openFolderInExplorer: (path: string) => ipcRenderer.send("openFolderInExplorer", path),
openInSteam: (url: string) => ipcRenderer.send("openInSteam", url),
Expand Down

0 comments on commit 6d0d337

Please sign in to comment.