refactor-component-creation #47
@ -175,27 +175,6 @@ export class AppComponent implements OnInit{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private onCreateNewGamesystem(templateType: TemplateType | undefined) {
|
|
||||||
let parentGamesystemName = undefined
|
|
||||||
if(this.openContent != ModelComponentType.GAMESYTEM) {
|
|
||||||
this.openGamesystemsOverview();
|
|
||||||
} else {
|
|
||||||
parentGamesystemName = this.gamesystemOverview!.selectedGamesystemName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let createdGamesystem;
|
|
||||||
if(parentGamesystemName == undefined) {
|
|
||||||
createdGamesystem = this.gameModel?.createSimpleGamesystem("New Gamesystem", templateType);
|
|
||||||
} else {
|
|
||||||
createdGamesystem = this.gameModel!.createSimpleGamesystemWithParent("New Gamesystem", parentGamesystemName, templateType)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(createdGamesystem != undefined) {
|
|
||||||
this.gamesystemOverview!.refresh();
|
|
||||||
this.editor?.openGameModelComponent(createdGamesystem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getSelectedModelComponent(): ModelComponent | undefined {
|
private getSelectedModelComponent(): ModelComponent | undefined {
|
||||||
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
|
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
|
||||||
@ -332,8 +311,12 @@ export class AppComponent implements OnInit{
|
|||||||
get openedOverview(): Overview | undefined {
|
get openedOverview(): Overview | undefined {
|
||||||
if(this.openContent === ModelComponentType.ITEMGROUP || this.openContent === ModelComponentType.ITEM) {
|
if(this.openContent === ModelComponentType.ITEMGROUP || this.openContent === ModelComponentType.ITEM) {
|
||||||
return this.itemOverview;
|
return this.itemOverview;
|
||||||
} else {
|
} else if(this.openContent === ModelComponentType.SCRIPTACCOUNT) {
|
||||||
return undefined;
|
return this.scriptAccountOverview;
|
||||||
|
} else if(this.openContent === ModelComponentType.CHARACTER) {
|
||||||
|
return this.characterOverview;
|
||||||
|
} else if(this.openContent === ModelComponentType.GAMESYTEM) {
|
||||||
|
return this.gamesystemOverview;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,12 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
|
|||||||
simpleGamesystem.parentGamesystem = this
|
simpleGamesystem.parentGamesystem = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(parentGamesystem == undefined || parentGamesystem.componentName === this.componentName) {
|
||||||
if(parentGamesystem != undefined) {
|
gameModel.removeGamesystem(simpleGamesystem);
|
||||||
|
this.addChildGamesystem(simpleGamesystem);
|
||||||
|
} else {
|
||||||
parentGamesystem.removeChildGamesystem(simpleGamesystem);
|
parentGamesystem.removeChildGamesystem(simpleGamesystem);
|
||||||
parentGamesystem.addChildGamesystem(this);
|
parentGamesystem.addChildGamesystem(this);
|
||||||
this.parentGamesystem = parentGamesystem
|
|
||||||
} else {
|
|
||||||
gameModel.removeGamesystem(simpleGamesystem);
|
|
||||||
gameModel.addGamesystem(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
|
|||||||
import {ProductGamesystem} from "../../gamesystems/ProductGamesystem";
|
import {ProductGamesystem} from "../../gamesystems/ProductGamesystem";
|
||||||
import {SimpleTemplateGamesystem} from "../../templates/simpleGamesystem/SimpleTemplateGamesystem";
|
import {SimpleTemplateGamesystem} from "../../templates/simpleGamesystem/SimpleTemplateGamesystem";
|
||||||
import {ProductTemplateCreator} from "../../templates/productGamesystem/ProductTemplateCreator";
|
import {ProductTemplateCreator} from "../../templates/productGamesystem/ProductTemplateCreator";
|
||||||
|
import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
|
||||||
|
import {TemplateType} from "../../templates/TemplateType";
|
||||||
|
|
||||||
export class GamesystemCreator extends ModelComponentCreator{
|
export class GamesystemCreator extends ModelComponentCreator{
|
||||||
|
|
||||||
@ -25,15 +27,7 @@ export class GamesystemCreator extends ModelComponentCreator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this.selectedComponent !== undefined && this.selectedComponent instanceof Gamesystem)/**Aka productGamesystem**/ {
|
if(this.selectedComponent !== undefined && this.selectedComponent instanceof Gamesystem)/**Aka productGamesystem**/ {
|
||||||
let productParentsystem: ProductGamesystem;
|
const productParentsystem: ProductGamesystem = this.constructProductFromSimple(this.selectedComponent, undefined)!
|
||||||
if(this.selectedComponent instanceof SimpleTemplateGamesystem) {
|
|
||||||
productParentsystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(this.selectedComponent, this.gameModel!, this.selectedComponent.templateType);
|
|
||||||
} else if(this.selectedComponent instanceof SimpleGamesystem) {
|
|
||||||
productParentsystem = ProductGamesystem.constructFromSimpleGamesystem(this.selectedComponent, this.gameModel);
|
|
||||||
} else {
|
|
||||||
productParentsystem = this.selectedComponent as ProductGamesystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
productParentsystem.addChildGamesystem(simpleGamesystem);
|
productParentsystem.addChildGamesystem(simpleGamesystem);
|
||||||
} else {
|
} else {
|
||||||
this.gameModel!.gamesystems.push(simpleGamesystem);
|
this.gameModel!.gamesystems.push(simpleGamesystem);
|
||||||
@ -42,5 +36,51 @@ export class GamesystemCreator extends ModelComponentCreator{
|
|||||||
return simpleGamesystem;
|
return simpleGamesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private constructProductFromSimple(simpleGamesystem: Gamesystem<any, any>, producttemplateType: TemplateType | undefined): ProductGamesystem | undefined {
|
||||||
|
if(!(simpleGamesystem instanceof ProductTemplateSystem) && producttemplateType != undefined) {
|
||||||
|
console.log("Wierd, Debug")
|
||||||
|
return ProductTemplateCreator.convertProductToTemplate(simpleGamesystem as ProductGamesystem, this.gameModel, producttemplateType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(simpleGamesystem instanceof ProductGamesystem) {
|
||||||
|
console.log("Wierder Debug")
|
||||||
|
return simpleGamesystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
let productGamesystem: ProductGamesystem
|
||||||
|
if(producttemplateType != undefined) {
|
||||||
|
productGamesystem = new ProductTemplateSystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription, producttemplateType);
|
||||||
|
} else {
|
||||||
|
productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.constructGamesystemHierarchy(productGamesystem, simpleGamesystem as SimpleGamesystem)
|
||||||
|
return productGamesystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private constructGamesystemHierarchy(productGamesystem: ProductGamesystem, simpleGamesystem: SimpleGamesystem) {
|
||||||
|
const simpleParentGamesystem = simpleGamesystem.parentGamesystem;
|
||||||
|
|
||||||
|
if(simpleGamesystem.states.length > 0) {
|
||||||
|
simpleGamesystem.componentName += "(Child)";
|
||||||
|
if(simpleParentGamesystem == undefined) {
|
||||||
|
this.gameModel.removeGamesystem(simpleGamesystem);
|
||||||
|
productGamesystem.addChildGamesystem(simpleGamesystem);
|
||||||
|
this.gameModel.addGamesystem(productGamesystem);
|
||||||
|
} else {
|
||||||
|
simpleParentGamesystem.removeChildGamesystem(simpleGamesystem);
|
||||||
|
productGamesystem.addChildGamesystem(simpleGamesystem);
|
||||||
|
simpleParentGamesystem.addChildGamesystem(productGamesystem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(simpleParentGamesystem == undefined) {
|
||||||
|
this.gameModel.removeGamesystem(simpleGamesystem);
|
||||||
|
this.gameModel.addGamesystem(productGamesystem);
|
||||||
|
} else {
|
||||||
|
simpleParentGamesystem.removeChildGamesystem(simpleGamesystem);
|
||||||
|
simpleParentGamesystem.addChildGamesystem(productGamesystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,17 @@ import {MatIcon} from "@angular/material/icon";
|
|||||||
import {NgClass, NgForOf} from "@angular/common";
|
import {NgClass, NgForOf} from "@angular/common";
|
||||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
import {Character} from "../../project/game-model/characters/Character";
|
import {Character} from "../../project/game-model/characters/Character";
|
||||||
|
import {Overview} from "../Overview";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-character-overview',
|
selector: 'app-character-overview',
|
||||||
templateUrl: './character-overview.component.html',
|
templateUrl: './character-overview.component.html',
|
||||||
styleUrl: './character-overview.component.scss'
|
styleUrl: './character-overview.component.scss'
|
||||||
})
|
})
|
||||||
export class CharacterOverviewComponent {
|
export class CharacterOverviewComponent implements Overview{
|
||||||
|
refresh(): void {
|
||||||
|
//Nothing to-do
|
||||||
|
}
|
||||||
|
|
||||||
@Input() gameModel: GameModel | undefined
|
@Input() gameModel: GameModel | undefined
|
||||||
@Output("onOpenCharacterEditor") openCharacterEmitter: EventEmitter<Character> = new EventEmitter<Character>();
|
@Output("onOpenCharacterEditor") openCharacterEmitter: EventEmitter<Character> = new EventEmitter<Character>();
|
||||||
|
@ -8,6 +8,7 @@ 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 {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
|
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
|
||||||
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
|
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
|
||||||
|
import {Overview} from "../Overview";
|
||||||
|
|
||||||
|
|
||||||
interface FlatNode {
|
interface FlatNode {
|
||||||
@ -20,7 +21,7 @@ interface FlatNode {
|
|||||||
templateUrl: './gamescript-overview.component.html',
|
templateUrl: './gamescript-overview.component.html',
|
||||||
styleUrl: './gamescript-overview.component.scss'
|
styleUrl: './gamescript-overview.component.scss'
|
||||||
})
|
})
|
||||||
export class GamescriptOverviewComponent implements OnInit {
|
export class GamescriptOverviewComponent implements OnInit, Overview {
|
||||||
|
|
||||||
@Input('gameModel') gameModel: GameModel | undefined
|
@Input('gameModel') gameModel: GameModel | undefined
|
||||||
@Output('openGamesystemEditor') openGamesystemEmitter : EventEmitter<Gamesystem<State<any>, Transition<any>>> = new EventEmitter<Gamesystem<State<any>, Transition<any>>>();
|
@Output('openGamesystemEditor') openGamesystemEmitter : EventEmitter<Gamesystem<State<any>, Transition<any>>> = new EventEmitter<Gamesystem<State<any>, Transition<any>>>();
|
||||||
|
@ -2,13 +2,14 @@ import {Component, EventEmitter, Input, NgZone, Output} from '@angular/core';
|
|||||||
import {ElectronService} from "../../core/services";
|
import {ElectronService} from "../../core/services";
|
||||||
import {GameModel} from "../../project/game-model/GameModel";
|
import {GameModel} from "../../project/game-model/GameModel";
|
||||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import {Overview} from "../Overview";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-script-account-overview',
|
selector: 'app-script-account-overview',
|
||||||
templateUrl: './script-account-overview.component.html',
|
templateUrl: './script-account-overview.component.html',
|
||||||
styleUrl: './script-account-overview.component.css'
|
styleUrl: './script-account-overview.component.css'
|
||||||
})
|
})
|
||||||
export class ScriptAccountOverviewComponent {
|
export class ScriptAccountOverviewComponent implements Overview{
|
||||||
@Input("gameModel") gameModel: GameModel | undefined
|
@Input("gameModel") gameModel: GameModel | undefined
|
||||||
@Output("onOpenScriptAccount") openScriptAccountEmitter: EventEmitter<ScriptAccount> = new EventEmitter<ScriptAccount>();
|
@Output("onOpenScriptAccount") openScriptAccountEmitter: EventEmitter<ScriptAccount> = new EventEmitter<ScriptAccount>();
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ export class ScriptAccountOverviewComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh(): void {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
onOpenScriptAccount(scriptAccount: ScriptAccount) {
|
onOpenScriptAccount(scriptAccount: ScriptAccount) {
|
||||||
console.log("onOpenScriptAccount (overview)")
|
console.log("onOpenScriptAccount (overview)")
|
||||||
this.openScriptAccountEmitter.emit(scriptAccount);
|
this.openScriptAccountEmitter.emit(scriptAccount);
|
||||||
|
7
testModel/gamesystems/Parentgamesystem.json
Normal file
7
testModel/gamesystems/Parentgamesystem.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"componentName": "Parentgamesystem",
|
||||||
|
"componentDescription": "",
|
||||||
|
"states": [],
|
||||||
|
"transitions": [],
|
||||||
|
"generateIsolatedStates": false
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user