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
57 changes: 57 additions & 0 deletions arguments_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[
{
"key": "DEV_MODE",
"description": "Activates the developer mode, enabling additional debug tools and shortcuts.",
"type": "boolean"
},
{
"key": "CONFIGURATION_FILE",
"description": "Path to the configuration file to use.",
"type": "string"
},
{
"key": "NO_CAMERA_MIN_ZOOM",
"description": "Disables the minimum zoom restriction on the camera.",
"type": "boolean"
},
{
"key": "ONLY_ALLOWED_TEAM_TAB",
"description": "The tab number of the only tab allowed in the Fighter Management UI.",
"type": "number"
},
{
"key": "ONLY_ALLOWED_LADDER_TAB",
"description": "The tab number of the only tab allowed in the Ladder UI.",
"type": "number"
},
{
"key": "SKIP_TURN_NO_DELAY",
"description": "Bypass the delay before ending a turn.",
"type": "boolean"
},
{
"key": "REPLAY_FILE_PATH",
"description": "Path to a replay file to load and play.",
"type": "string"
},
{
"key": "WORLD_FADE",
"description": "Activates the world fade effect during transitions.",
"type": "boolean"
},
{
"key": "HOT_RELOAD_EFFECT",
"description": "Enables hot reloading of visual effects.",
"type": "boolean"
},
{
"key": "NO_CLASS_RESTRICTION",
"description": "Disables class restrictions for character creation or editing.",
"type": "boolean"
},
{
"key": "RESTORE_CONSOLE_PATH",
"description": "Restores the last used console path on startup instead of defaulting to admin.",
"type": "boolean"
}
]
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 37 additions & 22 deletions packages/main/src/modules/GameClient.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ipcMain, app } from "electron";
import { join } from "path";
import { existsSync, mkdirSync } from "fs";
import { chmodSync } from "fs";
import { stat, chmod, readdir, readFile, appendFile } from "fs/promises";
import { exec } from "child_process";
import {app, ipcMain} from "electron";
import {join} from "path";
import {chmodSync, existsSync, mkdirSync} from "fs";
import {appendFile, chmod, readdir, readFile, stat} from "fs/promises";
import {exec} from "child_process";
import log from "electron-log";
import { GameUpdater, GameSettings, ReplayFile } from "./GameUpdater.js";
import type { AppModule } from "../AppModule.js";
import type { ModuleContext } from "../ModuleContext.js";
import {GameSettings, GameUpdater, ReplayFile} from "./GameUpdater.js";
import type {AppModule} from "../AppModule.js";
import type {ModuleContext} from "../ModuleContext.js";

