From 07ccceb9900e43f871bc71b05e6ee819457dc0c1 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Wed, 1 Jun 2022 17:51:17 -0400 Subject: [PATCH] add modal support, showModal->showContextMenu and new showModal --- src/deck-components/Menu.tsx | 11 ++++++++++- src/deck-components/Modal.tsx | 24 ++++++++++++++++++++---- src/deck-components/Spinner.tsx | 10 +--------- src/deck-components/SteamSpinner.tsx | 9 +++++++++ src/deck-components/index.ts | 1 + 5 files changed, 41 insertions(+), 14 deletions(-) mode change 100644 => 100755 src/deck-components/Menu.tsx mode change 100644 => 100755 src/deck-components/Modal.tsx mode change 100644 => 100755 src/deck-components/Spinner.tsx create mode 100755 src/deck-components/SteamSpinner.tsx mode change 100644 => 100755 src/deck-components/index.ts diff --git a/src/deck-components/Menu.tsx b/src/deck-components/Menu.tsx old mode 100644 new mode 100755 index 0565390..24d5f04 --- a/src/deck-components/Menu.tsx +++ b/src/deck-components/Menu.tsx @@ -1,7 +1,16 @@ -import { FC } from 'react'; +import { FC, ReactNode } from 'react'; import { findModuleChild } from '../webpack'; +export const showContextMenu: (children: ReactNode, parent?: EventTarget) => void = findModuleChild((m) => { + if (typeof m !== 'object') return undefined; + for (let prop in m) { + if (typeof m[prop] === 'function' && m[prop].toString().includes('stopPropagation))')) { + return m[prop]; + } + } +}); + interface MenuProps { label: string; onCancel?(): void; diff --git a/src/deck-components/Modal.tsx b/src/deck-components/Modal.tsx old mode 100644 new mode 100755 index ffac0e5..16cd1a0 --- a/src/deck-components/Modal.tsx +++ b/src/deck-components/Modal.tsx @@ -1,12 +1,28 @@ -import { ReactNode } from 'react'; - +import { FC, ReactNode } from 'react'; import { findModuleChild } from '../webpack'; -export const showModal: (children: ReactNode, parent: EventTarget) => void = findModuleChild((m) => { +// TODO: there is another argument, figure out what it does +export const showModal: (children: ReactNode, parent?: EventTarget) => void = findModuleChild((m) => { if (typeof m !== 'object') return undefined; for (let prop in m) { - if (typeof m[prop] === 'function' && m[prop].toString().includes('stopPropagation))')) { + if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) { return m[prop]; } } }); + +interface ModalRootProps { + onMiddleButton?(): void, + onCancel?(): void; + onOK?(): void; + bAllowFullSize?: boolean; +} + +export const ModalRoot = findModuleChild(m => { + if (typeof m !== "object") return undefined; + for (let prop in m) { + if (!m[prop]?.prototype?.OK && m[prop]?.prototype?.Cancel && m[prop]?.prototype?.render) { + return m[prop]; + } + } +}) as FC; \ No newline at end of file diff --git a/src/deck-components/Spinner.tsx b/src/deck-components/Spinner.tsx old mode 100644 new mode 100755 index 0f4bb0f..e70b5c6 --- a/src/deck-components/Spinner.tsx +++ b/src/deck-components/Spinner.tsx @@ -2,15 +2,7 @@ import { FC } from 'react'; import { IconsModule } from '../webpack'; -// interface ButtonProps { -// label?: string; -// description?: string; -// layout?: 'below'; -// onClick?(e: MouseEvent): void; -// disabled?: boolean; -// bottomSeparator?: boolean; -// } - +// TODO type this and other icons? export const Spinner = Object.values(IconsModule).find((mod: any) => mod?.toString && /Spinner\)}\),.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString()) ) as FC<{}>; \ No newline at end of file diff --git a/src/deck-components/SteamSpinner.tsx b/src/deck-components/SteamSpinner.tsx new file mode 100755 index 0000000..925de7f --- /dev/null +++ b/src/deck-components/SteamSpinner.tsx @@ -0,0 +1,9 @@ +import { FC } from 'react'; +import { findModuleChild } from '../webpack'; + +export const SteamSpinner = findModuleChild((m) => { + if (typeof m !== "object") return undefined; + for (let prop in m) { + if (m[prop]?.toString()?.includes("Steam Spinner") && m[prop].toString().includes("PreloadThrobber")) return m[prop] + } +}) as FC<{}>; \ No newline at end of file diff --git a/src/deck-components/index.ts b/src/deck-components/index.ts old mode 100644 new mode 100755 index 1dcf386..3896a7c --- a/src/deck-components/index.ts +++ b/src/deck-components/index.ts @@ -4,6 +4,7 @@ export * from './Menu'; export * from './Modal'; export * from './Panel'; export * from './Slider'; +export * from './SteamSpinner'; export * from './Spinner'; export * from './static-classes'; export * from './Toggle';