ConceptCreator/src/app/app.component.ts

83 lines
2.8 KiB
TypeScript
Raw Normal View History

import {Component, NgZone, OnInit, ViewChild} from '@angular/core';
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";
import {GameModel} from "./game-model/GameModel";
import {EditorComponent} from "./editor/editor.component";
import {ModelComponent} from "./game-model/ModelComponent";
import {
ScriptAccountOverviewComponent
} from "./side-overviews/script-account-overview/script-account-overview.component";
2024-01-26 23:07:40 +01:00
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
openContent : ModelComponentType | undefined = undefined;
@ViewChild('drawer') drawer: MatDrawerContainer|undefined
@ViewChild('editor') editor: EditorComponent|undefined
@ViewChild('scriptAccountOverview') scriptAccountOverview: ScriptAccountOverviewComponent | undefined
gameModel: GameModel | undefined
constructor(private electronService: ElectronService,
private zone: NgZone
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);
electronService.ipcRenderer.on('context-menu', (event: any, message: string) => {
this.zone.run(() => {
if(message == "edit") {
console.log("Edit!")
if(this.openContent == ModelComponentType.SCRIPTACCOUNT && this.scriptAccountOverview != undefined && this.scriptAccountOverview.selectedScriptAccount != undefined) {
this.editor!.openGameModelComponent(this.scriptAccountOverview.selectedScriptAccount!);
}
}
})
})
2024-01-26 23:07:40 +01:00
} else {
console.log('Run in browser');
}
}
ngOnInit() {
this.gameModel = new GameModel("No More");
this.gameModel.addScriptAccount("Temperature");
this.gameModel.addScriptAccount("Luftfeuchtigkeit");
}
openScriptAccountsOverview() {
this.openContent = ModelComponentType.SCRIPTACCOUNT
this.drawer!.open();
}
protected readonly ModelComponentType = ModelComponentType;
closeContentOverview() {
this.drawer!.close();
this.openContent = undefined;
}
protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
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
}