feat: custom achievement sound and volume changing)

This commit is contained in:
Moyasee
2025-11-07 17:48:56 +02:00
parent 754e9c14b8
commit a6cbaf6dc1
21 changed files with 583 additions and 46 deletions

View File

@@ -2,6 +2,8 @@ import axios from "axios";
import { JSDOM } from "jsdom";
import UserAgent from "user-agents";
import path from "node:path";
import fs from "node:fs";
import { THEMES_PATH } from "@main/constants";
export const getFileBuffer = async (url: string) =>
fetch(url, { method: "GET" }).then((response) =>
@@ -36,4 +38,26 @@ export const normalizePath = (str: string) =>
export const addTrailingSlash = (str: string) =>
str.endsWith("/") ? str : `${str}/`;
export const getThemePath = (themeId: string) =>
path.join(THEMES_PATH, themeId);
export const getThemeSoundPath = (themeId: string): string | null => {
const themeDir = getThemePath(themeId);
if (!fs.existsSync(themeDir)) {
return null;
}
const formats = ["wav", "mp3", "ogg", "m4a"];
for (const format of formats) {
const soundPath = path.join(themeDir, `achievement.${format}`);
if (fs.existsSync(soundPath)) {
return soundPath;
}
}
return null;
};
export * from "./reg-parser";