diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2ff3758..4bfac7a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -175,27 +175,6 @@ export class AppComponent implements OnInit{ }) } - private onCreateNewGamesystem(templateType: TemplateType | undefined) { - let parentGamesystemName = undefined - if(this.openContent != ModelComponentType.GAMESYTEM) { - this.openGamesystemsOverview(); - } else { - parentGamesystemName = this.gamesystemOverview!.selectedGamesystemName; - } - - - let createdGamesystem; - if(parentGamesystemName == undefined) { - createdGamesystem = this.gameModel?.createSimpleGamesystem("New Gamesystem", templateType); - } else { - createdGamesystem = this.gameModel!.createSimpleGamesystemWithParent("New Gamesystem", parentGamesystemName, templateType) - } - - if(createdGamesystem != undefined) { - this.gamesystemOverview!.refresh(); - this.editor?.openGameModelComponent(createdGamesystem); - } - } private getSelectedModelComponent(): ModelComponent | undefined { if(this.openContent == ModelComponentType.SCRIPTACCOUNT) { @@ -332,8 +311,12 @@ export class AppComponent implements OnInit{ get openedOverview(): Overview | undefined { if(this.openContent === ModelComponentType.ITEMGROUP || this.openContent === ModelComponentType.ITEM) { return this.itemOverview; - } else { - return undefined; + } else if(this.openContent === ModelComponentType.SCRIPTACCOUNT) { + return this.scriptAccountOverview; + } else if(this.openContent === ModelComponentType.CHARACTER) { + return this.characterOverview; + } else if(this.openContent === ModelComponentType.GAMESYTEM) { + return this.gamesystemOverview; } } } diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index 2b77cdc..eb2dc3e 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -32,14 +32,12 @@ export class ProductGamesystem extends Gamesystem, producttemplateType: TemplateType | undefined): ProductGamesystem | undefined { + if(!(simpleGamesystem instanceof ProductTemplateSystem) && producttemplateType != undefined) { + console.log("Wierd, Debug") + return ProductTemplateCreator.convertProductToTemplate(simpleGamesystem as ProductGamesystem, this.gameModel, producttemplateType); + } + + if(simpleGamesystem instanceof ProductGamesystem) { + console.log("Wierder Debug") + return simpleGamesystem; + } + + let productGamesystem: ProductGamesystem + if(producttemplateType != undefined) { + productGamesystem = new ProductTemplateSystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription, producttemplateType); + } else { + productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription); + } + + this.constructGamesystemHierarchy(productGamesystem, simpleGamesystem as SimpleGamesystem) + return productGamesystem; + } + + private constructGamesystemHierarchy(productGamesystem: ProductGamesystem, simpleGamesystem: SimpleGamesystem) { + const simpleParentGamesystem = simpleGamesystem.parentGamesystem; + + if(simpleGamesystem.states.length > 0) { + simpleGamesystem.componentName += "(Child)"; + if(simpleParentGamesystem == undefined) { + this.gameModel.removeGamesystem(simpleGamesystem); + productGamesystem.addChildGamesystem(simpleGamesystem); + this.gameModel.addGamesystem(productGamesystem); + } else { + simpleParentGamesystem.removeChildGamesystem(simpleGamesystem); + productGamesystem.addChildGamesystem(simpleGamesystem); + simpleParentGamesystem.addChildGamesystem(productGamesystem); + } + } else { + if(simpleParentGamesystem == undefined) { + this.gameModel.removeGamesystem(simpleGamesystem); + this.gameModel.addGamesystem(productGamesystem); + } else { + simpleParentGamesystem.removeChildGamesystem(simpleGamesystem); + simpleParentGamesystem.addChildGamesystem(productGamesystem); + } + } + } } diff --git a/src/app/side-overviews/character-overview/character-overview.component.ts b/src/app/side-overviews/character-overview/character-overview.component.ts index c182485..50ad56a 100644 --- a/src/app/side-overviews/character-overview/character-overview.component.ts +++ b/src/app/side-overviews/character-overview/character-overview.component.ts @@ -5,13 +5,17 @@ import {MatIcon} from "@angular/material/icon"; import {NgClass, NgForOf} from "@angular/common"; import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; import {Character} from "../../project/game-model/characters/Character"; +import {Overview} from "../Overview"; @Component({ selector: 'app-character-overview', templateUrl: './character-overview.component.html', styleUrl: './character-overview.component.scss' }) -export class CharacterOverviewComponent { +export class CharacterOverviewComponent implements Overview{ + refresh(): void { + //Nothing to-do + } @Input() gameModel: GameModel | undefined @Output("onOpenCharacterEditor") openCharacterEmitter: EventEmitter = new EventEmitter(); diff --git a/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts b/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts index 3194a5f..4c6fe9c 100644 --- a/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts +++ b/src/app/side-overviews/gamescript-overview/gamescript-overview.component.ts @@ -8,6 +8,7 @@ import {State} from "../../project/game-model/gamesystems/states/State"; import {Transition} from "../../project/game-model/gamesystems/transitions/Transition"; import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; +import {Overview} from "../Overview"; interface FlatNode { @@ -20,7 +21,7 @@ interface FlatNode { templateUrl: './gamescript-overview.component.html', styleUrl: './gamescript-overview.component.scss' }) -export class GamescriptOverviewComponent implements OnInit { +export class GamescriptOverviewComponent implements OnInit, Overview { @Input('gameModel') gameModel: GameModel | undefined @Output('openGamesystemEditor') openGamesystemEmitter : EventEmitter, Transition>> = new EventEmitter, Transition>>(); diff --git a/src/app/side-overviews/script-account-overview/script-account-overview.component.ts b/src/app/side-overviews/script-account-overview/script-account-overview.component.ts index 3643289..fce194e 100644 --- a/src/app/side-overviews/script-account-overview/script-account-overview.component.ts +++ b/src/app/side-overviews/script-account-overview/script-account-overview.component.ts @@ -2,13 +2,14 @@ import {Component, EventEmitter, Input, NgZone, Output} from '@angular/core'; import {ElectronService} from "../../core/services"; import {GameModel} from "../../project/game-model/GameModel"; import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; +import {Overview} from "../Overview"; @Component({ selector: 'app-script-account-overview', templateUrl: './script-account-overview.component.html', styleUrl: './script-account-overview.component.css' }) -export class ScriptAccountOverviewComponent { +export class ScriptAccountOverviewComponent implements Overview{ @Input("gameModel") gameModel: GameModel | undefined @Output("onOpenScriptAccount") openScriptAccountEmitter: EventEmitter = new EventEmitter(); @@ -17,6 +18,10 @@ export class ScriptAccountOverviewComponent { constructor() { } + refresh(): void { + //Nothing to do + } + onOpenScriptAccount(scriptAccount: ScriptAccount) { console.log("onOpenScriptAccount (overview)") this.openScriptAccountEmitter.emit(scriptAccount); diff --git a/testModel/gamesystems/Parentgamesystem.json b/testModel/gamesystems/Parentgamesystem.json new file mode 100644 index 0000000..75902da --- /dev/null +++ b/testModel/gamesystems/Parentgamesystem.json @@ -0,0 +1,7 @@ +{ + "componentName": "Parentgamesystem", + "componentDescription": "", + "states": [], + "transitions": [], + "generateIsolatedStates": false +} \ No newline at end of file