alt-templatesystem-impl #29

Closed
sebastian wants to merge 23 commits from alt-templatesystem-impl into character-specific-gamesystems
8 changed files with 61 additions and 39 deletions
Showing only changes of commit 21dc74376b - Show all commits

View File

@ -64,9 +64,20 @@ function createWindow(): BrowserWindow {
submenu: [
{
label: "Gamesystem",
click: () => {
win!.webContents.send('context-menu', "new-gamesystem");
}
submenu: [
{
label: "Normal",
click: () => {
win!.webContents.send('context-menu', "new-gamesystem-normal");
}
},
{
label: "Characterspecific",
click: () => {
win!.webContents.send('context-menu', "new-gamesystem-character");
}
}
]
},
{
label: "ScriptAccount",

View File

@ -24,6 +24,8 @@ import {Character} from "./project/game-model/characters/Character";
import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component";
import {CharacterSerializer} from "./project/serializer/CharacterSerializer";
import {CharacterParser} from "./project/parser/characterParser/CharacterParser";
import {TemplateType} from "./project/game-model/TemplateType";
import {TemplateTypeUtilities} from "./project/game-model/TemplateTypeUtilities";
@Component({
selector: 'app-root',
@ -76,8 +78,13 @@ export class AppComponent implements OnInit{
} else if(message.startsWith("new")) {
const splittedMessage = message.split("-");
const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]);
let templateType: TemplateType = TemplateType.NORMAL
if(splittedMessage.length > 2) {
templateType = TemplateTypeUtilities.fromString(splittedMessage[2]);
}
if(modelComponentType != undefined) {
this.onCreateModelComponent(modelComponentType);
this.onCreateModelComponent(modelComponentType, templateType);
} else {
console.log("[ERROR] [App-Component] Unknown Context-Menu Command!")
}
@ -127,10 +134,10 @@ export class AppComponent implements OnInit{
})
}
private onCreateModelComponent(modelComponentType: ModelComponentType) {
private onCreateModelComponent(modelComponentType: ModelComponentType, templateType: TemplateType) {
switch (modelComponentType) {
case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(); break
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(templateType); break
case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break
}
}
@ -144,7 +151,7 @@ export class AppComponent implements OnInit{
}
}
private onCreateNewGamesystem() {
private onCreateNewGamesystem(templateType: TemplateType) {
let parentGamesystemName = undefined
if(this.openContent != ModelComponentType.GAMESYTEM) {
this.openGamesystemsOverview();
@ -153,7 +160,7 @@ export class AppComponent implements OnInit{
}
const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName);
const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem "+ templateType, parentGamesystemName, templateType);
if(createdGamesystem != undefined) {
this.gamesystemOverview!.refresh();
this.editor?.openGameModelComponent(createdGamesystem);

View File

@ -5,7 +5,7 @@ import { Transition } from '../../project/game-model/gamesystems/transitions/Tra
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
import {TemplateType} from "../../project/game-model/gamesystems/TemplateType";
import {SimpleTemplateGamesystem} from "../../project/game-model/gamesystems/SimpleTemplateGamesystem";
@Component({
selector: 'app-gamesystem-editor',
@ -23,11 +23,11 @@ export class GamesystemEditorComponent implements OnInit{
}
isSimpleGamesystem() {
return this.gamesystem instanceof SimpleGamesystem;
return this.gamesystem instanceof SimpleGamesystem || this.gamesystem instanceof SimpleTemplateGamesystem;
}
convertGamesystemToSimpleGamesystem() {
if(this.gamesystem instanceof SimpleGamesystem) {
if(!(this.gamesystem instanceof ProductGamesystem)) {
return this.gamesystem as SimpleGamesystem;
}
}
@ -41,6 +41,4 @@ export class GamesystemEditorComponent implements OnInit{
onOpenGamesystemEditor(gamesystem: SimpleGamesystem) {
this.openGamesystemEmitter.emit(gamesystem);
}
protected readonly TemplateType = TemplateType;
}

View File

@ -1,17 +1,22 @@
import {Component, Input} from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import {MatTableDataSource} from "@angular/material/table";
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
import {SimpleTemplateGamesystem} from "../../../project/game-model/gamesystems/SimpleTemplateGamesystem";
@Component({
selector: 'app-simple-gamesystem-editor',
templateUrl: './simple-gamesystem-editor.component.html',
styleUrl: './simple-gamesystem-editor.component.scss'
})
export class SimpleGamesystemEditorComponent {
export class SimpleGamesystemEditorComponent implements OnInit{
@Input() simpleGamesystem: SimpleGamesystem | undefined
@Input() simpleGamesystem: SimpleGamesystem | SimpleTemplateGamesystem<any> | undefined
@Input() scriptAccunts: ScriptAccount[] = []
ngOnInit(): void {
console.log("SimpleGamesystem: ", this.simpleGamesystem)
}
}

View File

@ -5,8 +5,8 @@ import {State} from "./gamesystems/states/State";
import {ProductGamesystem} from "./gamesystems/ProductGamesystem";
import {SimpleGamesystem} from "./gamesystems/SimpleGamesystem";
import {Character} from "./characters/Character";
import {ModelComponentType} from "./ModelComponentType";
import {TemplateType} from "./gamesystems/TemplateType";
import {TemplateType} from "./TemplateType";
import {SimpleTemplateGamesystem} from "./gamesystems/SimpleTemplateGamesystem";
export class GameModel {
gameModelName: string
@ -46,9 +46,14 @@ export class GameModel {
return undefined;
}
createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined) {
createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined, templateType: TemplateType) {
if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) {
const simpleGamesystem = new SimpleGamesystem(gamesystemName, "");
let simpleGamesystem = new SimpleGamesystem(gamesystemName, "");
if(templateType == TemplateType.CHARACTER) {
simpleGamesystem = new SimpleTemplateGamesystem<Character>(gamesystemName, "")
}
if(parentGamesystemName != undefined) {
const parentGamesystem = this.findGamesystem(parentGamesystemName);
if(parentGamesystem instanceof SimpleGamesystem) {
@ -116,23 +121,4 @@ export class GameModel {
}
})
}
getTemplateGamesystems(templateType: TemplateType) {
const gamesystems = this.getGamesystemsAsList()
return gamesystems.filter(gamesystem => gamesystem.template === templateType);
}
private getGamesystemsAsList() : Gamesystem<any, any>[]{
const gamesystemList: Gamesystem<any, any>[] = []
const gamesystemQueue : Gamesystem<any, any>[] = this.gamesystems.map(gamesystem => gamesystem)
while(gamesystemQueue.length > 0) {
const currentGamesystem = gamesystemQueue.shift()!;
gamesystemList.push(currentGamesystem)
if(currentGamesystem instanceof ProductGamesystem) {
currentGamesystem.innerGamesystems.forEach(innerGamesystem => gamesystemQueue.push(innerGamesystem))
}
}
return gamesystemList
}
}

View File

@ -0,0 +1,3 @@
export enum TemplateType {
NORMAL, CHARACTER
}

View File

@ -0,0 +1,11 @@
import {TemplateType} from "./TemplateType";
export class TemplateTypeUtilities {
static fromString(value: string) {
if(value === 'character') {
return TemplateType.CHARACTER
} else {
return TemplateType.NORMAL
}
}
}

View File

@ -4,6 +4,7 @@ import {Gamesystem} from "./Gamesystem";
import {SimpleTransition} from "./transitions/SimpleTransition";
import {SimpleState} from "./states/SimpleState";
import {SimpleTemplateTransition} from "./transitions/SimpleTemplateTransition";
import {TemplateType} from "../TemplateType";
export class SimpleTemplateGamesystem<ReferenceType> extends Gamesystem<SimpleTemplateState<ReferenceType>, SimpleTemplateTransition<ReferenceType>> {