From 9ea5aa25d7ca0d8020331b7f1b39040c1b3f6d20 Mon Sep 17 00:00:00 2001 From: "Kyle J. Kemp" Date: Thu, 12 Sep 2024 10:31:36 -0500 Subject: [PATCH] fix base path for sprites --- app/ipc.ts | 4 ++++ app/main.ts | 3 ++- src/app/services/electron.service.ts | 6 ++++++ src/app/shared/components/sprite/sprite.component.ts | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/ipc.ts b/app/ipc.ts index fdf4f5e..25b6ef0 100644 --- a/app/ipc.ts +++ b/app/ipc.ts @@ -69,6 +69,10 @@ export function setupIPC(sendToUI: SendToUI) { sendToUI('version', require('./package.json').version); }); + ipcMain.on('GET_BASEURL', async () => { + sendToUI('baseurl', baseUrl); + }); + ipcMain.on('UPDATE_RESOURCES', async () => { try { sendToUI('notify', { type: 'info', text: 'Updating resources...' }); diff --git a/app/main.ts b/app/main.ts index b11a3f6..28ce524 100644 --- a/app/main.ts +++ b/app/main.ts @@ -37,6 +37,7 @@ const handleSetup = async () => { let isReady = false; sendToUI('version', require('./package.json').version); + sendToUI('baseurl', baseUrl); if (!fs.existsSync(baseUrl + '/resources/.loaded')) { sendToUI('firstload'); @@ -132,7 +133,7 @@ async function createWindow(): Promise { // load intercepter for image loading protocol.interceptFileProtocol('lotr', (req, callback) => { const url = req.url.substr(7); - callback({ path: path.normalize(app.getAppPath() + url) }); + callback({ path: path.normalize(baseUrl + url) }); }); win.webContents.setWindowOpenHandler(({ url }: any) => { diff --git a/src/app/services/electron.service.ts b/src/app/services/electron.service.ts index e000ad1..7a55fc3 100644 --- a/src/app/services/electron.service.ts +++ b/src/app/services/electron.service.ts @@ -32,6 +32,7 @@ export class ElectronService { public isInElectron = computed(() => !!window.api); public version = signal('web'); + public baseUrl = signal(''); private quicksaveFilepath = computed(() => { const mod = this.modService.mod(); @@ -104,6 +105,7 @@ export class ElectronService { this.isFirstLoad.set(false); this.send('GET_VERSION'); + this.send('GET_BASEURL'); this.requestAllJSON(); tryEnsureMaps(); @@ -173,6 +175,10 @@ export class ElectronService { this.version.set(version as string) ); + window.api.receive('baseurl', (baseurl) => + this.baseUrl.set(baseurl as string) + ); + const quicksaveFilepath = this.quicksaveFilepath(); if (quicksaveFilepath) { this.needsLoadForReadyCheck.set(true); diff --git a/src/app/shared/components/sprite/sprite.component.ts b/src/app/shared/components/sprite/sprite.component.ts index bea1ca0..aa7a6c5 100644 --- a/src/app/shared/components/sprite/sprite.component.ts +++ b/src/app/shared/components/sprite/sprite.component.ts @@ -25,7 +25,7 @@ export class SpriteComponent { return 'https://play.rair.land/assets'; } - return 'lotr://./resources/maps/__assets'; + return `lotr://./resources/maps/__assets`; }); public size = computed(() => divisors[this.type()]);