From 3c4d21731255016c6faebac6271ac67cfc7bbfb9 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 18 Jul 2024 00:53:55 -0400 Subject: [PATCH] Stuff --- src/equicordplugins/amITyping/index.ts | 24 + .../betterBanReasons/index.tsx | 100 ++++ .../betterBanReasons/style.css | 11 + .../components/MicrophoneSettingsModal.tsx | 331 +++++++++++++ .../components/index.tsx | 19 + .../constants/constants.ts | 31 ++ .../constants/index.ts | 19 + .../betterMicrophone.desktop/index.tsx | 63 +++ .../betterMicrophone.desktop/logger/index.ts | 23 + .../betterMicrophone.desktop/modals/index.tsx | 43 ++ .../patchers/index.ts | 19 + .../patchers/microphone.ts | 72 +++ .../betterMicrophone.desktop/stores/index.ts | 19 + .../stores/microphoneStore.ts | 94 ++++ .../components/AudioSourceSelect.tsx | 62 +++ .../OpenScreenshareSettingsButton.tsx | 38 ++ .../components/ScreenshareSettingsModal.tsx | 467 ++++++++++++++++++ .../components/index.tsx | 21 + .../constants/constants.ts | 38 ++ .../betterScreenshare.dev/constants/index.ts | 19 + .../betterScreenshare.dev/index.tsx | 71 +++ .../betterScreenshare.dev/logger/index.ts | 23 + .../betterScreenshare.dev/modals/index.tsx | 55 +++ .../betterScreenshare.dev/patchers/index.ts | 20 + .../patchers/screenshare.ts | 99 ++++ .../patchers/screenshareAudio.ts | 85 ++++ .../betterScreenshare.dev/patches/index.ts | 19 + .../patches/screenshareModal.tsx | 98 ++++ .../betterScreenshare.dev/stores/index.ts | 20 + .../stores/screenshareAudioStore.ts | 41 ++ .../stores/screenshareStore.ts | 122 +++++ .../commandPalette/commands.tsx | 195 ++++++++ .../components/CommandPalette.tsx | 130 +++++ .../components/MultipleChoice.tsx | 144 ++++++ .../commandPalette/components/TextInput.tsx | 63 +++ .../commandPalette/components/style.css | 112 +++++ src/equicordplugins/commandPalette/index.tsx | 144 ++++++ .../DependencyModal.tsx | 114 +++++ .../mediaDownloader.desktop/index.tsx | 333 +++++++++++++ .../mediaDownloader.desktop/native.ts | 300 +++++++++++ .../mediaDownloader.desktop/style.css | 9 + src/equicordplugins/noNitroUpsell/index.ts | 44 +- .../components/AuthorSummaryItem.tsx | 57 +++ .../components/ContributorAuthorSummary.tsx | 53 ++ .../components/buttons/CopyButton.tsx | 37 ++ .../components/buttons/DeleteButton.tsx | 39 ++ .../components/buttons/IconTooltipButton.tsx | 44 ++ .../components/buttons/NewButton.tsx | 37 ++ .../components/buttons/SaveButton.tsx | 38 ++ .../components/buttons/index.tsx | 23 + .../philsPluginLibrary/components/index.tsx | 23 + .../settingsModal/SettingsModal.tsx | 77 +++ .../settingsModal/SettingsModalCard.tsx | 83 ++++ .../settingsModal/SettingsModalCardItem.tsx | 39 ++ .../settingsModal/SettingsModalCardRow.tsx | 31 ++ .../SettingsModalProfilesCard.tsx | 113 +++++ .../components/settingsModal/index.tsx | 23 + .../settingsPanel/SettingsPanel.tsx | 35 ++ .../settingsPanel/SettingsPanelButton.tsx | 40 ++ .../settingsPanel/SettingsPanelRow.tsx | 37 ++ .../SettingsPanelTooltipButton.tsx | 34 ++ .../components/settingsPanel/index.tsx | 22 + .../philsPluginLibrary/constants/constants.ts | 30 ++ .../philsPluginLibrary/constants/index.ts | 19 + .../discordModules/classes.ts | 25 + .../discordModules/components.tsx | 24 + .../discordModules/index.ts | 22 + .../discordModules/modules.ts | 25 + .../discordModules/stores.ts | 25 + .../philsPluginLibrary/emitter/emitter.ts | 86 ++++ .../philsPluginLibrary/emitter/index.ts | 19 + .../philsPluginLibrary/icons/index.tsx | 142 ++++++ .../philsPluginLibrary/index.tsx | 50 ++ .../philsPluginLibrary/patchers/index.ts | 19 + .../philsPluginLibrary/patchers/patcher.ts | 29 ++ .../philsPluginLibrary/patches/audio.ts | 88 ++++ .../philsPluginLibrary/patches/index.ts | 21 + .../philsPluginLibrary/patches/userPanel.tsx | 107 ++++ .../philsPluginLibrary/patches/video.ts | 253 ++++++++++ .../philsPluginLibrary/store/index.ts | 20 + .../philsPluginLibrary/store/profileable.ts | 85 ++++ .../philsPluginLibrary/store/store.ts | 102 ++++ .../philsPluginLibrary/styles/index.ts | 19 + .../philsPluginLibrary/styles/styles.ts | 25 + .../philsPluginLibrary/types/common/index.ts | 46 ++ .../types/constants/index.ts | 31 ++ .../types/discordModules/classes/index.ts | 19 + .../discordModules/classes/panelClasses.ts | 53 ++ .../types/discordModules/components/index.ts | 19 + .../components/userSummaryItem.ts | 35 ++ .../types/discordModules/index.ts | 22 + .../types/discordModules/modules/conn.ts | 56 +++ .../discordModules/modules/connection.ts | 387 +++++++++++++++ .../modules/framerateReducer.ts | 36 ++ .../types/discordModules/modules/index.ts | 24 + .../discordModules/modules/mediaEngine.ts | 148 ++++++ .../types/discordModules/modules/utils.ts | 103 ++++ .../modules/videoQualityManager.ts | 81 +++ .../types/discordModules/stores/index.ts | 19 + .../discordModules/stores/mediaEngineStore.ts | 119 +++++ .../philsPluginLibrary/types/index.ts | 21 + .../philsPluginLibrary/utils/index.ts | 19 + .../philsPluginLibrary/utils/utils.ts | 27 + .../showBadgesInChat/index.tsx | 12 +- src/plugins/fakeNitro/index.tsx | 3 +- src/plugins/superReactionTweaks/README.md | 11 - src/plugins/superReactionTweaks/index.ts | 3 +- src/utils/constants.ts | 4 + 108 files changed, 7134 insertions(+), 38 deletions(-) create mode 100644 src/equicordplugins/amITyping/index.ts create mode 100644 src/equicordplugins/betterBanReasons/index.tsx create mode 100644 src/equicordplugins/betterBanReasons/style.css create mode 100644 src/equicordplugins/betterMicrophone.desktop/components/MicrophoneSettingsModal.tsx create mode 100644 src/equicordplugins/betterMicrophone.desktop/components/index.tsx create mode 100644 src/equicordplugins/betterMicrophone.desktop/constants/constants.ts create mode 100644 src/equicordplugins/betterMicrophone.desktop/constants/index.ts create mode 100644 src/equicordplugins/betterMicrophone.desktop/index.tsx create mode 100644 src/equicordplugins/betterMicrophone.desktop/logger/index.ts create mode 100644 src/equicordplugins/betterMicrophone.desktop/modals/index.tsx create mode 100644 src/equicordplugins/betterMicrophone.desktop/patchers/index.ts create mode 100644 src/equicordplugins/betterMicrophone.desktop/patchers/microphone.ts create mode 100644 src/equicordplugins/betterMicrophone.desktop/stores/index.ts create mode 100644 src/equicordplugins/betterMicrophone.desktop/stores/microphoneStore.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/components/AudioSourceSelect.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/components/OpenScreenshareSettingsButton.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/components/ScreenshareSettingsModal.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/components/index.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/constants/constants.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/constants/index.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/index.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/logger/index.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/modals/index.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/patchers/index.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/patchers/screenshare.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/patchers/screenshareAudio.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/patches/index.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/patches/screenshareModal.tsx create mode 100644 src/equicordplugins/betterScreenshare.dev/stores/index.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/stores/screenshareAudioStore.ts create mode 100644 src/equicordplugins/betterScreenshare.dev/stores/screenshareStore.ts create mode 100644 src/equicordplugins/commandPalette/commands.tsx create mode 100644 src/equicordplugins/commandPalette/components/CommandPalette.tsx create mode 100644 src/equicordplugins/commandPalette/components/MultipleChoice.tsx create mode 100644 src/equicordplugins/commandPalette/components/TextInput.tsx create mode 100644 src/equicordplugins/commandPalette/components/style.css create mode 100644 src/equicordplugins/commandPalette/index.tsx create mode 100644 src/equicordplugins/mediaDownloader.desktop/DependencyModal.tsx create mode 100644 src/equicordplugins/mediaDownloader.desktop/index.tsx create mode 100644 src/equicordplugins/mediaDownloader.desktop/native.ts create mode 100644 src/equicordplugins/mediaDownloader.desktop/style.css create mode 100644 src/equicordplugins/philsPluginLibrary/components/AuthorSummaryItem.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/ContributorAuthorSummary.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/buttons/CopyButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/buttons/DeleteButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/buttons/IconTooltipButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/buttons/NewButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/buttons/SaveButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/buttons/index.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/index.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsModal/SettingsModal.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsModal/SettingsModalCard.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsModal/SettingsModalCardItem.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsModal/SettingsModalCardRow.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsModal/SettingsModalProfilesCard.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsModal/index.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsPanel/SettingsPanel.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsPanel/SettingsPanelButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsPanel/SettingsPanelRow.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsPanel/SettingsPanelTooltipButton.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/components/settingsPanel/index.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/constants/constants.ts create mode 100644 src/equicordplugins/philsPluginLibrary/constants/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/discordModules/classes.ts create mode 100644 src/equicordplugins/philsPluginLibrary/discordModules/components.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/discordModules/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/discordModules/modules.ts create mode 100644 src/equicordplugins/philsPluginLibrary/discordModules/stores.ts create mode 100644 src/equicordplugins/philsPluginLibrary/emitter/emitter.ts create mode 100644 src/equicordplugins/philsPluginLibrary/emitter/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/icons/index.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/index.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/patchers/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/patchers/patcher.ts create mode 100644 src/equicordplugins/philsPluginLibrary/patches/audio.ts create mode 100644 src/equicordplugins/philsPluginLibrary/patches/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/patches/userPanel.tsx create mode 100644 src/equicordplugins/philsPluginLibrary/patches/video.ts create mode 100644 src/equicordplugins/philsPluginLibrary/store/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/store/profileable.ts create mode 100644 src/equicordplugins/philsPluginLibrary/store/store.ts create mode 100644 src/equicordplugins/philsPluginLibrary/styles/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/styles/styles.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/common/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/constants/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/classes/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/classes/panelClasses.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/components/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/components/userSummaryItem.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/conn.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/connection.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/framerateReducer.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/mediaEngine.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/utils.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/modules/videoQualityManager.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/stores/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/discordModules/stores/mediaEngineStore.ts create mode 100644 src/equicordplugins/philsPluginLibrary/types/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/utils/index.ts create mode 100644 src/equicordplugins/philsPluginLibrary/utils/utils.ts delete mode 100644 src/plugins/superReactionTweaks/README.md diff --git a/src/equicordplugins/amITyping/index.ts b/src/equicordplugins/amITyping/index.ts new file mode 100644 index 00000000..7b61c102 --- /dev/null +++ b/src/equicordplugins/amITyping/index.ts @@ -0,0 +1,24 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "AmITyping", + description: "Shows you if other people can see you typing.", + authors: [EquicordDevs.MrDiamond], + + patches: [ + { + find: "\"handleDismissInviteEducation\"", + replacement: { + match: /\i\.default\.getCurrentUser\(\)/, + replace: "\"\"" + } + } + ] +}); diff --git a/src/equicordplugins/betterBanReasons/index.tsx b/src/equicordplugins/betterBanReasons/index.tsx new file mode 100644 index 00000000..853cd1b0 --- /dev/null +++ b/src/equicordplugins/betterBanReasons/index.tsx @@ -0,0 +1,100 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./style.css"; + +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Button, Forms, i18n, TextInput } from "@webpack/common"; + +function ReasonsComponent() { + const { reasons } = settings.use(["reasons"]); + + return ( + + {reasons.map((reason: string, index: number) => ( +
+ { + reasons[index] = v; + settings.store.reasons = [...reasons]; + }} + placeholder="Reason" + /> + +
+ ))} + +
+ ); +} + +const settings = definePluginSettings({ + reasons: { + description: "Your custom reasons", + type: OptionType.COMPONENT, + default: [], + component: ReasonsComponent, + }, + textInputDefault: { + type: OptionType.BOOLEAN, + description: 'Shows a text input instead of a select menu by default. (Equivalent to clicking the "Other" option)' + } +}); + +export default definePlugin({ + name: "BetterBanReasons", + description: "Create custom reasons to use in the Discord ban modal, and/or show a text input by default instead of the options.", + authors: [Devs.Inbestigator], + patches: [ + { + find: "Messages.BAN_MULTIPLE_CONFIRM_TITLE", + replacement: [{ + match: /\[\{name:\i\.\i\.Messages\.BAN_REASON_OPTION_SPAM_ACCOUNT.+?\}\]/, + replace: "$self.getReasons()" + }, + { + match: /useState\(0\)(?=.{0,100}targetUserId:)/, + replace: "useState($self.getDefaultState())" + }] + } + ], + getReasons() { + const reasons = settings.store.reasons.length + ? settings.store.reasons + : [ + i18n.Messages.BAN_REASON_OPTION_SPAM_ACCOUNT, + i18n.Messages.BAN_REASON_OPTION_HACKED_ACCOUNT, + i18n.Messages.BAN_REASON_OPTION_BREAKING_RULES + ]; + return reasons.map(s => ({ name: s, value: s })); + }, + getDefaultState() { + return settings.store.textInputDefault ? 1 : 0; + }, + settings, +}); diff --git a/src/equicordplugins/betterBanReasons/style.css b/src/equicordplugins/betterBanReasons/style.css new file mode 100644 index 00000000..02fb4bbf --- /dev/null +++ b/src/equicordplugins/betterBanReasons/style.css @@ -0,0 +1,11 @@ +.vc-bbr-reason-wrapper { + display: grid; + padding: 0; + padding-bottom: 0.5rem; + gap: 0.5rem; + grid-template-columns: 6fr 1fr; +} + +.vc-bbr-remove-button { + height: 100%; +} diff --git a/src/equicordplugins/betterMicrophone.desktop/components/MicrophoneSettingsModal.tsx b/src/equicordplugins/betterMicrophone.desktop/components/MicrophoneSettingsModal.tsx new file mode 100644 index 00000000..b031fc0d --- /dev/null +++ b/src/equicordplugins/betterMicrophone.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"; +import { Styles } from "../../philsPluginLibrary/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) + }}> + + ({ + label: name, + value: id + }))} + isSelected={value => audioSource === value} + select={value => setAudioSource(value)} + serialize={() => ""} + {...props} + > + ); +}; diff --git a/src/equicordplugins/betterScreenshare.dev/components/OpenScreenshareSettingsButton.tsx b/src/equicordplugins/betterScreenshare.dev/components/OpenScreenshareSettingsButton.tsx new file mode 100644 index 00000000..d12493a9 --- /dev/null +++ b/src/equicordplugins/betterScreenshare.dev/components/OpenScreenshareSettingsButton.tsx @@ -0,0 +1,38 @@ +/* + * 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 { Button } from "@webpack/common"; +import React from "react"; + +import { openScreenshareModal } from "../modals"; + +export interface OpenScreenshareSettingsButtonProps { + title?: string; +} + +export const OpenScreenshareSettingsButton = (props: OpenScreenshareSettingsButtonProps) => { + return ( + + ); +}; diff --git a/src/equicordplugins/betterScreenshare.dev/components/ScreenshareSettingsModal.tsx b/src/equicordplugins/betterScreenshare.dev/components/ScreenshareSettingsModal.tsx new file mode 100644 index 00000000..ac529445 --- /dev/null +++ b/src/equicordplugins/betterScreenshare.dev/components/ScreenshareSettingsModal.tsx @@ -0,0 +1,467 @@ +/* + * 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, openModalLazy } from "@utils/modal"; +import { Button, Card, Forms, React, Select, Slider, TextInput, useEffect, useState } from "@webpack/common"; +import { SelectOption } from "@webpack/types"; + +import { MicrophoneSettingsModal } from "../../betterMicrophone.desktop/components"; +import { + MediaEngineStore, + openURL, + ProfilableStore, + SettingsModal, + SettingsModalCard, + SettingsModalCardItem, + SettingsModalCardRow, + SettingsModalProfilesCard, + types, + validateNumberInput, + validateTextInputNumber +} from "../../philsPluginLibrary"; +import { Styles } from "../../philsPluginLibrary/styles"; +import { PluginInfo } from "../constants"; +import { ScreenshareAudioProfile, ScreenshareAudioStore, ScreenshareProfile, ScreenshareStore } from "../stores"; + +const simpleResolutions: readonly (SelectOption & { value: types.Resolution; })[] = [ + { + label: "480p", + value: { + height: 480, + width: 720 + } + }, + { + label: "720p", + value: { + height: 720, + width: 1280 + } + }, + { + label: "1080p", + value: { + height: 1080, + width: 1920 + } + }, + { + label: "1440p", + value: { + height: 1440, + width: 2560 + } + }, + { + label: "2160p", + value: { + height: 2160, + width: 3840 + } + } +] as const; + +const simpleVideoBitrates: readonly SelectOption[] = [ + { + label: "Low", + value: 2500 + }, + { + label: "Medium", + value: 5000 + }, + { + label: "Medium-High", + value: 7500 + }, + { + label: "High", + value: 10000 + } +] as const; + +export interface ScreenshareSettingsModalProps extends React.ComponentProps { + screenshareStore: ProfilableStore; + screenshareAudioStore?: ProfilableStore; + onAudioDone?: () => void; +} + +export const ScreenshareSettingsModal = (props: ScreenshareSettingsModalProps) => { + const { screenshareStore, screenshareAudioStore, onAudioDone } = props; + + const { + currentProfile, + profiles, + simpleMode, + setVideoBitrateEnabled, + setVideoCodec, + setVideoCodecEnabled, + setFramerate, + setFramerateEnabled, + setHeight, + setKeyframeInterval, + setKeyframeIntervalEnabled, + setResolutionEnabled, + setVideoBitrate, + setWidth, + setCurrentProfile, + getProfile, + saveProfile, + setHdrEnabled, + setSimpleMode, + deleteProfile, + duplicateProfile, + getCurrentProfile, + getProfiles + } = screenshareStore.use(); + + + const { + name, + framerate, + framerateEnabled, + height, + keyframeInterval, + keyframeIntervalEnabled, + resolutionEnabled, + videoBitrate, + videoBitrateEnabled, + videoCodec, + videoCodecEnabled, + width, + hdrEnabled + } = currentProfile; + + const [videoCodecs, setVideoCodecs] = useState([]); + + const [isSaving, setIsSaving] = useState(false); + + const [textinputWidth, setTextinputWidth] = useState(width ? width.toString() : ""); + const [textinputHeight, setTextinputHeight] = useState(height ? height.toString() : ""); + const [textinputFramerate, setTextinputFramerate] = useState(framerate ? framerate.toString() : ""); + const [textinputKeyframeInterval, setTextinputKeyframeInterval] = useState(keyframeInterval ? keyframeInterval.toString() : ""); + + useEffect(() => { + setTextinputWidth(width ? width.toString() : ""); + setTextinputHeight(height ? height.toString() : ""); + setTextinputFramerate(framerate ? framerate.toString() : ""); + setTextinputKeyframeInterval(keyframeInterval ? keyframeInterval.toString() : ""); + }, [width, height, framerate, keyframeInterval]); + + useEffect(() => { + (async () => { + const mediaEngine = MediaEngineStore.getMediaEngine(); + + const stringifiedCodecs: types.CodecCapabilities[] = JSON.parse( + await new Promise(res => mediaEngine.getCodecCapabilities(res)) + ); + + setVideoCodecs(stringifiedCodecs); + })(); + }, []); + + const settingsCardResolutionSimple = + setResolutionEnabled(status) + }}> + + void setVideoBitrate(value)} + isSelected={(value: number) => videoBitrate === value} + serialize={() => ""} /> + + ; + + const settingsCardResolution = + setResolutionEnabled(status), + disabled: isSaving + }}> + + validateTextInputNumber(value) && setTextinputWidth(value)} + onBlur={e => { + const result = validateNumberInput(e.target.value); + setWidth(result); + setTextinputWidth(result ? result.toString() : ""); + }} /> + + + validateTextInputNumber(value) && setTextinputHeight(value)} + onBlur={e => { + const result = validateNumberInput(e.target.value); + setHeight(result); + setTextinputHeight(result ? result.toString() : ""); + }} /> + + ; + + const settingsCardItemFramerate = + + validateTextInputNumber(value) && setTextinputFramerate(value)} + onBlur={e => { + const result = validateNumberInput(e.target.value); + setFramerate(result); + setTextinputFramerate(result ? result.toString() : ""); + }} /> + ; + + const settingsCardFramerateProps: React.ComponentProps = { + title: "Framerate", + switchEnabled: true, + switchProps: { + checked: framerateEnabled ?? false, + disabled: isSaving, + onChange: status => setFramerateEnabled(status) + } + }; + + const settingsCardFramerate = + + {settingsCardItemFramerate} + ; + + const settingsCardFramerateSimple = + + {settingsCardItemFramerate} + ; + + const settingsCardKeyframeInterval = + setKeyframeIntervalEnabled(status) + }}> + + validateTextInputNumber(value) && setTextinputKeyframeInterval(value)} + onBlur={e => { + const result = validateNumberInput(e.target.value); + setKeyframeInterval(result); + setTextinputKeyframeInterval(result ? result.toString() : ""); + }} /> + + ; + + const settingsCardVideoBitrate = + setVideoBitrateEnabled(status) + }}> + +
+ setVideoBitrate(value)} + initialValue={videoBitrate || 500} + minValue={500} + maxValue={10000} + markers={[500, 10000]} + onValueRender={value => `${value.toFixed(0)}kb/s`} /> +
+
+
; + + const settingsCardAudioProps: React.ComponentProps = { + title: "Audio Settings" + }; + + const settingsCardItemAudio = + +