add nearest neighbor option to splash customisation

This commit is contained in:
Vendicated
2025-10-20 01:56:04 +02:00
parent 02907d3248
commit 28a13be709
4 changed files with 44 additions and 7 deletions
+5 -1
View File
@@ -24,7 +24,7 @@ export function createSplashWindow(startMinimized = false) {
loadView(splash, "splash.html"); loadView(splash, "splash.html");
const { splashBackground, splashColor, splashTheming } = Settings.store; const { splashBackground, splashColor, splashTheming, splashPixelated } = Settings.store;
if (splashTheming !== false) { if (splashTheming !== false) {
if (splashColor) { if (splashColor) {
@@ -39,6 +39,10 @@ export function createSplashWindow(startMinimized = false) {
} }
} }
if (splashPixelated) {
splash.webContents.insertCSS(`img { image-rendering: pixelated; }`);
}
return splash; return splash;
} }
@@ -13,8 +13,14 @@
} }
.vcd-user-assets-actions { .vcd-user-assets-actions {
display: grid;
width: 100%;
gap: 0.5em;
margin-bottom: auto;
}
.vcd-user-assets-buttons {
display: flex; display: flex;
flex-direction: column;
gap: 0.5em; gap: 0.5em;
} }
@@ -6,7 +6,9 @@
import "./UserAssets.css"; import "./UserAssets.css";
import { FormSwitch } from "@vencord/types/components";
import { import {
Margins,
ModalCloseButton, ModalCloseButton,
ModalContent, ModalContent,
ModalHeader, ModalHeader,
@@ -18,6 +20,7 @@ import {
} from "@vencord/types/utils"; } from "@vencord/types/utils";
import { Button, showToast, Text, useState } from "@vencord/types/webpack/common"; import { Button, showToast, Text, useState } from "@vencord/types/webpack/common";
import { UserAssetType } from "main/userAssets"; import { UserAssetType } from "main/userAssets";
import { useSettings } from "renderer/settings";
import { SettingsComponent } from "./Settings"; import { SettingsComponent } from "./Settings";
@@ -51,11 +54,18 @@ function openAssetsModal() {
function Asset({ asset }: { asset: UserAssetType }) { function Asset({ asset }: { asset: UserAssetType }) {
// cache busting // cache busting
const [version, setVersion] = useState(Date.now()); const [version, setVersion] = useState(Date.now());
const settings = useSettings();
const isSplash = asset === "splash";
const imageRendering = isSplash && settings.splashPixelated ? "pixelated" : "auto";
const onChooseAsset = (value?: null) => async () => { const onChooseAsset = (value?: null) => async () => {
const res = await VesktopNative.fileManager.chooseUserAsset(asset, value); const res = await VesktopNative.fileManager.chooseUserAsset(asset, value);
if (res === "ok") { if (res === "ok") {
setVersion(Date.now()); setVersion(Date.now());
if (isSplash && value === null) {
settings.splashPixelated = false;
}
} else if (res === "failed") { } else if (res === "failed") {
showToast("Something went wrong. Please try again"); showToast("Something went wrong. Please try again");
} }
@@ -67,13 +77,29 @@ function Asset({ asset }: { asset: UserAssetType }) {
{wordsToTitle(wordsFromCamel(asset))} {wordsToTitle(wordsFromCamel(asset))}
</Text> </Text>
<div className="vcd-user-assets-asset"> <div className="vcd-user-assets-asset">
<img className="vcd-user-assets-image" src={`vesktop://assets/${asset}?v=${version}`} alt="" /> <img
className="vcd-user-assets-image"
src={`vesktop://assets/${asset}?v=${version}`}
alt=""
style={{ imageRendering }}
/>
<div className="vcd-user-assets-actions"> <div className="vcd-user-assets-actions">
<div className="vcd-user-assets-buttons">
<Button onClick={onChooseAsset()}>Customize</Button> <Button onClick={onChooseAsset()}>Customize</Button>
<Button color={Button.Colors.PRIMARY} onClick={onChooseAsset(null)}> <Button color={Button.Colors.PRIMARY} onClick={onChooseAsset(null)}>
Reset to default Reset to default
</Button> </Button>
</div> </div>
{isSplash && (
<FormSwitch
title="Nearest-Neighbor Scaling (for pixel art)"
value={settings.splashPixelated ?? false}
onChange={val => (settings.splashPixelated = val)}
className={Margins.top16}
hideBorder
/>
)}
</div>
</div> </div>
</section> </section>
); );
+1
View File
@@ -28,6 +28,7 @@ export interface Settings {
splashTheming?: boolean; splashTheming?: boolean;
splashColor?: string; splashColor?: string;
splashBackground?: string; splashBackground?: string;
splashPixelated?: boolean;
spellCheckLanguages?: string[]; spellCheckLanguages?: string[];