Compare commits
48 Commits
b376737dba
...
3.0.2
Author | SHA1 | Date | |
---|---|---|---|
ea6db9afd1 | |||
d56b375953 | |||
ec25d5d2bb | |||
13b90092b7 | |||
f214aa454e | |||
9d2599dd2f | |||
eddaaaaa2f | |||
a21abe86bb | |||
d685114bd7 | |||
4e4998671a | |||
5cae8bc63a | |||
409c8b0b04 | |||
c395662134 | |||
89d1bcbd86 | |||
c3c13b0e07 | |||
4e1f76a713 | |||
4fb2ab7bed | |||
bb90e28d92 | |||
a554c53f89 | |||
307e0c9747 | |||
86033e2d6a | |||
1a563e64d5 | |||
5aec2d8245 | |||
87742b66b7 | |||
df3bd69141 | |||
12feed96e9 | |||
b530dbf72f | |||
174616f07b | |||
d2a0e09e75 | |||
a91fff1f59 | |||
376ee1e648 | |||
d6623891bb | |||
9f62332334 | |||
f051253abb | |||
57a95b4759 | |||
f5831b377c | |||
33bd75eeee | |||
3b3447c42c | |||
2162ba15fe | |||
1ab19957ba | |||
2082beb387 | |||
4fbce4cd0a | |||
2ef108da2b | |||
7d32e663d0 | |||
4845eaeed2 | |||
3e63d7527e | |||
3dc62a060e | |||
6d2d5de6d2 |
@@ -7,3 +7,6 @@ bun.lockb
|
|||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
/static/
|
/static/
|
||||||
|
|
||||||
|
# Tauri
|
||||||
|
/src-tauri/
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"useTabs": false,
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"plugins": ["prettier-plugin-svelte", "prettier-plugin-rust"],
|
"plugins": ["prettier-plugin-svelte"],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": "*.svelte",
|
"files": "*.svelte",
|
||||||
|
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
@@ -7,6 +7,7 @@
|
|||||||
"fill-labs.dependi",
|
"fill-labs.dependi",
|
||||||
"mylesmurphy.prettify-ts",
|
"mylesmurphy.prettify-ts",
|
||||||
"edwinhuish.better-comments-next",
|
"edwinhuish.better-comments-next",
|
||||||
"dbaeumer.vscode-eslint"
|
"dbaeumer.vscode-eslint",
|
||||||
|
"bradlc.vscode-tailwindcss"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"svelte.enable-ts-plugin": true,
|
"svelte.enable-ts-plugin": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"[rust]":{
|
"[rust]": {
|
||||||
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -631,8 +631,7 @@ to attach them to the start of each source file to most effectively
|
|||||||
state the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
Copyright (C) 2025 HorizonCode
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
75
README.md
75
README.md
@@ -1,3 +1,74 @@
|
|||||||
# EZPPLauncher Tauri
|
# EZPPLauncher
|
||||||
|
|
||||||
Trying to recode this shit with tauri, kms
|
**EZPPLauncher** is a custom launcher for the private osu! server [EZPPFarm](https://ez-pp.farm), built with **Rust** and **Svelte** using the [Tauri](https://tauri.app) framework.
|
||||||
|
It enhances the osu! experience with quality-of-life features and integration specifically designed for the EZPPFarm community.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🖼️ Preview
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Features
|
||||||
|
|
||||||
|
- [x] Automatically updates osu! before launching
|
||||||
|
- [x] Automatic ingame login
|
||||||
|
- [x] Patches the osu! client to show misses in Relax and Autopilot
|
||||||
|
- [x] Displays your EZPPFarm stats in the launcher
|
||||||
|
- [x] Shows the number of imported beatmapsets
|
||||||
|
- [x] Shows the number of imported skins
|
||||||
|
- [x] Displays ping to the EZPPFarm server
|
||||||
|
- [x] Discord Rich Presence
|
||||||
|
- [x] Performance Display Overlay (currently in experimental patcher release stream)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 💻 Supported Platforms
|
||||||
|
|
||||||
|
| Platform | Status |
|
||||||
|
| -------- | ---------------------------------------- |
|
||||||
|
| Windows | ✅ Supported |
|
||||||
|
| macOS | ❌ Not supported |
|
||||||
|
| Linux | 🕧 Partially supported (via osu-winello) |
|
||||||
|
|
||||||
|
> Currently, only **Windows** is fully supported. Support for other platforms may be considered in the future.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠 Build From Source
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
- **Rust** (installed via [rustup](https://rustup.rs/) – recommended for Windows)
|
||||||
|
- **Cargo** (comes with rustup)
|
||||||
|
- **[Bun](https://bun.sh/)** (JavaScript runtime)
|
||||||
|
|
||||||
|
### Steps
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install all dependencies
|
||||||
|
bun i
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
bun run build
|
||||||
|
```
|
||||||
|
|
||||||
|
After building, the launcher executable will be located at:
|
||||||
|
|
||||||
|
```
|
||||||
|
src-tauri/target/release/ezpplauncher.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📁 Project Structure (Simplified)
|
||||||
|
|
||||||
|
```
|
||||||
|
├── src/ # Frontend (Svelte)
|
||||||
|
├── src-tauri/ # Backend (Rust)
|
||||||
|
│ ├── tauri.conf.json # Tauri configuration
|
||||||
|
├── package.json # Bun project config
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
BIN
assets/EZPPLauncher-preview.png
Normal file
BIN
assets/EZPPLauncher-preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
13
bun.lock
13
bun.lock
@@ -7,7 +7,7 @@
|
|||||||
"@better-fetch/fetch": "^1.1.18",
|
"@better-fetch/fetch": "^1.1.18",
|
||||||
"@fontsource/sora": "^5.2.6",
|
"@fontsource/sora": "^5.2.6",
|
||||||
"@fontsource/space-mono": "^5.2.8",
|
"@fontsource/space-mono": "^5.2.8",
|
||||||
"@iarna/toml": "^3.0.0",
|
"@iarna/toml": "2.2.5",
|
||||||
"@number-flow/svelte": "^0.3.9",
|
"@number-flow/svelte": "^0.3.9",
|
||||||
"@tailwindcss/typography": "0.5.16",
|
"@tailwindcss/typography": "0.5.16",
|
||||||
"@tailwindcss/vite": "^4.1.11",
|
"@tailwindcss/vite": "^4.1.11",
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"@sveltejs/kit": "2.22.2",
|
"@sveltejs/kit": "2.22.2",
|
||||||
"@sveltejs/vite-plugin-svelte": "5.1.0",
|
"@sveltejs/vite-plugin-svelte": "5.1.0",
|
||||||
"@tauri-apps/cli": "2.6.1",
|
"@tauri-apps/cli": "2.6.1",
|
||||||
|
"@types/bun": "^1.2.18",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/semver": "^7.7.0",
|
"@types/semver": "^7.7.0",
|
||||||
"autoprefixer": "10.4.21",
|
"autoprefixer": "10.4.21",
|
||||||
@@ -157,7 +158,7 @@
|
|||||||
|
|
||||||
"@humanwhocodes/retry": ["@humanwhocodes/retry@0.4.3", "", {}, "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ=="],
|
"@humanwhocodes/retry": ["@humanwhocodes/retry@0.4.3", "", {}, "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ=="],
|
||||||
|
|
||||||
"@iarna/toml": ["@iarna/toml@3.0.0", "", {}, "sha512-td6ZUkz2oS3VeleBcN+m//Q6HlCFCPrnI0FZhrt/h4XqLEdOyYp2u21nd8MdsR+WJy5r9PTDaHTDDfhf4H4l6Q=="],
|
"@iarna/toml": ["@iarna/toml@2.2.5", "", {}, "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="],
|
||||||
|
|
||||||
"@internationalized/date": ["@internationalized/date@3.8.2", "", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-/wENk7CbvLbkUvX1tu0mwq49CVkkWpkXubGel6birjRPyo6uQ4nQpnq5xZu823zRCwwn82zgHrvgF1vZyvmVgA=="],
|
"@internationalized/date": ["@internationalized/date@3.8.2", "", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-/wENk7CbvLbkUvX1tu0mwq49CVkkWpkXubGel6birjRPyo6uQ4nQpnq5xZu823zRCwwn82zgHrvgF1vZyvmVgA=="],
|
||||||
|
|
||||||
@@ -303,6 +304,8 @@
|
|||||||
|
|
||||||
"@tauri-apps/plugin-sql": ["@tauri-apps/plugin-sql@2.3.0", "", { "dependencies": { "@tauri-apps/api": "^2.6.0" } }, "sha512-JYwIocfsLaDWa41LMiZWuzts7yCJR+EpZPRmgpO7Gd7XiAS9S67dKz306j/k/d9XntB0YopMRBol2OIWMschuA=="],
|
"@tauri-apps/plugin-sql": ["@tauri-apps/plugin-sql@2.3.0", "", { "dependencies": { "@tauri-apps/api": "^2.6.0" } }, "sha512-JYwIocfsLaDWa41LMiZWuzts7yCJR+EpZPRmgpO7Gd7XiAS9S67dKz306j/k/d9XntB0YopMRBol2OIWMschuA=="],
|
||||||
|
|
||||||
|
"@types/bun": ["@types/bun@1.2.18", "", { "dependencies": { "bun-types": "1.2.18" } }, "sha512-Xf6RaWVheyemaThV0kUfaAUvCNokFr+bH8Jxp+tTZfx7dAPA8z9ePnP9S9+Vspzuxxx9JRAXhnyccRj3GyCMdQ=="],
|
||||||
|
|
||||||
"@types/cookie": ["@types/cookie@0.6.0", "", {}, "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA=="],
|
"@types/cookie": ["@types/cookie@0.6.0", "", {}, "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA=="],
|
||||||
|
|
||||||
"@types/crypto-js": ["@types/crypto-js@4.2.2", "", {}, "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ=="],
|
"@types/crypto-js": ["@types/crypto-js@4.2.2", "", {}, "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ=="],
|
||||||
@@ -313,6 +316,8 @@
|
|||||||
|
|
||||||
"@types/node": ["@types/node@20.19.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-jJD50LtlD2dodAEO653i3YF04NWak6jN3ky+Ri3Em3mGR39/glWiboM/IePaRbgwSfqM1TpGXfAg8ohn/4dTgA=="],
|
"@types/node": ["@types/node@20.19.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-jJD50LtlD2dodAEO653i3YF04NWak6jN3ky+Ri3Em3mGR39/glWiboM/IePaRbgwSfqM1TpGXfAg8ohn/4dTgA=="],
|
||||||
|
|
||||||
|
"@types/react": ["@types/react@19.1.8", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g=="],
|
||||||
|
|
||||||
"@types/semver": ["@types/semver@7.7.0", "", {}, "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA=="],
|
"@types/semver": ["@types/semver@7.7.0", "", {}, "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA=="],
|
||||||
|
|
||||||
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.35.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.35.1", "@typescript-eslint/type-utils": "8.35.1", "@typescript-eslint/utils": "8.35.1", "@typescript-eslint/visitor-keys": "8.35.1", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.35.1", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-9XNTlo7P7RJxbVeICaIIIEipqxLKguyh+3UbXuT2XQuFp6d8VOeDEGuz5IiX0dgZo8CiI6aOFLg4e8cF71SFVg=="],
|
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.35.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.35.1", "@typescript-eslint/type-utils": "8.35.1", "@typescript-eslint/utils": "8.35.1", "@typescript-eslint/visitor-keys": "8.35.1", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.35.1", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-9XNTlo7P7RJxbVeICaIIIEipqxLKguyh+3UbXuT2XQuFp6d8VOeDEGuz5IiX0dgZo8CiI6aOFLg4e8cF71SFVg=="],
|
||||||
@@ -369,6 +374,8 @@
|
|||||||
|
|
||||||
"buffer-builder": ["buffer-builder@0.2.0", "", {}, "sha512-7VPMEPuYznPSoR21NE1zvd2Xna6c/CloiZCfcMXR1Jny6PjX0N4Nsa38zcBFo/FMK+BlA+FLKbJCQ0i2yxp+Xg=="],
|
"buffer-builder": ["buffer-builder@0.2.0", "", {}, "sha512-7VPMEPuYznPSoR21NE1zvd2Xna6c/CloiZCfcMXR1Jny6PjX0N4Nsa38zcBFo/FMK+BlA+FLKbJCQ0i2yxp+Xg=="],
|
||||||
|
|
||||||
|
"bun-types": ["bun-types@1.2.18", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-04+Eha5NP7Z0A9YgDAzMk5PHR16ZuLVa83b26kH5+cp1qZW4F6FmAURngE7INf4tKOvCE69vYvDEwoNl1tGiWw=="],
|
||||||
|
|
||||||
"callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="],
|
"callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="],
|
||||||
|
|
||||||
"caniuse-lite": ["caniuse-lite@1.0.30001726", "", {}, "sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw=="],
|
"caniuse-lite": ["caniuse-lite@1.0.30001726", "", {}, "sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw=="],
|
||||||
@@ -397,6 +404,8 @@
|
|||||||
|
|
||||||
"cssesc": ["cssesc@3.0.0", "", { "bin": { "cssesc": "bin/cssesc" } }, "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg=="],
|
"cssesc": ["cssesc@3.0.0", "", { "bin": { "cssesc": "bin/cssesc" } }, "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg=="],
|
||||||
|
|
||||||
|
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
|
||||||
|
|
||||||
"debug": ["debug@4.4.1", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="],
|
"debug": ["debug@4.4.1", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="],
|
||||||
|
|
||||||
"deep-is": ["deep-is@0.1.4", "", {}, "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="],
|
"deep-is": ["deep-is@0.1.4", "", {}, "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="],
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
"@better-fetch/fetch": "^1.1.18",
|
"@better-fetch/fetch": "^1.1.18",
|
||||||
"@fontsource/sora": "^5.2.6",
|
"@fontsource/sora": "^5.2.6",
|
||||||
"@fontsource/space-mono": "^5.2.8",
|
"@fontsource/space-mono": "^5.2.8",
|
||||||
"@iarna/toml": "^3.0.0",
|
"@iarna/toml": "2.2.5",
|
||||||
"@number-flow/svelte": "^0.3.9",
|
"@number-flow/svelte": "^0.3.9",
|
||||||
"@tailwindcss/typography": "0.5.16",
|
"@tailwindcss/typography": "0.5.16",
|
||||||
"@tailwindcss/vite": "^4.1.11",
|
"@tailwindcss/vite": "^4.1.11",
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
"@sveltejs/kit": "2.22.2",
|
"@sveltejs/kit": "2.22.2",
|
||||||
"@sveltejs/vite-plugin-svelte": "5.1.0",
|
"@sveltejs/vite-plugin-svelte": "5.1.0",
|
||||||
"@tauri-apps/cli": "2.6.1",
|
"@tauri-apps/cli": "2.6.1",
|
||||||
|
"@types/bun": "^1.2.18",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/semver": "^7.7.0",
|
"@types/semver": "^7.7.0",
|
||||||
"autoprefixer": "10.4.21",
|
"autoprefixer": "10.4.21",
|
||||||
|
42
src-tauri/Cargo.lock
generated
42
src-tauri/Cargo.lock
generated
@@ -489,7 +489,7 @@ checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"fnv",
|
"fnv",
|
||||||
"uuid",
|
"uuid 1.17.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -843,6 +843,19 @@ dependencies = [
|
|||||||
"windows-sys 0.60.2",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "discord-rich-presence"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a75db747ecd252c01bfecaf709b07fcb4c634adf0edb5fed47bc9c3052e7076b"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"serde_repr",
|
||||||
|
"uuid 0.8.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -1081,10 +1094,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ezpplauncher"
|
name = "ezpplauncher"
|
||||||
version = "3.0.0-beta.1"
|
version = "3.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base64 0.21.7",
|
||||||
|
"discord-rich-presence",
|
||||||
"hardware-id",
|
"hardware-id",
|
||||||
"md5",
|
"md5",
|
||||||
|
"once_cell",
|
||||||
"open",
|
"open",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -1100,6 +1116,7 @@ dependencies = [
|
|||||||
"tauri-plugin-single-instance",
|
"tauri-plugin-single-instance",
|
||||||
"tauri-plugin-sql",
|
"tauri-plugin-sql",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"widestring",
|
||||||
"winapi",
|
"winapi",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.60.2",
|
||||||
"winreg 0.55.0",
|
"winreg 0.55.0",
|
||||||
@@ -3802,7 +3819,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid 1.17.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4737,7 +4754,7 @@ dependencies = [
|
|||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
"time",
|
"time",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid 1.17.0",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4968,7 +4985,7 @@ dependencies = [
|
|||||||
"toml",
|
"toml",
|
||||||
"url",
|
"url",
|
||||||
"urlpattern",
|
"urlpattern",
|
||||||
"uuid",
|
"uuid 1.17.0",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -5475,6 +5492,15 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.2.16",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.17.0"
|
version = "1.17.0"
|
||||||
@@ -5774,6 +5800,12 @@ dependencies = [
|
|||||||
"wasite",
|
"wasite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "widestring"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ezpplauncher"
|
name = "ezpplauncher"
|
||||||
version = "3.0.0-beta.1"
|
version = "3.0.1"
|
||||||
description = "EZPPLauncher redefined."
|
description = "EZPPLauncher redefined."
|
||||||
authors = ["HorizonCode"]
|
authors = ["HorizonCode"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
@@ -34,10 +34,14 @@ md5 = "0.8.0"
|
|||||||
tokio = { version = "1.46.1", features = ["full"] }
|
tokio = { version = "1.46.1", features = ["full"] }
|
||||||
open = "5.3.2"
|
open = "5.3.2"
|
||||||
windows-sys = "0.60.2"
|
windows-sys = "0.60.2"
|
||||||
|
discord-rich-presence = "0.2.5"
|
||||||
|
once_cell = "1.21.3"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winreg = "0.55.0"
|
winreg = "0.55.0"
|
||||||
winapi = { version = "0.3", features = ["winuser"] }
|
winapi = { version = "0.3", features = ["winuser", "wincrypt", "memoryapi", "winbase", "dpapi"] }
|
||||||
|
base64 = "0.21"
|
||||||
|
widestring = "1.0"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
tauri-plugin-single-instance = "2.3.0"
|
tauri-plugin-single-instance = "2.3.0"
|
||||||
|
@@ -11,8 +11,10 @@ use tokio::io::AsyncWriteExt;
|
|||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio::time::{Duration, sleep};
|
use tokio::time::{Duration, sleep};
|
||||||
|
|
||||||
|
use crate::presence;
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
check_folder_completeness, get_osu_config, get_osu_user_config, get_window_title_by_pid,
|
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,
|
||||||
set_osu_config_vals, set_osu_user_config_vals,
|
set_osu_config_vals, set_osu_user_config_vals,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -281,8 +283,6 @@ pub fn set_osu_config_values(
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
||||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -291,6 +291,7 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
|||||||
let mut updater_process = {
|
let mut updater_process = {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||||
Command::new(&osu_exe_path)
|
Command::new(&osu_exe_path)
|
||||||
.arg("-repair")
|
.arg("-repair")
|
||||||
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)
|
||||||
@@ -300,7 +301,7 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
|||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
Command::new(&osu_exe_path)
|
Command::new("osu-wine")
|
||||||
.arg("-repair")
|
.arg("-repair")
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||||
@@ -336,10 +337,8 @@ pub async fn run_osu_updater(folder: String) -> Result<(), String> {
|
|||||||
sleep(Duration::from_millis(500)).await;
|
sleep(Duration::from_millis(500)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for updater process to fully exit
|
|
||||||
let _ = updater_process.wait().await;
|
let _ = updater_process.wait().await;
|
||||||
|
|
||||||
// Clean up update-related files
|
|
||||||
let force_update_files = [".require_update", "help.txt", "_pending"];
|
let force_update_files = [".require_update", "help.txt", "_pending"];
|
||||||
for update_file_name in &force_update_files {
|
for update_file_name in &force_update_files {
|
||||||
let path = PathBuf::from(&folder).join(update_file_name);
|
let path = PathBuf::from(&folder).join(update_file_name);
|
||||||
@@ -371,8 +370,6 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
/* #[cfg(windows)]
|
/* #[cfg(windows)]
|
||||||
use std::os::windows::process::CommandExt; */
|
use std::os::windows::process::CommandExt; */
|
||||||
|
|
||||||
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
const DETACHED_PROCESS: u32 = 0x00000008;
|
const DETACHED_PROCESS: u32 = 0x00000008;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -381,6 +378,7 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
let mut game_process = {
|
let mut game_process = {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
let osu_exe_path = PathBuf::from(&folder).join("osu!.exe");
|
||||||
Command::new(&osu_exe_path)
|
Command::new(&osu_exe_path)
|
||||||
.arg("-devserver")
|
.arg("-devserver")
|
||||||
.arg("ez-pp.farm")
|
.arg("ez-pp.farm")
|
||||||
@@ -391,8 +389,8 @@ pub async fn run_osu(folder: String, patch: bool) -> Result<(), String> {
|
|||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
Command::new(&osu_exe_path)
|
Command::new("osu-wine")
|
||||||
.arg("-devserver")
|
.arg("--devserver")
|
||||||
.arg("ez-pp.farm")
|
.arg("ez-pp.farm")
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
.map_err(|e| format!("Failed to spawn updater: {}", e))?
|
||||||
@@ -415,13 +413,6 @@ 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(&patcher_exe_path)
|
|
||||||
.spawn()
|
|
||||||
.map_err(|e| format!("Failed to run patcher: {e}"))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,6 +434,7 @@ pub struct UpdateFile {
|
|||||||
pub async fn get_ezpp_launcher_update_files(
|
pub async fn get_ezpp_launcher_update_files(
|
||||||
folder: String,
|
folder: String,
|
||||||
update_url: String,
|
update_url: String,
|
||||||
|
update_stream: String,
|
||||||
) -> Result<(Vec<UpdateFile>, Vec<UpdateFile>), String> {
|
) -> Result<(Vec<UpdateFile>, Vec<UpdateFile>), String> {
|
||||||
let osu_path = PathBuf::from(folder);
|
let osu_path = PathBuf::from(folder);
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
@@ -450,6 +442,7 @@ pub async fn get_ezpp_launcher_update_files(
|
|||||||
let update_files = client
|
let update_files = client
|
||||||
.patch(update_url)
|
.patch(update_url)
|
||||||
.header("User-Agent", "EZPPLauncher")
|
.header("User-Agent", "EZPPLauncher")
|
||||||
|
.query(&[("stream", update_stream)])
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())?
|
.map_err(|e| e.to_string())?
|
||||||
@@ -542,7 +535,6 @@ pub async fn download_ezpp_launcher_update_files(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
// Emit progress to frontend
|
|
||||||
app.emit(
|
app.emit(
|
||||||
"download-progress",
|
"download-progress",
|
||||||
UpdateStatus {
|
UpdateStatus {
|
||||||
@@ -634,3 +626,114 @@ pub fn open_url_in_browser(url: String) -> Result<(), String> {
|
|||||||
pub fn exit(app: AppHandle) {
|
pub fn exit(app: AppHandle) {
|
||||||
app.exit(0x0100);
|
app.exit(0x0100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_platform() -> String {
|
||||||
|
std::env::consts::OS.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn check_for_corruption(folder: String) -> Result<bool, String> {
|
||||||
|
let osu_path = PathBuf::from(folder);
|
||||||
|
let osu_ui = osu_path.join("osu!ui.dll");
|
||||||
|
let osu_gameplay = osu_path.join("osu!gameplay.dll");
|
||||||
|
|
||||||
|
let osu_ui_bak = osu_path.join("osu!ui.dll.bak");
|
||||||
|
let osu_gameplay_bak = osu_path.join("osu!gameplay.dll.bak");
|
||||||
|
|
||||||
|
let required_files = [&osu_ui, &osu_gameplay];
|
||||||
|
|
||||||
|
for file in &required_files {
|
||||||
|
if !file.exists() {
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let bak_files = [&osu_ui_bak, &osu_gameplay_bak];
|
||||||
|
for bak in &bak_files {
|
||||||
|
if bak.exists() {
|
||||||
|
if let Err(e) = fs::remove_file(bak).await {
|
||||||
|
return Err(format!("Failed to delete {}: {}", bak.display(), e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn presence_connect() -> bool {
|
||||||
|
presence::connect().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn presence_disconnect() {
|
||||||
|
presence::disconnect().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PresenceStatus {
|
||||||
|
state: Option<String>,
|
||||||
|
details: Option<String>,
|
||||||
|
large_image_key: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn presence_update_status(status: PresenceStatus) {
|
||||||
|
presence::update_status(
|
||||||
|
status.state.as_deref(),
|
||||||
|
status.details.as_deref(),
|
||||||
|
status.large_image_key.as_deref(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PresenceUser {
|
||||||
|
username: Option<String>,
|
||||||
|
id: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn presence_update_user(user: PresenceUser) {
|
||||||
|
presence::update_user(user.username.as_deref(), user.id.as_deref());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn presence_is_connected() -> bool {
|
||||||
|
presence::has_presence().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn has_wmctrl() -> bool {
|
||||||
|
is_wmctrl_available()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn has_osuwinello() -> bool {
|
||||||
|
is_osuwinello_available()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn has_net8() -> bool {
|
||||||
|
is_net8_installed().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn encrypt_string(string: String, entropy: String) -> String {
|
||||||
|
let encrypted = encrypt_password(&string, &entropy);
|
||||||
|
|
||||||
|
match encrypted {
|
||||||
|
Ok(encrypted_vec) => encrypted_vec,
|
||||||
|
Err(_) => string,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: should not be called by tauri on non windows systems, return the string nonthenless
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn encrypt_string(string: String, _entropy: String) -> String {
|
||||||
|
string
|
||||||
|
}
|
||||||
|
@@ -2,30 +2,35 @@
|
|||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
pub mod presence;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
download_ezpp_launcher_update_files, exit, find_osu_installation, get_beatmapsets_count,
|
check_for_corruption, download_ezpp_launcher_update_files, encrypt_string, exit,
|
||||||
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
|
find_osu_installation, get_beatmapsets_count, get_ezpp_launcher_update_files, get_hwid,
|
||||||
get_osu_skin, get_osu_version, get_skins_count, is_osu_running, open_url_in_browser,
|
get_launcher_version, get_osu_release_stream, get_osu_skin, get_osu_version, get_platform,
|
||||||
replace_ui_files, run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values,
|
get_skins_count, has_net8, has_osuwinello, has_wmctrl, is_osu_running, open_url_in_browser,
|
||||||
valid_osu_folder,
|
presence_connect, presence_disconnect, presence_is_connected, presence_update_status,
|
||||||
|
presence_update_user, replace_ui_files, run_osu, run_osu_updater, set_osu_config_values,
|
||||||
|
set_osu_user_config_values, valid_osu_folder,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
unsafe {
|
||||||
|
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_always_on_top(true)
|
|
||||||
.expect("failed to set always on top");
|
|
||||||
app_window.set_focus().expect("failed to focus");
|
app_window.set_focus().expect("failed to focus");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
builder
|
let app = builder
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
get_hwid,
|
get_hwid,
|
||||||
find_osu_installation,
|
find_osu_installation,
|
||||||
@@ -45,13 +50,33 @@ pub fn run() {
|
|||||||
is_osu_running,
|
is_osu_running,
|
||||||
open_url_in_browser,
|
open_url_in_browser,
|
||||||
get_launcher_version,
|
get_launcher_version,
|
||||||
exit
|
exit,
|
||||||
|
get_platform,
|
||||||
|
check_for_corruption,
|
||||||
|
presence_connect,
|
||||||
|
presence_disconnect,
|
||||||
|
presence_update_status,
|
||||||
|
presence_update_user,
|
||||||
|
presence_is_connected,
|
||||||
|
has_osuwinello,
|
||||||
|
has_wmctrl,
|
||||||
|
has_net8,
|
||||||
|
encrypt_string
|
||||||
])
|
])
|
||||||
.plugin(tauri_plugin_fs::init())
|
.plugin(tauri_plugin_fs::init())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_cors_fetch::init())
|
.plugin(tauri_plugin_cors_fetch::init())
|
||||||
.plugin(tauri_plugin_sql::Builder::default().build())
|
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||||
.run(tauri::generate_context!())
|
.build(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while building tauri application");
|
||||||
|
|
||||||
|
app.run(|_app_handle, event| {
|
||||||
|
if let tauri::RunEvent::ExitRequested { api, .. } = event {
|
||||||
|
api.prevent_exit();
|
||||||
|
|
||||||
|
tauri::async_runtime::block_on(presence::disconnect());
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
231
src-tauri/src/presence.rs
Normal file
231
src-tauri/src/presence.rs
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
use discord_rich_presence::{
|
||||||
|
activity::{Activity, Assets, Button, Timestamps},
|
||||||
|
DiscordIpc, DiscordIpcClient,
|
||||||
|
};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use std::sync::Mutex as StdMutex;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
use tokio::time::{interval, Duration};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct PresenceData {
|
||||||
|
pub state: String,
|
||||||
|
pub details: String,
|
||||||
|
pub large_image_key: String,
|
||||||
|
pub large_image_text: String,
|
||||||
|
pub small_image_key: Option<String>,
|
||||||
|
pub small_image_text: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum PresenceCommand {
|
||||||
|
Connect(oneshot::Sender<bool>),
|
||||||
|
Disconnect(oneshot::Sender<()>),
|
||||||
|
UpdateData(PresenceData),
|
||||||
|
IsConnected(oneshot::Sender<bool>),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PresenceActor {
|
||||||
|
receiver: mpsc::Receiver<PresenceCommand>,
|
||||||
|
client: Option<DiscordIpcClient>,
|
||||||
|
data: PresenceData,
|
||||||
|
start_timestamp: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PresenceActor {
|
||||||
|
fn new(receiver: mpsc::Receiver<PresenceCommand>) -> Self {
|
||||||
|
let start = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_secs() as i64;
|
||||||
|
|
||||||
|
let data = PresenceData {
|
||||||
|
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 {
|
||||||
|
receiver,
|
||||||
|
client: None,
|
||||||
|
data,
|
||||||
|
start_timestamp: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run(&mut self) {
|
||||||
|
let mut update_interval = interval(Duration::from_millis(2500));
|
||||||
|
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
Some(cmd) = self.receiver.recv() => {
|
||||||
|
match cmd {
|
||||||
|
PresenceCommand::Connect(responder) => self.handle_connect(responder).await,
|
||||||
|
PresenceCommand::Disconnect(responder) => {
|
||||||
|
self.handle_disconnect(responder).await;
|
||||||
|
},
|
||||||
|
PresenceCommand::UpdateData(new_data) => {
|
||||||
|
self.data = new_data;
|
||||||
|
},
|
||||||
|
PresenceCommand::IsConnected(responder) => {
|
||||||
|
let _ = responder.send(self.client.is_some());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = update_interval.tick() => {
|
||||||
|
if self.client.is_some() {
|
||||||
|
self.handle_update().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_connect(&mut self, responder: oneshot::Sender<bool>) {
|
||||||
|
if self.client.is_some() {
|
||||||
|
let _ = responder.send(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Actor: Connecting to Discord...");
|
||||||
|
match DiscordIpcClient::new("1032772293220384808").map_err(|e| e.to_string()) {
|
||||||
|
Ok(mut new_client) => {
|
||||||
|
if let Err(e) = new_client.connect().map_err(|e| e.to_string()) {
|
||||||
|
eprintln!("Failed to connect to Discord: {:?}", e);
|
||||||
|
let _ = responder.send(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.client = Some(new_client);
|
||||||
|
println!("Actor: Connected successfully.");
|
||||||
|
self.handle_update().await;
|
||||||
|
let _ = responder.send(true);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to create Discord client: {:?}", e);
|
||||||
|
let _ = responder.send(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_disconnect(&mut self, responder: oneshot::Sender<()>) {
|
||||||
|
if let Some(mut client) = self.client.take() {
|
||||||
|
println!("Actor: Disconnecting...");
|
||||||
|
let _ = client.clear_activity().map_err(|e| e.to_string());
|
||||||
|
let _ = client.close().map_err(|e| e.to_string());
|
||||||
|
println!("Actor: Disconnected successfully.");
|
||||||
|
}
|
||||||
|
let _ = responder.send(());
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_update(&mut self) {
|
||||||
|
if let Some(client) = self.client.as_mut() {
|
||||||
|
let mut assets = Assets::new()
|
||||||
|
.large_image(&self.data.large_image_key)
|
||||||
|
.large_text(&self.data.large_image_text);
|
||||||
|
|
||||||
|
if let Some(key) = &self.data.small_image_key {
|
||||||
|
assets = assets.small_image(key);
|
||||||
|
}
|
||||||
|
if let Some(text) = &self.data.small_image_text {
|
||||||
|
assets = assets.small_text(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
let activity = Activity::new()
|
||||||
|
.state(&self.data.state)
|
||||||
|
.details(&self.data.details)
|
||||||
|
.timestamps(Timestamps::new().start(self.start_timestamp))
|
||||||
|
.assets(assets)
|
||||||
|
.buttons(vec![
|
||||||
|
Button::new(
|
||||||
|
"Download the Launcher",
|
||||||
|
"https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest",
|
||||||
|
),
|
||||||
|
Button::new("Join EZPZFarm", "https://ez-pp.farm/discord"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if let Err(e) = client.set_activity(activity).map_err(|e| e.to_string()) {
|
||||||
|
eprintln!("Failed to set activity, disconnecting: {:?}", e);
|
||||||
|
if let Some(mut client) = self.client.take() {
|
||||||
|
let _ = client.clear_activity();
|
||||||
|
let _ = client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static PRESENCE_TX: Lazy<mpsc::Sender<PresenceCommand>> = Lazy::new(|| {
|
||||||
|
let (tx, rx) = mpsc::channel(10);
|
||||||
|
let mut actor = PresenceActor::new(rx);
|
||||||
|
tokio::spawn(async move { actor.run().await });
|
||||||
|
tx
|
||||||
|
});
|
||||||
|
|
||||||
|
pub static PRESENCE_DATA: Lazy<StdMutex<PresenceData>> = Lazy::new(|| {
|
||||||
|
StdMutex::new(PresenceData {
|
||||||
|
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 {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
if PRESENCE_TX.send(PresenceCommand::Connect(tx)).await.is_ok() {
|
||||||
|
return rx.await.unwrap_or(false);
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn disconnect() {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
if PRESENCE_TX.send(PresenceCommand::Disconnect(tx)).await.is_ok() {
|
||||||
|
let _ = rx.await;
|
||||||
|
} else {
|
||||||
|
println!("Could not send disconnect command; actor may not be running.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn has_presence() -> bool {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
if PRESENCE_TX.send(PresenceCommand::IsConnected(tx)).await.is_ok() {
|
||||||
|
return rx.await.unwrap_or(false);
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_status(state: Option<&str>, details: Option<&str>, large_image_key: Option<&str>) {
|
||||||
|
let mut data = PRESENCE_DATA.lock().unwrap();
|
||||||
|
if let Some(s) = state {
|
||||||
|
data.state = s.to_string();
|
||||||
|
}
|
||||||
|
if let Some(d) = details {
|
||||||
|
data.details = d.to_string();
|
||||||
|
}
|
||||||
|
if let Some(img) = large_image_key {
|
||||||
|
data.large_image_key = img.to_string();
|
||||||
|
}
|
||||||
|
let data_clone = data.clone();
|
||||||
|
let tx = PRESENCE_TX.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(PresenceCommand::UpdateData(data_clone)).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_user(username: Option<&str>, id: Option<&str>) {
|
||||||
|
let mut data = PRESENCE_DATA.lock().unwrap();
|
||||||
|
data.small_image_key = id.map(|id_str| format!("https://a.ez-pp.farm/{}", id_str));
|
||||||
|
data.small_image_text = username.map(|s| s.to_string());
|
||||||
|
let data_clone = data.clone();
|
||||||
|
let tx = PRESENCE_TX.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let _ = tx.send(PresenceCommand::UpdateData(data_clone)).await;
|
||||||
|
});
|
||||||
|
}
|
@@ -71,7 +71,6 @@ pub fn set_osu_user_config_vals(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect indices and keys to update to avoid borrow checker issues
|
|
||||||
let mut updates = Vec::new();
|
let mut updates = Vec::new();
|
||||||
for (i, line) in lines.iter().enumerate() {
|
for (i, line) in lines.iter().enumerate() {
|
||||||
if let Some((existing_key, _)) = line.split_once(" = ") {
|
if let Some((existing_key, _)) = line.split_once(" = ") {
|
||||||
@@ -86,7 +85,6 @@ pub fn set_osu_user_config_vals(
|
|||||||
keys_to_add.remove(trimmed_key.as_str());
|
keys_to_add.remove(trimmed_key.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new keys that were not found
|
|
||||||
for key in keys_to_add {
|
for key in keys_to_add {
|
||||||
if let Some(value) = keys_to_set.get(key) {
|
if let Some(value) = keys_to_set.get(key) {
|
||||||
lines.push(format!("{} = {}", key, value));
|
lines.push(format!("{} = {}", key, value));
|
||||||
@@ -139,7 +137,6 @@ pub fn set_osu_config_vals(
|
|||||||
keys_to_add.remove(trimmed_key.as_str());
|
keys_to_add.remove(trimmed_key.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new keys that were not found
|
|
||||||
for key in keys_to_add {
|
for key in keys_to_add {
|
||||||
if let Some(value) = keys_to_set.get(key) {
|
if let Some(value) = keys_to_set.get(key) {
|
||||||
lines.push(format!("{} = {}", key, value));
|
lines.push(format!("{} = {}", key, value));
|
||||||
@@ -177,19 +174,78 @@ pub fn get_osu_config<P: AsRef<Path>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub fn get_window_title_by_pid(_pid: Pid) -> String {
|
pub fn is_osuwinello_available() -> bool {
|
||||||
"".to_string()
|
use std::process::Command;
|
||||||
|
Command::new("osu-wine")
|
||||||
|
.arg("--info")
|
||||||
|
.stdout(std::process::Stdio::null())
|
||||||
|
.stderr(std::process::Stdio::null())
|
||||||
|
.status()
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn is_osuwinello_available() -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
pub fn is_wmctrl_available() -> bool {
|
||||||
|
use std::process::Command;
|
||||||
|
Command::new("wmctrl")
|
||||||
|
.arg("-V")
|
||||||
|
.stdout(std::process::Stdio::null())
|
||||||
|
.stderr(std::process::Stdio::null())
|
||||||
|
.status()
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn is_wmctrl_available() -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
pub fn get_window_title_by_pid(target_pid: Pid) -> String {
|
||||||
|
use std::process::Command;
|
||||||
|
let find_title = || -> Option<String> {
|
||||||
|
let output = Command::new("wmctrl").arg("-lp").output().ok()?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let output_str = String::from_utf8(output.stdout).ok()?;
|
||||||
|
|
||||||
|
for line in output_str.lines() {
|
||||||
|
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||||
|
if parts.len() < 4 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(pid) = parts[2].parse::<u32>() {
|
||||||
|
if pid == target_pid.as_u32() {
|
||||||
|
let title = parts[4..].join(" ");
|
||||||
|
return Some(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
find_title().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn get_window_title_by_pid(pid: Pid) -> String {
|
pub fn get_window_title_by_pid(pid: Pid) -> String {
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::os::windows::ffi::OsStringExt;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use winapi::shared::windef::HWND;
|
use winapi::shared::windef::HWND;
|
||||||
use winapi::um::winuser::{
|
use winapi::um::winuser::{
|
||||||
EnumWindows, GetWindowTextW, GetWindowThreadProcessId, IsWindowVisible,
|
EnumWindows, GetWindowTextW, GetWindowThreadProcessId, IsWindowVisible,
|
||||||
};
|
};
|
||||||
use std::ffi::OsString;
|
|
||||||
use std::os::windows::ffi::OsStringExt;
|
|
||||||
|
|
||||||
extern "system" fn enum_windows_proc(
|
extern "system" fn enum_windows_proc(
|
||||||
hwnd: HWND,
|
hwnd: HWND,
|
||||||
@@ -210,11 +266,11 @@ pub fn get_window_title_by_pid(pid: Pid) -> String {
|
|||||||
let title_str = title.to_string_lossy().into_owned();
|
let title_str = title.to_string_lossy().into_owned();
|
||||||
if !title_str.is_empty() {
|
if !title_str.is_empty() {
|
||||||
*result.lock().unwrap() = Some(title_str);
|
*result.lock().unwrap() = Some(title_str);
|
||||||
return 0; // Stop enumeration
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1 // Continue enumeration
|
1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,3 +284,92 @@ pub fn get_window_title_by_pid(pid: Pid) -> String {
|
|||||||
}
|
}
|
||||||
result.lock().unwrap().clone().unwrap_or_default()
|
result.lock().unwrap().clone().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn is_net8_installed() -> bool {
|
||||||
|
use std::process::Command;
|
||||||
|
let output_result = Command::new("dotnet").arg("--list-runtimes").output();
|
||||||
|
match output_result {
|
||||||
|
Ok(output) => {
|
||||||
|
if !output.status.success() {
|
||||||
|
eprintln!(
|
||||||
|
"Error: `dotnet --list-runtimes` failed with status: {}",
|
||||||
|
output.status
|
||||||
|
);
|
||||||
|
eprintln!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let stdout_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
stdout_str
|
||||||
|
.lines()
|
||||||
|
.any(|line| line.starts_with("Microsoft.WindowsDesktop.App 8."))
|
||||||
|
}
|
||||||
|
Err(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn encrypt_password(password: &str, entropy: &str) -> Result<String, String> {
|
||||||
|
use base64::{Engine as _, engine::general_purpose};
|
||||||
|
use std::ffi::OsStr;
|
||||||
|
use std::os::windows::ffi::OsStrExt;
|
||||||
|
use std::ptr;
|
||||||
|
use std::slice;
|
||||||
|
use winapi::shared::minwindef::{BYTE, DWORD, LPVOID};
|
||||||
|
use winapi::shared::ntdef::LPCWSTR;
|
||||||
|
use winapi::um::dpapi::{CRYPTPROTECT_UI_FORBIDDEN, CryptProtectData};
|
||||||
|
use winapi::um::winbase::LocalFree;
|
||||||
|
use winapi::um::wincrypt::DATA_BLOB;
|
||||||
|
|
||||||
|
let description = "Encrypted";
|
||||||
|
|
||||||
|
let password_bytes = password.as_bytes();
|
||||||
|
let mut input_blob = DATA_BLOB {
|
||||||
|
cbData: password_bytes.len() as DWORD,
|
||||||
|
pbData: password_bytes.as_ptr() as *mut BYTE,
|
||||||
|
};
|
||||||
|
|
||||||
|
let entropy_bytes = entropy.as_bytes();
|
||||||
|
let mut entropy_blob = DATA_BLOB {
|
||||||
|
cbData: entropy_bytes.len() as DWORD,
|
||||||
|
pbData: entropy_bytes.as_ptr() as *mut BYTE,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut output_blob = DATA_BLOB {
|
||||||
|
cbData: 0,
|
||||||
|
pbData: ptr::null_mut(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let wide_description: Vec<u16> = OsStrExt::encode_wide(OsStr::new(description))
|
||||||
|
.chain(Some(0))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let p_description: LPCWSTR = wide_description.as_ptr();
|
||||||
|
|
||||||
|
let result = unsafe {
|
||||||
|
CryptProtectData(
|
||||||
|
&mut input_blob,
|
||||||
|
p_description,
|
||||||
|
&mut entropy_blob,
|
||||||
|
ptr::null_mut(),
|
||||||
|
ptr::null_mut(),
|
||||||
|
CRYPTPROTECT_UI_FORBIDDEN,
|
||||||
|
&mut output_blob,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if result == 0 {
|
||||||
|
return Err("CryptProtectData failed".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
let encrypted_data =
|
||||||
|
unsafe { slice::from_raw_parts(output_blob.pbData, output_blob.cbData as usize).to_vec() };
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
LocalFree(output_blob.pbData as LPVOID);
|
||||||
|
}
|
||||||
|
|
||||||
|
let base64_string = general_purpose::STANDARD.encode(&encrypted_data);
|
||||||
|
|
||||||
|
Ok(base64_string)
|
||||||
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "ezpplauncher",
|
"productName": "ezpplauncher",
|
||||||
"version": "3.0.0-beta.1",
|
"version": "3.0.1",
|
||||||
"identifier": "farm.ezpp.launcher",
|
"identifier": "farm.ezpp.launcher",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "bun run vite:dev",
|
"beforeDevCommand": "bun run vite:dev",
|
||||||
|
10
src/app.css
10
src/app.css
@@ -150,8 +150,18 @@
|
|||||||
@layer base {
|
@layer base {
|
||||||
* {
|
* {
|
||||||
@apply border-border outline-ring/50;
|
@apply border-border outline-ring/50;
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-khtml-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
|
button:not([disabled]),
|
||||||
|
[role="button"]:not([disabled]) {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
import type { EZPPUser, EZPPUserInfoResponse, EZPPUserResponse } from '@/types';
|
import type {
|
||||||
|
EZPPUser,
|
||||||
|
EZPPUserInfoResponse,
|
||||||
|
EZPPUserResponse,
|
||||||
|
EZPPUSerStatusResponse,
|
||||||
|
} from '@/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/';
|
||||||
@@ -54,12 +59,12 @@ export const ezppfarm = {
|
|||||||
}
|
}
|
||||||
return request.data;
|
return request.data;
|
||||||
},
|
},
|
||||||
getUserInfo: async (userId: number) => {
|
getUserInfo: async (userId: number, scope: 'all' | 'info' | 'stats' = 'all') => {
|
||||||
const request = await betterFetch<EZPPUserInfoResponse>(`${API_ENDPOINT}v1/get_player_info`, {
|
const request = await betterFetch<EZPPUserInfoResponse>(`${API_ENDPOINT}v1/get_player_info`, {
|
||||||
timeout,
|
timeout,
|
||||||
query: {
|
query: {
|
||||||
id: userId,
|
id: userId,
|
||||||
scope: 'all',
|
scope,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -68,4 +73,20 @@ export const ezppfarm = {
|
|||||||
});
|
});
|
||||||
return request.error ? undefined : request.data;
|
return request.error ? undefined : request.data;
|
||||||
},
|
},
|
||||||
|
getUserStatus: async (userId: number) => {
|
||||||
|
const request = await betterFetch<EZPPUSerStatusResponse>(
|
||||||
|
`${API_ENDPOINT}v1/get_player_status`,
|
||||||
|
{
|
||||||
|
timeout,
|
||||||
|
query: {
|
||||||
|
id: userId,
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': 'EZPPLauncher',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return request.error ? undefined : request.data;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@@ -20,10 +20,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div data-tauri-drag-region class="titlebar z-[60] border-b border-theme-800/90">
|
<div data-tauri-drag-region class="titlebar z-[60] border-b border-theme-800/90">
|
||||||
<div class="mr-auto ms-2 flex flex-row gap-2 items-center text-[1.05rem] font-semibold pointer-events-none">
|
<div
|
||||||
|
class="mr-auto ms-2 flex flex-row gap-2 items-center text-[1.05rem] font-semibold pointer-events-none"
|
||||||
|
>
|
||||||
<img src={Logo} alt="EZPP Launcher Logo" class="h-11 w-11 inline-block" />
|
<img src={Logo} alt="EZPP Launcher Logo" class="h-11 w-11 inline-block" />
|
||||||
<span>EZPPLauncher</span>
|
<span>EZPPLauncher</span>
|
||||||
<Badge class="!text-[0.6rem] py-[0.5px] bg-primary-500 hover:bg-primary-500">{$launcherVersion}</Badge>
|
<Badge class="!text-[0.6rem] py-[0.5px] bg-primary-500 hover:bg-primary-500"
|
||||||
|
>{$launcherVersion}</Badge
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="titlebar-button rounded-lg transition-colors duration-75" id="titlebar-minimize">
|
<div class="titlebar-button rounded-lg transition-colors duration-75" id="titlebar-minimize">
|
||||||
<Minimize size={18} />
|
<Minimize size={18} />
|
||||||
|
@@ -1,14 +1,22 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import { ezppfarm } from './api/ezpp';
|
import { ezppfarm } from './api/ezpp';
|
||||||
import type { Component } from 'svelte';
|
import type { Component } from 'svelte';
|
||||||
import Loading from '../pages/Loading.svelte';
|
import Loading from '../screens/Loading.svelte';
|
||||||
import type { Release } from './types';
|
import type { Release } from './types';
|
||||||
|
|
||||||
export const currentView = writable<Component>(Loading);
|
export const currentView = writable<Component>(Loading);
|
||||||
|
|
||||||
|
export const platform = writable<string>('');
|
||||||
|
|
||||||
export const launcherVersion = writable<string>('');
|
export const launcherVersion = writable<string>('');
|
||||||
export const newVersion = writable<Release | undefined>(undefined);
|
export const newVersion = writable<Release | undefined>(undefined);
|
||||||
|
|
||||||
|
export const launcherStreams = writable<string[]>(['stable']);
|
||||||
|
export const launcherStream = writable<string>('stable');
|
||||||
|
|
||||||
|
export const discordPresence = writable<boolean>(false);
|
||||||
|
export const presenceLoading = writable<boolean>(false);
|
||||||
|
|
||||||
export const currentLoadingInfo = writable<string>('Initializing...');
|
export const currentLoadingInfo = writable<string>('Initializing...');
|
||||||
|
|
||||||
export const firstStartup = writable<boolean>(false);
|
export const firstStartup = writable<boolean>(false);
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core';
|
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 { listen } from '@tauri-apps/api/event';
|
||||||
|
import { betterFetch } from '@better-fetch/fetch';
|
||||||
|
|
||||||
const updateUrl = 'https://ez-pp.farm/ezpplauncher';
|
const updateUrl = 'https://next.ez-pp.farm/api/ezpplauncher';
|
||||||
|
|
||||||
export const getHWID = async () => {
|
export const getHWID = async () => {
|
||||||
const hwid = await invoke('get_hwid');
|
const hwid = await invoke('get_hwid');
|
||||||
@@ -73,8 +74,24 @@ export const runUpdater = async (folder: string) => await invoke('run_osu_update
|
|||||||
export const runOsu = async (folder: string, patch: boolean) =>
|
export const runOsu = async (folder: string, patch: boolean) =>
|
||||||
await invoke('run_osu', { folder, patch });
|
await invoke('run_osu', { folder, patch });
|
||||||
|
|
||||||
export const getEZPPLauncherUpdateFiles = async (folder: string) => {
|
export const getEZPPLauncherStreams = async () => {
|
||||||
const result = await invoke('get_ezpp_launcher_update_files', { folder, updateUrl });
|
const resp = await betterFetch<{ streams: string[] }>(updateUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resp.error) {
|
||||||
|
return resp.data.streams;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEZPPLauncherUpdateFiles = async (folder: string, updateStream: string) => {
|
||||||
|
const result = await invoke('get_ezpp_launcher_update_files', {
|
||||||
|
folder,
|
||||||
|
updateUrl,
|
||||||
|
updateStream,
|
||||||
|
});
|
||||||
if (typeof result === 'object') {
|
if (typeof result === 'object') {
|
||||||
const [filesToDownload, updateFiles] = result as [UpdateFile[], UpdateFile[]];
|
const [filesToDownload, updateFiles] = result as [UpdateFile[], UpdateFile[]];
|
||||||
return {
|
return {
|
||||||
@@ -113,3 +130,11 @@ export const isOsuRunning = async () => {
|
|||||||
|
|
||||||
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 isOsuCorrupted = async (folder: string) =>
|
||||||
|
await invoke<boolean>('check_for_corruption', { folder });
|
||||||
|
export const hasWMCTRL = async () => await invoke<boolean>('has_wmctrl');
|
||||||
|
export const hasOsuWinello = async () => await invoke<boolean>('has_osuwinello');
|
||||||
|
export const hasNet8 = async () => await invoke<boolean>('has_net8');
|
||||||
|
export const encryptString = async (str: string, entropy: string) =>
|
||||||
|
await invoke<string>('encrypt_string', { string: str, entropy });
|
||||||
|
19
src/lib/presence.ts
Normal file
19
src/lib/presence.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
|
||||||
|
export const connect = async () => await invoke('presence_connect');
|
||||||
|
export const disconnect = async () => await invoke('presence_disconnect');
|
||||||
|
export const updateStatus = async (status: {
|
||||||
|
state: string;
|
||||||
|
details: string;
|
||||||
|
largeImageKey?: string;
|
||||||
|
}) =>
|
||||||
|
await invoke('presence_update_status', {
|
||||||
|
status: {
|
||||||
|
state: status.state,
|
||||||
|
details: status.details,
|
||||||
|
largeImageKey: status.largeImageKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
export const updateUser = async (user: { username: string; id?: string | null }) =>
|
||||||
|
await invoke('presence_update_user', { user: { username: user.username, id: user.id } });
|
||||||
|
export const isConnected = async () => await invoke<boolean>('presence_is_connected');
|
@@ -185,3 +185,65 @@ export type Release = {
|
|||||||
browser_download_url: string;
|
browser_download_url: string;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type EZPPUSerStatusResponse = EZPPUserOfflineStatus | EZPPUserOnlineStatus;
|
||||||
|
|
||||||
|
type EZPPUserOfflineStatus = {
|
||||||
|
status: string;
|
||||||
|
player_status: {
|
||||||
|
online: false;
|
||||||
|
last_seen: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
type EZPPUserOnlineStatus = {
|
||||||
|
status: string;
|
||||||
|
player_status: {
|
||||||
|
online: true;
|
||||||
|
login_time: number;
|
||||||
|
status: {
|
||||||
|
action: EZPPActionStatus;
|
||||||
|
info_text: string;
|
||||||
|
mode: number;
|
||||||
|
mods: number;
|
||||||
|
beatmap: EZPPUserBeatmapStatus | null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
type EZPPUserBeatmapStatus = {
|
||||||
|
md5: string;
|
||||||
|
id: number;
|
||||||
|
set_id: number;
|
||||||
|
artist: string;
|
||||||
|
title: string;
|
||||||
|
version: string;
|
||||||
|
creator: string;
|
||||||
|
last_update: string;
|
||||||
|
total_length: number;
|
||||||
|
max_combo: number;
|
||||||
|
status: number;
|
||||||
|
plays: number;
|
||||||
|
passes: number;
|
||||||
|
mode: number;
|
||||||
|
bpm: number;
|
||||||
|
cs: number;
|
||||||
|
od: number;
|
||||||
|
ar: number;
|
||||||
|
hp: number;
|
||||||
|
diff: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export enum EZPPActionStatus {
|
||||||
|
AFK = 1,
|
||||||
|
PLAYING = 2,
|
||||||
|
EDITING = 3,
|
||||||
|
MODDING = 4,
|
||||||
|
MULTIPLAYER_SELECT = 5,
|
||||||
|
WATCHING = 6,
|
||||||
|
TESTING = 8,
|
||||||
|
SUBMITTING = 9,
|
||||||
|
MULTIPLAYER_IDLE = 11,
|
||||||
|
MULTIPLAYER_PLAYING = 12,
|
||||||
|
DIRECT = 13,
|
||||||
|
}
|
||||||
|
@@ -89,3 +89,14 @@ export const formatBytes = (bytes: number, decimals = 2) => {
|
|||||||
export const openURL = async (url: string) => {
|
export const openURL = async (url: string) => {
|
||||||
await invoke('open_url_in_browser', { url });
|
await invoke('open_url_in_browser', { url });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const urlIsValidImage = async (url: string) => {
|
||||||
|
try {
|
||||||
|
const request = await fetch(url);
|
||||||
|
if (!request.ok) return false;
|
||||||
|
const contentType = request.headers.get('content-type');
|
||||||
|
return contentType?.startsWith('image/');
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@@ -1,8 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Logo from '$assets/logo.png';
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
|
|
||||||
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
||||||
import { currentLoadingInfo, firstStartup, launcherVersion, setupValues } from '@/global';
|
import * as AlertDialog from '@/components/ui/alert-dialog';
|
||||||
|
import {
|
||||||
|
currentLoadingInfo,
|
||||||
|
discordPresence,
|
||||||
|
firstStartup,
|
||||||
|
launcherVersion,
|
||||||
|
platform,
|
||||||
|
presenceLoading,
|
||||||
|
setupValues,
|
||||||
|
} from '@/global';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
|
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
|
||||||
import {
|
import {
|
||||||
@@ -16,13 +26,17 @@
|
|||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
import { Toaster } from '@/components/ui/sonner';
|
import { Toaster } from '@/components/ui/sonner';
|
||||||
import { userAuth } from '@/userAuthentication';
|
import { userAuth } from '@/userAuthentication';
|
||||||
import { getLauncherVersion } from '@/osuUtil';
|
import { encryptString, exit, getLauncherVersion, getPlatform } from '@/osuUtil';
|
||||||
|
import Button from '@/components/ui/button/button.svelte';
|
||||||
|
import * as presence from '@/presence';
|
||||||
|
|
||||||
import '@fontsource/sora';
|
import '@fontsource/sora';
|
||||||
import '@fontsource/space-mono';
|
import '@fontsource/space-mono';
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
|
let unsupported_platform = $state<boolean>(false);
|
||||||
|
|
||||||
function disableReload() {
|
function disableReload() {
|
||||||
if (window.location.hostname !== 'tauri.localhost') {
|
if (window.location.hostname !== 'tauri.localhost') {
|
||||||
return;
|
return;
|
||||||
@@ -77,6 +91,8 @@
|
|||||||
disableReload();
|
disableReload();
|
||||||
setupValues();
|
setupValues();
|
||||||
launcherVersion.set(await getLauncherVersion());
|
launcherVersion.set(await getLauncherVersion());
|
||||||
|
platform.set(await getPlatform());
|
||||||
|
if ($platform !== 'windows' && $platform !== 'linux') unsupported_platform = true;
|
||||||
const isFirstStartup = await $userSettings.init();
|
const isFirstStartup = await $userSettings.init();
|
||||||
$userAuth.init();
|
$userAuth.init();
|
||||||
|
|
||||||
@@ -86,17 +102,40 @@
|
|||||||
const config_cursor_smoothening = $userSettings.value('cursor_smoothening');
|
const config_cursor_smoothening = $userSettings.value('cursor_smoothening');
|
||||||
const config_reduce_animations = $userSettings.value('reduce_animations');
|
const config_reduce_animations = $userSettings.value('reduce_animations');
|
||||||
const config_osu_installation_path = $userSettings.value('osu_installation_path');
|
const config_osu_installation_path = $userSettings.value('osu_installation_path');
|
||||||
|
const config_discord_presence = $userSettings.value('discord_presence');
|
||||||
|
|
||||||
patch.set(config_patching.get(true));
|
patch.set(config_patching.get(true));
|
||||||
customCursor.set(config_custom_cursor.get(true));
|
customCursor.set(config_custom_cursor.get(true));
|
||||||
cursorSmoothening.set(config_cursor_smoothening.get(true));
|
cursorSmoothening.set(config_cursor_smoothening.get(true));
|
||||||
reduceAnimations.set(config_reduce_animations.get(false));
|
reduceAnimations.set(config_reduce_animations.get(false));
|
||||||
osuInstallationPath.set(config_osu_installation_path.get(''));
|
osuInstallationPath.set(config_osu_installation_path.get(''));
|
||||||
|
discordPresence.set(config_discord_presence.get(true));
|
||||||
|
|
||||||
patch.subscribe((val) => config_patching.set(val));
|
patch.subscribe((val) => config_patching.set(val));
|
||||||
customCursor.subscribe((val) => config_custom_cursor.set(val));
|
customCursor.subscribe((val) => config_custom_cursor.set(val));
|
||||||
cursorSmoothening.subscribe((val) => config_cursor_smoothening.set(val));
|
cursorSmoothening.subscribe((val) => config_cursor_smoothening.set(val));
|
||||||
reduceAnimations.subscribe((val) => config_reduce_animations.set(val));
|
reduceAnimations.subscribe((val) => config_reduce_animations.set(val));
|
||||||
|
discordPresence.subscribe(async (val) => {
|
||||||
|
config_discord_presence.set(val);
|
||||||
|
try {
|
||||||
|
presenceLoading.set(true);
|
||||||
|
if (val) {
|
||||||
|
await presence.connect();
|
||||||
|
} else {
|
||||||
|
await presence.disconnect();
|
||||||
|
}
|
||||||
|
presenceLoading.set(false);
|
||||||
|
} catch {}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($discordPresence) {
|
||||||
|
currentLoadingInfo.set('Connecting to Discord RPC...');
|
||||||
|
presenceLoading.set(true);
|
||||||
|
await presence.connect();
|
||||||
|
presenceLoading.set(false);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
firstStartup.set(isFirstStartup);
|
firstStartup.set(isFirstStartup);
|
||||||
});
|
});
|
||||||
@@ -110,6 +149,29 @@
|
|||||||
|
|
||||||
<Titlebar />
|
<Titlebar />
|
||||||
|
|
||||||
|
<AlertDialog.Root open={unsupported_platform}>
|
||||||
|
<AlertDialog.Content class="bg-theme-950 border-theme-800 p-0">
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
|
||||||
|
>
|
||||||
|
<img class="h-20 w-20" src={Logo} alt="logo" />
|
||||||
|
<span class="font-semibold text-xl">Unsupported Platform!</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center text-sm text-center bg-theme-900 border border-theme-800 rounded-lg mx-3 p-3"
|
||||||
|
>
|
||||||
|
This Platform is not supported by EZPPLauncher.
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-center mb-3">
|
||||||
|
<Button
|
||||||
|
onclick={async () => {
|
||||||
|
await exit();
|
||||||
|
}}>Close</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</AlertDialog.Content>
|
||||||
|
</AlertDialog.Root>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</main>
|
</main>
|
||||||
|
@@ -8,11 +8,16 @@
|
|||||||
beatmapSets,
|
beatmapSets,
|
||||||
currentSkin,
|
currentSkin,
|
||||||
currentView,
|
currentView,
|
||||||
|
discordPresence,
|
||||||
|
launcherStream,
|
||||||
|
launcherStreams,
|
||||||
launcherVersion,
|
launcherVersion,
|
||||||
launching,
|
launching,
|
||||||
newVersion,
|
newVersion,
|
||||||
osuBuild,
|
osuBuild,
|
||||||
osuStream,
|
osuStream,
|
||||||
|
platform,
|
||||||
|
presenceLoading,
|
||||||
serverConnectionFails,
|
serverConnectionFails,
|
||||||
serverPing,
|
serverPing,
|
||||||
skins,
|
skins,
|
||||||
@@ -46,6 +51,7 @@
|
|||||||
numberHumanReadable,
|
numberHumanReadable,
|
||||||
openURL,
|
openURL,
|
||||||
releaseStreamToReadable,
|
releaseStreamToReadable,
|
||||||
|
urlIsValidImage,
|
||||||
} from '@/utils';
|
} from '@/utils';
|
||||||
import { fade, scale } from 'svelte/transition';
|
import { fade, scale } from 'svelte/transition';
|
||||||
import { Checkbox } from '@/components/ui/checkbox';
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
@@ -77,6 +83,7 @@
|
|||||||
import { osuapi } from '@/api/osuapi';
|
import { osuapi } from '@/api/osuapi';
|
||||||
import {
|
import {
|
||||||
downloadEZPPLauncherUpdateFiles,
|
downloadEZPPLauncherUpdateFiles,
|
||||||
|
encryptString,
|
||||||
exit,
|
exit,
|
||||||
getBeatmapSetsCount,
|
getBeatmapSetsCount,
|
||||||
getEZPPLauncherUpdateFiles,
|
getEZPPLauncherUpdateFiles,
|
||||||
@@ -84,6 +91,10 @@
|
|||||||
getSkin,
|
getSkin,
|
||||||
getSkinsCount,
|
getSkinsCount,
|
||||||
getVersion,
|
getVersion,
|
||||||
|
hasNet8,
|
||||||
|
hasOsuWinello,
|
||||||
|
hasWMCTRL,
|
||||||
|
isOsuCorrupted,
|
||||||
isOsuRunning,
|
isOsuRunning,
|
||||||
isValidOsuFolder,
|
isValidOsuFolder,
|
||||||
replaceUIFiles,
|
replaceUIFiles,
|
||||||
@@ -95,10 +106,13 @@
|
|||||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||||
import { ezppfarm } from '@/api/ezpp';
|
import { ezppfarm } from '@/api/ezpp';
|
||||||
import Hearts from '@/components/ui/effects/Hearts.svelte';
|
import Hearts from '@/components/ui/effects/Hearts.svelte';
|
||||||
|
import { EZPPActionStatus } from '@/types';
|
||||||
|
import * as presence from '@/presence';
|
||||||
|
|
||||||
let selectedTab = $state('home');
|
let selectedTab = $state('home');
|
||||||
let progress = $state(-1);
|
let progress = $state(-1);
|
||||||
let launchInfo = $state('');
|
let launchInfo = $state('');
|
||||||
|
let launchError = $state<Error | undefined>(undefined);
|
||||||
|
|
||||||
let selectedGamemode = $derived(
|
let selectedGamemode = $derived(
|
||||||
getGamemodeInt(modeIntToStr($preferredMode), typeIntToStr($preferredType))
|
getGamemodeInt(modeIntToStr($preferredMode), typeIntToStr($preferredType))
|
||||||
@@ -177,9 +191,27 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($platform === 'linux') {
|
||||||
|
if (!(await hasWMCTRL())) {
|
||||||
|
toast.error('Hmmm...', {
|
||||||
|
description: 'wmctrl seems to be missing, please install via AUR.',
|
||||||
|
});
|
||||||
|
launching.set(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(await hasOsuWinello())) {
|
||||||
|
toast.error('Hmmm...', {
|
||||||
|
description: 'osu-winello seems to be missing, please install it.',
|
||||||
|
});
|
||||||
|
launching.set(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
launchInfo = 'Looking for EZPPLauncher File updates...';
|
launchInfo = 'Looking for EZPPLauncher File updates...';
|
||||||
const updateResult = await getEZPPLauncherUpdateFiles(osuPath);
|
const updateResult = await getEZPPLauncherUpdateFiles(osuPath, $launcherStream);
|
||||||
|
|
||||||
if (updateResult) {
|
if (updateResult) {
|
||||||
if (updateResult.filesToDownload.length > 0) {
|
if (updateResult.filesToDownload.length > 0) {
|
||||||
launchInfo = 'Found EZPPLauncher File updates!';
|
launchInfo = 'Found EZPPLauncher File updates!';
|
||||||
@@ -203,6 +235,9 @@
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
launchError = err as Error;
|
||||||
|
launching.set(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -216,7 +251,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const releaseStream = await getReleaseStream(osuPath);
|
const releaseStream = await getReleaseStream(osuPath);
|
||||||
let forceUpdate = releaseStream && releaseStream.toLowerCase() !== 'stable40';
|
const osuCorrupted = await isOsuCorrupted(osuPath);
|
||||||
|
let forceUpdate =
|
||||||
|
(releaseStream && releaseStream.toLowerCase() !== 'stable40') || osuCorrupted;
|
||||||
|
|
||||||
const versions = compareBuildNumbers($osuBuild, streamInfo);
|
const versions = compareBuildNumbers($osuBuild, streamInfo);
|
||||||
if (versions > 0 || forceUpdate) {
|
if (versions > 0 || forceUpdate) {
|
||||||
@@ -260,7 +297,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Password',
|
key: 'Password',
|
||||||
value: password,
|
value:
|
||||||
|
$platform === 'windows'
|
||||||
|
? await encryptString(password, 'cu24180ncjeiu0ci1nwui')
|
||||||
|
: password,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'SaveUsername',
|
key: 'SaveUsername',
|
||||||
@@ -305,9 +345,130 @@
|
|||||||
await replaceUIFiles(osuPath, false);
|
await replaceUIFiles(osuPath, false);
|
||||||
await new Promise((res) => setTimeout(res, 1000));
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
await getCurrentWindow().hide();
|
await getCurrentWindow().hide();
|
||||||
|
|
||||||
|
let presenceUpdater: number | undefined = undefined;
|
||||||
|
|
||||||
|
const isPresenceConnected = await presence.isConnected();
|
||||||
|
|
||||||
|
if ($discordPresence && isPresenceConnected) {
|
||||||
|
let osuDetected = false;
|
||||||
|
presenceUpdater = window.setInterval(async () => {
|
||||||
|
if (!osuDetected) {
|
||||||
|
const osuRunning = await isOsuRunning();
|
||||||
|
if (osuRunning) osuDetected = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($currentUser) {
|
||||||
|
const userStats = await ezppfarm.getUserInfo($currentUser.id, 'stats');
|
||||||
|
const userStatus = await ezppfarm.getUserStatus($currentUser.id);
|
||||||
|
if (userStatus?.player_status.online) {
|
||||||
|
let largeImageKey = 'ezppfarm';
|
||||||
|
let details = 'Idle...';
|
||||||
|
let state =
|
||||||
|
userStatus.player_status.status.info_text.length > 0
|
||||||
|
? userStatus.player_status.status.info_text
|
||||||
|
: ' ';
|
||||||
|
|
||||||
|
const gamemode = getModeAndTypeFromGamemode(userStatus.player_status.status.mode);
|
||||||
|
const gamemodeName = getGamemodeName(
|
||||||
|
modeIntToStr(gamemode.mode),
|
||||||
|
typeIntToStr(gamemode.type)
|
||||||
|
);
|
||||||
|
|
||||||
|
switch (userStatus.player_status.status.action) {
|
||||||
|
case EZPPActionStatus.AFK:
|
||||||
|
details = 'AFK...';
|
||||||
|
state = ' ';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.PLAYING:
|
||||||
|
details = 'Playing...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.EDITING:
|
||||||
|
details = 'Editing...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.MODDING:
|
||||||
|
details = 'Modding...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.MULTIPLAYER_SELECT:
|
||||||
|
details = 'Multiplayer: Selecting a Beatmap...';
|
||||||
|
state = ' ';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.WATCHING:
|
||||||
|
details = 'Watching...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.TESTING:
|
||||||
|
details = 'Testing...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.SUBMITTING:
|
||||||
|
details = 'Submitting...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.MULTIPLAYER_IDLE:
|
||||||
|
details = 'Multiplayer: Idle...';
|
||||||
|
state = ' ';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.MULTIPLAYER_PLAYING:
|
||||||
|
details = 'Multiplayer: Playing...';
|
||||||
|
break;
|
||||||
|
case EZPPActionStatus.DIRECT:
|
||||||
|
details = 'Browsing osu!direct...';
|
||||||
|
state = ' ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userStatus.player_status.status.beatmap !== null) {
|
||||||
|
const beatmapCoverImage = `https://assets.ppy.sh/beatmaps/${userStatus.player_status.status.beatmap.set_id}/covers/list@2x.jpg`;
|
||||||
|
const isValidImage = await urlIsValidImage(beatmapCoverImage);
|
||||||
|
if (isValidImage) largeImageKey = beatmapCoverImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
details = `[${gamemodeName}] ${details}`;
|
||||||
|
try {
|
||||||
|
const currentModeStats =
|
||||||
|
userStats?.player.stats[userStatus.player_status.status.mode];
|
||||||
|
let username = $currentUser.name;
|
||||||
|
|
||||||
|
if (currentModeStats && currentModeStats.rank > 0)
|
||||||
|
username += ` (#${currentModeStats.rank})`;
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
presence.updateUser({
|
||||||
|
username,
|
||||||
|
id: $currentUser.id.toFixed(),
|
||||||
|
}),
|
||||||
|
presence.updateStatus({
|
||||||
|
details,
|
||||||
|
state,
|
||||||
|
largeImageKey,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000 * 2);
|
||||||
|
}
|
||||||
|
|
||||||
await runOsu(osuPath, true);
|
await runOsu(osuPath, true);
|
||||||
|
|
||||||
launchInfo = 'Cleaning up...';
|
launchInfo = 'Cleaning up...';
|
||||||
await getCurrentWindow().show();
|
await getCurrentWindow().show();
|
||||||
|
if (presenceUpdater) {
|
||||||
|
window.clearInterval(presenceUpdater);
|
||||||
|
console.log('clearing discord presence...');
|
||||||
|
try {
|
||||||
|
await Promise.all([
|
||||||
|
presence.updateUser({
|
||||||
|
username: ' ',
|
||||||
|
id: null,
|
||||||
|
}),
|
||||||
|
presence.updateStatus({
|
||||||
|
details: ' ',
|
||||||
|
state: 'Idle in Launcher...',
|
||||||
|
largeImageKey: 'ezppfarm',
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
} catch {}
|
||||||
|
console.log('discord presence cleared...');
|
||||||
|
}
|
||||||
await new Promise((res) => setTimeout(res, 1000));
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
await replaceUIFiles(osuPath, true);
|
await replaceUIFiles(osuPath, true);
|
||||||
|
|
||||||
@@ -325,24 +486,60 @@
|
|||||||
const skin = await getSkin(osuPath);
|
const skin = await getSkin(osuPath);
|
||||||
currentSkin.set(skin);
|
currentSkin.set(skin);
|
||||||
|
|
||||||
|
if ($currentUser) {
|
||||||
|
const userInfo = await ezppfarm.getUserInfo($currentUser.id);
|
||||||
|
if (userInfo) currentUserInfo.set(userInfo.player);
|
||||||
|
}
|
||||||
|
|
||||||
launching.set(false);
|
launching.set(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
launchError = err as Error;
|
||||||
console.log(err);
|
console.log(err);
|
||||||
toast.error('Hmmm...', {
|
toast.error('Hmmm...', {
|
||||||
description: 'Failed to launch.',
|
description: 'Failed to launch.',
|
||||||
});
|
});
|
||||||
launching.set(false);
|
launching.set(false);
|
||||||
|
|
||||||
if ($currentUser) {
|
|
||||||
const userInfo = await ezppfarm.getUserInfo($currentUser.id);
|
|
||||||
if (userInfo) currentUserInfo.set(userInfo.player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AlertDialog.Root open={$newVersion !== undefined}>
|
<AlertDialog.Root open={launchError !== undefined}>
|
||||||
<AlertDialog.Content class="bg-theme-950 border-theme-800 p-0">
|
<AlertDialog.Content class="bg-theme-950 border-theme-800 p-0">
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
|
||||||
|
>
|
||||||
|
<img class="h-20 w-20" src={Logo} alt="logo" />
|
||||||
|
<span class="font-semibold text-xl">Error on Launch!</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center text-sm text-center bg-theme-900 border border-theme-800 rounded-lg mx-3 p-3"
|
||||||
|
>
|
||||||
|
{#if launchError}
|
||||||
|
<pre class="text-wrap text-start">{JSON.stringify(
|
||||||
|
launchError,
|
||||||
|
Object.getOwnPropertyNames(launchError),
|
||||||
|
2
|
||||||
|
)}</pre>
|
||||||
|
{:else}
|
||||||
|
Unexpected error
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-center mb-3">
|
||||||
|
<Button
|
||||||
|
onclick={async () => {
|
||||||
|
launchError = undefined;
|
||||||
|
}}>Close</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</AlertDialog.Content>
|
||||||
|
</AlertDialog.Root>
|
||||||
|
|
||||||
|
<AlertDialog.Root open={$newVersion !== undefined}>
|
||||||
|
<AlertDialog.Content
|
||||||
|
class="bg-theme-950 border-theme-800 p-0"
|
||||||
|
escapeKeydownBehavior="ignore"
|
||||||
|
interactOutsideBehavior="ignore"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
|
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
|
||||||
>
|
>
|
||||||
@@ -378,7 +575,11 @@
|
|||||||
</AlertDialog.Root>
|
</AlertDialog.Root>
|
||||||
|
|
||||||
<AlertDialog.Root bind:open={$launching}>
|
<AlertDialog.Root bind:open={$launching}>
|
||||||
<AlertDialog.Content class="bg-theme-950 border-theme-800 p-0">
|
<AlertDialog.Content
|
||||||
|
class="bg-theme-950 border-theme-800 p-0"
|
||||||
|
escapeKeydownBehavior="ignore"
|
||||||
|
interactOutsideBehavior="ignore"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
|
class="flex flex-col items-center justify-center border-b border-theme-800 bg-black/40 rounded-t-lg p-3"
|
||||||
>
|
>
|
||||||
@@ -636,7 +837,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-6 w-full h-full bg-theme-900/40 p-6">
|
<div class="flex flex-col gap-6 w-full h-full bg-theme-900/40 p-6">
|
||||||
<div
|
<div
|
||||||
class="flex flex-row flex-nowrap h-11 w-full bg-theme-800/50 border border-theme-800/90 rounded-lg p-[4px]"
|
class="flex flex-row flex-nowrap h-11 gap-1 w-full bg-theme-800/50 border border-theme-800/90 rounded-lg p-[4px]"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="w-full flex justify-center items-center font-semibold text-sm rounded-lg {selectedTab ===
|
class="w-full flex justify-center items-center font-semibold text-sm rounded-lg {selectedTab ===
|
||||||
@@ -862,11 +1063,18 @@
|
|||||||
>
|
>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<Label class="text-sm" for="setting-custom-cursor">Patching</Label>
|
<Label class="text-sm" for="setting-custom-cursor">Patching</Label>
|
||||||
<div class="text-muted-foreground text-xs">Shows misses in Relax and Autopilot</div>
|
<div class="text-muted-foreground text-xs">
|
||||||
|
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"
|
||||||
|
>currently only on windows!</span
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="setting-custom-cursor"
|
id="setting-custom-cursor"
|
||||||
checked={$patch}
|
checked={$platform === 'windows' ? $patch : false}
|
||||||
|
disabled={$platform !== 'windows'}
|
||||||
onCheckedChange={async (e) => {
|
onCheckedChange={async (e) => {
|
||||||
patch.set(e);
|
patch.set(e);
|
||||||
$userSettings.save();
|
$userSettings.save();
|
||||||
@@ -913,13 +1121,13 @@
|
|||||||
></Checkbox>
|
></Checkbox>
|
||||||
|
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<Label class="text-sm" for="setting-cursor-smoothening">Reduce Animations</Label>
|
<Label class="text-sm" for="setting-reduce-animations">Reduce Animations</Label>
|
||||||
<div class="text-muted-foreground text-xs">
|
<div class="text-muted-foreground text-xs">
|
||||||
Disables some animations in the Launcher to improve performance on low-end devices.
|
Disables some animations in the Launcher to improve performance on low-end devices.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="setting-cursor-smoothening"
|
id="setting-reduce-animations"
|
||||||
checked={$reduceAnimations}
|
checked={$reduceAnimations}
|
||||||
onCheckedChange={async (e) => {
|
onCheckedChange={async (e) => {
|
||||||
reduceAnimations.set(e);
|
reduceAnimations.set(e);
|
||||||
@@ -927,9 +1135,29 @@
|
|||||||
}}
|
}}
|
||||||
class="flex items-center justify-center w-5 h-5"
|
class="flex items-center justify-center w-5 h-5"
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<Label class="text-sm" for="setting-rich-presence">Discord Rich Presence</Label>
|
||||||
|
<div class="text-muted-foreground text-xs">
|
||||||
|
Let other discord users show what you are doing right now 👀
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="relative">
|
||||||
|
{#if $presenceLoading}
|
||||||
|
<div class="-left-8 absolute" transition:fade>
|
||||||
|
<LoaderCircle class="animate-spin" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<Checkbox
|
||||||
|
id="setting-rich-presence"
|
||||||
|
bind:checked={$discordPresence}
|
||||||
|
disabled={$presenceLoading}
|
||||||
|
class="flex items-center justify-center w-5 h-5"
|
||||||
|
></Checkbox>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="grid grid-cols-[0.7fr_auto] gap-y-5 items-center border-theme-800 pl-6 pr-5 pb-4"
|
class="grid grid-cols-[0.7fr_auto] gap-y-1 items-center border-theme-800 pl-6 pr-5 pb-4"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<Label class="text-sm" for="setting-custom-cursor">osu! installation path</Label>
|
<Label class="text-sm" for="setting-custom-cursor">osu! installation path</Label>
|
||||||
@@ -949,6 +1177,54 @@
|
|||||||
onclick={browse_osu_installation}>Browse</Button
|
onclick={browse_osu_installation}>Browse</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<Label class="text-sm" for="setting-custom-cursor">patcher release stream</Label>
|
||||||
|
<div class="text-muted-foreground text-xs">
|
||||||
|
test different versions of the patcher
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row w-full">
|
||||||
|
<Select.Root
|
||||||
|
type="single"
|
||||||
|
bind:value={$launcherStream}
|
||||||
|
onValueChange={async (newStream) => {
|
||||||
|
if (newStream === 'experimental' && !(await hasNet8())) {
|
||||||
|
launcherStream.set('stable');
|
||||||
|
toast.error('.NET 8.0 Desktop Runtime not found!', {
|
||||||
|
action: {
|
||||||
|
label: 'Download .NET 8.0',
|
||||||
|
onClick: async () =>
|
||||||
|
await openURL(
|
||||||
|
'https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-8.0.18-windows-x64-installer'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$userSettings.value('patcherStream').set(newStream);
|
||||||
|
launcherStream.set(newStream);
|
||||||
|
await $userSettings.save();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Select.Trigger
|
||||||
|
class="border-theme-800 bg-theme-950 !text-muted-foreground font-semibold"
|
||||||
|
>
|
||||||
|
<div class="flex flex-row items-center gap-2 font-normal text-foreground">
|
||||||
|
{$launcherStream}
|
||||||
|
</div>
|
||||||
|
</Select.Trigger>
|
||||||
|
<Select.Content class="bg-theme-950 border border-theme-950 rounded-lg">
|
||||||
|
{#each $launcherStreams as stream (stream)}
|
||||||
|
<Select.Item value={stream}>
|
||||||
|
<div class="flex flex-row gap-2 items-center">
|
||||||
|
{stream}
|
||||||
|
</div>
|
||||||
|
</Select.Item>
|
||||||
|
{/each}
|
||||||
|
</Select.Content>
|
||||||
|
</Select.Root>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@@ -7,6 +7,8 @@
|
|||||||
currentSkin,
|
currentSkin,
|
||||||
currentView,
|
currentView,
|
||||||
firstStartup,
|
firstStartup,
|
||||||
|
launcherStream,
|
||||||
|
launcherStreams,
|
||||||
launcherVersion,
|
launcherVersion,
|
||||||
newVersion,
|
newVersion,
|
||||||
osuBuild,
|
osuBuild,
|
||||||
@@ -30,6 +32,7 @@
|
|||||||
import { currentUserInfo } from '@/data';
|
import { currentUserInfo } from '@/data';
|
||||||
import {
|
import {
|
||||||
getBeatmapSetsCount,
|
getBeatmapSetsCount,
|
||||||
|
getEZPPLauncherStreams,
|
||||||
getReleaseStream,
|
getReleaseStream,
|
||||||
getSkin,
|
getSkin,
|
||||||
getSkinsCount,
|
getSkinsCount,
|
||||||
@@ -148,6 +151,14 @@
|
|||||||
newVersion.set(launcherUpdate);
|
newVersion.set(launcherUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ezpplauncherStreams = await getEZPPLauncherStreams();
|
||||||
|
if (ezpplauncherStreams) launcherStreams.set(ezpplauncherStreams);
|
||||||
|
|
||||||
|
const selectedLauncherStream = $userSettings.value('patcherStream').get('stable');
|
||||||
|
if ($launcherStreams.includes(selectedLauncherStream)) {
|
||||||
|
launcherStream.set(selectedLauncherStream);
|
||||||
|
}
|
||||||
|
|
||||||
animate(ezppLogo, {
|
animate(ezppLogo, {
|
||||||
opacity: [1, 0],
|
opacity: [1, 0],
|
||||||
scale: [1, 1.05],
|
scale: [1, 1.05],
|
24
tests/imageCheck.test.ts
Normal file
24
tests/imageCheck.test.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { expect, test } from 'bun:test';
|
||||||
|
|
||||||
|
const urlIsValidImage = async (url: string) => {
|
||||||
|
try {
|
||||||
|
const request = await fetch(url);
|
||||||
|
if (!request.ok) return false;
|
||||||
|
const contentType = request.headers.get('content-type');
|
||||||
|
return contentType?.startsWith('image/');
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
test('image check', async () => {
|
||||||
|
const imageUrl = 'https://assets.ppy.sh/beatmaps/1/covers/list@2x.jpg';
|
||||||
|
const imageCheckResult = await urlIsValidImage(imageUrl);
|
||||||
|
expect(imageCheckResult).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('image check fail', async () => {
|
||||||
|
const imageUrl = 'https://assets.ppy.sh/beatmaps/0/covers/list@2x.jpg';
|
||||||
|
const imageCheckResult = await urlIsValidImage(imageUrl);
|
||||||
|
expect(imageCheckResult).toBe(false);
|
||||||
|
});
|
Reference in New Issue
Block a user