Skip to content

Commit

Permalink
style: prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wurielle authored and actions-user committed Jan 14, 2025
1 parent 4483cc0 commit 1e9c51e
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions apps/app/src/electron/game-overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { Window } from 'win-control'
import { Deferred } from '@packages/toolbox'

type ProcessInfo = {
process: string,
pid: number,
filepath: string,
process: string
pid: number
filepath: string
user: string
}

Expand All @@ -32,8 +32,7 @@ class GameOverlay {
private markQuit = false
private scaleFactor = 1.0

constructor() {
}
constructor() {}

public isReady = () => ready.promise

Expand Down Expand Up @@ -81,12 +80,12 @@ class GameOverlay {
const { top, left, right, bottom } = Window.getByPid(
payload.pid,
).getDimensions()
const width = right-left
const height = bottom-top
const width = right - left
const height = bottom - top

mouse.getPosition().then(async (initialPosition) => {
await mouse.setPosition(
new Point(left+width / 2, top+height / 2),
new Point(left + width / 2, top + height / 2),
)
await mouse.leftClick()
await mouse.setPosition(initialPosition)
Expand Down Expand Up @@ -247,7 +246,7 @@ class GameOverlay {
for (const window of this.Overlay.getTopWindows()) {
if (window.processId === processInfo.pid) {
console.log(
`--------------------\n injecting ${ JSON.stringify(window) }`,
`--------------------\n injecting ${JSON.stringify(window)}`,
)
this.Overlay.injectProcess(window)
this.hookedProcesses.push(processInfo)
Expand All @@ -256,34 +255,33 @@ class GameOverlay {
}

public start() {
return import('@packages/electron-game-overlay')
.then((Overlay) => {
this.Overlay = Overlay.default
this.scaleFactor = screen.getDisplayNearestPoint({
x: 0,
y: 0,
}).scaleFactor

this.startOverlay()
return import('@packages/electron-game-overlay').then((Overlay) => {
this.Overlay = Overlay.default
this.scaleFactor = screen.getDisplayNearestPoint({
x: 0,
y: 0,
}).scaleFactor

const child = fork(path.join(EXTERNALS_DIR, 'detect-game.js'))
this.startOverlay()

child.on('message', (processInfo: ProcessEvent) => {
if (processInfo.type === 'game-detection') {
this.injectByProcessOnceFocused(processInfo.payload)
}
})
const child = fork(path.join(EXTERNALS_DIR, 'detect-game.js'))

onIPCGameOverlayStartIntercept(() => {
this.startIntercept()
})
child.on('message', (processInfo: ProcessEvent) => {
if (processInfo.type === 'game-detection') {
this.injectByProcessOnceFocused(processInfo.payload)
}
})

onIPCGameOverlayStopIntercept(() => {
this.stopIntercept()
})
onIPCGameOverlayStartIntercept(() => {
this.startIntercept()
})

return ready.resolve(true)
onIPCGameOverlayStopIntercept(() => {
this.stopIntercept()
})

return ready.resolve(true)
})
}

public quit() {
Expand Down

0 comments on commit 1e9c51e

Please sign in to comment.