From 61ea729381cce9f1d4cc6032aeecc8fe1e0035f1 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 18 Jul 2024 01:24:03 -0400 Subject: [PATCH] Fixes --- .../components/MicrophoneSettingsModal.tsx | 331 ++++++++++++++++++ .../components/ScreenshareSettingsModal.tsx | 2 +- .../components/index.tsx | 1 + .../betterScreenshare.desktop/stores/index.ts | 1 + .../stores/microphoneStore.ts | 94 +++++ .../stores/screenshareAudioStore.ts | 6 +- .../patches/audio.ts | 2 +- .../patches/index.ts | 2 + .../patches/screenshareAudioStore.ts | 41 +++ .../patches/screenshareStore.ts | 122 +++++++ .../patches/video.ts | 2 +- .../philsPluginLibrary.desktop/store/index.ts | 1 + .../store/microphoneStore.ts | 94 +++++ 13 files changed, 693 insertions(+), 6 deletions(-) create mode 100644 src/equicordplugins/betterScreenshare.desktop/components/MicrophoneSettingsModal.tsx create mode 100644 src/equicordplugins/betterScreenshare.desktop/stores/microphoneStore.ts create mode 100644 src/equicordplugins/philsPluginLibrary.desktop/patches/screenshareAudioStore.ts create mode 100644 src/equicordplugins/philsPluginLibrary.desktop/patches/screenshareStore.ts create mode 100644 src/equicordplugins/philsPluginLibrary.desktop/store/microphoneStore.ts diff --git a/src/equicordplugins/betterScreenshare.desktop/components/MicrophoneSettingsModal.tsx b/src/equicordplugins/betterScreenshare.desktop/components/MicrophoneSettingsModal.tsx new file mode 100644 index 00000000..87bac7b0 --- /dev/null +++ b/src/equicordplugins/betterScreenshare.desktop/components/MicrophoneSettingsModal.tsx @@ -0,0 +1,331 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Flex } from "@components/Flex"; +import { Switch } from "@components/Switch"; +import { ModalSize } from "@utils/modal"; +import { Card, Forms, Select, Slider, TextInput, useEffect, useState } from "@webpack/common"; +import { SelectOption } from "@webpack/types"; + +import { + ProfilableStore, + SettingsModal, + SettingsModalCard, + SettingsModalCardItem, + SettingsModalCardRow, + SettingsModalProfilesCard, + validateNumberInput, + validateTextInputNumber +} from "../../philsPluginLibrary.desktop"; +import { Styles } from "../../philsPluginLibrary.desktop/styles"; +import { MicrophoneProfile, MicrophoneStore } from "../stores"; + +const simpleVoiceBitrates: readonly SelectOption[] = [ + { + label: "Normal", + value: 96 + }, + { + label: "Medium-High", + value: 160 + }, + { + label: "High", + value: 320 + }, + { + label: "Very-High", + value: 512 + } +] as const; + +export interface MicrophoneSettingsModalProps extends React.ComponentProps { + microphoneStore: ProfilableStore; + showInfo?: boolean; +} + +export const MicrophoneSettingsModal = (props: MicrophoneSettingsModalProps) => { + const { microphoneStore, showInfo } = props; + + const { + currentProfile, + simpleMode, + setSimpleMode, + deleteProfile, + duplicateProfile, + getCurrentProfile, + getDefaultProfiles, + getProfile, + getProfiles, + isCurrentProfileADefaultProfile, + profiles, + saveProfile, + setChannels, + setChannelsEnabled, + setCurrentProfile, + setFreq, + setFreqEnabled, + setPacsize, + setPacsizeEnabled, + setRate, + setRateEnabled, + setVoiceBitrate, + setVoiceBitrateEnabled + } = microphoneStore.use(); + + const { + name, + channels, + channelsEnabled, + freq, + freqEnabled, + pacsize, + pacsizeEnabled, + rate, + rateEnabled, + voiceBitrate, + voiceBitrateEnabled + } = currentProfile; + + const [isSaving, setIsSaving] = useState(false); + + const [rateInput, setRateInput] = useState(rate ? rate.toString() : ""); + const [freqInput, setFreqInput] = useState(freq ? freq.toString() : ""); + const [pacsizeInput, setPacsizeInput] = useState(pacsize ? pacsize.toString() : ""); + const [channelsInput, setChannelsInput] = useState(channels ? channels.toString() : ""); + + useEffect(() => { + setRateInput(rate ? rate.toString() : ""); + setFreqInput(freq ? freq.toString() : ""); + setPacsizeInput(pacsize ? pacsize.toString() : ""); + setChannelsInput(channels ? channels.toString() : ""); + }, [rate, freq, pacsize, channels]); + + const simpleToggle = + + Simple + setSimpleMode(checked)} /> + ; + + const settingsCardVoiceBitrateSimple = + setVoiceBitrateEnabled(status) + }}> + +