Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for custom startup animations #355

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
50d2b71
add option to disable the splash animation
ading2210 Jan 22, 2024
c18e0c2
reduce size of splash screen when animation is disabled
ading2210 Jan 22, 2024
454efff
add setting for custom splash animations
ading2210 Jan 22, 2024
1a828bf
avoid showing unloaded splash image
ading2210 Jan 22, 2024
e962e34
remove debug console.log
ading2210 Jan 23, 2024
9ff6653
Merge branch 'Vencord:main' into main
ading2210 Jan 24, 2024
f7da64a
don't put file path in custom url protocol
ading2210 Jan 24, 2024
c8b93fe
don't use deprecated registerFileProtocol
ading2210 Jan 24, 2024
7e733bf
Merge branch 'Vencord:main' into main
ading2210 Jan 29, 2024
804858f
add upstream changes
sz6084 May 8, 2024
0451ddf
Merge remote-tracking branch 'upstream/main'
ading2210 May 8, 2024
e6467ea
remove unrelated edit
ading2210 May 9, 2024
0a96d9e
Merge branch 'Vencord:main' into main
sz6084 May 12, 2024
2a3f158
Merge branch 'Vencord:main' into main
sz6084 May 18, 2024
9c0b22d
Merge branch 'Vencord:main' into main
sz6084 May 29, 2024
80e0fb7
Merge remote-tracking branch 'upstream/main'
ading2210 Jul 19, 2024
209d4cd
add splash animation preview in the vesktop settings
ading2210 Jul 19, 2024
3822fb1
fix preview image not updating when animation path is changed
ading2210 Jul 25, 2024
466488c
copy file to vesktop folder instead of storing full path
ading2210 Jul 25, 2024
415aa19
fix rmdir error if splash dir was previously unset
ading2210 Jul 26, 2024
d8248c8
Merge branch 'Vencord:main' into main
sz6084 Aug 29, 2024
4ac701f
Merge branch 'Vencord:main' into main
sz6084 Oct 7, 2024
17739bd
Merge branch 'main' into main
sz6084 Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import "./ipc";

import { app, BrowserWindow, nativeTheme } from "electron";
import { app, BrowserWindow, nativeTheme, net, protocol } from "electron";
import { checkUpdates } from "updater/main";

