Skip to content

Commit

Permalink
[Fix] toggle overlay (#1143)
Browse files Browse the repository at this point in the history
* init fix toggle overlay

* update hp/overlay to alpha build

* fix codecheck

* prettier

* update hp overlay

* update ext provider and overlay
  • Loading branch information
BrettCleary authored Nov 8, 2024
1 parent ac374ca commit 9235a6c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 42 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"@hyperplay/check-disk-space": "^3.5.2",
"@hyperplay/quests-ui": "^0.0.28",
"@hyperplay/ui": "^1.8.8",
"@hyperplay/utils": "^0.2.4",
"@hyperplay/utils": "^0.3.3",
"@mantine/carousel": "^7.12.0",
"@mantine/core": "^7.12.0",
"@mantine/dropzone": "^7.12.0",
Expand Down Expand Up @@ -364,9 +364,9 @@
},
"optionalDependencies": {
"@hyperplay/extension-importer": "^0.0.4",
"@hyperplay/extension-provider": "^0.0.7",
"@hyperplay/extension-provider": "^0.0.8",
"@hyperplay/mock-backend": "^0.0.1",
"@hyperplay/overlay": "^0.0.6",
"@hyperplay/overlay": "^0.0.7",
"@hyperplay/providers": "^0.0.6",
"@hyperplay/proxy-server": "^0.0.11"
},
Expand Down
10 changes: 5 additions & 5 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ if (!gotTheLock) {
// Someone tried to run a second instance, we should focus the overlay or the main window if no overlay is running.
const hpOverlay = await getHpOverlay()
if (hpOverlay?.overlayIsRunning()) {
hpOverlay.toggleOverlay({ action: 'ON' })
hpOverlay.toggleOverlay({ action: 'ON', actionCause: 'AUTOMATED' })
} else {
const mainWindow = getMainWindow()
mainWindow?.show()
Expand Down Expand Up @@ -484,8 +484,8 @@ if (!gotTheLock) {

// keyboards with alt and no option key can be used with mac so register both
const hpOverlay = await getHpOverlay()
const toggle =
hpOverlay?.toggleOverlay ??
const toggle = () =>
hpOverlay?.toggleOverlay({ action: 'TOGGLE', actionCause: 'HOTKEY' }) ??
(() =>
logInfo(
'Cannot toggle overlay without @hyperplay/overlay package',
Expand Down Expand Up @@ -2069,9 +2069,9 @@ ipcMain.on('killOverlay', async () => {
hpOverlay?.closeOverlay()
})

ipcMain.on('toggleOverlay', async () => {
ipcMain.on('toggleOverlay', async (ev, ...args) => {
const hpOverlay = await getHpOverlay()
hpOverlay?.toggleOverlay()
hpOverlay?.toggleOverlay(...args)
})

ipcMain.handle('getHyperPlayListings', async () => {
Expand Down
7 changes: 5 additions & 2 deletions src/backend/overlay/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
PROVIDERS,
OverlayRenderState,
OverlayMode,
ToastKey
ToastKey,
HyperPlayAPI
} from '@hyperplay/utils'
import { Toast } from './types'
import { ipcRenderer } from 'electron'
Expand Down Expand Up @@ -102,4 +103,6 @@ export const lockPopup = (lock: boolean) => ipcRenderer.send('lockPopup', lock)

export const killOverlay = () => ipcRenderer.send('killOverlay')

export const toggleOverlay = () => ipcRenderer.send('toggleOverlay')
export const toggleOverlay = (
args: Parameters<HyperPlayAPI['toggleOverlay']>[0]
) => ipcRenderer.send('toggleOverlay', args)
5 changes: 3 additions & 2 deletions src/common/typedefs/ipcBridge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ import {
MetaMaskInitMethod,
ImportableBrowser,
MetaMaskImportOptions,
ClientUpdateStatuses
ClientUpdateStatuses,
HyperPlayAPI
} from '@hyperplay/utils'

/**
Expand Down Expand Up @@ -94,7 +95,7 @@ interface HyperPlaySyncIPCFunctions {
toastCloseOnClick: (key: ToastKey) => void
lockPopup: (lock: boolean) => void
killOverlay: () => void
toggleOverlay: () => void
toggleOverlay: HyperPlayAPI['toggleOverlay']
authConnected: () => void
goToGamePage: (gameId: string, action: GamePageActions) => void
authDisconnected: () => void
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/OverlayManager/Overlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Overlay = observer(function ({
</Button>
<Button
onClick={async () => {
window.api.toggleOverlay()
window.api.toggleOverlay({ action: 'OFF', actionCause: 'HOTKEY' })
}}
type="secondary"
size="medium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export const QuestDetailsViewPlayWrapper = observer(
steamAccountLinked: false
},
playStreak: getPlaystreakArgsFromQuestData({
// @ts-expect-error need to update quests-ui to match new hp/utils Quest type
questMeta,
questPlayStreakData
})
Expand Down
49 changes: 20 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1263,12 +1263,12 @@
fs-extra "^11.2.0"
graceful-fs "^4.2.11"

"@hyperplay/extension-provider@^0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@hyperplay/extension-provider/-/extension-provider-0.0.7.tgz#20d380ced3e1cac2f700143471d49b0ff6ed9e1c"
integrity sha512-BcI53hI9sC1vtup1cB0+7a5gL34lSq8INUOl/CY/F+4l4YG7IHQBZ9E6IEd76oO+kloxpVBggoe1DUwa+qyutA==
"@hyperplay/extension-provider@^0.0.8":
version "0.0.8"
resolved "https://registry.yarnpkg.com/@hyperplay/extension-provider/-/extension-provider-0.0.8.tgz#74c95ebd4bb7f148051960fb614bd6d5462119a5"
integrity sha512-/5UHQdjHhvPX2iAmnZ9xy6c+yx70VYSYjnE/iSKdyfrZpIkY2kFzTGzi38nZV1GZVoKjV2EDuzLImYt9eXxjSw==
dependencies:
"@hyperplay/utils" "^0.0.12"
"@hyperplay/utils" "^0.3.3"
fs-extra "^11.2.0"
graceful-fs "^4.2.11"
zod "^3.23.8"
Expand All @@ -1285,12 +1285,12 @@
express "^4.18.2"
stream-throttle "^0.1.3"

"@hyperplay/overlay@^0.0.6":
version "0.0.6"
resolved "https://registry.yarnpkg.com/@hyperplay/overlay/-/overlay-0.0.6.tgz#c25bc205917dfc0c17c9b95a525cea08960a3680"
integrity sha512-y9GON2QFoJybfElUhv8P9eDPwRXLyHzcCvr2GLPY685Yww8ryGlnpj8LevpLqirz71PqrR2p5P9wmUTybi9KMg==
"@hyperplay/overlay@^0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@hyperplay/overlay/-/overlay-0.0.7.tgz#d212accddc925cac7f11d626b4ba30a9058819f9"
integrity sha512-iIKdcFewYLh32aqwDPYxUQHJ5LCNTayhfYU/8ZhL4t8/PmjZtmzSKiBoMH/U+8S31m9kE4aoavMmHYX5xhkqtw==
dependencies:
"@hyperplay/utils" "^0.0.14"
"@hyperplay/utils" "^0.3.3"
mobx "^6.12.3"

"@hyperplay/providers@^0.0.6":
Expand Down Expand Up @@ -1329,31 +1329,17 @@
resolved "https://registry.yarnpkg.com/@hyperplay/ui/-/ui-1.8.8.tgz#35e833a3f9760fe0d74a539e32f9cc77a77cfa4c"
integrity sha512-UpSV2mbd1XLkZfh6YPiYCwj7ZEqz/Jk1aFym8YLrNmY70AjhVDMxBJmSxuy83iKWJbBeIZAxE5ZzAAU2fiZpFg==

"@hyperplay/utils@^0.0.12":
version "0.0.12"
resolved "https://registry.yarnpkg.com/@hyperplay/utils/-/utils-0.0.12.tgz#4ce7a97268f862deae99363d2d8029ee80003cc0"
integrity sha512-EQ7i/OPlF8Se1DsLWvyrEf1Bv20wNnKpT7U+t6KolDudolhAnMNMvjnpcDc431ctWxpi9PZbYjNcwhkGdpo9ww==
dependencies:
bignumber.js "^9.1.2"

"@hyperplay/utils@^0.0.14":
version "0.0.14"
resolved "https://registry.yarnpkg.com/@hyperplay/utils/-/utils-0.0.14.tgz#7420bdb67214c24086ed8463a9cabc30a7023192"
integrity sha512-eWn3jVTBBH2ki5+etZQs77hH4qVpphSINjBRW8AJ5oNtUXCqrPFS+eFimfUyzi+Kwl2/ef9lQ1QD3SEe/1BRZA==
dependencies:
bignumber.js "^9.1.2"

"@hyperplay/utils@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@hyperplay/utils/-/utils-0.0.9.tgz#80836cfde5c4d63e41f5df809ae2e80314600c5a"
integrity sha512-gMAa6gdFXfLrJUjPAD2is06qNo4MHzpb6Cbzt4xfNd7wI9chOblQ+piwTI1oFWs44GgfacsMq6i5esNly3hELg==
dependencies:
bignumber.js "^9.1.2"

"@hyperplay/utils@^0.2.4":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@hyperplay/utils/-/utils-0.2.6.tgz#2862c690f4dbf7871c66631f29ce0561020ef8d7"
integrity sha512-9ldiOq7ioaEecHJaqKBbwo1594nMLUPQXjaeuupqWU88GJW1CNcbhJhi6p3H6v4eSsj5IWr5VkxGmAVyOKuBkg==
"@hyperplay/utils@^0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@hyperplay/utils/-/utils-0.3.3.tgz#9d594a29012ae5a172138878208d6d4edb6412f2"
integrity sha512-t8XB7oFWJU4S1ULxVBURt9BhpgaZAq5C131Ch5wShxuMTjxxGEhTAAcppsH+VYd7lwtp4se9myzhc6u21rUNgQ==
dependencies:
bignumber.js "^9.1.2"

Expand Down Expand Up @@ -10442,7 +10428,12 @@ mobx-react-lite@^4.0.7:
dependencies:
use-sync-external-store "^1.2.0"

mobx@^6.12.3, mobx@^6.13.1:
mobx@^6.12.3:
version "6.13.5"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.13.5.tgz#957d9df88c7f8b4baa7c6f8bdcb6d68b432a6ed5"
integrity sha512-/HTWzW2s8J1Gqt+WmUj5Y0mddZk+LInejADc79NJadrWla3rHzmRHki/mnEUH1AvOmbNTZ1BRbKxr8DSgfdjMA==

mobx@^6.13.1:
version "6.13.1"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.13.1.tgz#76c41aa675199f75b84a257e4bec8ff839e33259"
integrity sha512-ekLRxgjWJr8hVxj9ZKuClPwM/iHckx3euIJ3Np7zLVNtqJvfbbq7l370W/98C8EabdQ1pB5Jd3BbDWxJPNnaOg==
Expand Down

0 comments on commit 9235a6c

Please sign in to comment.