Skip to content

Commit

Permalink
fix base path for sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Sep 12, 2024
1 parent c43ad7e commit 9ea5aa2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...' });
Expand Down
3 changes: 2 additions & 1 deletion app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -132,7 +133,7 @@ async function createWindow(): Promise<BrowserWindow> {
// 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) => {
Expand Down
6 changes: 6 additions & 0 deletions src/app/services/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class ElectronService {
public isInElectron = computed(() => !!window.api);

public version = signal<string>('web');
public baseUrl = signal<string>('');

private quicksaveFilepath = computed(() => {
const mod = this.modService.mod();
Expand Down Expand Up @@ -104,6 +105,7 @@ export class ElectronService {
this.isFirstLoad.set(false);

this.send('GET_VERSION');
this.send('GET_BASEURL');

this.requestAllJSON();
tryEnsureMaps();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/components/sprite/sprite.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
Expand Down

0 comments on commit 9ea5aa2

Please sign in to comment.