import { DATA_DIR } from "./constants";
Expand All @@ -25,7 +25,7 @@ if (IS_DEV) {
process.env.VENCORD_USER_DATA_DIR = DATA_DIR;

function init() {
const { disableSmoothScroll, hardwareAcceleration } = Settings.store;
const { disableSmoothScroll, hardwareAcceleration, splashAnimationPath } = Settings.store;

if (hardwareAcceleration === false) app.disableHardwareAcceleration();
if (disableSmoothScroll) {
Expand Down Expand Up @@ -63,6 +63,11 @@ function init() {
registerScreenShareHandler();
registerMediaPermissionsHandler();

//register file handler so we can load the custom splash animation from the user's filesystem
protocol.handle("splash-animation", () => {
return net.fetch("file:///"+splashAnimationPath);
ading2210 marked this conversation as resolved.
Show resolved Hide resolved
});

bootstrap();

app.on("activate", () => {
Expand Down
11 changes: 11 additions & 0 deletions src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
return dir;
});

handle(IpcEvents.SELECT_IMAGE_PATH, async () => {
const res = await dialog.showOpenDialog(mainWin!, {
properties: ["openFile"],
filters: [
{name: "Images", extensions: ["apng", "avif", "gif", "jpeg", "png", "svg", "webp"]}
]
});
if (!res.filePaths.length) return "cancelled";
return res.filePaths[0];
});

handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));

handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
Expand Down
20 changes: 16 additions & 4 deletions src/main/splash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/

import { BrowserWindow } from "electron";
import { BrowserWindow, webContents } from "electron";
import { join } from "path";
import { SplashProps } from "shared/browserWinProperties";
import { ICON_PATH, VIEW_DIR } from "shared/paths";

import { Settings } from "./settings";

export function createSplashWindow(startMinimized = false) {
const { splashBackground, splashColor, splashTheming, splashAnimationPath } = Settings.store;

const splash = new BrowserWindow({
...SplashProps,
icon: ICON_PATH,
show: !startMinimized
});

splash.loadFile(join(VIEW_DIR, "splash.html"));

const { splashBackground, splashColor, splashTheming } = Settings.store;

if (splashTheming) {
if (splashColor) {
const semiTransparentSplashColor = splashColor.replace("rgb(", "rgba(").replace(")", ", 0.2)");
Expand All @@ -34,6 +34,18 @@ export function createSplashWindow(startMinimized = false) {
splash.webContents.insertCSS(`body { --bg: ${splashBackground} !important }`);
}
}

if (splashAnimationPath) {
splash.webContents.executeJavaScript(`
document.getElementById("animation").src = "splash-animation://img";
`);
}
else {
splash.webContents.insertCSS(`img {image-rendering: pixelated}`)
splash.webContents.executeJavaScript(`
document.getElementById("animation").src = "../shiggy.gif";
`);
}

return splash;
}
3 changes: 2 additions & 1 deletion src/preload/VesktopNative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const VesktopNative = {
},
fileManager: {
showItemInFolder: (path: string) => invoke<void>(IpcEvents.SHOW_ITEM_IN_FOLDER, path),
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR)
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR),
selectImagePath: () => invoke<LiteralUnion<"cancelled", string>>(IpcEvents.SELECT_IMAGE_PATH)
},
settings: {
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
Expand Down
37 changes: 37 additions & 0 deletions src/renderer/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,43 @@ export default function SettingsUi() {
</>
)}

<Forms.FormTitle>Custom Spash Animation</Forms.FormTitle>
ading2210 marked this conversation as resolved.
Show resolved Hide resolved
<Forms.FormText>
The animation on the splash window is loaded from{" "}
{Settings.splashAnimationPath ? (
<a
href="about:blank"
onClick={e => {
e.preventDefault();
VesktopNative.fileManager.showItemInFolder(Settings.splashAnimationPath!);
}}
>
{Settings.splashAnimationPath}
</a>
) : (
"the default location"
)}
</Forms.FormText>
<div className="vcd-location-btns" style={{marginBottom: 20}}>
<Button
size={Button.Sizes.SMALL}
onClick={async () => {
const choice = await VesktopNative.fileManager.selectImagePath();
if (choice === "cancelled") return;
Settings.splashAnimationPath = choice;
}}
>
Change
</Button>
<Button
size={Button.Sizes.SMALL}
color={Button.Colors.RED}
onClick={() => (Settings.splashAnimationPath = void 0)}
>
Reset
</Button>
</div>

<Forms.FormTitle>Vencord Location</Forms.FormTitle>
<Forms.FormText>
Vencord files are loaded from{" "}
Expand Down
1 change: 1 addition & 0 deletions src/shared/IpcEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const enum IpcEvents {
SET_SETTINGS = "VCD_SET_SETTINGS",

SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR",
SELECT_IMAGE_PATH= "VCD_SELECT_IMAGE_PATH",

UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA",
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
Expand Down
1 change: 1 addition & 0 deletions src/shared/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface Settings {
checkUpdates?: boolean;

splashTheming?: boolean;
splashAnimationPath?: string;
splashColor?: string;
splashBackground?: string;
}
Expand Down
14 changes: 5 additions & 9 deletions static/views/splash.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@

img {
width: 128px;
height: 128px;
image-rendering: pixelated;
height: 128px
}
</style>
</head>

<body>
<div class="wrapper">
<img
draggable="false"
src="../shiggy.gif"
alt="shiggy"
role="presentation"
/>
<!-- the data url is here to ensure there isn't an empty frame before the image is loaded -->
<img id="animation" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
draggable="false" alt="animation" role="presentation" />
<p>Loading Vesktop...</p>
</div>
</body>
</body>