From 0e954f1b4827dff1b1a59e8ba552203e726572f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 11 May 2024 09:32:57 +0200 Subject: [PATCH] Rename Inventoryslots --- .../inventory-slot-creator.component.html | 2 +- .../inventory-slot-creator.component.scss | 3 +++ .../inventory-slot-creator.component.ts | 18 +++++++++++++++--- .../inventory-slot-editor.component.html | 2 +- .../inventory-slot-editor.component.ts | 9 +++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html index 3dd619f..f1f80a3 100644 --- a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html @@ -1,4 +1,4 @@ -

Create Inventory Slot

+

{{data == undefined ? 'Create New Inventory Slot':'Rename Inventory Slot'}}

Slot-Name diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.scss b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.scss index e69de29..4e80027 100644 --- a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.scss +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.scss @@ -0,0 +1,3 @@ +.long-form { + width: 100%; +} diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts index 1058c63..a2b75db 100644 --- a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts @@ -1,4 +1,4 @@ -import {Component, Inject} from '@angular/core'; +import {Component, Inject, OnInit} from '@angular/core'; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {InventorySlot} from "../../../../project/game-model/inventory/intentory-slots/InventorySlot"; import {FormControl, Validators} from "@angular/forms"; @@ -8,17 +8,29 @@ import {FormControl, Validators} from "@angular/forms"; templateUrl: './inventory-slot-creator.component.html', styleUrl: './inventory-slot-creator.component.scss' }) -export class InventorySlotCreatorComponent { +export class InventorySlotCreatorComponent implements OnInit{ slotNameCtrl = new FormControl('', [Validators.required]); constructor(private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: InventorySlot | undefined) { + } + ngOnInit() { + if(this.data != undefined) { + this.slotNameCtrl.setValue(this.data.slotName); + } + } submit() { - this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!)) + if(this.data != undefined) { + this.data.slotName = this.slotNameCtrl.value!; + this.dialogRef.close(this.data); + } else { + this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!)) + } + } cancel() { diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html index 71a6528..7ec0516 100644 --- a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html @@ -4,7 +4,7 @@ {{slot.slotName}}
- +
diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts index c364410..d78ac36 100644 --- a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts @@ -29,4 +29,13 @@ export class InventorySlotEditorComponent { } }) } + + renameInventorySlot(inventorySlot: InventorySlot) { + this.dialog.open(InventorySlotCreatorComponent, { + minWidth: "400px", + data: inventorySlot + }) + } + + protected readonly indexedDB = indexedDB; }