add nearest neighbor option to splash customisation
This commit is contained in:
+5
-1
@@ -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,12 +77,28 @@ 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">
|
||||||
<Button onClick={onChooseAsset()}>Customize</Button>
|
<div className="vcd-user-assets-buttons">
|
||||||
<Button color={Button.Colors.PRIMARY} onClick={onChooseAsset(null)}>
|
<Button onClick={onChooseAsset()}>Customize</Button>
|
||||||
Reset to default
|
<Button color={Button.Colors.PRIMARY} onClick={onChooseAsset(null)}>
|
||||||
</Button>
|
Reset to default
|
||||||
|
</Button>
|
||||||
|
</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>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Vendored
+1
@@ -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[];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user