diff --git a/src/app/app.component.html b/src/app/app.component.html index 85d1f15..9b85948 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -27,7 +27,7 @@
- +
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5009811..87fe6af 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -62,6 +62,9 @@ import { } from "./editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component"; import {MatTooltip} from "@angular/material/tooltip"; import {MatCard, MatCardContent} from "@angular/material/card"; +import { + ScriptaccountActionEditorComponent +} from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -81,65 +84,66 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl SimpleTransitionEditorComponent, ProductTransitionEditorComponent, ProductStateEditorComponent, - ProductGamesystemEditorComponent - ], - imports: [ - BrowserModule, - FormsModule, - HttpClientModule, - CoreModule, - SharedModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: httpLoaderFactory, - deps: [HttpClient] - } - }), - BrowserAnimationsModule, - MatIcon, - MatToolbar, - MatButton, - MatFormField, - MatInput, - MatDrawerContainer, - MatDrawer, - MatIconButton, - MatMenuTrigger, - MatMenu, - MatMenuItem, - MatListItem, - MatActionList, - MatTabGroup, - MatTab, - MatTabLabel, - MatLabel, - MatFormField, - ReactiveFormsModule, - MatError, - MatDialogTitle, - MatDialogContent, - MatDialogActions, - MatMiniFabButton, - MatTreeModule, - MatTable, - MatColumnDef, - MatHeaderCell, - MatHeaderCellDef, - MatCellDef, - MatCell, - MatHeaderRow, - MatRow, - MatHeaderRowDef, - MatRowDef, - MatCheckbox, - MatSelect, - MatOption, - MatHint, - MatTooltip, - MatCard, - MatCardContent + ProductGamesystemEditorComponent, + ScriptaccountActionEditorComponent ], + imports: [ + BrowserModule, + FormsModule, + HttpClientModule, + CoreModule, + SharedModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: httpLoaderFactory, + deps: [HttpClient] + } + }), + BrowserAnimationsModule, + MatIcon, + MatToolbar, + MatButton, + MatFormField, + MatInput, + MatDrawerContainer, + MatDrawer, + MatIconButton, + MatMenuTrigger, + MatMenu, + MatMenuItem, + MatListItem, + MatActionList, + MatTabGroup, + MatTab, + MatTabLabel, + MatLabel, + MatFormField, + ReactiveFormsModule, + MatError, + MatDialogTitle, + MatDialogContent, + MatDialogActions, + MatMiniFabButton, + MatTreeModule, + MatTable, + MatColumnDef, + MatHeaderCell, + MatHeaderCellDef, + MatCellDef, + MatCell, + MatHeaderRow, + MatRow, + MatHeaderRowDef, + MatRowDef, + MatCheckbox, + MatSelect, + MatOption, + MatHint, + MatTooltip, + MatCard, + MatCardContent + ], providers: [], bootstrap: [AppComponent] }) diff --git a/src/app/editor/editor.component.html b/src/app/editor/editor.component.html index b43ce41..f51aa7a 100644 --- a/src/app/editor/editor.component.html +++ b/src/app/editor/editor.component.html @@ -12,7 +12,8 @@ [scriptAccount]="convertModelComponentToScriptAccount(modelComponent)"> + (onOpenGamesystemEditor)="openGameModelComponent($event)" + [scriptAccounts]="gameModel!.scriptAccounts"> diff --git a/src/app/editor/editor.component.ts b/src/app/editor/editor.component.ts index 38ec9f8..a1e377f 100644 --- a/src/app/editor/editor.component.ts +++ b/src/app/editor/editor.component.ts @@ -16,6 +16,7 @@ export class EditorComponent { gameModelComponents: ModelComponent[] = []; @Output("onModelNameUpdate") onModelNameUpdateEmitter = new EventEmitter(); activeTab: number = this.gameModelComponents.length; + @Input() gameModel: GameModel | undefined openGameModelComponent(gameModelComponent: ModelComponent) { if(!this.gameModelComponents.includes(gameModelComponent)) { diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index 624b252..2eb564e 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,3 +1,3 @@ - + diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index 8bff8e1..a35cc1b 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -1,21 +1,27 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {GameModel} from "../../game-model/GameModel"; import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; import {State} from "../../game-model/gamesystems/states/State"; import {Transition} from "../../game-model/gamesystems/transitions/Transition"; import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-gamesystem-editor', templateUrl: './gamesystem-editor.component.html', styleUrl: './gamesystem-editor.component.scss' }) -export class GamesystemEditorComponent { +export class GamesystemEditorComponent implements OnInit{ @Input() gamesystem: Gamesystem, Transition> | undefined + @Input() scriptAccounts: ScriptAccount[] = []; @Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter(); + ngOnInit() { + console.log("GamesystemEditor: ", this.scriptAccounts.length) + } + isSimpleGamesystem() { return this.gamesystem instanceof SimpleGamesystem; } diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html index 4b24edd..cc28a3d 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html @@ -1,4 +1,4 @@ - +
- +
diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts index ab4fcc5..5baf0e9 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts @@ -1,6 +1,7 @@ import {Component, Input} from '@angular/core'; import {SimpleGamesystem} from "../../../game-model/gamesystems/SimpleGamesystem"; import {MatTableDataSource} from "@angular/material/table"; +import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-simple-gamesystem-editor', @@ -10,7 +11,7 @@ import {MatTableDataSource} from "@angular/material/table"; export class SimpleGamesystemEditorComponent { @Input() simpleGamesystem: SimpleGamesystem | undefined - + @Input() scriptAccunts: ScriptAccount[] = [] } diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index 6e99ce8..e6bbea0 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -64,7 +64,6 @@ export class ProductTransitionEditorComponent implements OnInit{ } const leafStates = LeafGamesystemCalculator.calcLeafStates(state); - console.log(leafStates) return leafStates[index]; } diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html new file mode 100644 index 0000000..af7af1b --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + +
ScriptAccount + {{action.scriptAccount.componentName}} + + ScriptAccount + + {{scriptAccount.componentName}} + + + Value + {{action.changingValue}} + + Value + + + + + + + + + +
diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss new file mode 100644 index 0000000..1caa532 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss @@ -0,0 +1,7 @@ +table { + width: 100%; +} + +.long-form { + width: 100%; +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts new file mode 100644 index 0000000..3c4a363 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ScriptaccountActionEditorComponent } from './scriptaccount-action-editor.component'; + +describe('ScriptaccountActionEditorComponent', () => { + let component: ScriptaccountActionEditorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ScriptaccountActionEditorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ScriptaccountActionEditorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts new file mode 100644 index 0000000..f2b8860 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -0,0 +1,53 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {Transition} from "../../../../game-model/gamesystems/transitions/Transition"; +import {MatTableDataSource} from "@angular/material/table"; +import {ScriptAccountAction} from "../../../../game-model/gamesystems/actions/ScriptAccountAction"; +import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; + +@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 | undefined + @Input() scriptAccounts: ScriptAccount[] = [] + + dataSource: MatTableDataSource = new MatTableDataSource(); + displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete']; + + editedAction: ScriptAccountAction | undefined + addedAction: ScriptAccountAction | undefined + + ngOnInit() { + this.dataSource.data = this.transition!.scriptAccountActions.map(action => action); + console.log("# ScriptAccounts", this.scriptAccounts.length) + } + + 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.transition?.addScriptAccountAction(this.addedAction) + console.log(this.addedAction.scriptAccount) + this.dataSource.data = this.transition!.scriptAccountActions; + console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length) + this.addedAction = undefined; + } + this.editedAction = undefined; + } + + deleteAction(action: ScriptAccountAction) { + this.transition!.removeScriptAccountAction(action.scriptAccount) + this.dataSource.data = this.transition!.scriptAccountActions + } +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 0834eb0..837048b 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -40,7 +40,7 @@
-

Expanded Detail

+
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index 5c8b3d4..efa965a 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -1,21 +1,12 @@ import {Component, Input, OnInit} from '@angular/core'; -import {GameModel} from "../../../../game-model/GameModel"; import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; import { - MatCell, - MatCellDef, - MatColumnDef, - MatHeaderCell, - MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef, - MatTable, MatTableDataSource } from "@angular/material/table"; import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/SimpleTransition"; import {animate, state, style, transition, trigger} from "@angular/animations"; import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState"; -import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; -import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; - +import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount"; @Component({ selector: 'app-simple-transition-editor', templateUrl: './simple-transition-editor.component.html', @@ -31,6 +22,7 @@ import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGame export class SimpleTransitionEditorComponent implements OnInit { @Input() gamesystem: SimpleGamesystem | undefined + @Input() scriptAccounts: ScriptAccount[] = [] displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"]; dataSource = new MatTableDataSource(); columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; @@ -49,6 +41,7 @@ export class SimpleTransitionEditorComponent implements OnInit { this.dataSource.filterPredicate = (data: SimpleTransition, filter: string) => { return [data.startingState, data.endingState].some((state) => state.stateLabel.toLowerCase().includes(filter)) } + console.log("TransitionEditor: ", this.scriptAccounts.length) } addTransition() {