54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
|
import {ModelComponent} from "../project/game-model/ModelComponent";
|
|
import {GameModel} from "../project/game-model/GameModel";
|
|
import {ScriptAccount} from "../project/game-model/scriptAccounts/ScriptAccount";
|
|
import {Gamesystem} from "../project/game-model/gamesystems/Gamesystem";
|
|
import {State} from "../project/game-model/gamesystems/states/State";
|
|
import {Transition} from "../project/game-model/gamesystems/transitions/Transition";
|
|
import {ModelComponentType} from "../project/game-model/ModelComponentType";
|
|
|
|
|
|
@Component({
|
|
selector: 'app-editor',
|
|
templateUrl: './editor.component.html',
|
|
styleUrl: './editor.component.scss'
|
|
})
|
|
export class EditorComponent {
|
|
gameModelComponents: ModelComponent[] = [];
|
|
@Output("onModelNameUpdate") onModelNameUpdateEmitter = new EventEmitter<boolean>();
|
|
activeTab: number = this.gameModelComponents.length;
|
|
@Input() gameModel: GameModel | undefined
|
|
|
|
openGameModelComponent(gameModelComponent: ModelComponent) {
|
|
if(!this.gameModelComponents.includes(gameModelComponent)) {
|
|
this.gameModelComponents.push(gameModelComponent);
|
|
this.activeTab = this.gameModelComponents.length;
|
|
} else {
|
|
this.activeTab = this.gameModelComponents.findIndex(component => component.componentName === gameModelComponent.componentName);
|
|
}
|
|
}
|
|
|
|
closeGameModelComponent(gameModelComponent: ModelComponent) {
|
|
this.gameModelComponents = this.gameModelComponents.filter(modelComponent => modelComponent !== gameModelComponent);
|
|
}
|
|
|
|
convertModelComponentToScriptAccount(modelComponent: ModelComponent) {
|
|
if(modelComponent instanceof ScriptAccount) {
|
|
return modelComponent as ScriptAccount;
|
|
}
|
|
}
|
|
|
|
convertModelComponentToGamesystem(modelComponent: ModelComponent) {
|
|
if(modelComponent instanceof Gamesystem) {
|
|
return modelComponent as Gamesystem<State<any>, Transition<any>>;
|
|
}
|
|
}
|
|
|
|
|
|
onModelNameUpdate() {
|
|
this.onModelNameUpdateEmitter.emit(true);
|
|
}
|
|
|
|
protected readonly ModelComponentType = ModelComponentType;
|
|
}
|