Compare commits
169 Commits
3.0.4
...
5b1e32d4eb
| Author | SHA1 | Date | |
|---|---|---|---|
|
5b1e32d4eb
|
|||
|
d0b0011910
|
|||
|
1467d3e296
|
|||
|
2ded0d4b94
|
|||
|
9d80811e83
|
|||
| 730a27b397 | |||
| e84feb292b | |||
| 485cb3acf7 | |||
|
44ad025d3d
|
|||
|
ec80b13de3
|
|||
|
6a279de728
|
|||
|
4e33ec3451
|
|||
|
6fdb2376a1
|
|||
|
afdd74175a
|
|||
|
6f8043d2d0
|
|||
| f7fff7748a | |||
| d5286263b9 | |||
| 1cc1a4a0c3 | |||
| d2ae9e939f | |||
| bde922ab9f | |||
| a1f96a7de3 | |||
| 3b2c902264 | |||
| 40a32d7a60 | |||
| 52c60acf37 | |||
| 2788cd6e8b | |||
| 2d1941db33 | |||
| 00958d5238 | |||
| b8a0b448c7 | |||
| 09487e945e | |||
| 2532ab0059 | |||
| 16fe91b3a5 | |||
| eca08f16c5 | |||
| e76d67f3a8 | |||
| 9811b36e58 | |||
|
0f10beb3b4
|
|||
|
4326199a56
|
|||
|
7f65384b1c
|
|||
|
aacd0d1d91
|
|||
|
079a076f99
|
|||
| 6d88c39ce2 | |||
| 56608a64fc | |||
| eaf6f5976d | |||
| 93f1f380ec | |||
| c47ea1f976 | |||
| 09af78f1aa | |||
| 3900b5c6cf | |||
| adf607e24c | |||
| 1128b51778 | |||
| d435f0c09a | |||
| b188e2dee8 | |||
| 8fd56ae749 | |||
| b2e7d22d28 | |||
| d871e06172 | |||
| 6a1c5441c3 | |||
| ef36f49a6f | |||
| 7e40536ec8 | |||
| 694d403aeb | |||
| 9515892b2f | |||
| 0a58f0f63b | |||
| 60e3ef4131 | |||
| 7375cccc05 | |||
| 251bf8177c | |||
| bf4ce18671 | |||
| 4dc83c882d | |||
| e20f11be64 | |||
| 407996269e | |||
| 95c6db6a1d | |||
| a87a4bcc54 | |||
| 97f072f4ce | |||
| 1aa3070ea1 | |||
| d3c3e4e771 | |||
| 921dbd716c | |||
| 34e82f89e8 | |||
| 901fbefd1b | |||
| a795978827 | |||
| a9152cc376 | |||
| 8d790c7da3 | |||
| f5a2c4365b | |||
| a925548ae9 | |||
| a6495ea353 | |||
| 24802b5132 | |||
| f09405ed58 | |||
| eeda85f48f | |||
| 9770e81d6f | |||
| 31b7d17b09 | |||
| 1fc0391113 | |||
| 62f03cf7c0 | |||
| 94f6e850cf | |||
| d6fdb2a152 | |||
| 9cd990cf96 | |||
| 2e0ef81bcb | |||
| 96680ff8b5 | |||
| 0b9d6373bf | |||
| 295c1424c9 | |||
| 0e12a801d2 | |||
| cf86dba5c4 | |||
| 540c653399 | |||
| c9b8d9f599 | |||
| 49665d94bc | |||
| 1a19c19399 | |||
| cbfe5ec868 | |||
| c5b18dacbb | |||
| ef01984875 | |||
| 46ee36ce81 | |||
| c4658ae4cc | |||
| ca15ff566f | |||
| a6fdda4487 | |||
| a30946eb60 | |||
| 9106ad89b3 | |||
| 194709df0c | |||
| 20f625be60 | |||
| 66a5fd84ae | |||
| 44d7401947 | |||
| f973e48561 | |||
| de186b7ff9 | |||
| 244d526933 | |||
| c7a990e3fe | |||
| ed1f741a9e | |||
| b6616a37f4 | |||
| 63433ac626 | |||
| 149b4715d7 | |||
| ae3443d0b9 | |||
| abc7b9d9d9 | |||
| d9dd21d3be | |||
| 0df31178f4 | |||
| 6825f9e99b | |||
| 08a8e34781 | |||
| 1aa973f6bb | |||
| 0999832985 | |||
| 11798318f4 | |||
| f1b909e248 | |||
| 1f845f1282 | |||
| f9b38ec9eb | |||
| 623559cf8e | |||
| 80bd096834 | |||
| e1c6e35f95 | |||
| 57158bab15 | |||
| 58837053c7 | |||
| 458a2cca36 | |||
| cb66df6082 | |||
| 1d1904e995 | |||
| c07e390b65 | |||
| bae0fad19b | |||
| 993eb167fc | |||
| ea2e348ccc | |||
| 2855880c18 | |||
| dcb57c5452 | |||
| c9def2c46b | |||
| b8ebcf5509 | |||
| a338df6a36 | |||
| d67d58824b | |||
| ad090ce38c | |||
| 3d57524a16 | |||
| d6bf3ccb3c | |||
| a548dc875e | |||
| 3029cc66fb | |||
| adf40b70cb | |||
| ff00b27330 | |||
| 95a5591c70 | |||
| cdc3c78ffe | |||
| 509aa36379 | |||
| 20e5961b7c | |||
| 9b816e1e5c | |||
| ada83b32dc | |||
| cbf85753a8 | |||
| eb1ef06c07 | |||
| a64655ec5d | |||
| 45b902cfb6 | |||
| f53aba9a7b |
@@ -1,7 +1,16 @@
|
|||||||
{
|
{
|
||||||
"svelte.enable-ts-plugin": true,
|
"svelte.enable-ts-plugin": true,
|
||||||
|
"git.enableCommitSigning": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"[rust]": {
|
"[rust]": {
|
||||||
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
||||||
|
},
|
||||||
|
"json.schemaDownload.trustedDomains": {
|
||||||
|
"https://schemastore.azurewebsites.net/": true,
|
||||||
|
"https://raw.githubusercontent.com/": true,
|
||||||
|
"https://www.schemastore.org/": true,
|
||||||
|
"https://json.schemastore.org/": true,
|
||||||
|
"https://json-schema.org/": true,
|
||||||
|
"https://schema.tauri.app/": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ It enhances the osu! experience with quality-of-life features and integration sp
|
|||||||
- [x] Displays ping to the EZPPFarm server
|
- [x] Displays ping to the EZPPFarm server
|
||||||
- [x] Discord Rich Presence
|
- [x] Discord Rich Presence
|
||||||
- [x] Performance Display Overlay (currently in experimental patcher release stream)
|
- [x] Performance Display Overlay (currently in experimental patcher release stream)
|
||||||
|
- [x] Launcher Theming
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ It enhances the osu! experience with quality-of-life features and integration sp
|
|||||||
|
|
||||||
- **Rust** (installed via [rustup](https://rustup.rs/) – recommended for Windows)
|
- **Rust** (installed via [rustup](https://rustup.rs/) – recommended for Windows)
|
||||||
- **Cargo** (comes with rustup)
|
- **Cargo** (comes with rustup)
|
||||||
|
- **[CMake](https://cmake.org/download/)**
|
||||||
- **[Bun](https://bun.sh/)** (JavaScript runtime)
|
- **[Bun](https://bun.sh/)** (JavaScript runtime)
|
||||||
|
|
||||||
### Steps
|
### Steps
|
||||||
@@ -72,3 +74,9 @@ src-tauri/target/release/ezpplauncher.exe
|
|||||||
├── package.json # Bun project config
|
├── package.json # Bun project config
|
||||||
└── README.md
|
└── README.md
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎨 Launcher Themes
|
||||||
|
|
||||||
|
By default, the launcher includes several downloadable themes. If you want to create your own custom theme, please use the [create-ezpplauncher-theme](https://git.ez-pp.farm/EZPPFarm/create-ezpplauncher-theme) repository for a template and instructions.
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 157 KiB |
@@ -36,5 +36,14 @@ export default ts.config(
|
|||||||
svelteConfig,
|
svelteConfig,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'no-empty': 'off',
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^\\$\\$(Props|Events|Slots|Generic)$' },
|
||||||
|
],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "ezpplauncher",
|
"name": "ezpplauncher",
|
||||||
"version": "3.0.0",
|
"version": "3.2.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"debug": "bun run tauri dev",
|
"debug": "bun run tauri dev",
|
||||||
"build": "bun ./scripts/sync-version.ts && bun run tauri:build",
|
"build": "bun ./scripts/build.ts",
|
||||||
"vite:dev": "vite dev",
|
"vite:dev": "vite dev",
|
||||||
"vite:build": "vite build",
|
"vite:build": "vite build && exit 0",
|
||||||
"tauri:build": "tauri build",
|
"tauri:build": "tauri build",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
@@ -18,58 +18,64 @@
|
|||||||
},
|
},
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@better-fetch/fetch": "^1.1.18",
|
"@better-fetch/fetch": "^1.1.21",
|
||||||
"@fontsource/sora": "^5.2.6",
|
"@fontsource-variable/sora": "^5.2.8",
|
||||||
"@fontsource/space-mono": "^5.2.8",
|
"@fontsource/space-mono": "^5.2.9",
|
||||||
"@number-flow/svelte": "^0.3.9",
|
"@number-flow/svelte": "^0.4.0",
|
||||||
"@tailwindcss/typography": "0.5.16",
|
"@tailwindcss/typography": "^0.5.19",
|
||||||
"@tailwindcss/vite": "^4.1.11",
|
"@tailwindcss/vite": "^4.3.0",
|
||||||
"@tauri-apps/api": "2.6.0",
|
"@tauri-apps/api": "^2.11.0",
|
||||||
"@tauri-apps/plugin-dialog": "2.3.1",
|
"@tauri-apps/plugin-dialog": "^2.7.1",
|
||||||
"@tauri-apps/plugin-fs": "2.4.1",
|
"@tauri-apps/plugin-fs": "^2.5.1",
|
||||||
"@tauri-apps/plugin-shell": "2.3.0",
|
"@tauri-apps/plugin-shell": "^2.3.5",
|
||||||
"animejs": "^4.0.2",
|
"@types/node": "^25.9.1",
|
||||||
|
"animejs": "^4.4.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"lucide-svelte": "0.525.0",
|
"jszip": "^3.10.1",
|
||||||
|
"react": "^19.2.4",
|
||||||
|
"react-dom": "^19.2.4",
|
||||||
|
"react-to-webcomponent": "^2.0.1",
|
||||||
"semver": "^7.7.2",
|
"semver": "^7.7.2",
|
||||||
"tw-animate-css": "^1.3.0",
|
"sileo": "^0.1.3",
|
||||||
"svelte-confetti": "^2.0.0"
|
"svelte-confetti": "^2.3.2",
|
||||||
|
"tw-animate-css": "^1.3.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.2.5",
|
"@eslint/compat": "^2.0.0",
|
||||||
"@eslint/js": "^9.18.0",
|
"@eslint/js": "^9.35.0",
|
||||||
"@iarna/toml": "2.2.5",
|
"@iarna/toml": "2.2.5",
|
||||||
"@lucide/svelte": "^0.525.0",
|
"@lucide/svelte": "^1.16.0",
|
||||||
"@sveltejs/adapter-static": "3.0.8",
|
"@sveltejs/adapter-static": "^3.0.9",
|
||||||
"@sveltejs/kit": "2.22.2",
|
"@sveltejs/kit": "^2.57.1",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.1.0",
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||||
"@tauri-apps/cli": "2.6.1",
|
"@tauri-apps/cli": "^2.10.0",
|
||||||
"@types/bun": "^1.2.18",
|
"@types/bun": "^1.2.21",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/semver": "^7.7.0",
|
"@types/react-dom": "^19.2.3",
|
||||||
|
"@types/semver": "^7.7.1",
|
||||||
"autoprefixer": "10.4.21",
|
"autoprefixer": "10.4.21",
|
||||||
"bits-ui": "^2.8.10",
|
"bits-ui": "^1.4.7",
|
||||||
"clsx": "2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.35.0",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-svelte": "^3.0.0",
|
"eslint-plugin-svelte": "^3.12.2",
|
||||||
"globals": "^16.0.0",
|
"globals": "^17.0.0",
|
||||||
"mode-watcher": "^1.0.6",
|
"mode-watcher": "^1.1.0",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.6.2",
|
||||||
"prettier-plugin-svelte": "^3.3.3",
|
"prettier-plugin-svelte": "^3.4.0",
|
||||||
"sass-embedded": "1.89.2",
|
"sass-embedded": "^1.92.1",
|
||||||
"svelte": "5.34.8",
|
"svelte": "^5.55.3",
|
||||||
"svelte-check": "4.2.2",
|
"svelte-check": "^4.3.1",
|
||||||
"svelte-sonner": "^1.0.5",
|
"svelte-sonner": "^1.0.5",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tailwind-variants": "^1.0.0",
|
"tailwind-variants": "^3.1.0",
|
||||||
"tailwindcss": "^4.1.7",
|
"tailwindcss": "^4.1.7",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"tslib": "2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "5.8.3",
|
"typescript": "^6.0.2",
|
||||||
"typescript-eslint": "^8.20.0",
|
"typescript-eslint": "^8.42.0",
|
||||||
"vite": "7.0.0",
|
"vite": "^8.0.8",
|
||||||
"vite-plugin-devtools-json": "^0.3.0"
|
"vite-plugin-devtools-json": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { spawn } from 'child_process';
|
||||||
|
|
||||||
|
function runVite(): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const proc = spawn('bunx', ['--bun', 'vite', 'build'], { stdio: ['inherit', 'pipe', 'pipe'] });
|
||||||
|
|
||||||
|
proc.stdout?.on('data', (data: Buffer) => {
|
||||||
|
process.stdout.write(data);
|
||||||
|
if (data.toString().includes('✔ done')) {
|
||||||
|
setTimeout(() => {
|
||||||
|
proc.kill();
|
||||||
|
resolve();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.stderr?.on('data', (data: Buffer) => process.stderr.write(data));
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0 || code === null) resolve();
|
||||||
|
else reject(new Error(`vite build exited with code ${code}`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(cmd: string, args: string[]): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const proc = spawn(cmd, args, { stdio: 'inherit' });
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) resolve();
|
||||||
|
else reject(new Error(`${cmd} exited with code ${code}`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await run('bun', ['./scripts/sync-version.ts']);
|
||||||
|
await runVite();
|
||||||
|
await run('bunx', ['tauri', 'build']);
|
||||||
@@ -3,19 +3,26 @@ import path from 'path';
|
|||||||
import * as toml from '@iarna/toml';
|
import * as toml from '@iarna/toml';
|
||||||
import { cwd } from 'process';
|
import { cwd } from 'process';
|
||||||
|
|
||||||
|
const packageJsonPath = path.join(cwd(), 'package.json');
|
||||||
const cargoTomlPath = path.join(cwd(), 'src-tauri', 'Cargo.toml');
|
const cargoTomlPath = path.join(cwd(), 'src-tauri', 'Cargo.toml');
|
||||||
const tauriConfPath = path.join(cwd(), 'src-tauri', 'tauri.conf.json');
|
const tauriConfPath = path.join(cwd(), 'src-tauri', 'tauri.conf.json');
|
||||||
|
|
||||||
const cargoToml = fs.readFileSync(cargoTomlPath, 'utf8');
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||||
const cargo = toml.parse(cargoToml) as Record<string, string>;
|
const version = packageJson.version;
|
||||||
|
if (!version) throw new Error('Could not find version in package.json');
|
||||||
|
|
||||||
const version = cargo.package['version'];
|
let cargoTomlContent = fs.readFileSync(cargoTomlPath, 'utf8');
|
||||||
if (!version) throw new Error('Could not find version in Cargo.toml');
|
const cargo = toml.parse(cargoTomlContent) as { package: { version: string } };
|
||||||
|
|
||||||
|
if (cargo.package.version !== version) {
|
||||||
|
cargoTomlContent = cargoTomlContent.replace(/version = ".*?"/, `version = "${version}"`);
|
||||||
|
fs.writeFileSync(cargoTomlPath, cargoTomlContent);
|
||||||
|
console.log(`✅ Synced Cargo.toml version to ${version}`);
|
||||||
|
}
|
||||||
|
|
||||||
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
|
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
|
||||||
if (tauriConf.version !== version) {
|
if (tauriConf.version !== version) {
|
||||||
tauriConf.version = version;
|
tauriConf.version = version;
|
||||||
|
|
||||||
fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2));
|
fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2));
|
||||||
console.log(`✅ Synced tauri.conf.json version to ${version}`);
|
console.log(`✅ Synced tauri.conf.json version to ${version}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"types": ["@types/bun", "@types/node"]
|
||||||
|
},
|
||||||
|
"include": ["*.ts"]
|
||||||
|
}
|
||||||
@@ -1,12 +1,22 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ezpplauncher"
|
name = "ezpplauncher"
|
||||||
version = "3.0.4"
|
version = "3.2.1"
|
||||||
description = "EZPPLauncher redefined."
|
description = "EZPPLauncher redefined."
|
||||||
authors = ["HorizonCode"]
|
authors = ["HorizonCode"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
incremental = true # Compile your binary in smaller steps.
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1 # Allows LLVM to perform better optimization.
|
||||||
|
lto = true # Enables link-time-optimizations.
|
||||||
|
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
|
||||||
|
panic = "abort" # Higher performance by disabling panic handlers.
|
||||||
|
strip = true # Ensures debug symbols are removed.
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
# The `_lib` suffix may seem redundant but it is necessary
|
# The `_lib` suffix may seem redundant but it is necessary
|
||||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||||
@@ -15,33 +25,37 @@ name = "ezpplauncher_lib"
|
|||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.3.1", features = [] }
|
tauri-build = { version = "2.6.2", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2.7.0", features = [] }
|
tauri = { version = "2.11.2", features = ["protocol-asset"] }
|
||||||
tauri-plugin-shell = "2.3.0"
|
tauri-plugin-shell = "2.3.5"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = "1.0.141"
|
serde_json = "1.0.150"
|
||||||
serde_repr = "0.1.20"
|
serde_repr = "0.1.20"
|
||||||
tauri-plugin-dialog = "2.3.1"
|
tauri-plugin-dialog = "2.7.1"
|
||||||
tauri-plugin-fs = "2.4.1"
|
tauri-plugin-fs = "2.5.1"
|
||||||
hardware-id = "0.3.0"
|
hardware-id = "0.3.0"
|
||||||
tauri-plugin-cors-fetch = "4.1.0"
|
tauri-plugin-cors-fetch = "5.0.0"
|
||||||
sysinfo = "0.36.1"
|
sysinfo = "0.39.2"
|
||||||
reqwest = { version = "0.12.22", features = ["json", "stream"] }
|
reqwest = { version = "0.13.3", features = ["json", "stream", "query"] }
|
||||||
md5 = "0.8.0"
|
md5 = "0.8.0"
|
||||||
tokio = { version = "1.46.1", features = ["full"] }
|
tokio = { version = "1.52.2", features = ["full"] }
|
||||||
open = "5.3.2"
|
open = "5.3.5"
|
||||||
windows-sys = "0.60.2"
|
presenceforge = { version = "0.2.1", features = ["tokio-runtime"] }
|
||||||
discord-rich-presence = "0.2.5"
|
once_cell = "1.21.4"
|
||||||
once_cell = "1.21.3"
|
futures-util = "0.3.32"
|
||||||
|
byteorder = "1.5.0"
|
||||||
|
anyhow = "1.0.102"
|
||||||
|
url = "2.5.8"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winreg = "0.55.0"
|
winreg = "0.56.0"
|
||||||
winapi = { version = "0.3", features = ["winuser", "wincrypt", "memoryapi", "winbase", "dpapi"] }
|
winapi = { version = "0.3", features = ["winuser", "wincrypt", "memoryapi", "winbase", "dpapi"] }
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
widestring = "1.0"
|
widestring = "1.2.1"
|
||||||
|
windows-sys = "0.61.2"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
tauri-plugin-single-instance = "2.3.2"
|
tauri-plugin-single-instance = "2.4.2"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "default",
|
"identifier": "default",
|
||||||
"description": "Capability for the main window",
|
"description": "Capability for the main window",
|
||||||
"windows": ["main"],
|
"windows": [
|
||||||
|
"main"
|
||||||
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"shell:allow-open",
|
"shell:allow-open",
|
||||||
@@ -19,58 +21,128 @@
|
|||||||
{
|
{
|
||||||
"identifier": "fs:allow-read",
|
"identifier": "fs:allow-read",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "fs:allow-write",
|
"identifier": "fs:allow-write",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "fs:allow-exists",
|
"identifier": "fs:allow-exists",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "fs:allow-read-file",
|
"identifier": "fs:allow-read-file",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "fs:allow-write-file",
|
"identifier": "fs:allow-write-file",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "fs:allow-read-text-file",
|
"identifier": "fs:allow-read-text-file",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "fs:allow-mkdir",
|
"identifier": "fs:allow-mkdir",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "path": "$HOME/.ezpplauncher" },
|
{
|
||||||
{ "path": "$HOME/.ezpplauncher/*" },
|
"path": "$HOME/.ezpplauncher"
|
||||||
{ "path": "$HOME/.ezpplauncher/**/*" }
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "fs:allow-read-dir",
|
||||||
|
"allow": [
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "fs:allow-remove",
|
||||||
|
"allow": [
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "$HOME/.ezpplauncher/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 29 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#fff</color>
|
||||||
|
</resources>
|
||||||
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 357 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -1,6 +0,0 @@
|
|||||||
!macro NSIS_HOOK_POSTINSTALL
|
|
||||||
${If} $PassiveMode = 1
|
|
||||||
${OrIf} ${Silent}
|
|
||||||
Exec '"$INSTDIR\${MAINBINARYNAME}.exe"'
|
|
||||||
${EndIf}
|
|
||||||
!macroend
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
!macro NSIS_HOOK_POSTINSTALL
|
||||||
|
${If} $PassiveMode = 1
|
||||||
|
${OrIf} ${Silent}
|
||||||
|
Exec '"$INSTDIR\${MAINBINARYNAME}.exe"'
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!macro NSIS_HOOK_PREUNINSTALL
|
||||||
|
${If} $DeleteAppDataCheckboxState = 1
|
||||||
|
MessageBox MB_YESNO "Do you want to remove all EZPPLauncher data and themes?" IDYES do_delete IDNO skip_delete
|
||||||
|
do_delete:
|
||||||
|
StrCpy $R9 1
|
||||||
|
skip_delete:
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!macro NSIS_HOOK_POSTUNINSTALL
|
||||||
|
${If} $R9 = 1
|
||||||
|
RMDir /r "$PROFILE\.ezpplauncher"
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
@@ -12,6 +12,8 @@ use tokio::io::AsyncWriteExt;
|
|||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio::time::{Duration, sleep};
|
use tokio::time::{Duration, sleep};
|
||||||
|
|
||||||
|
use crate::OpenedUrls;
|
||||||
|
use crate::osudb::parse_osudb;
|
||||||
use crate::presence;
|
use crate::presence;
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
check_folder_completeness, encrypt_password, get_osu_config, get_osu_user_config,
|
check_folder_completeness, encrypt_password, get_osu_config, get_osu_user_config,
|
||||||
@@ -19,6 +21,14 @@ use crate::utils::{
|
|||||||
set_osu_config_vals, set_osu_user_config_vals,
|
set_osu_config_vals, set_osu_user_config_vals,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn opened_urls(app: tauri::AppHandle) -> Vec<PathBuf> {
|
||||||
|
let args = app.state::<OpenedUrls>().0.lock().unwrap().clone();
|
||||||
|
app.state::<OpenedUrls>().0.lock().unwrap().clear();
|
||||||
|
|
||||||
|
args
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_launcher_version() -> String {
|
pub fn get_launcher_version() -> String {
|
||||||
env!("CARGO_PKG_VERSION").to_string()
|
env!("CARGO_PKG_VERSION").to_string()
|
||||||
@@ -56,17 +66,11 @@ pub fn valid_osu_folder(folder: String) -> bool {
|
|||||||
"scores.db",
|
"scores.db",
|
||||||
];
|
];
|
||||||
|
|
||||||
let folder_files: Vec<&str> = osu_folder_files.iter().map(|&s| s).collect();
|
let path = PathBuf::from(folder);
|
||||||
if folder_files.iter().any(|&file| file == "osu!.exe") == false {
|
if !path.join("osu!.exe").exists() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
check_folder_completeness(path, &osu_folder_files) >= 70.0
|
||||||
let path = PathBuf::from(folder);
|
|
||||||
let match_percentage = check_folder_completeness(path, &osu_folder_files) >= 70.0;
|
|
||||||
if match_percentage {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@@ -83,10 +87,10 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
|
|
||||||
let hklm_registry_paths = ["SOFTWARE\\Classes\\osu\\DefaultIcon"];
|
let hklm_registry_paths = ["SOFTWARE\\Classes\\osu\\DefaultIcon"];
|
||||||
|
|
||||||
let hkcr_registry_paths = [
|
let hkcu_registry_paths = [
|
||||||
"osustable.File.osk\\DefaultIcon",
|
"Software\\Classes\\osustable.File.osk\\DefaultIcon",
|
||||||
"osustable.File.osr\\DefaultIcon",
|
"Software\\Classes\\osustable.File.osr\\DefaultIcon",
|
||||||
"osustable.File.osz\\DefaultIcon",
|
"Software\\Classes\\osustable.File.osz\\DefaultIcon",
|
||||||
];
|
];
|
||||||
|
|
||||||
let osu_folder_files = [
|
let osu_folder_files = [
|
||||||
@@ -135,10 +139,10 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let hkcr = RegKey::predef(HKEY_CLASSES_ROOT);
|
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
|
||||||
|
|
||||||
for reg_path in &hkcr_registry_paths {
|
for reg_path in &hkcu_registry_paths {
|
||||||
if let Ok(subkey) = hkcr.open_subkey_with_flags(reg_path, KEY_READ | KEY_WOW64_32KEY) {
|
if let Ok(subkey) = hkcu.open_subkey_with_flags(reg_path, KEY_READ | KEY_WOW64_32KEY) {
|
||||||
let value_names = [""];
|
let value_names = [""];
|
||||||
for value_name in &value_names {
|
for value_name in &value_names {
|
||||||
if let Ok(value) = subkey.get_value::<String, _>(value_name) {
|
if let Ok(value) = subkey.get_value::<String, _>(value_name) {
|
||||||
@@ -160,53 +164,108 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
pub async fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
||||||
let path = PathBuf::from(folder);
|
let path = PathBuf::from(folder);
|
||||||
let osu_user_config = get_osu_user_config(path.clone());
|
let osu_db_path = path.join("osu!.db");
|
||||||
let songs_path = osu_user_config
|
if !osu_db_path.exists() {
|
||||||
.and_then(|config| config.get("Songs").cloned())
|
return Some(0);
|
||||||
.unwrap_or_else(|| path.join("Songs").to_string_lossy().into_owned());
|
|
||||||
let songs_folder = PathBuf::from(songs_path);
|
|
||||||
|
|
||||||
if !songs_folder.exists() {
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
|
let osu_db_bytes = fs::read(osu_db_path).await.ok()?;
|
||||||
|
let osu_db = parse_osudb(osu_db_bytes).ok()?;
|
||||||
|
let beatmap_sets = osu_db
|
||||||
|
.beatmaps
|
||||||
|
.iter()
|
||||||
|
.map(|b| b.beatmapset_id)
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
.len();
|
||||||
|
Some(beatmap_sets as u64)
|
||||||
|
}
|
||||||
|
|
||||||
let mut count = 0;
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
if let Ok(entries) = std::fs::read_dir(songs_folder) {
|
#[serde(rename_all = "camelCase")]
|
||||||
for entry in entries.flatten() {
|
pub struct SkinInfo {
|
||||||
if entry.file_type().map_or(false, |ft| ft.is_dir()) {
|
pub name: String,
|
||||||
let dir_path = entry.path();
|
pub author: Option<String>,
|
||||||
if let Ok(files) = std::fs::read_dir(&dir_path) {
|
pub modified: u64,
|
||||||
for file in files.flatten() {
|
|
||||||
if file.path().extension().map_or(false, |ext| ext == "osu") {
|
|
||||||
count += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Some(count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_skins_count(folder: String) -> Option<u64> {
|
pub async fn get_skins(folder: String) -> Option<Vec<SkinInfo>> {
|
||||||
let path = PathBuf::from(folder);
|
use std::path::PathBuf;
|
||||||
let skins_folder = path.join("Skins");
|
use std::time::UNIX_EPOCH;
|
||||||
|
use tokio::fs;
|
||||||
|
|
||||||
|
let skins_folder = PathBuf::from(folder).join("Skins");
|
||||||
|
|
||||||
if !skins_folder.exists() {
|
if !skins_folder.exists() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut entries = fs::read_dir(skins_folder).await.ok()?;
|
||||||
|
|
||||||
|
let mut skins = Vec::new();
|
||||||
|
|
||||||
|
while let Some(entry) = entries.next_entry().await.ok()? {
|
||||||
|
if !entry.file_type().await.ok()?.is_dir() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dir_path = entry.path();
|
||||||
|
let skin_ini = dir_path.join("skin.ini");
|
||||||
|
|
||||||
|
if !skin_ini.exists() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = entry.file_name().to_string_lossy().to_string();
|
||||||
|
|
||||||
|
let author = fs::read_to_string(&skin_ini)
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.and_then(|content| {
|
||||||
|
content.lines().find_map(|line| {
|
||||||
|
let (key, value) = line.split_once(':')?;
|
||||||
|
key.trim()
|
||||||
|
.eq_ignore_ascii_case("Author")
|
||||||
|
.then(|| value.trim().to_string())
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
let modified = entry
|
||||||
|
.metadata()
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.and_then(|m| m.modified().ok())
|
||||||
|
.and_then(|t| t.duration_since(UNIX_EPOCH).ok())
|
||||||
|
.map(|d| d.as_secs())
|
||||||
|
.unwrap_or(0);
|
||||||
|
|
||||||
|
skins.push(SkinInfo {
|
||||||
|
name,
|
||||||
|
author,
|
||||||
|
modified,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(skins)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn get_skins_count(folder: String) -> Option<u64> {
|
||||||
|
let path = PathBuf::from(folder);
|
||||||
|
let skins_folder = path.join("Skins");
|
||||||
|
|
||||||
|
if !skins_folder.exists() {
|
||||||
|
return Some(0);
|
||||||
|
}
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
if let Ok(entries) = std::fs::read_dir(skins_folder) {
|
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
||||||
for entry in entries.flatten() {
|
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||||
if entry.file_type().map_or(false, |ft| ft.is_dir()) {
|
if entry.file_type().await.map_or(false, |ft| ft.is_dir()) {
|
||||||
let dir_path = entry.path();
|
let dir_path = entry.path();
|
||||||
if let Ok(files) = std::fs::read_dir(&dir_path) {
|
if let Ok(mut files) = fs::read_dir(&dir_path).await {
|
||||||
for file in files.flatten() {
|
while let Ok(Some(file)) = files.next_entry().await {
|
||||||
if file.path().extension().map_or(false, |ext| ext == "ini") {
|
if file.path().extension().map_or(false, |ext| ext == "ini") {
|
||||||
count += 1;
|
count += 1;
|
||||||
break;
|
break;
|
||||||
@@ -222,28 +281,28 @@ pub fn get_skins_count(folder: String) -> Option<u64> {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_osu_skin(folder: String) -> String {
|
pub fn get_osu_skin(folder: String) -> String {
|
||||||
let path = PathBuf::from(folder);
|
let path = PathBuf::from(folder);
|
||||||
let osu_user_config = get_osu_user_config(path.clone());
|
let osu_user_config = get_osu_user_config(path);
|
||||||
return osu_user_config
|
osu_user_config
|
||||||
.and_then(|config| config.get("Skin").cloned())
|
.and_then(|config| config.get("Skin").cloned())
|
||||||
.unwrap_or_else(|| "Default".to_string());
|
.unwrap_or_else(|| "Default".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_osu_version(folder: String) -> String {
|
pub fn get_osu_version(folder: String) -> String {
|
||||||
let path = PathBuf::from(folder);
|
let path = PathBuf::from(folder);
|
||||||
let osu_user_config = get_osu_user_config(path.clone());
|
let osu_user_config = get_osu_user_config(path);
|
||||||
return osu_user_config
|
osu_user_config
|
||||||
.and_then(|config| config.get("LastVersion").cloned())
|
.and_then(|config| config.get("LastVersion").cloned())
|
||||||
.unwrap_or_else(|| "failed".to_string());
|
.unwrap_or_else(|| "failed".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_osu_release_stream(folder: String) -> String {
|
pub fn get_osu_release_stream(folder: String) -> String {
|
||||||
let path = PathBuf::from(folder);
|
let path = PathBuf::from(folder);
|
||||||
let osu_config = get_osu_config(path.clone());
|
let osu_config = get_osu_config(path);
|
||||||
return osu_config
|
osu_config
|
||||||
.and_then(|config| config.get("_ReleaseStream").cloned())
|
.and_then(|config| config.get("_ReleaseStream").cloned())
|
||||||
.unwrap_or_else(|| "Stable40".to_string());
|
.unwrap_or_else(|| "Stable40".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
@@ -261,10 +320,7 @@ pub fn set_osu_user_config_values(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|entry| (entry.key.as_str(), Some(entry.value.as_str())))
|
.map(|entry| (entry.key.as_str(), Some(entry.value.as_str())))
|
||||||
.collect();
|
.collect();
|
||||||
match set_osu_user_config_vals(&osu_folder_path, &converted) {
|
Ok(set_osu_user_config_vals(&osu_folder_path, &converted).is_ok())
|
||||||
Ok(_) => Ok(true),
|
|
||||||
Err(_) => Ok(false),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -276,22 +332,16 @@ pub fn set_osu_config_values(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|entry| (entry.key.as_str(), Some(entry.value.as_str())))
|
.map(|entry| (entry.key.as_str(), Some(entry.value.as_str())))
|
||||||
.collect();
|
.collect();
|
||||||
match set_osu_config_vals(&osu_folder_path, &converted) {
|
Ok(set_osu_config_vals(&osu_folder_path, &converted).is_ok())
|
||||||
Ok(_) => Ok(true),
|
|
||||||
Err(_) => Ok(false),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||||
#[cfg(windows)]
|
|
||||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
|
||||||
#[cfg(windows)]
|
|
||||||
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
|
||||||
|
|
||||||
let mut updater_process = {
|
let mut updater_process = {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||||
|
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
||||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||||
Command::new(&osu_exe_path)
|
Command::new(&osu_exe_path)
|
||||||
.arg("-repair")
|
.arg("-repair")
|
||||||
@@ -368,9 +418,6 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
||||||
/* #[cfg(windows)]
|
|
||||||
use std::os::windows::process::CommandExt; */
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -385,7 +432,7 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
.arg("ez-pp.farm")
|
.arg("ez-pp.farm")
|
||||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
.map_err(|e| format!("Failed to spawn osu: {}", e))?
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@@ -394,25 +441,52 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
.arg("--devserver")
|
.arg("--devserver")
|
||||||
.arg("ez-pp.farm")
|
.arg("ez-pp.farm")
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
.map_err(|e| format!("Failed to spawn osu: {}", e))?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if patch {
|
#[cfg(windows)]
|
||||||
sleep(Duration::from_secs(3)).await;
|
{
|
||||||
|
if patch {
|
||||||
|
let patcher_exe_path = PathBuf::from(&folder)
|
||||||
|
.join("EZPPLauncher")
|
||||||
|
.join("patcher")
|
||||||
|
.join("osu!.patcher.exe");
|
||||||
|
|
||||||
let patcher_exe_path = PathBuf::from(&folder)
|
if patcher_exe_path.exists() {
|
||||||
.join("EZPPLauncher")
|
#[cfg(windows)]
|
||||||
.join("patcher")
|
{
|
||||||
.join("osu!.patcher.exe");
|
let mut sys = System::new_all();
|
||||||
|
|
||||||
if patcher_exe_path.exists() {
|
loop {
|
||||||
#[cfg(windows)]
|
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||||
{
|
|
||||||
let _ = Command::new(&patcher_exe_path)
|
let mut found = false;
|
||||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
|
||||||
.spawn()
|
for (_pid, process) in sys.processes() {
|
||||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
if process.name() == "osu!.exe" {
|
||||||
|
let pid = process.pid();
|
||||||
|
let title = get_window_title_by_pid(pid);
|
||||||
|
|
||||||
|
if !title.is_empty() && !title.contains("updater") {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(500)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = Command::new(&patcher_exe_path)
|
||||||
|
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +631,6 @@ pub async fn download_ezpp_launcher_update_files(
|
|||||||
#[serde(tag = "type", content = "details")]
|
#[serde(tag = "type", content = "details")]
|
||||||
pub enum ReplaceUIError {
|
pub enum ReplaceUIError {
|
||||||
FileNotFound(String),
|
FileNotFound(String),
|
||||||
PermissionDenied(String),
|
|
||||||
IoError(String),
|
IoError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,44 +639,169 @@ pub fn replace_ui_files(folder: String, revert: bool) -> Result<(), ReplaceUIErr
|
|||||||
let osu_path = PathBuf::from(folder);
|
let osu_path = PathBuf::from(folder);
|
||||||
let ezpp_ui = osu_path.join("EZPPLauncher").join("ezpp!ui.dll");
|
let ezpp_ui = osu_path.join("EZPPLauncher").join("ezpp!ui.dll");
|
||||||
let osu_ui = osu_path.join("osu!ui.dll");
|
let osu_ui = osu_path.join("osu!ui.dll");
|
||||||
|
let ezpp_seasonal = osu_path.join("EZPPLauncher").join("ezpp!seasonal.dll");
|
||||||
|
let osu_seasonal = osu_path.join("osu!seasonal.dll");
|
||||||
let ezpp_gameplay = osu_path.join("EZPPLauncher").join("ezpp!gameplay.dll");
|
let ezpp_gameplay = osu_path.join("EZPPLauncher").join("ezpp!gameplay.dll");
|
||||||
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
||||||
|
|
||||||
let osu_ui_bak = osu_path.join("osu!ui.dll.bak");
|
let osu_ui_bak = osu_path.join("osu!ui.dll.bak");
|
||||||
|
let osu_seasonal_bak = osu_path.join("osu!seasonal.dll.bak");
|
||||||
let osu_gameplay_bak = osu_path.join("osu!gameplay.dll.bak");
|
let osu_gameplay_bak = osu_path.join("osu!gameplay.dll.bak");
|
||||||
|
|
||||||
let try_rename = |from: &PathBuf, to: &PathBuf| -> Result<(), ReplaceUIError> {
|
let temp_file = osu_path.join(".ezpplauncher_files");
|
||||||
if !from.exists() {
|
|
||||||
return Err(ReplaceUIError::FileNotFound(from.display().to_string()));
|
let copy_file = |source: &PathBuf, dest: &PathBuf, name: &str| -> Result<(), ReplaceUIError> {
|
||||||
|
if !source.exists() {
|
||||||
|
return Err(ReplaceUIError::FileNotFound(source.display().to_string()));
|
||||||
}
|
}
|
||||||
std::fs::rename(from, to).map_err(|e| match e.kind() {
|
|
||||||
std::io::ErrorKind::NotFound => {
|
if dest.exists() {
|
||||||
ReplaceUIError::FileNotFound(from.display().to_string())
|
std::fs::remove_file(dest).map_err(|e| {
|
||||||
}
|
ReplaceUIError::IoError(format!("Failed to remove {}: {}", name, e))
|
||||||
std::io::ErrorKind::PermissionDenied => {
|
})?;
|
||||||
ReplaceUIError::PermissionDenied(from.display().to_string())
|
}
|
||||||
}
|
|
||||||
_ => ReplaceUIError::IoError(e.to_string()),
|
std::fs::copy(source, dest)
|
||||||
})
|
.map_err(|e| ReplaceUIError::IoError(format!("Failed to copy {}: {}", name, e)))?;
|
||||||
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let restore_backup =
|
||||||
|
|bak: &PathBuf, dest: &PathBuf, name: &str| -> Result<(), ReplaceUIError> {
|
||||||
|
if bak.exists() {
|
||||||
|
if dest.exists() {
|
||||||
|
std::fs::remove_file(dest).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to remove {}: {}", name, e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
std::fs::rename(bak, dest).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to rename {} from backup: {}", name, e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
if !revert {
|
if !revert {
|
||||||
try_rename(&osu_ui, &osu_ui_bak)?;
|
if osu_ui.exists() && !osu_ui_bak.exists() {
|
||||||
try_rename(&ezpp_ui, &osu_ui)?;
|
std::fs::rename(&osu_ui, &osu_ui_bak).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to backup osu!ui.dll: {}", e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
if osu_seasonal.exists() && !osu_seasonal_bak.exists() {
|
||||||
|
std::fs::rename(&osu_seasonal, &osu_seasonal_bak).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to backup osu!seasonal.dll: {}", e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
if osu_gameplay.exists() && !osu_gameplay_bak.exists() {
|
||||||
|
std::fs::rename(&osu_gameplay, &osu_gameplay_bak).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to backup osu!gameplay.dll: {}", e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
try_rename(&osu_gameplay, &osu_gameplay_bak)?;
|
copy_file(&ezpp_ui, &osu_ui, "osu!ui.dll")?;
|
||||||
try_rename(&ezpp_gameplay, &osu_gameplay)?;
|
copy_file(&ezpp_seasonal, &osu_seasonal, "osu!seasonal.dll")?;
|
||||||
|
copy_file(&ezpp_gameplay, &osu_gameplay, "osu!gameplay.dll")?;
|
||||||
|
|
||||||
|
std::fs::write(&temp_file, b"1")
|
||||||
|
.map_err(|e| ReplaceUIError::IoError(format!("Failed to write marker file: {}", e)))?;
|
||||||
} else {
|
} else {
|
||||||
try_rename(&osu_ui, &ezpp_ui)?;
|
restore_backup(&osu_ui_bak, &osu_ui, "osu!ui.dll")?;
|
||||||
try_rename(&osu_ui_bak, &osu_ui)?;
|
restore_backup(&osu_seasonal_bak, &osu_seasonal, "osu!seasonal.dll")?;
|
||||||
|
restore_backup(&osu_gameplay_bak, &osu_gameplay, "osu!gameplay.dll")?;
|
||||||
|
|
||||||
try_rename(&osu_gameplay, &ezpp_gameplay)?;
|
if osu_ui.exists() && osu_seasonal.exists() && osu_gameplay.exists() {
|
||||||
try_rename(&osu_gameplay_bak, &osu_gameplay)?;
|
std::fs::remove_file(&temp_file).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to remove marker file: {}", e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(tag = "type", content = "details")]
|
||||||
|
pub enum CorruptionCheckError {
|
||||||
|
IoError(String),
|
||||||
|
FileNotFound(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn check_for_corruption(folder: String) -> Result<bool, CorruptionCheckError> {
|
||||||
|
let osu_path = PathBuf::from(folder);
|
||||||
|
let osu_ui = osu_path.join("osu!ui.dll");
|
||||||
|
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
||||||
|
let osu_seasonal = osu_path.join("osu!seasonal.dll");
|
||||||
|
|
||||||
|
let osu_ui_bak = osu_path.join("osu!ui.dll.bak");
|
||||||
|
let osu_gameplay_bak = osu_path.join("osu!gameplay.dll.bak");
|
||||||
|
let osu_seasonal_bak = osu_path.join("osu!seasonal.dll.bak");
|
||||||
|
|
||||||
|
let temp_file = osu_path.join(".ezpplauncher_files");
|
||||||
|
|
||||||
|
if temp_file.exists() {
|
||||||
|
if osu_ui_bak.exists() {
|
||||||
|
if osu_ui.exists() {
|
||||||
|
fs::remove_file(&osu_ui).await.map_err(|e| {
|
||||||
|
CorruptionCheckError::IoError(format!("Failed to remove osu!ui.dll: {}", e))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::rename(&osu_ui_bak, &osu_ui).await.map_err(|e| {
|
||||||
|
CorruptionCheckError::IoError(format!(
|
||||||
|
"Failed to restore osu!ui.dll from backup: {}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
if osu_gameplay_bak.exists() {
|
||||||
|
if osu_gameplay.exists() {
|
||||||
|
fs::remove_file(&osu_gameplay).await.map_err(|e| {
|
||||||
|
CorruptionCheckError::IoError(format!(
|
||||||
|
"Failed to remove osu!gameplay.dll: {}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::rename(&osu_gameplay_bak, &osu_gameplay)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
CorruptionCheckError::IoError(format!(
|
||||||
|
"Failed to restore osu!gameplay.dll from backup: {}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
if osu_seasonal_bak.exists() {
|
||||||
|
if osu_seasonal.exists() {
|
||||||
|
fs::remove_file(&osu_seasonal).await.map_err(|e| {
|
||||||
|
CorruptionCheckError::IoError(format!(
|
||||||
|
"Failed to remove osu!seasonal.dll: {}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::rename(&osu_seasonal_bak, &osu_seasonal)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
CorruptionCheckError::IoError(format!(
|
||||||
|
"Failed to restore osu!seasonal.dll from backup: {}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !osu_ui.exists() || !osu_gameplay.exists() || !osu_seasonal.exists() {
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn is_osu_running() -> bool {
|
pub fn is_osu_running() -> bool {
|
||||||
let mut sys = System::new_all();
|
let mut sys = System::new_all();
|
||||||
@@ -633,35 +831,6 @@ pub fn get_platform() -> String {
|
|||||||
std::env::consts::OS.to_string()
|
std::env::consts::OS.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn check_for_corruption(folder: String) -> Result<bool, String> {
|
|
||||||
let osu_path = PathBuf::from(folder);
|
|
||||||
let osu_ui = osu_path.join("osu!ui.dll");
|
|
||||||
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
|
||||||
|
|
||||||
let osu_ui_bak = osu_path.join("osu!ui.dll.bak");
|
|
||||||
let osu_gameplay_bak = osu_path.join("osu!gameplay.dll.bak");
|
|
||||||
|
|
||||||
let required_files = [&osu_ui, &osu_gameplay];
|
|
||||||
|
|
||||||
for file in &required_files {
|
|
||||||
if !file.exists() {
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let bak_files = [&osu_ui_bak, &osu_gameplay_bak];
|
|
||||||
for bak in &bak_files {
|
|
||||||
if bak.exists() {
|
|
||||||
if let Err(e) = fs::remove_file(bak).await {
|
|
||||||
return Err(format!("Failed to delete {}: {}", bak.display(), e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn presence_connect() -> bool {
|
pub async fn presence_connect() -> bool {
|
||||||
presence::connect().await
|
presence::connect().await
|
||||||
@@ -701,6 +870,21 @@ pub async fn presence_update_user(user: PresenceUser) {
|
|||||||
presence::update_user(user.username.as_deref(), user.id.as_deref());
|
presence::update_user(user.username.as_deref(), user.id.as_deref());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PresenceButton {
|
||||||
|
text: Option<String>,
|
||||||
|
url: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn presence_update_button(button: PresenceButton) {
|
||||||
|
match (button.text.as_deref(), button.url.as_deref()) {
|
||||||
|
(Some(text), Some(url)) => presence::set_button(text, url),
|
||||||
|
_ =>presence::clear_button()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn presence_is_connected() -> bool {
|
pub async fn presence_is_connected() -> bool {
|
||||||
presence::has_presence().await
|
presence::has_presence().await
|
||||||
@@ -723,12 +907,7 @@ pub async fn has_net8() -> bool {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn encrypt_string(string: String, entropy: String) -> String {
|
pub fn encrypt_string(string: String, entropy: String) -> String {
|
||||||
let encrypted = encrypt_password(&string, &entropy);
|
encrypt_password(&string, &entropy).unwrap_or(string)
|
||||||
|
|
||||||
match encrypted {
|
|
||||||
Ok(encrypted_vec) => encrypted_vec,
|
|
||||||
Err(_) => string,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -764,7 +943,7 @@ pub async fn download_ezpp_launcher_update(app: AppHandle, url: String) -> Resul
|
|||||||
UpdateStatus {
|
UpdateStatus {
|
||||||
file_name: "Update".to_string(),
|
file_name: "Update".to_string(),
|
||||||
downloaded,
|
downloaded,
|
||||||
size: size,
|
size,
|
||||||
progress: ((downloaded as f64 / size as f64 * 100.0) * 100.0).trunc() / 100.0,
|
progress: ((downloaded as f64 / size as f64 * 100.0) * 100.0).trunc() / 100.0,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -806,3 +985,69 @@ pub async fn install_ezpp_launcher_update(app: AppHandle) -> Result<(), String>
|
|||||||
pub async fn install_ezpp_launcher_update(_app: AppHandle) -> Result<(), String> {
|
pub async fn install_ezpp_launcher_update(_app: AppHandle) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn run_open_tablet_driver(path: String) -> Result<(), String> {
|
||||||
|
let otd_path = PathBuf::from(&path);
|
||||||
|
if !otd_path.exists() {
|
||||||
|
return Err(format!("OpenTabletDriver not found at: {}", path));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||||
|
#[cfg(windows)]
|
||||||
|
const CREATE_NEW_PROCESS_GROUP: u32 = 0x00000200;
|
||||||
|
|
||||||
|
{
|
||||||
|
#[cfg(windows)]
|
||||||
|
Command::new(&otd_path)
|
||||||
|
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("Failed to start OpenTabletDriver: {}", e))?;
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
Command::new(&otd_path)
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("Failed to start OpenTabletDriver: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn stop_open_tablet_driver(path: String) -> Result<(), String> {
|
||||||
|
let binary_name = PathBuf::from(&path)
|
||||||
|
.file_name()
|
||||||
|
.and_then(|n| n.to_str())
|
||||||
|
.ok_or("Invalid OpenTabletDriver path")?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let mut sys = System::new_all();
|
||||||
|
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||||
|
|
||||||
|
let process = sys.processes().values().find(|p| {
|
||||||
|
p.name().eq_ignore_ascii_case(&binary_name)
|
||||||
|
}).ok_or("OpenTabletDriver is not running")?;
|
||||||
|
|
||||||
|
process.kill();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn is_open_tablet_driver_running() -> bool {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
let mut sys = System::new_all();
|
||||||
|
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||||
|
|
||||||
|
sys.processes().values().any(|p| {
|
||||||
|
p.name().eq_ignore_ascii_case("OpenTabletDriver.Daemon.exe")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +1,92 @@
|
|||||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::Mutex;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
use tauri_plugin_fs::FsExt;
|
||||||
|
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
pub mod osudb;
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
check_for_corruption, download_ezpp_launcher_update, download_ezpp_launcher_update_files,
|
check_for_corruption, download_ezpp_launcher_update, download_ezpp_launcher_update_files,
|
||||||
encrypt_string, exit, find_osu_installation, get_beatmapsets_count,
|
encrypt_string, exit, find_osu_installation, get_beatmapsets_count,
|
||||||
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
|
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
|
||||||
get_osu_skin, get_osu_version, get_platform, get_skins_count, has_net8, has_osuwinello,
|
get_osu_skin, get_osu_version, get_platform, get_skins, get_skins_count, has_net8,
|
||||||
has_wmctrl, install_ezpp_launcher_update, is_osu_running, open_url_in_browser,
|
has_osuwinello, has_wmctrl, install_ezpp_launcher_update, is_osu_running, open_url_in_browser,
|
||||||
presence_connect, presence_disconnect, presence_is_connected, presence_update_status,
|
opened_urls, presence_connect, presence_disconnect, presence_is_connected,
|
||||||
presence_update_user, replace_ui_files, run_osu, run_osu_updater, set_osu_config_values,
|
presence_update_status, presence_update_user, presence_update_button, replace_ui_files, run_osu, run_osu_updater,
|
||||||
set_osu_user_config_values, valid_osu_folder,
|
set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OpenedUrls(Mutex<Vec<PathBuf>>);
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
unsafe {
|
unsafe {
|
||||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
// std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut builder = tauri::Builder::default();
|
let mut builder = tauri::Builder::default();
|
||||||
#[cfg(desktop)]
|
#[cfg(desktop)]
|
||||||
{
|
{
|
||||||
builder = builder.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
|
builder = builder.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
|
||||||
let app_window = app.get_webview_window("main").expect("no main window");
|
let app_window = app.get_webview_window("main").expect("no main window");
|
||||||
app_window.set_focus().expect("failed to focus");
|
app_window.set_focus().expect("failed to focus");
|
||||||
|
if args.len() > 1 {
|
||||||
|
use tauri::Emitter;
|
||||||
|
|
||||||
|
let mut files = Vec::new();
|
||||||
|
|
||||||
|
for maybe_file in args.iter().skip(1) {
|
||||||
|
if maybe_file.starts_with("-") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = PathBuf::from(maybe_file);
|
||||||
|
|
||||||
|
if path.extension().and_then(|e| e.to_str()) == Some("ezpplauncher-theme") {
|
||||||
|
app.fs_scope().allow_file(&path).ok();
|
||||||
|
files.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.emit("opened", files.clone()).ok();
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
let app = builder
|
let app = builder
|
||||||
|
.manage(OpenedUrls(Mutex::new(vec![])))
|
||||||
|
.setup(|app| {
|
||||||
|
let args = std::env::args().collect::<Vec<_>>();
|
||||||
|
if args.len() > 1 {
|
||||||
|
let mut files = Vec::new();
|
||||||
|
|
||||||
|
for maybe_file in args.iter().skip(1) {
|
||||||
|
if maybe_file.starts_with("-") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = PathBuf::from(maybe_file);
|
||||||
|
if path.extension().and_then(|e| e.to_str()) == Some("ezpplauncher-theme") {
|
||||||
|
app.fs_scope().allow_file(&path).ok();
|
||||||
|
files.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.state::<OpenedUrls>().0.lock().unwrap().extend(files);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
opened_urls,
|
||||||
get_hwid,
|
get_hwid,
|
||||||
find_osu_installation,
|
find_osu_installation,
|
||||||
valid_osu_folder,
|
valid_osu_folder,
|
||||||
get_beatmapsets_count,
|
get_beatmapsets_count,
|
||||||
|
get_skins,
|
||||||
get_skins_count,
|
get_skins_count,
|
||||||
get_osu_version,
|
get_osu_version,
|
||||||
get_osu_release_stream,
|
get_osu_release_stream,
|
||||||
@@ -58,6 +108,7 @@ pub fn run() {
|
|||||||
presence_disconnect,
|
presence_disconnect,
|
||||||
presence_update_status,
|
presence_update_status,
|
||||||
presence_update_user,
|
presence_update_user,
|
||||||
|
presence_update_button,
|
||||||
presence_is_connected,
|
presence_is_connected,
|
||||||
has_osuwinello,
|
has_osuwinello,
|
||||||
has_wmctrl,
|
has_wmctrl,
|
||||||
@@ -73,12 +124,7 @@ pub fn run() {
|
|||||||
.build(tauri::generate_context!())
|
.build(tauri::generate_context!())
|
||||||
.expect("error while building tauri application");
|
.expect("error while building tauri application");
|
||||||
|
|
||||||
app.run(|_app_handle, event| {
|
app.run(|app, event| {
|
||||||
if let tauri::RunEvent::ExitRequested { api, .. } = event {
|
presence::handle_run_event(app, &event);
|
||||||
api.prevent_exit();
|
|
||||||
|
|
||||||
tauri::async_runtime::block_on(presence::disconnect());
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,370 @@
|
|||||||
|
use std::io::{Cursor, Read};
|
||||||
|
|
||||||
|
use anyhow::{Result, anyhow};
|
||||||
|
use byteorder::{LittleEndian, ReadBytesExt};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
pub struct OsuReader {
|
||||||
|
cursor: Cursor<Vec<u8>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OsuReader {
|
||||||
|
pub fn new(data: Vec<u8>) -> Self {
|
||||||
|
Self {
|
||||||
|
cursor: Cursor::new(data),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_i16(&mut self) -> Result<i16> {
|
||||||
|
Ok(self.cursor.read_i16::<LittleEndian>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_i32(&mut self) -> Result<i32> {
|
||||||
|
Ok(self.cursor.read_i32::<LittleEndian>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_i64(&mut self) -> Result<i64> {
|
||||||
|
Ok(self.cursor.read_i64::<LittleEndian>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_u8(&mut self) -> Result<u8> {
|
||||||
|
Ok(self.cursor.read_u8()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_f32(&mut self) -> Result<f32> {
|
||||||
|
Ok(self.cursor.read_f32::<LittleEndian>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_f64(&mut self) -> Result<f64> {
|
||||||
|
Ok(self.cursor.read_f64::<LittleEndian>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_bool(&mut self) -> Result<bool> {
|
||||||
|
Ok(self.read_u8()? != 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_string(&mut self) -> Result<Option<String>> {
|
||||||
|
let indicator = self.read_u8()?;
|
||||||
|
|
||||||
|
if indicator == 0 {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
if indicator != 0x0B {
|
||||||
|
return Err(anyhow!("Invalid osu string indicator"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let len = self.read_uleb128()? as usize;
|
||||||
|
let mut buf = vec![0; len];
|
||||||
|
self.cursor.read_exact(&mut buf)?;
|
||||||
|
|
||||||
|
Ok(Some(String::from_utf8(buf)?))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_uleb128(&mut self) -> Result<u64> {
|
||||||
|
let mut result = 0;
|
||||||
|
let mut shift = 0;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let byte = self.read_u8()?;
|
||||||
|
result |= ((byte & 0x7F) as u64) << shift;
|
||||||
|
|
||||||
|
if (byte & 0x80) == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
shift += 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TimingPoint {
|
||||||
|
pub bpm: f64,
|
||||||
|
pub offset: f64,
|
||||||
|
pub inherited: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Beatmap {
|
||||||
|
pub artist_name: Option<String>,
|
||||||
|
pub artist_unicode: Option<String>,
|
||||||
|
pub song_title: Option<String>,
|
||||||
|
pub song_title_unicode: Option<String>,
|
||||||
|
pub creator: Option<String>,
|
||||||
|
pub difficulty: Option<String>,
|
||||||
|
pub audio: Option<String>,
|
||||||
|
pub md5: Option<String>,
|
||||||
|
pub osu_file_name: Option<String>,
|
||||||
|
|
||||||
|
pub ranked_status: u8,
|
||||||
|
pub hitcircles: i16,
|
||||||
|
pub slider_count: i16,
|
||||||
|
pub spinner_count: i16,
|
||||||
|
pub last_modification: i64,
|
||||||
|
|
||||||
|
pub approach_rate: f32,
|
||||||
|
pub circle_size: f32,
|
||||||
|
pub hp_drain: f32,
|
||||||
|
pub overall_difficulty: f32,
|
||||||
|
pub slider_velocity: f64,
|
||||||
|
|
||||||
|
pub difficulties: HashMap<i32, f64>,
|
||||||
|
|
||||||
|
pub drain_time: i32,
|
||||||
|
pub total_time: i32,
|
||||||
|
pub preview_offset: i32,
|
||||||
|
|
||||||
|
pub beatmap_id: i32,
|
||||||
|
pub beatmapset_id: i32,
|
||||||
|
pub thread_id: i32,
|
||||||
|
|
||||||
|
pub grade_standard: u8,
|
||||||
|
pub grade_taiko: u8,
|
||||||
|
pub grade_catch: u8,
|
||||||
|
pub grade_mania: u8,
|
||||||
|
|
||||||
|
pub local_beatmap_offset: i16,
|
||||||
|
pub stack_leniency: f32,
|
||||||
|
|
||||||
|
pub mode: u8,
|
||||||
|
pub song_source: Option<String>,
|
||||||
|
pub song_tags: Option<String>,
|
||||||
|
|
||||||
|
pub online_beatmap_offset: i16,
|
||||||
|
pub title_font: Option<String>,
|
||||||
|
|
||||||
|
pub unplayed: bool,
|
||||||
|
pub last_played: i64,
|
||||||
|
pub osz2: bool,
|
||||||
|
pub folder_name: Option<String>,
|
||||||
|
pub last_checked_against_repository: i64,
|
||||||
|
|
||||||
|
pub ignore_sound: bool,
|
||||||
|
pub ignore_skin: bool,
|
||||||
|
pub disable_storyboard: bool,
|
||||||
|
pub disable_video: bool,
|
||||||
|
pub visual_override: bool,
|
||||||
|
|
||||||
|
pub last_modification_time: i32,
|
||||||
|
pub mania_scroll_speed: u8,
|
||||||
|
|
||||||
|
pub timing_points: Vec<TimingPoint>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct OsuDbData {
|
||||||
|
pub osuver: i32,
|
||||||
|
pub folder_count: i32,
|
||||||
|
pub is_unlocked: bool,
|
||||||
|
pub date_unlock_ticks: i64,
|
||||||
|
pub username: Option<String>,
|
||||||
|
pub beatmaps: Vec<Beatmap>,
|
||||||
|
pub userperms: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// =========================
|
||||||
|
// PARSER
|
||||||
|
// =========================
|
||||||
|
//
|
||||||
|
|
||||||
|
pub fn parse_osudb(bytes: Vec<u8>) -> Result<OsuDbData> {
|
||||||
|
let mut reader = OsuReader::new(bytes);
|
||||||
|
|
||||||
|
let osuver = reader.read_i32()?;
|
||||||
|
let folder_count = reader.read_i32()?;
|
||||||
|
let is_unlocked = reader.read_bool()?;
|
||||||
|
let date_unlock_ticks = reader.read_i64()?;
|
||||||
|
let username = reader.read_string()?;
|
||||||
|
let beatmaps_count = reader.read_i32()?;
|
||||||
|
|
||||||
|
let mut beatmaps = Vec::new();
|
||||||
|
|
||||||
|
for _ in 0..beatmaps_count {
|
||||||
|
if osuver < 20191107 {
|
||||||
|
reader.read_i32()?; // entry size
|
||||||
|
}
|
||||||
|
|
||||||
|
let artist_name = reader.read_string()?;
|
||||||
|
let artist_unicode = reader.read_string()?;
|
||||||
|
let song_title = reader.read_string()?;
|
||||||
|
let song_title_unicode = reader.read_string()?;
|
||||||
|
let creator = reader.read_string()?;
|
||||||
|
let difficulty = reader.read_string()?;
|
||||||
|
let audio = reader.read_string()?;
|
||||||
|
let md5 = reader.read_string()?;
|
||||||
|
let osu_file_name = reader.read_string()?;
|
||||||
|
|
||||||
|
let ranked_status = reader.read_u8()?;
|
||||||
|
let hitcircles = reader.read_i16()?;
|
||||||
|
let slider_count = reader.read_i16()?;
|
||||||
|
let spinner_count = reader.read_i16()?;
|
||||||
|
let last_modification = reader.read_i64()?;
|
||||||
|
|
||||||
|
let approach_rate = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let circle_size = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let hp_drain = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let overall_difficulty = if osuver < 20140609 {
|
||||||
|
reader.read_u8()? as f32
|
||||||
|
} else {
|
||||||
|
reader.read_f32()?
|
||||||
|
};
|
||||||
|
|
||||||
|
let slider_velocity = reader.read_f64()?;
|
||||||
|
|
||||||
|
let mut difficulties: HashMap<i32, f64> = HashMap::new();
|
||||||
|
|
||||||
|
if osuver >= 20140609 {
|
||||||
|
for _ in 0..4 {
|
||||||
|
let len = reader.read_i32()?;
|
||||||
|
for _ in 0..len {
|
||||||
|
reader.read_u8()?;
|
||||||
|
let mode = reader.read_i32()?;
|
||||||
|
reader.read_u8()?;
|
||||||
|
let diff = if osuver > 20250107 {
|
||||||
|
reader.read_f32()? as f64
|
||||||
|
} else {
|
||||||
|
reader.read_f64()?
|
||||||
|
};
|
||||||
|
|
||||||
|
difficulties.insert(mode, diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let drain_time = reader.read_i32()?;
|
||||||
|
let total_time = reader.read_i32()?;
|
||||||
|
let preview_offset = reader.read_i32()?;
|
||||||
|
|
||||||
|
let timing_len = reader.read_i32()?;
|
||||||
|
let mut timing_points = Vec::new();
|
||||||
|
for _ in 0..timing_len {
|
||||||
|
timing_points.push(TimingPoint {
|
||||||
|
bpm: reader.read_f64()?,
|
||||||
|
offset: reader.read_f64()?,
|
||||||
|
inherited: reader.read_bool()?,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let beatmap_id = reader.read_i32()?;
|
||||||
|
let beatmapset_id = reader.read_i32()?;
|
||||||
|
let thread_id = reader.read_i32()?;
|
||||||
|
|
||||||
|
let grade_standard = reader.read_u8()?;
|
||||||
|
let grade_taiko = reader.read_u8()?;
|
||||||
|
let grade_catch = reader.read_u8()?;
|
||||||
|
let grade_mania = reader.read_u8()?;
|
||||||
|
|
||||||
|
let local_beatmap_offset = reader.read_i16()?;
|
||||||
|
let stack_leniency = reader.read_f32()?;
|
||||||
|
|
||||||
|
let mode = reader.read_u8()?;
|
||||||
|
let song_source = reader.read_string()?;
|
||||||
|
let song_tags = reader.read_string()?;
|
||||||
|
|
||||||
|
let online_beatmap_offset = reader.read_i16()?;
|
||||||
|
let title_font = reader.read_string()?;
|
||||||
|
|
||||||
|
let unplayed = reader.read_bool()?;
|
||||||
|
let last_played = reader.read_i64()?;
|
||||||
|
let osz2 = reader.read_bool()?;
|
||||||
|
let folder_name = reader.read_string()?;
|
||||||
|
let last_checked_against_repository = reader.read_i64()?;
|
||||||
|
|
||||||
|
let ignore_sound = reader.read_bool()?;
|
||||||
|
let ignore_skin = reader.read_bool()?;
|
||||||
|
let disable_storyboard = reader.read_bool()?;
|
||||||
|
let disable_video = reader.read_bool()?;
|
||||||
|
let visual_override = reader.read_bool()?;
|
||||||
|
|
||||||
|
if osuver < 20140609 {
|
||||||
|
reader.read_i16()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let last_modification_time = reader.read_i32()?;
|
||||||
|
let mania_scroll_speed = reader.read_u8()?;
|
||||||
|
|
||||||
|
beatmaps.push(Beatmap {
|
||||||
|
artist_name,
|
||||||
|
artist_unicode,
|
||||||
|
song_title,
|
||||||
|
song_title_unicode,
|
||||||
|
creator,
|
||||||
|
difficulty,
|
||||||
|
audio,
|
||||||
|
md5,
|
||||||
|
osu_file_name,
|
||||||
|
ranked_status,
|
||||||
|
hitcircles,
|
||||||
|
slider_count,
|
||||||
|
spinner_count,
|
||||||
|
last_modification,
|
||||||
|
approach_rate,
|
||||||
|
circle_size,
|
||||||
|
hp_drain,
|
||||||
|
overall_difficulty,
|
||||||
|
slider_velocity,
|
||||||
|
difficulties,
|
||||||
|
drain_time,
|
||||||
|
total_time,
|
||||||
|
preview_offset,
|
||||||
|
beatmap_id,
|
||||||
|
beatmapset_id,
|
||||||
|
thread_id,
|
||||||
|
grade_standard,
|
||||||
|
grade_taiko,
|
||||||
|
grade_catch,
|
||||||
|
grade_mania,
|
||||||
|
local_beatmap_offset,
|
||||||
|
stack_leniency,
|
||||||
|
mode,
|
||||||
|
song_source,
|
||||||
|
song_tags,
|
||||||
|
online_beatmap_offset,
|
||||||
|
title_font,
|
||||||
|
unplayed,
|
||||||
|
last_played,
|
||||||
|
osz2,
|
||||||
|
folder_name,
|
||||||
|
last_checked_against_repository,
|
||||||
|
ignore_sound,
|
||||||
|
ignore_skin,
|
||||||
|
disable_storyboard,
|
||||||
|
disable_video,
|
||||||
|
visual_override,
|
||||||
|
last_modification_time,
|
||||||
|
mania_scroll_speed,
|
||||||
|
timing_points,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let userperms = reader.read_i32()?;
|
||||||
|
|
||||||
|
Ok(OsuDbData {
|
||||||
|
osuver,
|
||||||
|
folder_count,
|
||||||
|
is_unlocked,
|
||||||
|
date_unlock_ticks,
|
||||||
|
username,
|
||||||
|
beatmaps,
|
||||||
|
userperms,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
use discord_rich_presence::{
|
|
||||||
activity::{Activity, Assets, Button, Timestamps},
|
|
||||||
DiscordIpc, DiscordIpcClient,
|
|
||||||
};
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use presenceforge::{ActivityBuilder, AsyncDiscordIpcClient};
|
||||||
use std::sync::Mutex as StdMutex;
|
use std::sync::Mutex as StdMutex;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
use tauri::{AppHandle, RunEvent};
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
use tokio::time::{interval, Duration};
|
use tokio::time::{Duration, interval};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct PresenceButton {
|
||||||
|
pub label: String,
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PresenceData {
|
pub struct PresenceData {
|
||||||
@@ -16,6 +20,21 @@ pub struct PresenceData {
|
|||||||
pub large_image_text: String,
|
pub large_image_text: String,
|
||||||
pub small_image_key: Option<String>,
|
pub small_image_key: Option<String>,
|
||||||
pub small_image_text: Option<String>,
|
pub small_image_text: Option<String>,
|
||||||
|
pub dynamic_button: Option<PresenceButton>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for PresenceData {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
state: "Idle in Launcher...".to_string(),
|
||||||
|
details: " ".to_string(),
|
||||||
|
large_image_key: "ezppfarm".to_string(),
|
||||||
|
large_image_text: "EZPPFarm".to_string(),
|
||||||
|
small_image_key: None,
|
||||||
|
small_image_text: None,
|
||||||
|
dynamic_button: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -26,11 +45,19 @@ enum PresenceCommand {
|
|||||||
IsConnected(oneshot::Sender<bool>),
|
IsConnected(oneshot::Sender<bool>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ReconnectResult {
|
||||||
|
Connected(AsyncDiscordIpcClient),
|
||||||
|
Failed,
|
||||||
|
}
|
||||||
|
|
||||||
struct PresenceActor {
|
struct PresenceActor {
|
||||||
receiver: mpsc::Receiver<PresenceCommand>,
|
receiver: mpsc::Receiver<PresenceCommand>,
|
||||||
client: Option<DiscordIpcClient>,
|
reconnect_rx: mpsc::Receiver<ReconnectResult>,
|
||||||
|
reconnect_tx: mpsc::Sender<ReconnectResult>,
|
||||||
|
client: Option<AsyncDiscordIpcClient>,
|
||||||
data: PresenceData,
|
data: PresenceData,
|
||||||
start_timestamp: i64,
|
start_timestamp: i64,
|
||||||
|
reconnecting: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PresenceActor {
|
impl PresenceActor {
|
||||||
@@ -40,141 +67,184 @@ impl PresenceActor {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.as_secs() as i64;
|
.as_secs() as i64;
|
||||||
|
|
||||||
let data = PresenceData {
|
let (reconnect_tx, reconnect_rx) = mpsc::channel(1);
|
||||||
state: "Idle in Launcher...".to_string(),
|
|
||||||
details: " ".to_string(),
|
|
||||||
large_image_key: "ezppfarm".to_string(),
|
|
||||||
large_image_text: "EZPPFarm".to_string(),
|
|
||||||
small_image_key: None,
|
|
||||||
small_image_text: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
PresenceActor {
|
Self {
|
||||||
receiver,
|
receiver,
|
||||||
|
reconnect_rx,
|
||||||
|
reconnect_tx,
|
||||||
client: None,
|
client: None,
|
||||||
data,
|
data: PresenceData::default(),
|
||||||
start_timestamp: start,
|
start_timestamp: start,
|
||||||
|
reconnecting: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run(&mut self) {
|
async fn run(&mut self) {
|
||||||
let mut update_interval = interval(Duration::from_millis(2500));
|
let mut heartbeat = interval(Duration::from_secs(5));
|
||||||
|
heartbeat.tick().await;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
Some(cmd) = self.receiver.recv() => {
|
Some(cmd) = self.receiver.recv() => {
|
||||||
match cmd {
|
match cmd {
|
||||||
PresenceCommand::Connect(responder) => self.handle_connect(responder).await,
|
PresenceCommand::Connect(resp) => self.cmd_connect(resp).await,
|
||||||
PresenceCommand::Disconnect(responder) => {
|
PresenceCommand::Disconnect(resp) => self.cmd_disconnect(resp).await,
|
||||||
self.handle_disconnect(responder).await;
|
PresenceCommand::UpdateData(data) => {
|
||||||
},
|
self.data = data;
|
||||||
PresenceCommand::UpdateData(new_data) => {
|
self.push_presence().await;
|
||||||
self.data = new_data;
|
}
|
||||||
},
|
PresenceCommand::IsConnected(resp) => {
|
||||||
PresenceCommand::IsConnected(responder) => {
|
let _ = resp.send(self.client.is_some());
|
||||||
let _ = responder.send(self.client.is_some());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = update_interval.tick() => {
|
|
||||||
if self.client.is_some() {
|
Some(result) = self.reconnect_rx.recv() => {
|
||||||
self.handle_update().await;
|
self.reconnecting = false;
|
||||||
|
match result {
|
||||||
|
ReconnectResult::Connected(client) => {
|
||||||
|
println!("Presence: reconnect succeeded.");
|
||||||
|
self.client = Some(client);
|
||||||
|
self.push_presence().await;
|
||||||
|
}
|
||||||
|
ReconnectResult::Failed => {
|
||||||
|
eprintln!("Presence: all reconnect attempts exhausted.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = heartbeat.tick() => {
|
||||||
|
self.push_presence().await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_connect(&mut self, responder: oneshot::Sender<bool>) {
|
async fn cmd_connect(&mut self, resp: oneshot::Sender<bool>) {
|
||||||
if self.client.is_some() {
|
if self.client.is_some() {
|
||||||
let _ = responder.send(true);
|
let _ = resp.send(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Actor: Connecting to Discord...");
|
match try_connect_once().await {
|
||||||
match DiscordIpcClient::new("1032772293220384808").map_err(|e| e.to_string()) {
|
Some(client) => {
|
||||||
Ok(mut new_client) => {
|
self.client = Some(client);
|
||||||
if let Err(e) = new_client.connect().map_err(|e| e.to_string()) {
|
self.reconnecting = false;
|
||||||
eprintln!("Failed to connect to Discord: {:?}", e);
|
self.push_presence().await;
|
||||||
let _ = responder.send(false);
|
let _ = resp.send(true);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("Presence: initial connect failed; spawning reconnect task.");
|
||||||
|
let _ = resp.send(false);
|
||||||
|
self.spawn_reconnect_task();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn cmd_disconnect(&mut self, resp: oneshot::Sender<()>) {
|
||||||
|
if let Some(mut client) = self.client.take() {
|
||||||
|
let _ = client.clear_activity().await;
|
||||||
|
println!("Presence: disconnected.");
|
||||||
|
}
|
||||||
|
let _ = resp.send(());
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn push_presence(&mut self) {
|
||||||
|
let client = match self.client.as_mut() {
|
||||||
|
Some(c) => c,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut builder = ActivityBuilder::new()
|
||||||
|
.state(&self.data.state)
|
||||||
|
.details(&self.data.details)
|
||||||
|
.start_timestamp(self.start_timestamp as u64)
|
||||||
|
.large_image(&self.data.large_image_key)
|
||||||
|
.large_text(&self.data.large_image_text);
|
||||||
|
|
||||||
|
if let Some(key) = &self.data.small_image_key {
|
||||||
|
builder = builder.small_image(key);
|
||||||
|
}
|
||||||
|
if let Some(text) = &self.data.small_image_text {
|
||||||
|
builder = builder.small_text(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(btn) = &self.data.dynamic_button {
|
||||||
|
builder = builder.button(&btn.label, &btn.url);
|
||||||
|
} else {
|
||||||
|
builder = builder.button(
|
||||||
|
"Download the Launcher",
|
||||||
|
"https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
builder = builder.button("Join EZPPFarm", "https://ez-pp.farm/discord");
|
||||||
|
|
||||||
|
let activity = builder.build();
|
||||||
|
|
||||||
|
/* println!("Presence: updating activity: {:?}", activity); */
|
||||||
|
if let Err(e) = client.set_activity(&activity).await {
|
||||||
|
eprintln!("Presence: set_activity failed ({:?}); will reconnect.", e);
|
||||||
|
self.client = None;
|
||||||
|
self.spawn_reconnect_task();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn_reconnect_task(&mut self) {
|
||||||
|
if self.reconnecting {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.reconnecting = true;
|
||||||
|
|
||||||
|
let tx = self.reconnect_tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
const MAX_ATTEMPTS: u32 = 5;
|
||||||
|
for attempt in 1..=MAX_ATTEMPTS {
|
||||||
|
let delay = Duration::from_secs(5 * attempt as u64);
|
||||||
|
println!(
|
||||||
|
"Presence: reconnect attempt {}/{} in {:?}…",
|
||||||
|
attempt, MAX_ATTEMPTS, delay
|
||||||
|
);
|
||||||
|
tokio::time::sleep(delay).await;
|
||||||
|
|
||||||
|
if let Some(client) = try_connect_once().await {
|
||||||
|
let _ = tx.send(ReconnectResult::Connected(client)).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.client = Some(new_client);
|
}
|
||||||
println!("Actor: Connected successfully.");
|
let _ = tx.send(ReconnectResult::Failed).await;
|
||||||
self.handle_update().await;
|
});
|
||||||
let _ = responder.send(true);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn try_connect_once() -> Option<AsyncDiscordIpcClient> {
|
||||||
|
match AsyncDiscordIpcClient::new("1032772293220384808").await {
|
||||||
|
Ok(mut client) => match client.connect().await {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("Presence: IPC connected.");
|
||||||
|
Some(client)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to create Discord client: {:?}", e);
|
eprintln!("Presence: IPC connect error: {:?}", e);
|
||||||
let _ = responder.send(false);
|
None
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_disconnect(&mut self, responder: oneshot::Sender<()>) {
|
|
||||||
if let Some(mut client) = self.client.take() {
|
|
||||||
println!("Actor: Disconnecting...");
|
|
||||||
let _ = client.clear_activity().map_err(|e| e.to_string());
|
|
||||||
let _ = client.close().map_err(|e| e.to_string());
|
|
||||||
println!("Actor: Disconnected successfully.");
|
|
||||||
}
|
|
||||||
let _ = responder.send(());
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_update(&mut self) {
|
|
||||||
if let Some(client) = self.client.as_mut() {
|
|
||||||
let mut assets = Assets::new()
|
|
||||||
.large_image(&self.data.large_image_key)
|
|
||||||
.large_text(&self.data.large_image_text);
|
|
||||||
|
|
||||||
if let Some(key) = &self.data.small_image_key {
|
|
||||||
assets = assets.small_image(key);
|
|
||||||
}
|
|
||||||
if let Some(text) = &self.data.small_image_text {
|
|
||||||
assets = assets.small_text(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
let activity = Activity::new()
|
|
||||||
.state(&self.data.state)
|
|
||||||
.details(&self.data.details)
|
|
||||||
.timestamps(Timestamps::new().start(self.start_timestamp))
|
|
||||||
.assets(assets)
|
|
||||||
.buttons(vec![
|
|
||||||
Button::new(
|
|
||||||
"Download the Launcher",
|
|
||||||
"https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest",
|
|
||||||
),
|
|
||||||
Button::new("Join EZPPFarm", "https://ez-pp.farm/discord"),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if let Err(e) = client.set_activity(activity).map_err(|e| e.to_string()) {
|
|
||||||
eprintln!("Failed to set activity, disconnecting: {:?}", e);
|
|
||||||
if let Some(mut client) = self.client.take() {
|
|
||||||
let _ = client.clear_activity();
|
|
||||||
let _ = client.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Presence: failed to create client: {:?}", e);
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRESENCE_TX: Lazy<mpsc::Sender<PresenceCommand>> = Lazy::new(|| {
|
static PRESENCE_TX: Lazy<mpsc::Sender<PresenceCommand>> = Lazy::new(|| {
|
||||||
let (tx, rx) = mpsc::channel(10);
|
let (tx, rx) = mpsc::channel(32);
|
||||||
let mut actor = PresenceActor::new(rx);
|
let mut actor = PresenceActor::new(rx);
|
||||||
tokio::spawn(async move { actor.run().await });
|
tokio::spawn(async move { actor.run().await });
|
||||||
tx
|
tx
|
||||||
});
|
});
|
||||||
|
|
||||||
pub static PRESENCE_DATA: Lazy<StdMutex<PresenceData>> = Lazy::new(|| {
|
pub static PRESENCE_DATA: Lazy<StdMutex<PresenceData>> =
|
||||||
StdMutex::new(PresenceData {
|
Lazy::new(|| StdMutex::new(PresenceData::default()));
|
||||||
state: "Idle in Launcher...".to_string(),
|
|
||||||
details: " ".to_string(),
|
|
||||||
large_image_key: "ezppfarm".to_string(),
|
|
||||||
large_image_text: "EZPPFarm".to_string(),
|
|
||||||
small_image_key: None,
|
|
||||||
small_image_text: None,
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
pub async fn connect() -> bool {
|
pub async fn connect() -> bool {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
@@ -187,45 +257,90 @@ pub async fn connect() -> bool {
|
|||||||
pub async fn disconnect() {
|
pub async fn disconnect() {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
if PRESENCE_TX.send(PresenceCommand::Disconnect(tx)).await.is_ok() {
|
if PRESENCE_TX.send(PresenceCommand::Disconnect(tx)).await.is_ok() {
|
||||||
let _ = rx.await;
|
let _ = tokio::time::timeout(Duration::from_secs(2), rx).await;
|
||||||
} else {
|
|
||||||
println!("Could not send disconnect command; actor may not be running.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn has_presence() -> bool {
|
pub async fn has_presence() -> bool {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
if PRESENCE_TX.send(PresenceCommand::IsConnected(tx)).await.is_ok() {
|
if PRESENCE_TX
|
||||||
|
.send(PresenceCommand::IsConnected(tx))
|
||||||
|
.await
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
return rx.await.unwrap_or(false);
|
return rx.await.unwrap_or(false);
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_status(state: Option<&str>, details: Option<&str>, large_image_key: Option<&str>) {
|
pub fn update_status(state: Option<&str>, details: Option<&str>, large_image_key: Option<&str>) {
|
||||||
let mut data = PRESENCE_DATA.lock().unwrap();
|
let data = {
|
||||||
if let Some(s) = state {
|
let mut guard = PRESENCE_DATA.lock().unwrap();
|
||||||
data.state = s.to_string();
|
if let Some(s) = state {
|
||||||
}
|
guard.state = s.to_string();
|
||||||
if let Some(d) = details {
|
}
|
||||||
data.details = d.to_string();
|
if let Some(d) = details {
|
||||||
}
|
guard.details = d.to_string();
|
||||||
if let Some(img) = large_image_key {
|
}
|
||||||
data.large_image_key = img.to_string();
|
if let Some(img) = large_image_key {
|
||||||
}
|
guard.large_image_key = img.to_string();
|
||||||
let data_clone = data.clone();
|
}
|
||||||
|
guard.clone()
|
||||||
|
};
|
||||||
|
|
||||||
let tx = PRESENCE_TX.clone();
|
let tx = PRESENCE_TX.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let _ = tx.send(PresenceCommand::UpdateData(data_clone)).await;
|
let _ = tx.send(PresenceCommand::UpdateData(data)).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_user(username: Option<&str>, id: Option<&str>) {
|
pub fn update_user(username: Option<&str>, id: Option<&str>) {
|
||||||
let mut data = PRESENCE_DATA.lock().unwrap();
|
let data = {
|
||||||
data.small_image_key = id.map(|id_str| format!("https://a.ez-pp.farm/{}", id_str));
|
let mut guard = PRESENCE_DATA.lock().unwrap();
|
||||||
data.small_image_text = username.map(|s| s.to_string());
|
guard.small_image_key = id.map(|s| format!("https://a.ez-pp.farm/{}", s));
|
||||||
let data_clone = data.clone();
|
guard.small_image_text = username.map(str::to_string);
|
||||||
|
guard.clone()
|
||||||
|
};
|
||||||
|
|
||||||
let tx = PRESENCE_TX.clone();
|
let tx = PRESENCE_TX.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let _ = tx.send(PresenceCommand::UpdateData(data_clone)).await;
|
let _ = tx.send(PresenceCommand::UpdateData(data)).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_button(label: &str, url: &str) {
|
||||||
|
let data = {
|
||||||
|
let mut guard = PRESENCE_DATA.lock().unwrap();
|
||||||
|
guard.dynamic_button = Some(PresenceButton {
|
||||||
|
label: label.to_string(),
|
||||||
|
url: url.to_string(),
|
||||||
|
});
|
||||||
|
guard.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let tx = PRESENCE_TX.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(PresenceCommand::UpdateData(data)).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clear_button() {
|
||||||
|
let data = {
|
||||||
|
let mut guard = PRESENCE_DATA.lock().unwrap();
|
||||||
|
guard.dynamic_button = None;
|
||||||
|
guard.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let tx = PRESENCE_TX.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(PresenceCommand::UpdateData(data)).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn handle_run_event(_app: &AppHandle, event: &RunEvent) {
|
||||||
|
if let RunEvent::ExitRequested { .. } | RunEvent::Exit = event {
|
||||||
|
tauri::async_runtime::block_on(async {
|
||||||
|
disconnect().await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -286,8 +286,18 @@ pub fn get_window_title_by_pid(pid: Pid) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn is_net8_installed() -> bool {
|
pub async fn is_net8_installed() -> bool {
|
||||||
use std::process::Command;
|
use tokio::process::Command;
|
||||||
let output_result = Command::new("dotnet").arg("--list-runtimes").output();
|
|
||||||
|
let mut command = Command::new("dotnet");
|
||||||
|
command.arg("--list-runtimes");
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
command.creation_flags(CREATE_NO_WINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
let output_result = command.output().await;
|
||||||
match output_result {
|
match output_result {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
@@ -300,9 +310,7 @@ pub async fn is_net8_installed() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let stdout_str = String::from_utf8_lossy(&output.stdout);
|
let stdout_str = String::from_utf8_lossy(&output.stdout);
|
||||||
stdout_str
|
stdout_str.lines().any(|line| line.starts_with("Microsoft.WindowsDesktop.App 8."))
|
||||||
.lines()
|
|
||||||
.any(|line| line.starts_with("Microsoft.WindowsDesktop.App 8."))
|
|
||||||
}
|
}
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "EZPPLauncher",
|
"productName": "EZPPLauncher",
|
||||||
"version": "3.0.4",
|
"version": "3.2.1",
|
||||||
"identifier": "farm.EZPPFarm.Launcher",
|
"identifier": "farm.EZPPFarm.Launcher",
|
||||||
"mainBinaryName": "ezpplauncher",
|
"mainBinaryName": "ezpplauncher",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "bun run vite:dev",
|
"beforeDevCommand": "bun run vite:dev",
|
||||||
"devUrl": "http://localhost:1420",
|
"devUrl": "http://localhost:1420",
|
||||||
"beforeBuildCommand": "bun run vite:build",
|
"beforeBuildCommand": "",
|
||||||
"frontendDist": "../build"
|
"frontendDist": "../build"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
@@ -15,20 +15,31 @@
|
|||||||
{
|
{
|
||||||
"title": "EZPPLauncher",
|
"title": "EZPPLauncher",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 700,
|
"height": 650,
|
||||||
|
"minWidth": 1000,
|
||||||
|
"minHeight": 650,
|
||||||
"decorations": false,
|
"decorations": false,
|
||||||
"resizable": false,
|
"resizable": false,
|
||||||
"maximizable": false
|
"maximizable": false,
|
||||||
|
"shadow": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"withGlobalTauri": true,
|
"withGlobalTauri": true,
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": "default-src 'self' tauri: asset:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' asset: data: blob: https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct; connect-src 'self' https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct; media-src 'self' asset: blob:;",
|
||||||
|
"assetProtocol": {
|
||||||
|
"enable": true,
|
||||||
|
"scope": [
|
||||||
|
"$HOME/.ezpplauncher/themes/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"publisher": "EZPPFarm",
|
"publisher": "EZPPFarm",
|
||||||
"copyright": "EZPPFarm",
|
"copyright": "EZPPFarm",
|
||||||
|
"shortDescription": "osu! launcher for EZPPFarm",
|
||||||
|
"longDescription": "EZPPLauncher is a custom osu! launcher for the EZPPFarm server, featuring automatic updates, ingame login, stat tracking and launcher theming.",
|
||||||
"homepage": "https://ez-pp.farm",
|
"homepage": "https://ez-pp.farm",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"active": true,
|
"active": true,
|
||||||
@@ -36,6 +47,17 @@
|
|||||||
"nsis",
|
"nsis",
|
||||||
"appimage"
|
"appimage"
|
||||||
],
|
],
|
||||||
|
"fileAssociations": [
|
||||||
|
{
|
||||||
|
"ext": [
|
||||||
|
"ezpplauncher-theme"
|
||||||
|
],
|
||||||
|
"name": "EZPPLauncher Theme",
|
||||||
|
"description": "EZPPLauncher Theme File",
|
||||||
|
"role": "Viewer",
|
||||||
|
"mimeType": "application/x-ezpplauncher-theme"
|
||||||
|
}
|
||||||
|
],
|
||||||
"windows": {
|
"windows": {
|
||||||
"webviewInstallMode": {
|
"webviewInstallMode": {
|
||||||
"silent": true,
|
"silent": true,
|
||||||
@@ -44,7 +66,8 @@
|
|||||||
"nsis": {
|
"nsis": {
|
||||||
"installMode": "currentUser",
|
"installMode": "currentUser",
|
||||||
"compression": "lzma",
|
"compression": "lzma",
|
||||||
"installerHooks": "./nsis-hooks.nsh"
|
"installerIcon": "icons/icon.ico",
|
||||||
|
"installerHooks": "./nsis/nsis-hooks.nsh"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"icon": [
|
"icon": [
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
@import "tw-animate-css";
|
@import "tw-animate-css";
|
||||||
|
|
||||||
@custom-variant dark (&:is(.dark *));
|
@custom-variant dark (&:where(.dark, .dark *));
|
||||||
|
|
||||||
|
@import "@fontsource-variable/sora";
|
||||||
|
@import "@fontsource/space-mono";
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--radius: 0.625rem;
|
--radius: 0.625rem;
|
||||||
@@ -41,7 +44,7 @@
|
|||||||
--sidebar-ring: oklch(60.7% 0.226 299.68);
|
--sidebar-ring: oklch(60.7% 0.226 299.68);
|
||||||
|
|
||||||
--font-sans:
|
--font-sans:
|
||||||
"Sora", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
|
"Sora Variable", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
|
||||||
"Segoe UI Symbol", "Noto Color Emoji";
|
"Segoe UI Symbol", "Noto Color Emoji";
|
||||||
--font-mono:
|
--font-mono:
|
||||||
"Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
"Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
||||||
@@ -55,7 +58,7 @@
|
|||||||
--card-foreground: oklch(89.24% 0.079 263.24);
|
--card-foreground: oklch(89.24% 0.079 263.24);
|
||||||
--popover: oklch(20.3% 0.05 282.86);
|
--popover: oklch(20.3% 0.05 282.86);
|
||||||
--popover-foreground: oklch(89.24% 0.079 263.24);
|
--popover-foreground: oklch(89.24% 0.079 263.24);
|
||||||
--primary: oklch(81.45% 0.159 300.53);
|
--primary: oklch(72.08% 0.196 356.34);
|
||||||
--primary-foreground: oklch(20.22% 0.048 282.86);
|
--primary-foreground: oklch(20.22% 0.048 282.86);
|
||||||
--secondary: oklch(42.99% 0.031 270.49);
|
--secondary: oklch(42.99% 0.031 270.49);
|
||||||
--secondary-foreground: oklch(89.24% 0.079 263.24);
|
--secondary-foreground: oklch(89.24% 0.079 263.24);
|
||||||
@@ -67,8 +70,8 @@
|
|||||||
--destructive-foreground: oklch(20.22% 0.048 282.86);
|
--destructive-foreground: oklch(20.22% 0.048 282.86);
|
||||||
--border: oklch(27.7% 0.041 276.87);
|
--border: oklch(27.7% 0.041 276.87);
|
||||||
--input: oklch(27.7% 0.041 276.87);
|
--input: oklch(27.7% 0.041 276.87);
|
||||||
--ring: oklch(81.45% 0.159 300.53);
|
--ring: oklch(72.08% 0.196 356.34);
|
||||||
--chart-1: oklch(81.45% 0.159 300.53);
|
--chart-1: oklch(72.08% 0.196 356.34);
|
||||||
--chart-2: oklch(77.19% 0.121 223.01);
|
--chart-2: oklch(77.19% 0.121 223.01);
|
||||||
--chart-3: oklch(79.1% 0.119 150.21);
|
--chart-3: oklch(79.1% 0.119 150.21);
|
||||||
--chart-4: oklch(79.74% 0.167 57.97);
|
--chart-4: oklch(79.74% 0.167 57.97);
|
||||||
@@ -76,12 +79,12 @@
|
|||||||
--sidebar: oklch(13.29% 0.036 282.86);
|
--sidebar: oklch(13.29% 0.036 282.86);
|
||||||
--sidebar-background: oklch(13.29% 0.036 282.86);
|
--sidebar-background: oklch(13.29% 0.036 282.86);
|
||||||
--sidebar-foreground: oklch(89.24% 0.079 263.24);
|
--sidebar-foreground: oklch(89.24% 0.079 263.24);
|
||||||
--sidebar-primary: oklch(81.45% 0.159 300.53);
|
--sidebar-primary: oklch(72.08% 0.196 356.34);
|
||||||
--sidebar-primary-foreground: oklch(20.22% 0.048 282.86);
|
--sidebar-primary-foreground: oklch(20.22% 0.048 282.86);
|
||||||
--sidebar-accent: oklch(75.21% 0.121 293.01);
|
--sidebar-accent: oklch(75.21% 0.121 293.01);
|
||||||
--sidebar-accent-foreground: oklch(20.22% 0.048 282.86);
|
--sidebar-accent-foreground: oklch(20.22% 0.048 282.86);
|
||||||
--sidebar-border: oklch(35.13% 0.03 273.31);
|
--sidebar-border: oklch(35.13% 0.03 273.31);
|
||||||
--sidebar-ring: oklch(81.45% 0.159 300.53);
|
--sidebar-ring: oklch(72.08% 0.196 356.34);
|
||||||
}
|
}
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
@@ -108,20 +111,18 @@
|
|||||||
--color-popover: var(--popover);
|
--color-popover: var(--popover);
|
||||||
--color-popover-foreground: var(--popover-foreground);
|
--color-popover-foreground: var(--popover-foreground);
|
||||||
--color-primary: var(--primary);
|
--color-primary: var(--primary);
|
||||||
--color-primary-50: #fefdff;
|
--color-primary-50: #ffe5f1;
|
||||||
--color-primary-100: #faf6fe;
|
--color-primary-100: #ffcce2;
|
||||||
--color-primary-200: #f2e9fc;
|
--color-primary-200: #ff99c5;
|
||||||
--color-primary-300: #e9dbfa;
|
--color-primary-300: #ff66a8;
|
||||||
--color-primary-400: #e1cef9;
|
--color-primary-400: #ff338b;
|
||||||
--color-primary-500: #d9c0f7;
|
--color-primary-500: #ff006e;
|
||||||
--color-primary-600: #c6a0f3;
|
--color-primary-600: #cc0058;
|
||||||
--color-primary-700: #b381ef;
|
--color-primary-700: #990042;
|
||||||
--color-primary-800: #a061eb;
|
--color-primary-800: #66002c;
|
||||||
--color-primary-900: #8d41e7;
|
--color-primary-900: #330016;
|
||||||
--color-primary-950: #8331e5;
|
--color-primary-950: #24000f;
|
||||||
--color-primary-foreground: var(--primary-foreground);
|
--color-primary-foreground: var(--primary-foreground);
|
||||||
--color-primary-50: #fefdff;
|
|
||||||
--color-primary-100: #faf6fe;
|
|
||||||
--color-secondary: var(--secondary);
|
--color-secondary: var(--secondary);
|
||||||
--color-secondary-foreground: var(--secondary-foreground);
|
--color-secondary-foreground: var(--secondary-foreground);
|
||||||
--color-muted: var(--muted);
|
--color-muted: var(--muted);
|
||||||
@@ -147,6 +148,62 @@
|
|||||||
--color-sidebar-ring: var(--sidebar-ring);
|
--color-sidebar-ring: var(--sidebar-ring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main[data-theme="execution_clap"] {
|
||||||
|
--primary: #fc112b;
|
||||||
|
--primary-foreground: #fff;
|
||||||
|
--ring: #fc112b;
|
||||||
|
--color-primary-50: #fef2f2;
|
||||||
|
--color-primary-100: #fee2e2;
|
||||||
|
--color-primary-200: #fecaca;
|
||||||
|
--color-primary-300: #fca5a5;
|
||||||
|
--color-primary-400: #f87171;
|
||||||
|
--color-primary-500: #ef4444;
|
||||||
|
--color-primary-600: #dc2626;
|
||||||
|
--color-primary-700: #b91c1c;
|
||||||
|
--color-primary-800: #991b1b;
|
||||||
|
--color-primary-900: #7f1d1d;
|
||||||
|
--color-primary-950: #450a0a;
|
||||||
|
--bg-primary-50: #fef2f2;
|
||||||
|
--bg-primary-100: #fee2e2;
|
||||||
|
--bg-primary-200: #fecaca;
|
||||||
|
--bg-primary-300: #fca5a5;
|
||||||
|
--bg-primary-400: #f87171;
|
||||||
|
--bg-primary-500: #ef4444;
|
||||||
|
--bg-primary-600: #dc2626;
|
||||||
|
--bg-primary-700: #b91c1c;
|
||||||
|
--bg-primary-800: #991b1b;
|
||||||
|
--bg-primary-900: #7f1d1d;
|
||||||
|
--bg-primary-950: #450a0a;
|
||||||
|
}
|
||||||
|
|
||||||
|
main[data-theme="lost_umbrella"] {
|
||||||
|
--primary: #e5e5e5;
|
||||||
|
--primary-foreground: #000;
|
||||||
|
--ring: #e5e5e5;
|
||||||
|
--color-primary-50: #0d0d0d;
|
||||||
|
--color-primary-100: #1a1a1a;
|
||||||
|
--color-primary-200: #333333;
|
||||||
|
--color-primary-300: #4d4d4d;
|
||||||
|
--color-primary-400: #666666;
|
||||||
|
--color-primary-500: #808080;
|
||||||
|
--color-primary-600: #999999;
|
||||||
|
--color-primary-700: #b3b3b3;
|
||||||
|
--color-primary-800: #cccccc;
|
||||||
|
--color-primary-900: #e6e6e6;
|
||||||
|
--color-primary-950: #f2f2f2;
|
||||||
|
--bg-primary-50: #0d0d0d;
|
||||||
|
--bg-primary-100: #1a1a1a;
|
||||||
|
--bg-primary-200: #333333;
|
||||||
|
--bg-primary-300: #4d4d4d;
|
||||||
|
--bg-primary-400: #666666;
|
||||||
|
--bg-primary-500: #808080;
|
||||||
|
--bg-primary-600: #999999;
|
||||||
|
--bg-primary-700: #b3b3b3;
|
||||||
|
--bg-primary-800: #cccccc;
|
||||||
|
--bg-primary-900: #e6e6e6;
|
||||||
|
--bg-primary-950: #f2f2f2;
|
||||||
|
}
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
* {
|
* {
|
||||||
@apply border-border outline-ring/50;
|
@apply border-border outline-ring/50;
|
||||||
|
|||||||
|
After Width: | Height: | Size: 173 KiB |
@@ -0,0 +1,86 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { reduceAnimations } from '@/userSettings';
|
||||||
|
|
||||||
|
//TODO: maybe dynamic background images fetched from ezpp?
|
||||||
|
|
||||||
|
const COUNT = 60;
|
||||||
|
|
||||||
|
function rand(min: number, max: number) {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
const streaks = Array.from({ length: COUNT })
|
||||||
|
.map((_, i) => {
|
||||||
|
const depth = rand(0, 2);
|
||||||
|
|
||||||
|
const scale = 0.6 + depth * 0.8;
|
||||||
|
const speed = 0.4 + depth * 1.35;
|
||||||
|
|
||||||
|
const distance = 150;
|
||||||
|
const duration = distance / speed;
|
||||||
|
|
||||||
|
return {
|
||||||
|
width: rand(300, 320) * scale,
|
||||||
|
height: 32 * scale,
|
||||||
|
x: (i / COUNT) * 200 - 50,
|
||||||
|
y: ((i * 137.5) % 100) - 20,
|
||||||
|
opacity: 0.25 + depth * 0.65,
|
||||||
|
duration,
|
||||||
|
delay: rand(0, duration),
|
||||||
|
scale,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.sort((a, b) => a.scale - b.scale);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="absolute bg blur-[2px]">
|
||||||
|
<div
|
||||||
|
class="relative h-full w-full from-0% to-90% bg-gradient-to-b from-transparent to-black z-50"
|
||||||
|
></div>
|
||||||
|
{#each streaks as s, index (index)}
|
||||||
|
<div
|
||||||
|
class="streak drop-shadow-lg transition-opacity duration-1000"
|
||||||
|
style="
|
||||||
|
width:{s.width}px;
|
||||||
|
height:{s.height}px;
|
||||||
|
left:{s.x}%;
|
||||||
|
top:{s.y}%;
|
||||||
|
opacity:{$reduceAnimations ? 0 : s.opacity};
|
||||||
|
animation-duration:{s.duration}s;
|
||||||
|
animation-delay:-{s.delay}s;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.bg {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
var(--color-primary-300) 0%,
|
||||||
|
var(--color-primary-600) 40%,
|
||||||
|
var(--color-primary-900) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.streak {
|
||||||
|
position: absolute;
|
||||||
|
background: #d6f3ff;
|
||||||
|
border-radius: 999px;
|
||||||
|
transform: rotate(-35deg);
|
||||||
|
animation: move linear infinite;
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes move {
|
||||||
|
from {
|
||||||
|
transform: translate(-150vw, 150vh) rotate(-35deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translate(150vw, -150vh) rotate(-35deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import NyanCat from '$assets/themes/nyan_cat/image.gif';
|
||||||
|
import { reduceAnimations } from '@/userSettings';
|
||||||
|
|
||||||
|
//TODO: maybe dynamic background images fetched from ezpp?
|
||||||
|
|
||||||
|
const COUNT = 18;
|
||||||
|
|
||||||
|
function rand(min: number, max: number) {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
const streaks = Array.from({ length: COUNT })
|
||||||
|
.map((_, i) => {
|
||||||
|
const depth = rand(0, 2);
|
||||||
|
|
||||||
|
const scale = 0.6 + depth * 0.8;
|
||||||
|
const speed = 0.4 + depth * 1.35;
|
||||||
|
|
||||||
|
const distance = 150;
|
||||||
|
const duration = distance / speed;
|
||||||
|
|
||||||
|
return {
|
||||||
|
width: 290 * scale,
|
||||||
|
height: 140 * scale,
|
||||||
|
x: (i / COUNT) * 200 - 50,
|
||||||
|
y: ((i * 137.5) % 100) - 20,
|
||||||
|
opacity: 0.25 + depth * 0.65,
|
||||||
|
duration,
|
||||||
|
delay: rand(0, duration),
|
||||||
|
scale,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.sort((a, b) => a.scale - b.scale);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="absolute bg blur-[2px]">
|
||||||
|
<div
|
||||||
|
class="relative h-full w-full from-0% to-90% bg-gradient-to-b from-transparent to-black z-50"
|
||||||
|
></div>
|
||||||
|
{#each streaks as s, index (index)}
|
||||||
|
<div
|
||||||
|
class="streak drop-shadow-lg transition-opacity duration-1000"
|
||||||
|
style="
|
||||||
|
width:{s.width}px;
|
||||||
|
height:{s.height}px;
|
||||||
|
left:{s.x}%;
|
||||||
|
top:{s.y}%;
|
||||||
|
opacity:{$reduceAnimations ? 0 : s.opacity};
|
||||||
|
animation-duration:{s.duration}s;
|
||||||
|
animation-delay:-{s.delay}s;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={NyanCat}
|
||||||
|
alt="nyan cat"
|
||||||
|
class="w-full h-full"
|
||||||
|
style="opacity:{$reduceAnimations ? 0 : s.opacity};"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.bg {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
var(--color-blue-800) 0%,
|
||||||
|
var(--color-blue-600) 40%,
|
||||||
|
var(--color-blue-900) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.streak {
|
||||||
|
position: absolute;
|
||||||
|
animation: move linear infinite;
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes move {
|
||||||
|
from {
|
||||||
|
transform: translate(-250vw, 0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translate(250vw, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Ellipsis from '@lucide/svelte/icons/ellipsis';
|
||||||
|
import Play from '@lucide/svelte/icons/play';
|
||||||
|
|
||||||
|
const prop: {
|
||||||
|
downloading: boolean;
|
||||||
|
progress: number;
|
||||||
|
text: string;
|
||||||
|
subtext?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
onClick?: () => void;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
const radius = 16;
|
||||||
|
const circumference = 2 * Math.PI * radius;
|
||||||
|
const strokeDashoffset = $derived(circumference - (prop.progress / 100) * circumference);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="group flex items-center h-12 rounded-full bg-primary disabled:bg-primary/70 shadow-lg shadow-primary/25 transition-all not-disabled:hover:shadow-primary/40 not-disabled:hover:brightness-110 not-disabled:active:scale-[0.98] cursor-pointer w-fit"
|
||||||
|
disabled={prop.disabled}
|
||||||
|
onclick={prop.onClick}
|
||||||
|
>
|
||||||
|
<div class="relative size-12 shrink-0 flex items-center justify-center">
|
||||||
|
{#if prop.downloading}
|
||||||
|
{#if prop.progress === -1}
|
||||||
|
<svg class="absolute inset-0 animate-spin" viewBox="0 0 48 48">
|
||||||
|
<circle class="stroke-black/10" cx="24" cy="24" r={radius} fill="none" stroke-width="3" />
|
||||||
|
<circle
|
||||||
|
class="stroke-pink-950"
|
||||||
|
cx="24"
|
||||||
|
cy="24"
|
||||||
|
r={radius}
|
||||||
|
fill="none"
|
||||||
|
stroke-width="3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-dasharray={circumference}
|
||||||
|
stroke-dashoffset={circumference * 0.7}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
{:else}
|
||||||
|
<svg class="absolute inset-0 -rotate-90" viewBox="0 0 48 48">
|
||||||
|
<circle
|
||||||
|
cx="24"
|
||||||
|
cy="24"
|
||||||
|
r={radius}
|
||||||
|
fill="none"
|
||||||
|
stroke="rgba(0,0,0,0.2)"
|
||||||
|
stroke-width="3"
|
||||||
|
/>
|
||||||
|
<circle
|
||||||
|
cx="24"
|
||||||
|
cy="24"
|
||||||
|
r={radius}
|
||||||
|
fill="none"
|
||||||
|
stroke="rgba(0,0,0,0.7)"
|
||||||
|
stroke-width="3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-dasharray={circumference}
|
||||||
|
stroke-dashoffset={strokeDashoffset}
|
||||||
|
class="transition-[stroke-dashoffset] duration-100"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
<div class="size-9 rounded-full bg-black/30 flex items-center justify-center relative z-10">
|
||||||
|
{#if prop.downloading}
|
||||||
|
{#if prop.progress === -1}
|
||||||
|
<Ellipsis class="size-4 text-primary-foreground fill-current animate-pulse" />
|
||||||
|
{:else}
|
||||||
|
<span class="text-[10px] font-bold text-primary-foreground">
|
||||||
|
{prop.progress.toFixed()}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
<Play class="size-4 text-primary-foreground fill-current ml-0.5" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pr-6 pl-1 text-center w-52">
|
||||||
|
<p class="text-sm font-bold text-primary-foreground leading-tight">
|
||||||
|
{prop.text}
|
||||||
|
</p>
|
||||||
|
{#if prop.subtext}
|
||||||
|
<p class="text-[10px] text-primary-foreground/70 leading-tight">
|
||||||
|
{prop.subtext}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
import Check from 'lucide-svelte/icons/check';
|
import Check from '@lucide/svelte/icons/check';
|
||||||
import Minus from 'lucide-svelte/icons/minus';
|
import Minus from '@lucide/svelte/icons/minus';
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<DropdownMenuPrimitive.Item
|
<DropdownMenuPrimitive.Item
|
||||||
bind:ref
|
bind:ref
|
||||||
class={cn(
|
class={cn(
|
||||||
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
'data-[highlighted]:bg-primary data-[highlighted]:text-primary-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
||||||
inset && 'pl-8',
|
inset && 'pl-8',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from 'bits-ui';
|
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from 'bits-ui';
|
||||||
import Circle from 'lucide-svelte/icons/circle';
|
import Circle from '@lucide/svelte/icons/circle';
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||||
import ChevronRight from 'lucide-svelte/icons/chevron-right';
|
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { cn } from '$lib/utils';
|
import { cn } from '$lib/utils';
|
||||||
import { Heart } from 'lucide-svelte';
|
import { Heart } from '@lucide/svelte';
|
||||||
|
|
||||||
interface Sparkle {
|
interface Sparkle {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -7,17 +7,26 @@
|
|||||||
|
|
||||||
let { smoothCursor = true }: { smoothCursor?: boolean } = $props();
|
let { smoothCursor = true }: { smoothCursor?: boolean } = $props();
|
||||||
|
|
||||||
|
const VELOCITY_WINDOW_MS = 16;
|
||||||
|
const SPEED_THRESHOLD = 9;
|
||||||
|
const REQUIRED_CONSECUTIVE = 3;
|
||||||
|
|
||||||
let mouseX = $state(0);
|
let mouseX = $state(0);
|
||||||
let mouseY = $state(0);
|
let mouseY = $state(0);
|
||||||
let lastMouseX = $state(0);
|
let lastMouseX = 0;
|
||||||
let lastMouseY = $state(0);
|
let lastMouseY = 0;
|
||||||
let isMouseDown = $state(false);
|
let isMouseDown = $state(false);
|
||||||
let isHoveringInteractive = $state(false);
|
let isHoveringInteractive = $state(false);
|
||||||
let dragStartX = $state(0);
|
let dragStartX = 0;
|
||||||
let dragStartY = $state(0);
|
let dragStartY = 0;
|
||||||
let degrees = $state(0);
|
let degrees = $state(0);
|
||||||
let applyRotation = $state(false);
|
let applyRotation = $state(false);
|
||||||
|
|
||||||
|
let lastVelocityTime = 0;
|
||||||
|
let consecutiveHighSpeed = 0;
|
||||||
|
let velocityAccumX = 0;
|
||||||
|
let velocityAccumY = 0;
|
||||||
|
|
||||||
function isInteractive(el: Element | null): boolean {
|
function isInteractive(el: Element | null): boolean {
|
||||||
while (el) {
|
while (el) {
|
||||||
const tag = el.tagName.toLowerCase();
|
const tag = el.tagName.toLowerCase();
|
||||||
@@ -25,12 +34,11 @@
|
|||||||
const computed = getComputedStyle(el);
|
const computed = getComputedStyle(el);
|
||||||
if (
|
if (
|
||||||
['button', 'a', 'input', 'select', 'textarea', 'label', 'option'].includes(tag) ||
|
['button', 'a', 'input', 'select', 'textarea', 'label', 'option'].includes(tag) ||
|
||||||
(role && ['button', 'link', 'checkbox', 'combobox'].includes(role)) ||
|
(role && ['button', 'link', 'checkbox', 'combobox', 'menuitem', 'option'].includes(role)) ||
|
||||||
computed.cursor === 'pointer'
|
computed.cursor === 'pointer'
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
el = el.parentElement;
|
el = el.parentElement;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -43,17 +51,32 @@
|
|||||||
const deltaX = e.pageX - window.pageXOffset - dragStartX;
|
const deltaX = e.pageX - window.pageXOffset - dragStartX;
|
||||||
const deltaY = e.pageY - window.pageYOffset - dragStartY;
|
const deltaY = e.pageY - window.pageYOffset - dragStartY;
|
||||||
|
|
||||||
const velocityX = mouseX - lastMouseX;
|
velocityAccumX += mouseX - lastMouseX;
|
||||||
const velocityY = mouseY - lastMouseY;
|
velocityAccumY += mouseY - lastMouseY;
|
||||||
|
|
||||||
const dist = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
|
const now = performance.now();
|
||||||
|
const dt = now - lastVelocityTime;
|
||||||
|
|
||||||
if (!applyRotation && isMouseDown && dist > 80) applyRotation = true;
|
if (dt >= VELOCITY_WINDOW_MS) {
|
||||||
|
const speed = Math.sqrt(velocityAccumX ** 2 + velocityAccumY ** 2) / dt;
|
||||||
|
|
||||||
|
if (speed > SPEED_THRESHOLD) {
|
||||||
|
consecutiveHighSpeed++;
|
||||||
|
if (!applyRotation && isMouseDown && consecutiveHighSpeed >= REQUIRED_CONSECUTIVE) {
|
||||||
|
applyRotation = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
consecutiveHighSpeed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
velocityAccumX = 0;
|
||||||
|
velocityAccumY = 0;
|
||||||
|
lastVelocityTime = now;
|
||||||
|
}
|
||||||
|
|
||||||
let newDegrees = (Math.atan2(-deltaX, deltaY) * 180) / Math.PI + 24.3;
|
let newDegrees = (Math.atan2(-deltaX, deltaY) * 180) / Math.PI + 24.3;
|
||||||
|
|
||||||
let diff = (newDegrees - degrees) % 360;
|
let diff = (newDegrees - degrees) % 360;
|
||||||
|
|
||||||
if (diff < -180) diff += 360;
|
if (diff < -180) diff += 360;
|
||||||
if (diff > 180) diff -= 360;
|
if (diff > 180) diff -= 360;
|
||||||
|
|
||||||
@@ -67,26 +90,18 @@
|
|||||||
isHoveringInteractive = isInteractive(el);
|
isHoveringInteractive = isInteractive(el);
|
||||||
|
|
||||||
if (!isMouseDown) {
|
if (!isMouseDown) {
|
||||||
if (isHoveringInteractive) {
|
animate(cursorAdditive, {
|
||||||
animate(cursorAdditive, {
|
opacity: isHoveringInteractive ? 1 : 0,
|
||||||
opacity: 1,
|
duration: 800,
|
||||||
duration: 800,
|
ease: (t: number) => (t - 1) ** 5 + 1,
|
||||||
ease: (t: number) => (t - 1) ** 5 + 1,
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
animate(cursorAdditive, {
|
|
||||||
opacity: 0,
|
|
||||||
duration: 800,
|
|
||||||
ease: (t: number) => (t - 1) ** 5 + 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
animate(cursor, {
|
animate(cursor, {
|
||||||
duration: smoothCursor ? $cursorSmoothness : 0,
|
duration: smoothCursor ? $cursorSmoothness : 0,
|
||||||
translateX: mouseX,
|
translateX: mouseX,
|
||||||
translateY: mouseY - 50,
|
translateY: mouseY,
|
||||||
ease: (t: number) => (t - 1) ** 5 + 1,
|
ease: (t: number) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t),
|
||||||
});
|
});
|
||||||
|
|
||||||
animate(cursor, {
|
animate(cursor, {
|
||||||
@@ -107,6 +122,11 @@
|
|||||||
dragStartX = event.clientX;
|
dragStartX = event.clientX;
|
||||||
dragStartY = event.clientY;
|
dragStartY = event.clientY;
|
||||||
|
|
||||||
|
velocityAccumX = 0;
|
||||||
|
velocityAccumY = 0;
|
||||||
|
consecutiveHighSpeed = 0;
|
||||||
|
lastVelocityTime = performance.now();
|
||||||
|
|
||||||
isMouseDown = true;
|
isMouseDown = true;
|
||||||
animate(cursorInner, {
|
animate(cursorInner, {
|
||||||
scale: 0.9,
|
scale: 0.9,
|
||||||
@@ -124,6 +144,10 @@
|
|||||||
const handleMouseUp = () => {
|
const handleMouseUp = () => {
|
||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
applyRotation = false;
|
applyRotation = false;
|
||||||
|
consecutiveHighSpeed = 0;
|
||||||
|
velocityAccumX = 0;
|
||||||
|
velocityAccumY = 0;
|
||||||
|
|
||||||
animate(cursorInner, {
|
animate(cursorInner, {
|
||||||
scale: 1,
|
scale: 1,
|
||||||
duration: 500,
|
duration: 500,
|
||||||
@@ -179,4 +203,4 @@
|
|||||||
:global(html.hiddenCursor textarea) {
|
:global(html.hiddenCursor textarea) {
|
||||||
cursor: none !important;
|
cursor: none !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
// Props
|
||||||
|
let { children, class: className = '', topOffset = 0 } = $props();
|
||||||
|
|
||||||
|
let wrapper: HTMLDivElement;
|
||||||
|
let container: HTMLDivElement;
|
||||||
|
let thumb: HTMLDivElement;
|
||||||
|
|
||||||
|
// Thumb state
|
||||||
|
let thumbHeight = $state(20);
|
||||||
|
let thumbTop = $state(0);
|
||||||
|
|
||||||
|
// Drag state
|
||||||
|
let dragging = false;
|
||||||
|
let startY = 0;
|
||||||
|
let startScroll = 0;
|
||||||
|
|
||||||
|
/** Update thumb height & position */
|
||||||
|
function updateScrollbar() {
|
||||||
|
if (!container) return;
|
||||||
|
|
||||||
|
const { scrollTop, scrollHeight, clientHeight } = container;
|
||||||
|
const scrollable = scrollHeight - clientHeight;
|
||||||
|
|
||||||
|
if (scrollable <= 0) {
|
||||||
|
thumbHeight = 0;
|
||||||
|
thumbTop = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
thumbHeight = Math.max((clientHeight / scrollHeight) * clientHeight, 24);
|
||||||
|
|
||||||
|
const trackHeight = clientHeight - thumbHeight - topOffset;
|
||||||
|
thumbTop = (scrollTop / scrollable) * trackHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Start dragging the thumb */
|
||||||
|
function startDrag(e: PointerEvent) {
|
||||||
|
dragging = true;
|
||||||
|
startY = e.clientY;
|
||||||
|
startScroll = container.scrollTop;
|
||||||
|
thumb.setPointerCapture(e.pointerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Drag the thumb */
|
||||||
|
function drag(e: PointerEvent) {
|
||||||
|
if (!dragging) return;
|
||||||
|
|
||||||
|
const delta = e.clientY - startY;
|
||||||
|
const { scrollHeight, clientHeight } = container;
|
||||||
|
const scrollable = scrollHeight - clientHeight;
|
||||||
|
const trackHeight = clientHeight - thumbHeight - topOffset;
|
||||||
|
|
||||||
|
container.scrollTop = startScroll + (delta / trackHeight) * scrollable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** End dragging */
|
||||||
|
function endDrag(e: PointerEvent) {
|
||||||
|
dragging = false;
|
||||||
|
thumb.releasePointerCapture(e.pointerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reactive effect to update scrollbar
|
||||||
|
$effect(() => updateScrollbar());
|
||||||
|
|
||||||
|
// ResizeObserver for dynamic content
|
||||||
|
$effect(() => {
|
||||||
|
if (!container) return;
|
||||||
|
const observer = new ResizeObserver(updateScrollbar);
|
||||||
|
observer.observe(container);
|
||||||
|
return () => observer.disconnect();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="wrapper" bind:this={wrapper}>
|
||||||
|
<!-- Scrollable content -->
|
||||||
|
<div
|
||||||
|
class={`content ${className}`}
|
||||||
|
bind:this={container}
|
||||||
|
onscroll={updateScrollbar}
|
||||||
|
id="scrollable-content"
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Custom scrollbar -->
|
||||||
|
<div class="scrollbar" style="top: {topOffset}px;">
|
||||||
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<div
|
||||||
|
class="thumb"
|
||||||
|
bind:this={thumb}
|
||||||
|
onpointerdown={startDrag}
|
||||||
|
onpointermove={drag}
|
||||||
|
onpointerup={endDrag}
|
||||||
|
onpointercancel={endDrag}
|
||||||
|
aria-controls="scrollable-content"
|
||||||
|
style="height:{thumbHeight}px; transform:translateY({thumbTop}px);"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.wrapper {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollable content */
|
||||||
|
.content {
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
scrollbar-width: none; /* Firefox */
|
||||||
|
}
|
||||||
|
|
||||||
|
.content::-webkit-scrollbar {
|
||||||
|
display: none; /* Chrome, Safari, Edge */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollbar track */
|
||||||
|
.scrollbar {
|
||||||
|
position: absolute;
|
||||||
|
right: 2px;
|
||||||
|
bottom: 0;
|
||||||
|
width: 8px;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Thumb */
|
||||||
|
.thumb {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
background: var(--color-theme-700);
|
||||||
|
border-radius: 999px;
|
||||||
|
cursor: grab;
|
||||||
|
transition: background 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
background: var(--color-theme-600);
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb:hover {
|
||||||
|
background: var(--color-theme-700);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
bind:ref
|
bind:ref
|
||||||
{value}
|
{value}
|
||||||
class={cn(
|
class={cn(
|
||||||
'data-[highlighted]:bg-primary-800/30 data-[highlighted]:text-accent-foreground relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
'data-[highlighted]:bg-primary data-[highlighted]:text-primary-foreground relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { createElement } from 'react';
|
||||||
|
import { createRoot } from 'react-dom/client';
|
||||||
|
import type { SileoOptions } from 'sileo';
|
||||||
|
|
||||||
|
let props: SileoOptions = $props();
|
||||||
|
let rootEl: HTMLElement;
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
const root = createRoot(rootEl);
|
||||||
|
|
||||||
|
import('sileo').then(({ Toaster }) => {
|
||||||
|
const sileo = createElement(Toaster, { ...props });
|
||||||
|
root.render(sileo);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => root.unmount();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div bind:this={rootEl}></div>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import Root from './switch.svelte';
|
||||||
|
|
||||||
|
export {
|
||||||
|
Root,
|
||||||
|
//
|
||||||
|
Root as Switch,
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Switch as SwitchPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
checked = $bindable(false),
|
||||||
|
...restProps
|
||||||
|
}: WithoutChildrenOrChild<SwitchPrimitive.RootProps> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<SwitchPrimitive.Root
|
||||||
|
bind:ref
|
||||||
|
bind:checked
|
||||||
|
class={cn(
|
||||||
|
'focus-visible:ring-ring focus-visible:ring-offset-background data-[state=checked]:bg-primary data-[state=unchecked]:bg-input peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
<SwitchPrimitive.Thumb
|
||||||
|
class={cn(
|
||||||
|
'bg-background pointer-events-none block size-5 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0'
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SwitchPrimitive.Root>
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Minimize from 'lucide-svelte/icons/minus';
|
import Minimize from '@lucide/svelte/icons/minus';
|
||||||
import Close from 'lucide-svelte/icons/x';
|
import Close from '@lucide/svelte/icons/x';
|
||||||
|
import Volume2 from '@lucide/svelte/icons/volume-2';
|
||||||
import Logo from '$assets/logo.png';
|
|
||||||
|
|
||||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { launcherVersion } from '@/global';
|
import { custom_theme_audio_playing, custom_theme_volume } from '@/global';
|
||||||
import Badge from '../badge/badge.svelte';
|
import { reduceAnimations, userSettings } from '@/userSettings';
|
||||||
|
import { Volume, Volume1, VolumeOff } from '@lucide/svelte';
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
@@ -19,32 +19,93 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div data-tauri-drag-region class="titlebar z-[60] border-b border-theme-800/90">
|
<div data-tauri-drag-region class="titlebar z-[100]">
|
||||||
<div
|
{#if $custom_theme_audio_playing}
|
||||||
class="mr-auto ms-2 flex flex-row gap-2 items-center text-[1.05rem] font-semibold pointer-events-none"
|
{#if $custom_theme_audio_playing}
|
||||||
>
|
<div class="relative flex items-center justify-center group">
|
||||||
<img src={Logo} alt="EZPP Launcher Logo" class="h-11 w-11 inline-block" />
|
<div class="relative flex items-center justify-center p-1 cursor-pointer">
|
||||||
<span>EZPPLauncher</span>
|
<div
|
||||||
<Badge class="!text-[0.6rem] py-[0.5px] bg-primary-500 hover:bg-primary-500"
|
class="absolute inset-0 bg-background rounded
|
||||||
>{$launcherVersion}</Badge
|
scale-80 opacity-0
|
||||||
>
|
group-hover:opacity-100
|
||||||
|
group-hover:scale-100
|
||||||
|
{$reduceAnimations ? '' : 'transition-all duration-200 ease-out'}"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
{#if $custom_theme_volume > 0.7}
|
||||||
|
<Volume2 class="z-10 pointer-events-none" size={14} />
|
||||||
|
{:else if $custom_theme_volume >= 0.15}
|
||||||
|
<Volume1 class="z-10 pointer-events-none" size={14} />
|
||||||
|
{:else if $custom_theme_volume > 0}
|
||||||
|
<Volume class="z-10 pointer-events-none" size={14} />
|
||||||
|
{:else}
|
||||||
|
<VolumeOff class="z-10 pointer-events-none" size={14} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute top-full right-0 translate-x-[7px]
|
||||||
|
opacity-0 invisible pointer-events-none -translate-y-2
|
||||||
|
group-hover:opacity-100 group-hover:visible group-hover:pointer-events-auto group-hover:translate-y-0
|
||||||
|
{$reduceAnimations ? '' : 'transition-all duration-200 ease-out'}
|
||||||
|
z-50"
|
||||||
|
>
|
||||||
|
<div class="h-2 w-full"></div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-center h-[120px] w-[35px]
|
||||||
|
bg-black/20 backdrop-blur-sm border border-white/10 rounded-xl"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="0"
|
||||||
|
max="1"
|
||||||
|
step="0.01"
|
||||||
|
bind:value={$custom_theme_volume}
|
||||||
|
on:input={() => {
|
||||||
|
$userSettings.value('volume').set($custom_theme_volume);
|
||||||
|
$userSettings.save();
|
||||||
|
}}
|
||||||
|
class="volume-slider"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
<div class="relative flex items-center justify-center p-1 group" id="titlebar-minimize">
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-background rounded
|
||||||
|
scale-80 opacity-0
|
||||||
|
group-hover:opacity-100
|
||||||
|
group-hover:scale-100
|
||||||
|
{$reduceAnimations ? '' : 'transition-all duration-200 ease-out'}
|
||||||
|
origin-center"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<Minimize class="z-10 pointer-events-none" size={14} />
|
||||||
</div>
|
</div>
|
||||||
<div class="titlebar-button rounded-lg transition-colors duration-75" id="titlebar-minimize">
|
<div class="relative flex items-center justify-center p-1 group" id="titlebar-close">
|
||||||
<Minimize size={18} />
|
<div
|
||||||
</div>
|
class="absolute inset-0 bg-red-500 rounded
|
||||||
<div class="titlebar-button close rounded-lg transition-colors duration-75" id="titlebar-close">
|
scale-80 opacity-0
|
||||||
<Close size={18} />
|
group-hover:opacity-100
|
||||||
|
group-hover:scale-100
|
||||||
|
{$reduceAnimations ? '' : 'transition-all duration-200 ease-out'}
|
||||||
|
origin-center"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<Close class="z-10 pointer-events-none" size={14} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.titlebar {
|
.titlebar {
|
||||||
height: 50px;
|
height: 35px;
|
||||||
/* background: #040612; */
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 10px;
|
gap: 5px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -52,21 +113,54 @@
|
|||||||
right: 0;
|
right: 0;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
pointer-events: all !important;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
.titlebar-button {
|
|
||||||
display: inline-flex;
|
.volume-slider {
|
||||||
justify-content: center;
|
appearance: none;
|
||||||
align-items: center;
|
-webkit-appearance: none;
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
width: 100px; /* becomes vertical */
|
||||||
user-select: none;
|
height: 6px;
|
||||||
-webkit-user-select: none;
|
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
transform: rotate(-90deg);
|
||||||
}
|
}
|
||||||
.titlebar-button:hover {
|
|
||||||
&.close {
|
/* track */
|
||||||
background: #c22e2e;
|
.volume-slider::-webkit-slider-runnable-track {
|
||||||
}
|
height: 6px;
|
||||||
background: #2d3049;
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* thumb */
|
||||||
|
.volume-slider::-webkit-slider-thumb {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
margin-top: -4px; /* center thumb */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Firefox */
|
||||||
|
.volume-slider::-moz-range-track {
|
||||||
|
height: 6px;
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.volume-slider::-moz-range-thumb {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -64,11 +64,18 @@ export class Config {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
values () {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
value(key: string) {
|
value(key: string) {
|
||||||
return {
|
return {
|
||||||
set: <T>(val: T) => {
|
set: <T>(val: T) => {
|
||||||
this.config[key] = val;
|
this.config[key] = val;
|
||||||
},
|
},
|
||||||
|
exists: () => {
|
||||||
|
return this.config[key] !== undefined;
|
||||||
|
},
|
||||||
get: <T>(fallback: T): T => {
|
get: <T>(fallback: T): T => {
|
||||||
return (this.config[key] as T) ?? fallback;
|
return (this.config[key] as T) ?? fallback;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
export function estimateRefreshRate(): Promise<number> {
|
export async function estimateFrameRate(): Promise<number> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const last = performance.now();
|
const samples: number[] = [];
|
||||||
let frames = 0;
|
let last = performance.now();
|
||||||
|
|
||||||
function loop() {
|
const tick = () => {
|
||||||
const now = performance.now();
|
const now = performance.now();
|
||||||
frames++;
|
samples.push(now - last);
|
||||||
|
last = now;
|
||||||
|
|
||||||
if (now - last >= 1000) {
|
if (samples.length < 60) {
|
||||||
console.log(`Estimated Refresh Rate: ${frames - 2} FPS`);
|
requestAnimationFrame(tick);
|
||||||
resolve(frames - 2); // estimated Hz
|
|
||||||
} else {
|
} else {
|
||||||
requestAnimationFrame(loop);
|
const avgDelta = samples.reduce((a, b) => a + b) / samples.length;
|
||||||
|
resolve(Math.round(1000 / avgDelta));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
requestAnimationFrame(loop);
|
requestAnimationFrame(tick);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { listen } from '@tauri-apps/api/event';
|
||||||
|
import { onDestroy } from 'svelte';
|
||||||
|
|
||||||
|
type TauriDragDropEvent = {
|
||||||
|
paths: string[];
|
||||||
|
position: { x: number; y: number };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useDropZone = ({ onDrop }: { onDrop: (paths: string[]) => void }) => {
|
||||||
|
let element = $state<HTMLDivElement | null>(null);
|
||||||
|
let dragIn = $state(false);
|
||||||
|
let isDraggingOverApp = $state(false);
|
||||||
|
|
||||||
|
const isOver = (x: number, y: number) => {
|
||||||
|
if (!element) return false;
|
||||||
|
const el = document.elementFromPoint(x, y);
|
||||||
|
return element === el || element.contains(el); // ← fix
|
||||||
|
};
|
||||||
|
|
||||||
|
const dropUnlisten = listen<TauriDragDropEvent>('tauri://drag-drop', (e) => {
|
||||||
|
const { x, y } = e.payload.position;
|
||||||
|
if (isOver(x, y)) {
|
||||||
|
onDrop(e.payload.paths);
|
||||||
|
}
|
||||||
|
dragIn = false;
|
||||||
|
isDraggingOverApp = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
const overUnlisten = listen<TauriDragDropEvent>('tauri://drag-over', (e) => {
|
||||||
|
const { x, y } = e.payload.position;
|
||||||
|
isDraggingOverApp = true;
|
||||||
|
dragIn = isOver(x, y);
|
||||||
|
});
|
||||||
|
|
||||||
|
const leaveUnlisten = listen('tauri://drag-leave', () => {
|
||||||
|
dragIn = false;
|
||||||
|
isDraggingOverApp = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
onDestroy(async () => {
|
||||||
|
(await dropUnlisten)();
|
||||||
|
(await overUnlisten)();
|
||||||
|
(await leaveUnlisten)();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
get ref() {
|
||||||
|
return element;
|
||||||
|
},
|
||||||
|
set ref(el: HTMLDivElement | null) {
|
||||||
|
element = el;
|
||||||
|
},
|
||||||
|
get dragIn() {
|
||||||
|
return dragIn;
|
||||||
|
},
|
||||||
|
get isDraggingOverApp() {
|
||||||
|
return isDraggingOverApp;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -3,7 +3,9 @@ import { ezppfarm } from './api/ezpp';
|
|||||||
import type { Component } from 'svelte';
|
import type { Component } from 'svelte';
|
||||||
import Loading from '../screens/Loading.svelte';
|
import Loading from '../screens/Loading.svelte';
|
||||||
import type { Release } from './types';
|
import type { Release } from './types';
|
||||||
|
import type { Theme } from './themes';
|
||||||
|
import { browser } from '$app/environment';
|
||||||
|
import { setGlobalVolume } from './utils';
|
||||||
export const currentView = writable<Component>(Loading);
|
export const currentView = writable<Component>(Loading);
|
||||||
|
|
||||||
export const platform = writable<string>('');
|
export const platform = writable<string>('');
|
||||||
@@ -14,6 +16,8 @@ export const newVersion = writable<Release | undefined>(undefined);
|
|||||||
export const launcherStreams = writable<string[]>(['stable']);
|
export const launcherStreams = writable<string[]>(['stable']);
|
||||||
export const launcherStream = writable<string>('stable');
|
export const launcherStream = writable<string>('stable');
|
||||||
|
|
||||||
|
export const trackingEnabled = writable<boolean>(false);
|
||||||
|
|
||||||
export const discordPresence = writable<boolean>(false);
|
export const discordPresence = writable<boolean>(false);
|
||||||
export const presenceLoading = writable<boolean>(false);
|
export const presenceLoading = writable<boolean>(false);
|
||||||
|
|
||||||
@@ -22,6 +26,19 @@ export const currentLoadingInfo = writable<string>('Initializing...');
|
|||||||
export const firstStartup = writable<boolean>(false);
|
export const firstStartup = writable<boolean>(false);
|
||||||
|
|
||||||
export const launching = writable<boolean>(false);
|
export const launching = writable<boolean>(false);
|
||||||
|
export const custom_themes = writable<Theme[]>([]);
|
||||||
|
export const custom_theme_container = writable<HTMLElement | undefined>(undefined);
|
||||||
|
export const active_custom_theme = writable<Theme | undefined>(undefined);
|
||||||
|
export const custom_theme_audio_playing = writable<boolean>(false);
|
||||||
|
export const custom_theme_volume = writable<number>(0.15);
|
||||||
|
custom_theme_volume.subscribe((val) => {
|
||||||
|
if (browser) {
|
||||||
|
setGlobalVolume(val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const openTabletDriverEnabled = writable<boolean>(false);
|
||||||
|
export const openTabletDriverPath = writable<string>('');
|
||||||
|
|
||||||
export const serverPing = writable<number | undefined>(undefined);
|
export const serverPing = writable<number | undefined>(undefined);
|
||||||
export const serverConnectionFails = writable(0);
|
export const serverConnectionFails = writable(0);
|
||||||
@@ -29,7 +46,8 @@ export const serverConnectionFails = writable(0);
|
|||||||
export const onlineFriends = writable<number | undefined>(undefined);
|
export const onlineFriends = writable<number | undefined>(undefined);
|
||||||
|
|
||||||
export const beatmapSets = writable<number | undefined>(undefined);
|
export const beatmapSets = writable<number | undefined>(undefined);
|
||||||
export const skins = writable<number | undefined>(undefined);
|
export const skinsCount = writable<number | undefined>(undefined);
|
||||||
|
export const skins = writable<{ name: string; author: string | undefined; modified: number }[]>([]);
|
||||||
|
|
||||||
export const osuStream = writable<string | undefined>(undefined);
|
export const osuStream = writable<string | undefined>(undefined);
|
||||||
export const osuBuild = writable<string | undefined>(undefined);
|
export const osuBuild = writable<string | undefined>(undefined);
|
||||||
|
|||||||
@@ -3,22 +3,28 @@ import type { UpdateFile, UpdateStatus } from './types';
|
|||||||
import { listen } from '@tauri-apps/api/event';
|
import { listen } from '@tauri-apps/api/event';
|
||||||
import { betterFetch } from '@better-fetch/fetch';
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
|
||||||
const updateUrl = 'https://next.ez-pp.farm/api/ezpplauncher';
|
const updateUrl = 'https://ez-pp.farm/api/ezpplauncher';
|
||||||
|
|
||||||
export const getHWID = async () => {
|
export function normalizeOsuName(name: string): string {
|
||||||
const hwid = await invoke('get_hwid');
|
return (
|
||||||
return typeof hwid === 'string' ? hwid : undefined;
|
name
|
||||||
};
|
.trim()
|
||||||
|
// Remove leading symbols/spaces
|
||||||
|
.replace(/^[^a-zA-Z0-9]+/, '')
|
||||||
|
// Normalize spacing
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.toLowerCase()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export const isValidOsuFolder = async (folder: string): Promise<boolean> => {
|
export const getHWID = async (): Promise<string | undefined> =>
|
||||||
const result = await invoke('valid_osu_folder', { folder });
|
await invoke<string | undefined>('get_hwid');
|
||||||
return typeof result === 'boolean' ? result : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const autoDetectOsuInstallFolder = async () => {
|
export const isValidOsuFolder = async (folder: string): Promise<boolean | undefined> =>
|
||||||
const result = await invoke('find_osu_installation');
|
await invoke<boolean | undefined>('valid_osu_folder', { folder });
|
||||||
return typeof result === 'string' ? result : undefined;
|
|
||||||
};
|
export const autoDetectOsuInstallFolder = async () =>
|
||||||
|
await invoke<string | undefined>('find_osu_installation');
|
||||||
|
|
||||||
export const setUserConfigValues = async (
|
export const setUserConfigValues = async (
|
||||||
osuFolderPath: string,
|
osuFolderPath: string,
|
||||||
@@ -38,36 +44,23 @@ export const setConfigValues = async (
|
|||||||
entries,
|
entries,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getReleaseStream = async (folder: string) => {
|
export const getReleaseStream = async (folder: string): Promise<string | undefined> =>
|
||||||
const result = await invoke('get_osu_release_stream', { folder });
|
await invoke<string | undefined>('get_osu_release_stream', { folder });
|
||||||
return typeof result === 'string' ? result : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getVersion = async (folder: string) => {
|
export const getVersion = async (folder: string): Promise<string | undefined> =>
|
||||||
const result = await invoke('get_osu_version', { folder });
|
await invoke<string | undefined>('get_osu_version', { folder });
|
||||||
return typeof result === 'string' ? result : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getBeatmapSetsCount = async (folder: string) => {
|
export const getBeatmapSetsCount = async (folder: string): Promise<number | undefined> =>
|
||||||
const result = await invoke('get_beatmapsets_count', {
|
await invoke<number | undefined>('get_beatmapsets_count', {
|
||||||
folder,
|
folder,
|
||||||
});
|
});
|
||||||
return typeof result === 'number' ? result : 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSkinsCount = async (folder: string) => {
|
|
||||||
const result = await invoke('get_skins_count', {
|
|
||||||
folder,
|
|
||||||
});
|
|
||||||
return typeof result === 'number' ? result : 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSkin = async (folder: string) => {
|
export const getSkin = async (folder: string) => {
|
||||||
const result = await invoke('get_osu_skin', {
|
const result = await invoke<string | undefined>('get_osu_skin', {
|
||||||
folder,
|
folder,
|
||||||
});
|
});
|
||||||
|
|
||||||
return typeof result === 'string' ? result : 'Default';
|
return result || 'Default';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const runUpdater = async (folder: string) => await invoke('run_osu_updater', { folder });
|
export const runUpdater = async (folder: string) => await invoke('run_osu_updater', { folder });
|
||||||
@@ -82,7 +75,6 @@ export const getEZPPLauncherStreams = async () => {
|
|||||||
if (!resp.error) {
|
if (!resp.error) {
|
||||||
return resp.data.streams;
|
return resp.data.streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,8 +101,8 @@ export const downloadEZPPLauncherUpdateFiles = async (
|
|||||||
allFiles: UpdateFile[],
|
allFiles: UpdateFile[],
|
||||||
progressCallback: (file: UpdateStatus) => void
|
progressCallback: (file: UpdateStatus) => void
|
||||||
) => {
|
) => {
|
||||||
const downloadStatusListen = await listen('download-progress', (event) =>
|
const downloadStatusListen = await listen<UpdateStatus>('download-progress', (event) =>
|
||||||
progressCallback(event.payload as UpdateStatus)
|
progressCallback(event.payload)
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
await invoke('download_ezpp_launcher_update_files', { folder, updateFiles, allFiles });
|
await invoke('download_ezpp_launcher_update_files', { folder, updateFiles, allFiles });
|
||||||
@@ -123,20 +115,17 @@ export const replaceUIFiles = async (folder: string, revert: boolean) => {
|
|||||||
await invoke('replace_ui_files', { folder, revert });
|
await invoke('replace_ui_files', { folder, revert });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isOsuRunning = async () => {
|
export const isOsuRunning = async (): Promise<boolean> => await invoke<boolean>('is_osu_running');
|
||||||
const result = await invoke('is_osu_running');
|
|
||||||
return typeof result === 'boolean' ? result : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getLauncherVersion = async () => await invoke<string>('get_launcher_version');
|
export const getLauncherVersion = async () => await invoke<string>('get_launcher_version');
|
||||||
export const exit = async () => await invoke('exit');
|
export const exit = async () => await invoke('exit');
|
||||||
export const getPlatform = async () => await invoke<string>('get_platform');
|
export const getPlatform = async (): Promise<string> => await invoke<string>('get_platform');
|
||||||
export const isOsuCorrupted = async (folder: string) =>
|
export const isOsuCorrupted = async (folder: string): Promise<boolean> =>
|
||||||
await invoke<boolean>('check_for_corruption', { folder });
|
await invoke<boolean>('check_for_corruption', { folder });
|
||||||
export const hasWMCTRL = async () => await invoke<boolean>('has_wmctrl');
|
export const hasWMCTRL = async (): Promise<boolean> => await invoke<boolean>('has_wmctrl');
|
||||||
export const hasOsuWinello = async () => await invoke<boolean>('has_osuwinello');
|
export const hasOsuWinello = async (): Promise<boolean> => await invoke<boolean>('has_osuwinello');
|
||||||
export const hasNet8 = async () => await invoke<boolean>('has_net8');
|
export const hasNet8 = async (): Promise<boolean> => await invoke<boolean>('has_net8');
|
||||||
export const encryptString = async (str: string, entropy: string) =>
|
export const encryptString = async (str: string, entropy: string): Promise<string> =>
|
||||||
await invoke<string>('encrypt_string', { string: str, entropy });
|
await invoke<string>('encrypt_string', { string: str, entropy });
|
||||||
export const downloadUpdate = async (
|
export const downloadUpdate = async (
|
||||||
url: string,
|
url: string,
|
||||||
@@ -152,3 +141,11 @@ export const downloadUpdate = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const installUpdate = async () => await invoke('install_ezpp_launcher_update');
|
export const installUpdate = async () => await invoke('install_ezpp_launcher_update');
|
||||||
|
export const getSkins = async (folder: string) =>
|
||||||
|
await invoke<{ name: string; author: string | undefined; modified: number }[] | undefined>(
|
||||||
|
'get_skins',
|
||||||
|
{ folder }
|
||||||
|
);
|
||||||
|
export const startOpenTabletDriver = async (otdDaemonPath: string) =>
|
||||||
|
await invoke('run_open_tablet_driver', { path: otdDaemonPath });
|
||||||
|
export const stopOpenTabletDriver = async (otdDaemonPath: string) => await invoke('stop_open_tablet_driver', { path: otdDaemonPath });
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ export const updateStatus = async (status: {
|
|||||||
});
|
});
|
||||||
export const updateUser = async (user: { username: string; id?: string | null }) =>
|
export const updateUser = async (user: { username: string; id?: string | null }) =>
|
||||||
await invoke('presence_update_user', { user: { username: user.username, id: user.id } });
|
await invoke('presence_update_user', { user: { username: user.username, id: user.id } });
|
||||||
|
export const updateButton = async (button: { text?: string; url?: string }) =>
|
||||||
|
await invoke('presence_update_button', { button: button });
|
||||||
export const isConnected = async () => await invoke<boolean>('presence_is_connected');
|
export const isConnected = async () => await invoke<boolean>('presence_is_connected');
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
const specialOrder = "'-!#$%&(),;@[]^_`{}~+=";
|
||||||
|
|
||||||
|
const priority = Object.fromEntries([...specialOrder].map((c, i) => [c, i]));
|
||||||
|
|
||||||
|
const osuSkinsCollator = new Intl.Collator(undefined, {
|
||||||
|
numeric: true,
|
||||||
|
sensitivity: 'base',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const sortSkins = (
|
||||||
|
skins: { name: string; author: string | undefined; modified: number }[]
|
||||||
|
) =>
|
||||||
|
skins.sort((a, b) => {
|
||||||
|
const pa = priority[a.name[0]];
|
||||||
|
const pb = priority[b.name[0]];
|
||||||
|
|
||||||
|
if (pa !== undefined || pb !== undefined) {
|
||||||
|
if (pa === undefined) return 1;
|
||||||
|
if (pb === undefined) return -1;
|
||||||
|
return pa - pb;
|
||||||
|
}
|
||||||
|
|
||||||
|
return osuSkinsCollator.compare(a.name, b.name);
|
||||||
|
});
|
||||||
@@ -0,0 +1,495 @@
|
|||||||
|
import * as path from '@tauri-apps/api/path';
|
||||||
|
import * as fs from '@tauri-apps/plugin-fs';
|
||||||
|
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||||
|
import { active_custom_theme, custom_themes } from './global';
|
||||||
|
import { calculateGitBlobSha, setGlobalVolume } from './utils';
|
||||||
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
import zip from 'jszip';
|
||||||
|
import { SemVer } from 'semver';
|
||||||
|
|
||||||
|
export type Theme = {
|
||||||
|
folder_name: string;
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
author: string;
|
||||||
|
scriptUrl: string;
|
||||||
|
assets: string;
|
||||||
|
preview: string;
|
||||||
|
status: 'installed' | 'downloading' | 'extracting' | 'deleting' | 'not-installed';
|
||||||
|
progress: number;
|
||||||
|
updateAvailable: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ThemeInfo = {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
apiVersion: string;
|
||||||
|
author: string;
|
||||||
|
entry: string;
|
||||||
|
style: string;
|
||||||
|
preview: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDownloadableThemes = async () => {
|
||||||
|
const themes: Theme[] = [];
|
||||||
|
|
||||||
|
const downloadableThemes = await betterFetch<
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
author: string;
|
||||||
|
}[]
|
||||||
|
>('https://git.ez-pp.farm/EZPPFarm/EZPPLauncher-Themes/raw/branch/main/themes.json', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Accept: 'application/json',
|
||||||
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (downloadableThemes.data) {
|
||||||
|
for (const theme of downloadableThemes.data) {
|
||||||
|
themes.push({
|
||||||
|
folder_name: `${toSafeName(theme.name)}-${generateRandomString(16)}`,
|
||||||
|
name: theme.name,
|
||||||
|
version: theme.version,
|
||||||
|
author: theme.author,
|
||||||
|
scriptUrl: '',
|
||||||
|
assets: '',
|
||||||
|
preview: `https://git.ez-pp.farm/EZPPFarm/EZPPLauncher-Themes/raw/branch/main/previews/${toSafeName(theme.name)}.png`,
|
||||||
|
status: 'not-installed',
|
||||||
|
progress: 0,
|
||||||
|
updateAvailable: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error('Failed to fetch downloadable themes');
|
||||||
|
console.error(downloadableThemes.error);
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getThemes = async (): Promise<Theme[]> => {
|
||||||
|
const themes: Theme[] = [];
|
||||||
|
themes.push({
|
||||||
|
folder_name: 'default',
|
||||||
|
author: 'EZPPFarm',
|
||||||
|
name: 'Default',
|
||||||
|
version: '1.0.0',
|
||||||
|
scriptUrl: '',
|
||||||
|
assets: '',
|
||||||
|
preview: '',
|
||||||
|
status: 'installed',
|
||||||
|
progress: 0,
|
||||||
|
updateAvailable: false,
|
||||||
|
});
|
||||||
|
const folderPath = await path.join(await path.homeDir(), '.ezpplauncher', 'themes');
|
||||||
|
if (await fs.exists(folderPath)) {
|
||||||
|
const themeFolders = await fs.readDir(folderPath);
|
||||||
|
for (const themeFolder of themeFolders) {
|
||||||
|
const themeFolderPath = await path.join(folderPath, themeFolder.name);
|
||||||
|
const themeConfigFilePath = await path.join(folderPath, themeFolder.name, 'theme.json');
|
||||||
|
if (await fs.exists(themeConfigFilePath)) {
|
||||||
|
const themeConfig = await fs.readTextFile(themeConfigFilePath);
|
||||||
|
const theme = JSON.parse(themeConfig) as ThemeInfo;
|
||||||
|
const scriptFile = await path.join(folderPath, themeFolder.name, theme.entry);
|
||||||
|
if (await fs.exists(scriptFile)) {
|
||||||
|
themes.push({
|
||||||
|
folder_name: themeFolder.name,
|
||||||
|
name: theme.name,
|
||||||
|
version: theme.version,
|
||||||
|
author: theme.author,
|
||||||
|
scriptUrl: convertFileSrc(await path.normalize(`${themeFolderPath}/${theme.entry}`)),
|
||||||
|
assets: convertFileSrc(await path.normalize(`${themeFolderPath}/assets`)),
|
||||||
|
preview: convertFileSrc(
|
||||||
|
await path.normalize(`${themeFolderPath}/assets/${theme.preview}`)
|
||||||
|
),
|
||||||
|
status: 'installed',
|
||||||
|
progress: 0,
|
||||||
|
updateAvailable: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
};
|
||||||
|
|
||||||
|
function combineChunks(chunks: Uint8Array[], totalLength: number): Uint8Array {
|
||||||
|
const result = new Uint8Array(totalLength);
|
||||||
|
|
||||||
|
let offset = 0;
|
||||||
|
for (const chunk of chunks) {
|
||||||
|
result.set(chunk, offset);
|
||||||
|
offset += chunk.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const downloadTheme = async (
|
||||||
|
theme: Theme,
|
||||||
|
force = false
|
||||||
|
): Promise<{ success: boolean; error?: string }> => {
|
||||||
|
if (theme.status !== 'not-installed' && !force) return { success: false };
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'downloading';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
const themeFileName = `${toSafeName(theme.name)}.ezpplauncher-theme`;
|
||||||
|
const themeContents = await betterFetch<{
|
||||||
|
file_contents: {
|
||||||
|
sha: string;
|
||||||
|
download_url: string;
|
||||||
|
};
|
||||||
|
}>(
|
||||||
|
`https://git.ez-pp.farm/api/v1/repos/EZPPFarm/EZPPLauncher-Themes/contents-ext/themes/${themeFileName}?ref=main`
|
||||||
|
);
|
||||||
|
if (themeContents.error) {
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'not-installed';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: themeContents.error.message ?? 'An unknown error occurred',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const downloadUrl = `https://git.ez-pp.farm/EZPPFarm/EZPPLauncher-Themes/raw/branch/main/themes/${themeFileName}`;
|
||||||
|
const downloadReq = await fetch(downloadUrl, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!downloadReq.ok || downloadReq.body === null) {
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'not-installed';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Failed to download theme file.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const total = Number(downloadReq.headers.get('content-length')) || 0;
|
||||||
|
const reader = downloadReq.body.getReader();
|
||||||
|
let received = 0;
|
||||||
|
const chunks = [];
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
chunks.push(value);
|
||||||
|
received += value.length;
|
||||||
|
const progress = received / total;
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.progress = progress;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileBuffer = combineChunks(chunks, total);
|
||||||
|
|
||||||
|
const sha = calculateGitBlobSha(Buffer.from(fileBuffer));
|
||||||
|
if (sha !== themeContents.data.file_contents.sha) {
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'not-installed';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Failed to verify downloaded theme file hash.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: check file hash
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'extracting';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
const baseThemeFolder = await path.join(await path.homeDir(), '.ezpplauncher', 'themes');
|
||||||
|
const themeFolder = await path.join(baseThemeFolder, toSafeName(theme.name));
|
||||||
|
if (!(await fs.exists(baseThemeFolder))) await fs.mkdir(baseThemeFolder, { recursive: true });
|
||||||
|
if (!(await fs.exists(themeFolder))) await fs.mkdir(themeFolder, { recursive: true });
|
||||||
|
|
||||||
|
const zipFile = await zip.loadAsync(fileBuffer);
|
||||||
|
const totalFiles = Object.keys(zipFile.files).length;
|
||||||
|
let extractedFiles = 0;
|
||||||
|
for (const zipEntry of Object.keys(zipFile.files)) {
|
||||||
|
const file = zipFile.file(zipEntry);
|
||||||
|
if (file) {
|
||||||
|
try {
|
||||||
|
const fileData = await file.async('uint8array');
|
||||||
|
const filePath = await path.join(themeFolder, zipEntry);
|
||||||
|
const dirPath = await path.dirname(filePath);
|
||||||
|
if (!(await fs.exists(dirPath))) await fs.mkdir(dirPath, { recursive: true });
|
||||||
|
await new Promise((res) => setTimeout(res, 250));
|
||||||
|
await fs.writeFile(filePath, fileData);
|
||||||
|
extractedFiles++;
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.progress = extractedFiles / totalFiles;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'not-installed';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Failed to extract theme file.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const themeInfo = await fs.readTextFile(await path.join(themeFolder, 'theme.json'));
|
||||||
|
const themeInfoObj = JSON.parse(themeInfo) as ThemeInfo;
|
||||||
|
const themeScriptUrl = convertFileSrc(
|
||||||
|
await path.normalize(`${themeFolder}/${themeInfoObj.entry}`)
|
||||||
|
);
|
||||||
|
const themeAssets = convertFileSrc(await path.normalize(`${themeFolder}/assets`));
|
||||||
|
const themePreview = convertFileSrc(
|
||||||
|
await path.normalize(`${themeFolder}/assets/${themeInfoObj.preview}`)
|
||||||
|
);
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.scriptUrl = themeScriptUrl;
|
||||||
|
matchedTheme.assets = themeAssets;
|
||||||
|
matchedTheme.preview = themePreview;
|
||||||
|
matchedTheme.status = 'installed';
|
||||||
|
matchedTheme.progress = 1;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
|
||||||
|
await reloadThemes();
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const loadTheme = async (theme: Theme, themeContainer: HTMLElement, volume = 0.15) => {
|
||||||
|
active_custom_theme.set(theme);
|
||||||
|
themeContainer.innerHTML = '';
|
||||||
|
if (theme.scriptUrl.length > 0) {
|
||||||
|
const themeScript = await import(/* @vite-ignore */ theme.scriptUrl);
|
||||||
|
themeScript.mountTheme(themeContainer, { assets: theme.assets });
|
||||||
|
}
|
||||||
|
setGlobalVolume(volume);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteTheme = async (themeToUninstall: Theme) => {
|
||||||
|
if (themeToUninstall.status !== 'installed') return false;
|
||||||
|
const baseThemeFolder = await path.join(await path.homeDir(), '.ezpplauncher', 'themes');
|
||||||
|
if (!(await fs.exists(baseThemeFolder))) return false;
|
||||||
|
const themeFolder = await path.join(baseThemeFolder, themeToUninstall.folder_name);
|
||||||
|
if (!(await fs.exists(themeFolder))) return false;
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === themeToUninstall.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'deleting';
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
await fs.remove(themeFolder, { recursive: true });
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === themeToUninstall.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.scriptUrl = '';
|
||||||
|
matchedTheme.assets = '';
|
||||||
|
matchedTheme.preview = `https://git.ez-pp.farm/EZPPFarm/EZPPLauncher-Themes/raw/branch/main/previews/${toSafeName(themeToUninstall.name)}.png`;
|
||||||
|
matchedTheme.status = 'not-installed';
|
||||||
|
matchedTheme.updateAvailable = false;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
|
||||||
|
await reloadThemes();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const checkThemeFromFile = async (filePath: string) => {
|
||||||
|
const normalizedFilePath = await path.normalize(filePath);
|
||||||
|
if (!(await fs.exists(normalizedFilePath))) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'File not found',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const fileBuffer = await fs.readFile(normalizedFilePath);
|
||||||
|
|
||||||
|
let themeInfo: ThemeInfo | undefined = undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const zipFile = await zip.loadAsync(fileBuffer);
|
||||||
|
|
||||||
|
const themeConfig = zipFile.file('theme.json');
|
||||||
|
if (!themeConfig) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Theme config file not found',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const themeConfigData = await themeConfig.async('string');
|
||||||
|
themeInfo = JSON.parse(themeConfigData) as {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
apiVersion: string;
|
||||||
|
author: string;
|
||||||
|
entry: string;
|
||||||
|
style: string;
|
||||||
|
preview: string;
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Could not read theme file',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: !!themeInfo,
|
||||||
|
themeInfo,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const importThemeFromFile = async (themeName: string, filePath: string) => {
|
||||||
|
const baseThemeFolder = await path.join(await path.homeDir(), '.ezpplauncher', 'themes');
|
||||||
|
const themeFolder = await path.join(baseThemeFolder, toSafeName(themeName));
|
||||||
|
if (!(await fs.exists(baseThemeFolder))) await fs.mkdir(baseThemeFolder, { recursive: true });
|
||||||
|
if (!(await fs.exists(themeFolder))) await fs.mkdir(themeFolder, { recursive: true });
|
||||||
|
|
||||||
|
const fileBuffer = await fs.readFile(filePath);
|
||||||
|
const zipFile = await zip.loadAsync(fileBuffer);
|
||||||
|
for (const zipEntry of Object.keys(zipFile.files)) {
|
||||||
|
const file = zipFile.file(zipEntry);
|
||||||
|
if (file) {
|
||||||
|
try {
|
||||||
|
const fileData = await file.async('uint8array');
|
||||||
|
const filePath = await path.join(themeFolder, zipEntry);
|
||||||
|
const dirPath = await path.dirname(filePath);
|
||||||
|
if (!(await fs.exists(dirPath))) await fs.mkdir(dirPath, { recursive: true });
|
||||||
|
await new Promise((res) => setTimeout(res, 250));
|
||||||
|
await fs.writeFile(filePath, fileData);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Failed to extract theme file.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await reloadThemes();
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const reloadThemes = async () => {
|
||||||
|
const [downloadableThemes, installedThemes] = await Promise.all([
|
||||||
|
getDownloadableThemes(),
|
||||||
|
getThemes(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const installedMap = new Map(installedThemes.map((t) => [t.name, t]));
|
||||||
|
const combinedMap = new Map(installedThemes.map((t) => [t.name, { ...t }]));
|
||||||
|
|
||||||
|
for (const downloadable of downloadableThemes) {
|
||||||
|
const installed = installedMap.get(downloadable.name);
|
||||||
|
|
||||||
|
if (installed) {
|
||||||
|
if (new SemVer(downloadable.version).compare(new SemVer(installed.version)) > 0) {
|
||||||
|
combinedMap.get(downloadable.name)!.updateAvailable = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
combinedMap.set(downloadable.name, downloadable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const combinedThemes = [...combinedMap.values()];
|
||||||
|
|
||||||
|
custom_themes.update((storeThemes) => {
|
||||||
|
const storeMap = new Map(storeThemes.map((t) => [t.name, t]));
|
||||||
|
const ACTIVE_STATUSES = new Set(['downloading', 'extracting', 'deleting']);
|
||||||
|
|
||||||
|
for (const theme of combinedThemes) {
|
||||||
|
const storeTheme = storeMap.get(theme.name);
|
||||||
|
if (!storeTheme || ACTIVE_STATUSES.has(storeTheme.status)) continue;
|
||||||
|
|
||||||
|
storeTheme.scriptUrl = theme.scriptUrl;
|
||||||
|
storeTheme.assets = theme.assets;
|
||||||
|
storeTheme.preview = theme.preview;
|
||||||
|
storeTheme.version = theme.version;
|
||||||
|
storeTheme.author = theme.author;
|
||||||
|
storeTheme.updateAvailable = theme.updateAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newThemes = combinedThemes.filter((t) => !storeMap.has(t.name));
|
||||||
|
const merged = [...storeThemes, ...newThemes];
|
||||||
|
|
||||||
|
return merged.sort((a, b) => {
|
||||||
|
if (a.name === 'Default') return -1;
|
||||||
|
if (b.name === 'Default') return 1;
|
||||||
|
if (a.status === 'installed' && b.status !== 'installed') return -1;
|
||||||
|
if (a.status !== 'installed' && b.status === 'installed') return 1;
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toSafeName = (name: string) => {
|
||||||
|
return (
|
||||||
|
name
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[<>:"/\\|?*]/g, '_')
|
||||||
|
// eslint-disable-next-line no-control-regex
|
||||||
|
.replace(/[\x00-\x1F\x7F]/g, '_')
|
||||||
|
.replace(/[\s-]+/g, '_')
|
||||||
|
.replace(/_+/g, '_')
|
||||||
|
.replace(/[. ]+$/g, '_')
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const generateRandomString = (length: number) => {
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
return Array.from({ length }, () =>
|
||||||
|
characters.charAt(Math.floor(Math.random() * characters.length))
|
||||||
|
).join('');
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
declare global {
|
||||||
|
const umami: Umami;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see {@link https://umami.is/docs/tracker-functions|Umami Docs}
|
||||||
|
*/
|
||||||
|
interface Umami {
|
||||||
|
track(): Promise<string> | undefined;
|
||||||
|
track(event_name: string, event_data?: Record<string, unknown>): Promise<string> | undefined;
|
||||||
|
track(custom_payload: { website: string; [key: string]: unknown }): Promise<string> | undefined;
|
||||||
|
track(
|
||||||
|
callback: (props: {
|
||||||
|
hostname: string;
|
||||||
|
language: string;
|
||||||
|
referrer: string;
|
||||||
|
screen: string;
|
||||||
|
title: string;
|
||||||
|
url: string;
|
||||||
|
website: string;
|
||||||
|
}) => { website: string; [key: string]: unknown }
|
||||||
|
): Promise<string> | undefined;
|
||||||
|
|
||||||
|
/** Pass in your own ID to identify a user. */
|
||||||
|
identify(identity_id: string): Promise<void>;
|
||||||
|
|
||||||
|
/** Save data about the current session. */
|
||||||
|
identify(identity_id: string, data: Record<string, unknown>): Promise<void>;
|
||||||
|
|
||||||
|
/** To save data without a unique ID, pass in only a JSON object. */
|
||||||
|
identify(data: Record<string, unknown>): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { type ClassValue, clsx } from 'clsx';
|
import { type ClassValue, clsx } from 'clsx';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
import { custom_theme_audio_playing } from './global';
|
||||||
|
import * as crypto from 'crypto-js';
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
@@ -44,7 +46,6 @@ export const formatTimeReadable = (initialSeconds: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const releaseStreamToReadable = (releaseStream: string) => {
|
export const releaseStreamToReadable = (releaseStream: string) => {
|
||||||
console.log(releaseStream.replaceAll(' ', '').toLowerCase());
|
|
||||||
if (releaseStream.replaceAll(' ', '').toLowerCase() === 'cuttingedge') return 'Cutting Edge';
|
if (releaseStream.replaceAll(' ', '').toLowerCase() === 'cuttingedge') return 'Cutting Edge';
|
||||||
return 'Stable';
|
return 'Stable';
|
||||||
};
|
};
|
||||||
@@ -100,3 +101,111 @@ export const urlIsValidImage = async (url: string) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function toURL(data: Buffer, type: string) {
|
||||||
|
return URL.createObjectURL(new Blob([new Uint8Array(data)], { type }));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setGlobalVolume(volume: number) {
|
||||||
|
const mediaElements: NodeListOf<HTMLMediaElement> = document.querySelectorAll('audio, video');
|
||||||
|
mediaElements.forEach((element) => {
|
||||||
|
element.volume = volume;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fadeGlobalVolume(
|
||||||
|
volumeFrom: number,
|
||||||
|
volumeTo: number,
|
||||||
|
duration: number,
|
||||||
|
onDone?: () => void
|
||||||
|
) {
|
||||||
|
const mediaElements: NodeListOf<HTMLMediaElement> = document.querySelectorAll('audio, video');
|
||||||
|
|
||||||
|
const startTime = performance.now();
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
const currentTime = performance.now();
|
||||||
|
const elapsedTime = currentTime - startTime;
|
||||||
|
const progress = Math.min(elapsedTime / duration, 1);
|
||||||
|
|
||||||
|
const interpolatedVolume = volumeFrom + (volumeTo - volumeFrom) * progress;
|
||||||
|
|
||||||
|
mediaElements.forEach((element) => {
|
||||||
|
element.volume = interpolatedVolume;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (progress < 1) {
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
} else {
|
||||||
|
if (onDone) onDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
animate();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pauseGlobalMedia = () => {
|
||||||
|
const mediaElements: NodeListOf<HTMLMediaElement> = document.querySelectorAll('audio, video');
|
||||||
|
mediaElements.forEach((element) => element.pause());
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resumeGlobalMedia = () => {
|
||||||
|
const mediaElements: NodeListOf<HTMLMediaElement> = document.querySelectorAll('audio, video');
|
||||||
|
mediaElements.forEach((element) => element.play());
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setCurrentTimeGlobalMedia = (time: number) => {
|
||||||
|
const mediaElements: NodeListOf<HTMLMediaElement> = document.querySelectorAll('audio, video');
|
||||||
|
mediaElements.forEach((element) => (element.currentTime = time));
|
||||||
|
};
|
||||||
|
|
||||||
|
export function trackMediaContainer(node: HTMLElement) {
|
||||||
|
const media = new Set<HTMLMediaElement>();
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
custom_theme_audio_playing.set(Array.from(media).some((el) => !el.paused));
|
||||||
|
}
|
||||||
|
|
||||||
|
function register(el: HTMLMediaElement) {
|
||||||
|
media.add(el);
|
||||||
|
|
||||||
|
const handler = () => update();
|
||||||
|
el.addEventListener('play', handler);
|
||||||
|
el.addEventListener('pause', handler);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
media.delete(el);
|
||||||
|
el.removeEventListener('play', handler);
|
||||||
|
el.removeEventListener('pause', handler);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// find existing media inside the div
|
||||||
|
node.querySelectorAll<HTMLMediaElement>('video, audio').forEach(register);
|
||||||
|
|
||||||
|
const observer = new MutationObserver((mutations) => {
|
||||||
|
for (const m of mutations) {
|
||||||
|
m.addedNodes.forEach((n) => {
|
||||||
|
if (n instanceof HTMLMediaElement) register(n);
|
||||||
|
if (n instanceof HTMLElement) {
|
||||||
|
n.querySelectorAll<HTMLMediaElement>('video, audio').forEach(register);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(node, { childList: true, subtree: true });
|
||||||
|
|
||||||
|
return {
|
||||||
|
destroy() {
|
||||||
|
observer.disconnect();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function calculateGitBlobSha(fileBuffer: Buffer): string {
|
||||||
|
const header = Buffer.from(`blob ${fileBuffer.length}\0`);
|
||||||
|
const store = Buffer.concat([header, fileBuffer]);
|
||||||
|
|
||||||
|
return crypto.SHA1(crypto.lib.WordArray.create(store)).toString(crypto.enc.Hex);
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,13 +5,20 @@
|
|||||||
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
||||||
import * as AlertDialog from '@/components/ui/alert-dialog';
|
import * as AlertDialog from '@/components/ui/alert-dialog';
|
||||||
import {
|
import {
|
||||||
|
active_custom_theme,
|
||||||
currentLoadingInfo,
|
currentLoadingInfo,
|
||||||
|
custom_theme_container,
|
||||||
|
custom_theme_volume,
|
||||||
|
custom_themes,
|
||||||
discordPresence,
|
discordPresence,
|
||||||
firstStartup,
|
firstStartup,
|
||||||
launcherVersion,
|
launcherVersion,
|
||||||
|
openTabletDriverEnabled,
|
||||||
|
openTabletDriverPath,
|
||||||
platform,
|
platform,
|
||||||
presenceLoading,
|
presenceLoading,
|
||||||
setupValues,
|
setupValues,
|
||||||
|
trackingEnabled,
|
||||||
} from '@/global';
|
} from '@/global';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
|
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
|
||||||
@@ -24,14 +31,17 @@
|
|||||||
userSettings,
|
userSettings,
|
||||||
} from '@/userSettings';
|
} from '@/userSettings';
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
import { Toaster } from '@/components/ui/sonner';
|
import SileoToast from '@/components/ui/sileo/sileo-toast.svelte';
|
||||||
import { userAuth } from '@/userAuthentication';
|
import { userAuth } from '@/userAuthentication';
|
||||||
import { encryptString, exit, getLauncherVersion, getPlatform } from '@/osuUtil';
|
import { exit, getLauncherVersion, getPlatform } from '@/osuUtil';
|
||||||
import Button from '@/components/ui/button/button.svelte';
|
import Button from '@/components/ui/button/button.svelte';
|
||||||
import * as presence from '@/presence';
|
import * as presence from '@/presence';
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
import '@fontsource/sora';
|
import { getDownloadableThemes, getThemes, loadTheme } from '@/themes';
|
||||||
import '@fontsource/space-mono';
|
import { sileo } from 'sileo';
|
||||||
|
import AnimatedBg from '@/components/ui/animated-bg/AnimatedBg.svelte';
|
||||||
|
import { SemVer } from 'semver';
|
||||||
|
import { trackMediaContainer } from '@/utils';
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
@@ -91,30 +101,52 @@
|
|||||||
disableReload();
|
disableReload();
|
||||||
setupValues();
|
setupValues();
|
||||||
launcherVersion.set(await getLauncherVersion());
|
launcherVersion.set(await getLauncherVersion());
|
||||||
platform.set(await getPlatform());
|
|
||||||
if ($platform !== 'windows' && $platform !== 'linux') unsupported_platform = true;
|
|
||||||
const isFirstStartup = await $userSettings.init();
|
const isFirstStartup = await $userSettings.init();
|
||||||
|
firstStartup.set(isFirstStartup);
|
||||||
$userAuth.init();
|
$userAuth.init();
|
||||||
|
|
||||||
currentLoadingInfo.set('Loading config...');
|
currentLoadingInfo.set('Loading config...');
|
||||||
|
const config_theme = $userSettings.value('theme');
|
||||||
|
const config_theme_volume = $userSettings.value('volume');
|
||||||
const config_patching = $userSettings.value('patching');
|
const config_patching = $userSettings.value('patching');
|
||||||
const config_custom_cursor = $userSettings.value('custom_cursor');
|
const config_custom_cursor = $userSettings.value('custom_cursor');
|
||||||
const config_cursor_smoothening = $userSettings.value('cursor_smoothening');
|
const config_cursor_smoothening = $userSettings.value('cursor_smoothening');
|
||||||
const config_reduce_animations = $userSettings.value('reduce_animations');
|
const config_reduce_animations = $userSettings.value('reduce_animations');
|
||||||
const config_osu_installation_path = $userSettings.value('osu_installation_path');
|
const config_osu_installation_path = $userSettings.value('osu_installation_path');
|
||||||
const config_discord_presence = $userSettings.value('discord_presence');
|
const config_discord_presence = $userSettings.value('discord_presence');
|
||||||
|
const config_tracking_enabled = $userSettings.value('tracking_consent');
|
||||||
|
const config_otd_enabled = $userSettings.value('otd_enabled');
|
||||||
|
const config_otd_path = $userSettings.value('otd_path');
|
||||||
|
|
||||||
|
const localThemes = await getThemes();
|
||||||
|
const last_theme = localThemes.find((t) => t.name === config_theme.get('Default'));
|
||||||
|
if (!last_theme) {
|
||||||
|
$userSettings.value('theme').set('Default');
|
||||||
|
await $userSettings.save();
|
||||||
|
loadTheme(localThemes[0], $custom_theme_container!, config_theme_volume.get(0.15));
|
||||||
|
} else {
|
||||||
|
loadTheme(last_theme, $custom_theme_container!, config_theme_volume.get(0.15));
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_theme_volume.set(config_theme_volume.get(0.15));
|
||||||
patch.set(config_patching.get(true));
|
patch.set(config_patching.get(true));
|
||||||
customCursor.set(config_custom_cursor.get(true));
|
customCursor.set(config_custom_cursor.get(true));
|
||||||
cursorSmoothening.set(config_cursor_smoothening.get(true));
|
cursorSmoothening.set(config_cursor_smoothening.get(true));
|
||||||
reduceAnimations.set(config_reduce_animations.get(false));
|
reduceAnimations.set(config_reduce_animations.get(false));
|
||||||
osuInstallationPath.set(config_osu_installation_path.get(''));
|
osuInstallationPath.set(config_osu_installation_path.get(''));
|
||||||
discordPresence.set(config_discord_presence.get(true));
|
discordPresence.set(config_discord_presence.get(true));
|
||||||
|
openTabletDriverEnabled.set(config_otd_enabled.get(false));
|
||||||
|
openTabletDriverPath.set(config_otd_path.get(''));
|
||||||
|
if (config_tracking_enabled.exists()) {
|
||||||
|
trackingEnabled.set(config_tracking_enabled.get(false));
|
||||||
|
}
|
||||||
|
|
||||||
patch.subscribe((val) => config_patching.set(val));
|
patch.subscribe((val) => config_patching.set(val));
|
||||||
customCursor.subscribe((val) => config_custom_cursor.set(val));
|
customCursor.subscribe((val) => config_custom_cursor.set(val));
|
||||||
cursorSmoothening.subscribe((val) => config_cursor_smoothening.set(val));
|
cursorSmoothening.subscribe((val) => config_cursor_smoothening.set(val));
|
||||||
reduceAnimations.subscribe((val) => config_reduce_animations.set(val));
|
reduceAnimations.subscribe((val) => config_reduce_animations.set(val));
|
||||||
|
openTabletDriverEnabled.subscribe((val) => config_otd_enabled.set(val));
|
||||||
|
|
||||||
discordPresence.subscribe(async (val) => {
|
discordPresence.subscribe(async (val) => {
|
||||||
config_discord_presence.set(val);
|
config_discord_presence.set(val);
|
||||||
try {
|
try {
|
||||||
@@ -125,7 +157,10 @@
|
|||||||
await presence.disconnect();
|
await presence.disconnect();
|
||||||
}
|
}
|
||||||
presenceLoading.set(false);
|
presenceLoading.set(false);
|
||||||
} catch {}
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
presenceLoading.set(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -135,9 +170,44 @@
|
|||||||
await presence.connect();
|
await presence.connect();
|
||||||
presenceLoading.set(false);
|
presenceLoading.set(false);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
presenceLoading.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
firstStartup.set(isFirstStartup);
|
try {
|
||||||
|
currentLoadingInfo.set('Loading themes...');
|
||||||
|
const downloadableThemes = await getDownloadableThemes();
|
||||||
|
const combinedThemes = [...localThemes];
|
||||||
|
for (const theme of downloadableThemes) {
|
||||||
|
if (!combinedThemes.find((t) => t.name === theme.name)) combinedThemes.push(theme);
|
||||||
|
const installedTheme = localThemes.find((t) => t.name === theme.name);
|
||||||
|
if (installedTheme) {
|
||||||
|
const installedThemeVersion = new SemVer(installedTheme.version);
|
||||||
|
const downloadableThemeVersion = new SemVer(theme.version);
|
||||||
|
if (downloadableThemeVersion.compare(installedThemeVersion) > 0) {
|
||||||
|
installedTheme.updateAvailable = true;
|
||||||
|
const index = combinedThemes.findIndex((t) => t.name === theme.name);
|
||||||
|
combinedThemes[index] = installedTheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_themes.set(combinedThemes);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
sileo.error({
|
||||||
|
title: 'An error occured!',
|
||||||
|
description: 'Failed to load themes',
|
||||||
|
fill: '#181825',
|
||||||
|
styles: {
|
||||||
|
description: 'text-center!',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
platform.set(await getPlatform());
|
||||||
|
if ($platform !== 'windows' && $platform !== 'linux') unsupported_platform = true;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -145,7 +215,7 @@
|
|||||||
<OsuCursor smoothCursor={$cursorSmoothening} />
|
<OsuCursor smoothCursor={$cursorSmoothening} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Toaster richColors closeButton />
|
<SileoToast position="top-center" fill="black" />
|
||||||
|
|
||||||
<Titlebar />
|
<Titlebar />
|
||||||
|
|
||||||
@@ -173,5 +243,19 @@
|
|||||||
</AlertDialog.Root>
|
</AlertDialog.Root>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
<div class="opacity-30">
|
||||||
|
<div transition:fade={{ duration: $reduceAnimations ? 0 : 500 }}>
|
||||||
|
<div
|
||||||
|
class={$active_custom_theme && $active_custom_theme.name === 'Default'
|
||||||
|
? 'hidden'
|
||||||
|
: 'absolute z-0 top-0 left-0 w-full h-full object-cover object-center aspect-video'}
|
||||||
|
bind:this={$custom_theme_container}
|
||||||
|
use:trackMediaContainer
|
||||||
|
></div>
|
||||||
|
{#if ($active_custom_theme && $active_custom_theme.name === 'Default') || !$active_custom_theme}
|
||||||
|
<AnimatedBg />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||