Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0d7d7ce4f | |||
| a7a4bce19f |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "oflauncher",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "oflauncher",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "oflauncher",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"description": "Launcher Minecraft custom pour le modpack ATM10 (1.21.1 / NeoForge)",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "OFLauncher",
|
||||
|
||||
+8
-1
@@ -3,7 +3,7 @@ import { join } from 'path'
|
||||
import { setMainWindow } from './events'
|
||||
import { IPC, type UserSettings, type PlayOptions } from '../shared/ipc'
|
||||
import { login, logout, restoreSession, getCurrent } from './auth'
|
||||
import { play, stopGame } from './play'
|
||||
import { play, stopGame, isGameRunning } from './play'
|
||||
import { getPackMetaCached } from './modpack'
|
||||
import { getSettings, setSettings } from './settings'
|
||||
import { paths } from './paths'
|
||||
@@ -35,6 +35,13 @@ function createWindow(): BrowserWindow {
|
||||
|
||||
win.on('ready-to-show', () => win.show())
|
||||
|
||||
win.on('close', (e) => {
|
||||
if (isGameRunning()) {
|
||||
e.preventDefault()
|
||||
win.hide()
|
||||
}
|
||||
})
|
||||
|
||||
// Liens externes -> navigateur système.
|
||||
win.webContents.setWindowOpenHandler(({ url }) => {
|
||||
void shell.openExternal(url)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ChildProcess } from 'child_process'
|
||||
import { app, BrowserWindow } from 'electron'
|
||||
import { getCurrent } from './auth'
|
||||
import { fetchPackMeta } from './modpack'
|
||||
import { ensureJava } from './java'
|
||||
@@ -47,6 +48,10 @@ export async function play(opts?: PlayOptions): Promise<void> {
|
||||
gameProcess = proc
|
||||
proc.on('close', () => {
|
||||
gameProcess = null
|
||||
const allHidden = BrowserWindow.getAllWindows().every((w) => !w.isVisible())
|
||||
if (allHidden) {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
emit.progress({ phase: 'error', message: (e as Error).message, progress: undefined })
|
||||
@@ -60,3 +65,7 @@ export function stopGame(): boolean {
|
||||
gameProcess.kill()
|
||||
return true
|
||||
}
|
||||
|
||||
export function isGameRunning(): boolean {
|
||||
return gameProcess !== null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user