diff --git a/src/main/index.ts b/src/main/index.ts index 9d6a52c..780d52a 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -6,7 +6,7 @@ import "./ipc"; -import { app, BrowserWindow, nativeTheme } from "electron"; +import { app, BrowserWindow, nativeTheme, protocol } from "electron"; import { checkUpdates } from "updater/main"; import { DATA_DIR } from "./constants"; @@ -63,6 +63,12 @@ function init() { registerScreenShareHandler(); registerMediaPermissionsHandler(); + //register file handler so we can load the custom splash animation from the user's filesystem + protocol.registerFileProtocol("image", (request, callback) => { + const url = request.url.substring(8); + callback({path: url}); + }); + bootstrap(); app.on("activate", () => { diff --git a/src/main/ipc.ts b/src/main/ipc.ts index e0bf131..3bfca76 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -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) => { diff --git a/src/main/splash.ts b/src/main/splash.ts index 7283455..1d1df1b 100644 --- a/src/main/splash.ts +++ b/src/main/splash.ts @@ -4,7 +4,7 @@ * 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"; @@ -12,17 +12,14 @@ import { ICON_PATH, VIEW_DIR } from "shared/paths"; import { Settings } from "./settings"; export function createSplashWindow(startMinimized = false) { - const { splashBackground, splashColor, splashTheming, disableSplashAnimation } = Settings.store; + const { splashBackground, splashColor, splashTheming, splashAnimationPath } = Settings.store; - if (disableSplashAnimation) { - SplashProps.height = 150; - } const splash = new BrowserWindow({ ...SplashProps, icon: ICON_PATH, show: !startMinimized }); - + splash.loadFile(join(VIEW_DIR, "splash.html")); if (splashTheming) { @@ -37,9 +34,17 @@ export function createSplashWindow(startMinimized = false) { splash.webContents.insertCSS(`body { --bg: ${splashBackground} !important }`); } } - - if (!disableSplashAnimation) { - splash.webContents.insertCSS(`img {display: block !important}`); + + if (splashAnimationPath) { + splash.webContents.executeJavaScript(` + document.getElementById("animation").src = "image://${splashAnimationPath}"; + `); + } + else { + splash.webContents.insertCSS(`img {image-rendering: pixelated}`) + splash.webContents.executeJavaScript(` + document.getElementById("animation").src = "../shiggy.gif"; + `); } return splash; diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index a2ca74c..172d2c2 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -33,7 +33,8 @@ export const VesktopNative = { }, fileManager: { showItemInFolder: (path: string) => invoke(IpcEvents.SHOW_ITEM_IN_FOLDER, path), - selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR) + selectVencordDir: () => invoke>(IpcEvents.SELECT_VENCORD_DIR), + selectImagePath: () => invoke>(IpcEvents.SELECT_IMAGE_PATH) }, settings: { get: () => sendSync(IpcEvents.GET_SETTINGS), diff --git a/src/renderer/components/Settings.tsx b/src/renderer/components/Settings.tsx index 236558e..5e3ed1c 100644 --- a/src/renderer/components/Settings.tsx +++ b/src/renderer/components/Settings.tsx @@ -49,7 +49,6 @@ export default function SettingsUi() { ["disableSmoothScroll", "Disable smooth scrolling", "Disables smooth scrolling in Vesktop", false], ["hardwareAcceleration", "Hardware Acceleration", "Enable hardware acceleration", true], ["splashTheming", "Splash theming", "Adapt the splash window colors to your custom theme", false], - ["disableSplashAnimation", "Disable splash animation", "Disable the animation on the splash window", false], [ "openLinksWithElectron", "Open Links in app (experimental)", @@ -154,6 +153,45 @@ export default function SettingsUi() { )} + Custom Spash Animation + + The animation on the splash window is loaded from{" "} + {Settings.splashAnimationPath ? ( + { + e.preventDefault(); + VesktopNative.fileManager.showItemInFolder(Settings.splashAnimationPath!); + }} + > + {Settings.splashAnimationPath} + + ) : ( + "the default location" + )} + +
+ + +
+ Vencord Location Vencord files are loaded from{" "} diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index df64403..b5d40c4 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -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", diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index 688e1a8..d6e9dc2 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -28,7 +28,7 @@ export interface Settings { checkUpdates?: boolean; splashTheming?: boolean; - disableSplashAnimation?: boolean; + splashAnimationPath?: string; splashColor?: string; splashBackground?: string; } diff --git a/static/views/splash.html b/static/views/splash.html index a125871..4b91560 100644 --- a/static/views/splash.html +++ b/static/views/splash.html @@ -25,15 +25,13 @@ img { width: 128px; height: 128px; - image-rendering: pixelated; - display: none; }
- shiggy + animation

Loading Vesktop...

\ No newline at end of file