From c38dcc556c20f400c73e4759c0968da206b3f42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 19:58:48 +0100 Subject: [PATCH] Unspecify CharacterSystem and Specify Charactersystem on correct occasions --- .../template-gamesystem-editor.component.html | 6 +++-- .../template-gamesystem-editor.component.ts | 16 ++++++++----- .../template-transition-editor.component.html | 4 ++-- .../template-transition-editor.component.ts | 18 +++++++------- testModel/characters/Hicks Haddock.json | 24 +++++++++++++------ 5 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html index b9939bf..03535b4 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.html @@ -1,4 +1,6 @@ - + diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts index 6d94a87..e184244 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-gamesystem-editor.component.ts @@ -14,14 +14,18 @@ export class TemplateGamesystemEditorComponent { @Input() gamesystem: TemplateGamesystem | undefined @Input() scriptAccunts: ScriptAccount[] = [] - @Output('onAddFirstTemplateState') addFirstTemplateStateEmitter: EventEmitter = new EventEmitter(); - @Output('onRemoveLastTemplateState') removeLastTemplateStateEmitter: EventEmitter = new EventEmitter(); + @Output('onSpecifyTemplate') specifyTemplate: EventEmitter = new EventEmitter(); + @Output('onUnspecifyTemplate') unspecifyTemplate: EventEmitter = new EventEmitter(); - onAddFirstTemplateState() { - this.addFirstTemplateStateEmitter.emit(this.gamesystem!) + onSpecifyTemplate() { + if(this.gamesystem!.templateTransitions.length > 0 && this.gamesystem!.templateStates.length > 0) { + this.specifyTemplate.emit(this.gamesystem!) + } } - onRemoveLastTemplateState() { - this.removeLastTemplateStateEmitter.emit(this.gamesystem!) + onUnspecifyTemplate() { + if(this.gamesystem!.templateTransitions.length == 0 && this.gamesystem!.templateStates.length == 0) { + this.unspecifyTemplate.emit(this.gamesystem!) + } } } diff --git a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.html b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.html index 3f83ab5..2032141 100644 --- a/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/template-gamesystem-editor/template-transition-editor/template-transition-editor.component.html @@ -11,14 +11,14 @@ Starting State - {{transition.startingState.stateLabel}} + {{transition.startingState.stateLabel}} Ending State - {{transition.endingState.stateLabel}} + {{transition.endingState.stateLabel}} 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 d075eb3..a90b51a 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 @@ -24,19 +24,13 @@ export class TemplateTransitionEditorComponent { @Input() templateGamesystem: TemplateGamesystem | undefined @Input() scriptAccounts: ScriptAccount[] = [] + @Output() onAddFirstTemplateTransition: EventEmitter = new EventEmitter() + @Output() onRemoveLastTemplateTransition: EventEmitter = new EventEmitter() displayedColumns: string[] = ["starting-state", "ending-state", "delete"]; dataSource = new MatTableDataSource(); columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; expandedElement: SimpleTransition | null = null; - editedTransition: SimpleTransition | undefined - editedTransitionIndex = -1; - defaultStartingState: SimpleState = new SimpleState("None", ""); - defaultEndingState: SimpleState = new SimpleState("None", ""); - - transitionError: boolean = false; - transitionStartingStateError = true; - transitionEndingStateError = true; applyFilter(event: KeyboardEvent) { const filterValue = (event.target as HTMLInputElement).value; @@ -56,9 +50,17 @@ export class TemplateTransitionEditorComponent { templateTranstion.startingState.stateLabel !== transition.startingState.stateLabel && templateTranstion.endingState.stateLabel !== transition.endingState.stateLabel); this.dataSource.data = this.templateGamesystem!.templateTransitions + + if(this.templateGamesystem!.templateTransitions.length == 0) { + this.onRemoveLastTemplateTransition.emit(transition) + } } extractReferencedTransition(transition: SimpleTransition) { + if(this.templateGamesystem!.templateTransitions.length == 0) { + this.onAddFirstTemplateTransition.emit(transition) + } + this.templateGamesystem!.addReferenceTransition(transition) this.dataSource.data = this.templateGamesystem!.templateTransitions } diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index a1b3c32..4bb79d5 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -6,16 +6,26 @@ "templateStates": [ { "initial": false, - "conditions": [ - { - "scriptAccount": "Temperature", - "minValue": 0, - "maxValue": "5" - } - ], + "conditions": [], "stateLabel": "Wütend" } ], + "templateTransitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": { + "initial": true, + "conditions": [], + "stateLabel": "Glücklich" + }, + "endingState": { + "initial": false, + "conditions": [], + "stateLabel": "Wütend" + } + } + ], "referenceGamesystem": "Characterstimmung" } ]