Persist ScriptAccountActions to TemplateTransition
All checks were successful
E2E Testing / test (push) Successful in 2m9s
All checks were successful
E2E Testing / test (push) Successful in 2m9s
This commit is contained in:
parent
b9b5384ca4
commit
f11e290a6b
@ -1,4 +1,4 @@
|
|||||||
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts" [templateReference]="templateReference"></app-simple-state-editor>
|
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts" [templateReference]="templateReference"></app-simple-state-editor>
|
||||||
<div id="transition-editor">
|
<div id="transition-editor">
|
||||||
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
<app-simple-transition-editor [templateReference]="templateReference" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,6 +3,10 @@ import {MatTableDataSource} from "@angular/material/table";
|
|||||||
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition";
|
import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition";
|
||||||
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
||||||
|
import {Character} from "../../../../project/game-model/characters/Character";
|
||||||
|
import {
|
||||||
|
SimpleTemplateTransition
|
||||||
|
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-scriptaccount-action-editor',
|
selector: 'app-scriptaccount-action-editor',
|
||||||
@ -13,6 +17,7 @@ export class ScriptaccountActionEditorComponent implements OnInit{
|
|||||||
@Input() transition: Transition<any> | undefined
|
@Input() transition: Transition<any> | undefined
|
||||||
@Input() scriptAccounts: ScriptAccount[] = []
|
@Input() scriptAccounts: ScriptAccount[] = []
|
||||||
@Input() enableEditing: boolean = false;
|
@Input() enableEditing: boolean = false;
|
||||||
|
@Input() templateReference: Character | undefined
|
||||||
|
|
||||||
dataSource: MatTableDataSource<ScriptAccountAction> = new MatTableDataSource();
|
dataSource: MatTableDataSource<ScriptAccountAction> = new MatTableDataSource();
|
||||||
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
|
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
|
||||||
@ -21,7 +26,17 @@ export class ScriptaccountActionEditorComponent implements OnInit{
|
|||||||
addedAction: ScriptAccountAction | undefined
|
addedAction: ScriptAccountAction | undefined
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dataSource.data = this.transition!.scriptAccountActions.map(action => action);
|
if(this.transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
|
||||||
|
if(this.transition!.actionMap.has(this.templateReference!)) {
|
||||||
|
this.dataSource.data = this.transition!.actionMap.get(this.templateReference)!
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.transition!.scriptAccountActions
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.transition!.scriptAccountActions
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!this.enableEditing) {
|
if(!this.enableEditing) {
|
||||||
this.displayedColumns = this.displayedColumns.slice(0, -2);
|
this.displayedColumns = this.displayedColumns.slice(0, -2);
|
||||||
@ -41,12 +56,21 @@ export class ScriptaccountActionEditorComponent implements OnInit{
|
|||||||
|
|
||||||
finishEditing() {
|
finishEditing() {
|
||||||
if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') {
|
if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') {
|
||||||
this.transition?.addScriptAccountAction(this.addedAction)
|
if(this.transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
|
||||||
console.log(this.addedAction.scriptAccount)
|
const templateTransition = this.transition as SimpleTemplateTransition<Character>
|
||||||
this.dataSource.data = this.transition!.scriptAccountActions;
|
if(templateTransition.actionMap.has(this.templateReference!)) {
|
||||||
console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length)
|
templateTransition.actionMap.get(this.templateReference!)!.push(this.addedAction)
|
||||||
|
} else {
|
||||||
|
templateTransition.actionMap.set(this.templateReference!, [this.addedAction]);
|
||||||
|
}
|
||||||
|
this.dataSource.data = this.transition!.actionMap.get(this.templateReference)!;
|
||||||
|
} else {
|
||||||
|
this.transition?.addScriptAccountAction(this.addedAction)
|
||||||
|
this.dataSource.data = this.transition!.scriptAccountActions;
|
||||||
|
}
|
||||||
this.addedAction = undefined;
|
this.addedAction = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editedAction = undefined;
|
this.editedAction = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
||||||
<div class="condition-action-container">
|
<div class="condition-action-container">
|
||||||
<div class="action-container">
|
<div class="action-container">
|
||||||
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true"></app-scriptaccount-action-editor>
|
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true" [templateReference]="templateReference"></app-scriptaccount-action-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="condition-container">
|
<div class="condition-container">
|
||||||
<app-scriptaccount-condition-editor [conditions]="element.scriptAccountConditions" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
<app-scriptaccount-condition-editor [conditions]="element.scriptAccountConditions" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
||||||
|
@ -12,6 +12,7 @@ import {SimpleTemplateGamesystem} from "../../../../project/game-model/gamesyste
|
|||||||
import {
|
import {
|
||||||
SimpleTemplateTransition
|
SimpleTemplateTransition
|
||||||
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
|
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
|
||||||
|
import {Character} from "../../../../project/game-model/characters/Character";
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-simple-transition-editor',
|
selector: 'app-simple-transition-editor',
|
||||||
templateUrl: './simple-transition-editor.component.html',
|
templateUrl: './simple-transition-editor.component.html',
|
||||||
@ -29,6 +30,7 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
|||||||
@Input() gamesystem: SimpleGamesystem | undefined
|
@Input() gamesystem: SimpleGamesystem | undefined
|
||||||
@Input() scriptAccounts: ScriptAccount[] = []
|
@Input() scriptAccounts: ScriptAccount[] = []
|
||||||
@Input() referenceEditor: boolean = false
|
@Input() referenceEditor: boolean = false
|
||||||
|
@Input() templateReference: Character | undefined
|
||||||
@Output() referenceTransitionEmitter: EventEmitter<SimpleTransition> = new EventEmitter<SimpleTransition>()
|
@Output() referenceTransitionEmitter: EventEmitter<SimpleTransition> = new EventEmitter<SimpleTransition>()
|
||||||
displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"];
|
displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"];
|
||||||
dataSource = new MatTableDataSource<SimpleTransition>();
|
dataSource = new MatTableDataSource<SimpleTransition>();
|
||||||
|
@ -71,7 +71,12 @@
|
|||||||
"endingState": "Winter"
|
"endingState": "Winter"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"scriptAccountActions": [],
|
"scriptAccountActions": [
|
||||||
|
{
|
||||||
|
"changingValue": 10,
|
||||||
|
"scriptAccount": "Temperature"
|
||||||
|
}
|
||||||
|
],
|
||||||
"scriptAccountConditions": [],
|
"scriptAccountConditions": [],
|
||||||
"startingState": "Winter",
|
"startingState": "Winter",
|
||||||
"endingState": "Frühling"
|
"endingState": "Frühling"
|
||||||
|
Loading…
Reference in New Issue
Block a user