Compare commits
5 Commits
e6218e107e
...
fe63b30115
Author | SHA1 | Date | |
---|---|---|---|
fe63b30115 | |||
224468f088 | |||
5d4c9a6e58 | |||
|
e8e3c83b45 | ||
|
2a01f45bf6 |
@ -64,7 +64,7 @@ import {MatTooltip} from "@angular/material/tooltip";
|
|||||||
import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card";
|
import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card";
|
||||||
import {
|
import {
|
||||||
ScriptaccountActionEditorComponent
|
ScriptaccountActionEditorComponent
|
||||||
} from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component";
|
} from "./editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component";
|
||||||
import {
|
import {
|
||||||
ScriptaccountConditionEditorComponent
|
ScriptaccountConditionEditorComponent
|
||||||
} from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component";
|
} from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component";
|
||||||
|
@ -117,13 +117,16 @@
|
|||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
<mat-expansion-panel>
|
<mat-expansion-panel *ngIf="!isInteractionSequence(element)">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>Actions</mat-panel-title>
|
<mat-panel-title>Actions</mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<mat-tab-group>
|
<mat-tab-group>
|
||||||
<mat-tab label="ScriptAccount Actions">
|
<mat-tab label="ScriptAccount Actions">
|
||||||
<app-scriptaccount-action-editor [scriptAccounts]="gameModel!.scriptAccounts"></app-scriptaccount-action-editor>
|
<app-scriptaccount-action-editor [scriptAccounts]="gameModel!.scriptAccounts" [actions]="element.scriptAccountActions"
|
||||||
|
(onAddAction)="onAddAction(element, $event)" (onRemoveAction)="onRemoveAction(element, $event)"
|
||||||
|
[enableEditing]="true"
|
||||||
|
></app-scriptaccount-action-editor>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<mat-tab label="Inventory Actions">
|
<mat-tab label="Inventory Actions">
|
||||||
<p>Inventory Actions</p>
|
<p>Inventory Actions</p>
|
||||||
|
@ -9,6 +9,7 @@ import {Interaction} from "../../../project/game-model/interactions/Interaction"
|
|||||||
import {Condition} from "../../../project/game-model/interactions/condition/Condition";
|
import {Condition} from "../../../project/game-model/interactions/condition/Condition";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
|
import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
|
||||||
|
import {ScriptAccountAction} from "../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-character-interaction-editor',
|
selector: 'app-character-interaction-editor',
|
||||||
@ -85,4 +86,15 @@ export class CharacterInteractionEditorComponent implements OnInit{
|
|||||||
onDeleteCondition(interaction: AbstractInteraction, condition: ScriptAccountCondition) {
|
onDeleteCondition(interaction: AbstractInteraction, condition: ScriptAccountCondition) {
|
||||||
interaction!.removeCondition(condition);
|
interaction!.removeCondition(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAddAction(interaction: AbstractInteraction, action: ScriptAccountAction) {
|
||||||
|
if(interaction instanceof Interaction) {
|
||||||
|
interaction.addAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onRemoveAction(interaction: AbstractInteraction, action: ScriptAccountAction) {
|
||||||
|
if(interaction instanceof Interaction) {
|
||||||
|
interaction.removeAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
|
import {MatTableDataSource} from "@angular/material/table";
|
||||||
|
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import {Transition} from "../../../project/game-model/gamesystems/transitions/Transition";
|
||||||
|
import {ScriptAccountAction} from "../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
||||||
|
import {TemplateElement} from "../../../project/game-model/templates/TemplateElement";
|
||||||
|
import {
|
||||||
|
SimpleTemplateTransition
|
||||||
|
} from "../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition";
|
||||||
|
import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-scriptaccount-action-editor',
|
||||||
|
templateUrl: './scriptaccount-action-editor.component.html',
|
||||||
|
styleUrl: './scriptaccount-action-editor.component.scss'
|
||||||
|
})
|
||||||
|
export class ScriptaccountActionEditorComponent implements OnInit{
|
||||||
|
@Input() scriptAccounts: ScriptAccount[] = []
|
||||||
|
@Input() enableEditing: boolean = false;
|
||||||
|
@Input() actions: ScriptAccountAction[] = []
|
||||||
|
@Output() onAddAction: EventEmitter<ScriptAccountAction> = new EventEmitter<ScriptAccountAction>();
|
||||||
|
@Output() onRemoveAction: EventEmitter<ScriptAccountAction> = new EventEmitter<ScriptAccountAction>();
|
||||||
|
|
||||||
|
dataSource: MatTableDataSource<ScriptAccountAction> = new MatTableDataSource();
|
||||||
|
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
|
||||||
|
|
||||||
|
editedAction: ScriptAccountAction | undefined
|
||||||
|
addedAction: ScriptAccountAction | undefined
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.dataSource.data = this.actions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!this.enableEditing) {
|
||||||
|
this.displayedColumns = this.displayedColumns.slice(0, -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editAction(scriptAccountAction: ScriptAccountAction) {
|
||||||
|
this.editedAction = scriptAccountAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
createNewAction() {
|
||||||
|
this.addedAction = new ScriptAccountAction(new ScriptAccount("", ""), 0);
|
||||||
|
this.editedAction = this.addedAction;
|
||||||
|
|
||||||
|
this.dataSource.data = this.dataSource.data.concat(this.addedAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
finishEditing() {
|
||||||
|
if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') {
|
||||||
|
this.onAddAction.emit(this.addedAction);
|
||||||
|
this.addedAction = undefined;
|
||||||
|
}
|
||||||
|
this.editedAction = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
deleteAction(deletedAction: ScriptAccountAction) {
|
||||||
|
this.dataSource.data = this.dataSource.data.filter(action => action !== deletedAction);
|
||||||
|
this.onRemoveAction.emit(deletedAction);
|
||||||
|
}
|
||||||
|
}
|
@ -62,7 +62,8 @@
|
|||||||
<td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplayWithExpand.length">
|
<td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplayWithExpand.length">
|
||||||
<div class="example-element-detail"
|
<div class="example-element-detail"
|
||||||
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
||||||
<app-scriptaccount-condition-editor [enableEditiong]="false" [conditions]="element.scriptAccountConditions" ></app-scriptaccount-condition-editor>
|
<app-scriptaccount-condition-editor [enableEditiong]="false" [conditions]="element.scriptAccountConditions" ></app-scriptaccount-condition-editor>
|
||||||
|
<app-scriptaccount-action-editor [enableEditing]="false" [actions]="element.scriptAccountActions"></app-scriptaccount-action-editor>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
|
||||||
import {MatTableDataSource} from "@angular/material/table";
|
|
||||||
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
|
|
||||||
import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition";
|
|
||||||
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
|
||||||
import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement";
|
|
||||||
import {
|
|
||||||
SimpleTemplateTransition
|
|
||||||
} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-scriptaccount-action-editor',
|
|
||||||
templateUrl: './scriptaccount-action-editor.component.html',
|
|
||||||
styleUrl: './scriptaccount-action-editor.component.scss'
|
|
||||||
})
|
|
||||||
export class ScriptaccountActionEditorComponent implements OnInit{
|
|
||||||
@Input() transition: Transition<any> | undefined
|
|
||||||
@Input() scriptAccounts: ScriptAccount[] = []
|
|
||||||
@Input() enableEditing: boolean = false;
|
|
||||||
@Input() templateElement: TemplateElement | undefined
|
|
||||||
|
|
||||||
dataSource: MatTableDataSource<ScriptAccountAction> = new MatTableDataSource();
|
|
||||||
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
|
|
||||||
|
|
||||||
editedAction: ScriptAccountAction | undefined
|
|
||||||
addedAction: ScriptAccountAction | undefined
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.dataSource.data = this.getDisplayedActions()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!this.enableEditing) {
|
|
||||||
this.displayedColumns = this.displayedColumns.slice(0, -2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editAction(scriptAccountAction: ScriptAccountAction) {
|
|
||||||
this.editedAction = scriptAccountAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
createNewAction() {
|
|
||||||
this.addedAction = new ScriptAccountAction(new ScriptAccount("", ""), 0);
|
|
||||||
this.editedAction = this.addedAction;
|
|
||||||
|
|
||||||
this.dataSource.data = this.dataSource.data.concat(this.addedAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
finishEditing() {
|
|
||||||
if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') {
|
|
||||||
if(this.templateElement != undefined && this.transition instanceof SimpleTemplateTransition) {
|
|
||||||
if(this.transition.actionMap.has(this.templateElement!)) {
|
|
||||||
this.transition.actionMap.get(this.templateElement!)!.push(this.addedAction)
|
|
||||||
} else {
|
|
||||||
this.transition.actionMap.set(this.templateElement!, [this.addedAction])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.transition?.addScriptAccountAction(this.addedAction)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.dataSource.data = this.getDisplayedActions();
|
|
||||||
this.addedAction = undefined;
|
|
||||||
}
|
|
||||||
this.editedAction = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
getDisplayedActions(): ScriptAccountAction[] {
|
|
||||||
if(this.templateElement == undefined) {
|
|
||||||
return this.transition!.scriptAccountActions.map(action => action);
|
|
||||||
} else if(this.transition instanceof SimpleTemplateTransition) {
|
|
||||||
return this.transition!.actionMap.get(this.templateElement)!
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteAction(action: ScriptAccountAction) {
|
|
||||||
if(this.templateElement != undefined && this.transition instanceof SimpleTemplateTransition && this.transition.actionMap.has(this.templateElement!)) {
|
|
||||||
const updatedAction = this.transition.actionMap.get(this.templateElement)!.filter(currentAction =>
|
|
||||||
currentAction.scriptAccount !== action.scriptAccount)
|
|
||||||
this.transition.actionMap.set(this.templateElement!, updatedAction)
|
|
||||||
} else {
|
|
||||||
this.transition!.removeScriptAccountAction(action.scriptAccount)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dataSource.data = this.getDisplayedActions()
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,7 +42,8 @@
|
|||||||
[@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 [templateElement]="templateElement" [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true"></app-scriptaccount-action-editor>
|
<app-scriptaccount-action-editor [actions]="getDisplayedActions(element)" [scriptAccounts]="scriptAccounts" [enableEditing]="true"
|
||||||
|
(onAddAction)="onAddAction(element, $event)" (onRemoveAction)="onDeleteAction(element, $event)"></app-scriptaccount-action-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="condition-container">
|
<div class="condition-container">
|
||||||
<app-scriptaccount-condition-editor [conditions]="getDisplayedConditions(element)" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
<app-scriptaccount-condition-editor [conditions]="getDisplayedConditions(element)" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
||||||
|
@ -12,6 +12,7 @@ import {TemplateElement} from "../../../../project/game-model/templates/Template
|
|||||||
import {
|
import {
|
||||||
SimpleTemplateTransition
|
SimpleTemplateTransition
|
||||||
} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition";
|
} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition";
|
||||||
|
import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction";
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-simple-transition-editor',
|
selector: 'app-simple-transition-editor',
|
||||||
templateUrl: './simple-transition-editor.component.html',
|
templateUrl: './simple-transition-editor.component.html',
|
||||||
@ -102,7 +103,6 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
transition.addScriptAccountCondition(condition);
|
transition.addScriptAccountCondition(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
|
deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
|
||||||
@ -126,4 +126,32 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAddAction(transition: SimpleTransition, action: ScriptAccountAction) {
|
||||||
|
if(this.templateElement != undefined && transition instanceof SimpleTemplateTransition) {
|
||||||
|
transition.actionMap.get(this.templateElement)!.push(action)
|
||||||
|
} else {
|
||||||
|
transition.addScriptAccountAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteAction(transition: SimpleTransition, action: ScriptAccountAction) {
|
||||||
|
if(this.templateElement != undefined && transition instanceof SimpleTemplateTransition) {
|
||||||
|
let updatedActions = transition.actionMap.get(this.templateElement)!
|
||||||
|
updatedActions = updatedActions.filter(currentAction => action.scriptAccount !== currentAction.scriptAccount);
|
||||||
|
transition.actionMap.set(this.templateElement, updatedActions);
|
||||||
|
} else {
|
||||||
|
transition.removeScriptAccountAction(action.scriptAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getDisplayedActions(transition: SimpleTransition) {
|
||||||
|
if(this.templateElement == undefined) {
|
||||||
|
return transition.scriptAccountActions
|
||||||
|
} else if(transition instanceof SimpleTemplateTransition) {
|
||||||
|
return transition.actionMap.get(this.templateElement)!
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import {Condition} from "./condition/Condition";
|
|||||||
import {ScriptAccountCondition} from "../gamesystems/conditions/ScriptAccountCondition";
|
import {ScriptAccountCondition} from "../gamesystems/conditions/ScriptAccountCondition";
|
||||||
import {InventoryCondition} from "./condition/InventoryCondition";
|
import {InventoryCondition} from "./condition/InventoryCondition";
|
||||||
import {GamesystemCondition} from "./condition/GamesystemCondition";
|
import {GamesystemCondition} from "./condition/GamesystemCondition";
|
||||||
|
import {Action} from "./actions/Action";
|
||||||
|
|
||||||
export abstract class AbstractInteraction {
|
export abstract class AbstractInteraction {
|
||||||
|
|
||||||
|
@ -35,4 +35,11 @@ export class Interaction extends AbstractInteraction{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addAction(action: Action) {
|
||||||
|
this.actions.push(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeAction(deletedAction: Action) {
|
||||||
|
this.actions = this.actions.filter(action => action !== deletedAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,27 @@
|
|||||||
"conditions": [],
|
"conditions": [],
|
||||||
"stateLabel": "A",
|
"stateLabel": "A",
|
||||||
"stateDescription": ""
|
"stateDescription": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"initial": false,
|
||||||
|
"conditions": [],
|
||||||
|
"stateLabel": "B",
|
||||||
|
"stateDescription": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transitions": [
|
||||||
|
{
|
||||||
|
"scriptAccountActions": [
|
||||||
|
{
|
||||||
|
"characterDependency": 2,
|
||||||
|
"changingValue": 6,
|
||||||
|
"scriptAccount": "Test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scriptAccountConditions": [],
|
||||||
|
"startingState": "A",
|
||||||
|
"endingState": "B"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"transitions": [],
|
|
||||||
"generateIsolatedStates": false
|
"generateIsolatedStates": false
|
||||||
}
|
}
|
@ -7,8 +7,27 @@
|
|||||||
"conditions": [],
|
"conditions": [],
|
||||||
"stateLabel": "1",
|
"stateLabel": "1",
|
||||||
"stateDescription": ""
|
"stateDescription": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"initial": false,
|
||||||
|
"conditions": [],
|
||||||
|
"stateLabel": "2",
|
||||||
|
"stateDescription": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transitions": [
|
||||||
|
{
|
||||||
|
"scriptAccountActions": [
|
||||||
|
{
|
||||||
|
"characterDependency": 2,
|
||||||
|
"changingValue": 5,
|
||||||
|
"scriptAccount": "Test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scriptAccountConditions": [],
|
||||||
|
"startingState": "1",
|
||||||
|
"endingState": "2"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"transitions": [],
|
|
||||||
"generateIsolatedStates": false
|
"generateIsolatedStates": false
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user