mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 13:51:02 +00:00
Compare commits
2 Commits
feat/LBX-4
...
feat/LBX-4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bf70cd2b4 | ||
|
|
2e2a95c314 |
@@ -2,12 +2,15 @@ import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
import type { GameShop } from "@types";
|
||||
import { downloadsSublevel, gamesSublevel, levelKeys } from "@main/level";
|
||||
import { FILE_EXTENSIONS_TO_EXTRACT } from "@shared";
|
||||
import { FILE_EXTENSIONS_TO_EXTRACT, removeSymbolsFromName } from "@shared";
|
||||
import { SevenZip, ExtractionProgress } from "./7zip";
|
||||
import { WindowManager } from "./window-manager";
|
||||
import { publishExtractionCompleteNotification } from "./notifications";
|
||||
import { logger } from "./logger";
|
||||
import { GameExecutables } from "./game-executables";
|
||||
import createDesktopShortcut from "create-desktop-shortcuts";
|
||||
import { app } from "electron";
|
||||
import { SystemPath } from "./system-path";
|
||||
|
||||
const PROGRESS_THROTTLE_MS = 1000;
|
||||
|
||||
@@ -204,6 +207,8 @@ export class GameFilesManager {
|
||||
});
|
||||
|
||||
WindowManager.mainWindow?.webContents.send("on-library-batch-complete");
|
||||
|
||||
await this.createDesktopShortcutForGame(game.title, foundExePath);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
@@ -213,6 +218,40 @@ export class GameFilesManager {
|
||||
}
|
||||
}
|
||||
|
||||
private async createDesktopShortcutForGame(
|
||||
gameTitle: string,
|
||||
executablePath: string
|
||||
): Promise<void> {
|
||||
try {
|
||||
const windowVbsPath = app.isPackaged
|
||||
? path.join(process.resourcesPath, "windows.vbs")
|
||||
: undefined;
|
||||
|
||||
const options = {
|
||||
filePath: executablePath,
|
||||
name: removeSymbolsFromName(gameTitle),
|
||||
outputPath: SystemPath.getPath("desktop"),
|
||||
};
|
||||
|
||||
const success = createDesktopShortcut({
|
||||
windows: { ...options, VBScriptPath: windowVbsPath },
|
||||
linux: options,
|
||||
osx: options,
|
||||
});
|
||||
|
||||
if (success) {
|
||||
logger.info(
|
||||
`[GameFilesManager] Created desktop shortcut for ${this.objectId}`
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`[GameFilesManager] Error creating desktop shortcut: ${this.objectId}`,
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async findExecutableInFolder(
|
||||
folderPath: string,
|
||||
executableNames: string[]
|
||||
|
||||
Reference in New Issue
Block a user