Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions files/shellscripts/EpicGamesLauncher.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Param(
[Parameter(Mandatory=$true)]
$gameURI,
[Parameter(Mandatory=$true)]
$gameProcessName
)


# Start the game via Epic Games Launcher
Start-Process $gameURI

# Wait for the game to start
while (-not (Get-Process -Name $gameProcessName -ErrorAction SilentlyContinue)) {
Start-Sleep -Seconds 5
}

# Wait for the game to exit
while (Get-Process -Name $gameProcessName -ErrorAction SilentlyContinue) {
Start-Sleep -Seconds 5
}

# Give Epic Games Launcher a few seconds before closing
Start-Sleep -Seconds 10

# Close Epic Games Launcher
Stop-Process -Name "EpicGamesLauncher" -Force -ErrorAction SilentlyContinue
10 changes: 7 additions & 3 deletions src/lib/parsers/epic.parser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ParserInfo, GenericParser, ParsedData } from "../../models";
import { ParserInfo, GenericParser, ParsedData, EpicGameManifest } from "../../models";
import { APP } from "../../variables";
import * as _ from "lodash";
import * as fs from "fs-extra";
import * as os from "os";
import * as path from "path";
import { glob } from "glob";
import * as paths from "../../paths";

export class EpicParser implements GenericParser {
private get lang() {
Expand Down Expand Up @@ -65,9 +66,10 @@ export class EpicParser implements GenericParser {
const files: string[] = await glob(
[epicManifestsDir.replace(/\\/g, "/"), "*.item"].join("/"),
);
const scriptsPath = path.join(paths.userDataDir, "scripts");
for (let file of files) {
if (fs.existsSync(file) && fs.lstatSync(file).isFile()) {
let item = JSON.parse(fs.readFileSync(file).toString());
let item: EpicGameManifest = JSON.parse(fs.readFileSync(file).toString());
let launchPath = path.join(
item.InstallLocation,
item.LaunchExecutable,
Expand All @@ -77,11 +79,13 @@ export class EpicParser implements GenericParser {
fs.existsSync(launchPath) &&
!appTitles.includes(item.DisplayName)
) {
const processName = item.LaunchExecutable.replace(/\.exe$/i, "");
appTitles.push(item.DisplayName);
parsedData.success.push({
extractedTitle: item.DisplayName,
extractedAppId: item.AppName,
launchOptions: `-windowStyle hidden -NoProfile -ExecutionPolicy Bypass -Command "&Start-Process \\"com.epicgames.launcher://apps/${item.AppName}?action=launch&silent=true\\""`,
startInDirectory: scriptsPath,
launchOptions: `-windowStyle hidden -NoProfile -ExecutionPolicy Bypass -File .\\EpicGamesLauncher.ps1 -gameURI "com.epicgames.launcher://apps/${item.AppName}?action=launch&silent=true" -gameProcessName "${processName}"`,
filePath: launchPath,
fileLaunchOptions: item.LaunchCommand,
});
Expand Down
8 changes: 8 additions & 0 deletions src/models/epic.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// game json manifest
export interface EpicGameManifest {
InstallLocation: string;
LaunchExecutable: string;
DisplayName: string;
AppName: string;
LaunchCommand: string;
}
1 change: 1 addition & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from "./user-exceptions.model";
export * from "./config-presets.model";
export * from "./error.model";
export * from "./uwp.model";
export * from "./epic.model";