Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
/ ModManager Public archive

Commit

Permalink
Mod Manager 7.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MatuxGG committed Aug 14, 2024
1 parent ceb252c commit d2dea78
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 29 deletions.
3 changes: 2 additions & 1 deletion electron/main/class/appGlobals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from "path";
import {fileURLToPath} from "node:url";
import {VITE_DEV_SERVER_URL} from "../index";

let mainWindow = null;
let tray = null;
Expand All @@ -24,8 +25,8 @@ export const AMONGUS_REGIONINFO_PATH = path.join(process.env.APPDATA, '..', 'Loc
export const AMONGUS_SETTINGS_PATH = path.join(process.env.APPDATA, '..', 'LocalLow', 'Innersloth', 'Among Us', 'settings.amogus');
export const AMONGUS_OLD_SETTINGS_PATH = path.join(process.env.APPDATA, '..', 'LocalLow', 'Innersloth', 'Among Us', 'settings.amogus.old');
export const AMONGUS_NEW_SETTINGS_PATH = path.join(process.env.APPDATA, '..', 'LocalLow', 'Innersloth', 'Among Us', 'settings.amogus.new');

export const AMONGUS_DOWNLOAD_LINK = GL_WEBSITE_URL + "/amonguspage";
export const UPDATE_APP_DATA_INTERVAL = process.env.VITE_DEV_SERVER_URL ? 60000 : 600000;

export const setMainWindow = (win) => {
mainWindow = win;
Expand Down
2 changes: 1 addition & 1 deletion electron/main/class/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Files {
});
});

