mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-23 19:01:02 +00:00
feat: custom achievement sound and volume changing)
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user