diff --git a/app/main.ts b/app/main.ts index f651a10..7745629 100644 --- a/app/main.ts +++ b/app/main.ts @@ -71,6 +71,12 @@ function createWindow(): BrowserWindow { click: () => { win!.webContents.send('context-menu', "new-scriptaccount"); } + }, + { + label: "Character", + click: () => { + win!.webContents.send('context-menu', "new-character"); + } } ] diff --git a/src/app/app.component.ts b/src/app/app.component.ts index fc3303d..a016545 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -118,6 +118,7 @@ export class AppComponent implements OnInit{ switch (modelComponentType) { case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(); break + case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break } } @@ -146,6 +147,15 @@ export class AppComponent implements OnInit{ } } + private onCreateNewCharacter() { + const createdCharacter = this.gameModel!.createCharacter("New Character") + if(createdCharacter != undefined) { + this.editor?.openGameModelComponent(createdCharacter); + } else { + console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)"); + } + } + private getSelectedModelComponent(): ModelComponent | undefined { if(this.openContent == ModelComponentType.SCRIPTACCOUNT) { if(this.scriptAccountOverview != undefined) { @@ -239,4 +249,6 @@ export class AppComponent implements OnInit{ this.gamesystemOverview.resetSelectedGamesystem() } } + + } diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 5ac5c22..e4311b0 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -16,8 +16,8 @@ export class GameModel { constructor(gameModelName: string) { this.gameModelName = gameModelName; - this.characters.push(new Character("Astrid Hofferson", "", ModelComponentType.CHARACTER)) - this.characters.push(new Character("Hicks Haddock", "", ModelComponentType.CHARACTER)) + this.characters.push(new Character("Astrid Hofferson", "")) + this.characters.push(new Character("Hicks Haddock", "")) } addGamesystem(gamesystem: Gamesystem) { @@ -69,6 +69,16 @@ export class GameModel { } } + createCharacter(characterName: string) { + const searchedCharacter = this.characters.find(character => character.componentName === characterName); + if(searchedCharacter == undefined) { + const character = new Character(characterName, ""); + this.characters.push(character) + return character + } + return undefined + } + removeScriptAccount(scriptAccount: ScriptAccount) { if(scriptAccount != undefined) { this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount); diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 711ca1a..07acf19 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -3,7 +3,7 @@ import {ModelComponentType} from "../ModelComponentType"; export class Character extends ModelComponent{ - constructor(componentName: string, componentDescription: string, type: ModelComponentType) { - super(componentName, componentDescription, type); + constructor(componentName: string, componentDescription: string) { + super(componentName, componentDescription, ModelComponentType.CHARACTER); } }