diff --git a/src/app/app.component.ts b/src/app/app.component.ts index fc9e189..fbdd765 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -204,7 +204,7 @@ export class AppComponent implements OnInit{ const gamesystemParser = new GamesystemParser(scriptAccounts); const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems); - const characterParser = new CharacterParser(gamesystemParser.getAllParsedGamesystems(), scriptAccounts); + const characterParser = new CharacterParser(gamesystemParser.getAllParsedGamesystems(), scriptAccounts, gamesystemParser.parsedStates); const characters = characterParser.parseCharacters(storedGameModel.storedCharacters); gameModel.scriptAccounts = scriptAccounts diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.ts b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.ts index a90b51a..592f1a7 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core'; import {TemplateGamesystem} from "../../../../project/game-model/gamesystems/TemplateGamesystem"; import {AppModule} from "../../../../app.module"; import {animate, state, style, transition, trigger} from "@angular/animations"; @@ -20,7 +20,7 @@ import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems ]), ], }) -export class TemplateTransitionEditorComponent { +export class TemplateTransitionEditorComponent implements OnChanges{ @Input() templateGamesystem: TemplateGamesystem | undefined @Input() scriptAccounts: ScriptAccount[] = [] @@ -31,6 +31,9 @@ export class TemplateTransitionEditorComponent { columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; expandedElement: SimpleTransition | null = null; + ngOnChanges() { + this.dataSource.data = this.templateGamesystem!.templateTransitions + } applyFilter(event: KeyboardEvent) { const filterValue = (event.target as HTMLInputElement).value; diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index 998b26f..dbb6661 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -3,14 +3,15 @@ import {Character} from "../../game-model/characters/Character"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {TemplateParser} from "../templateParser/TemplateParser"; import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; +import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; export class CharacterParser { private templateParser: TemplateParser - constructor(gamesystems: Gamesystem[], scriptAccounts: ScriptAccount[]) { - this.templateParser = new TemplateParser(gamesystems, scriptAccounts) + constructor(gamesystems: Gamesystem[], scriptAccounts: ScriptAccount[], states: SimpleState[]) { + this.templateParser = new TemplateParser(gamesystems, scriptAccounts, states) } public parseCharacters(characters: StoreComponent[]): Character[] { diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index c8542ea..5c26a3e 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -6,11 +6,13 @@ import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; import {StateParser} from "./StateParser"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {TransitionParser} from "./TransitionParser"; +import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; export class GamesystemParser { private parsedParentGamesystems: ParsedParentGamesystems[] = [] private parsedGamesystems: Gamesystem[] = [] + parsedStates: SimpleState[] = [] private scriptAccounts: ScriptAccount[] @@ -46,6 +48,7 @@ export class GamesystemParser { const stateParser = new StateParser(this.scriptAccounts); simpleGamesystem.states = stateParser.parseStates(gamesystemData.states) + this.parsedStates = this.parsedStates.concat(simpleGamesystem.states) const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions) diff --git a/src/app/project/parser/templateParser/TemplateParser.ts b/src/app/project/parser/templateParser/TemplateParser.ts index 9e3169e..888da7d 100644 --- a/src/app/project/parser/templateParser/TemplateParser.ts +++ b/src/app/project/parser/templateParser/TemplateParser.ts @@ -4,15 +4,19 @@ import {TemplateGamesystem} from "../../game-model/gamesystems/TemplateGamesyste import {StateParser} from "../gamesystemParser/StateParser"; import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; +import {TransitionParser} from "../gamesystemParser/TransitionParser"; +import {SimpleState} from "../../game-model/gamesystems/states/SimpleState"; export class TemplateParser { private gamesystems: Gamesystem[] private stateParser: StateParser + private transitionParser: TransitionParser - constructor(gamesystems: Gamesystem[], scriptAccounts: ScriptAccount[]) { + constructor(gamesystems: Gamesystem[], scriptAccounts: ScriptAccount[], states: SimpleState[]) { this.gamesystems = gamesystems; this.stateParser = new StateParser(scriptAccounts); + this.transitionParser = new TransitionParser(states, scriptAccounts) } parseTemplateGamesystems(templateGamesystemData: any): TemplateGamesystem[] { @@ -35,7 +39,7 @@ export class TemplateParser { const templateStates = this.stateParser.parseStates(templateGamesystemData.templateStates) const templateSystem = new TemplateGamesystem(referencedGamesystem as SimpleGamesystem); templateSystem.templateStates = templateStates - + templateSystem.templateTransitions = this.transitionParser.parseTransitions(templateGamesystemData.templateTransitions); return templateSystem }