mirror of https://github.com/GooseMod/GooseMod
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
46 lines
1.6 KiB
let goosemodScope = {};
|
|
|
|
export const setThisScope = (scope) => {
|
|
goosemodScope = scope;
|
|
};
|
|
|
|
export const show = (buttonText, title, description, cancelText = undefined, confirmButtonColor = undefined) => {
|
|
return new Promise((res) => {
|
|
const { React } = goosemodScope.webpackModules.common;
|
|
const { find, findByDisplayName, findByProps } = goosemodScope.webpackModules;
|
|
|
|
const Text = findByDisplayName("Text");
|
|
const Markdown = find((x) => x.displayName === 'Markdown' && x.rules);
|
|
const ButtonColors = findByProps('button', 'colorRed');
|
|
|
|
(0, findByProps('openModal', 'updateModal').openModal)((e) => {
|
|
if (e.transitionState === 3) res(false); // If clicked off
|
|
|
|
return React.createElement(findByDisplayName("ConfirmModal"),
|
|
{
|
|
header: title,
|
|
confirmText: buttonText,
|
|
cancelText: cancelText || goosemod.webpackModules.findByPropsAll('Messages')[1].Messages.CANCEL,
|
|
confirmButtonColor: ButtonColors[`color${confirmButtonColor ? (confirmButtonColor[0].toUpperCase() + confirmButtonColor.substring(1).toLowerCase()) : 'Red'}`],
|
|
onClose: () => { // General close (?)
|
|
res(false);
|
|
},
|
|
onCancel: () => { // Cancel text
|
|
res(false);
|
|
e.onClose();
|
|
},
|
|
onConfirm: () => { // Confirm button
|
|
res(true);
|
|
e.onClose();
|
|
},
|
|
transitionState: e.transitionState,
|
|
},
|
|
...description.split('\n').map((x) => React.createElement(Markdown,
|
|
{
|
|
size: Text.Sizes.SIZE_16
|
|
},
|
|
x))
|
|
);
|
|
});
|
|
});
|
|
}; |