Compare commits
3 Commits
f39dab4f40
...
1c25ad6c3c
Author | SHA1 | Date |
---|---|---|
Ducko | 1c25ad6c3c | |
Ducko | 2749e6ccb7 | |
Ducko | 68c7f13f94 |
|
@ -0,0 +1,65 @@
|
|||
const { React } = goosemodScope.webpackModules.common;
|
||||
|
||||
const OriginalTextInput = goosemodScope.webpackModules.findByDisplayName('TextInput');
|
||||
|
||||
const OriginalFormItem = goosemodScope.webpackModules.findByDisplayName('FormItem');
|
||||
const OriginalFormText = goosemodScope.webpackModules.findByDisplayName('FormText');
|
||||
|
||||
const Flex = goosemodScope.webpackModules.findByDisplayName('Flex');
|
||||
const Margins = goosemodScope.webpackModules.findByProps('marginTop20', 'marginBottom20');
|
||||
const FormClasses = goosemodScope.webpackModules.findByProps('formText', 'description');
|
||||
|
||||
const FormDivider = goosemodScope.webpackModules.findByDisplayName('FormDivider');
|
||||
const SettingsFormClasses = goosemodScope.webpackModules.findByProps('dividerDefault', 'titleDefault');
|
||||
|
||||
class Divider extends React.PureComponent {
|
||||
render() {
|
||||
return React.createElement(FormDivider, {
|
||||
className: SettingsFormClasses.dividerDefault
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class FormItem extends React.PureComponent {
|
||||
render() {
|
||||
return React.createElement(OriginalFormItem, {
|
||||
title: this.props.title,
|
||||
required: this.props.required,
|
||||
className: [Flex.Direction.VERTICAL, Flex.Justify.START, Flex.Align.STRETCH, Flex.Wrap.NO_WRAP, Margins.marginBottom20].join(' ')
|
||||
},
|
||||
|
||||
this.props.children,
|
||||
|
||||
this.props.note && React.createElement(OriginalFormText, {
|
||||
className: FormClasses.description + (this.props.noteHasMargin ? (' ' + Margins.marginTop8) : '')
|
||||
}, this.props.note),
|
||||
|
||||
React.createElement(Divider)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TextInput extends React.PureComponent {
|
||||
render() {
|
||||
const title = this.props.children;
|
||||
delete this.props.children;
|
||||
|
||||
return React.createElement(FormItem, {
|
||||
title,
|
||||
note: this.props.note,
|
||||
required: this.props.required,
|
||||
|
||||
noteHasMargin: true
|
||||
},
|
||||
|
||||
React.createElement(OriginalTextInput, {
|
||||
...this.props
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
FormItem,
|
||||
TextInput
|
||||
};
|
|
@ -13,8 +13,6 @@ export const powercord = {
|
|||
async ( { args: [ { text } ] } ) => {
|
||||
const out = await executor(text.split(' ')); // Run original executor func (await incase it's an async function)
|
||||
|
||||
console.log(out);
|
||||
|
||||
if (!out.send) {
|
||||
goosemodScope.patcher.internalMessage(out.result); // PC impl. sends internal message when out.send === false, so we also do the same via our previous Patcher API function
|
||||
|
||||
|
@ -46,19 +44,102 @@ export const powercord = {
|
|||
|
||||
goosemodScope.showToast(content);
|
||||
}
|
||||
},
|
||||
|
||||
settings: {
|
||||
registerSettings: (id, { label, render, category }) => {
|
||||
const { React } = goosemodScope.webpackModules.common;
|
||||
|
||||
const SettingsView = goosemodScope.webpackModules.findByDisplayName('SettingsView');
|
||||
|
||||
const FormTitle = goosemodScope.webpackModules.findByDisplayName('FormTitle');
|
||||
const FormSection = goosemodScope.webpackModules.findByDisplayName('FormSection');
|
||||
|
||||
goosemodScope.patcher.inject(id, SettingsView.prototype, 'getPredicateSections', (_, sections) => {
|
||||
if (!sections.find(c => c.section === 'changelog')) return sections;
|
||||
|
||||
const dividers = sections.filter(c => c.section === 'DIVIDER');
|
||||
|
||||
const finalLabel = typeof label === 'function' ? label() : label;
|
||||
|
||||
sections.splice(sections.indexOf(dividers[dividers.length - 2]) - 2, 0,
|
||||
{
|
||||
section: finalLabel,
|
||||
label: finalLabel,
|
||||
predicate: () => { },
|
||||
element: () => React.createElement(FormSection, { },
|
||||
React.createElement(FormTitle, { tag: 'h2' }, finalLabel),
|
||||
|
||||
render({
|
||||
getSetting: settingStores[category].getSetting,
|
||||
updateSetting: settingStores[category].updateSetting
|
||||
})
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
return sections;
|
||||
});
|
||||
},
|
||||
|
||||
unregisterSettings: (id) => {
|
||||
goosemodScope.patcher.uninject(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const settingStores = {};
|
||||
|
||||
class SimpleStore {
|
||||
constructor() {
|
||||
this.store = {};
|
||||
}
|
||||
|
||||
getSetting = (key, defaultValue) => {
|
||||
return this.store[key] ?? defaultValue;
|
||||
}
|
||||
|
||||
updateSetting = (key, value) => {
|
||||
this.store[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
export class Plugin {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
loadStylesheet(path) {
|
||||
const url = `https://raw.githubusercontent.com/${this.github.repo}/main/${path}`;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
delayedConstructor() {
|
||||
if (this.delayedConstructed) return;
|
||||
this.delayedConstructed = true;
|
||||
|
||||
settingStores[this.entityID] = new SimpleStore();
|
||||
}
|
||||
|
||||
get entityID() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
get settings() {
|
||||
return settingStores[this.entityID];
|
||||
}
|
||||
|
||||
get goosemodHandlers() {
|
||||
return {
|
||||
onImport: this.startPlugin.bind(this),
|
||||
onImport: () => {
|
||||
this.delayedConstructor();
|
||||
|
||||
this.startPlugin.bind(this)();
|
||||
},
|
||||
|
||||
onRemove: this.pluginWillUnload.bind(this)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
"powercord/entities": "./moduleWrappers/powercord/entities.js",
|
||||
"powercord/injector": "./moduleWrappers/powercord/injector.js",
|
||||
"powercord/webpack": "./moduleWrappers/powercord/webpack.js",
|
||||
"powercord/util": "./moduleWrappers/powercord/util.js"
|
||||
"powercord/util": "./moduleWrappers/powercord/util.js",
|
||||
"powercord/components/settings": "./moduleWrappers/powercord/components/settings.js"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue