{{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;
+ }
+ }
}
|