export class GameClient implements AppModule {
private gameUpdater: GameUpdater | null = null;
Expand Down Expand Up @@ -37,6 +36,9 @@ export class GameClient implements AppModule {
ipcMain.handle("gameClient:launchReplayOffline", (_e, path) =>
this.launchReplayOffline(path)
);
ipcMain.handle("gameClient:getGameArgumentsDescriptor", () =>
this.getGameArgumentsDescriptor()
);
}

onSettingsUpdate(settings: GameSettings): void {
Expand Down Expand Up @@ -75,18 +77,15 @@ export class GameClient implements AppModule {
await this.startJavaProcess({
mainClass: "com.ankamagames.dofusarena.client.DofusArenaClient",
settings: this.currentSettings || undefined,
extraArgs: [
"-ONLY_ALLOWED_TEAM_TAB=1",
"-ONLY_ALLOWED_LADDER_TAB=ONE_VS_ONE",
],
extraArgs: this.currentSettings?.devExtraJavaArgs.split(" ").map(arg => `-${arg}`) ?? [],
});
}

async openReplaysFolder(): Promise<void> {
const { shell } = await import("electron");
const {shell} = await import("electron");
const replaysPath = join(this.gameClientPath, "game", "replays");

mkdirSync(replaysPath, { recursive: true });
mkdirSync(replaysPath, {recursive: true});

try {
await shell.openPath(replaysPath);
Expand All @@ -101,8 +100,8 @@ export class GameClient implements AppModule {

async listReplays(): Promise<ReplayFile[]> {
const replaysPath = join(this.gameClientPath, "game", "replays");
const { readdir } = await import("fs/promises");
mkdirSync(replaysPath, { recursive: true });
const {readdir} = await import("fs/promises");
mkdirSync(replaysPath, {recursive: true});

try {
const files = await readdir(replaysPath);
Expand Down Expand Up @@ -191,7 +190,7 @@ export class GameClient implements AppModule {
settings?: GameSettings;
extraArgs?: string[];
}): Promise<void> {
const { mainClass, settings, extraArgs = [] } = options;
const {mainClass, settings, extraArgs = []} = options;
const gameDir = join(this.gameClientPath, "game");
const libDir = join(this.gameClientPath, "lib");
const jreDir = join(this.gameClientPath, "jre");
Expand Down Expand Up @@ -349,7 +348,7 @@ export class GameClient implements AppModule {
return new Promise((resolve, reject) => {
const child = exec(
`"${javaExecutable}" ${args.join(" ")}`,
{ cwd },
{cwd},
(error) => {
if (error && !error.killed) {
log.error("Java process error:", error);
Expand Down Expand Up @@ -380,7 +379,7 @@ export class GameClient implements AppModule {
}
const child = exec(
`"${javaExecutable}" ${args.join(" ")}`,
{ cwd },
{cwd},
(error) => {
if (error && !error.killed) {
log.error("Java process error:", error);
Expand Down Expand Up @@ -411,7 +410,7 @@ export class GameClient implements AppModule {
}

// Ensure we have the full system PATH for finding wine
const env = { ...process.env };
const env = {...process.env};
if (!env.PATH?.includes("/opt/homebrew/bin")) {
env.PATH = `${
env.PATH || ""
Expand All @@ -420,7 +419,7 @@ export class GameClient implements AppModule {

const child = exec(
`wine "${javaExecutable}" ${args.join(" ")}`,
{ cwd, env },
{cwd, env},
(error) => {
if (error && !error.killed) {
log.error("Java process error:", error);
Expand All @@ -435,6 +434,22 @@ export class GameClient implements AppModule {
});
}

async getGameArgumentsDescriptor(): Promise<any> {
try {
let schemaPath = join(this.gameClientPath, "game", "arguments.json");
if (existsSync(schemaPath)) {
log.info("Loading arguments descriptor from ", schemaPath)
const content = await readFile(schemaPath, "utf-8");
return JSON.parse(content);
}
log.info("Arguments descriptor not found")
return null;
} catch (error) {
log.error("Failed to load arguments.json:", error);
return null;
}
}

private parseReplayFilename(filename: string, fullPath: string): ReplayFile {
const replayFile: ReplayFile = {
filename,
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/modules/GameUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface GameSettings {
gameRamAllocation: number;
devModeEnabled: boolean;
devExtraJavaArgs: string;
devGameArgs: string;
devForceVersion: string;
devCdnEnvironment: "production" | "staging";
}
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/services/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class SettingsManager {
return {
gameRamAllocation: 2,
devModeEnabled: false,
devGameArgs: "ONLY_ALLOWED_TEAM_TAB=1 ONLY_ALLOWED_LADDER_TAB=ONE_VS_ONE",
devExtraJavaArgs: "",
devForceVersion: "",
devCdnEnvironment: "production",
Expand Down
2 changes: 2 additions & 0 deletions packages/preload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const gameClient = {
listReplays: () => ipcRenderer.invoke("gameClient:listReplays"),
launchReplayOffline: (replayPath: string) =>
ipcRenderer.invoke("gameClient:launchReplayOffline", replayPath),
getGameArgumentsDescriptor: () =>
ipcRenderer.invoke("gameClient:getGameArgumentsDescriptor"),
};

// News functions
Expand Down
Loading
Loading