req.on('error', (error) => {
req.on('error', (error: any) => {
logError(error);
reject(error);
});
Expand Down
31 changes: 20 additions & 11 deletions electron/main/class/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import fs from "fs";
// @ts-ignore
import axios from "axios";
import {isOnline} from "./onlineCheck";
import {ModVersion} from "./modVersion";

export const handleArgs = () => {
let args = getArgs();
Expand Down Expand Up @@ -57,19 +58,24 @@ export const downloadMod = async (event, mod, version) => {
console.log("Downloading mod on server...");
let downloadLines = [];
if (mod.type !== "allInOne") {
let oldVersion = null;
let installedVersions = getAppData().getInstalledModVersions(mod.sid);
let versions = getAppData().getModVersions(mod.sid);
for (const installedVersion of installedVersions) {
if (!versions.some(v => v.version === installedVersion.version)) {
let generatedMod = mod;
generatedMod.version = installedVersion.version;
let generatedVersion = {'version': installedVersion.version};
downloadLines.push(["update", generatedMod, generatedVersion]);
if (versions.some(v => v.version === installedVersion.version && v.release.tag_name !== installedVersion.releaseVersion)) {
oldVersion = installedVersion;
}
}

if (!isDownloadInProgress("mod", mod, version) && !getAppData().isInstalledModFromIdAndVersion(mod.sid, version.version)) {
downloadLines.push(["mod", mod, version]);
if (oldVersion !== null) {
if (!isDownloadInProgress("update", mod, version)) {
let generatedVersion = {'version': oldVersion.version, 'release': {'tag_name': oldVersion.releaseVersion}};
downloadLines.push(["update", mod, version, generatedVersion]);
}
} else if (!getAppData().isInstalledModFromIdAndVersion(mod.sid, version.version)) {
if (!isDownloadInProgress("mod", mod, version)) {
downloadLines.push(["mod", mod, version]);
}
}

for (const dep of version.modDependencies) {
Expand All @@ -88,7 +94,6 @@ export const downloadMod = async (event, mod, version) => {
}
}


if (downloadLines.length === 0) {
return;
}
Expand All @@ -111,7 +116,10 @@ export const downloadMod = async (event, mod, version) => {
}
break;
case "update":
promises.push(ModWorker.uninstallMod(event, dl[1], dl[2]));
promises.push(ModWorker.uninstallMod(event, dl[1], dl[3]));
await new Promise((resolve) => setTimeout(resolve, 100));
promises.push(ModWorker.downloadMod(event, dl[1], dl[2]));
break;
}
//promises.push(dl[3]);
}
Expand All @@ -125,7 +133,8 @@ export const downloadMod = async (event, mod, version) => {
} else if (dl[0] === "vanilla") {
getAppData().config.addInstalledVanilla(dl[2].gameVersion);
} else if (dl[0] === "update") {
getAppData().config.removeInstalledMod(dl[1], dl[2]);
getAppData().config.removeInstalledMod(dl[1], dl[3]);
getAppData().config.addInstalledMod(dl[1], dl[2]);
} else if (dl[0] === "allInOne") {
getAppData().config.addInstalledMod(dl[1], null);
}
Expand Down Expand Up @@ -243,7 +252,7 @@ export const updateTray = () => {
});
} else {
modsLines.push({
label: trans("Stop $", getAppData().startedMod[0].name+" "+getAppData().startedMod[1].release.tag_name),
label: getAppData().startedMod[0] === 'Vanilla' ? 'Stop vanilla' : trans("Stop $", getAppData().startedMod[0].name+" "+getAppData().startedMod[1].release.tag_name),
click: function () {
getMainWindow().webContents.send('handleArgs', 'stopCurrentMod');
}
Expand Down
2 changes: 1 addition & 1 deletion electron/main/class/ipcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
updateTray
} from "./functions";
import modWorker from "./modWorker";
import {initializeUpdater, isUpdating} from "./updater";
import {initializeUpdater} from "./updater";

const setupIPCMainHandlers = () => {

Expand Down
2 changes: 1 addition & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
setAppData,
setArgs,
setMainWindow, setMMIconPath,
setTray
setTray, trans
} from "./class/appGlobals";
import AppData from "./class/appData";
import {handleArgs, logError} from "./class/functions";
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": "modmanager7",
"version": "7.0.2",
"version": "7.0.3",
"main": "dist-electron/main/index.js",
"description": "Mod Manager 7 by Good Loss",
"author": "MatuxGG",
Expand Down
24 changes: 15 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default {
} else {
document.getElementById("themeDiv").classList.remove("dark");
}
this.connection(true);
},
openLink(url) {
if (window.electronAPI && window.electronAPI.openExternal) {
Expand All @@ -120,6 +121,19 @@ export default {
window.open(url, '_blank').focus();
}
},
connection(status) {
let statusDiv = document.getElementById("statusDiv");
let statusTextDiv = document.getElementById("statusText");
if (status) {
statusDiv.classList.remove("offline");
statusDiv.classList.add("online");
statusTextDiv.innerText = this.$t("Online");
} else {
statusDiv.classList.remove("online");
statusDiv.classList.add("offline");
statusTextDiv.innerText = this.$t("Offline");
}
},
},
provide() {
return {
Expand Down Expand Up @@ -293,15 +307,7 @@ export default {
});
window.electronAPI.receiveData('connection', (status) => {
if (status === true) {
document.getElementById("statusDiv").classList.remove("bg-red-700");
document.getElementById("statusDiv").classList.add("bg-green-700");
document.getElementById("statusText").innerText = "Online";
} else {
document.getElementById("statusDiv").classList.remove("bg-green-700");
document.getElementById("statusDiv").classList.add("bg-red-700");
document.getElementById("statusText").innerText = "Offline";
}
this.connection(status);
});
window.electronAPI.receiveData('updateAppData', (appData) => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/MenuLeft.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<div class="text-sm flex flex-col items-center text-lg gap-2">
<template v-if="$store.state.appData">
<div v-if="startedMod !== false" @click.prevent="stopMod()" class="p-1 cursor-pointer flex flex-col justify-center items-center dark:bg-green-800 w-full rounded">
<div v-if="startedMod !== false" @click.prevent="stopMod()" class="p-1 cursor-pointer flex flex-col justify-center items-center bg-green-500 dark:bg-green-700 w-full rounded">
<span v-if="startedMod[0].name === 'Vanilla'">{{ $t('Started vanilla') }}</span>
<template v-if="startedMod[0] === 'Vanilla'">
<span>{{ $t('Started vanilla') }}</span>
Expand All @@ -33,15 +33,15 @@
</div>
</template>
</div>
<div v-else @click.prevent="startVanilla()" class="flex justify-center cursor-pointer p-1 dark:bg-red-800 w-full rounded">
<div v-else @click.prevent="startVanilla()" class="flex justify-center cursor-pointer p-1 bg-red-500 dark:bg-red-800 w-full rounded">
<span>{{ $t('No mod started yet') }}</span>
</div>
</template>
<div id="statusDiv" class="flex items-center justify-center rounded p-1 gap-2 text-white text-sm bg-green-700 w-full">
<div id="statusDiv" class="flex items-center justify-center rounded p-1 gap-2 text-sm online w-full">
<svg class="w-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21 12C21 16.9706 16.9706 21 12 21M21 12C21 7.02944 16.9706 3 12 3M21 12C21 13.6569 16.9706 15 12 15C7.02944 15 3 13.6569 3 12M21 12C21 10.3431 16.9706 9 12 9C7.02944 9 3 10.3431 3 12M12 21C7.02944 21 3 16.9706 3 12M12 21C10.3431 21 9 16.9706 9 12C9 7.02944 10.3431 3 12 3M12 21C13.6569 21 15 16.9706 15 12C15 7.02944 13.6569 3 12 3M3 12C3 7.02944 7.02944 3 12 3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span id="statusText">Online</span>
<span id="statusText">...</span>
</div>
<div class="flex items-center justify-between gap-2">
<a v-for="miniIcon in miniIcons" :key="miniIcon.id" @click.prevent="openLink(miniIcon.href)">
Expand Down
8 changes: 8 additions & 0 deletions src/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@

.downloader-line {
@apply p-2 border-white border rounded cursor-pointer;
}

.online {
@apply bg-green-500 dark:bg-green-700;
}

.offline {
@apply bg-red-500 dark:bg-red-800;
}

0 comments on commit d2dea78

Please sign in to comment.