2024-12-25 17:06:39 -05:00
|
|
|
import "./style.css";
|
|
|
|
|
2024-12-25 13:00:52 -05:00
|
|
|
import { definePluginSettings } from "@api/Settings";
|
|
|
|
import { Devs } from "@utils/constants";
|
|
|
|
import definePlugin, { OptionType } from "@utils/types";
|
|
|
|
import { findByProps, findByPropsLazy, findComponentByCode } from "@webpack";
|
|
|
|
import { FluxDispatcher, Forms, Select, Slider, Text, useEffect } from "@webpack/common";
|
|
|
|
import { useState } from "@webpack/common";
|
|
|
|
import { identity } from "@utils/misc";
|
|
|
|
import { boolean } from "ts-pattern/dist/patterns";
|
|
|
|
import { Settings } from "Vencord";
|
|
|
|
import { Link } from "@components/Link";
|
|
|
|
|
|
|
|
const audioConfigModule = findByPropsLazy("getOutputVolume");
|
|
|
|
|
|
|
|
function OutputVolumeComponent() {
|
|
|
|
const [outputVolume, setOutputVolume] = useState(audioConfigModule.getOutputVolume());
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const listener = () => setOutputVolume(audioConfigModule.getOutputVolume());
|
|
|
|
FluxDispatcher.subscribe("AUDIO_SET_OUTPUT_VOLUME", listener);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2024-12-25 16:36:12 -05:00
|
|
|
{Settings.plugins.VCPanelSettings.showOutputVolumeHeader && <Forms.FormTitle>Output volume - {Math.floor(outputVolume)}%</Forms.FormTitle>}
|
|
|
|
<Slider maxValue={200} minValue={0} initialValue={outputVolume} hideBubble={Settings.plugins.VCPanelSettings.showOutputVolumeHeader} onValueChange={(volume) => {
|
2024-12-25 13:00:52 -05:00
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
type: "AUDIO_SET_OUTPUT_VOLUME",
|
|
|
|
volume
|
|
|
|
});
|
|
|
|
}} />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function InputVolumeComponent() {
|
|
|
|
const [inputVolume, setInputVolume] = useState(audioConfigModule.getInputVolume());
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const listener = () => setInputVolume(audioConfigModule.getInputVolume());
|
|
|
|
FluxDispatcher.subscribe("AUDIO_SET_INPUT_VOLUME", listener);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2024-12-25 16:36:12 -05:00
|
|
|
{Settings.plugins.VCPanelSettings.showInputVolumeHeader && <Forms.FormTitle>Input volume - {Math.floor(inputVolume)}%</Forms.FormTitle>}
|
2024-12-25 13:00:52 -05:00
|
|
|
<Slider maxValue={100} minValue={0} initialValue={inputVolume} onValueChange={(volume) => {
|
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
type: "AUDIO_SET_INPUT_VOLUME",
|
|
|
|
volume
|
|
|
|
});
|
|
|
|
}} />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function OutputDeviceComponent() {
|
|
|
|
const [outputDevice, setOutputDevice] = useState(audioConfigModule.getOutputDeviceId());
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const listener = () => setOutputDevice(audioConfigModule.getOutputDeviceId());
|
|
|
|
FluxDispatcher.subscribe("AUDIO_SET_OUTPUT_DEVICE", listener);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2024-12-25 16:36:12 -05:00
|
|
|
{Settings.plugins.VCPanelSettings.showOutputDeviceHeader && <Forms.FormTitle>Output device</Forms.FormTitle>}
|
2024-12-25 13:00:52 -05:00
|
|
|
<Select options={Object.values(audioConfigModule.getOutputDevices()).map((device: any /*i am NOT typing this*/) => {
|
2024-12-25 16:36:12 -05:00
|
|
|
return { value: device.id, label: Settings.plugins.VCPanelSettings.showOutputDeviceHeader ? device.name : `🔊 ${device.name}` };
|
2024-12-25 13:00:52 -05:00
|
|
|
})}
|
|
|
|
serialize={identity}
|
|
|
|
isSelected={(value) => value === outputDevice}
|
|
|
|
select={(id) => {
|
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
type: "AUDIO_SET_OUTPUT_DEVICE",
|
|
|
|
id
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
|
|
|
|
</Select>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function InputDeviceComponent() {
|
|
|
|
const [inputDevice, setInputDevice] = useState(audioConfigModule.getInputDeviceId());
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const listener = () => setInputDevice(audioConfigModule.getInputDeviceId());
|
|
|
|
FluxDispatcher.subscribe("AUDIO_SET_INPUT_DEVICE", listener);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ marginTop: "10px" }}>
|
2024-12-25 16:36:12 -05:00
|
|
|
{Settings.plugins.VCPanelSettings.showInputDeviceHeader && <Forms.FormTitle>Input device</Forms.FormTitle>}
|
2024-12-25 13:00:52 -05:00
|
|
|
<Select options={Object.values(audioConfigModule.getInputDevices()).map((device: any /*i am NOT typing this*/) => {
|
2024-12-25 16:36:12 -05:00
|
|
|
return { value: device.id, label: Settings.plugins.VCPanelSettings.showInputDeviceHeader ? device.name : `🎤 ${device.name}` };
|
2024-12-25 13:00:52 -05:00
|
|
|
})}
|
|
|
|
serialize={identity}
|
|
|
|
isSelected={(value) => value === inputDevice}
|
|
|
|
select={(id) => {
|
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
type: "AUDIO_SET_INPUT_DEVICE",
|
|
|
|
id
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
|
|
|
|
</Select>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function VoiceSettings() {
|
2024-12-25 17:06:39 -05:00
|
|
|
const [showSettings, setShowSettings] = useState(Settings.plugins.VCPanelSettings.uncollapseSettingsByDefault);
|
2024-12-25 16:36:12 -05:00
|
|
|
return <div style={{ marginTop: "20px" }}>
|
2024-12-25 17:06:39 -05:00
|
|
|
<div style={{ marginBottom: "10px" }}>
|
|
|
|
<Link className="vc-panelsettings-underline-on-hover" style={{ color: "var(--header-secondary)" }} onClick={() => { setShowSettings(!showSettings); }}>{!showSettings ? "► Settings" : "▼ Hide"}</Link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{
|
|
|
|
showSettings && <>
|
|
|
|
{Settings.plugins.VCPanelSettings.outputVolume && <OutputVolumeComponent />}
|
|
|
|
{Settings.plugins.VCPanelSettings.inputVolume && <InputVolumeComponent />}
|
|
|
|
{Settings.plugins.VCPanelSettings.outputDevice && <OutputDeviceComponent />}
|
|
|
|
{Settings.plugins.VCPanelSettings.inputDevice && <InputDeviceComponent />}
|
|
|
|
</>
|
|
|
|
}
|
2024-12-25 13:00:52 -05:00
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default definePlugin({
|
|
|
|
name: "VCPanelSettings",
|
|
|
|
description: "Control voice settings right from the voice panel",
|
|
|
|
authors: [Devs.nin0dev],
|
|
|
|
settings: definePluginSettings({
|
2024-12-25 17:06:39 -05:00
|
|
|
title1: {
|
|
|
|
type: OptionType.COMPONENT,
|
|
|
|
component: () => <Text style={{ fontWeight: "bold", fontSize: "1.27rem" }}>Appearance</Text>,
|
|
|
|
description: ""
|
|
|
|
},
|
|
|
|
uncollapseSettingsByDefault: {
|
2024-12-25 13:00:52 -05:00
|
|
|
type: OptionType.BOOLEAN,
|
2024-12-25 17:06:39 -05:00
|
|
|
default: false,
|
|
|
|
description: "Automatically uncollapse voice settings by default"
|
|
|
|
},
|
|
|
|
title2: {
|
|
|
|
type: OptionType.COMPONENT,
|
|
|
|
component: () => <Text style={{ fontWeight: "bold", fontSize: "1.27rem" }}>Settings to show</Text>,
|
|
|
|
description: ""
|
2024-12-25 13:00:52 -05:00
|
|
|
},
|
|
|
|
outputVolume: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true,
|
|
|
|
description: "Show an output volume slider"
|
|
|
|
},
|
2024-12-25 17:06:39 -05:00
|
|
|
inputVolume: {
|
2024-12-25 13:00:52 -05:00
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true,
|
2024-12-25 17:06:39 -05:00
|
|
|
description: "Show an input volume slider"
|
2024-12-25 13:00:52 -05:00
|
|
|
},
|
2024-12-25 17:06:39 -05:00
|
|
|
outputDevice: {
|
2024-12-25 13:00:52 -05:00
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true,
|
2024-12-25 17:06:39 -05:00
|
|
|
description: "Show an output device selector"
|
2024-12-25 13:00:52 -05:00
|
|
|
},
|
2024-12-25 17:06:39 -05:00
|
|
|
|
|
|
|
inputDevice: {
|
2024-12-25 13:00:52 -05:00
|
|
|
type: OptionType.BOOLEAN,
|
2024-12-25 17:06:39 -05:00
|
|
|
default: true,
|
|
|
|
description: "Show an input device selector"
|
2024-12-25 13:00:52 -05:00
|
|
|
},
|
2024-12-25 17:06:39 -05:00
|
|
|
title3: {
|
|
|
|
type: OptionType.COMPONENT,
|
|
|
|
component: () => <Text style={{ fontWeight: "bold", fontSize: "1.27rem" }}>Headers to show</Text>,
|
|
|
|
description: ""
|
|
|
|
},
|
|
|
|
showOutputVolumeHeader: {
|
2024-12-25 13:00:52 -05:00
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true,
|
2024-12-25 17:06:39 -05:00
|
|
|
description: "Show header above output volume slider"
|
|
|
|
},
|
|
|
|
showInputVolumeHeader: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true,
|
|
|
|
description: "Show header above input volume slider"
|
|
|
|
},
|
|
|
|
showOutputDeviceHeader: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: false,
|
|
|
|
description: "Show header above output device slider"
|
2024-12-25 13:00:52 -05:00
|
|
|
},
|
|
|
|
showInputDeviceHeader: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: false,
|
|
|
|
description: "Show header above input device slider"
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
renderVoiceSettings() { return <VoiceSettings />; },
|
|
|
|
patches: [
|
|
|
|
{
|
|
|
|
find: "this.renderChannelButtons()",
|
|
|
|
replacement: {
|
|
|
|
match: /this.renderChannelButtons\(\)/,
|
|
|
|
replace: "this.renderChannelButtons(), $self.renderVoiceSettings()"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|