|
@@ -1,8 +1,109 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
+import { Component, OnInit, OnDestroy, inject } from '@angular/core';
|
|
|
+import { Editor } from 'ngx-editor';
|
|
|
+import { Npc, Npcs } from 'src/interfaces/interfaces';
|
|
|
+import { DataService } from 'src/services/data/data.service';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-journal-npcs',
|
|
|
templateUrl: './journal-npcs.component.html',
|
|
|
styleUrl: './journal-npcs.component.scss',
|
|
|
})
|
|
|
-export class JournalNpcsComponent {}
|
|
|
+export class JournalNpcsComponent {
|
|
|
+ editor: Editor = new Editor();
|
|
|
+ toolbar: any = [
|
|
|
+ // default value
|
|
|
+ ['bold', 'italic'],
|
|
|
+ ['bullet_list'],
|
|
|
+ [{ heading: ['h3', 'h4', 'h5', 'h6'] }],
|
|
|
+ ];
|
|
|
+
|
|
|
+ public isAlliesCollapsed = false;
|
|
|
+ public isEnemiesCollapsed = false;
|
|
|
+ public isOthersCollapsed = false;
|
|
|
+
|
|
|
+ private newNpcType: string = '';
|
|
|
+
|
|
|
+ /** Used to show the interactale form or the display version of an entry. */
|
|
|
+ public isInEditMode = false;
|
|
|
+
|
|
|
+ /** The index of the currently active entry */
|
|
|
+ public currentIndex: number = 0;
|
|
|
+
|
|
|
+ private backupIndex: number = -1;
|
|
|
+ /** Indicates, if the currentEntry is a newly generated one that is still not saved. */
|
|
|
+ public isNewNpc = false;
|
|
|
+
|
|
|
+ /**The array of JournalEntries, synched to the */
|
|
|
+ public npcs: Npcs = {
|
|
|
+ allies: [
|
|
|
+ {
|
|
|
+ name: 'Guardfield',
|
|
|
+ shortDescription: 'Ein ganz besonderer Guard',
|
|
|
+ longDescription:
|
|
|
+ 'Man kann es gar nicht in Worte fassen, wie siehr wir alle diese Wache bewundern!',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'Bob',
|
|
|
+ shortDescription: 'Ein ganz besonderer Guard',
|
|
|
+ longDescription:
|
|
|
+ 'Man kann es gar nicht in Worte fassen, wie siehr wir alle diese Wache bewundern!',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'Hans',
|
|
|
+ shortDescription: 'Ein ganz besonderer Guard',
|
|
|
+ longDescription:
|
|
|
+ 'Man kann es gar nicht in Worte fassen, wie siehr wir alle diese Wache bewundern!',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ enemies: [],
|
|
|
+ others: [],
|
|
|
+ };
|
|
|
+
|
|
|
+ /** Holds the data for the current entry */
|
|
|
+ public currentNpc: Npc = {
|
|
|
+ name: '',
|
|
|
+ shortDescription: '',
|
|
|
+ longDescription: '',
|
|
|
+ };
|
|
|
+
|
|
|
+ private dataService: DataService = inject(DataService);
|
|
|
+ onInit(): void {
|
|
|
+ // this.npcs = this.dataService.npcsData;
|
|
|
+ // console.log('JournalNpcsComponent: ', this.npcs);
|
|
|
+ }
|
|
|
+
|
|
|
+ // FUNCTIONS
|
|
|
+
|
|
|
+ public selectNpc(index: number, type: string): void {
|
|
|
+ this.currentIndex = index;
|
|
|
+ this.newNpcType = type;
|
|
|
+ this.currentNpc = this.getNpc();
|
|
|
+ this.isNewNpc = false;
|
|
|
+ this.isInEditMode = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public addNpc(type: string): void {
|
|
|
+ this.currentNpc = {
|
|
|
+ name: '',
|
|
|
+ shortDescription: '',
|
|
|
+ longDescription: '',
|
|
|
+ };
|
|
|
+ this.isInEditMode = true;
|
|
|
+ this.isNewNpc = true;
|
|
|
+ this.backupIndex = this.currentIndex;
|
|
|
+ this.newNpcType = type;
|
|
|
+ }
|
|
|
+
|
|
|
+ private getNpc(): Npc {
|
|
|
+ switch (this.newNpcType) {
|
|
|
+ case 'allies':
|
|
|
+ return this.npcs.allies[this.currentIndex];
|
|
|
+ case 'enemies':
|
|
|
+ return this.npcs.enemies[this.currentIndex];
|
|
|
+ case 'others':
|
|
|
+ return this.npcs.others[this.currentIndex];
|
|
|
+ default:
|
|
|
+ return this.npcs.allies[this.currentIndex];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|