@@ -37,8 +37,7 @@ class GameOverlay {
37
37
private markQuit = false
38
38
private scaleFactor = 1.0
39
39
40
- constructor ( ) {
41
- }
40
+ constructor ( ) { }
42
41
43
42
public isReady = ( ) => ready . promise
44
43
@@ -89,12 +88,12 @@ class GameOverlay {
89
88
const { top, left, right, bottom } = this . WinControl . getByPid (
90
89
payload . pid ,
91
90
) . getDimensions ( )
92
- const width = right - left
93
- const height = bottom - top
91
+ const width = right - left
92
+ const height = bottom - top
94
93
95
94
mouse . getPosition ( ) . then ( async ( initialPosition ) => {
96
95
await mouse . setPosition (
97
- new Point ( left + width / 2 , top + height / 2 ) ,
96
+ new Point ( left + width / 2 , top + height / 2 ) ,
98
97
)
99
98
await mouse . leftClick ( )
100
99
await mouse . setPosition ( initialPosition )
@@ -254,9 +253,7 @@ class GameOverlay {
254
253
public injectByProcess ( processInfo : ProcessInfo ) {
255
254
for ( const window of this . Overlay . getTopWindows ( ) ) {
256
255
if ( window . processId === processInfo . pid ) {
257
- console . log (
258
- `[game-overlay] Injecting ${ JSON . stringify ( window ) } ` ,
259
- )
256
+ console . log ( `[game-overlay] Injecting ${ JSON . stringify ( window ) } ` )
260
257
this . Overlay . injectProcess ( window )
261
258
this . hookedProcesses . push ( processInfo )
262
259
}
@@ -267,7 +264,11 @@ class GameOverlay {
267
264
const databasesStore = useDatabasesStore ( )
268
265
const gameOverlayStore = useGameOverlayStore ( )
269
266
/* Importing win-control in preload breaks reload so we import it dynamically on start instead */
270
- return Promise . all ( [ import ( '@packages/electron-game-overlay' ) , import ( 'win-control' ) , gameOverlayStore . $whenReady ( ) ] ) . then ( ( [ Overlay , WinControl ] ) => {
267
+ return Promise . all ( [
268
+ import ( '@packages/electron-game-overlay' ) ,
269
+ import ( 'win-control' ) ,
270
+ gameOverlayStore . $whenReady ( ) ,
271
+ ] ) . then ( ( [ Overlay , WinControl ] ) => {
271
272
this . WinControl = WinControl
272
273
this . Overlay = Overlay . default
273
274
this . scaleFactor = screen . getDisplayNearestPoint ( {
@@ -277,35 +278,62 @@ class GameOverlay {
277
278
278
279
this . startOverlay ( )
279
280
280
-
281
- watch ( ( ) => [ gameOverlayStore . enableGameOverlay , gameOverlayStore . allowlist , gameOverlayStore . denylist , databasesStore . data ] , ( ) => {
282
- if ( ! gameOverlayStore . enableGameOverlay ) return
283
- console . log ( '[game-overlay] Creating process watcher process' )
284
- const child = fork ( path . join ( EXTERNALS_DIR , 'detect-game.js' ) )
285
- child . on ( 'message' , ( processInfo : ProcessEvent ) => {
286
- if ( processInfo . type === 'process-creation' ) {
287
- const { filepath } = processInfo . payload
288
- const isGame = micromatch . isMatch ( filepath , [ ...gameOverlayStore . allowlist , ...( databasesStore . data [ 'game-overlay-allowlist' ] || [ ] ) ] . filter ( Boolean ) )
289
- && ! micromatch . isMatch ( filepath , [ ...gameOverlayStore . denylist , ...( databasesStore . data [ 'game-overlay-denylist' ] || [ ] ) ] . filter ( Boolean ) )
290
- if ( isGame ) {
291
- console . log ( '[game-overlay]: Game launched' , filepath )
292
- // require('windows-tlist').getProcessInfo(processInfo.payload.pid).then(({ modules }: any) => console.log(modules.map(({ path }: any) => path.substring(path.lastIndexOf('\\')+1))))
293
- this . injectByProcessOnceFocused ( processInfo . payload )
281
+ watch (
282
+ ( ) => [
283
+ gameOverlayStore . enableGameOverlay ,
284
+ gameOverlayStore . allowlist ,
285
+ gameOverlayStore . denylist ,
286
+ databasesStore . data ,
287
+ ] ,
288
+ ( ) => {
289
+ if ( ! gameOverlayStore . enableGameOverlay ) return
290
+ console . log ( '[game-overlay] Creating process watcher process' )
291
+ const child = fork ( path . join ( EXTERNALS_DIR , 'detect-game.js' ) )
292
+ child . on ( 'message' , ( processInfo : ProcessEvent ) => {
293
+ if ( processInfo . type === 'process-creation' ) {
294
+ const { filepath } = processInfo . payload
295
+ const isGame =
296
+ micromatch . isMatch (
297
+ filepath ,
298
+ [
299
+ ...gameOverlayStore . allowlist ,
300
+ ...( databasesStore . data [ 'game-overlay-allowlist' ] || [ ] ) ,
301
+ ] . filter ( Boolean ) ,
302
+ ) &&
303
+ ! micromatch . isMatch (
304
+ filepath ,
305
+ [
306
+ ...gameOverlayStore . denylist ,
307
+ ...( databasesStore . data [ 'game-overlay-denylist' ] || [ ] ) ,
308
+ ] . filter ( Boolean ) ,
309
+ )
310
+ if ( isGame ) {
311
+ console . log ( '[game-overlay]: Game launched' , filepath )
312
+ // require('windows-tlist').getProcessInfo(processInfo.payload.pid).then(({ modules }: any) => console.log(modules.map(({ path }: any) => path.substring(path.lastIndexOf('\\')+1))))
313
+ this . injectByProcessOnceFocused ( processInfo . payload )
314
+ }
294
315
}
295
- }
296
- if ( processInfo . type === 'process-deletion' ) {
297
- if ( this . hookedProcesses . find ( ( process ) => process . pid === processInfo . payload . pid ) ) {
298
- this . hookedProcesses = this . hookedProcesses . filter ( ( process ) => process . pid !== processInfo . payload . pid )
316
+ if ( processInfo . type === 'process-deletion' ) {
317
+ if (
318
+ this . hookedProcesses . find (
319
+ ( process ) => process . pid === processInfo . payload . pid ,
320
+ )
321
+ ) {
322
+ this . hookedProcesses = this . hookedProcesses . filter (
323
+ ( process ) => process . pid !== processInfo . payload . pid ,
324
+ )
325
+ }
299
326
}
300
- }
301
- } )
302
- onWatcherCleanup ( ( ) => {
303
- child . kill ( )
304
- } )
305
- } , {
306
- deep : true ,
307
- immediate : true ,
308
- } )
327
+ } )
328
+ onWatcherCleanup ( ( ) => {
329
+ child . kill ( )
330
+ } )
331
+ } ,
332
+ {
333
+ deep : true ,
334
+ immediate : true ,
335
+ } ,
336
+ )
309
337
310
338
onIPCGameOverlayStartIntercept ( ( ) => {
311
339
this . startIntercept ( )
0 commit comments