Skip to content

Commit

Permalink
closes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 15, 2024
1 parent 16ab241 commit 959111b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="flex relative">
<app-sprite class="absolute -top-5 -left-5" [scale]="0.5" [type]="type()" [sprite]="sprite()"></app-sprite>

<span class="ml-7">{{ name() }}</span>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component, computed, inject, input } from '@angular/core';
import { ModService } from '../../../services/mod.service';

@Component({
selector: 'app-sprite-with-inline-name',
templateUrl: './sprite-with-inline-name.component.html',
styleUrl: './sprite-with-inline-name.component.scss',
})
export class SpriteWithInlineNameComponent {
private modService = inject(ModService);

public name = input.required<string>();
public type = input.required<'items' | 'creatures'>();

public sprite = computed(() => {
const mod = this.modService.mod();
const name = this.name();
const type = this.type();

if (type === 'items') {
const foundItem = mod.items.find((i) => i.name === name);
return foundItem?.sprite ?? -1;
}

if (type === 'creatures') {
const foundNpc = mod.npcs.find((i) => i.npcId === name);
return foundNpc?.sprite[0] ?? -1;
}

return -1;
});
}
3 changes: 3 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { InputNpcComponent } from './components/input-npc/input-npc.component';
import { InputQuesttypeComponent } from './components/input-questtype/input-questtype.component';
import { InputQuestrewardComponent } from './components/input-questreward/input-questreward.component';
import { InputMapnpcComponent } from './components/input-mapnpc/input-mapnpc.component';
import { SpriteWithInlineNameComponent } from './components/sprite-with-inline-name/sprite-with-inline-name.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -82,6 +83,7 @@ import { InputMapnpcComponent } from './components/input-mapnpc/input-mapnpc.com
InputQuesttypeComponent,
InputQuestrewardComponent,
InputMapnpcComponent,
SpriteWithInlineNameComponent,
],
imports: [
CommonModule,
Expand Down Expand Up @@ -129,6 +131,7 @@ import { InputMapnpcComponent } from './components/input-mapnpc/input-mapnpc.com
InputQuesttypeComponent,
InputQuestrewardComponent,
InputMapnpcComponent,
SpriteWithInlineNameComponent,
],
})
export class SharedModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<div class="form-row split">
<div class="form-column">
<div class="form-row">
{{ drop.result }}
<app-sprite-with-inline-name [name]="drop.result" type="items"></app-sprite-with-inline-name>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
<div class="form-row split">
<div class="form-column">
<div class="form-row pl-1">
{{ item.result }}
<app-sprite-with-inline-name [name]="item.result" type="items"></app-sprite-with-inline-name>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<div class="form-row split">
<div class="form-column">
<div class="form-row">
{{ npc }}
<app-sprite-with-inline-name [name]="npc" type="creatures"></app-sprite-with-inline-name>
</div>
</div>

Expand Down Expand Up @@ -219,4 +219,4 @@

<app-debug-view>
{{ editingData | json }}
</app-debug-view>
</app-debug-view>
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
<div class="form-row split">
<div class="form-column">
<div class="form-row">
{{ npc.result }}
<app-sprite-with-inline-name [name]="npc.result" type="creatures"></app-sprite-with-inline-name>
</div>
</div>

Expand Down

0 comments on commit 959111b

Please sign in to comment.