From 7a8c939d6ac6923a4c85cac3272b2ff3b4b471e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 10 Feb 2024 12:21:31 +0100 Subject: [PATCH] Visualize SimpleTransitions --- src/app/app.component.ts | 6 +- src/app/app.module.ts | 6 +- .../simple-gamesystem-editor.component.html | 1 + .../simple-gamesystem-editor.component.scss | 3 + .../simple-transition-editor.component.html | 56 +++++++++++++++++++ .../simple-transition-editor.component.scss | 51 +++++++++++++++++ ...simple-transition-editor.component.spec.ts | 23 ++++++++ .../simple-transition-editor.component.ts | 38 +++++++++++++ 8 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html create mode 100644 src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss create mode 100644 src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.spec.ts create mode 100644 src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 870e90d..c23a46e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -147,8 +147,10 @@ export class AppComponent implements OnInit{ const weather = new SimpleGamesystem("Weather"); const season = new SimpleGamesystem("Season"); - season.createState("Spring", "Spring, also known as springtime, is one of the four temperate seasons, succeeding winter and preceding summer."); - season.createState("Summer", "Summer is the hottest and brightest of the four temperate seasons, occurring after spring and before autumn. "); + const springState = season.createState("Spring", "Spring, also known as springtime, is one of the four temperate seasons, succeeding winter and preceding summer."); + const summerState = season.createState("Summer", "Summer is the hottest and brightest of the four temperate seasons, occurring after spring and before autumn. "); + + season.createTransition(springState!, summerState!); this.gameModel.addGamesystem(weather) this.gameModel.addGamesystem(season); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8e5ae65..31cd04f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -47,6 +47,9 @@ import { MatTable } from "@angular/material/table"; import {MatCheckbox} from "@angular/material/checkbox"; +import { + SimpleTransitionEditorComponent +} from "./editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -62,7 +65,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl GamescriptOverviewComponent, GamesystemEditorComponent, SimpleGamesystemEditorComponent, - SimpleStateEditorComponent + SimpleStateEditorComponent, + SimpleTransitionEditorComponent ], imports: [ BrowserModule, 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 78dcc5c..5ad3526 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 +1,2 @@ + diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.scss b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.scss index e69de29..7112fce 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.scss +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.scss @@ -0,0 +1,3 @@ +.transition-editor { + margin-top: 15px; +} 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 new file mode 100644 index 0000000..edd4815 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Starting State{{transition.startingState.stateLabel}}Ending State{{transition.endingState.stateLabel}} +
+

Expanded Detail

+
+
+ + + +   + +
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss new file mode 100644 index 0000000..26f0b74 --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.scss @@ -0,0 +1,51 @@ +table { + width: 100%; + margin-top: 20px; +} +.mat-column-edit, .mat-column-delete, .mat-column-expand { + width: 32px; +} + +tr.example-detail-row { + height: 0; +} + +tr.example-element-row:not(.example-expanded-row):hover { + background: #545456; +} + +tr.example-element-row:not(.example-expanded-row):active { + background: #545456; +} + +.example-element-row td { + border-bottom-width: 0; +} + +.example-element-detail { + overflow: hidden; + display: flex; +} + +.example-element-diagram { + min-width: 80px; + border: 2px solid black; + padding: 8px; + font-weight: lighter; + margin: 8px 0; + height: 104px; +} + +.example-element-symbol { + font-weight: bold; + font-size: 40px; + line-height: normal; +} + +.example-element-description { + padding: 16px; +} + +.example-element-description-attribution { + opacity: 0.5; +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.spec.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.spec.ts new file mode 100644 index 0000000..0edfece --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SimpleTransitionEditorComponent } from './simple-transition-editor.component'; + +describe('SimpleTransitionEditorComponent', () => { + let component: SimpleTransitionEditorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SimpleTransitionEditorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SimpleTransitionEditorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 0000000..146d59f --- /dev/null +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -0,0 +1,38 @@ +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/SimpleTransition"; +import {animate, state, style, transition, trigger} from "@angular/animations"; + +@Component({ + selector: 'app-simple-transition-editor', + templateUrl: './simple-transition-editor.component.html', + styleUrl: './simple-transition-editor.component.scss', + animations: [ + trigger('detailExpand', [ + state('collapsed,void', style({height: '0px', minHeight: '0'})), + state('expanded', style({height: '*'})), + transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), + ]), + ], +}) +export class SimpleTransitionEditorComponent implements OnInit { + + @Input() gamesystem: SimpleGamesystem | undefined + displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"]; + dataSource = new MatTableDataSource(); + columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; + expandedElement: SimpleTransition | null = null; + ngOnInit() { + this.dataSource.data = this.gamesystem!.transitions; + } +}