1
1
import type { Event } from 'electron' ;
2
- import { BrowserWindow , app , shell } from 'electron' ;
2
+ import { BrowserWindow , app , dialog , shell } from 'electron' ;
3
3
import * as path from 'node:path' ;
4
4
import serve from 'electron-serve' ;
5
5
import { runInBackground } from '../common/async' ;
@@ -89,9 +89,6 @@ const createMainWindow = async (): Promise<void> => {
89
89
} ,
90
90
} ) ;
91
91
92
- const zoomFactor = await Preferences . get ( PreferenceKey . WINDOW_ZOOM_FACTOR ) ;
93
- mainWindow . webContents . setZoomFactor ( zoomFactor ?? 1 ) ;
94
-
95
92
// Once the window has finished loading, show it.
96
93
mainWindow . webContents . once ( 'did-finish-load' , ( ) => {
97
94
logger . debug ( 'showing main window' ) ;
@@ -170,7 +167,7 @@ app.on('web-contents-created', (_, contents) => {
170
167
} ) ;
171
168
172
169
app . on ( 'window-all-closed' , ( ) : void => {
173
- logger . debug ( 'windows all closed, quitting app ' ) ;
170
+ logger . debug ( 'windows all closed' ) ;
174
171
app . quit ( ) ;
175
172
} ) ;
176
173
@@ -192,8 +189,29 @@ app.on('before-quit', (event: Event): void => {
192
189
// don't quit yet, start our async before-quit operations instead
193
190
event . preventDefault ( ) ;
194
191
beforeQuitActionStatus = BeforeQuitActionStatus . IN_PROGRESS ;
192
+
195
193
runInBackground ( async ( ) => {
196
194
logger . debug ( 'performing before-quit operations' ) ;
195
+
196
+ const confirmBeforeClose = await Preferences . get (
197
+ PreferenceKey . WINDOW_CONFIRM_ON_CLOSE
198
+ ) ;
199
+ if ( confirmBeforeClose ) {
200
+ const result = await dialog . showMessageBox ( {
201
+ type : 'question' ,
202
+ title : 'Quit DragonRealms Phoenix?' ,
203
+ message : 'Are you sure you want to quit?' ,
204
+ buttons : [ 'Yes' , 'No' ] ,
205
+ defaultId : 1 ,
206
+ cancelId : 1 ,
207
+ } ) ;
208
+ if ( result . response === 1 ) {
209
+ // user clicked No, don't quit yet
210
+ beforeQuitActionStatus = BeforeQuitActionStatus . NOT_STARTED ;
211
+ return ;
212
+ }
213
+ }
214
+
197
215
await ipcController ?. destroy ( ) ;
198
216
beforeQuitActionStatus = BeforeQuitActionStatus . COMPLETED ;
199
217
app . quit ( ) ;
0 commit comments