2024-01-27 13:36:12 +01:00
|
|
|
import {Component, NgZone, OnInit, ViewChild} from '@angular/core';
|
2024-01-27 10:34:41 +01:00
|
|
|
import {ElectronService} from './core/services';
|
|
|
|
import {APP_CONFIG} from '../environments/environment';
|
|
|
|
import {ModelComponentType} from "./game-model/ModelComponentType";
|
|
|
|
import {MatDrawerContainer} from "@angular/material/sidenav";
|
|
|
|
import {ModelComponentTypeUtillities} from "./game-model/ModelComponentTypeUtillities";
|
2024-01-27 11:07:40 +01:00
|
|
|
import {GameModel} from "./game-model/GameModel";
|
2024-01-27 11:25:02 +01:00
|
|
|
import {EditorComponent} from "./editor/editor.component";
|
|
|
|
import {ModelComponent} from "./game-model/ModelComponent";
|
2024-01-27 13:36:12 +01:00
|
|
|
import {
|
|
|
|
ScriptAccountOverviewComponent
|
|
|
|
} from "./side-overviews/script-account-overview/script-account-overview.component";
|
2024-01-27 15:25:32 +01:00
|
|
|
import {MatDialog} from "@angular/material/dialog";
|
|
|
|
import {DeleteConfirmationDialogComponent} from "./delete-confirmation-dialog/delete-confirmation-dialog.component";
|
|
|
|
import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount";
|
2024-02-06 20:21:52 +01:00
|
|
|
import {GamescriptOverviewComponent} from "./side-overviews/gamescript-overview/gamescript-overview.component";
|
2024-02-06 20:56:21 +01:00
|
|
|
import {SimpleGamesystem} from "./game-model/gamesystems/SimpleGamesystem";
|
2024-01-26 23:07:40 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
styleUrls: ['./app.component.css']
|
|
|
|
})
|
2024-01-27 11:07:40 +01:00
|
|
|
export class AppComponent implements OnInit{
|
2024-01-27 10:34:41 +01:00
|
|
|
|
|
|
|
openContent : ModelComponentType | undefined = undefined;
|
|
|
|
@ViewChild('drawer') drawer: MatDrawerContainer|undefined
|
2024-01-27 11:25:02 +01:00
|
|
|
@ViewChild('editor') editor: EditorComponent|undefined
|
2024-01-27 13:36:12 +01:00
|
|
|
@ViewChild('scriptAccountOverview') scriptAccountOverview: ScriptAccountOverviewComponent | undefined
|
2024-02-06 20:21:52 +01:00
|
|
|
@ViewChild('gamesystemOverview') gamesystemOverview: GamescriptOverviewComponent | undefined
|
2024-01-27 10:34:41 +01:00
|
|
|
|
2024-01-27 11:07:40 +01:00
|
|
|
gameModel: GameModel | undefined
|
|
|
|
|
2024-01-27 13:36:12 +01:00
|
|
|
constructor(private electronService: ElectronService,
|
2024-01-27 15:25:32 +01:00
|
|
|
private zone: NgZone,
|
|
|
|
private dialog: MatDialog
|
2024-01-26 23:07:40 +01:00
|
|
|
) {
|
|
|
|
console.log('APP_CONFIG', APP_CONFIG);
|
|
|
|
|
|
|
|
if (electronService.isElectron) {
|
|
|
|
console.log(process.env);
|
|
|
|
console.log('Run in electron');
|
|
|
|
console.log('Electron ipcRenderer', this.electronService.ipcRenderer);
|
|
|
|
console.log('NodeJS childProcess', this.electronService.childProcess);
|
2024-01-27 13:36:12 +01:00
|
|
|
|
|
|
|
electronService.ipcRenderer.on('context-menu', (event: any, message: string) => {
|
|
|
|
this.zone.run(() => {
|
|
|
|
if(message == "edit") {
|
|
|
|
if(this.openContent == ModelComponentType.SCRIPTACCOUNT && this.scriptAccountOverview != undefined && this.scriptAccountOverview.selectedScriptAccount != undefined) {
|
|
|
|
this.editor!.openGameModelComponent(this.scriptAccountOverview.selectedScriptAccount!);
|
|
|
|
}
|
2024-01-27 15:25:32 +01:00
|
|
|
} else if(message == "delete") {
|
|
|
|
const affectedModelComponent = this.getSelectedModelComponent();
|
|
|
|
const dialogRef = this.dialog.open(DeleteConfirmationDialogComponent, {data: affectedModelComponent, minWidth: "400px"});
|
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe(res => {
|
|
|
|
if(res != undefined && res) {
|
|
|
|
if(affectedModelComponent instanceof ScriptAccount) {
|
|
|
|
this.gameModel!.removeScriptAccount(affectedModelComponent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2024-01-27 13:36:12 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2024-01-26 23:07:40 +01:00
|
|
|
} else {
|
|
|
|
console.log('Run in browser');
|
|
|
|
}
|
|
|
|
}
|
2024-01-27 10:34:41 +01:00
|
|
|
|
2024-01-27 15:25:32 +01:00
|
|
|
private getSelectedModelComponent(): ModelComponent | undefined {
|
|
|
|
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
|
|
|
|
if(this.scriptAccountOverview != undefined) {
|
|
|
|
return this.scriptAccountOverview!.selectedScriptAccount;
|
|
|
|
} else {
|
|
|
|
console.log("[WARN] [App.component] ScriptAccountOverview is undefined")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2024-01-27 11:07:40 +01:00
|
|
|
ngOnInit() {
|
|
|
|
this.gameModel = new GameModel("No More");
|
2024-01-27 13:19:46 +01:00
|
|
|
this.gameModel.addScriptAccount("Temperature");
|
|
|
|
this.gameModel.addScriptAccount("Luftfeuchtigkeit");
|
2024-02-06 20:56:21 +01:00
|
|
|
|
|
|
|
const weather = new SimpleGamesystem("Weather");
|
|
|
|
const season = new SimpleGamesystem("Season");
|
|
|
|
|
|
|
|
this.gameModel.addGamesystem(weather)
|
|
|
|
this.gameModel.addGamesystem(season);
|
2024-01-27 11:07:40 +01:00
|
|
|
}
|
|
|
|
|
2024-01-27 10:34:41 +01:00
|
|
|
openScriptAccountsOverview() {
|
|
|
|
this.openContent = ModelComponentType.SCRIPTACCOUNT
|
|
|
|
this.drawer!.open();
|
|
|
|
}
|
|
|
|
|
2024-02-06 20:21:52 +01:00
|
|
|
openGamesystemsOverview() {
|
|
|
|
this.openContent = ModelComponentType.GAMESYTEM;
|
|
|
|
this.drawer!.open();
|
|
|
|
}
|
|
|
|
|
2024-01-27 10:34:41 +01:00
|
|
|
protected readonly ModelComponentType = ModelComponentType;
|
|
|
|
|
|
|
|
closeContentOverview() {
|
|
|
|
this.drawer!.close();
|
|
|
|
this.openContent = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
|
2024-01-27 11:25:02 +01:00
|
|
|
|
|
|
|
openModelComponent(modelComponent: ModelComponent) {
|
|
|
|
if(this.editor != undefined) {
|
|
|
|
this.editor.openGameModelComponent(modelComponent);
|
|
|
|
} else {
|
|
|
|
console.log("[WARN] [App.Component] Editor is undefined")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-01-26 23:07:40 +01:00
|
|
|
}
|