mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-19 22:20:34 +00:00
Compare commits
29 commits
629098e01c
...
ab98a76589
Author | SHA1 | Date | |
---|---|---|---|
|
ab98a76589 | ||
|
c7e5295da0 | ||
|
8c6104305b | ||
|
50ce282284 | ||
|
2272e1dfaa | ||
|
bcb0c4100f | ||
|
8a0b8b60b5 | ||
|
7eeeceea1c | ||
|
073b561db1 | ||
|
487bb264c8 | ||
|
543d1de570 | ||
|
7cf5fab128 | ||
|
eb2ef2298b | ||
|
f5dffe12c2 | ||
|
240ce8b07f | ||
|
ab7cf5dfa9 | ||
|
3b969e55ef | ||
|
a742cc2b53 | ||
|
f4ca72c6f6 | ||
|
d9e8a86688 | ||
|
253bfa1ea2 | ||
|
5a96c0bb54 | ||
|
915e14ddab | ||
|
a7a461309d | ||
|
3bcbe7e386 | ||
|
89c2cd2108 | ||
|
ffaca84aa5 | ||
|
25b9898c09 | ||
|
833010fa52 |
9 changed files with 343 additions and 81 deletions
14
src/plugins/customFolderIcons/README.md
Normal file
14
src/plugins/customFolderIcons/README.md
Normal 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)
|
||||
|
||||
|
||||
|
124
src/plugins/customFolderIcons/components.tsx
Normal file
124
src/plugins/customFolderIcons/components.tsx
Normal 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"
|
||||
});
|
||||
}}/>
|
||||
);
|
||||
}
|
60
src/plugins/customFolderIcons/index.tsx
Normal file
60
src/plugins/customFolderIcons/index.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
29
src/plugins/customFolderIcons/settings.tsx
Normal file
29
src/plugins/customFolderIcons/settings.tsx
Normal 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;
|
29
src/plugins/customFolderIcons/util.tsx
Normal file
29
src/plugins/customFolderIcons/util.tsx
Normal 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})`;
|
||||
}
|
5
src/plugins/fullSearchContext/README.md
Normal file
5
src/plugins/fullSearchContext/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# FullSearchContext
|
||||
|
||||
Makes the message context menu in message search results have all options you'd expect.
|
||||
|
||||
![](https://github.com/user-attachments/assets/472d1327-3935-44c7-b7c4-0978b5348550)
|
82
src/plugins/fullSearchContext/index.tsx
Normal file
82
src/plugins/fullSearchContext/index.tsx
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migratePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ChannelStore, ContextMenuApi, i18n, UserStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
import type { MouseEvent } from "react";
|
||||
|
||||
const { useMessageMenu } = findByPropsLazy("useMessageMenu");
|
||||
|
||||
function MessageMenu({ message, channel, onHeightUpdate }) {
|
||||
const canReport = message.author &&
|
||||
!(message.author.id === UserStore.getCurrentUser().id || message.author.system);
|
||||
|
||||
return useMessageMenu({
|
||||
navId: "message-actions",
|
||||
ariaLabel: i18n.Messages.MESSAGE_UTILITIES_A11Y_LABEL,
|
||||
|
||||
message,
|
||||
channel,
|
||||
canReport,
|
||||
onHeightUpdate,
|
||||
onClose: () => ContextMenuApi.closeContextMenu(),
|
||||
|
||||
textSelection: "",
|
||||
favoriteableType: null,
|
||||
favoriteableId: null,
|
||||
favoriteableName: null,
|
||||
itemHref: void 0,
|
||||
itemSrc: void 0,
|
||||
itemSafeSrc: void 0,
|
||||
itemTextContent: void 0,
|
||||
});
|
||||
}
|
||||
|
||||
migratePluginSettings("FullSearchContext", "SearchReply");
|
||||
export default definePlugin({
|
||||
name: "FullSearchContext",
|
||||
description: "Makes the message context menu in message search results have all options you'd expect",
|
||||
authors: [Devs.Ven, Devs.Aria],
|
||||
|
||||
patches: [{
|
||||
find: "onClick:this.handleMessageClick,",
|
||||
replacement: {
|
||||
match: /this(?=\.handleContextMenu\(\i,\i\))/,
|
||||
replace: "$self"
|
||||
}
|
||||
}],
|
||||
|
||||
handleContextMenu(event: MouseEvent, message: Message) {
|
||||
const channel = ChannelStore.getChannel(message.channel_id);
|
||||
if (!channel) return;
|
||||
|
||||
event.stopPropagation();
|
||||
|
||||
ContextMenuApi.openContextMenu(event, contextMenuProps =>
|
||||
<MessageMenu
|
||||
message={message}
|
||||
channel={channel}
|
||||
onHeightUpdate={contextMenuProps.onHeightUpdate}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
|
@ -1,6 +0,0 @@
|
|||
# SearchReply
|
||||
|
||||
Adds a reply button to search results.
|
||||
|
||||
![the plugin in action](https://github.com/Vendicated/Vencord/assets/45497981/07e741d3-0f97-4e5c-82b0-80712ecf2cbb)
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { ReplyIcon } from "@components/Icons";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { ChannelStore, i18n, Menu, PermissionsBits, PermissionStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
|
||||
const replyToMessage = findByCodeLazy(".TEXTAREA_FOCUS)", "showMentionToggle:");
|
||||
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => {
|
||||
// make sure the message is in the selected channel
|
||||
if (SelectedChannelStore.getChannelId() !== message.channel_id) return;
|
||||
const channel = ChannelStore.getChannel(message?.channel_id);
|
||||
if (!channel) return;
|
||||
if (channel.guild_id && !PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return;
|
||||
|
||||
// dms and group chats
|
||||
const dmGroup = findGroupChildrenByChildId("pin", children);
|
||||
if (dmGroup && !dmGroup.some(child => child?.props?.id === "reply")) {
|
||||
const pinIndex = dmGroup.findIndex(c => c?.props.id === "pin");
|
||||
dmGroup.splice(pinIndex + 1, 0, (
|
||||
<Menu.MenuItem
|
||||
id="reply"
|
||||
label={i18n.Messages.MESSAGE_ACTION_REPLY}
|
||||
icon={ReplyIcon}
|
||||
action={(e: React.MouseEvent) => replyToMessage(channel, message, e)}
|
||||
/>
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
// servers
|
||||
const serverGroup = findGroupChildrenByChildId("mark-unread", children);
|
||||
if (serverGroup && !serverGroup.some(child => child?.props?.id === "reply")) {
|
||||
serverGroup.unshift((
|
||||
<Menu.MenuItem
|
||||
id="reply"
|
||||
label={i18n.Messages.MESSAGE_ACTION_REPLY}
|
||||
icon={ReplyIcon}
|
||||
action={(e: React.MouseEvent) => replyToMessage(channel, message, e)}
|
||||
/>
|
||||
));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export default definePlugin({
|
||||
name: "SearchReply",
|
||||
description: "Adds a reply button to search results",
|
||||
authors: [Devs.Aria],
|
||||
contextMenus: {
|
||||
"message": messageContextMenuPatch
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue