Compare commits
118 Commits
3.1.3
..
03b326e142
| Author | SHA1 | Date | |
|---|---|---|---|
| 03b326e142 | |||
| 2ec8b08983 | |||
| 344f15b8da | |||
| 554f07412b | |||
| f8f53c4236 | |||
| 64f76d95a6 | |||
| 02fecd237c | |||
| eaffc35288 | |||
| 78c7fdb756 | |||
| ec7ce53016 | |||
| 0610d4beef | |||
|
416067f2ea
|
|||
|
e58be09bdb
|
|||
| ccb0c467f2 | |||
|
67bc968497
|
|||
|
dc06b53089
|
|||
|
d5e5fd4c43
|
|||
|
29359c9242
|
|||
|
71bd64a2cf
|
|||
|
7fa83d6d0a
|
|||
|
f2e795e2c9
|
|||
|
cece28dd46
|
|||
| 474f1f0c33 | |||
| 871c40922e | |||
| 20e8389409 | |||
|
051a86943e
|
|||
|
7d0147edb9
|
|||
|
7e2404753b
|
|||
|
9952e164c5
|
|||
|
df8ee34e73
|
|||
|
3a27646da8
|
|||
|
ace3320632
|
|||
| 2ba094f07e | |||
| fcf9e46a8f | |||
| 3768ab1064 | |||
| e5e09505a0 | |||
| 94f78f281d | |||
| d2ecc5210f | |||
| 6f8036e9d4 | |||
| 73256f32c4 | |||
| cfb4c8a611 | |||
| f2d8056cfd | |||
| 2eb95cd802 | |||
| a28d56e283 | |||
| f88a33c2aa | |||
| 8a964d0a6a | |||
| cc4697efbc | |||
|
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 |
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"useTabs": false,
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"plugins": ["prettier-plugin-svelte"],
|
"plugins": ["prettier-plugin-svelte", "@trivago/prettier-plugin-sort-imports"],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": "*.svelte",
|
"files": "*.svelte",
|
||||||
|
|||||||
Vendored
+3
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"svelte.enable-ts-plugin": true,
|
"svelte.enable-ts-plugin": true,
|
||||||
|
"git.enableCommitSigning": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.formatOnSaveMode": "file",
|
||||||
"[rust]": {
|
"[rust]": {
|
||||||
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ It enhances the osu! experience with quality-of-life features and integration sp
|
|||||||
## 🚀 Features
|
## 🚀 Features
|
||||||
|
|
||||||
- [x] Automatically updates osu! before launching
|
- [x] Automatically updates osu! before launching
|
||||||
|
- [x] Automatically start/stop the OpenTabletDriver Daemon
|
||||||
- [x] Automatic ingame login
|
- [x] Automatic ingame login
|
||||||
- [x] Patches the osu! client to show misses in Relax and Autopilot
|
- [x] Patches the osu! client to show misses in Relax and Autopilot
|
||||||
- [x] Displays your EZPPFarm stats in the launcher
|
- [x] Displays your EZPPFarm stats in the launcher
|
||||||
@@ -22,6 +23,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
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -73,3 +75,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.
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 157 KiB |
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://next.shadcn-svelte.com/schema.json",
|
"$schema": "https://shadcn-svelte.com/schema.json",
|
||||||
"tailwind": {
|
"tailwind": {
|
||||||
"css": "src\\app.css",
|
"css": "src\\app.css",
|
||||||
"baseColor": "gray"
|
"baseColor": "gray"
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
"lib": "$lib"
|
"lib": "$lib"
|
||||||
},
|
},
|
||||||
"typescript": true,
|
"typescript": true,
|
||||||
"registry": "https://tw3.shadcn-svelte.com/registry/default"
|
"registry": "https://shadcn-svelte.com/registry"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
import prettier from 'eslint-config-prettier';
|
import svelteConfig from './svelte.config.js';
|
||||||
import { includeIgnoreFile } from '@eslint/compat';
|
import { includeIgnoreFile } from '@eslint/compat';
|
||||||
import js from '@eslint/js';
|
import js from '@eslint/js';
|
||||||
|
import prettier from 'eslint-config-prettier';
|
||||||
import svelte from 'eslint-plugin-svelte';
|
import svelte from 'eslint-plugin-svelte';
|
||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import ts from 'typescript-eslint';
|
import ts from 'typescript-eslint';
|
||||||
import svelteConfig from './svelte.config.js';
|
|
||||||
|
|
||||||
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
|
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
|
||||||
|
|
||||||
|
|||||||
+45
-44
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "ezpplauncher",
|
"name": "ezpplauncher",
|
||||||
"version": "3.1.3",
|
"version": "3.2.3",
|
||||||
"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 vite:build && 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,64 +18,65 @@
|
|||||||
},
|
},
|
||||||
"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.4.0",
|
"@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.10.1",
|
"@tauri-apps/api": "^2.11.0",
|
||||||
"@tauri-apps/plugin-dialog": "^2.6.0",
|
"@tauri-apps/plugin-dialog": "^2.7.1",
|
||||||
"@tauri-apps/plugin-fs": "^2.4.5",
|
"@tauri-apps/plugin-fs": "^2.5.1",
|
||||||
"@tauri-apps/plugin-shell": "^2.3.5",
|
"@tauri-apps/plugin-shell": "^2.3.5",
|
||||||
"@types/umami": "^2.10.1",
|
"@types/node": "^25.9.1",
|
||||||
"animejs": "^4.1.3",
|
"animejs": "^4.4.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"lucide-svelte": "^1.0.1",
|
"jszip": "^3.10.1",
|
||||||
"react": "^19.2.4",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.4",
|
"react-dom": "^19.2.6",
|
||||||
"react-to-webcomponent": "^2.0.1",
|
"react-to-webcomponent": "^2.0.1",
|
||||||
"semver": "^7.7.2",
|
"semver": "^7.8.1",
|
||||||
"sileo": "^0.1.3",
|
"sileo": "^0.1.5",
|
||||||
"svelte-confetti": "^2.3.2",
|
"svelte-confetti": "^2.3.2",
|
||||||
"tw-animate-css": "^1.3.8"
|
"tw-animate-css": "^1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^2.0.0",
|
"@eslint/compat": "^2.1.0",
|
||||||
"@eslint/js": "^9.35.0",
|
"@eslint/js": "^10.0.1",
|
||||||
"@iarna/toml": "2.2.5",
|
"@iarna/toml": "2.2.5",
|
||||||
"@lucide/svelte": "^1.8.0",
|
"@lucide/svelte": "^1.16.0",
|
||||||
"@sveltejs/adapter-static": "^3.0.9",
|
"@sveltejs/adapter-static": "^3.0.10",
|
||||||
"@sveltejs/kit": "^2.57.1",
|
"@sveltejs/kit": "^2.61.1",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||||
"@tauri-apps/cli": "^2.10.0",
|
"@tauri-apps/cli": "^2.11.2",
|
||||||
"@types/bun": "^1.2.21",
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
||||||
|
"@types/bun": "^1.3.14",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"autoprefixer": "10.4.21",
|
"autoprefixer": "10.5.0",
|
||||||
"bits-ui": "^1.4.7",
|
"bits-ui": "^2.18.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"eslint": "^9.35.0",
|
"eslint": "^10.4.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-svelte": "^3.12.2",
|
"eslint-plugin-svelte": "^3.17.1",
|
||||||
"globals": "^17.0.0",
|
"globals": "^17.6.0",
|
||||||
"mode-watcher": "^1.1.0",
|
"mode-watcher": "^1.1.0",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.8.3",
|
||||||
"prettier-plugin-svelte": "^3.4.0",
|
"prettier-plugin-svelte": "^4.0.1",
|
||||||
"sass-embedded": "^1.92.1",
|
"sass-embedded": "^1.100.0",
|
||||||
"svelte": "^5.55.3",
|
"svelte": "^5.55.9",
|
||||||
"svelte-check": "^4.3.1",
|
"svelte-check": "^4.4.8",
|
||||||
"svelte-sonner": "^1.0.5",
|
"svelte-sonner": "^1.1.1",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.6.0",
|
||||||
"tailwind-variants": "^3.1.0",
|
"tailwind-variants": "^3.2.2",
|
||||||
"tailwindcss": "^4.1.7",
|
"tailwindcss": "^4.3.0",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "^6.0.2",
|
"typescript": "^6.0.3",
|
||||||
"typescript-eslint": "^8.42.0",
|
"typescript-eslint": "^8.60.0",
|
||||||
"vite": "^8.0.8",
|
"vite": "^8.0.14",
|
||||||
"vite-plugin-devtools-json": "^1.0.0"
|
"vite-plugin-devtools-json": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
//set NO_STRIP=1 in env for linux to prevent stripping of debug symbols in tauri builds, which causes issues with source maps
|
||||||
|
if (process.platform === 'linux') process.env.NO_STRIP = '1';
|
||||||
|
await run('bunx', ['tauri', 'build']);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import * as toml from '@iarna/toml';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as toml from '@iarna/toml';
|
|
||||||
import { cwd } from 'process';
|
import { cwd } from 'process';
|
||||||
|
|
||||||
const packageJsonPath = path.join(cwd(), 'package.json');
|
const packageJsonPath = path.join(cwd(), 'package.json');
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"types": ["@types/bun", "@types/node"]
|
||||||
|
},
|
||||||
|
"include": ["*.ts"]
|
||||||
|
}
|
||||||
Generated
+1268
-323
File diff suppressed because it is too large
Load Diff
+36
-17
@@ -1,12 +1,22 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ezpplauncher"
|
name = "ezpplauncher"
|
||||||
version = "3.1.3"
|
version = "3.2.3"
|
||||||
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,35 +25,44 @@ name = "ezpplauncher_lib"
|
|||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.5.5", features = [] }
|
tauri-build = { version = "2.6.2", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2.10.2", features = [] }
|
tauri = { version = "2.11.2", features = ["protocol-asset"] }
|
||||||
tauri-plugin-shell = "2.3.5"
|
tauri-plugin-shell = "2.3.5"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = "1.0.149"
|
serde_json = "1.0.150"
|
||||||
serde_repr = "0.1.20"
|
serde_repr = "0.1.20"
|
||||||
tauri-plugin-dialog = "2.6.0"
|
tauri-plugin-dialog = "2.7.1"
|
||||||
tauri-plugin-fs = "2.4.5"
|
tauri-plugin-fs = "2.5.1"
|
||||||
hardware-id = "0.3.0"
|
hardware-id = "0.3.0"
|
||||||
tauri-plugin-cors-fetch = "5.0.0"
|
tauri-plugin-cors-fetch = "5.0.0"
|
||||||
sysinfo = "0.38.2"
|
sysinfo = "0.39.2"
|
||||||
reqwest = { version = "0.13.2", features = ["json", "stream", "query"] }
|
reqwest = { version = "0.13.4", features = ["json", "stream", "query"] }
|
||||||
md5 = "0.8.0"
|
md5 = "0.8.0"
|
||||||
tokio = { version = "1.48.0", features = ["full"] }
|
tokio = { version = "1.52.3", features = ["full"] }
|
||||||
open = "5.3.3"
|
open = "5.3.5"
|
||||||
discord-rich-presence = "1.1.0"
|
presenceforge = { version = "0.2.1", features = ["tokio-runtime"] }
|
||||||
once_cell = "1.21.3"
|
once_cell = "1.21.4"
|
||||||
futures-util = "0.3.32"
|
futures-util = "0.3.32"
|
||||||
osynic_osudb = "0.1.4"
|
byteorder = "1.5.0"
|
||||||
|
anyhow = "1.0.102"
|
||||||
|
url = "2.5.8"
|
||||||
|
zip = "8.6.0"
|
||||||
|
sha1 = "0.11.0"
|
||||||
|
hex = "0.4.3"
|
||||||
|
rusqlite = { version = "0.40.0", features = ["bundled"] }
|
||||||
|
aes-gcm = "0.10.3"
|
||||||
|
base64 = "0.22.1"
|
||||||
|
sha2 = "0.11.0"
|
||||||
|
thiserror = "2.0.18"
|
||||||
|
|
||||||
[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.9", features = ["winuser", "wincrypt", "memoryapi", "winbase", "dpapi"] }
|
||||||
base64 = "0.22.1"
|
|
||||||
widestring = "1.2.1"
|
widestring = "1.2.1"
|
||||||
windows-sys = "0.61.2"
|
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.4.0"
|
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,57 +21,127 @@
|
|||||||
{
|
{
|
||||||
"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/**/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,3 +4,18 @@
|
|||||||
Exec '"$INSTDIR\${MAINBINARYNAME}.exe"'
|
Exec '"$INSTDIR\${MAINBINARYNAME}.exe"'
|
||||||
${EndIf}
|
${EndIf}
|
||||||
!macroend
|
!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
|
||||||
+557
-115
@@ -1,19 +1,26 @@
|
|||||||
|
use crate::config::ConfigError;
|
||||||
use hardware_id::get_id;
|
use hardware_id::get_id;
|
||||||
use osynic_osudb::entity::osu::osudb::OsuDB;
|
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::Value;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::Stdio;
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
use tauri::State;
|
||||||
|
use tauri_plugin_fs::FsExt;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio::time::{Duration, sleep};
|
use tokio::time::{Duration, sleep};
|
||||||
|
|
||||||
|
use crate::osudb::parse_osudb;
|
||||||
use crate::presence;
|
use crate::presence;
|
||||||
|
use crate::state::AppState;
|
||||||
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,
|
||||||
get_window_title_by_pid, is_net8_installed, is_osuwinello_available, is_wmctrl_available,
|
get_window_title_by_pid, is_net8_installed, is_osuwinello_available, is_wmctrl_available,
|
||||||
@@ -21,14 +28,23 @@ use crate::utils::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_launcher_version() -> String {
|
pub fn opened_urls(app: tauri::AppHandle) -> Vec<PathBuf> {
|
||||||
env!("CARGO_PKG_VERSION").to_string()
|
let args = app.state::<AppState>().opened_files.lock().unwrap().clone();
|
||||||
|
app.state::<AppState>().opened_files.lock().unwrap().clear();
|
||||||
|
|
||||||
|
args
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_launcher_version(app: tauri::AppHandle) -> String {
|
||||||
|
app.package_info().version.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_hwid() -> String {
|
pub fn get_hwid() -> String {
|
||||||
let hwid = get_id().unwrap();
|
get_id()
|
||||||
hwid.into()
|
.unwrap_or("recorderinsandybridge".to_string())
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
@@ -64,15 +80,10 @@ pub fn valid_osu_folder(folder: String) -> bool {
|
|||||||
check_folder_completeness(path, &osu_folder_files) >= 70.0
|
check_folder_completeness(path, &osu_folder_files) >= 70.0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn find_osu_installation() -> Option<String> {
|
pub fn find_osu_installation() -> Option<String> {
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tauri::command]
|
{
|
||||||
pub fn find_osu_installation() -> Option<String> {
|
|
||||||
use winreg::RegKey;
|
use winreg::RegKey;
|
||||||
use winreg::enums::*;
|
use winreg::enums::*;
|
||||||
|
|
||||||
@@ -119,7 +130,8 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
let stripped = trimmed.strip_suffix(",0").unwrap_or(trimmed);
|
let stripped = trimmed.strip_suffix(",0").unwrap_or(trimmed);
|
||||||
let path = PathBuf::from(stripped.trim());
|
let path = PathBuf::from(stripped.trim());
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
let match_percentage = check_folder_completeness(parent, &osu_folder_files);
|
let match_percentage =
|
||||||
|
check_folder_completeness(parent, &osu_folder_files);
|
||||||
|
|
||||||
if match_percentage >= 70.0 {
|
if match_percentage >= 70.0 {
|
||||||
return Some(parent.to_string_lossy().into());
|
return Some(parent.to_string_lossy().into());
|
||||||
@@ -141,7 +153,8 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
let stripped = trimmed.strip_suffix(",1").unwrap_or(trimmed);
|
let stripped = trimmed.strip_suffix(",1").unwrap_or(trimmed);
|
||||||
let path = PathBuf::from(stripped.trim());
|
let path = PathBuf::from(stripped.trim());
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
let match_percentage = check_folder_completeness(parent, &osu_folder_files);
|
let match_percentage =
|
||||||
|
check_folder_completeness(parent, &osu_folder_files);
|
||||||
|
|
||||||
if match_percentage >= 70.0 {
|
if match_percentage >= 70.0 {
|
||||||
return Some(parent.to_string_lossy().into());
|
return Some(parent.to_string_lossy().into());
|
||||||
@@ -151,6 +164,7 @@ pub fn find_osu_installation() -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,10 +175,15 @@ pub async fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
|||||||
if !osu_db_path.exists() {
|
if !osu_db_path.exists() {
|
||||||
return Some(0);
|
return Some(0);
|
||||||
}
|
}
|
||||||
let mut osudb = OsuDB::from_file(&osu_db_path).unwrap();
|
let osu_db_bytes = fs::read(osu_db_path).await.ok()?;
|
||||||
let beatmaps = osudb.beatmaps.iter_mut();
|
let osu_db = parse_osudb(osu_db_bytes).ok()?;
|
||||||
let beatmap_sets = beatmaps.map(|b| b.beatmapset_id).collect::<HashSet<_>>();
|
let beatmap_sets = osu_db
|
||||||
return Some(beatmap_sets.len() as u64);
|
.beatmaps
|
||||||
|
.iter()
|
||||||
|
.map(|b| b.beatmapset_id)
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
.len();
|
||||||
|
Some(beatmap_sets as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -242,7 +261,7 @@ pub async fn get_skins_count(folder: String) -> Option<u64> {
|
|||||||
let skins_folder = path.join("Skins");
|
let skins_folder = path.join("Skins");
|
||||||
|
|
||||||
if !skins_folder.exists() {
|
if !skins_folder.exists() {
|
||||||
return None;
|
return Some(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
@@ -432,14 +451,37 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if patch {
|
if patch {
|
||||||
sleep(Duration::from_secs(3)).await;
|
|
||||||
|
|
||||||
let patcher_exe_path = PathBuf::from(&folder)
|
let patcher_exe_path = PathBuf::from(&folder)
|
||||||
.join("EZPPLauncher")
|
.join("EZPPLauncher")
|
||||||
.join("patcher")
|
.join("patcher")
|
||||||
.join("osu!.patcher.exe");
|
.join("osu!.patcher.exe");
|
||||||
|
|
||||||
if patcher_exe_path.exists() {
|
if patcher_exe_path.exists() {
|
||||||
|
let mut sys = System::new_all();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
sys.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||||
|
|
||||||
|
let mut found = false;
|
||||||
|
|
||||||
|
for (_pid, process) in sys.processes() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
let _ = Command::new(&patcher_exe_path)
|
let _ = Command::new(&patcher_exe_path)
|
||||||
@@ -447,6 +489,14 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
||||||
}
|
}
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
let _ = Command::new("osu-wine")
|
||||||
|
.arg("--wine")
|
||||||
|
.arg(&patcher_exe_path)
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("Failed to run patcher: {}", e))?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,7 +640,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),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,92 +657,86 @@ pub fn replace_ui_files(folder: String, revert: bool) -> Result<(), ReplaceUIErr
|
|||||||
let osu_seasonal_bak = osu_path.join("osu!seasonal.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 create_link = |target: &PathBuf, link: &PathBuf| -> Result<(), ReplaceUIError> {
|
let temp_file = osu_path.join(".ezpplauncher_files");
|
||||||
if !target.exists() {
|
|
||||||
return Err(ReplaceUIError::FileNotFound(target.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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if link.exists() || link.is_symlink() {
|
if dest.exists() {
|
||||||
std::fs::remove_file(link).ok();
|
std::fs::remove_file(dest).map_err(|e| {
|
||||||
|
ReplaceUIError::IoError(format!("Failed to remove {}: {}", name, e))
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
std::fs::copy(source, dest)
|
||||||
{
|
.map_err(|e| ReplaceUIError::IoError(format!("Failed to copy {}: {}", name, e)))?;
|
||||||
let result = if target.is_dir() {
|
Ok(())
|
||||||
std::os::windows::fs::symlink_dir(target, link)
|
|
||||||
} else {
|
|
||||||
std::os::windows::fs::symlink_file(target, link)
|
|
||||||
};
|
|
||||||
if result.is_ok() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
if std::os::unix::fs::symlink(target, link).is_ok() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::fs::hard_link(target, link).map_err(|e| match e.kind() {
|
|
||||||
std::io::ErrorKind::NotFound => {
|
|
||||||
ReplaceUIError::FileNotFound(target.display().to_string())
|
|
||||||
}
|
|
||||||
std::io::ErrorKind::PermissionDenied => {
|
|
||||||
ReplaceUIError::PermissionDenied(target.display().to_string())
|
|
||||||
}
|
|
||||||
_ => ReplaceUIError::IoError(e.to_string()),
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let remove_link = |link: &PathBuf| -> Result<(), ReplaceUIError> {
|
let restore_backup =
|
||||||
if link.exists() || link.is_symlink() {
|
|bak: &PathBuf, dest: &PathBuf, name: &str| -> Result<(), ReplaceUIError> {
|
||||||
std::fs::remove_file(link).map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
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(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
if !revert {
|
if !revert {
|
||||||
if osu_ui.exists() && !osu_ui_bak.exists() {
|
if osu_ui.exists() && !osu_ui_bak.exists() {
|
||||||
std::fs::rename(&osu_ui, &osu_ui_bak)
|
std::fs::rename(&osu_ui, &osu_ui_bak).map_err(|e| {
|
||||||
.map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
ReplaceUIError::IoError(format!("Failed to backup osu!ui.dll: {}", e))
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
if osu_seasonal.exists() && !osu_seasonal_bak.exists() {
|
if osu_seasonal.exists() && !osu_seasonal_bak.exists() {
|
||||||
std::fs::rename(&osu_seasonal, &osu_seasonal_bak)
|
std::fs::rename(&osu_seasonal, &osu_seasonal_bak).map_err(|e| {
|
||||||
.map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
ReplaceUIError::IoError(format!("Failed to backup osu!seasonal.dll: {}", e))
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
if osu_gameplay.exists() && !osu_gameplay_bak.exists() {
|
if osu_gameplay.exists() && !osu_gameplay_bak.exists() {
|
||||||
std::fs::rename(&osu_gameplay, &osu_gameplay_bak)
|
std::fs::rename(&osu_gameplay, &osu_gameplay_bak).map_err(|e| {
|
||||||
.map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
ReplaceUIError::IoError(format!("Failed to backup osu!gameplay.dll: {}", e))
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_link(&ezpp_ui, &osu_ui)?;
|
copy_file(&ezpp_ui, &osu_ui, "osu!ui.dll")?;
|
||||||
create_link(&ezpp_seasonal, &osu_seasonal)?;
|
copy_file(&ezpp_seasonal, &osu_seasonal, "osu!seasonal.dll")?;
|
||||||
create_link(&ezpp_gameplay, &osu_gameplay)?;
|
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 {
|
||||||
remove_link(&osu_ui)?;
|
restore_backup(&osu_ui_bak, &osu_ui, "osu!ui.dll")?;
|
||||||
remove_link(&osu_seasonal)?;
|
restore_backup(&osu_seasonal_bak, &osu_seasonal, "osu!seasonal.dll")?;
|
||||||
remove_link(&osu_gameplay)?;
|
restore_backup(&osu_gameplay_bak, &osu_gameplay, "osu!gameplay.dll")?;
|
||||||
|
|
||||||
if osu_ui_bak.exists() {
|
if osu_ui.exists() && osu_seasonal.exists() && osu_gameplay.exists() {
|
||||||
std::fs::rename(&osu_ui_bak, &osu_ui)
|
std::fs::remove_file(&temp_file).map_err(|e| {
|
||||||
.map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
ReplaceUIError::IoError(format!("Failed to remove marker file: {}", e))
|
||||||
}
|
})?;
|
||||||
if osu_seasonal_bak.exists() {
|
|
||||||
std::fs::rename(&osu_seasonal_bak, &osu_seasonal)
|
|
||||||
.map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
|
||||||
}
|
|
||||||
if osu_gameplay_bak.exists() {
|
|
||||||
std::fs::rename(&osu_gameplay_bak, &osu_gameplay)
|
|
||||||
.map_err(|e| ReplaceUIError::IoError(e.to_string()))?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(tag = "type", content = "details")]
|
||||||
|
pub enum CorruptionCheckError {
|
||||||
|
IoError(String),
|
||||||
|
FileNotFound(String),
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn check_for_corruption(folder: String) -> Result<bool, String> {
|
pub async fn check_for_corruption(folder: String) -> Result<bool, CorruptionCheckError> {
|
||||||
let osu_path = PathBuf::from(folder);
|
let osu_path = PathBuf::from(folder);
|
||||||
let osu_ui = osu_path.join("osu!ui.dll");
|
let osu_ui = osu_path.join("osu!ui.dll");
|
||||||
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
||||||
@@ -703,47 +746,69 @@ pub async fn check_for_corruption(folder: String) -> Result<bool, String> {
|
|||||||
let osu_gameplay_bak = osu_path.join("osu!gameplay.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 osu_seasonal_bak = osu_path.join("osu!seasonal.dll.bak");
|
||||||
|
|
||||||
let check_and_restore = async |path: &PathBuf, bak: &PathBuf| -> Result<bool, String> {
|
let temp_file = osu_path.join(".ezpplauncher_files");
|
||||||
if path.exists() && bak.exists() {
|
|
||||||
fs::remove_file(path).await.map_err(|e| e.to_string())?;
|
if temp_file.exists() {
|
||||||
fs::rename(bak, path).await.map_err(|e| e.to_string())?;
|
if osu_ui_bak.exists() {
|
||||||
Ok(false)
|
if osu_ui.exists() {
|
||||||
} else if path.exists() {
|
fs::remove_file(&osu_ui).await.map_err(|e| {
|
||||||
let is_symlink = || -> bool {
|
CorruptionCheckError::IoError(format!("Failed to remove osu!ui.dll: {}", e))
|
||||||
if let Ok(meta) = std::fs::symlink_metadata(path) {
|
})?;
|
||||||
return meta.file_type().is_symlink();
|
|
||||||
}
|
}
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
fs::rename(&osu_ui_bak, &osu_ui).await.map_err(|e| {
|
||||||
let is_hard_link = || -> bool {
|
CorruptionCheckError::IoError(format!(
|
||||||
use std::os::unix::fs::MetadataExt;
|
"Failed to restore osu!ui.dll from backup: {}",
|
||||||
if let Ok(meta) = std::fs::symlink_metadata(path) {
|
e
|
||||||
return meta.len() == 0 && meta.nlink() > 1;
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
))
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
fs::rename(&osu_gameplay_bak, &osu_gameplay)
|
||||||
let is_hard_link = || -> bool {
|
.await
|
||||||
false
|
.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
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
if is_symlink() || is_hard_link() {
|
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);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
} else {
|
|
||||||
Ok(true)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let ui_corrupted = check_and_restore(&osu_ui, &osu_ui_bak).await?;
|
|
||||||
let gameplay_corrupted = check_and_restore(&osu_gameplay, &osu_gameplay_bak).await?;
|
|
||||||
let seasonal_corrupted = check_and_restore(&osu_seasonal, &osu_seasonal_bak).await?;
|
|
||||||
|
|
||||||
Ok(ui_corrupted || gameplay_corrupted || seasonal_corrupted)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -814,6 +879,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
|
||||||
@@ -882,9 +962,10 @@ pub async fn download_ezpp_launcher_update(app: AppHandle, url: String) -> Resul
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn install_ezpp_launcher_update(app: AppHandle) -> Result<(), String> {
|
pub async fn install_ezpp_launcher_update(app: AppHandle) -> Result<(), String> {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
let temp_dir = app.path().temp_dir().expect("Failed to get temp directory");
|
let temp_dir = app.path().temp_dir().expect("Failed to get temp directory");
|
||||||
let file_path = temp_dir.join("ezpplauncher_update.exe");
|
let file_path = temp_dir.join("ezpplauncher_update.exe");
|
||||||
if !file_path.exists() {
|
if !file_path.exists() {
|
||||||
@@ -905,12 +986,373 @@ pub async fn install_ezpp_launcher_update(app: AppHandle) -> Result<(), String>
|
|||||||
sleep(Duration::from_millis(250)).await;
|
sleep(Duration::from_millis(250)).await;
|
||||||
|
|
||||||
app.exit(0x0100);
|
app.exit(0x0100);
|
||||||
|
}
|
||||||
|
|
||||||
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 CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
|
Command::new(&otd_path)
|
||||||
|
.creation_flags(CREATE_NO_WINDOW)
|
||||||
|
.stdin(Stdio::null())
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("Failed to start OpenTabletDriver: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn stop_open_tablet_driver() -> Result<(), String> {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
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("OpenTabletDriver.Daemon.exe"))
|
||||||
|
.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))]
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn install_ezpp_launcher_update(_app: AppHandle) -> Result<(), String> {
|
pub async fn is_open_tablet_driver_path_valid(app: AppHandle, path: String) -> bool {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
app.fs_scope().allow_file(&path).ok();
|
||||||
|
let otd_path = PathBuf::from(&path);
|
||||||
|
otd_path.exists()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Clone)]
|
||||||
|
pub struct ExtractProgress {
|
||||||
|
pub theme_name: String,
|
||||||
|
pub total: usize,
|
||||||
|
pub extracted: usize,
|
||||||
|
pub progress: f64,
|
||||||
|
pub current_file: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Clone)]
|
||||||
|
pub struct DownloadProgress {
|
||||||
|
pub theme_name: String,
|
||||||
|
pub received: u64,
|
||||||
|
pub total: u64,
|
||||||
|
pub progress: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn download_and_extract_theme(
|
||||||
|
app: AppHandle,
|
||||||
|
download_url: String,
|
||||||
|
expected_sha: String,
|
||||||
|
theme_folder: String,
|
||||||
|
theme_name: String,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let response = client
|
||||||
|
.get(&download_url)
|
||||||
|
.header(
|
||||||
|
"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",
|
||||||
|
)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to download theme: {}", e))?;
|
||||||
|
|
||||||
|
let total = response.content_length().unwrap_or(0);
|
||||||
|
let mut received: u64 = 0;
|
||||||
|
let mut chunks: Vec<u8> = Vec::new();
|
||||||
|
|
||||||
|
let mut stream = response.bytes_stream();
|
||||||
|
while let Some(chunk) = futures_util::StreamExt::next(&mut stream).await {
|
||||||
|
let chunk = chunk.map_err(|e| format!("Failed to read chunk: {}", e))?;
|
||||||
|
received += chunk.len() as u64;
|
||||||
|
chunks.extend_from_slice(&chunk);
|
||||||
|
let _ = app.emit(
|
||||||
|
"download_progress",
|
||||||
|
DownloadProgress {
|
||||||
|
theme_name: theme_name.clone(),
|
||||||
|
received,
|
||||||
|
total,
|
||||||
|
progress: if total > 0 {
|
||||||
|
received as f64 / total as f64
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let sha = tokio::task::spawn_blocking({
|
||||||
|
let chunks = chunks.clone();
|
||||||
|
move || {
|
||||||
|
use sha1::{Digest, Sha1};
|
||||||
|
let header = format!("blob {}\0", chunks.len());
|
||||||
|
let mut hasher = Sha1::new();
|
||||||
|
hasher.update(header.as_bytes());
|
||||||
|
hasher.update(&chunks);
|
||||||
|
hex::encode(hasher.finalize())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Thread error: {}", e))?;
|
||||||
|
|
||||||
|
if sha != expected_sha {
|
||||||
|
return Err("Failed to verify downloaded theme file hash.".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse zip on blocking thread
|
||||||
|
let entries: Vec<(String, Vec<u8>, bool)> = tokio::task::spawn_blocking(move || {
|
||||||
|
let cursor = std::io::Cursor::new(chunks);
|
||||||
|
let mut archive = zip::ZipArchive::new(cursor)
|
||||||
|
.map_err(|e| format!("Failed to read zip archive: {}", e))?;
|
||||||
|
|
||||||
|
let mut entries = Vec::new();
|
||||||
|
for i in 0..archive.len() {
|
||||||
|
let mut zip_entry = archive
|
||||||
|
.by_index(i)
|
||||||
|
.map_err(|e| format!("Failed to read zip entry: {}", e))?;
|
||||||
|
|
||||||
|
let name = match zip_entry.enclosed_name() {
|
||||||
|
Some(p) => p.to_string_lossy().to_string(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let is_dir = zip_entry.is_dir();
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
if !is_dir {
|
||||||
|
std::io::copy(&mut zip_entry, &mut buf)
|
||||||
|
.map_err(|e| format!("Failed to read zip entry data: {}", e))?;
|
||||||
|
}
|
||||||
|
entries.push((name, buf, is_dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<_, String>(entries)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Thread error: {}", e))??;
|
||||||
|
|
||||||
|
let total_files = entries.len();
|
||||||
|
let mut extracted = 0;
|
||||||
|
|
||||||
|
for (name, buf, is_dir) in entries {
|
||||||
|
let entry_path = std::path::Path::new(&theme_folder).join(&name);
|
||||||
|
|
||||||
|
if is_dir {
|
||||||
|
tokio::fs::create_dir_all(&entry_path)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to create directory: {}", e))?;
|
||||||
|
} else {
|
||||||
|
if let Some(parent) = entry_path.parent() {
|
||||||
|
tokio::fs::create_dir_all(parent)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to create parent directory: {}", e))?;
|
||||||
|
}
|
||||||
|
tokio::fs::write(&entry_path, &buf)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to write file: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
extracted += 1;
|
||||||
|
let _ = app.emit(
|
||||||
|
"extract_progress",
|
||||||
|
ExtractProgress {
|
||||||
|
theme_name: theme_name.clone(),
|
||||||
|
total: total_files,
|
||||||
|
extracted,
|
||||||
|
progress: extracted as f64 / total_files as f64,
|
||||||
|
current_file: name,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn extract_theme(
|
||||||
|
app: AppHandle,
|
||||||
|
file_path: String,
|
||||||
|
theme_folder: String,
|
||||||
|
theme_name: String,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
app.fs_scope().allow_file(&file_path).ok();
|
||||||
|
let entries: Vec<(String, Vec<u8>, bool)> = tokio::task::spawn_blocking(move || {
|
||||||
|
let file = std::fs::File::open(&file_path)
|
||||||
|
.map_err(|e| format!("Failed to open theme file: {}", e))?;
|
||||||
|
let mut archive =
|
||||||
|
zip::ZipArchive::new(file).map_err(|e| format!("Failed to read zip archive: {}", e))?;
|
||||||
|
|
||||||
|
let mut entries = Vec::new();
|
||||||
|
for i in 0..archive.len() {
|
||||||
|
let mut zip_entry = archive
|
||||||
|
.by_index(i)
|
||||||
|
.map_err(|e| format!("Failed to read zip entry: {}", e))?;
|
||||||
|
|
||||||
|
let name = match zip_entry.enclosed_name() {
|
||||||
|
Some(p) => p.to_string_lossy().to_string(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let is_dir = zip_entry.is_dir();
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
if !is_dir {
|
||||||
|
zip_entry
|
||||||
|
.read_to_end(&mut buf)
|
||||||
|
.map_err(|e| format!("Failed to read zip entry data: {}", e))?;
|
||||||
|
}
|
||||||
|
entries.push((name, buf, is_dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<_, String>(entries)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Thread error: {}", e))??;
|
||||||
|
|
||||||
|
let total = entries.len();
|
||||||
|
let mut extracted = 0;
|
||||||
|
|
||||||
|
for (name, buf, is_dir) in entries {
|
||||||
|
let entry_path = std::path::Path::new(&theme_folder).join(&name);
|
||||||
|
|
||||||
|
if is_dir {
|
||||||
|
tokio::fs::create_dir_all(&entry_path)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to create directory: {}", e))?;
|
||||||
|
} else {
|
||||||
|
if let Some(parent) = entry_path.parent() {
|
||||||
|
tokio::fs::create_dir_all(parent)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to create parent directory: {}", e))?;
|
||||||
|
}
|
||||||
|
tokio::fs::write(&entry_path, &buf)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to write file: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
extracted += 1;
|
||||||
|
let _ = app.emit(
|
||||||
|
"extract_progress",
|
||||||
|
ExtractProgress {
|
||||||
|
theme_name: theme_name.clone(),
|
||||||
|
total,
|
||||||
|
extracted,
|
||||||
|
progress: extracted as f64 / total as f64,
|
||||||
|
current_file: name,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
pub struct ThemeInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub entry: String,
|
||||||
|
pub preview: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn read_theme_info(app: AppHandle, file_path: String) -> Result<ThemeInfo, String> {
|
||||||
|
app.fs_scope().allow_file(&file_path).ok();
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let file = std::fs::File::open(&file_path)
|
||||||
|
.map_err(|e| format!("Failed to open theme file: {}", e))?;
|
||||||
|
let mut archive =
|
||||||
|
zip::ZipArchive::new(file).map_err(|e| format!("Failed to read zip archive: {}", e))?;
|
||||||
|
|
||||||
|
let mut theme_config = archive
|
||||||
|
.by_name("theme.json")
|
||||||
|
.map_err(|_| "Theme config file not found".to_string())?;
|
||||||
|
|
||||||
|
let mut contents = String::new();
|
||||||
|
std::io::Read::read_to_string(&mut theme_config, &mut contents)
|
||||||
|
.map_err(|e| format!("Failed to read theme config: {}", e))?;
|
||||||
|
|
||||||
|
let theme_info: ThemeInfo = serde_json::from_str(&contents)
|
||||||
|
.map_err(|e| format!("Failed to parse theme config: {}", e))?;
|
||||||
|
|
||||||
|
Ok(theme_info)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Thread error: {}", e))?
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn config_get(key: String, state: State<AppState>) -> Result<Option<Value>, ConfigError> {
|
||||||
|
state.config.lock().unwrap().get(&key)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn config_set(
|
||||||
|
key: String,
|
||||||
|
value: Value,
|
||||||
|
encrypt: bool,
|
||||||
|
state: State<AppState>,
|
||||||
|
) -> Result<(), ConfigError> {
|
||||||
|
state.config.lock().unwrap().set(&key, value, encrypt)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn config_exists(key: String, state: State<AppState>) -> Result<bool, ConfigError> {
|
||||||
|
state.config.lock().unwrap().exists(&key)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn config_delete(key: String, state: State<AppState>) -> Result<(), ConfigError> {
|
||||||
|
state.config.lock().unwrap().delete(&key)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn config_clear(state: State<AppState>) -> Result<(), ConfigError> {
|
||||||
|
state.config.lock().unwrap().clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn config_all(state: State<AppState>) -> Result<Vec<(String, Value)>, ConfigError> {
|
||||||
|
state.config.lock().unwrap().all()
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,219 @@
|
|||||||
|
use aes_gcm::aead::rand_core::RngCore;
|
||||||
|
use aes_gcm::{
|
||||||
|
Aes256Gcm, Key, Nonce,
|
||||||
|
aead::{Aead, KeyInit, OsRng},
|
||||||
|
};
|
||||||
|
use base64::{Engine, engine::general_purpose::STANDARD as BASE64};
|
||||||
|
use rusqlite::{Connection, OptionalExtension, params};
|
||||||
|
use serde_json::Value;
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum ConfigError {
|
||||||
|
#[error("SQLite error: {0}")]
|
||||||
|
Sqlite(#[from] rusqlite::Error),
|
||||||
|
#[error("Encryption error: {0}")]
|
||||||
|
Encryption(String),
|
||||||
|
#[error("JSON error: {0}")]
|
||||||
|
Json(#[from] serde_json::Error),
|
||||||
|
#[error("Base64 error: {0}")]
|
||||||
|
Base64(#[from] base64::DecodeError),
|
||||||
|
#[error("Config not initialized")]
|
||||||
|
NotInitialized,
|
||||||
|
#[error("IO error: {0}")]
|
||||||
|
Io(#[from] std::io::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for ConfigError {
|
||||||
|
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
||||||
|
s.serialize_str(&self.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Config {
|
||||||
|
db_path: PathBuf,
|
||||||
|
conn: Option<Connection>,
|
||||||
|
hwid_key: Option<[u8; 32]>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub fn new(db_path: impl Into<PathBuf>) -> Self {
|
||||||
|
Self {
|
||||||
|
db_path: db_path.into(),
|
||||||
|
conn: None,
|
||||||
|
hwid_key: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init(&mut self, hwid: &str) -> Result<bool, ConfigError> {
|
||||||
|
let mut hasher = Sha256::new();
|
||||||
|
hasher.update(hwid.as_bytes());
|
||||||
|
let key_bytes: [u8; 32] = hasher.finalize().into();
|
||||||
|
self.hwid_key = Some(key_bytes);
|
||||||
|
|
||||||
|
let is_new = !self.db_path.exists();
|
||||||
|
|
||||||
|
if let Some(parent) = self.db_path.parent() {
|
||||||
|
std::fs::create_dir_all(parent)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let conn = Connection::open(&self.db_path)?;
|
||||||
|
|
||||||
|
conn.execute_batch(
|
||||||
|
"
|
||||||
|
PRAGMA journal_mode=WAL;
|
||||||
|
CREATE TABLE IF NOT EXISTS config (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
encrypted INTEGER NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
self.conn = Some(conn);
|
||||||
|
Ok(is_new)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(&self, key: &str) -> Result<Option<Value>, ConfigError> {
|
||||||
|
let conn = self.conn.as_ref().ok_or(ConfigError::NotInitialized)?;
|
||||||
|
|
||||||
|
let mut stmt = conn.prepare("SELECT value, encrypted FROM config WHERE key = ?1")?;
|
||||||
|
|
||||||
|
let row: Option<(String, bool)> = stmt
|
||||||
|
.query_row(params![key], |r| Ok((r.get(0)?, r.get(1)?)))
|
||||||
|
.optional()?;
|
||||||
|
|
||||||
|
match row {
|
||||||
|
None => Ok(None),
|
||||||
|
Some((raw, false)) => Ok(Some(serde_json::from_str::<Value>(&raw)?)),
|
||||||
|
Some((raw, true)) => {
|
||||||
|
let plaintext = self
|
||||||
|
.decrypt_value(&raw)
|
||||||
|
.map_err(|_| ConfigError::Encryption(format!("failed to decrypt '{}'", key)))?;
|
||||||
|
|
||||||
|
serde_json::from_str::<Value>(&plaintext)
|
||||||
|
.map(Some)
|
||||||
|
.map_err(|_| {
|
||||||
|
ConfigError::Encryption(format!("decrypted '{}' is not valid JSON", key))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn exists(&self, key: &str) -> Result<bool, ConfigError> {
|
||||||
|
let conn = self.conn.as_ref().ok_or(ConfigError::NotInitialized)?;
|
||||||
|
let count: i64 = conn.query_row(
|
||||||
|
"SELECT COUNT(*) FROM config WHERE key = ?1",
|
||||||
|
params![key],
|
||||||
|
|r| r.get(0),
|
||||||
|
)?;
|
||||||
|
Ok(count > 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return all key/value pairs (decrypting encrypted ones).
|
||||||
|
pub fn all(&self) -> Result<Vec<(String, Value)>, ConfigError> {
|
||||||
|
let conn = self.conn.as_ref().ok_or(ConfigError::NotInitialized)?;
|
||||||
|
let mut stmt = conn.prepare("SELECT key, value, encrypted FROM config")?;
|
||||||
|
|
||||||
|
let rows = stmt.query_map([], |r| {
|
||||||
|
Ok((
|
||||||
|
r.get::<_, String>(0)?,
|
||||||
|
r.get::<_, String>(1)?,
|
||||||
|
r.get::<_, bool>(2)?,
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let mut out = Vec::new();
|
||||||
|
for row in rows {
|
||||||
|
let (k, raw, enc) = row?;
|
||||||
|
let v: Value = if enc {
|
||||||
|
let pt = self.decrypt_value(&raw)?;
|
||||||
|
serde_json::from_str(&pt)?
|
||||||
|
} else {
|
||||||
|
serde_json::from_str(&raw)?
|
||||||
|
};
|
||||||
|
out.push((k, v));
|
||||||
|
}
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set<T: serde::Serialize>(
|
||||||
|
&self,
|
||||||
|
key: &str,
|
||||||
|
value: T,
|
||||||
|
encrypt: bool,
|
||||||
|
) -> Result<(), ConfigError> {
|
||||||
|
let json = serde_json::to_string(&value)?;
|
||||||
|
if encrypt {
|
||||||
|
let blob = self.encrypt_value(&json)?;
|
||||||
|
self.upsert(key, &blob, true)
|
||||||
|
} else {
|
||||||
|
self.upsert(key, &json, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn delete(&self, key: &str) -> Result<(), ConfigError> {
|
||||||
|
let conn = self.conn.as_ref().ok_or(ConfigError::NotInitialized)?;
|
||||||
|
conn.execute("DELETE FROM config WHERE key = ?1", params![key])?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clear(&self) -> Result<(), ConfigError> {
|
||||||
|
let conn = self.conn.as_ref().ok_or(ConfigError::NotInitialized)?;
|
||||||
|
conn.execute("DELETE FROM config", [])?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn upsert(&self, key: &str, raw: &str, encrypted: bool) -> Result<(), ConfigError> {
|
||||||
|
let conn = self.conn.as_ref().ok_or(ConfigError::NotInitialized)?;
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO config (key, value, encrypted)
|
||||||
|
VALUES (?1, ?2, ?3)
|
||||||
|
ON CONFLICT(key) DO UPDATE SET value = excluded.value,
|
||||||
|
encrypted = excluded.encrypted",
|
||||||
|
params![key, raw, encrypted as i32],
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cipher(&self) -> Result<Aes256Gcm, ConfigError> {
|
||||||
|
let key_bytes = self.hwid_key.ok_or(ConfigError::NotInitialized)?;
|
||||||
|
let key = Key::<Aes256Gcm>::from_slice(&key_bytes);
|
||||||
|
Ok(Aes256Gcm::new(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn encrypt_value(&self, plaintext: &str) -> Result<String, ConfigError> {
|
||||||
|
let cipher = self.cipher()?;
|
||||||
|
let mut nonce_bytes = [0u8; 12];
|
||||||
|
OsRng.fill_bytes(&mut nonce_bytes);
|
||||||
|
let nonce = Nonce::from_slice(&nonce_bytes);
|
||||||
|
|
||||||
|
let ciphertext = cipher
|
||||||
|
.encrypt(nonce, plaintext.as_bytes())
|
||||||
|
.map_err(|e| ConfigError::Encryption(e.to_string()))?;
|
||||||
|
|
||||||
|
let mut combined = nonce_bytes.to_vec();
|
||||||
|
combined.extend_from_slice(&ciphertext);
|
||||||
|
Ok(BASE64.encode(&combined))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decrypt_value(&self, blob: &str) -> Result<String, ConfigError> {
|
||||||
|
let cipher = self.cipher()?;
|
||||||
|
let combined = BASE64.decode(blob)?;
|
||||||
|
|
||||||
|
if combined.len() < 12 {
|
||||||
|
return Err(ConfigError::Encryption("blob too short".into()));
|
||||||
|
}
|
||||||
|
|
||||||
|
let (nonce_bytes, ciphertext) = combined.split_at(12);
|
||||||
|
let nonce = Nonce::from_slice(nonce_bytes);
|
||||||
|
|
||||||
|
let plaintext = cipher
|
||||||
|
.decrypt(nonce, ciphertext)
|
||||||
|
.map_err(|e| ConfigError::Encryption(e.to_string()))?;
|
||||||
|
|
||||||
|
String::from_utf8(plaintext).map_err(|e| ConfigError::Encryption(e.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
+98
-19
@@ -1,38 +1,108 @@
|
|||||||
// 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 hardware_id::get_id;
|
||||||
|
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 config;
|
||||||
|
pub mod osudb;
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
|
pub mod state;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
use crate::commands::{
|
use crate::{
|
||||||
check_for_corruption, download_ezpp_launcher_update, download_ezpp_launcher_update_files,
|
commands::{
|
||||||
encrypt_string, exit, find_osu_installation, get_beatmapsets_count,
|
check_for_corruption, config_all, config_clear, config_delete, config_exists, config_get,
|
||||||
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
|
config_set, download_and_extract_theme, download_ezpp_launcher_update,
|
||||||
get_osu_skin, get_osu_version, get_platform, get_skins, get_skins_count, has_net8,
|
download_ezpp_launcher_update_files, encrypt_string, exit, extract_theme,
|
||||||
has_osuwinello, has_wmctrl, install_ezpp_launcher_update, is_osu_running, open_url_in_browser,
|
find_osu_installation, get_beatmapsets_count, get_ezpp_launcher_update_files, get_hwid,
|
||||||
presence_connect, presence_disconnect, presence_is_connected, presence_update_status,
|
get_launcher_version, get_osu_release_stream, get_osu_skin, get_osu_version, get_platform,
|
||||||
presence_update_user, replace_ui_files, run_osu, run_osu_updater, set_osu_config_values,
|
get_skins, get_skins_count, has_net8, has_osuwinello, has_wmctrl,
|
||||||
set_osu_user_config_values, valid_osu_folder,
|
install_ezpp_launcher_update, is_open_tablet_driver_path_valid,
|
||||||
|
is_open_tablet_driver_running, is_osu_running, open_url_in_browser, opened_urls,
|
||||||
|
presence_connect, presence_disconnect, presence_is_connected, presence_update_button,
|
||||||
|
presence_update_status, presence_update_user, read_theme_info, replace_ui_files,
|
||||||
|
run_open_tablet_driver, run_osu, run_osu_updater, set_osu_config_values,
|
||||||
|
set_osu_user_config_values, stop_open_tablet_driver, valid_osu_folder,
|
||||||
|
},
|
||||||
|
state::AppState,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[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
|
||||||
|
.setup(|app| {
|
||||||
|
// ── Config ────────────────────────────────────────────────────────
|
||||||
|
let home = std::env::var("HOME")
|
||||||
|
.or_else(|_| std::env::var("USERPROFILE"))
|
||||||
|
.unwrap_or_else(|_| ".".into());
|
||||||
|
let db_path = PathBuf::from(home).join(".ezpplauncher").join("config.db");
|
||||||
|
|
||||||
|
let hwid = get_id().unwrap_or_else(|_| "recorderinsandybridge".into());
|
||||||
|
|
||||||
|
let mut cfg = config::Config::new(db_path);
|
||||||
|
cfg.init(&hwid)?;
|
||||||
|
|
||||||
|
// ── Opened files ──────────────────────────────────────────────────
|
||||||
|
let mut opened_files = Vec::new();
|
||||||
|
let args = std::env::args().collect::<Vec<_>>();
|
||||||
|
if args.len() > 1 {
|
||||||
|
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();
|
||||||
|
opened_files.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.manage(AppState {
|
||||||
|
config: Mutex::new(cfg),
|
||||||
|
opened_files: Mutex::new(opened_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,
|
||||||
@@ -59,13 +129,27 @@ 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,
|
||||||
has_net8,
|
has_net8,
|
||||||
encrypt_string,
|
encrypt_string,
|
||||||
download_ezpp_launcher_update,
|
download_ezpp_launcher_update,
|
||||||
install_ezpp_launcher_update
|
install_ezpp_launcher_update,
|
||||||
|
read_theme_info,
|
||||||
|
extract_theme,
|
||||||
|
download_and_extract_theme,
|
||||||
|
config_get,
|
||||||
|
config_set,
|
||||||
|
config_exists,
|
||||||
|
config_delete,
|
||||||
|
config_clear,
|
||||||
|
config_all,
|
||||||
|
run_open_tablet_driver,
|
||||||
|
stop_open_tablet_driver,
|
||||||
|
is_open_tablet_driver_running,
|
||||||
|
is_open_tablet_driver_path_valid
|
||||||
])
|
])
|
||||||
.plugin(tauri_plugin_fs::init())
|
.plugin(tauri_plugin_fs::init())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
@@ -74,12 +158,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,
|
||||||
|
})
|
||||||
|
}
|
||||||
+208
-111
@@ -1,15 +1,17 @@
|
|||||||
use discord_rich_presence::{
|
|
||||||
activity::{Activity, Assets, Button, Timestamps},
|
|
||||||
DiscordIpc, DiscordIpcClient,
|
|
||||||
};
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::future::Future;
|
use presenceforge::{ActivityBuilder, AsyncDiscordIpcClient};
|
||||||
use std::pin::Pin;
|
|
||||||
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::{Duration, interval};
|
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 {
|
||||||
pub state: String,
|
pub state: String,
|
||||||
@@ -18,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,14 +43,21 @@ enum PresenceCommand {
|
|||||||
Disconnect(oneshot::Sender<()>),
|
Disconnect(oneshot::Sender<()>),
|
||||||
UpdateData(PresenceData),
|
UpdateData(PresenceData),
|
||||||
IsConnected(oneshot::Sender<bool>),
|
IsConnected(oneshot::Sender<bool>),
|
||||||
Tick,
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
@@ -43,153 +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_secs(5));
|
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(responder) => {
|
|
||||||
let _ = responder.send(self.client.is_some());
|
|
||||||
}
|
}
|
||||||
PresenceCommand::Tick => {
|
PresenceCommand::IsConnected(resp) => {
|
||||||
if self.client.is_some() {
|
let _ = resp.send(self.client.is_some());
|
||||||
self.handle_update().await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some(result) = self.reconnect_rx.recv() => {
|
||||||
|
self.reconnecting = false;
|
||||||
|
match result {
|
||||||
|
ReconnectResult::Connected(client) => {
|
||||||
|
println!("Presence: reconnect succeeded.");
|
||||||
|
self.client = Some(client);
|
||||||
|
self.push_presence().await;
|
||||||
}
|
}
|
||||||
_ = update_interval.tick() => {
|
ReconnectResult::Failed => {
|
||||||
let _ = PRESENCE_TX.send(PresenceCommand::Tick).await;
|
eprintln!("Presence: all reconnect attempts exhausted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = heartbeat.tick() => {
|
||||||
|
self.push_presence().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_connect(&mut self, responder: oneshot::Sender<bool>) -> Pin<Box<dyn Future<Output = ()> + Send + '_>> {
|
async fn cmd_connect(&mut self, resp: oneshot::Sender<bool>) {
|
||||||
Box::pin(async move {
|
|
||||||
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 {
|
||||||
let mut dc_client = DiscordIpcClient::new("1032772293220384808");
|
Some(client) => {
|
||||||
match dc_client.connect() {
|
self.client = Some(client);
|
||||||
Ok(()) => {
|
self.reconnecting = false;
|
||||||
self.client = Some(dc_client);
|
self.push_presence().await;
|
||||||
println!("Actor: Connected successfully.");
|
let _ = resp.send(true);
|
||||||
self.handle_update().await;
|
|
||||||
let _ = responder.send(true);
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
None => {
|
||||||
eprintln!("Failed to connect to Discord: {:?}. Retrying in 5s...", e);
|
eprintln!("Presence: initial connect failed; spawning reconnect task.");
|
||||||
let tx = PRESENCE_TX.clone();
|
let _ = resp.send(false);
|
||||||
tokio::spawn(async move {
|
self.spawn_reconnect_task();
|
||||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
|
||||||
let (resp_tx, _) = oneshot::channel();
|
|
||||||
let _ = tx.send(PresenceCommand::Connect(resp_tx)).await;
|
|
||||||
});
|
|
||||||
|
|
||||||
if !responder.is_closed() {
|
|
||||||
let _ = responder.send(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_disconnect(&mut self, responder: oneshot::Sender<()>) {
|
async fn cmd_disconnect(&mut self, resp: oneshot::Sender<()>) {
|
||||||
if let Some(mut client) = self.client.take() {
|
if let Some(mut client) = self.client.take() {
|
||||||
println!("Actor: Disconnecting from Discord...");
|
let _ = client.clear_activity().await;
|
||||||
let _ = client.clear_activity();
|
println!("Presence: disconnected.");
|
||||||
let _ = client.close();
|
|
||||||
println!("Actor: Disconnected successfully.");
|
|
||||||
}
|
}
|
||||||
let _ = responder.send(());
|
let _ = resp.send(());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_update(&mut self) {
|
async fn push_presence(&mut self) {
|
||||||
if let Some(client) = self.client.as_mut() {
|
let client = match self.client.as_mut() {
|
||||||
let mut assets = Assets::new()
|
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_image(&self.data.large_image_key)
|
||||||
.large_text(&self.data.large_image_text);
|
.large_text(&self.data.large_image_text);
|
||||||
|
|
||||||
if let Some(key) = &self.data.small_image_key {
|
if let Some(key) = &self.data.small_image_key {
|
||||||
assets = assets.small_image(key);
|
builder = builder.small_image(key);
|
||||||
}
|
}
|
||||||
if let Some(text) = &self.data.small_image_text {
|
if let Some(text) = &self.data.small_image_text {
|
||||||
assets = assets.small_text(text);
|
builder = builder.small_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
let activity = Activity::new()
|
if let Some(btn) = &self.data.dynamic_button {
|
||||||
.state(&self.data.state)
|
builder = builder.button(&btn.label, &btn.url);
|
||||||
.details(&self.data.details)
|
} else {
|
||||||
.timestamps(Timestamps::new().start(self.start_timestamp))
|
builder = builder.button(
|
||||||
.assets(assets)
|
|
||||||
.buttons(vec![
|
|
||||||
Button::new(
|
|
||||||
"Download the Launcher",
|
"Download the Launcher",
|
||||||
"https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest",
|
"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) {
|
|
||||||
eprintln!("Failed to set activity, disconnecting: {:?}", e);
|
|
||||||
self.client = None;
|
|
||||||
|
|
||||||
let (tx, _) = oneshot::channel();
|
|
||||||
self.handle_connect(tx).await;
|
|
||||||
} else {
|
|
||||||
println!("Actor: Presence updated successfully.");
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = tx.send(ReconnectResult::Failed).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) => {
|
||||||
|
eprintln!("Presence: IPC connect error: {:?}", e);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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();
|
||||||
@@ -201,8 +256,7 @@ pub async fn connect() -> bool {
|
|||||||
|
|
||||||
pub async fn disconnect() {
|
pub async fn disconnect() {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
// Use a timeout to ensure we don't hang the exit process if Discord is unresponsive
|
if PRESENCE_TX.send(PresenceCommand::Disconnect(tx)).await.is_ok() {
|
||||||
if let Ok(_) = PRESENCE_TX.send(PresenceCommand::Disconnect(tx)).await {
|
|
||||||
let _ = tokio::time::timeout(Duration::from_secs(2), rx).await;
|
let _ = tokio::time::timeout(Duration::from_secs(2), rx).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,30 +274,73 @@ pub async fn has_presence() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 = {
|
||||||
|
let mut guard = PRESENCE_DATA.lock().unwrap();
|
||||||
if let Some(s) = state {
|
if let Some(s) = state {
|
||||||
data.state = s.to_string();
|
guard.state = s.to_string();
|
||||||
}
|
}
|
||||||
if let Some(d) = details {
|
if let Some(d) = details {
|
||||||
data.details = d.to_string();
|
guard.details = d.to_string();
|
||||||
}
|
}
|
||||||
if let Some(img) = large_image_key {
|
if let Some(img) = large_image_key {
|
||||||
data.large_image_key = img.to_string();
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// state.rs
|
||||||
|
use crate::config::Config;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
pub struct AppState {
|
||||||
|
pub config: Mutex<Config>,
|
||||||
|
pub opened_files: Mutex<Vec<PathBuf>>,
|
||||||
|
}
|
||||||
+10
-3
@@ -24,10 +24,13 @@ pub fn get_osu_user_config<P: AsRef<Path>>(
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let current_user = std::env::var("USERNAME").unwrap_or_else(|_| "Admin".to_string());
|
let current_user = std::env::var("USERNAME")
|
||||||
|
.or_else(|_| std::env::var("USER"))
|
||||||
|
.unwrap_or_else(|_| "Admin".to_string());
|
||||||
let osu_config_path = osu_folder_path
|
let osu_config_path = osu_folder_path
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.join(format!("osu!.{}.cfg", current_user));
|
.join(format!("osu!.{}.cfg", current_user));
|
||||||
|
println!("Looking for user config at: {:?}", osu_config_path);
|
||||||
if !osu_config_path.exists() {
|
if !osu_config_path.exists() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -48,7 +51,9 @@ pub fn set_osu_user_config_vals(
|
|||||||
osu_folder_path: &str,
|
osu_folder_path: &str,
|
||||||
key_values: &[(&str, Option<&str>)],
|
key_values: &[(&str, Option<&str>)],
|
||||||
) -> Result<bool, String> {
|
) -> Result<bool, String> {
|
||||||
let current_user = std::env::var("USERNAME").unwrap_or_else(|_| "Admin".to_string());
|
let current_user = std::env::var("USERNAME")
|
||||||
|
.or_else(|_| std::env::var("USER"))
|
||||||
|
.unwrap_or_else(|_| "Admin".to_string());
|
||||||
let osu_config_path = Path::new(osu_folder_path).join(format!("osu!.{}.cfg", current_user));
|
let osu_config_path = Path::new(osu_folder_path).join(format!("osu!.{}.cfg", current_user));
|
||||||
|
|
||||||
if !osu_config_path.exists() {
|
if !osu_config_path.exists() {
|
||||||
@@ -310,7 +315,9 @@ 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.lines().any(|line| line.starts_with("Microsoft.WindowsDesktop.App 8."))
|
stdout_str
|
||||||
|
.lines()
|
||||||
|
.any(|line| line.starts_with("Microsoft.WindowsDesktop.App 8."))
|
||||||
}
|
}
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "EZPPLauncher",
|
"productName": "EZPPLauncher",
|
||||||
"version": "3.1.3",
|
"version": "3.2.3",
|
||||||
"identifier": "farm.EZPPFarm.Launcher",
|
"identifier": "farm.EZPPFarm.Launcher",
|
||||||
"mainBinaryName": "ezpplauncher",
|
"mainBinaryName": "ezpplauncher",
|
||||||
"build": {
|
"build": {
|
||||||
@@ -16,19 +16,45 @@
|
|||||||
"title": "EZPPLauncher",
|
"title": "EZPPLauncher",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 650,
|
"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: customprotocol: asset:",
|
||||||
|
"script-src": "'self' 'unsafe-inline' asset: http://asset.localhost https://asset.localhost https://analytics.ez-pp.farm",
|
||||||
|
"style-src": "'self' 'unsafe-inline' asset: http://asset.localhost https://asset.localhost",
|
||||||
|
"img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct",
|
||||||
|
"connect-src": "'self' ipc: http://ipc.localhost 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 https://osu.ppy.sh",
|
||||||
|
"media-src": "'self' asset: http://asset.localhost https://asset.localhost blob:",
|
||||||
|
"font-src": [
|
||||||
|
"'self'",
|
||||||
|
"asset:",
|
||||||
|
"blob:",
|
||||||
|
"data:",
|
||||||
|
"http://asset.localhost",
|
||||||
|
"https://asset.localhost"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"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 +62,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,6 +81,7 @@
|
|||||||
"nsis": {
|
"nsis": {
|
||||||
"installMode": "currentUser",
|
"installMode": "currentUser",
|
||||||
"compression": "lzma",
|
"compression": "lzma",
|
||||||
|
"installerIcon": "icons/icon.ico",
|
||||||
"installerHooks": "./nsis/nsis-hooks.nsh"
|
"installerHooks": "./nsis/nsis-hooks.nsh"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+4
-1
@@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
@custom-variant dark (&:where(.dark, .dark *));
|
@custom-variant dark (&:where(.dark, .dark *));
|
||||||
|
|
||||||
|
@import "@fontsource-variable/sora";
|
||||||
|
@import "@fontsource/space-mono";
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--radius: 0.625rem;
|
--radius: 0.625rem;
|
||||||
--background: oklch(95.36% 0.017 256.57);
|
--background: oklch(95.36% 0.017 256.57);
|
||||||
@@ -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",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 173 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 70 KiB |
Binary file not shown.
+1
-1
@@ -3,7 +3,7 @@ import type {
|
|||||||
EZPPUserInfoResponse,
|
EZPPUserInfoResponse,
|
||||||
EZPPUserResponse,
|
EZPPUserResponse,
|
||||||
EZPPUSerStatusResponse,
|
EZPPUSerStatusResponse,
|
||||||
} from '@/types';
|
} from '$lib/types';
|
||||||
import { betterFetch } from '@better-fetch/fetch';
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
|
||||||
const BANCHO_ENDPOINT = 'https://c.ez-pp.farm/';
|
const BANCHO_ENDPOINT = 'https://c.ez-pp.farm/';
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import type { Release } from '@/types';
|
import type { Release } from '$lib/types';
|
||||||
import { betterFetch } from '@better-fetch/fetch';
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { StreamsResult } from '@/types';
|
import type { StreamsResult } from '$lib/types';
|
||||||
import { betterFetch } from '@better-fetch/fetch';
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
|
||||||
const API_ENDPOINT = 'https://osu.ppy.sh/api/';
|
const API_ENDPOINT = 'https://osu.ppy.sh/api/';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
|
||||||
import { buttonVariants } from '$lib/components/ui/button/index.js';
|
import { buttonVariants } from '$lib/components/ui/button/index.js';
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
|
||||||
import { buttonVariants } from '$lib/components/ui/button/index.js';
|
import { buttonVariants } from '$lib/components/ui/button/index.js';
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AlertDialog as AlertDialogPrimitive, type WithoutChild } from 'bits-ui';
|
|
||||||
import AlertDialogOverlay from './alert-dialog-overlay.svelte';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import AlertDialogOverlay from './alert-dialog-overlay.svelte';
|
||||||
|
import { AlertDialog as AlertDialogPrimitive, type WithoutChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
import type { WithElementRef } from 'bits-ui';
|
import type { WithElementRef } from 'bits-ui';
|
||||||
import type { HTMLAttributes } from 'svelte/elements';
|
import type { HTMLAttributes } from 'svelte/elements';
|
||||||
import { cn } from '$lib/utils.js';
|
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
import type { WithElementRef } from 'bits-ui';
|
import type { WithElementRef } from 'bits-ui';
|
||||||
import type { HTMLAttributes } from 'svelte/elements';
|
import type { HTMLAttributes } from 'svelte/elements';
|
||||||
import { cn } from '$lib/utils.js';
|
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
|
||||||
import Title from './alert-dialog-title.svelte';
|
|
||||||
import Action from './alert-dialog-action.svelte';
|
import Action from './alert-dialog-action.svelte';
|
||||||
import Cancel from './alert-dialog-cancel.svelte';
|
import Cancel from './alert-dialog-cancel.svelte';
|
||||||
|
import Content from './alert-dialog-content.svelte';
|
||||||
|
import Description from './alert-dialog-description.svelte';
|
||||||
import Footer from './alert-dialog-footer.svelte';
|
import Footer from './alert-dialog-footer.svelte';
|
||||||
import Header from './alert-dialog-header.svelte';
|
import Header from './alert-dialog-header.svelte';
|
||||||
import Overlay from './alert-dialog-overlay.svelte';
|
import Overlay from './alert-dialog-overlay.svelte';
|
||||||
import Content from './alert-dialog-content.svelte';
|
import Title from './alert-dialog-title.svelte';
|
||||||
import Description from './alert-dialog-description.svelte';
|
import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
const Root = AlertDialogPrimitive.Root;
|
const Root = AlertDialogPrimitive.Root;
|
||||||
const Trigger = AlertDialogPrimitive.Trigger;
|
const Trigger = AlertDialogPrimitive.Trigger;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { reduceAnimations } from '@/userSettings';
|
import { reduceAnimations } from '$lib/userSettings';
|
||||||
|
|
||||||
//TODO: maybe dynamic background images fetched from ezpp?
|
//TODO: maybe dynamic background images fetched from ezpp?
|
||||||
|
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import NyanCat from '$assets/nyan-cat.gif';
|
|
||||||
import { reduceAnimations } from '@/userSettings';
|
|
||||||
import { fade } from 'svelte/transition';
|
|
||||||
|
|
||||||
//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>
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Avatar as AvatarPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Avatar as AvatarPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Avatar as AvatarPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Avatar as AvatarPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Avatar as AvatarPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Avatar as AvatarPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Root from './avatar.svelte';
|
|
||||||
import Image from './avatar-image.svelte';
|
|
||||||
import Fallback from './avatar-fallback.svelte';
|
import Fallback from './avatar-fallback.svelte';
|
||||||
|
import Image from './avatar-image.svelte';
|
||||||
|
import Root from './avatar.svelte';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Root,
|
Root,
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
import type { WithElementRef } from 'bits-ui';
|
import type { WithElementRef } from 'bits-ui';
|
||||||
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
||||||
import { cn } from '$lib/utils.js';
|
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
this={href ? 'a' : 'span'}
|
this={href ? 'a' : 'span'}
|
||||||
bind:this={ref}
|
bind:this={ref}
|
||||||
{href}
|
{href}
|
||||||
class={cn(badgeVariants({ variant, className }))}
|
class={cn(badgeVariants({ variant }), className)}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
>
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
|
|||||||
@@ -53,13 +53,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if href}
|
{#if href}
|
||||||
<a bind:this={ref} class={cn(buttonVariants({ variant, size, className }))} {href} {...restProps}>
|
<a bind:this={ref} class={cn(buttonVariants({ variant, size }), className)} {href} {...restProps}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</a>
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
bind:this={ref}
|
bind:this={ref}
|
||||||
class={cn(buttonVariants({ variant, size, className }))}
|
class={cn(buttonVariants({ variant, size }), className)}
|
||||||
{type}
|
{type}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Checkbox as CheckboxPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
import { cn } from '$lib/utils.js';
|
||||||
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 { Checkbox as CheckboxPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Root from './checkbox.svelte';
|
import Root from './checkbox.svelte';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Root,
|
Root,
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Ellipsis from 'lucide-svelte/icons/ellipsis';
|
import Ellipsis from '@lucide/svelte/icons/ellipsis';
|
||||||
import Play from 'lucide-svelte/icons/play';
|
import Play from '@lucide/svelte/icons/play';
|
||||||
|
|
||||||
const prop: {
|
const prop: {
|
||||||
downloading: boolean;
|
downloading: boolean;
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="group flex items-center h-12 rounded-full bg-primary-300 disabled:bg-primary-300/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"
|
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}
|
disabled={prop.disabled}
|
||||||
onclick={prop.onClick}
|
onclick={prop.onClick}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
import { cn } from '$lib/utils.js';
|
||||||
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 { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from 'bits-ui';
|
|
||||||
import Circle from '@lucide/svelte/icons/circle';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import Circle from '@lucide/svelte/icons/circle';
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { HTMLAttributes } from 'svelte/elements';
|
|
||||||
import { type WithElementRef } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { type WithElementRef } from 'bits-ui';
|
||||||
|
import type { HTMLAttributes } from 'svelte/elements';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
||||||
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
||||||
import CheckboxItem from './dropdown-menu-checkbox-item.svelte';
|
import CheckboxItem from './dropdown-menu-checkbox-item.svelte';
|
||||||
import Content from './dropdown-menu-content.svelte';
|
import Content from './dropdown-menu-content.svelte';
|
||||||
import GroupHeading from './dropdown-menu-group-heading.svelte';
|
import GroupHeading from './dropdown-menu-group-heading.svelte';
|
||||||
@@ -9,6 +8,7 @@ import Separator from './dropdown-menu-separator.svelte';
|
|||||||
import Shortcut from './dropdown-menu-shortcut.svelte';
|
import Shortcut from './dropdown-menu-shortcut.svelte';
|
||||||
import SubContent from './dropdown-menu-sub-content.svelte';
|
import SubContent from './dropdown-menu-sub-content.svelte';
|
||||||
import SubTrigger from './dropdown-menu-sub-trigger.svelte';
|
import SubTrigger from './dropdown-menu-sub-trigger.svelte';
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
const Sub = DropdownMenuPrimitive.Sub;
|
const Sub = DropdownMenuPrimitive.Sub;
|
||||||
const Root = DropdownMenuPrimitive.Root;
|
const Root = DropdownMenuPrimitive.Root;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
||||||
import type { WithElementRef } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import type { WithElementRef } from 'bits-ui';
|
||||||
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Label as LabelPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Label as LabelPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,23 +1,32 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import cursor_default from '$assets/cursor.png';
|
|
||||||
import cursor_additive from '$assets/cursor-additive.png';
|
import cursor_additive from '$assets/cursor-additive.png';
|
||||||
|
import cursor_default from '$assets/cursor.png';
|
||||||
|
import { cursorSmoothness } from '$lib/userSettings';
|
||||||
import { animate } from 'animejs';
|
import { animate } from 'animejs';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { cursorSmoothness } from '@/userSettings';
|
|
||||||
|
|
||||||
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();
|
||||||
@@ -30,7 +39,6 @@
|
|||||||
) {
|
) {
|
||||||
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: 1,
|
opacity: isHoveringInteractive ? 1 : 0,
|
||||||
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,
|
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,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Progress as ProgressPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Progress as ProgressPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -74,19 +74,26 @@
|
|||||||
|
|
||||||
<div class="wrapper" bind:this={wrapper}>
|
<div class="wrapper" bind:this={wrapper}>
|
||||||
<!-- Scrollable content -->
|
<!-- Scrollable content -->
|
||||||
<div class={`content ${className}`} bind:this={container} onscroll={updateScrollbar}>
|
<div
|
||||||
|
class={`content ${className}`}
|
||||||
|
bind:this={container}
|
||||||
|
onscroll={updateScrollbar}
|
||||||
|
id="scrollable-content"
|
||||||
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Custom scrollbar -->
|
<!-- Custom scrollbar -->
|
||||||
<div class="scrollbar" style="top: {topOffset}px;">
|
<div class="scrollbar" style="top: {topOffset}px;">
|
||||||
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<div
|
<div
|
||||||
class="thumb"
|
class="thumb bg-theme-600/60! hover:bg-theme-700! active:bg-theme-700 transition-colors"
|
||||||
bind:this={thumb}
|
bind:this={thumb}
|
||||||
onpointerdown={startDrag}
|
onpointerdown={startDrag}
|
||||||
onpointermove={drag}
|
onpointermove={drag}
|
||||||
onpointerup={endDrag}
|
onpointerup={endDrag}
|
||||||
onpointercancel={endDrag}
|
onpointercancel={endDrag}
|
||||||
|
aria-controls="scrollable-content"
|
||||||
style="height:{thumbHeight}px; transform:translateY({thumbTop}px);"
|
style="height:{thumbHeight}px; transform:translateY({thumbTop}px);"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -117,8 +124,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
right: 2px;
|
right: 2px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 12px;
|
width: 8px;
|
||||||
background: var(--color-theme-950);
|
background: transparent;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +133,7 @@
|
|||||||
.thumb {
|
.thumb {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: var(--color-theme-800);
|
background: var(--color-theme-700);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
transition: background 0.15s;
|
transition: background 0.15s;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { Select as SelectPrimitive } from 'bits-ui';
|
import Content from './select-content.svelte';
|
||||||
|
|
||||||
import GroupHeading from './select-group-heading.svelte';
|
import GroupHeading from './select-group-heading.svelte';
|
||||||
import Item from './select-item.svelte';
|
import Item from './select-item.svelte';
|
||||||
import Content from './select-content.svelte';
|
|
||||||
import Trigger from './select-trigger.svelte';
|
|
||||||
import Separator from './select-separator.svelte';
|
|
||||||
import ScrollDownButton from './select-scroll-down-button.svelte';
|
import ScrollDownButton from './select-scroll-down-button.svelte';
|
||||||
import ScrollUpButton from './select-scroll-up-button.svelte';
|
import ScrollUpButton from './select-scroll-up-button.svelte';
|
||||||
|
import Separator from './select-separator.svelte';
|
||||||
|
import Trigger from './select-trigger.svelte';
|
||||||
|
import { Select as SelectPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
const Root = SelectPrimitive.Root;
|
const Root = SelectPrimitive.Root;
|
||||||
const Group = SelectPrimitive.Group;
|
const Group = SelectPrimitive.Group;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Select as SelectPrimitive, type WithoutChild } from 'bits-ui';
|
|
||||||
import SelectScrollUpButton from './select-scroll-up-button.svelte';
|
|
||||||
import SelectScrollDownButton from './select-scroll-down-button.svelte';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import SelectScrollDownButton from './select-scroll-down-button.svelte';
|
||||||
|
import SelectScrollUpButton from './select-scroll-up-button.svelte';
|
||||||
|
import { Select as SelectPrimitive, type WithoutChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Select as SelectPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Select as SelectPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
import Check from '@lucide/svelte/icons/check';
|
import Check from '@lucide/svelte/icons/check';
|
||||||
import { Select as SelectPrimitive, type WithoutChild } from 'bits-ui';
|
import { Select as SelectPrimitive, type WithoutChild } from 'bits-ui';
|
||||||
import { cn } from '$lib/utils.js';
|
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
bind:ref
|
bind:ref
|
||||||
{value}
|
{value}
|
||||||
class={cn(
|
class={cn(
|
||||||
'data-[highlighted]:bg-primary-300 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',
|
'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}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
||||||
import { Select as SelectPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
import { Select as SelectPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
import { cn } from '$lib/utils.js';
|
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
import ChevronUp from '@lucide/svelte/icons/chevron-up';
|
import ChevronUp from '@lucide/svelte/icons/chevron-up';
|
||||||
import { Select as SelectPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
import { Select as SelectPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
import { cn } from '$lib/utils.js';
|
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Separator as SeparatorPrimitive } from 'bits-ui';
|
|
||||||
import { Separator } from '$lib/components/ui/separator/index.js';
|
import { Separator } from '$lib/components/ui/separator/index.js';
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import type { Separator as SeparatorPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Select as SelectPrimitive, type WithoutChild } from 'bits-ui';
|
|
||||||
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
||||||
|
import { Select as SelectPrimitive, type WithoutChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Separator as SeparatorPrimitive } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Separator as SeparatorPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { SileoToasterProps } from './types';
|
||||||
import { createElement } from 'react';
|
import { createElement } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import type { SileoOptions } from 'sileo';
|
|
||||||
|
|
||||||
let props: SileoOptions = $props();
|
let props: SileoToasterProps = $props();
|
||||||
let rootEl: HTMLElement;
|
let rootEl: HTMLElement;
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -18,4 +18,4 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={rootEl}></div>
|
<div class="z-9999" bind:this={rootEl}></div>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import type { SileoOptions, SileoPosition } from 'sileo';
|
||||||
|
|
||||||
|
type SileoOffsetValue = number | string;
|
||||||
|
type SileoOffsetConfig = Partial<Record<'top' | 'right' | 'bottom' | 'left', SileoOffsetValue>>;
|
||||||
|
|
||||||
|
export interface SileoToasterProps {
|
||||||
|
children?: ReactNode;
|
||||||
|
position?: SileoPosition;
|
||||||
|
offset?: SileoOffsetValue | SileoOffsetConfig;
|
||||||
|
options?: Partial<SileoOptions>;
|
||||||
|
theme?: 'light' | 'dark' | 'system';
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Toaster as Sonner, type ToasterProps as SonnerProps } from 'svelte-sonner';
|
|
||||||
import { mode } from 'mode-watcher';
|
import { mode } from 'mode-watcher';
|
||||||
|
import { Toaster as Sonner, type ToasterProps as SonnerProps } from 'svelte-sonner';
|
||||||
|
|
||||||
let { ...restProps }: SonnerProps = $props();
|
let { ...restProps }: SonnerProps = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Switch as SwitchPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
|
||||||
import { cn } from '$lib/utils.js';
|
import { cn } from '$lib/utils.js';
|
||||||
|
import { Switch as SwitchPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Minimize from 'lucide-svelte/icons/minus';
|
import { config } from '$lib/config';
|
||||||
import Close from 'lucide-svelte/icons/x';
|
import { custom_theme_audio_playing, custom_theme_volume } from '$lib/global';
|
||||||
|
import { reduceAnimations } from '$lib/userSettings';
|
||||||
import Logo from '$assets/logo.png';
|
import { Volume, Volume1, VolumeOff } from '@lucide/svelte';
|
||||||
|
import Minimize from '@lucide/svelte/icons/minus';
|
||||||
|
import Volume2 from '@lucide/svelte/icons/volume-2';
|
||||||
|
import Close from '@lucide/svelte/icons/x';
|
||||||
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 Badge from '../badge/badge.svelte';
|
|
||||||
import { reduceAnimations } from '@/userSettings';
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const appWindow = getCurrentWindow();
|
const appWindow = getCurrentWindow();
|
||||||
@@ -21,6 +20,58 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div data-tauri-drag-region class="titlebar z-[100]">
|
<div data-tauri-drag-region class="titlebar z-[100]">
|
||||||
|
{#if $custom_theme_audio_playing}
|
||||||
|
{#if $custom_theme_audio_playing}
|
||||||
|
<div class="relative flex items-center justify-center group">
|
||||||
|
<div class="relative flex items-center justify-center p-1 cursor-pointer">
|
||||||
|
<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'}"
|
||||||
|
></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={() => {
|
||||||
|
config.value<number>('volume').set($custom_theme_volume);
|
||||||
|
}}
|
||||||
|
class="volume-slider"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
<div class="relative flex items-center justify-center p-1 group" id="titlebar-minimize">
|
<div class="relative flex items-center justify-center p-1 group" id="titlebar-minimize">
|
||||||
<div
|
<div
|
||||||
class="absolute inset-0 bg-background rounded
|
class="absolute inset-0 bg-background rounded
|
||||||
@@ -63,4 +114,52 @@
|
|||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.volume-slider {
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
|
||||||
|
width: 100px; /* becomes vertical */
|
||||||
|
height: 6px;
|
||||||
|
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* track */
|
||||||
|
.volume-slider::-webkit-slider-runnable-track {
|
||||||
|
height: 6px;
|
||||||
|
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>
|
||||||
|
|||||||
+30
-73
@@ -1,82 +1,39 @@
|
|||||||
import { exists, mkdir, readTextFile, writeFile } from '@tauri-apps/plugin-fs';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import * as path from '@tauri-apps/api/path';
|
|
||||||
import { Crypto } from './crypto';
|
|
||||||
import { getHWID } from './osuUtil';
|
|
||||||
|
|
||||||
export class Config {
|
interface ConfigValue<T> {
|
||||||
private fileName: string;
|
set(value: T, opts?: { encrypt?: boolean }): Promise<void>;
|
||||||
private config: Record<string, unknown> = {};
|
get(fallback: T): Promise<T>;
|
||||||
private crypto: Crypto | undefined;
|
exists(): Promise<boolean>;
|
||||||
private configFilePath: string | undefined;
|
delete(): Promise<void>;
|
||||||
private encrypt: boolean;
|
|
||||||
|
|
||||||
constructor(fileName: string, encrypt?: boolean) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.encrypt = encrypt ?? false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(): Promise<boolean> {
|
export const config = {
|
||||||
const hwid = (await getHWID()) ?? 'recorderinsandybridge';
|
value<T = unknown>(key: string): ConfigValue<T> {
|
||||||
|
|
||||||
this.crypto = new Crypto(hwid);
|
|
||||||
|
|
||||||
const homeDir = await path.homeDir();
|
|
||||||
const folderPath = await path.join(homeDir, '.ezpplauncher');
|
|
||||||
this.configFilePath = await path.join(folderPath, this.fileName);
|
|
||||||
|
|
||||||
const createFolder = !(await exists(folderPath));
|
|
||||||
if (createFolder) await mkdir(folderPath);
|
|
||||||
|
|
||||||
const configExists = await exists(this.configFilePath);
|
|
||||||
if (!configExists) return true;
|
|
||||||
|
|
||||||
await this.load();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async load() {
|
|
||||||
if (!this.configFilePath) throw Error('configFilePath not set');
|
|
||||||
if (this.encrypt && !this.crypto) throw Error('crypto not initialized');
|
|
||||||
|
|
||||||
const fileStream = await readTextFile(this.configFilePath);
|
|
||||||
try {
|
|
||||||
const decryptedJSON = JSON.parse(
|
|
||||||
this.encrypt && this.crypto ? this.crypto.decrypt(fileStream) : fileStream
|
|
||||||
) as Record<string, unknown>;
|
|
||||||
this.config = decryptedJSON;
|
|
||||||
} catch {
|
|
||||||
this.config = {};
|
|
||||||
await this.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async save() {
|
|
||||||
if (!this.configFilePath) throw Error('configFilePath not set');
|
|
||||||
if (this.encrypt && !this.crypto) throw Error('crypto not initialized');
|
|
||||||
const encryptedJSON =
|
|
||||||
this.encrypt && this.crypto
|
|
||||||
? this.crypto.encrypt(JSON.stringify(this.config))
|
|
||||||
: JSON.stringify(this.config);
|
|
||||||
|
|
||||||
await writeFile(this.configFilePath, Buffer.from(encryptedJSON), {
|
|
||||||
append: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
value(key: string) {
|
|
||||||
return {
|
return {
|
||||||
set: <T>(val: T) => {
|
set(value: T, opts?: { encrypt?: boolean }): Promise<void> {
|
||||||
this.config[key] = val;
|
return invoke('config_set', { key, value, encrypt: opts?.encrypt ?? false });
|
||||||
},
|
},
|
||||||
exists: () => {
|
|
||||||
return this.config[key] !== undefined;
|
async get(fallback: T): Promise<T> {
|
||||||
|
const result = await invoke<T | null>('config_get', { key });
|
||||||
|
return result ?? fallback;
|
||||||
},
|
},
|
||||||
get: <T>(fallback: T): T => {
|
|
||||||
return (this.config[key] as T) ?? fallback;
|
exists(): Promise<boolean> {
|
||||||
|
return invoke<boolean>('config_exists', { key });
|
||||||
},
|
},
|
||||||
del: () => {
|
|
||||||
delete this.config[key];
|
delete(): Promise<void> {
|
||||||
|
return invoke('config_delete', { key });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
all(): Promise<[string, unknown][]> {
|
||||||
|
return invoke<[string, unknown][]>('config_all');
|
||||||
|
},
|
||||||
|
|
||||||
|
clear(): Promise<void> {
|
||||||
|
return invoke('config_clear');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import { Crypto } from './crypto';
|
||||||
|
import { getHWID } from './osuUtil';
|
||||||
|
import * as path from '@tauri-apps/api/path';
|
||||||
|
import { exists, mkdir, readTextFile, writeFile, remove } from '@tauri-apps/plugin-fs';
|
||||||
|
|
||||||
|
export class Config {
|
||||||
|
private fileName: string;
|
||||||
|
private config: Record<string, unknown> = {};
|
||||||
|
private crypto: Crypto | undefined;
|
||||||
|
private configFilePath: string | undefined;
|
||||||
|
private encrypt: boolean;
|
||||||
|
|
||||||
|
constructor(fileName: string, encrypt?: boolean) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.encrypt = encrypt ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(): Promise<boolean> {
|
||||||
|
const hwid = (await getHWID()) ?? 'recorderinsandybridge';
|
||||||
|
|
||||||
|
this.crypto = new Crypto(hwid);
|
||||||
|
|
||||||
|
const homeDir = await path.homeDir();
|
||||||
|
const folderPath = await path.join(homeDir, '.ezpplauncher');
|
||||||
|
this.configFilePath = await path.join(folderPath, this.fileName);
|
||||||
|
|
||||||
|
const createFolder = !(await exists(folderPath));
|
||||||
|
if (createFolder) await mkdir(folderPath);
|
||||||
|
|
||||||
|
const configExists = await exists(this.configFilePath);
|
||||||
|
if (configExists) {
|
||||||
|
await this.load();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async load() {
|
||||||
|
if (!this.configFilePath) throw Error('configFilePath not set');
|
||||||
|
if (this.encrypt && !this.crypto) throw Error('crypto not initialized');
|
||||||
|
|
||||||
|
const fileStream = await readTextFile(this.configFilePath);
|
||||||
|
try {
|
||||||
|
const decryptedJSON = JSON.parse(
|
||||||
|
this.encrypt && this.crypto ? this.crypto.decrypt(fileStream) : fileStream
|
||||||
|
) as Record<string, unknown>;
|
||||||
|
this.config = decryptedJSON;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
this.config = {};
|
||||||
|
await this.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete() {
|
||||||
|
if (!this.configFilePath) throw Error('configFilePath not set');
|
||||||
|
await remove(this.configFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
async save() {
|
||||||
|
if (!this.configFilePath) throw Error('configFilePath not set');
|
||||||
|
if (this.encrypt && !this.crypto) throw Error('crypto not initialized');
|
||||||
|
const encryptedJSON =
|
||||||
|
this.encrypt && this.crypto
|
||||||
|
? this.crypto.encrypt(JSON.stringify(this.config))
|
||||||
|
: JSON.stringify(this.config);
|
||||||
|
|
||||||
|
await writeFile(this.configFilePath, Buffer.from(encryptedJSON), {
|
||||||
|
append: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
values() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
value(key: string) {
|
||||||
|
return {
|
||||||
|
set: <T>(val: T) => {
|
||||||
|
this.config[key] = val;
|
||||||
|
},
|
||||||
|
exists: () => {
|
||||||
|
return this.config[key] !== undefined;
|
||||||
|
},
|
||||||
|
get: <T>(fallback: T): T => {
|
||||||
|
return (this.config[key] as T) ?? fallback;
|
||||||
|
},
|
||||||
|
del: () => {
|
||||||
|
delete this.config[key];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { writable } from 'svelte/store';
|
|
||||||
import type { EZPPUserInfo } from './types';
|
import type { EZPPUserInfo } from './types';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export const currentUserInfo = writable<EZPPUserInfo | undefined>(undefined);
|
export const currentUserInfo = writable<EZPPUserInfo | undefined>(undefined);
|
||||||
|
|||||||
+12
-10
@@ -1,19 +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) {
|
||||||
resolve(frames - 2);
|
requestAnimationFrame(tick);
|
||||||
} 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;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
+19
-4
@@ -1,8 +1,11 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { browser } from '$app/environment';
|
||||||
import { ezppfarm } from './api/ezpp';
|
|
||||||
import type { Component } from 'svelte';
|
|
||||||
import Loading from '../screens/Loading.svelte';
|
import Loading from '../screens/Loading.svelte';
|
||||||
|
import { ezppfarm } from './api/ezpp';
|
||||||
|
import type { Theme } from './themes';
|
||||||
import type { Release } from './types';
|
import type { Release } from './types';
|
||||||
|
import { setGlobalVolume } from './utils';
|
||||||
|
import type { Component } from 'svelte';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export const currentView = writable<Component>(Loading);
|
export const currentView = writable<Component>(Loading);
|
||||||
|
|
||||||
@@ -24,7 +27,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 nyanCatSong = writable<HTMLAudioElement | undefined>(undefined);
|
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);
|
||||||
|
|||||||
+31
-40
@@ -1,7 +1,7 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core';
|
|
||||||
import type { UpdateFile, UpdateStatus } from './types';
|
import type { UpdateFile, UpdateStatus } from './types';
|
||||||
import { listen } from '@tauri-apps/api/event';
|
|
||||||
import { betterFetch } from '@better-fetch/fetch';
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
import { listen } from '@tauri-apps/api/event';
|
||||||
|
|
||||||
const updateUrl = 'https://ez-pp.farm/api/ezpplauncher';
|
const updateUrl = 'https://ez-pp.farm/api/ezpplauncher';
|
||||||
|
|
||||||
@@ -17,20 +17,14 @@ export function normalizeOsuName(name: string): string {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getHWID = async () => {
|
export const getHWID = async (): Promise<string | undefined> =>
|
||||||
const hwid = await invoke('get_hwid');
|
await invoke<string | undefined>('get_hwid');
|
||||||
return typeof hwid === 'string' ? hwid : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isValidOsuFolder = async (folder: string): Promise<boolean> => {
|
export const isValidOsuFolder = async (folder: string): Promise<boolean | undefined> =>
|
||||||
const result = await invoke('valid_osu_folder', { folder });
|
await invoke<boolean | undefined>('valid_osu_folder', { folder });
|
||||||
return typeof result === 'boolean' ? result : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const autoDetectOsuInstallFolder = async () => {
|
export const autoDetectOsuInstallFolder = async () =>
|
||||||
const result = await invoke('find_osu_installation');
|
await invoke<string | undefined>('find_osu_installation');
|
||||||
return typeof result === 'string' ? result : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setUserConfigValues = async (
|
export const setUserConfigValues = async (
|
||||||
osuFolderPath: string,
|
osuFolderPath: string,
|
||||||
@@ -50,29 +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 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 });
|
||||||
@@ -113,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 });
|
||||||
@@ -127,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,
|
||||||
@@ -161,3 +146,9 @@ export const getSkins = async (folder: string) =>
|
|||||||
'get_skins',
|
'get_skins',
|
||||||
{ folder }
|
{ folder }
|
||||||
);
|
);
|
||||||
|
export const startOpenTabletDriver = async (otdDaemonPath: string) =>
|
||||||
|
await invoke('run_open_tablet_driver', { path: otdDaemonPath });
|
||||||
|
export const stopOpenTabletDriver = async () => await invoke('stop_open_tablet_driver');
|
||||||
|
export const isOpenTabletDriverRunning = async () => await invoke('is_open_tablet_driver_running');
|
||||||
|
export const isOpenTabletDriverPathValid = async (path: string) =>
|
||||||
|
await invoke('is_open_tablet_driver_path_valid', { path });
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
+3
-1
@@ -7,7 +7,9 @@ const osuSkinsCollator = new Intl.Collator(undefined, {
|
|||||||
sensitivity: 'base',
|
sensitivity: 'base',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const sortSkins = (skins: { name: string, author: string | undefined, modified: number}[]) =>
|
export const sortSkins = (
|
||||||
|
skins: { name: string; author: string | undefined; modified: number }[]
|
||||||
|
) =>
|
||||||
skins.sort((a, b) => {
|
skins.sort((a, b) => {
|
||||||
const pa = priority[a.name[0]];
|
const pa = priority[a.name[0]];
|
||||||
const pb = priority[b.name[0]];
|
const pb = priority[b.name[0]];
|
||||||
|
|||||||
@@ -0,0 +1,457 @@
|
|||||||
|
import { active_custom_theme, custom_themes } from './global';
|
||||||
|
import { disableMediaControls, setGlobalVolume } from './utils';
|
||||||
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||||
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
import { listen } from '@tauri-apps/api/event';
|
||||||
|
import * as path from '@tauri-apps/api/path';
|
||||||
|
import * as fs from '@tauri-apps/plugin-fs';
|
||||||
|
import { SemVer } from 'semver';
|
||||||
|
|
||||||
|
export type Theme = {
|
||||||
|
folder_name: string;
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
author: string;
|
||||||
|
scriptUrl: string;
|
||||||
|
cssStyle: 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DownloadProgress = {
|
||||||
|
theme_name: string;
|
||||||
|
received: number;
|
||||||
|
total: number;
|
||||||
|
progress: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ExtractProgress = {
|
||||||
|
theme_name: string;
|
||||||
|
total: number;
|
||||||
|
extracted: number;
|
||||||
|
progress: number;
|
||||||
|
current_file: 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,
|
||||||
|
cssStyle: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} 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,
|
||||||
|
cssStyle: '',
|
||||||
|
});
|
||||||
|
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);
|
||||||
|
const cssStylePath = await path.join(folderPath, themeFolder.name, theme.style);
|
||||||
|
const cssStyle = (await fs.exists(cssStylePath)) ? await fs.readTextFile(cssStylePath) : '';
|
||||||
|
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,
|
||||||
|
cssStyle,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
};
|
||||||
|
|
||||||
|
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 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 downloadUrl = `https://git.ez-pp.farm/EZPPFarm/EZPPLauncher-Themes/raw/branch/main/themes/${themeFileName}`;
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'downloading';
|
||||||
|
matchedTheme.progress = 0;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
|
||||||
|
const unlistenDownload = await listen<DownloadProgress>('download_progress', (event) => {
|
||||||
|
if (event.payload.theme_name !== theme.name) return;
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'downloading';
|
||||||
|
matchedTheme.progress = event.payload.progress;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const unlistenExtract = await listen<ExtractProgress>('extract_progress', (event) => {
|
||||||
|
if (event.payload.theme_name !== theme.name) return;
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.status = 'extracting';
|
||||||
|
matchedTheme.progress = event.payload.progress;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await invoke('download_and_extract_theme', {
|
||||||
|
downloadUrl,
|
||||||
|
expectedSha: themeContents.data.file_contents.sha,
|
||||||
|
themeFolder,
|
||||||
|
themeName: theme.name,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
const erro = err as 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: erro.message || 'Failed to download or extract theme.' };
|
||||||
|
} finally {
|
||||||
|
unlistenDownload();
|
||||||
|
unlistenExtract();
|
||||||
|
}
|
||||||
|
|
||||||
|
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}`)
|
||||||
|
);
|
||||||
|
const cssStylePath = await path.join(themeFolder, themeInfoObj.style);
|
||||||
|
const cssStyle = (await fs.exists(cssStylePath)) ? await fs.readTextFile(cssStylePath) : '';
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === theme.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.scriptUrl = themeScriptUrl;
|
||||||
|
matchedTheme.cssStyle = cssStyle;
|
||||||
|
matchedTheme.assets = themeAssets;
|
||||||
|
matchedTheme.preview = themePreview;
|
||||||
|
matchedTheme.status = 'installed';
|
||||||
|
matchedTheme.progress = 1;
|
||||||
|
matchedTheme.folder_name = toSafeName(theme.name);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
disableMediaControls();
|
||||||
|
};
|
||||||
|
|
||||||
|
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.cssStyle = '';
|
||||||
|
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' };
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const themeInfo = await invoke<ThemeInfo>('read_theme_info', {
|
||||||
|
filePath: normalizedFilePath,
|
||||||
|
});
|
||||||
|
return { success: true, themeInfo };
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
return { success: false, error: 'Could not read theme file' };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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 unlisten = await listen<ExtractProgress>('extract_progress', (event) => {
|
||||||
|
if (event.payload.theme_name !== themeName) return;
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === themeName);
|
||||||
|
if (matchedTheme) matchedTheme.progress = event.payload.progress;
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await invoke('extract_theme', {
|
||||||
|
filePath,
|
||||||
|
themeFolder,
|
||||||
|
themeName,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
return { success: false, error: 'Failed to extract theme file.' };
|
||||||
|
} finally {
|
||||||
|
unlisten();
|
||||||
|
}
|
||||||
|
|
||||||
|
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}`)
|
||||||
|
);
|
||||||
|
const cssStylePath = await path.join(themeFolder, themeInfoObj.style);
|
||||||
|
const cssStyle = (await fs.exists(cssStylePath)) ? await fs.readTextFile(cssStylePath) : '';
|
||||||
|
|
||||||
|
custom_themes.update((themes) => {
|
||||||
|
const matchedTheme = themes.find((t) => t.name === themeInfoObj.name);
|
||||||
|
if (matchedTheme) {
|
||||||
|
matchedTheme.scriptUrl = themeScriptUrl;
|
||||||
|
matchedTheme.cssStyle = cssStyle;
|
||||||
|
matchedTheme.assets = themeAssets;
|
||||||
|
matchedTheme.preview = themePreview;
|
||||||
|
matchedTheme.status = 'installed';
|
||||||
|
matchedTheme.progress = 1;
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
storeTheme.cssStyle = theme.cssStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
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('');
|
||||||
|
};
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
export type LaunchView = 'HOME' | 'LOGIN' | 'SETTINGS' | 'THEMES';
|
||||||
|
|
||||||
export type EZPPUserResponse = {
|
export type EZPPUserResponse = {
|
||||||
code: number;
|
code: number;
|
||||||
message: string;
|
message: string;
|
||||||
|
|||||||
@@ -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,4 @@
|
|||||||
import { writable } from 'svelte/store';
|
|
||||||
import { Config } from './config';
|
|
||||||
import type { EZPPUser } from './types';
|
import type { EZPPUser } from './types';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export const userAuth = writable<Config>(new Config('user_auth', true));
|
|
||||||
export const currentUser = writable<EZPPUser | undefined>(undefined);
|
export const currentUser = writable<EZPPUser | undefined>(undefined);
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import { Config } from './config';
|
|
||||||
|
|
||||||
export const userSettings = writable<Config>(new Config('user_settings', false));
|
|
||||||
|
|
||||||
export const customCursor = writable<boolean>(false);
|
export const customCursor = writable<boolean>(false);
|
||||||
export const cursorSmoothening = writable<boolean>(false);
|
export const cursorSmoothening = writable<boolean>(false);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import { custom_theme_audio_playing } from './global';
|
||||||
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 * as crypto from 'crypto-js';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
@@ -99,3 +101,148 @@ 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();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const MEDIA_ACTIONS: MediaSessionAction[] = [
|
||||||
|
'play',
|
||||||
|
'pause',
|
||||||
|
'stop',
|
||||||
|
'previoustrack',
|
||||||
|
'nexttrack',
|
||||||
|
'seekbackward',
|
||||||
|
'seekforward',
|
||||||
|
];
|
||||||
|
|
||||||
|
export function disableMediaControls() {
|
||||||
|
const mediaElements: NodeListOf<HTMLMediaElement> = document.querySelectorAll('audio, video');
|
||||||
|
|
||||||
|
if ('mediaSession' in navigator) {
|
||||||
|
MEDIA_ACTIONS.forEach((action) => {
|
||||||
|
try {
|
||||||
|
navigator.mediaSession.setActionHandler(action, () => {});
|
||||||
|
} catch {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener(
|
||||||
|
'keydown',
|
||||||
|
(e: KeyboardEvent) => {
|
||||||
|
if (e.key.startsWith('Media')) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
mediaElements.forEach((el) => {
|
||||||
|
el.disableRemotePlayback = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|||||||
+161
-186
@@ -1,49 +1,44 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Logo from '$assets/logo.png';
|
import Logo from '$assets/logo.png';
|
||||||
import NyanCatSong from '$assets/nyan-cat.mp3';
|
import * as AlertDialog from '$lib/components/ui/alert-dialog';
|
||||||
import '../app.css';
|
import AnimatedBg from '$lib/components/ui/animated-bg/AnimatedBg.svelte';
|
||||||
|
import Button from '$lib/components/ui/button/button.svelte';
|
||||||
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
import OsuCursor from '$lib/components/ui/osu-cursor/OsuCursor.svelte';
|
||||||
import * as AlertDialog from '@/components/ui/alert-dialog';
|
import SileoToast from '$lib/components/ui/sileo/sileo-toast.svelte';
|
||||||
|
import Titlebar from '$lib/components/ui/titlebar/titlebar.svelte';
|
||||||
|
import { config } from '$lib/config';
|
||||||
|
import { Config } from '$lib/config_old';
|
||||||
import {
|
import {
|
||||||
|
active_custom_theme,
|
||||||
currentLoadingInfo,
|
currentLoadingInfo,
|
||||||
|
custom_theme_container,
|
||||||
|
custom_theme_volume,
|
||||||
|
custom_themes,
|
||||||
discordPresence,
|
discordPresence,
|
||||||
firstStartup,
|
firstStartup,
|
||||||
launcherVersion,
|
launcherVersion,
|
||||||
nyanCatSong,
|
openTabletDriverEnabled,
|
||||||
|
openTabletDriverPath,
|
||||||
platform,
|
platform,
|
||||||
presenceLoading,
|
presenceLoading,
|
||||||
setupValues,
|
setupValues,
|
||||||
trackingEnabled,
|
trackingEnabled,
|
||||||
} from '@/global';
|
} from '$lib/global';
|
||||||
import { onMount } from 'svelte';
|
import { exit, getLauncherVersion, getPlatform } from '$lib/osuUtil';
|
||||||
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
|
import * as presence from '$lib/presence';
|
||||||
import {
|
import { getDownloadableThemes, getThemes, loadTheme } from '$lib/themes';
|
||||||
cursorSmoothening,
|
import { cursorSmoothening, customCursor, patch, reduceAnimations } from '$lib/userSettings';
|
||||||
customCursor,
|
import { trackMediaContainer } from '$lib/utils';
|
||||||
osuInstallationPath,
|
import '../app.css';
|
||||||
patch,
|
|
||||||
reduceAnimations,
|
|
||||||
userSettings,
|
|
||||||
} from '@/userSettings';
|
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
import SileoToast from '@/components/ui/sileo/sileo-toast.svelte';
|
import { SemVer } from 'semver';
|
||||||
import { userAuth } from '@/userAuthentication';
|
|
||||||
import { encryptString, exit, getLauncherVersion, getPlatform } from '@/osuUtil';
|
|
||||||
import Button from '@/components/ui/button/button.svelte';
|
|
||||||
import * as presence from '@/presence';
|
|
||||||
import { fade } from 'svelte/transition';
|
|
||||||
|
|
||||||
import '@fontsource/sora';
|
|
||||||
import '@fontsource/space-mono';
|
|
||||||
import AnimatedBg from '@/components/ui/animated-bg/AnimatedBg.svelte';
|
|
||||||
import NyanCatBg from '@/components/ui/animated-bg/NyanCatBg.svelte';
|
|
||||||
import { sileo } from 'sileo';
|
import { sileo } from 'sileo';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
let unsupported_platform = $state<boolean>(false);
|
let unsupported_platform = $state<boolean>(false);
|
||||||
let secret_enabled = $state<boolean>(false);
|
|
||||||
|
|
||||||
function disableReload() {
|
function disableReload() {
|
||||||
if (window.location.hostname !== 'tauri.localhost') {
|
if (window.location.hostname !== 'tauri.localhost') {
|
||||||
@@ -57,18 +52,12 @@
|
|||||||
event.key === 'F8' ||
|
event.key === 'F8' ||
|
||||||
event.key === 'F10' ||
|
event.key === 'F10' ||
|
||||||
event.key === 'F12' ||
|
event.key === 'F12' ||
|
||||||
(event.ctrlKey && event.key === 'r') ||
|
((event.ctrlKey || event.metaKey) && event.key === 'r') ||
|
||||||
(event.metaKey && event.key === 'r') ||
|
((event.ctrlKey || event.metaKey) && event.key === 'f') ||
|
||||||
(event.ctrlKey && event.key === 'f') ||
|
((event.ctrlKey || event.metaKey) && event.key === 'g') ||
|
||||||
(event.metaKey && event.key === 'f') ||
|
((event.ctrlKey || event.metaKey) && event.key === 'j') ||
|
||||||
(event.ctrlKey && event.key === 'g') ||
|
((event.ctrlKey || event.metaKey) && event.key === 'p') ||
|
||||||
(event.metaKey && event.key === 'g') ||
|
((event.ctrlKey || event.metaKey) && event.key === 'u')
|
||||||
(event.ctrlKey && event.key === 'j') ||
|
|
||||||
(event.metaKey && event.key === 'j') ||
|
|
||||||
(event.ctrlKey && event.key === 'p') ||
|
|
||||||
(event.metaKey && event.key === 'p') ||
|
|
||||||
(event.ctrlKey && event.key === 'u') ||
|
|
||||||
(event.metaKey && event.key === 'u')
|
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -93,166 +82,97 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let konami_code = [
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'b',
|
|
||||||
'a',
|
|
||||||
];
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
window.Buffer = Buffer;
|
window.Buffer = Buffer;
|
||||||
|
|
||||||
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();
|
|
||||||
$userAuth.init();
|
|
||||||
|
|
||||||
document.addEventListener('keydown', (e) => {
|
const oldUserConfig = new Config('user_settings', false);
|
||||||
if (e.key.toLowerCase() === konami_code[0].toLowerCase()) {
|
const oldUserConfigExists = await oldUserConfig.init();
|
||||||
konami_code.shift();
|
if (oldUserConfigExists) {
|
||||||
if (konami_code.length === 0) {
|
const oldUserConfigValues = oldUserConfig.values();
|
||||||
if (secret_enabled) {
|
if (Object.keys(oldUserConfigValues).length > 0) {
|
||||||
sileo.success({
|
await config.value<boolean>('setup_complete').set(true);
|
||||||
title: 'Cheatcode deactivated!',
|
|
||||||
duration: 3000,
|
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const audio = $nyanCatSong;
|
|
||||||
if (audio) {
|
|
||||||
const fadeOutDuration = 2000; // 2 seconds
|
|
||||||
const fadeOutSteps = 20;
|
|
||||||
const fadeOutStepTime = fadeOutDuration / fadeOutSteps;
|
|
||||||
const volumeStep = audio.volume / fadeOutSteps;
|
|
||||||
|
|
||||||
const fadeOutInterval = setInterval(() => {
|
for (const key in oldUserConfigValues) {
|
||||||
if (audio.volume > 0) {
|
const value = oldUserConfigValues[key];
|
||||||
audio.volume = Math.max(0, audio.volume - volumeStep);
|
await config.value<typeof value>(key).set(value);
|
||||||
} else {
|
|
||||||
audio.pause();
|
|
||||||
clearInterval(fadeOutInterval);
|
|
||||||
}
|
}
|
||||||
}, fadeOutStepTime);
|
|
||||||
}
|
}
|
||||||
nyanCatSong.set(undefined);
|
await oldUserConfig.delete();
|
||||||
secret_enabled = false;
|
|
||||||
konami_code = [
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'b',
|
|
||||||
'a',
|
|
||||||
];
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
sileo.success({
|
|
||||||
title: 'Cheatcode activated!',
|
|
||||||
duration: 3000,
|
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const audio = new Audio(NyanCatSong);
|
|
||||||
audio.loop = true;
|
|
||||||
audio.volume = 0;
|
|
||||||
audio.play();
|
|
||||||
const fadeInVolume = 0.15;
|
|
||||||
const fadeInDuration = 2000; // 2 seconds
|
|
||||||
const fadeInSteps = 20;
|
|
||||||
const fadeInStepTime = fadeInDuration / fadeInSteps;
|
|
||||||
const volumeStep = (fadeInVolume - audio.volume) / fadeInSteps;
|
|
||||||
|
|
||||||
const fadeInInterval = setInterval(() => {
|
const oldUserAuth = new Config('user_auth', true);
|
||||||
if (audio.volume < fadeInVolume) {
|
const oldUserAuthExists = await oldUserAuth.init();
|
||||||
audio.volume = Math.min(fadeInVolume, audio.volume + volumeStep);
|
if (oldUserAuthExists) {
|
||||||
} else {
|
const oldUserAuthValues = oldUserAuth.values();
|
||||||
clearInterval(fadeInInterval);
|
if (Object.keys(oldUserAuthValues).length > 0) {
|
||||||
|
for (const key in oldUserAuthValues) {
|
||||||
|
const value = oldUserAuthValues[key];
|
||||||
|
await config.value<typeof value>(key).set(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await oldUserAuth.delete();
|
||||||
}
|
}
|
||||||
}, fadeInStepTime);
|
|
||||||
nyanCatSong.set(audio);
|
|
||||||
|
|
||||||
secret_enabled = true;
|
const isSetupComplete = await config.value<boolean>('setup_complete').get(false);
|
||||||
konami_code = [
|
firstStartup.set(!isSetupComplete);
|
||||||
'ArrowUp',
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'b',
|
|
||||||
'a',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
konami_code = [
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowUp',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowDown',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'ArrowLeft',
|
|
||||||
'ArrowRight',
|
|
||||||
'b',
|
|
||||||
'a',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
currentLoadingInfo.set('Loading config...');
|
currentLoadingInfo.set('Loading config...');
|
||||||
const config_patching = $userSettings.value('patching');
|
const config_theme = config.value<string>('theme');
|
||||||
const config_custom_cursor = $userSettings.value('custom_cursor');
|
const config_theme_volume = config.value<number>('volume');
|
||||||
const config_cursor_smoothening = $userSettings.value('cursor_smoothening');
|
const config_patching = config.value<boolean>('patching');
|
||||||
const config_reduce_animations = $userSettings.value('reduce_animations');
|
const config_custom_cursor = config.value<boolean>('custom_cursor');
|
||||||
const config_osu_installation_path = $userSettings.value('osu_installation_path');
|
const config_cursor_smoothening = config.value<boolean>('cursor_smoothening');
|
||||||
const config_discord_presence = $userSettings.value('discord_presence');
|
const config_reduce_animations = config.value<boolean>('reduce_animations');
|
||||||
const config_tracking_enabled = $userSettings.value('tracking_consent');
|
const config_discord_presence = config.value<boolean>('discord_presence');
|
||||||
|
const config_tracking_enabled = config.value<boolean>('tracking_consent');
|
||||||
|
const config_otd_enabled = config.value<boolean>('otd_enabled');
|
||||||
|
const config_otd_path = config.value<string>('otd_path');
|
||||||
|
|
||||||
patch.set(config_patching.get(true));
|
const localThemes = await getThemes();
|
||||||
customCursor.set(config_custom_cursor.get(true));
|
const lastThemeName = await config_theme.get('Default');
|
||||||
cursorSmoothening.set(config_cursor_smoothening.get(true));
|
const last_theme = localThemes.find((t) => t.name === lastThemeName);
|
||||||
reduceAnimations.set(config_reduce_animations.get(false));
|
if (!last_theme || $platform === 'linux') {
|
||||||
osuInstallationPath.set(config_osu_installation_path.get(''));
|
await config.value<string>('theme').set('Default');
|
||||||
discordPresence.set(config_discord_presence.get(true));
|
loadTheme(localThemes[0], $custom_theme_container!, await config_theme_volume.get(0.15));
|
||||||
if (config_tracking_enabled.exists()) {
|
} else {
|
||||||
trackingEnabled.set(config_tracking_enabled.get(false));
|
loadTheme(last_theme, $custom_theme_container!, await config_theme_volume.get(0.15));
|
||||||
}
|
}
|
||||||
|
|
||||||
patch.subscribe((val) => config_patching.set(val));
|
custom_theme_volume.set(await config_theme_volume.get(0.15));
|
||||||
customCursor.subscribe((val) => config_custom_cursor.set(val));
|
patch.set(await config_patching.get(true));
|
||||||
cursorSmoothening.subscribe((val) => config_cursor_smoothening.set(val));
|
customCursor.set(await config_custom_cursor.get(true));
|
||||||
reduceAnimations.subscribe((val) => config_reduce_animations.set(val));
|
cursorSmoothening.set(await config_cursor_smoothening.get(true));
|
||||||
|
reduceAnimations.set(await config_reduce_animations.get(false));
|
||||||
|
discordPresence.set(await config_discord_presence.get(true));
|
||||||
|
openTabletDriverEnabled.set(await config_otd_enabled.get(false));
|
||||||
|
openTabletDriverPath.set(await config_otd_path.get(''));
|
||||||
|
if (await config_tracking_enabled.exists()) {
|
||||||
|
trackingEnabled.set(await config_tracking_enabled.get(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
patch.subscribe(async (val) => await config_patching.set(val));
|
||||||
|
customCursor.subscribe(async (val) => await config_custom_cursor.set(val));
|
||||||
|
cursorSmoothening.subscribe(async (val) => await config_cursor_smoothening.set(val));
|
||||||
|
reduceAnimations.subscribe(async (val) => await config_reduce_animations.set(val));
|
||||||
|
openTabletDriverEnabled.subscribe(async (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 {
|
||||||
presenceLoading.set(true);
|
presenceLoading.set(true);
|
||||||
if (val) {
|
|
||||||
await presence.connect();
|
if (val) await presence.connect();
|
||||||
} else {
|
else await presence.disconnect();
|
||||||
await presence.disconnect();
|
|
||||||
}
|
|
||||||
presenceLoading.set(false);
|
presenceLoading.set(false);
|
||||||
} catch {}
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
presenceLoading.set(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -262,17 +182,69 @@
|
|||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
combinedThemes.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);
|
||||||
|
});
|
||||||
|
|
||||||
|
custom_themes.set(combinedThemes);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
sileo.error({
|
||||||
|
title: 'An error occured!',
|
||||||
|
description: 'Failed to load themes',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
platform.set(await getPlatform());
|
||||||
|
if ($platform !== 'windows' && $platform !== 'linux') unsupported_platform = true;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
{@html `<style>${$active_custom_theme?.cssStyle || ''}</style>`}
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
{#if $customCursor}
|
{#if $customCursor}
|
||||||
<OsuCursor smoothCursor={$cursorSmoothening} />
|
<OsuCursor smoothCursor={$cursorSmoothening} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<SileoToast position="top-center" fill="black" />
|
<SileoToast
|
||||||
|
position="top-center"
|
||||||
|
options={{
|
||||||
|
fill: '#181825',
|
||||||
|
styles: {
|
||||||
|
description: 'text-white/90 text-center!',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Titlebar />
|
<Titlebar />
|
||||||
|
|
||||||
@@ -301,15 +273,18 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="opacity-30">
|
<div class="opacity-30">
|
||||||
{#if secret_enabled}
|
|
||||||
<div transition:fade={{ duration: $reduceAnimations ? 0 : 500 }}>
|
|
||||||
<NyanCatBg />
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div transition:fade={{ duration: $reduceAnimations ? 0 : 500 }}>
|
<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 />
|
<AnimatedBg />
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { currentView, launcherVersion, trackingEnabled } from '@/global';
|
import { currentView, launcherVersion, trackingEnabled } from '$lib/global';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
const View = $derived($currentView);
|
const View = $derived($currentView);
|
||||||
|
|||||||
+706
-243
File diff suppressed because it is too large
Load Diff
+42
-52
@@ -1,6 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Logo from '$assets/logo.png';
|
import Logo from '$assets/logo.png';
|
||||||
import { estimateRefreshRate } from '@/displayUtils';
|
import { ezppfarm } from '$lib/api/ezpp';
|
||||||
|
import { git } from '$lib/api/git';
|
||||||
|
import { config } from '$lib/config';
|
||||||
|
import { currentUserInfo } from '$lib/data';
|
||||||
|
import { estimateFrameRate } from '$lib/displayUtils';
|
||||||
import {
|
import {
|
||||||
beatmapSets,
|
beatmapSets,
|
||||||
currentLoadingInfo,
|
currentLoadingInfo,
|
||||||
@@ -15,21 +19,7 @@
|
|||||||
osuStream,
|
osuStream,
|
||||||
skins,
|
skins,
|
||||||
skinsCount,
|
skinsCount,
|
||||||
} from '@/global';
|
} from '$lib/global';
|
||||||
import {
|
|
||||||
cursorSmoothness,
|
|
||||||
osuInstallationPath,
|
|
||||||
preferredMode,
|
|
||||||
preferredType,
|
|
||||||
userSettings,
|
|
||||||
} from '@/userSettings';
|
|
||||||
import { animate, utils } from 'animejs';
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import SetupWizard from './SetupWizard.svelte';
|
|
||||||
import Launch from './Launch.svelte';
|
|
||||||
import { currentUser, userAuth } from '@/userAuthentication';
|
|
||||||
import { ezppfarm } from '@/api/ezpp';
|
|
||||||
import { currentUserInfo } from '@/data';
|
|
||||||
import {
|
import {
|
||||||
getBeatmapSetsCount,
|
getBeatmapSetsCount,
|
||||||
getEZPPLauncherStreams,
|
getEZPPLauncherStreams,
|
||||||
@@ -38,10 +28,20 @@
|
|||||||
getSkins,
|
getSkins,
|
||||||
getVersion,
|
getVersion,
|
||||||
isValidOsuFolder,
|
isValidOsuFolder,
|
||||||
} from '@/osuUtil';
|
} from '$lib/osuUtil';
|
||||||
import { git } from '@/api/git';
|
import type { EZPPUser } from '$lib/types';
|
||||||
|
import { currentUser } from '$lib/userAuthentication';
|
||||||
|
import {
|
||||||
|
cursorSmoothness,
|
||||||
|
osuInstallationPath,
|
||||||
|
preferredMode,
|
||||||
|
preferredType,
|
||||||
|
} from '$lib/userSettings';
|
||||||
|
import Launch from './Launch.svelte';
|
||||||
|
import SetupWizard from './SetupWizard.svelte';
|
||||||
|
import { animate, utils } from 'animejs';
|
||||||
import { sileo } from 'sileo';
|
import { sileo } from 'sileo';
|
||||||
import type { EZPPUser } from '@/types';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
let ezppLogo: HTMLImageElement;
|
let ezppLogo: HTMLImageElement;
|
||||||
let spinnerCircle: SVGCircleElement;
|
let spinnerCircle: SVGCircleElement;
|
||||||
@@ -67,23 +67,22 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const calculateCursorSmoothness = async () => {
|
const calculateCursorSmoothness = async () => {
|
||||||
const refreshRate = await estimateRefreshRate();
|
const refreshRate = await estimateFrameRate();
|
||||||
const hzMin = 60;
|
const hzMin = 60;
|
||||||
const hzMax = 144;
|
const hzMax = 500;
|
||||||
const durationMin = 70;
|
const durationMin = 350;
|
||||||
const durationMax = 180;
|
const durationMax = 600;
|
||||||
|
const clamped = Math.min(Math.max(refreshRate, hzMin), hzMax);
|
||||||
const duration =
|
const duration =
|
||||||
durationMin + ((refreshRate - hzMin) / (hzMax - hzMin)) * (durationMax - durationMin);
|
durationMin + ((clamped - hzMin) / (hzMax - hzMin)) * (durationMax - durationMin);
|
||||||
|
|
||||||
cursorSmoothness.set(Math.round(duration));
|
cursorSmoothness.set(Math.round(duration));
|
||||||
};
|
};
|
||||||
|
|
||||||
const prepare = async () => {
|
const prepare = async () => {
|
||||||
await calculateCursorSmoothness();
|
await calculateCursorSmoothness();
|
||||||
|
|
||||||
const username = $userAuth.value('username').get('');
|
const username = await config.value<string>('username').get('');
|
||||||
const password = $userAuth.value('password').get('');
|
const password = await config.value<string>('password').get('');
|
||||||
|
|
||||||
const shouldLogin = username.length > 0 && password.length > 0;
|
const shouldLogin = username.length > 0 && password.length > 0;
|
||||||
let userLoginResult: { message: string; user?: EZPPUser } = {
|
let userLoginResult: { message: string; user?: EZPPUser } = {
|
||||||
@@ -106,7 +105,8 @@
|
|||||||
message: 'Please check your username and password.',
|
message: 'Please check your username and password.',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
userLoginResult = {
|
userLoginResult = {
|
||||||
message: 'There was an issue connecting to the server. Please try again later.',
|
message: 'There was an issue connecting to the server. Please try again later.',
|
||||||
};
|
};
|
||||||
@@ -122,7 +122,8 @@
|
|||||||
preferredMode.set(userInfo.player.info.preferred_mode);
|
preferredMode.set(userInfo.player.info.preferred_mode);
|
||||||
preferredType.set(userInfo.player.info.preferred_type);
|
preferredType.set(userInfo.player.info.preferred_type);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
userLoginResult = {
|
userLoginResult = {
|
||||||
message: 'There was an issue connecting to the server. Please try again later.',
|
message: 'There was an issue connecting to the server. Please try again later.',
|
||||||
};
|
};
|
||||||
@@ -132,20 +133,18 @@
|
|||||||
|
|
||||||
if (!$firstStartup) {
|
if (!$firstStartup) {
|
||||||
currentLoadingInfo.set('Checking osu installation path...');
|
currentLoadingInfo.set('Checking osu installation path...');
|
||||||
const validFolder = await isValidOsuFolder($osuInstallationPath);
|
const config_osu_installation_path = config.value<string>('osu_installation_path');
|
||||||
|
const osuInstallationPathVal = await config_osu_installation_path.get('');
|
||||||
|
const validFolder = await isValidOsuFolder(osuInstallationPathVal);
|
||||||
if (!validFolder) {
|
if (!validFolder) {
|
||||||
|
await config_osu_installation_path.set('');
|
||||||
osuInstallationPath.set('');
|
osuInstallationPath.set('');
|
||||||
$userSettings.value('osu_installation_path').del();
|
|
||||||
await $userSettings.save();
|
|
||||||
sileo.error({
|
sileo.error({
|
||||||
title: 'Hmm...',
|
title: 'Hmm...',
|
||||||
description: 'Your previously set osu! installation path seems to be invalid.',
|
description: 'Your previously set osu! installation path seems to be invalid.',
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
osuInstallationPath.set(osuInstallationPathVal);
|
||||||
currentLoadingInfo.set('Getting osu version...');
|
currentLoadingInfo.set('Getting osu version...');
|
||||||
const osuReleaseStream = await getReleaseStream($osuInstallationPath);
|
const osuReleaseStream = await getReleaseStream($osuInstallationPath);
|
||||||
osuStream.set(osuReleaseStream);
|
osuStream.set(osuReleaseStream);
|
||||||
@@ -158,7 +157,6 @@
|
|||||||
|
|
||||||
currentLoadingInfo.set('Counting skins...');
|
currentLoadingInfo.set('Counting skins...');
|
||||||
const skins_list = await getSkins($osuInstallationPath);
|
const skins_list = await getSkins($osuInstallationPath);
|
||||||
console.log(skins_list);
|
|
||||||
if (skins_list) {
|
if (skins_list) {
|
||||||
skins.set(skins_list);
|
skins.set(skins_list);
|
||||||
skinsCount.set(skins_list.length);
|
skinsCount.set(skins_list.length);
|
||||||
@@ -180,7 +178,7 @@
|
|||||||
const ezpplauncherStreams = await getEZPPLauncherStreams();
|
const ezpplauncherStreams = await getEZPPLauncherStreams();
|
||||||
if (ezpplauncherStreams) launcherStreams.set(ezpplauncherStreams);
|
if (ezpplauncherStreams) launcherStreams.set(ezpplauncherStreams);
|
||||||
|
|
||||||
const selectedLauncherStream = $userSettings.value('patcherStream').get('stable');
|
const selectedLauncherStream = await config.value<string>('patcherStream').get('stable');
|
||||||
if ($launcherStreams.includes(selectedLauncherStream)) {
|
if ($launcherStreams.includes(selectedLauncherStream)) {
|
||||||
launcherStream.set(selectedLauncherStream);
|
launcherStream.set(selectedLauncherStream);
|
||||||
}
|
}
|
||||||
@@ -207,20 +205,12 @@
|
|||||||
sileo.success({
|
sileo.success({
|
||||||
title: 'Login successful!',
|
title: 'Login successful!',
|
||||||
description: userLoginResult.message,
|
description: userLoginResult.message,
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
duration: 2500,
|
duration: 2500,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
sileo.error({
|
sileo.error({
|
||||||
title: 'Login failed!',
|
title: 'Login failed!',
|
||||||
description: userLoginResult.message,
|
description: userLoginResult.message,
|
||||||
fill: '#181825',
|
|
||||||
styles: {
|
|
||||||
description: 'text-center!',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,19 +242,19 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col items-center justify-center h-[100vh] w-full">
|
<div class="flex flex-col items-center justify-center h-screen w-full z-10">
|
||||||
<div class="relative w-80 h-80 flex items-center justify-center">
|
<div class="relative w-80 h-80 flex items-center justify-center z-10">
|
||||||
<svg
|
<svg
|
||||||
class="absolute top-0 left-0 w-full h-full animate-spin"
|
class="absolute top-0 left-0 w-full h-full animate-spin"
|
||||||
style="animation-duration: 5s;"
|
style="animation-duration: 5s;"
|
||||||
viewBox="0 0 208 208"
|
viewBox="0 0 208 208"
|
||||||
>
|
>
|
||||||
<circle
|
<circle
|
||||||
|
class="stroke-primary"
|
||||||
cx="104"
|
cx="104"
|
||||||
cy="104"
|
cy="104"
|
||||||
r="90"
|
r="90"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="#ff0098"
|
|
||||||
stroke-width="8"
|
stroke-width="8"
|
||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-dasharray="180 385"
|
stroke-dasharray="180 385"
|
||||||
@@ -275,9 +265,9 @@
|
|||||||
<img
|
<img
|
||||||
src={Logo}
|
src={Logo}
|
||||||
alt="EZPPLauncher Logo"
|
alt="EZPPLauncher Logo"
|
||||||
class="w-52 h-52 mb-2 relative z-10"
|
class="w-52 h-52 mb-2 relative z-10 select-auto pointer-events-none"
|
||||||
bind:this={ezppLogo}
|
bind:this={ezppLogo}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-theme-200 text-sm mt-5">{$currentLoadingInfo}</span>
|
<span class="text-theme-200 text-sm mt-5 z-10">{$currentLoadingInfo}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { dev } from '$app/environment';
|
||||||
import Logo from '$assets/logo.png';
|
import Logo from '$assets/logo.png';
|
||||||
import Button from '@/components/ui/button/button.svelte';
|
import Button from '$lib/components/ui/button/button.svelte';
|
||||||
import Input from '@/components/ui/input/input.svelte';
|
import Checkbox from '$lib/components/ui/checkbox/checkbox.svelte';
|
||||||
import { animate } from 'animejs';
|
import Input from '$lib/components/ui/input/input.svelte';
|
||||||
import { onMount } from 'svelte';
|
import Label from '$lib/components/ui/label/label.svelte';
|
||||||
import { fade } from 'svelte/transition';
|
import { config } from '$lib/config';
|
||||||
import { Check, CircleCheckBig, CircleOff, LoaderCircle } from 'lucide-svelte';
|
|
||||||
import { open } from '@tauri-apps/plugin-dialog';
|
|
||||||
import Checkbox from '@/components/ui/checkbox/checkbox.svelte';
|
|
||||||
import {
|
|
||||||
cursorSmoothening,
|
|
||||||
customCursor,
|
|
||||||
osuInstallationPath,
|
|
||||||
patch,
|
|
||||||
reduceAnimations,
|
|
||||||
userSettings,
|
|
||||||
} from '@/userSettings';
|
|
||||||
import Label from '@/components/ui/label/label.svelte';
|
|
||||||
import {
|
import {
|
||||||
beatmapSets,
|
beatmapSets,
|
||||||
currentSkin,
|
currentSkin,
|
||||||
@@ -24,13 +13,10 @@
|
|||||||
discordPresence,
|
discordPresence,
|
||||||
osuBuild,
|
osuBuild,
|
||||||
osuStream,
|
osuStream,
|
||||||
platform,
|
|
||||||
presenceLoading,
|
presenceLoading,
|
||||||
skins,
|
skins,
|
||||||
skinsCount,
|
skinsCount,
|
||||||
} from '@/global';
|
} from '$lib/global';
|
||||||
import Launch from './Launch.svelte';
|
|
||||||
import Confetti from 'svelte-confetti';
|
|
||||||
import {
|
import {
|
||||||
autoDetectOsuInstallFolder,
|
autoDetectOsuInstallFolder,
|
||||||
getBeatmapSetsCount,
|
getBeatmapSetsCount,
|
||||||
@@ -39,7 +25,21 @@
|
|||||||
getSkins,
|
getSkins,
|
||||||
getVersion,
|
getVersion,
|
||||||
isValidOsuFolder,
|
isValidOsuFolder,
|
||||||
} from '@/osuUtil';
|
} from '$lib/osuUtil';
|
||||||
|
import {
|
||||||
|
cursorSmoothening,
|
||||||
|
customCursor,
|
||||||
|
osuInstallationPath,
|
||||||
|
patch,
|
||||||
|
reduceAnimations,
|
||||||
|
} from '$lib/userSettings';
|
||||||
|
import Launch from './Launch.svelte';
|
||||||
|
import { Check, CircleCheckBig, CircleOff, LoaderCircle } from '@lucide/svelte';
|
||||||
|
import { open } from '@tauri-apps/plugin-dialog';
|
||||||
|
import { animate } from 'animejs';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import Confetti from 'svelte-confetti';
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
let selectedStep = $state(1);
|
let selectedStep = $state(1);
|
||||||
const steps = ['Welcome', 'Locate your osu! Installation', 'Appearance Settings'];
|
const steps = ['Welcome', 'Locate your osu! Installation', 'Appearance Settings'];
|
||||||
@@ -94,9 +94,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveConfig = async () => {
|
const saveConfig = async () => {
|
||||||
$userSettings.value('osu_installation_path').set(osuInstallPath);
|
await config.value<string>('osu_installation_path').set(osuInstallPath);
|
||||||
await $userSettings.save();
|
|
||||||
osuInstallationPath.set(osuInstallPath);
|
osuInstallationPath.set(osuInstallPath);
|
||||||
|
await config.value<boolean>('setup_complete').set(true);
|
||||||
|
|
||||||
const beatmapSetCount = await getBeatmapSetsCount(osuInstallPath);
|
const beatmapSetCount = await getBeatmapSetsCount(osuInstallPath);
|
||||||
if (beatmapSetCount) {
|
if (beatmapSetCount) {
|
||||||
@@ -124,17 +124,16 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const osuPath = await autoDetectOsuInstallFolder();
|
const osuPath = await autoDetectOsuInstallFolder();
|
||||||
console.log(osuPath);
|
|
||||||
if (osuPath) {
|
if (osuPath) {
|
||||||
osuInstallPath = osuPath;
|
osuInstallPath = osuPath;
|
||||||
autoDetectedOsuPath = true;
|
autoDetectedOsuPath = true;
|
||||||
$userSettings.value('osu_installation_path').set(osuInstallPath);
|
await config.value<string>('osu_installation_path').set(osuInstallPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if wizardFinished}
|
{#if wizardFinished}
|
||||||
<div class="relative flex flex-col items-center justify-center h-[100vh] z-50">
|
<div class="relative flex flex-col items-center justify-center h-screen z-50">
|
||||||
<div class="absolute h-fit w-fit top-1/2 left-1/2">
|
<div class="absolute h-fit w-fit top-1/2 left-1/2">
|
||||||
<Confetti amount={200} y={[-1, 1.5]} x={[-2.3, 2.3]} colorArray={['#C6A0F3']} />
|
<Confetti amount={200} y={[-1, 1.5]} x={[-2.3, 2.3]} colorArray={['#C6A0F3']} />
|
||||||
</div>
|
</div>
|
||||||
@@ -143,7 +142,7 @@
|
|||||||
<Button class="mt-4" onclick={saveConfig}>Finish</Button>
|
<Button class="mt-4" onclick={saveConfig}>Finish</Button>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="grid grid-cols-[0.41fr_1fr] h-[100vh] z-50">
|
<div class="grid grid-cols-[0.41fr_1fr] h-screen z-50">
|
||||||
<div
|
<div
|
||||||
class="w-full h-full border-r border-black/40 bg-black/40 backdrop-blur-md flex flex-col gap-6 p-3 z-50"
|
class="w-full h-full border-r border-black/40 bg-black/40 backdrop-blur-md flex flex-col gap-6 p-3 z-50"
|
||||||
>
|
>
|
||||||
@@ -156,8 +155,7 @@
|
|||||||
: 'border-black/30 bg-black/30'} rounded-lg p-2 transition-all"
|
: 'border-black/30 bg-black/30'} rounded-lg p-2 transition-all"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col items-center justify-center h-8 w-8 border-[2px] {selectedStep >
|
class="flex flex-col items-center justify-center h-8 w-8 border-2 {selectedStep > i + 1
|
||||||
i + 1
|
|
||||||
? 'border-green-600'
|
? 'border-green-600'
|
||||||
: 'border-theme-600'} rounded-full"
|
: 'border-theme-600'} rounded-full"
|
||||||
>
|
>
|
||||||
@@ -267,20 +265,18 @@
|
|||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<Label class="text-sm" for="setting-patch">Patching</Label>
|
<Label class="text-sm" for="setting-patch">Patching</Label>
|
||||||
<div class="text-muted-foreground text-xs">
|
<div class="text-muted-foreground text-xs">
|
||||||
Shows misses in Relax and Autopilot {#if $platform !== 'windows'}<span
|
Shows misses in Relax and Autopilot <!-- {#if $platform !== 'windows'}<span
|
||||||
class="text-red-500 bg-red-800/20 border border-red-600/20 p-0.5 mx-1 px-2 rounded-lg !text-[0.55rem]"
|
class="text-red-500 bg-red-800/20 border border-red-600/20 p-0.5 mx-1 px-2 rounded-lg text-[0.55rem]!"
|
||||||
>currently only on windows!</span
|
>currently only on windows!</span
|
||||||
>
|
>
|
||||||
{/if}
|
{/if} -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="setting-patch"
|
id="setting-patch"
|
||||||
checked={$platform === 'windows' ? $patch : false}
|
checked={$patch}
|
||||||
disabled={$platform !== 'windows'}
|
|
||||||
onCheckedChange={async (e) => {
|
onCheckedChange={async (e) => {
|
||||||
patch.set(e);
|
patch.set(e);
|
||||||
$userSettings.save();
|
|
||||||
}}
|
}}
|
||||||
class="flex items-center justify-center w-5 h-5"
|
class="flex items-center justify-center w-5 h-5"
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
@@ -299,8 +295,6 @@
|
|||||||
cursorSmoothening.set(false);
|
cursorSmoothening.set(false);
|
||||||
}
|
}
|
||||||
customCursor.set(e);
|
customCursor.set(e);
|
||||||
|
|
||||||
$userSettings.save();
|
|
||||||
}}
|
}}
|
||||||
class="flex items-center justify-center w-5 h-5"
|
class="flex items-center justify-center w-5 h-5"
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
@@ -317,7 +311,6 @@
|
|||||||
onCheckedChange={async (e) => {
|
onCheckedChange={async (e) => {
|
||||||
if (!$customCursor) return;
|
if (!$customCursor) return;
|
||||||
cursorSmoothening.set(e);
|
cursorSmoothening.set(e);
|
||||||
$userSettings.save();
|
|
||||||
}}
|
}}
|
||||||
disabled={!$customCursor}
|
disabled={!$customCursor}
|
||||||
class="flex items-center justify-center w-5 h-5"
|
class="flex items-center justify-center w-5 h-5"
|
||||||
@@ -335,7 +328,6 @@
|
|||||||
checked={$reduceAnimations}
|
checked={$reduceAnimations}
|
||||||
onCheckedChange={async (e) => {
|
onCheckedChange={async (e) => {
|
||||||
reduceAnimations.set(e);
|
reduceAnimations.set(e);
|
||||||
$userSettings.save();
|
|
||||||
}}
|
}}
|
||||||
class="flex items-center justify-center w-5 h-5"
|
class="flex items-center justify-center w-5 h-5"
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
@@ -377,7 +369,7 @@
|
|||||||
else selectedStep = Math.min(selectedStep + 1, steps.length);
|
else selectedStep = Math.min(selectedStep + 1, steps.length);
|
||||||
}}
|
}}
|
||||||
disabled={selectedStep > steps.length ||
|
disabled={selectedStep > steps.length ||
|
||||||
(selectedStep === 2 && osuInstallPath.length <= 0)}
|
(selectedStep === 2 && !dev && osuInstallPath.length <= 0)}
|
||||||
>{selectedStep >= steps.length ? 'Finish' : 'Next'}</Button
|
>{selectedStep >= steps.length ? 'Finish' : 'Next'}</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ const config = {
|
|||||||
kit: {
|
kit: {
|
||||||
adapter: adapter(),
|
adapter: adapter(),
|
||||||
alias: {
|
alias: {
|
||||||
'@/*': './src/lib/*',
|
|
||||||
'$lib/*': './src/lib/*',
|
'$lib/*': './src/lib/*',
|
||||||
'$assets/*': './src/assets/*',
|
'$assets/*': './src/assets/*',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
import { fontFamily } from 'tailwindcss/defaultTheme';
|
|
||||||
import type { Config } from 'tailwindcss';
|
|
||||||
import tailwindcssAnimate from 'tailwindcss-animate';
|
|
||||||
|
|
||||||
const config: Config = {
|
|
||||||
darkMode: 'class',
|
|
||||||
content: ['./src/**/*.{html,js,svelte,ts}'],
|
|
||||||
safelist: ['dark'],
|
|
||||||
theme: {
|
|
||||||
container: {
|
|
||||||
center: true,
|
|
||||||
padding: '2rem',
|
|
||||||
screens: {
|
|
||||||
'2xl': '1400px',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extend: {
|
|
||||||
colors: {
|
|
||||||
theme: {
|
|
||||||
DEFAULT: '#181825',
|
|
||||||
50: '#E9E9F1',
|
|
||||||
100: '#DBDBE8',
|
|
||||||
200: '#BFBFD6',
|
|
||||||
300: '#A4A4C4',
|
|
||||||
400: '#8888B2',
|
|
||||||
500: '#6C6CA0',
|
|
||||||
600: '#575786',
|
|
||||||
700: '#45456B',
|
|
||||||
800: '#33334F',
|
|
||||||
900: '#212133',
|
|
||||||
950: '#181825',
|
|
||||||
},
|
|
||||||
border: 'hsl(var(--border) / <alpha-value>)',
|
|
||||||
input: 'hsl(var(--input) / <alpha-value>)',
|
|
||||||
ring: 'hsl(var(--ring) / <alpha-value>)',
|
|
||||||
background: 'hsl(var(--background) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--foreground) / <alpha-value>)',
|
|
||||||
primary: {
|
|
||||||
DEFAULT: 'hsl(var(--primary) / <alpha-value>)',
|
|
||||||
50: '#FEFDFF',
|
|
||||||
100: '#FAF6FE',
|
|
||||||
200: '#F2E9FC',
|
|
||||||
300: '#E9DBFA',
|
|
||||||
400: '#E1CEF9',
|
|
||||||
500: '#D9C0F7',
|
|
||||||
600: '#C6A0F3',
|
|
||||||
700: '#B381EF',
|
|
||||||
800: '#A061EB',
|
|
||||||
900: '#8D41E7',
|
|
||||||
950: '#8331E5',
|
|
||||||
foreground: 'hsl(var(--primary-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
secondary: {
|
|
||||||
DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
destructive: {
|
|
||||||
DEFAULT: 'hsl(var(--destructive) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
muted: {
|
|
||||||
DEFAULT: 'hsl(var(--muted) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--muted-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
accent: {
|
|
||||||
DEFAULT: 'hsl(var(--accent) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--accent-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
popover: {
|
|
||||||
DEFAULT: 'hsl(var(--popover) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--popover-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
card: {
|
|
||||||
DEFAULT: 'hsl(var(--card) / <alpha-value>)',
|
|
||||||
foreground: 'hsl(var(--card-foreground) / <alpha-value>)',
|
|
||||||
},
|
|
||||||
sidebar: {
|
|
||||||
DEFAULT: 'hsl(var(--sidebar-background))',
|
|
||||||
foreground: 'hsl(var(--sidebar-foreground))',
|
|
||||||
primary: 'hsl(var(--sidebar-primary))',
|
|
||||||
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
|
|
||||||
accent: 'hsl(var(--sidebar-accent))',
|
|
||||||
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
|
|
||||||
border: 'hsl(var(--sidebar-border))',
|
|
||||||
ring: 'hsl(var(--sidebar-ring))',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
borderRadius: {
|
|
||||||
xl: 'calc(var(--radius) + 4px)',
|
|
||||||
lg: 'var(--radius)',
|
|
||||||
md: 'calc(var(--radius) - 2px)',
|
|
||||||
sm: 'calc(var(--radius) - 4px)',
|
|
||||||
},
|
|
||||||
fontFamily: {
|
|
||||||
sans: ['"Sora"', ...fontFamily.sans],
|
|
||||||
mono: ['"Space Mono"', ...fontFamily.mono],
|
|
||||||
},
|
|
||||||
keyframes: {
|
|
||||||
'accordion-down': {
|
|
||||||
from: { height: '0' },
|
|
||||||
to: { height: 'var(--bits-accordion-content-height)' },
|
|
||||||
},
|
|
||||||
'accordion-up': {
|
|
||||||
from: { height: 'var(--bits-accordion-content-height)' },
|
|
||||||
to: { height: '0' },
|
|
||||||
},
|
|
||||||
'caret-blink': {
|
|
||||||
'0%,70%,100%': { opacity: '1' },
|
|
||||||
'20%,50%': { opacity: '0' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
animation: {
|
|
||||||
'accordion-down': 'accordion-down 0.2s ease-out',
|
|
||||||
'accordion-up': 'accordion-up 0.2s ease-out',
|
|
||||||
'caret-blink': 'caret-blink 1.25s ease-out infinite',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [tailwindcssAnimate],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user