diff --git a/src/app/editor/editor.component.html b/src/app/editor/editor.component.html index dc13cc1..688e3bf 100644 --- a/src/app/editor/editor.component.html +++ b/src/app/editor/editor.component.html @@ -11,7 +11,8 @@ + [gamesystem]="convertModelComponentToGamesystem(modelComponent)" + (onOpenGamesystemEditor)="openGameModelComponent($event)"> diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index 84988b6..624b252 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,2 +1,3 @@ - + diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index 666f6a6..e21373f 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -1,4 +1,4 @@ -import {Component, Input} from '@angular/core'; +import {Component, EventEmitter, Input, Output} from '@angular/core'; import {GameModel} from "../../game-model/GameModel"; import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; import {State} from "../../game-model/gamesystems/State"; @@ -14,6 +14,7 @@ import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem" export class GamesystemEditorComponent { @Input() gamesystem: Gamesystem, Transition> | undefined + @Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter(); isSimpleGamesystem() { return this.gamesystem instanceof SimpleGamesystem; @@ -30,4 +31,8 @@ export class GamesystemEditorComponent { return this.gamesystem as ProductGamesystem; } } + + onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { + this.openGamesystemEmitter.emit(gamesystem); + } } diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html index 65a72dd..d505323 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html @@ -1 +1 @@ - + diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts index 5648def..c5416a4 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts @@ -1,6 +1,7 @@ -import {Component, Input} from '@angular/core'; +import {Component, EventEmitter, Input, Output} from '@angular/core'; import {ProductGamesystem} from "../../../game-model/gamesystems/ProductGamesystem"; import {ProductStateEditorComponent} from "../state-editor/product-state-editor/product-state-editor.component"; +import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; @Component({ selector: 'app-product-gamesystem-editor', @@ -14,4 +15,9 @@ import {ProductStateEditorComponent} from "../state-editor/product-state-editor/ export class ProductGamesystemEditorComponent { @Input() gamesystem: ProductGamesystem | undefined + @Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter(); + + onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { + this.openGamesystemEditorEmitter.emit(gamesystem); + } } diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html index 2d1c8bb..5fbd207 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.html @@ -2,7 +2,7 @@ {{col}} - {{getStateLabel(state, i)}} + {{getLeafState(state, i).stateLabel}} {{state.initial? 'done':'close'}} diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts index 0332f73..23e6bb4 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {ProductGamesystem} from "../../../../game-model/gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import { @@ -16,6 +16,7 @@ import {State} from "../../../../game-model/gamesystems/State"; import {NgForOf, NgIf} from "@angular/common"; import {ProductState} from "../../../../game-model/gamesystems/ProductState"; import {MatIcon} from "@angular/material/icon"; +import {Gamesystem} from "../../../../game-model/gamesystems/Gamesystem"; @Component({ selector: 'app-product-state-editor', @@ -41,6 +42,7 @@ import {MatIcon} from "@angular/material/icon"; export class ProductStateEditorComponent implements OnInit{ @Input() gamesystem: ProductGamesystem | undefined + @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter(); displayedColumns: string[] = []; datasource = new MatTableDataSource(); @@ -64,8 +66,8 @@ export class ProductStateEditorComponent implements OnInit{ protected readonly SimpleState = SimpleState; - getStateLabel(state: State, i: number) { - return this.computeLeafStates(state)[i].stateLabel; + getLeafState(state: State, i: number) { + return this.computeLeafStates(state)[i]; } computeLeafStates(state: State) { @@ -80,4 +82,23 @@ export class ProductStateEditorComponent implements OnInit{ return leafStates; } } + + clickOnInnerState(leafIndex: number) { + const leaf_gamesystems = this.computeLeafGamesystems(this.gamesystem!); + const clicked_gamesystem = leaf_gamesystems[leafIndex]; + this.openGamesystemEditorEmitter.emit(clicked_gamesystem); + } + + computeLeafGamesystems(gamesystem: Gamesystem) { + if(gamesystem instanceof SimpleGamesystem) { + return [gamesystem]; + } else { + const product_gamesystem = gamesystem as ProductGamesystem; + const leaf_gamesystems: SimpleGamesystem[] = []; + product_gamesystem.innerGamesystems.forEach(innerGamesystem => { + this.computeLeafGamesystems(innerGamesystem).forEach(leafGamesystem => leaf_gamesystems.push(leafGamesystem)) + }) + return leaf_gamesystems; + } + } }