feat: Refactor API interactions and enhance user settings management

- Updated ezpp API to include user info retrieval and improved error handling.
- Introduced new writable stores for current user info and loading states.
- Added gamemode enums and utility functions for better gamemode handling.
- Refactored global state management to use consistent naming conventions.
- Enhanced loading and login components to provide better user feedback.
- Updated user settings to include preferred mode and type.
- Improved layout and page components for better state management and user experience.
This commit is contained in:
2025-07-03 11:46:50 +02:00
parent 892f2cea07
commit 651592c333
13 changed files with 680 additions and 128 deletions

View File

@@ -1,11 +1,11 @@
import { createAudioStore } from "@elron/svelte-audio-store";
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import { createAudioStore } from '@elron/svelte-audio-store';
import { type ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
const sounds = {
menuHeartbeat: "/audio/menuHeartbeat.mp3",
menuBack: "/audio/menuBack.wav",
menuHit: "/audio/menuHit.wav",
menuHeartbeat: '/audio/menuHeartbeat.mp3',
menuBack: '/audio/menuBack.wav',
menuHit: '/audio/menuHit.wav',
};
export const gameSounds = createAudioStore(sounds);
@@ -23,3 +23,30 @@ export const playAudio = (path: string, volume: number) => {
audio.volume = volume;
audio.play();
};
export const isNumber = (value: unknown) => {
if (typeof value === 'number' || typeof value === 'string') {
return value.toString().match(/^-?\d+(\.\d+)?$/) !== null;
}
return false;
};
export const formatTimeReadable = (initialSeconds: number) => {
let seconds = initialSeconds;
const days = Math.floor(seconds / (24 * 3600));
seconds -= days * 24 * 3600;
const hours = Math.floor(seconds / 3600);
seconds -= hours * 3600;
const minutes = Math.floor(seconds / 60);
let result = '';
if (days > 0) result += `${days}d `;
if (hours > 0) result += `${hours}h `;
result += `${minutes}m`;
return result.trim();
};