This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor manager and add uninstall button
- Loading branch information
1 parent
ae25e35
commit 1c766e1
Showing
16 changed files
with
338 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const isDevelopment: boolean = process.env.IS_DEV === "true" | ||
|
||
// @ts-expect-error | ||
// eslint-disable-next-line no-undef,@typescript-eslint/no-unsafe-assignment | ||
export const MANAGER_VERSION: string = __MANAGER_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pathLib from "path" | ||
import fs from "fs-extra" | ||
|
||
export async function detectGameVersion(directory: string): Promise<string> { | ||
const content = await fs.readFile( | ||
pathLib.resolve(directory, "./Among Us_Data/globalgamemanagers"), | ||
{ encoding: "utf8" } | ||
) | ||
|
||
const regex = /\d{4}\.\d{1,4}\.\d{1,4}/gu | ||
regex.exec(content) | ||
const match = regex.exec(content) | ||
|
||
if (match !== null) { | ||
return match[0] | ||
} | ||
|
||
throw new Error("Among Us version could not be detected") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pathLib from "path" | ||
import fs from "fs-extra" | ||
import { detectGameVersion } from "./detectGameVersion" | ||
import { STEAM_APPS_DIRECTORY } from "./util" | ||
|
||
export const ORIGINAL_GAME_DIRECTORY = pathLib.resolve(STEAM_APPS_DIRECTORY, "Among Us") | ||
|
||
let originalGameVersion: string | ||
export const getOriginalGameVersion = () => originalGameVersion | ||
|
||
export async function detectOriginalGameVersion() { | ||
if (!await fs.pathExists(ORIGINAL_GAME_DIRECTORY)) throw new Error("Among Us could not be found") | ||
originalGameVersion = await detectGameVersion(ORIGINAL_GAME_DIRECTORY) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { app, dialog } from "electron" | ||
import { detectOriginalGameVersion } from "./gameInfo" | ||
import { registerIPC, sendUIModData } from "./ipc" | ||
import { fetchRemoteMods } from "./remoteMods" | ||
import { discoverInstalledMods } from "./installedMods" | ||
import { STEAM_APPS_DIRECTORY } from "./util" | ||
|
||
export function initiateManager() { | ||
registerIPC() | ||
|
||
Promise.all([ | ||
discoverInstalledMods(), | ||
fetchRemoteMods(), | ||
detectOriginalGameVersion() | ||
]).then(() => { | ||
sendUIModData() | ||
}) | ||
} | ||
|
||
export async function loadGameVersionOrShowError() { | ||
try { | ||
await detectOriginalGameVersion() | ||
} catch { | ||
dialog.showErrorBox( | ||
"Among Us could not be found", | ||
`Please make sure Among Us is installed in the default location of Steam games. (${STEAM_APPS_DIRECTORY})` | ||
) | ||
|
||
app.exit(1) | ||
} | ||
} | ||
|
||
export { isGameRunning } from "./installedMods" | ||
export { getOriginalGameVersion } from "./gameInfo" | ||
export { STEAM_APPS_DIRECTORY } from "./util" |
Oops, something went wrong.