feat(Settings): Allow moving Vencord section to different places
This commit is contained in:
parent
f94cbfb2f4
commit
734054ff68
2 changed files with 40 additions and 3 deletions
|
@ -22,7 +22,7 @@ import DonateButton from "@components/DonateButton";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import IpcEvents from "@utils/IpcEvents";
|
import IpcEvents from "@utils/IpcEvents";
|
||||||
import { useAwaiter } from "@utils/misc";
|
import { useAwaiter } from "@utils/misc";
|
||||||
import { Button, Card, Forms, React, Switch } from "@webpack/common";
|
import { Button, Card, Forms, Margins, React, Switch } from "@webpack/common";
|
||||||
|
|
||||||
const st = (style: string) => `vcSettings${style}`;
|
const st = (style: string) => `vcSettings${style}`;
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ function VencordSettings() {
|
||||||
<Forms.FormDivider />
|
<Forms.FormDivider />
|
||||||
|
|
||||||
<Forms.FormSection title="Settings">
|
<Forms.FormSection title="Settings">
|
||||||
|
<Forms.FormText className={Margins.marginBottom20}>
|
||||||
|
Hint: You can change the position of this settings section in the settings of the "Settings" plugin!
|
||||||
|
</Forms.FormText>
|
||||||
<Switch
|
<Switch
|
||||||
value={settings.useQuickCss}
|
value={settings.useQuickCss}
|
||||||
onChange={(v: boolean) => settings.useQuickCss = v}
|
onChange={(v: boolean) => settings.useQuickCss = v}
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Settings } from "@api/settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import Logger from "@utils/Logger";
|
||||||
import { LazyComponent } from "@utils/misc";
|
import { LazyComponent } from "@utils/misc";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
import gitHash from "~git-hash";
|
import gitHash from "~git-hash";
|
||||||
|
|
||||||
|
@ -43,7 +45,23 @@ export default definePlugin({
|
||||||
}, {
|
}, {
|
||||||
find: "Messages.ACTIVITY_SETTINGS",
|
find: "Messages.ACTIVITY_SETTINGS",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/,
|
get match() {
|
||||||
|
switch (Settings.plugins.Settings.settingsLocation) {
|
||||||
|
case "top": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.USER_SETTINGS\}/;
|
||||||
|
case "aboveNitro": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.BILLING_SETTINGS\}/;
|
||||||
|
case "belowNitro": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.APP_SETTINGS\}/;
|
||||||
|
case "aboveActivity": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/;
|
||||||
|
case "belowActivity": return /(?<=\{section:(.{1,2})\.ID\.DIVIDER},)\{section:"changelog"/;
|
||||||
|
case "bottom": return /\{section:(.{1,2})\.ID\.CUSTOM,\s*element:.+?}/;
|
||||||
|
default: {
|
||||||
|
new Logger("Settings").error(
|
||||||
|
new Error("No switch case matched????? Don't mess with the settings, silly")
|
||||||
|
);
|
||||||
|
// matches nothing
|
||||||
|
return /(?!a)a/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
replace: (m, mod) => {
|
replace: (m, mod) => {
|
||||||
const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Plugins.plugins.Settings.tabs.updater},' : "";
|
const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Plugins.plugins.Settings.tabs.updater},' : "";
|
||||||
const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"Patch Helper",element:Vencord.Components.PatchHelper},' : "";
|
const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"Patch Helper",element:Vencord.Components.PatchHelper},' : "";
|
||||||
|
@ -61,6 +79,22 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
options: {
|
||||||
|
settingsLocation: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Where to put the Vencord settings section",
|
||||||
|
options: [
|
||||||
|
{ label: "At the very top", value: "top" },
|
||||||
|
{ label: "Above the Nitro section", value: "aboveNitro" },
|
||||||
|
{ label: "Below the Nitro section", value: "belowNitro" },
|
||||||
|
{ label: "Above Activity Settings", value: "aboveActivity", default: true },
|
||||||
|
{ label: "Below Activity Settings", value: "belowActivity" },
|
||||||
|
{ label: "At the very bottom", value: "bottom" },
|
||||||
|
],
|
||||||
|
restartNeeded: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
tabs: {
|
tabs: {
|
||||||
vencord: () => <SettingsComponent tab="VencordSettings" />,
|
vencord: () => <SettingsComponent tab="VencordSettings" />,
|
||||||
plugins: () => <SettingsComponent tab="VencordPlugins" />,
|
plugins: () => <SettingsComponent tab="VencordPlugins" />,
|
||||||
|
|
Loading…
Reference in a new issue