diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 4d3adae..2e6be03 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -3,8 +3,10 @@ Land of the Rair Mod Toolkit @if(electronService.isLoaded()) { - {{ modService.modName() }} - {{ modService.modAuthor() }} + {{ + modService.modName() }} + {{ + modService.modAuthor() }} } @@ -21,17 +23,24 @@ @@ -107,7 +118,8 @@
@for(tab of tabOrder; track tab.name; let i = $index) { - {{ tab.name }} ({{ tab.count() }}) } diff --git a/src/app/home/home.component.scss b/src/app/home/home.component.scss index e0f5f78..4caa115 100644 --- a/src/app/home/home.component.scss +++ b/src/app/home/home.component.scss @@ -41,3 +41,7 @@ overflow-y: auto; overflow-x: hidden; } + +a.btn-disabled { + opacity: 0.5; +} diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 5950ec6..1399e10 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -54,7 +54,11 @@ export class HomeComponent { }); public tabOrder = [ - { name: 'Maps', count: computed(() => this.modService.mod().maps.length) }, + { + name: 'Maps', + count: computed(() => this.modService.mod().maps.length), + disableOutsideElectron: true, + }, { name: 'Items', count: computed(() => this.modService.mod().items.length), @@ -173,4 +177,13 @@ export class HomeComponent { toggleTester() { this.tester()?.nativeElement.showModal(); } + + updateResources() { + if (this.electronService.isInElectron()) { + this.electronService.send('UPDATE_RESOURCES'); + return; + } + + void this.electronService.reloadExternalWebMod(); + } } diff --git a/src/app/services/electron.service.ts b/src/app/services/electron.service.ts index 60402c5..58f6430 100644 --- a/src/app/services/electron.service.ts +++ b/src/app/services/electron.service.ts @@ -29,6 +29,8 @@ export class ElectronService { private notifyService = inject(NotifyService); private settingsService = inject(SettingsService); + public isInElectron = computed(() => !!window.api); + private quicksaveFilepath = computed(() => { const mod = this.modService.mod(); const settings = this.settingsService.allSettings()[mod.meta.id]; @@ -38,6 +40,8 @@ export class ElectronService { constructor() { this.watchIPC(); + void this.tryLoadingOutsideElectron(); + effect(() => { const mod = this.modService.mod(); @@ -53,7 +57,30 @@ export class ElectronService { }); } + public async reloadExternalWebMod() { + const basegamecontent = await fetch( + 'https://play.rair.land/assets/content/_output/simplemods/BaseGameContent.rairmod.json' + ); + const contentJson = await basegamecontent.json(); + + this.modService.updateMod(contentJson as IModKit); + } + + private async tryLoadingOutsideElectron() { + if (this.isInElectron()) return; + + const mod = this.modService.mod(); + if (mod.meta.author === 'Anonymous') { + await this.reloadExternalWebMod(); + } + + this.isLoaded.set(true); + this.isFirstLoad.set(false); + } + private watchIPC() { + if (!this.isInElectron()) return; + window.api.reset(); const tryToReady = () => { @@ -157,10 +184,12 @@ export class ElectronService { } requestJSON(key: ModJSONKey) { + if (!this.isInElectron()) return; window.api.send('JSON', { json: key }); } send(key: string, value?: any) { + if (!this.isInElectron()) return; window.api.send(key, value); } } diff --git a/src/app/services/mod.service.ts b/src/app/services/mod.service.ts index e537824..02774e7 100644 --- a/src/app/services/mod.service.ts +++ b/src/app/services/mod.service.ts @@ -212,12 +212,12 @@ export class ModService { // map functions public ensureMapsExist() { - window.api.send('ENSURE_MAPS', this.mod().maps); + window.api?.send('ENSURE_MAPS', this.mod().maps); } public importMap(incomingMap: IEditorMap) { this.addMap(incomingMap); - window.api.send('ENSURE_MAP', { ...incomingMap }); + window.api?.send('ENSURE_MAP', { ...incomingMap }); } public addMap(incomingMap: IEditorMap) { diff --git a/src/app/shared/components/cell-buttons/cell-buttons.component.html b/src/app/shared/components/cell-buttons/cell-buttons.component.html index 2c96563..6986457 100644 --- a/src/app/shared/components/cell-buttons/cell-buttons.component.html +++ b/src/app/shared/components/cell-buttons/cell-buttons.component.html @@ -6,14 +6,16 @@ } @if(params.showCopyButton) { - } @if(params.showRenameButton) { - } @@ -25,7 +27,8 @@ } @if(params.showDeleteButton) { - diff --git a/src/app/shared/components/cell-buttons/cell-buttons.component.ts b/src/app/shared/components/cell-buttons/cell-buttons.component.ts index 6c21093..7a2939e 100644 --- a/src/app/shared/components/cell-buttons/cell-buttons.component.ts +++ b/src/app/shared/components/cell-buttons/cell-buttons.component.ts @@ -1,7 +1,8 @@ -import { Component, viewChild } from '@angular/core'; +import { Component, inject, viewChild } from '@angular/core'; import { SwalComponent } from '@sweetalert2/ngx-sweetalert2'; import { ICellRendererAngularComp } from 'ag-grid-angular'; import { ICellRendererParams } from 'ag-grid-community'; +import { ElectronService } from '../../../services/electron.service'; @Component({ selector: 'app-cell-buttons', @@ -9,6 +10,8 @@ import { ICellRendererParams } from 'ag-grid-community'; styleUrl: './cell-buttons.component.scss', }) export class CellButtonsComponent implements ICellRendererAngularComp { + public electronService = inject(ElectronService); + public params!: any; public deleteWarnSwal = viewChild('deleteItem'); diff --git a/src/app/shared/components/editor-base/editor-base.component.ts b/src/app/shared/components/editor-base/editor-base.component.ts index bc9aa05..0ced99d 100644 --- a/src/app/shared/components/editor-base/editor-base.component.ts +++ b/src/app/shared/components/editor-base/editor-base.component.ts @@ -10,6 +10,7 @@ import { import { LocalStorageService } from 'ngx-webstorage'; import { HasIdentification } from '../../../../interfaces'; import { id } from '../../../helpers/id'; +import { ElectronService } from '../../../services/electron.service'; import { ModService } from '../../../services/mod.service'; type Tab = { name: string; visibleIf?: Signal }; @@ -23,6 +24,7 @@ export class EditorBaseComponent implements OnInit { private localStorage = inject(LocalStorageService); + public electronService = inject(ElectronService); public modService = inject(ModService); public readonly key: string = ''; diff --git a/src/app/shared/components/editor-view-table/editor-view-table.component.html b/src/app/shared/components/editor-view-table/editor-view-table.component.html index de5a6f6..163034c 100644 --- a/src/app/shared/components/editor-view-table/editor-view-table.component.html +++ b/src/app/shared/components/editor-view-table/editor-view-table.component.html @@ -4,10 +4,12 @@
You don't have any {{ dataType() }}. - + @if(showImport()) { - + }
diff --git a/src/app/shared/components/editor-view-table/editor-view-table.component.ts b/src/app/shared/components/editor-view-table/editor-view-table.component.ts index e0d9c1f..05fdc4d 100644 --- a/src/app/shared/components/editor-view-table/editor-view-table.component.ts +++ b/src/app/shared/components/editor-view-table/editor-view-table.component.ts @@ -1,10 +1,11 @@ -import { Component, input, output } from '@angular/core'; +import { Component, inject, input, output } from '@angular/core'; import { ColDef, FilterChangedEvent, FilterModel, GridReadyEvent, } from 'ag-grid-community'; +import { ElectronService } from '../../../services/electron.service'; @Component({ selector: 'app-editor-view-table', @@ -12,6 +13,8 @@ import { styleUrl: './editor-view-table.component.scss', }) export class EditorViewTableComponent { + public electronService = inject(ElectronService); + public tableItems = input([]); public dataType = input(''); public tableColumns = input([]); diff --git a/src/app/shared/components/header-buttons/header-buttons.component.html b/src/app/shared/components/header-buttons/header-buttons.component.html index 3be3c82..2ee9e94 100644 --- a/src/app/shared/components/header-buttons/header-buttons.component.html +++ b/src/app/shared/components/header-buttons/header-buttons.component.html @@ -1,12 +1,14 @@
@if(params.showImportButton) { - } @if(params.showNewButton) { - } diff --git a/src/app/shared/components/header-buttons/header-buttons.component.ts b/src/app/shared/components/header-buttons/header-buttons.component.ts index 9f8239b..45f6671 100644 --- a/src/app/shared/components/header-buttons/header-buttons.component.ts +++ b/src/app/shared/components/header-buttons/header-buttons.component.ts @@ -1,6 +1,7 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { IHeaderAngularComp } from 'ag-grid-angular'; import { IHeaderParams } from 'ag-grid-community'; +import { ElectronService } from '../../../services/electron.service'; type AllHeaderParams = IHeaderParams & { showNewButton: boolean; @@ -15,6 +16,8 @@ type AllHeaderParams = IHeaderParams & { styleUrl: './header-buttons.component.scss', }) export class HeaderButtonsComponent implements IHeaderAngularComp { + public electronService = inject(ElectronService); + public params!: AllHeaderParams; agInit(params: AllHeaderParams) { diff --git a/src/app/shared/components/icon/icon.component.html b/src/app/shared/components/icon/icon.component.html index c85a378..6c35dde 100644 --- a/src/app/shared/components/icon/icon.component.html +++ b/src/app/shared/components/icon/icon.component.html @@ -1,4 +1,4 @@ @if(icon(); as icon) { - + } \ No newline at end of file diff --git a/src/app/shared/components/icon/icon.component.ts b/src/app/shared/components/icon/icon.component.ts index 63fb952..398c6e1 100644 --- a/src/app/shared/components/icon/icon.component.ts +++ b/src/app/shared/components/icon/icon.component.ts @@ -1,4 +1,5 @@ -import { Component, HostBinding, input } from '@angular/core'; +import { Component, computed, HostBinding, inject, input } from '@angular/core'; +import { ElectronService } from '../../../services/electron.service'; @Component({ selector: 'app-icon', @@ -6,11 +7,21 @@ import { Component, HostBinding, input } from '@angular/core'; styleUrl: './icon.component.scss', }) export class IconComponent { + private electronService = inject(ElectronService); + public icon = input.required(); public color = input(); public bgColor = input(); public borderColor = input(); + public baseUrl = computed(() => { + if (!this.electronService.isInElectron()) { + return 'https://play.rair.land/assets'; + } + + return 'lotr://./resources/maps/__assets'; + }); + @HostBinding('style.outline-color') get outlineColor() { return this.borderColor(); diff --git a/src/app/shared/components/sprite/sprite.component.html b/src/app/shared/components/sprite/sprite.component.html index 227efac..2322cd0 100644 --- a/src/app/shared/components/sprite/sprite.component.html +++ b/src/app/shared/components/sprite/sprite.component.html @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/shared/components/sprite/sprite.component.ts b/src/app/shared/components/sprite/sprite.component.ts index d02f513..bea1ca0 100644 --- a/src/app/shared/components/sprite/sprite.component.ts +++ b/src/app/shared/components/sprite/sprite.component.ts @@ -1,4 +1,5 @@ -import { Component, computed, input } from '@angular/core'; +import { Component, computed, inject, input } from '@angular/core'; +import { ElectronService } from '../../../services/electron.service'; type SpriteType = 'items' | 'creatures'; @@ -13,10 +14,20 @@ const divisors: Record = { styleUrl: './sprite.component.scss', }) export class SpriteComponent { + private electronService = inject(ElectronService); + public sprite = input.required(); public type = input.required<'items' | 'creatures'>(); public scale = input(1); + public baseUrl = computed(() => { + if (!this.electronService.isInElectron()) { + return 'https://play.rair.land/assets'; + } + + return 'lotr://./resources/maps/__assets'; + }); + public size = computed(() => divisors[this.type()]); public objectPosition = computed(() => { diff --git a/src/app/tabs/cores/cores-editor/cores-editor.component.html b/src/app/tabs/cores/cores-editor/cores-editor.component.html index 7ca98c5..3f5c4a6 100644 --- a/src/app/tabs/cores/cores-editor/cores-editor.component.html +++ b/src/app/tabs/cores/cores-editor/cores-editor.component.html @@ -4,7 +4,8 @@
- +
diff --git a/src/app/tabs/dialogs/dialogs-editor/dialogs-editor.component.html b/src/app/tabs/dialogs/dialogs-editor/dialogs-editor.component.html index 734a5de..1b48023 100644 --- a/src/app/tabs/dialogs/dialogs-editor/dialogs-editor.component.html +++ b/src/app/tabs/dialogs/dialogs-editor/dialogs-editor.component.html @@ -10,7 +10,8 @@
- +
diff --git a/src/app/tabs/droptables/droptables-editor/droptables-editor.component.html b/src/app/tabs/droptables/droptables-editor/droptables-editor.component.html index 1cc3066..6bf701a 100644 --- a/src/app/tabs/droptables/droptables-editor/droptables-editor.component.html +++ b/src/app/tabs/droptables/droptables-editor/droptables-editor.component.html @@ -4,7 +4,8 @@
- +
diff --git a/src/app/tabs/droptables/droptables.component.html b/src/app/tabs/droptables/droptables.component.html index b0a6c12..3c6fefa 100644 --- a/src/app/tabs/droptables/droptables.component.html +++ b/src/app/tabs/droptables/droptables.component.html @@ -1,6 +1,6 @@ @let editing = isEditing(); -@if(!canEdit()) { +@if(!canEdit() && tableItems().length === 0) {
Add items and maps first.
diff --git a/src/app/tabs/items/items-editor/items-editor.component.html b/src/app/tabs/items/items-editor/items-editor.component.html index 2d5adb1..244309f 100644 --- a/src/app/tabs/items/items-editor/items-editor.component.html +++ b/src/app/tabs/items/items-editor/items-editor.component.html @@ -17,7 +17,8 @@
- +
diff --git a/src/app/tabs/npcs/npcs-editor/npcs-editor.component.html b/src/app/tabs/npcs/npcs-editor/npcs-editor.component.html index fdf7243..8380ac8 100644 --- a/src/app/tabs/npcs/npcs-editor/npcs-editor.component.html +++ b/src/app/tabs/npcs/npcs-editor/npcs-editor.component.html @@ -10,7 +10,8 @@
- +
diff --git a/src/app/tabs/quests/quests-editor/quests-editor.component.html b/src/app/tabs/quests/quests-editor/quests-editor.component.html index a10728c..d823737 100644 --- a/src/app/tabs/quests/quests-editor/quests-editor.component.html +++ b/src/app/tabs/quests/quests-editor/quests-editor.component.html @@ -4,7 +4,8 @@
- +
diff --git a/src/app/tabs/recipes/recipes-editor/recipes-editor.component.html b/src/app/tabs/recipes/recipes-editor/recipes-editor.component.html index 4faf17e..d4ce115 100644 --- a/src/app/tabs/recipes/recipes-editor/recipes-editor.component.html +++ b/src/app/tabs/recipes/recipes-editor/recipes-editor.component.html @@ -4,7 +4,8 @@
- +
@@ -158,4 +159,4 @@ {{ editingData | json }} - + \ No newline at end of file diff --git a/src/app/tabs/spawners/spawners-editor/spawners-editor.component.html b/src/app/tabs/spawners/spawners-editor/spawners-editor.component.html index 055f2a3..876c2b7 100644 --- a/src/app/tabs/spawners/spawners-editor/spawners-editor.component.html +++ b/src/app/tabs/spawners/spawners-editor/spawners-editor.component.html @@ -4,7 +4,8 @@
- +
diff --git a/src/app/tabs/stems/stems-editor/stems-editor.component.html b/src/app/tabs/stems/stems-editor/stems-editor.component.html index 3d63d2b..99628ed 100644 --- a/src/app/tabs/stems/stems-editor/stems-editor.component.html +++ b/src/app/tabs/stems/stems-editor/stems-editor.component.html @@ -11,7 +11,8 @@
- +
diff --git a/src/app/tabs/trait-trees/trait-trees-editor/trait-trees-editor.component.html b/src/app/tabs/trait-trees/trait-trees-editor/trait-trees-editor.component.html index 580866e..f3a5c96 100644 --- a/src/app/tabs/trait-trees/trait-trees-editor/trait-trees-editor.component.html +++ b/src/app/tabs/trait-trees/trait-trees-editor/trait-trees-editor.component.html @@ -10,7 +10,8 @@
- +