From 69dce0b4f720fa18c19dda60ec20db84423e479d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 20 Apr 2024 09:37:40 +0200 Subject: [PATCH] Introduce ItemQualities and PerQualitiyProperties --- src/app/app.module.ts | 3 +- .../inventory-item-editor.component.html | 66 +++++++++++++++++++ .../inventory-item-editor.component.scss | 7 ++ .../inventory-item-editor.component.ts | 45 ++++++++++++- .../item-property-editor.component.html | 12 ++-- .../item-property-editor.component.ts | 35 ++++++++-- src/app/project/game-model/inventory/Item.ts | 28 ++++++++ .../inventory/ItemPropertyDescription.ts | 10 +++ .../game-model/inventory/ItemQuality.ts | 23 ++++++- 9 files changed, 212 insertions(+), 17 deletions(-) create mode 100644 src/app/project/game-model/inventory/ItemPropertyDescription.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 99f725d..a3bac22 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -61,7 +61,7 @@ import { ProductStateEditorComponent } from "./editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component"; import {MatTooltip} from "@angular/material/tooltip"; -import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card"; +import {MatCard, MatCardActions, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card"; import { ScriptaccountActionEditorComponent } from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; @@ -181,6 +181,7 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl MatExpansionPanelTitle, MatCardTitle, MatExpansionPanelHeader, + MatCardActions, ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/editor/inventory-item-editor/inventory-item-editor.component.html b/src/app/editor/inventory-item-editor/inventory-item-editor.component.html index 5219992..d326add 100644 --- a/src/app/editor/inventory-item-editor/inventory-item-editor.component.html +++ b/src/app/editor/inventory-item-editor/inventory-item-editor.component.html @@ -1,3 +1,19 @@ + + + Item Qualtities + + + + + + {{quality.quality_step}} + + + + + + + Item Characteristics @@ -6,3 +22,53 @@ + + + + Item Quality Characteristics + + + + + + + + + + + + + + + + + + + + + + + + +
Name + {{itemProperty.propertyName}} + + Name + + + Description + {{itemProperty.propertyDescription}} + + Name + + + + + + + + + +
+
+
diff --git a/src/app/editor/inventory-item-editor/inventory-item-editor.component.scss b/src/app/editor/inventory-item-editor/inventory-item-editor.component.scss index e69de29..8830c59 100644 --- a/src/app/editor/inventory-item-editor/inventory-item-editor.component.scss +++ b/src/app/editor/inventory-item-editor/inventory-item-editor.component.scss @@ -0,0 +1,7 @@ +table { + width: 100%; +} + +.mat-column-edit, .mat-column-delete { + width: 32px; +} diff --git a/src/app/editor/inventory-item-editor/inventory-item-editor.component.ts b/src/app/editor/inventory-item-editor/inventory-item-editor.component.ts index f642cd0..68d0366 100644 --- a/src/app/editor/inventory-item-editor/inventory-item-editor.component.ts +++ b/src/app/editor/inventory-item-editor/inventory-item-editor.component.ts @@ -1,17 +1,58 @@ -import {Component, Input} from '@angular/core'; +import {Component, ElementRef, Input, OnInit, ViewChildren} from '@angular/core'; import {Character} from "../../project/game-model/characters/Character"; import {GameModel} from "../../project/game-model/GameModel"; import {Item} from "../../project/game-model/inventory/Item"; import {MatCard, MatCardContent, MatCardHeader} from "@angular/material/card"; +import {ItemPropertyDescription} from "../../project/game-model/inventory/ItemPropertyDescription"; +import {ItemPropertyEditorComponent} from "./item-property-editor/item-property-editor.component"; +import {MatTableDataSource} from "@angular/material/table"; @Component({ selector: 'app-inventory-item-editor', templateUrl: './inventory-item-editor.component.html', styleUrl: './inventory-item-editor.component.scss' }) -export class InventoryItemEditorComponent { +export class InventoryItemEditorComponent implements OnInit{ @Input() item: Item | undefined; @Input() gameModel: GameModel | undefined; + @ViewChildren('perQualityPropertyEditors') perQualityPropertyEditors: ItemPropertyEditorComponent[] = []; + displayedColumns: string[] = ['name', 'description', 'edit', 'delete'] + editedProperty: ItemPropertyDescription | undefined + + datasource: MatTableDataSource = new MatTableDataSource() + + ngOnInit() { + this.datasource.data = this.item!.perQualityProperties + } + + deletePerQualityProperty(itemProperty: ItemPropertyDescription) { + this.item!.removePerQualityProperty(itemProperty); + this.datasource.data = this.item!.perQualityProperties + this.perQualityPropertyEditors.forEach(component => component.updatedDisplayedData()) + } + + editPerQualityProperty(itemProperty: ItemPropertyDescription) { + this.editedProperty = itemProperty + } + + finishEditing() { + if(this.editedProperty!.propertyName.length > 0) { + this.item!.editPerQualityProperty(this.editedProperty!); + + this.editedProperty = undefined; + this.perQualityPropertyEditors.forEach(component => component.updatedDisplayedData()) + } + } + + addQualityProperty() { + const qualityDescription = new ItemPropertyDescription("New Property", "") + this.item!.addPerQualityProperty(qualityDescription); + this.datasource.data = this.item!.perQualityProperties + this.editedProperty = qualityDescription; + + this.perQualityPropertyEditors.forEach(component => component.updatedDisplayedData()) + + } } diff --git a/src/app/editor/inventory-item-editor/item-property-editor/item-property-editor.component.html b/src/app/editor/inventory-item-editor/item-property-editor/item-property-editor.component.html index c39b808..733f829 100644 --- a/src/app/editor/inventory-item-editor/item-property-editor/item-property-editor.component.html +++ b/src/app/editor/inventory-item-editor/item-property-editor/item-property-editor.component.html @@ -2,8 +2,8 @@ Name - {{itemProperty.propertyName}} - + {{itemProperty.propertyName}} + Name @@ -14,8 +14,8 @@
-

{{element.propertyDescription}}

- +

{{element.propertyDescription}}

+ Description @@ -46,13 +46,13 @@ - + - +