issue-2-scriptAccounts #4

Merged
sebastian merged 15 commits from issue-2-scriptAccounts into main 2024-02-05 18:16:10 +01:00
3 changed files with 48 additions and 2 deletions
Showing only changes of commit 35a323e97a - Show all commits

View File

@ -1,4 +1,4 @@
import {app, BrowserWindow, screen} from 'electron'; import {app, BrowserWindow, screen, Menu, ipcMain} from 'electron';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
@ -50,6 +50,41 @@ function createWindow(): BrowserWindow {
win = null; win = null;
}); });
const contextMenuTemplate = [
{
label: 'New',
submenu: [
{
label: "Gamesystem",
click: () => {
win!.webContents.send('context-menu', "new-location");
}
},
{
label: "ScriptAccount",
click: () => {
win!.webContents.send('context-menu', "new-scriptaccount");
}
}
]
},
{
label: 'Edit...'
},
{
label: 'Delete...'
}
]
const contextMenu = Menu.buildFromTemplate(contextMenuTemplate);
win.webContents.on('context-menu', (e, params) => {
console.log("Electron: Context menu showing")
contextMenu.popup({ window: win!, x: params.x, y: params.y });
})
return win; return win;
} }

View File

@ -1,6 +1,6 @@
<mat-action-list> <mat-action-list>
<mat-list-item class="scriptAccount-item" *ngFor="let scriptAccount of gameModel!.scriptAccounts" <mat-list-item class="scriptAccount-item" *ngFor="let scriptAccount of gameModel!.scriptAccounts"
(dblclick)="onOpenScriptAccount(scriptAccount)"> (dblclick)="onOpenScriptAccount(scriptAccount)" (contextmenu)="onContextMenu($event)">
<mat-icon class="scriptAccount-icon">inventory_2</mat-icon>{{scriptAccount.componentName}} <mat-icon class="scriptAccount-icon">inventory_2</mat-icon>{{scriptAccount.componentName}}
</mat-list-item> </mat-list-item>
</mat-action-list> </mat-action-list>

View File

@ -1,6 +1,7 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import {GameModel} from "../../game-model/GameModel"; import {GameModel} from "../../game-model/GameModel";
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
import {ElectronService} from "../../core/services";
@Component({ @Component({
selector: 'app-script-account-overview', selector: 'app-script-account-overview',
@ -11,6 +12,9 @@ export class ScriptAccountOverviewComponent {
@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>();
constructor(private electronService: ElectronService) {
}
onOpenScriptAccount(scriptAccount: ScriptAccount) { onOpenScriptAccount(scriptAccount: ScriptAccount) {
console.log("onOpenScriptAccount (overview)") console.log("onOpenScriptAccount (overview)")
this.openScriptAccountEmitter.emit(scriptAccount); this.openScriptAccountEmitter.emit(scriptAccount);
@ -22,5 +26,12 @@ export class ScriptAccountOverviewComponent {
return scriptAccount; return scriptAccount;
} }
onContextMenu(event: MouseEvent) {
if(this.electronService.isElectron) {
console.log("[DEBUG] [ScriptAccountOverviewComponent] App is executed in electron")
} else {
console.log("[DEBUG] [ScriptAccountOverviewComponent] App is not executed in electron")
}
}
} }