Compare commits

...

32 commits

Author SHA1 Message Date
sadan4
79f1e38c8a
Merge 8c6104305b into 6cce8a8bc4 2024-09-17 17:19:11 -04:00
Nuckyz
6cce8a8bc4
Experiments: Allow clips to be recorded without streaming
Some checks failed
Sync to Codeberg / codeberg (push) Has been cancelled
test / test (push) Has been cancelled
2024-09-17 14:30:23 -03:00
Nuckyz
1848b16536
ReviewDB: Fix in panel profile 2024-09-17 14:30:23 -03:00
Kyuuhachi
c572116b97
BetterSettings: Add submenu for plugins (#2858)
Co-authored-by: Vendicated <vendicated@riseup.net>
2024-09-17 15:40:11 +00:00
Lumap
e26986f66a
AppleMusicRichPresence: fix formatting when listening to radio (#2869)
Co-authored-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Co-authored-by: v <vendicated@riseup.net>
2024-09-17 17:29:46 +02:00
sadan4
8c6104305b
Discard changes to src/utils/constants.ts 2024-09-14 15:16:27 -04:00
sadan4
50ce282284
Merge branch 'dev' into customFolderIcons 2024-09-14 15:16:10 -04:00
sadan4
2272e1dfaa
Merge branch 'dev' into customFolderIcons 2024-09-02 01:10:02 -04:00
sadan4
bcb0c4100f
Merge branch 'main' into customFolderIcons 2024-08-05 17:12:47 -04:00
sadan4
8a0b8b60b5
Merge branch 'main' into customFolderIcons 2024-07-30 23:13:40 -04:00
sadan
7eeeceea1c
rename and add setting 2024-07-29 23:37:53 -04:00
sadan4
073b561db1
Merge branch 'main' into customFolderIcons 2024-07-29 23:23:52 -04:00
sadan4
487bb264c8
Merge branch 'main' into customFolderIcons 2024-07-17 01:58:52 -04:00
sadan
543d1de570
inline var 2024-07-02 16:01:05 -04:00
sadan4
7cf5fab128
Update README.md 2024-07-02 11:07:12 -04:00
sadan4
eb2ef2298b
remove newline
Co-authored-by: Scyye <97131358+Scyye@users.noreply.github.com>
2024-07-02 10:55:45 -04:00
sadan
f5dffe12c2
fix imports 2024-07-01 23:55:07 -04:00
sadan4
240ce8b07f
Update plugin readme and add images 2024-06-30 00:07:47 -04:00
sadan4
ab7cf5dfa9
Merge branch 'main' into customFolderIcons 2024-06-30 00:02:25 -04:00
sadan
3b969e55ef
bunch of stuff
- fix preview
- fix settings
- update headers
- add readme
2024-06-29 23:56:51 -04:00
sadan
a742cc2b53
complete settings overhaul, still needs work. see FIXME: 2024-06-29 03:04:30 -04:00
sadan
f4ca72c6f6
add settings 2024-06-29 01:46:00 -04:00
sadan4
d9e8a86688
Merge branch 'main' into customFolderIcons 2024-06-29 01:45:33 -04:00
sadan4
253bfa1ea2
Merge branch 'main' into customFolderIcons 2024-06-27 00:45:29 -04:00
sadan
5a96c0bb54
Merge branch 'main' into customFolderIcons 2024-06-19 15:37:59 -04:00
sadan
915e14ddab
add things
- add size slider
- add preview when setting
2024-06-17 13:53:04 -04:00
sadan
a7a461309d
fix bug 2024-06-07 01:20:41 -04:00
sadan
3bcbe7e386
rename vars, minor changes 2024-06-06 22:40:44 -04:00
sadan
89c2cd2108
fix error handling 2024-06-06 22:04:22 -04:00
sadan
ffaca84aa5
guh 2024-06-06 22:00:50 -04:00
sadan
25b9898c09
fix *some* horrorcode 2024-06-06 21:58:13 -04:00
sadan
833010fa52
initial commit 2024-06-05 21:46:03 -04:00
12 changed files with 375 additions and 25 deletions

View file

@ -24,7 +24,7 @@ interface ActivityButton {
}
interface Activity {
state: string;
state?: string;
details?: string;
timestamps?: {
start?: number;
@ -52,8 +52,8 @@ const enum ActivityFlag {
export interface TrackData {
name: string;
album: string;
artist: string;
album?: string;
artist?: string;
appleMusicLink?: string;
songLink?: string;
@ -61,8 +61,8 @@ export interface TrackData {
albumArtwork?: string;
artistArtwork?: string;
playerPosition: number;
duration: number;
playerPosition?: number;
duration?: number;
}
const enum AssetImageType {
@ -155,8 +155,8 @@ const settings = definePluginSettings({
function customFormat(formatStr: string, data: TrackData) {
return formatStr
.replaceAll("{name}", data.name)
.replaceAll("{album}", data.album)
.replaceAll("{artist}", data.artist);
.replaceAll("{album}", data.album ?? "")
.replaceAll("{artist}", data.artist ?? "");
}
function getImageAsset(type: AssetImageType, data: TrackData) {
@ -212,14 +212,16 @@ export default definePlugin({
const assets: ActivityAssets = {};
const isRadio = Number.isNaN(trackData.duration) && (trackData.playerPosition === 0);
if (settings.store.largeImageType !== AssetImageType.Disabled) {
assets.large_image = largeImageAsset;
assets.large_text = customFormat(settings.store.largeTextString, trackData);
if (!isRadio) assets.large_text = customFormat(settings.store.largeTextString, trackData);
}
if (settings.store.smallImageType !== AssetImageType.Disabled) {
assets.small_image = smallImageAsset;
assets.small_text = customFormat(settings.store.smallTextString, trackData);
if (!isRadio) assets.small_text = customFormat(settings.store.smallTextString, trackData);
}
const buttons: ActivityButton[] = [];
@ -243,17 +245,17 @@ export default definePlugin({
name: customFormat(settings.store.nameString, trackData),
details: customFormat(settings.store.detailsString, trackData),
state: customFormat(settings.store.stateString, trackData),
state: isRadio ? undefined : customFormat(settings.store.stateString, trackData),
timestamps: (settings.store.enableTimestamps ? {
timestamps: (trackData.playerPosition && trackData.duration && settings.store.enableTimestamps) ? {
start: Date.now() - (trackData.playerPosition * 1000),
end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000),
} : undefined),
} : undefined,
assets,
buttons: buttons.length ? buttons.map(v => v.label) : undefined,
metadata: { button_urls: buttons.map(v => v.url) || undefined, },
buttons: !isRadio && buttons.length ? buttons.map(v => v.label) : undefined,
metadata: !isRadio && buttons.length ? { button_urls: buttons.map(v => v.url) } : undefined,
type: settings.store.activityType,
flags: ActivityFlag.INSTANCE,

View file

@ -0,0 +1,68 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { openPluginModal } from "@components/PluginSettings/PluginModal";
import { isObjectEmpty } from "@utils/misc";
import { Alerts, i18n, Menu, useMemo, useState } from "@webpack/common";
import Plugins from "~plugins";
function onRestartNeeded() {
Alerts.show({
title: "Restart required",
body: <p>You have changed settings that require a restart.</p>,
confirmText: "Restart now",
cancelText: "Later!",
onConfirm: () => location.reload()
});
}
export default function PluginsSubmenu() {
const sortedPlugins = useMemo(() => Object.values(Plugins)
.sort((a, b) => a.name.localeCompare(b.name)), []);
const [query, setQuery] = useState("");
const search = query.toLowerCase();
const include = (p: typeof Plugins[keyof typeof Plugins]) => (
Vencord.Plugins.isPluginEnabled(p.name)
&& p.options && !isObjectEmpty(p.options)
&& (
p.name.toLowerCase().includes(search)
|| p.description.toLowerCase().includes(search)
|| p.tags?.some(t => t.toLowerCase().includes(search))
)
);
const plugins = sortedPlugins.filter(include);
return (
<>
<Menu.MenuControlItem
id="vc-plugins-search"
control={(props, ref) => (
<Menu.MenuSearchControl
{...props}
query={query}
onChange={setQuery}
ref={ref}
placeholder={i18n.Messages.SEARCH}
/>
)}
/>
{!!plugins.length && <Menu.MenuSeparator />}
{plugins.map(p => (
<Menu.MenuItem
key={p.name}
id={p.name}
label={p.name}
action={() => openPluginModal(p, onRestartNeeded)}
/>
))}
</>
);
}

View file

@ -13,6 +13,8 @@ import { waitFor } from "@webpack";
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
import type { HTMLAttributes, ReactElement } from "react";
import PluginsSubmenu from "./PluginsSubmenu";
type SettingsEntry = { section: string, label: string; };
const cl = classNameFactory("");
@ -118,13 +120,21 @@ export default definePlugin({
},
{ // Settings cog context menu
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
replacement: {
match: /(EXPERIMENTS:.+?)(\(0,\i.\i\)\(\))(?=\.filter\(\i=>\{let\{section:\i\}=)/,
replace: "$1$self.wrapMenu($2)"
}
}
replacement: [
{
match: /(EXPERIMENTS:.+?)(\(0,\i.\i\)\(\))(?=\.filter\(\i=>\{let\{section:\i\}=)/,
replace: "$1$self.wrapMenu($2)"
},
{
match: /case \i\.\i\.DEVELOPER_OPTIONS:return \i;/,
replace: "$&case 'VencordPlugins':return $self.PluginsSubmenu();"
}
]
},
],
PluginsSubmenu,
// This is the very outer layer of the entire ui, so we can't wrap this in an ErrorBoundary
// without possibly also catching unrelated errors of children.
//

View file

@ -126,7 +126,7 @@ export default definePlugin({
}
},
{
find: '"Handling ping: "',
find: '"_handleLocalVideoDisabled: ',
predicate: () => settings.store.disableNoisyLoggers,
replacement: {
match: /new \i\.\i\("RTCConnection\("\.concat.+?\)\)(?=,)/,

View file

@ -0,0 +1,14 @@
# CustomFolderIcons
Allows you to set custom images/svgs as folder icons
Available as "Change Icon" in the folder context menu
![the context menu with the "Change Icon" button](https://github.com/sadan4/Vencord/assets/117494111/3dfb843c-6964-4ac3-a0b9-8772569953d3)
![an image of some example custom folder icons](https://github.com/sadan4/Vencord/assets/117494111/c5324ab1-3b7a-4286-8cb5-41c0ceb2ea44)
![the modal used to customize the folder icons](https://github.com/sadan4/Vencord/assets/117494111/1426d350-56db-4687-8052-6c1b1ce873a1)

View file

@ -0,0 +1,124 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 sadan
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { closeModal, ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
import { Button, Menu, Slider, TextInput, useState } from "@webpack/common";
import settings, { folderIconsData } from "./settings";
import { folderProp, int2rgba, setFolderData } from "./util";
export function ImageModal(folderProps: folderProp) {
const [data, setData] = useState(((settings.store.folderIcons ?? {}) as folderIconsData)[folderProps.folderId]?.url ?? "");
const [size, setSize] = useState(100);
return (
<>
<TextInput
// this looks like a horrorshow
defaultValue={data}
onChange={(val, _n) => {
setData(val);
}}
placeholder="https://example.com/image.png"
>
</TextInput>
<RenderPreview folderProps={folderProps} url={data} size={size} />
{data && <>
<div style={{
color: "#FFF"
}}>Change the size of the folder icon</div>
<Slider
initialValue={100}
onValueChange={(v: number) => {
setSize(v);
}}
maxValue={200}
minValue={25}
// [25, 200]
markers={Array.apply(0, Array(176)).map((_, i) => i + 25)}
stickToMarkers={true}
keyboardStep={1}
renderMarker={() => null} />
</>}
<Button onClick={() => {
setFolderData(folderProps, {
url: data,
size: size
});
closeModal("custom-folder-icon");
}}
>
Save
</Button>
<hr />
<Button onClick={() => {
// INFO: unset button
const folderSettings = settings.store.folderIcons as folderIconsData;
if (folderSettings[folderProps.folderId]) {
folderSettings[folderProps.folderId] = null;
}
closeModal("custom-folder-icon");
}}>
Unset
</Button>
<hr />
</>
);
}
export function RenderPreview({ folderProps, url, size }: { folderProps: folderProp; url: string; size: number; }) {
if (!url) return null;
return (
<div className="test1234" style={{
width: "20vh",
height: "20vh",
overflow: "hidden",
// 16/48
borderRadius: "33%",
backgroundColor: int2rgba(folderProps.folderColor, 0.4),
display: "flex",
justifyContent: "center",
alignItems: "center"
}}>
<img src={url} width={`${size}%`} height={`${size}%`} />
</div>
);
}
export function makeContextItem(a: folderProp) {
return (
<Menu.MenuItem
id="custom-folder-icons"
key="custom-folder-icons"
label="Change Icon"
action={() => {
openModalLazy(async () => {
return props => (
<ModalRoot {...props}>
<ModalHeader >
<div style={{
color: "white"
}}>
Set a New Icon.
</div>
</ModalHeader>
<ModalContent>
<ImageModal folderId={a.folderId} folderColor={a.folderColor}/>
</ModalContent>
<div style={{
color: "white",
margin: "2.5%",
marginTop: "1%"
}}>
You might have to hover the folder after setting in order for it to refresh.
</div>
</ModalRoot>
);
},
{
modalKey: "custom-folder-icon"
});
}}/>
);
}

View file

@ -0,0 +1,60 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 sadan
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { makeContextItem } from "./components";
import settings, { folderIconsData } from "./settings";
import { folderProp, int2rgba } from "./util";
export default definePlugin({
settings,
name: "CustomFolderIcons",
description: "Customize folder icons with any png",
authors: [
Devs.sadan
],
patches: [
{
find: ".expandedFolderIconWrapper",
replacement: {
match: /(return.{0,80}expandedFolderIconWrapper.*,)(\(0,..jsxs\)\(.*]}\))/,
replace: "$1$self.shouldReplace(arguments[0])?$self.replace(arguments[0]):$2"
}
}
],
contextMenus: {
"guild-context": (menuItems, props: folderProp) => {
if(!("folderId" in props)) return;
menuItems.push(makeContextItem(props));
}
},
shouldReplace(props: any): boolean{
return !!((settings.store.folderIcons as folderIconsData)?.[props.folderNode.id]?.url);
},
replace(props: any){
const folderSettings = (settings.store.folderIcons as folderIconsData);
if(folderSettings && folderSettings[props.folderNode.id]){
const data = folderSettings[props.folderNode.id];
return (
<div
style={{
backgroundColor: int2rgba(props.folderNode.color, +settings.store.solidIcon || .4),
display: "flex",
justifyContent: "center",
alignItems: "center",
width: "100%",
height: "100%"
}}
>
<img src={data!.url} width={`${data!.size ?? 100}%`} height={`${data!.size ?? 100}%`}
/>
</div>
);
}
}
});

View file

@ -0,0 +1,29 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 sadan
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import { OptionType } from "@utils/types";
export interface folderIcon{
url: string,
size: number,
}
export type folderIconsData = Record<string, folderIcon | null>;
const settings = definePluginSettings({
solidIcon: {
type: OptionType.BOOLEAN,
default: false,
description: "Use a solid background on the background of the image"
},
folderIcons: {
type: OptionType.COMPONENT,
hidden: true,
description: "folder icon settings",
component: () => <></>
}
});
export default settings;

View file

@ -0,0 +1,29 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 sadan
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import settings, { folderIcon, folderIconsData } from "./settings";
export async function setFolderData(props: folderProp, newData: folderIcon) {
if(!settings.store.folderIcons){
settings.store.folderIcons = {};
}
const folderSettings = (settings.store.folderIcons as folderIconsData);
folderSettings[props.folderId] = newData;
}
export interface folderProp {
folderId: string;
folderColor: number;
}
/**
* @param rgbVal RGB value
* @param alpha alpha bewteen zero and 1
*/
export function int2rgba(rgbVal: number, alpha: number = 1) {
const b = rgbVal & 0xFF,
g = (rgbVal & 0xFF00) >>> 8,
r = (rgbVal & 0xFF0000) >>> 16;
return `rgba(${[r, g, b].join(",")},${alpha})`;
}

View file

@ -23,12 +23,13 @@ import { ErrorCard } from "@components/ErrorCard";
import { Devs } from "@utils/constants";
import { Margins } from "@utils/margins";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { findByPropsLazy, findLazy } from "@webpack";
import { Forms, React } from "@webpack/common";
import hideBugReport from "./hideBugReport.css?managed";
const KbdStyles = findByPropsLazy("key", "combo");
const BugReporterExperiment = findLazy(m => m?.definition?.id === "2024-09_bug_reporter");
const settings = definePluginSettings({
toolbarDevMenu: {
@ -78,8 +79,8 @@ export default definePlugin({
{
find: "toolbar:function",
replacement: {
match: /\i\.isStaff\(\)/,
replace: "true"
match: /hasBugReporterAccess:(\i)/,
replace: "_hasBugReporterAccess:$1=true"
},
predicate: () => settings.store.toolbarDevMenu
},
@ -91,10 +92,18 @@ export default definePlugin({
match: /\i\.isDM\(\)\|\|\i\.isThread\(\)/,
replace: "false",
}
},
// enable option to always record clips even if you are not streaming
{
find: "isDecoupledGameClippingEnabled(){",
replacement: {
match: /\i\.isStaff\(\)/,
replace: "true"
}
}
],
start: () => enableStyle(hideBugReport),
start: () => !BugReporterExperiment.getCurrentConfig().hasBugReporterAccess && enableStyle(hideBugReport),
stop: () => disableStyle(hideBugReport),
settingsAboutComponent: () => {

View file

@ -91,7 +91,7 @@ export default definePlugin({
}
},
{
find: ".PANEL,isInteractionSource:",
find: ".PANEL,interactionType:",
replacement: {
match: /{profileType:\i\.\i\.PANEL,children:\[/,
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"

View file

@ -72,6 +72,11 @@ export interface Menu {
onChange(value: number): void,
renderValue?(value: number): string,
}>;
MenuSearchControl: RC<{
query: string
onChange(query: string): void;
placeholder?: string;
}>;
}
export interface ContextMenuApi {