diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a016545..c972bbf 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -20,6 +20,8 @@ import {ElectronService} from "./core/services"; import {ScriptAccountSerializer} from "./project/serializer/ScriptAccountSerializer"; import {StoreComponent} from "../../app/storage/StoreComponent"; import {GamesystemSerializer} from "./project/serializer/GamesystemSerializer"; +import {Character} from "./project/game-model/characters/Character"; +import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component"; @Component({ selector: 'app-root', @@ -33,6 +35,7 @@ export class AppComponent implements OnInit{ @ViewChild('editor') editor: EditorComponent|undefined @ViewChild('scriptAccountOverview') scriptAccountOverview: ScriptAccountOverviewComponent | undefined @ViewChild('gamesystemOverview') gamesystemOverview: GamescriptOverviewComponent | undefined + @ViewChild('characterOverview') characterOverview: CharacterOverviewComponent | undefined gameModel: GameModel | undefined @@ -109,6 +112,8 @@ export class AppComponent implements OnInit{ this.gameModel!.removeGamesystem(affectedModelComponent); //this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.GAMESYTEM)) this.gamesystemOverview!.refresh() + } else if(affectedModelComponent instanceof Character) { + this.gameModel!.removeCharacter(affectedModelComponent) } } }) @@ -169,6 +174,12 @@ export class AppComponent implements OnInit{ } else { console.log("[WARN] [App.component] GamesystemOverview is undefined") } + } else if(this.openContent == ModelComponentType.CHARACTER) { + if(this.characterOverview != undefined) { + return this.characterOverview.selectedCharacter; + } else { + console.log("[WARN] [App.component] ScriptAccountOverview is undefined") + } } return undefined; } diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index e4311b0..61b8c41 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -85,6 +85,12 @@ export class GameModel { } } + removeCharacter(character: Character) { + if(character != undefined) { + this.characters = this.characters.filter(c => c.componentName !== character.componentName) + } + } + findGamesystem(gamesystemName: string) { const gamesystemQueue : Gamesystem, Transition>[] = []; this.gamesystems.forEach(gamesystem => gamesystemQueue.push(gamesystem));