CharacterSpecific Templatesystems #36

Merged
sebastian merged 31 commits from template-systems into main 2024-04-14 13:45:04 +02:00
11 changed files with 119 additions and 6 deletions
Showing only changes of commit 4868495e70 - Show all commits

View File

@ -61,7 +61,7 @@ import {
ProductStateEditorComponent ProductStateEditorComponent
} from "./editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component"; } from "./editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component";
import {MatTooltip} from "@angular/material/tooltip"; import {MatTooltip} from "@angular/material/tooltip";
import {MatCard, MatCardContent} 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/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component";
@ -70,6 +70,10 @@ import {
} from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component"; } from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component";
import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component"; import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component";
import {CharacterEditorComponent} from "./editor/character-editor/character-editor.component"; import {CharacterEditorComponent} from "./editor/character-editor/character-editor.component";
import {MatAccordion, MatExpansionPanel, MatExpansionPanelTitle} from "@angular/material/expansion";
import {
TemplateSpecificatorComponent
} from "./editor/gamesystem-editor/template-specificator/template-specificator.component";
// AoT requires an exported function for factories // AoT requires an exported function for factories
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
@ -93,7 +97,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
ScriptaccountActionEditorComponent, ScriptaccountActionEditorComponent,
ScriptaccountConditionEditorComponent, ScriptaccountConditionEditorComponent,
CharacterOverviewComponent, CharacterOverviewComponent,
CharacterEditorComponent CharacterEditorComponent,
TemplateSpecificatorComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@ -150,7 +155,12 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
MatHint, MatHint,
MatTooltip, MatTooltip,
MatCard, MatCard,
MatCardContent MatCardContent,
MatCardHeader,
MatAccordion,
MatExpansionPanel,
MatExpansionPanelTitle,
MatCardTitle
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]

View File

@ -1 +1,16 @@
<p>character-editor works!</p> <mat-card>
<mat-card-header>
<mat-card-title>Characterspecific Gamesystems</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-accordion>
<mat-expansion-panel *ngFor="let templateSystem of character!.characterSpecificTemplateSystems">
<mat-expansion-panel-header>
<mat-panel-title>{{templateSystem.componentName}}</mat-panel-title>
</mat-expansion-panel-header>
<app-gamesystem-editor [gamesystem]="templateSystem" [scriptAccounts]="gameModel!.scriptAccounts"></app-gamesystem-editor>
</mat-expansion-panel>
</mat-accordion>
<button mat-stroked-button class="specify-btn" (click)="openTemplateSpecificator()">Specify Templatesystem</button>
</mat-card-content>
</mat-card>

View File

@ -0,0 +1,4 @@
.specify-btn {
width: 100%;
margin-top: 10px;
}

View File

@ -1,4 +1,11 @@
import { Component } from '@angular/core'; import {Component, Input} from '@angular/core';
import {Character} from "../../project/game-model/characters/Character";
import {GameModel} from "../../project/game-model/GameModel";
import {MatDialog} from "@angular/material/dialog";
import {
TemplateSpecificatorComponent
} from "../gamesystem-editor/template-specificator/template-specificator.component";
import {TemplateType} from "../../project/game-model/templates/TemplateType";
@Component({ @Component({
selector: 'app-character-editor', selector: 'app-character-editor',
@ -7,4 +14,19 @@ import { Component } from '@angular/core';
}) })
export class CharacterEditorComponent { export class CharacterEditorComponent {
@Input() character: Character | undefined;
@Input() gameModel: GameModel | undefined;
constructor(private dialog: MatDialog) {
}
openTemplateSpecificator() {
const dialogRef = this.dialog.open(TemplateSpecificatorComponent, {data: this.gameModel?.getTemplateSystems(TemplateType.CHARACTER), minWidth: "400px"});
dialogRef.afterClosed().subscribe(res => {
if(res != undefined) {
this.character!.addCharacterSpecificSimpleTemplatesystem(res);
}
})
}
} }

View File

@ -14,7 +14,10 @@
[gamesystem]="convertModelComponentToGamesystem(modelComponent)" [gamesystem]="convertModelComponentToGamesystem(modelComponent)"
(onOpenGamesystemEditor)="openGameModelComponent($event)" (onOpenGamesystemEditor)="openGameModelComponent($event)"
[scriptAccounts]="gameModel!.scriptAccounts"></app-gamesystem-editor> [scriptAccounts]="gameModel!.scriptAccounts"></app-gamesystem-editor>
<app-character-editor *ngIf="modelComponent.type === ModelComponentType.CHARACTER"> <app-character-editor *ngIf="modelComponent.type === ModelComponentType.CHARACTER"
[character]="convertModelComponentToCharacter(modelComponent)"
[gameModel]="gameModel!"
>
</app-character-editor> </app-character-editor>
</mat-tab> </mat-tab>

View File

@ -6,6 +6,7 @@ import {Gamesystem} from "../project/game-model/gamesystems/Gamesystem";
import {State} from "../project/game-model/gamesystems/states/State"; import {State} from "../project/game-model/gamesystems/states/State";
import {Transition} from "../project/game-model/gamesystems/transitions/Transition"; import {Transition} from "../project/game-model/gamesystems/transitions/Transition";
import {ModelComponentType} from "../project/game-model/ModelComponentType"; import {ModelComponentType} from "../project/game-model/ModelComponentType";
import {Character} from "../project/game-model/characters/Character";
@Component({ @Component({
@ -50,4 +51,10 @@ export class EditorComponent {
} }
protected readonly ModelComponentType = ModelComponentType; protected readonly ModelComponentType = ModelComponentType;
convertModelComponentToCharacter(modelComponent: ModelComponent) {
if(modelComponent instanceof Character)
return modelComponent as Character
return undefined;
}
} }

View File

@ -0,0 +1 @@
<p>template-specificator works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TemplateSpecificatorComponent } from './template-specificator.component';
describe('TemplateSpecificatorComponent', () => {
let component: TemplateSpecificatorComponent;
let fixture: ComponentFixture<TemplateSpecificatorComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TemplateSpecificatorComponent]
})
.compileComponents();
fixture = TestBed.createComponent(TemplateSpecificatorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-template-specificator',
templateUrl: './template-specificator.component.html',
styleUrl: './template-specificator.component.scss'
})
export class TemplateSpecificatorComponent {
}

View File

@ -133,4 +133,22 @@ export class GameModel {
} }
}) })
} }
getTemplateSystems(templateType: TemplateType) {
const requestedTemplates: Gamesystem<any, any>[] = []
const gamesystemQueue: Gamesystem<any, any>[] = this.gamesystems.concat();
while(gamesystemQueue.length > 0) {
const currentGamesystem = gamesystemQueue.shift()!;
if(currentGamesystem instanceof SimpleTemplateGamesystem && currentGamesystem.templateType === templateType) {
requestedTemplates.push(currentGamesystem)
}
if(currentGamesystem instanceof ProductGamesystem) {
currentGamesystem.innerGamesystems.forEach(innerGamesystem => gamesystemQueue.push(innerGamesystem))
}
}
return requestedTemplates;
}
} }