add modal support, showModal->showContextMenu and new showModal

This commit is contained in:
AAGaming
2022-06-01 17:51:17 -04:00
parent 536269b1b7
commit 07ccceb990
5 changed files with 41 additions and 14 deletions

11
src/deck-components/Menu.tsx Normal file → Executable file
View File

@@ -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;

24
src/deck-components/Modal.tsx Normal file → Executable file
View File

@@ -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<ModalRootProps>;

10
src/deck-components/Spinner.tsx Normal file → Executable file
View File

@@ -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<{}>;

View File

@@ -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<{}>;

1
src/deck-components/index.ts Normal file → Executable file
View File

@@ -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';