From 3b00a46c2586f8be5bcee162d22b2b547b3d37ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 20 Apr 2024 17:06:26 +0200 Subject: [PATCH] Create New Items --- app/main.ts | 6 ++++++ src/app/app.component.ts | 8 ++++++++ src/app/project/game-model/GameModel.ts | 2 ++ src/app/project/game-model/inventory/Item.ts | 7 ------- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/main.ts b/app/main.ts index c4ffd82..306c942 100644 --- a/app/main.ts +++ b/app/main.ts @@ -97,6 +97,12 @@ function createWindow(): BrowserWindow { click: () => { win!.webContents.send('context-menu', "new-character"); } + }, + { + label: 'Item', + click: () => { + win!.webContents.send('context-menu', "new-item"); + } } ] diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 64992c3..5fc052b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -138,6 +138,7 @@ export class AppComponent implements OnInit{ case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(templateType); break case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break + case ModelComponentType.ITEM: this.onCreateNewItem(); break } } @@ -181,6 +182,13 @@ export class AppComponent implements OnInit{ } } + private onCreateNewItem() { + const createdItem = this.gameModel!.createInventoryItem("New Item"); + if(createdItem != undefined) { + this.editor?.openGameModelComponent(createdItem); + } + } + private getSelectedModelComponent(): ModelComponent | undefined { if(this.openContent == ModelComponentType.SCRIPTACCOUNT) { if(this.scriptAccountOverview != undefined) { diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 4ba59a8..30e8383 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -107,7 +107,9 @@ export class GameModel { if(itemName != undefined) { const item = new Item(itemName, "", ModelComponentType.ITEM); this.inventoryItems.push(item); + return item; } + return undefined; } createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined, templateType: TemplateType | undefined) { diff --git a/src/app/project/game-model/inventory/Item.ts b/src/app/project/game-model/inventory/Item.ts index 13f8a35..a6ba802 100644 --- a/src/app/project/game-model/inventory/Item.ts +++ b/src/app/project/game-model/inventory/Item.ts @@ -13,13 +13,6 @@ export class Item extends ModelComponent { constructor(componentName: string, componentDescription: string, type: ModelComponentType) { super(componentName, componentDescription, type); - this.itemProperties.push(new ItemProperty("Weight", "Some Weights", 10)) - this.possible_qualities.push(new ItemQuality(0.25)) - this.possible_qualities.push(new ItemQuality(0.50)) - this.possible_qualities.push(new ItemQuality(0.75)) - this.possible_qualities.push(new ItemQuality(1.00)) - - this.addPerQualityProperty(new ItemPropertyDescription("Price", "Price to buy item")) } removePerQualityProperty(qualityProperty: ItemPropertyDescription) {