Skip to content

Commit

Permalink
closes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 8, 2024
1 parent b24cd6e commit 94170ca
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/handlers/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const fixTiledMapPaths = (map: any) => {

export function ensureMap(mapName: string, mapData: any) {
const path = `${baseUrl}/resources/maps/src/content/maps/custom/${mapName}.json`;
if (fs.existsSync(path)) return;

fs.writeFileSync(path, JSON.stringify(mapData));
}

Expand Down
4 changes: 3 additions & 1 deletion app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as handlers from './handlers';
import { baseUrl } from './helpers';
import { setupIPC } from './ipc';
import { setupIPC, watchMaps } from './ipc';
import { SendToUI } from './types';

const isDevelopment = process.env.NODE_ENV !== 'production';
Expand Down Expand Up @@ -32,11 +32,13 @@ const handleSetup = async () => {
let isReady = false;

if (!fs.existsSync(baseUrl + '/resources/.loaded')) {
sendToUI('firstload');
sendToUI('notify', {
type: 'info',
text: 'Loading resources for first time launch...',
});
await handlers.updateResources(sendToUI);
watchMaps(sendToUI);
sendToUI('notify', {
type: 'success',
text: 'Spritesheets and game data have been installed.',
Expand Down
14 changes: 11 additions & 3 deletions src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@

</div>

@if(electronService.isFirstLoad()) {
<div class="root-content px-3">
<div class="w-full h-full flex flex-nowrap justify-center items-center text-center text-3xl">
First time load detected.
<br><br>
Loading necessary resources to use the modding tools...
</div>
</div>
}

@if(electronService.isLoaded()) {
<div class="root-content p-3">
<div class="card bg-base-100 w-full shadow-xl">
Expand Down Expand Up @@ -101,9 +111,7 @@
@else {
<div class="root-content px-3">
<div class="w-full h-full flex flex-nowrap justify-center items-center text-center text-3xl">
First time load detected.
<br><br>
Loading necessary resources to use the modding tools...
<span class="loading loading-ring loading-lg"></span>
</div>
</div>
}
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 @@ -19,6 +19,7 @@ declare global {
})
export class ElectronService {
public isLoaded = signal<boolean>(false);
public isFirstLoad = signal<boolean>(false);

private modService = inject(ModService);
private notifyService = inject(NotifyService);
Expand All @@ -37,6 +38,11 @@ export class ElectronService {

window.api.receive('ready', () => {
this.isLoaded.set(true);
this.isFirstLoad.set(false);
});

window.api.receive('firstload', () => {
this.isFirstLoad.set(true);
});

window.api.receive('notify', ({ type, text }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/tabs/maps/maps.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class MapsComponent extends EditorBaseTableComponent<EditingType> {
public tableColumns: ColDef[] = [
{
field: 'name',
flex: 1,
flex: 2,
cellDataType: 'text',
filter: 'agTextColumnFilter',
sort: 'asc',
Expand Down

0 comments on commit 94170ca

Please sign in to comment.