Compare commits
9
Commits
8616253065
...
themes-v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
756638ecf1 | ||
|
|
34e93ee29b | ||
|
|
e1c04c4f5b | ||
|
|
cb117826c7 | ||
|
|
0e295c8425 | ||
|
|
746524d27e | ||
|
|
660fb557a6 | ||
|
|
575da8504a
|
||
|
|
0105c5975a
|
No files matched your search
@@ -183,6 +183,30 @@ src-tauri/target/release/bundle/deb/
|
|||||||
src-tauri/target/release/bundle/appimage/
|
src-tauri/target/release/bundle/appimage/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Cross-platform Releases
|
||||||
|
|
||||||
|
Use the release scripts to build a specific platform:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun run release:macos
|
||||||
|
bun run release:windows
|
||||||
|
bun run release:linux
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows installers can be cross-compiled from macOS with NSIS and `cargo-xwin`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install nsis llvm cmake nasm ninja
|
||||||
|
rustup target add x86_64-pc-windows-msvc
|
||||||
|
cargo install --locked cargo-xwin
|
||||||
|
bun run release:windows
|
||||||
|
```
|
||||||
|
|
||||||
|
The Windows installer is written to
|
||||||
|
`src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/`. Cross-compiled
|
||||||
|
Windows builds are unsigned. macOS releases must be built on macOS, and Linux
|
||||||
|
releases must be built on Linux.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📁 Project Structure (Overview)
|
## 📁 Project Structure (Overview)
|
||||||
|
|||||||
+4
-1
@@ -5,7 +5,10 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"debug": "bun run tauri dev",
|
"debug": "bun run tauri dev",
|
||||||
"build": "bun ./scripts/build.ts",
|
"release": "bun ./scripts/release.ts",
|
||||||
|
"release:macos": "bun ./scripts/release.ts macos",
|
||||||
|
"release:windows": "bun ./scripts/release.ts windows",
|
||||||
|
"release:linux": "bun ./scripts/release.ts linux",
|
||||||
"vite:dev": "vite dev",
|
"vite:dev": "vite dev",
|
||||||
"vite:build": "vite build && exit 0",
|
"vite:build": "vite build && exit 0",
|
||||||
"tauri:build": "tauri build",
|
"tauri:build": "tauri build",
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
import { spawn } from 'child_process';
|
|
||||||
|
|
||||||
function runVite(): Promise<void> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const proc = spawn('bunx', ['--bun', 'vite', 'build'], { stdio: ['inherit', 'pipe', 'pipe'] });
|
|
||||||
|
|
||||||
proc.stdout?.on('data', (data: Buffer) => {
|
|
||||||
process.stdout.write(data);
|
|
||||||
if (data.toString().includes('✔ done')) {
|
|
||||||
setTimeout(() => {
|
|
||||||
proc.kill();
|
|
||||||
resolve();
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
proc.stderr?.on('data', (data: Buffer) => process.stderr.write(data));
|
|
||||||
proc.on('close', (code) => {
|
|
||||||
if (code === 0 || code === null) resolve();
|
|
||||||
else reject(new Error(`vite build exited with code ${code}`));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(cmd: string, args: string[]): Promise<void> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const proc = spawn(cmd, args, { stdio: 'inherit' });
|
|
||||||
proc.on('close', (code) => {
|
|
||||||
if (code === 0) resolve();
|
|
||||||
else reject(new Error(`${cmd} exited with code ${code}`));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await run('bun', ['./scripts/sync-version.ts']);
|
|
||||||
await runVite();
|
|
||||||
|
|
||||||
//set NO_STRIP=1 in env for linux to prevent stripping of debug symbols in tauri builds, which causes issues with source maps
|
|
||||||
if (process.platform === 'linux') process.env.NO_STRIP = '1';
|
|
||||||
await run('bunx', ['tauri', 'build']);
|
|
||||||
@@ -0,0 +1,301 @@
|
|||||||
|
import { spawn, execFileSync } from 'node:child_process';
|
||||||
|
import { accessSync, constants, existsSync } from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
const WINDOWS_TARGET = 'x86_64-pc-windows-msvc';
|
||||||
|
const TARGETS = ['macos', 'windows', 'linux'] as const;
|
||||||
|
|
||||||
|
type Target = (typeof TARGETS)[number];
|
||||||
|
|
||||||
|
function hostTarget(): Target {
|
||||||
|
if (process.platform === 'darwin') return 'macos';
|
||||||
|
if (process.platform === 'win32') return 'windows';
|
||||||
|
if (process.platform === 'linux') return 'linux';
|
||||||
|
throw new Error(`Unsupported build host: ${process.platform}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function findCommand(command: string, envPath: string): string | undefined {
|
||||||
|
const extensions =
|
||||||
|
process.platform === 'win32'
|
||||||
|
? ['', ...(process.env.PATHEXT ?? '.EXE;.CMD;.BAT').split(';')]
|
||||||
|
: [''];
|
||||||
|
|
||||||
|
for (const directory of envPath.split(path.delimiter)) {
|
||||||
|
if (!directory) continue;
|
||||||
|
for (const extension of extensions) {
|
||||||
|
const candidate = path.join(directory, `${command}${extension.toLowerCase()}`);
|
||||||
|
try {
|
||||||
|
accessSync(candidate, constants.X_OK);
|
||||||
|
return candidate;
|
||||||
|
} catch {
|
||||||
|
// Keep looking through PATH.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prependExistingPath(env: NodeJS.ProcessEnv, directory: string) {
|
||||||
|
if (existsSync(directory)) env.PATH = `${directory}${path.delimiter}${env.PATH ?? ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureUtf8Locale(env: NodeJS.ProcessEnv) {
|
||||||
|
const current = env.LC_ALL || env.LC_CTYPE || env.LANG || '';
|
||||||
|
if (current && current !== 'C' && current !== 'POSIX') return;
|
||||||
|
|
||||||
|
// makeNSIS 3.13 crashes with std::bad_alloc on POSIX under the C locale.
|
||||||
|
const locale = process.platform === 'darwin' ? 'en_US.UTF-8' : 'C.UTF-8';
|
||||||
|
env.LC_ALL = locale;
|
||||||
|
env.LANG = locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectRustupToolchain(env: NodeJS.ProcessEnv) {
|
||||||
|
const rustup =
|
||||||
|
findCommand('rustup', env.PATH ?? '') ??
|
||||||
|
['/opt/homebrew/opt/rustup/bin/rustup', '/usr/local/opt/rustup/bin/rustup'].find((candidate) =>
|
||||||
|
existsSync(candidate)
|
||||||
|
);
|
||||||
|
if (!rustup) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cargo = execFileSync(rustup, ['which', 'cargo'], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
env,
|
||||||
|
stdio: ['ignore', 'pipe', 'ignore'],
|
||||||
|
}).trim();
|
||||||
|
env.PATH = `${path.dirname(cargo)}${path.delimiter}${env.PATH ?? ''}`;
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
const libDir = path.join(path.dirname(path.dirname(cargo)), 'lib');
|
||||||
|
env.DYLD_FALLBACK_LIBRARY_PATH = [libDir, env.DYLD_FALLBACK_LIBRARY_PATH]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(path.delimiter);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Fall back to the cargo already on PATH.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasRustTarget(target: string, env: NodeJS.ProcessEnv): boolean {
|
||||||
|
try {
|
||||||
|
const libdir = execFileSync('rustc', ['--print', 'target-libdir', '--target', target], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
env,
|
||||||
|
stdio: ['ignore', 'pipe', 'ignore'],
|
||||||
|
}).trim();
|
||||||
|
return existsSync(libdir);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureCrossWindowsLinker(env: NodeJS.ProcessEnv) {
|
||||||
|
// Microsoft's prebuilt CRT libraries reference PDBs that are not shipped
|
||||||
|
// with cargo-xwin, so lld-link emits LNK4099 for every library. The debug
|
||||||
|
// info is unavailable either way, so suppress only that specific warning.
|
||||||
|
const key = 'CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS';
|
||||||
|
env[key] = [env[key], '-C', 'link-arg=/ignore:4099'].filter(Boolean).join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
function windowsPrerequisites(env: NodeJS.ProcessEnv): string[] {
|
||||||
|
const missing: string[] = [];
|
||||||
|
|
||||||
|
if (!findCommand('cargo-xwin', env.PATH ?? '')) {
|
||||||
|
missing.push('cargo-xwin (install with: cargo install --locked cargo-xwin)');
|
||||||
|
}
|
||||||
|
if (!findCommand('cmake', env.PATH ?? '')) {
|
||||||
|
missing.push(
|
||||||
|
process.platform === 'darwin'
|
||||||
|
? 'CMake (install with: brew install cmake)'
|
||||||
|
: 'CMake (install cmake and add it to PATH)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!findCommand('nasm', env.PATH ?? '')) {
|
||||||
|
missing.push(
|
||||||
|
process.platform === 'darwin'
|
||||||
|
? 'NASM (install with: brew install nasm)'
|
||||||
|
: 'NASM (install nasm and add it to PATH)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!findCommand('ninja', env.PATH ?? '')) {
|
||||||
|
missing.push(
|
||||||
|
process.platform === 'darwin'
|
||||||
|
? 'Ninja (install with: brew install ninja)'
|
||||||
|
: 'Ninja (install ninja and add it to PATH)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!hasRustTarget(WINDOWS_TARGET, env)) {
|
||||||
|
missing.push(
|
||||||
|
`${WINDOWS_TARGET} Rust target (install with: rustup target add ${WINDOWS_TARGET})`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (process.platform !== 'win32') {
|
||||||
|
if (!findCommand('llvm-rc', env.PATH ?? '')) {
|
||||||
|
missing.push(
|
||||||
|
process.platform === 'darwin'
|
||||||
|
? 'LLVM (install with: brew install llvm, then add its bin directory to PATH)'
|
||||||
|
: 'LLVM (install llvm and lld, then add llvm-rc to PATH)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!findCommand('makensis', env.PATH ?? '')) {
|
||||||
|
missing.push(
|
||||||
|
process.platform === 'darwin'
|
||||||
|
? 'NSIS (install with: brew install nsis)'
|
||||||
|
: 'NSIS (install makensis and add it to PATH)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
function artifactDirectory(target: Target): string {
|
||||||
|
if (target === 'windows') {
|
||||||
|
const suffix =
|
||||||
|
process.platform === 'win32'
|
||||||
|
? path.join('target', 'release')
|
||||||
|
: path.join('target', WINDOWS_TARGET, 'release');
|
||||||
|
return path.join('src-tauri', suffix, 'bundle', 'nsis');
|
||||||
|
}
|
||||||
|
if (target === 'macos') return path.join('src-tauri', 'target', 'release', 'bundle');
|
||||||
|
return path.join('src-tauri', 'target', 'release', 'bundle');
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(command: string, args: string[], env: NodeJS.ProcessEnv): Promise<void> {
|
||||||
|
console.log(`\n$ ${[command, ...args].join(' ')}`);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const child = spawn(command, args, { env, stdio: 'inherit' });
|
||||||
|
|
||||||
|
child.on('error', reject);
|
||||||
|
child.on('close', (code) => {
|
||||||
|
if (code === 0) resolve();
|
||||||
|
else reject(new Error(`${command} exited with code ${code ?? 'unknown'}`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vite's static-adapter build can leave the process alive after writing the
|
||||||
|
* output. Stop it once the adapter confirms the build is complete.
|
||||||
|
*/
|
||||||
|
function buildFrontend(command: string, env: NodeJS.ProcessEnv): Promise<void> {
|
||||||
|
console.log(`\n$ ${command} x --bun vite build`);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const child = spawn(command, ['x', '--bun', 'vite', 'build'], {
|
||||||
|
env,
|
||||||
|
stdio: ['inherit', 'pipe', 'pipe'],
|
||||||
|
});
|
||||||
|
let completed = false;
|
||||||
|
|
||||||
|
const finish = (error?: Error) => {
|
||||||
|
if (completed) return;
|
||||||
|
completed = true;
|
||||||
|
if (error) reject(error);
|
||||||
|
else resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
child.stdout?.on('data', (data: Buffer) => {
|
||||||
|
process.stdout.write(data);
|
||||||
|
if (!completed && data.toString().includes('✔ done')) {
|
||||||
|
setTimeout(() => {
|
||||||
|
child.kill();
|
||||||
|
finish();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.stderr?.on('data', (data: Buffer) => process.stderr.write(data));
|
||||||
|
child.on('error', finish);
|
||||||
|
child.on('close', (code) => {
|
||||||
|
if (code === 0) finish();
|
||||||
|
else finish(new Error(`vite build exited with code ${code ?? 'unknown'}`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
console.log(`Build an EZPPLauncher release.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
bun run release Build for the current platform
|
||||||
|
bun run release:macos Build the macOS app and DMG
|
||||||
|
bun run release:windows Build the Windows NSIS installer
|
||||||
|
bun run release:linux Build the Linux package
|
||||||
|
|
||||||
|
On macOS, release:windows cross-compiles using cargo-xwin. On Linux, use
|
||||||
|
release:linux on a Linux host; Linux bundles cannot be built from macOS.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const requested = process.argv[2]?.toLowerCase();
|
||||||
|
if (requested === '--help' || requested === '-h') {
|
||||||
|
usage();
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
let target: Target;
|
||||||
|
try {
|
||||||
|
target = requested ? (requested as Target) : hostTarget();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error instanceof Error ? error.message : error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TARGETS.includes(target)) {
|
||||||
|
console.error(`Unknown release target: ${requested}`);
|
||||||
|
usage();
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const host = hostTarget();
|
||||||
|
if (target === 'macos' && host !== 'macos') {
|
||||||
|
console.error('macOS releases must be built on macOS.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (target === 'linux' && host !== 'linux') {
|
||||||
|
console.error('Linux releases must be built on Linux. Use a Linux host or CI runner.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const env = { ...process.env };
|
||||||
|
if (host === 'macos') {
|
||||||
|
prependExistingPath(env, '/opt/homebrew/opt/llvm/bin');
|
||||||
|
prependExistingPath(env, '/usr/local/opt/llvm/bin');
|
||||||
|
prependExistingPath(env, '/opt/homebrew/opt/nsis/bin');
|
||||||
|
prependExistingPath(env, '/usr/local/opt/nsis/bin');
|
||||||
|
}
|
||||||
|
if (host !== 'windows') ensureUtf8Locale(env);
|
||||||
|
if (target === 'windows') selectRustupToolchain(env);
|
||||||
|
|
||||||
|
if (target === 'windows' && host !== 'windows') {
|
||||||
|
const missing = windowsPrerequisites(env);
|
||||||
|
if (missing.length > 0) {
|
||||||
|
console.error('Windows cross-compilation is missing prerequisites:\n');
|
||||||
|
for (const requirement of missing) console.error(` - ${requirement}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
configureCrossWindowsLinker(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
const tauriArgs = ['x', 'tauri', 'build'];
|
||||||
|
if (target === 'windows') {
|
||||||
|
tauriArgs.push('--bundles', 'nsis');
|
||||||
|
if (host !== 'windows') tauriArgs.push('--runner', 'cargo-xwin', '--target', WINDOWS_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
const bun = findCommand('bun', env.PATH ?? '') ?? 'bun';
|
||||||
|
console.log(`Building the ${target} release from ${host}...`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await run(bun, ['./scripts/sync-version.ts'], env);
|
||||||
|
await buildFrontend(bun, env);
|
||||||
|
|
||||||
|
if (target === 'linux') env.NO_STRIP = '1';
|
||||||
|
await run(bun, tauriArgs, env);
|
||||||
|
|
||||||
|
console.log(`\n✅ ${target} release built.`);
|
||||||
|
console.log(`Artifacts: ${artifactDirectory(target)}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`\n❌ Release build failed: ${error instanceof Error ? error.message : error}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
+81
-61
@@ -265,8 +265,7 @@ pub async fn read_file_chunk(path: String, offset: u64, length: u64) -> Result<V
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_hwid() -> String {
|
pub fn get_hwid() -> String {
|
||||||
get_id()
|
get_id().unwrap_or("recorderinsandybridge".to_string())
|
||||||
.unwrap_or("recorderinsandybridge".to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Show the native macOS picker, which can select `osu!.app` bundles as files.
|
/// Show the native macOS picker, which can select `osu!.app` bundles as files.
|
||||||
@@ -398,6 +397,8 @@ pub async fn installation_diagnostics(app: AppHandle, folder: String) -> Install
|
|||||||
.map(patcher_file_stats)
|
.map(patcher_file_stats)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
// macOS fills in the Wine and FFmpeg fields below.
|
||||||
|
#[cfg_attr(not(target_os = "macos"), allow(unused_mut))]
|
||||||
let mut diagnostics = InstallationDiagnostics {
|
let mut diagnostics = InstallationDiagnostics {
|
||||||
platform: std::env::consts::OS.to_string(),
|
platform: std::env::consts::OS.to_string(),
|
||||||
os_version: System::long_os_version(),
|
os_version: System::long_os_version(),
|
||||||
@@ -551,18 +552,19 @@ pub async fn get_skins_count(folder: String) -> Option<u64> {
|
|||||||
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
||||||
while let Ok(Some(entry)) = entries.next_entry().await {
|
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||||
if let Ok(ft) = entry.file_type().await
|
if let Ok(ft) = entry.file_type().await
|
||||||
&& ft.is_dir() {
|
&& ft.is_dir()
|
||||||
let dir_path = entry.path();
|
{
|
||||||
let has_ini = tokio::fs::try_exists(dir_path.join("skin.ini"))
|
let dir_path = entry.path();
|
||||||
|
let has_ini = tokio::fs::try_exists(dir_path.join("skin.ini"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(false)
|
||||||
|
|| tokio::fs::try_exists(dir_path.join("Skin.ini"))
|
||||||
.await
|
.await
|
||||||
.unwrap_or(false)
|
.unwrap_or(false);
|
||||||
|| tokio::fs::try_exists(dir_path.join("Skin.ini"))
|
if has_ini {
|
||||||
.await
|
count += 1;
|
||||||
.unwrap_or(false);
|
|
||||||
if has_ini {
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(count)
|
Some(count)
|
||||||
@@ -759,7 +761,7 @@ pub async fn run_osu(
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if optimize {
|
if optimize {
|
||||||
#[link(name = "winmm")]
|
#[link(name = "winmm")]
|
||||||
extern "system" {
|
unsafe extern "system" {
|
||||||
fn timeBeginPeriod(uPeriod: u32) -> u32;
|
fn timeBeginPeriod(uPeriod: u32) -> u32;
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -906,7 +908,7 @@ pub async fn run_osu(
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if optimize {
|
if optimize {
|
||||||
#[link(name = "winmm")]
|
#[link(name = "winmm")]
|
||||||
extern "system" {
|
unsafe extern "system" {
|
||||||
fn timeEndPeriod(uPeriod: u32) -> u32;
|
fn timeEndPeriod(uPeriod: u32) -> u32;
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -1062,7 +1064,10 @@ pub async fn download_ezpp_launcher_update_files(
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let patcher_exe = osu_path.join("EZPPLauncher").join("patcher").join("osu!.patcher.exe");
|
let patcher_exe = osu_path
|
||||||
|
.join("EZPPLauncher")
|
||||||
|
.join("patcher")
|
||||||
|
.join("osu!.patcher.exe");
|
||||||
if patcher_exe.is_file() {
|
if patcher_exe.is_file() {
|
||||||
let _ = crate::utils::ensure_patcher_compatibility(&patcher_exe);
|
let _ = crate::utils::ensure_patcher_compatibility(&patcher_exe);
|
||||||
}
|
}
|
||||||
@@ -1324,24 +1329,24 @@ pub struct PresenceButton {
|
|||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PresenceActivityPayload {
|
pub struct PresenceActivityPayload {
|
||||||
pub state: Option<String>,
|
pub state: String,
|
||||||
pub details: Option<String>,
|
pub details: String,
|
||||||
pub large_image_key: Option<String>,
|
pub large_image_key: String,
|
||||||
pub large_image_text: Option<String>,
|
pub large_image_text: String,
|
||||||
pub small_image_key: Option<Option<String>>,
|
pub small_image_key: Option<String>,
|
||||||
pub small_image_text: Option<Option<String>>,
|
pub small_image_text: Option<String>,
|
||||||
pub button1: Option<Option<presence::PresenceButton>>,
|
pub button1: Option<presence::PresenceButton>,
|
||||||
pub button2: Option<Option<presence::PresenceButton>>,
|
pub button2: Option<presence::PresenceButton>,
|
||||||
pub show_timestamp: Option<bool>,
|
pub show_timestamp: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn presence_update_activity(activity: PresenceActivityPayload) {
|
pub async fn presence_update_activity(activity: PresenceActivityPayload) {
|
||||||
presence::update_activity(
|
presence::update_activity(
|
||||||
activity.state.as_deref(),
|
&activity.state,
|
||||||
activity.details.as_deref(),
|
&activity.details,
|
||||||
activity.large_image_key.as_deref(),
|
&activity.large_image_key,
|
||||||
activity.large_image_text.as_deref(),
|
&activity.large_image_text,
|
||||||
activity.small_image_key,
|
activity.small_image_key,
|
||||||
activity.small_image_text,
|
activity.small_image_text,
|
||||||
activity.button1,
|
activity.button1,
|
||||||
@@ -1938,18 +1943,19 @@ pub(crate) fn theme_root() -> Result<PathBuf, String> {
|
|||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
fn loopback_theme_asset_base() -> String {
|
fn loopback_theme_asset_base() -> String {
|
||||||
if crate::theme_server::base_url().is_none()
|
if crate::theme_server::base_url().is_none()
|
||||||
&& let Ok(root) = theme_root() {
|
&& let Ok(root) = theme_root()
|
||||||
match crate::theme_server::media_root() {
|
{
|
||||||
Ok(media) => {
|
match crate::theme_server::media_root() {
|
||||||
if let Err(error) = crate::theme_server::start(root, media) {
|
Ok(media) => {
|
||||||
log::warn!(target: "launcher", "Could not start the theme asset server: {error}");
|
if let Err(error) = crate::theme_server::start(root, media) {
|
||||||
}
|
log::warn!(target: "launcher", "Could not start the theme asset server: {error}");
|
||||||
}
|
|
||||||
Err(error) => {
|
|
||||||
log::warn!(target: "launcher", "Could not prepare the media cache: {error}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(error) => {
|
||||||
|
log::warn!(target: "launcher", "Could not prepare the media cache: {error}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
crate::theme_server::base_url().unwrap_or_default()
|
crate::theme_server::base_url().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2097,7 +2103,14 @@ pub async fn optimize_theme_media(app: AppHandle, source_url: String) -> Result<
|
|||||||
};
|
};
|
||||||
|
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
optimize_theme_media_blocking(&ffmpeg, &source, &original, &cache_name, &destination, on_progress)
|
optimize_theme_media_blocking(
|
||||||
|
&ffmpeg,
|
||||||
|
&source,
|
||||||
|
&original,
|
||||||
|
&cache_name,
|
||||||
|
&destination,
|
||||||
|
on_progress,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(|error| format!("Theme media optimizer thread failed: {error}"))?
|
.map_err(|error| format!("Theme media optimizer thread failed: {error}"))?
|
||||||
@@ -2258,17 +2271,20 @@ async fn download_ffmpeg(app: &AppHandle) -> Result<PathBuf, String> {
|
|||||||
.await
|
.await
|
||||||
.map_err(|error| format!("Could not write the FFmpeg archive: {error}"))?;
|
.map_err(|error| format!("Could not write the FFmpeg archive: {error}"))?;
|
||||||
|
|
||||||
if let Some(percent) = (received.min(total) * 100).checked_div(total).map(|v| v as u8)
|
if let Some(percent) = (received.min(total) * 100)
|
||||||
&& percent != last_percent {
|
.checked_div(total)
|
||||||
last_percent = percent;
|
.map(|v| v as u8)
|
||||||
let _ = app.emit(
|
&& percent != last_percent
|
||||||
"theme-media-progress",
|
{
|
||||||
ThemeMediaProgress {
|
last_percent = percent;
|
||||||
stage: "download".to_string(),
|
let _ = app.emit(
|
||||||
progress: percent as f64 / 100.0,
|
"theme-media-progress",
|
||||||
},
|
ThemeMediaProgress {
|
||||||
);
|
stage: "download".to_string(),
|
||||||
}
|
progress: percent as f64 / 100.0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.flush()
|
file.flush()
|
||||||
@@ -2715,15 +2731,18 @@ pub async fn open_presence_editor(app: AppHandle) -> Result<(), String> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let window =
|
let window = WebviewWindowBuilder::new(
|
||||||
WebviewWindowBuilder::new(&app, "presence-editor", WebviewUrl::App("index.html".into()))
|
&app,
|
||||||
.title("EZPPLauncher — Discord Rich Presence Editor")
|
"presence-editor",
|
||||||
.inner_size(1200.0, 800.0)
|
WebviewUrl::App("index.html".into()),
|
||||||
.min_inner_size(980.0, 650.0)
|
)
|
||||||
.resizable(true)
|
.title("EZPPLauncher — Discord Rich Presence Editor")
|
||||||
.center()
|
.inner_size(1200.0, 800.0)
|
||||||
.build()
|
.min_inner_size(980.0, 650.0)
|
||||||
.map_err(|error| format!("Could not open the presence editor: {error}"))?;
|
.resizable(true)
|
||||||
|
.center()
|
||||||
|
.build()
|
||||||
|
.map_err(|error| format!("Could not open the presence editor: {error}"))?;
|
||||||
|
|
||||||
let main_window = app.clone();
|
let main_window = app.clone();
|
||||||
window.on_window_event(move |event| {
|
window.on_window_event(move |event| {
|
||||||
@@ -3118,9 +3137,10 @@ fn collect_theme_asset_refs(value: &Value, assets: &mut HashSet<String>) {
|
|||||||
for (key, value) in object {
|
for (key, value) in object {
|
||||||
if (key == "src" || key == "preview")
|
if (key == "src" || key == "preview")
|
||||||
&& let Some(src) = value.as_str()
|
&& let Some(src) = value.as_str()
|
||||||
&& let Some(path) = theme_asset_reference(src) {
|
&& let Some(path) = theme_asset_reference(src)
|
||||||
assets.insert(path);
|
{
|
||||||
}
|
assets.insert(path);
|
||||||
|
}
|
||||||
collect_theme_asset_refs(value, assets);
|
collect_theme_asset_refs(value, assets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+130
-23
@@ -393,7 +393,97 @@ pub struct LogBundleEntry {
|
|||||||
pub content: String,
|
pub content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List the rotating ZIP bundles, newest first, for the in-app log viewer.
|
const MAX_LOG_VIEW_BYTES: u64 = 2 * 1024 * 1024;
|
||||||
|
|
||||||
|
fn modified_millis(metadata: &fs::Metadata) -> u64 {
|
||||||
|
metadata
|
||||||
|
.modified()
|
||||||
|
.ok()
|
||||||
|
.and_then(|time| time.duration_since(std::time::UNIX_EPOCH).ok())
|
||||||
|
.map(|duration| duration.as_millis() as u64)
|
||||||
|
.unwrap_or(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Describe the active session. Unlike archived bundles, these files are still
|
||||||
|
/// being written and appear in the viewer without waiting for a rotation.
|
||||||
|
fn current_log_bundle(dir: &Path) -> Option<LogBundleInfo> {
|
||||||
|
let mut size = 0;
|
||||||
|
let mut modified = 0;
|
||||||
|
let mut has_logs = false;
|
||||||
|
|
||||||
|
for stream in Stream::ALL {
|
||||||
|
let Ok(metadata) = fs::metadata(dir.join(stream.file_name())) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if metadata.len() == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
has_logs = true;
|
||||||
|
size += metadata.len();
|
||||||
|
modified = modified.max(modified_millis(&metadata));
|
||||||
|
}
|
||||||
|
|
||||||
|
has_logs.then(|| LogBundleInfo {
|
||||||
|
path: dir.to_string_lossy().into_owned(),
|
||||||
|
name: "Current session".to_string(),
|
||||||
|
size,
|
||||||
|
modified,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_log_entry(
|
||||||
|
name: String,
|
||||||
|
reader: &mut impl Read,
|
||||||
|
size: u64,
|
||||||
|
) -> Result<LogBundleEntry, String> {
|
||||||
|
let mut bytes = Vec::new();
|
||||||
|
reader
|
||||||
|
.take(MAX_LOG_VIEW_BYTES)
|
||||||
|
.read_to_end(&mut bytes)
|
||||||
|
.map_err(|error| format!("Could not read a log entry: {error}"))?;
|
||||||
|
let mut content = String::from_utf8_lossy(&bytes).into_owned();
|
||||||
|
if size > bytes.len() as u64 {
|
||||||
|
content.push_str("\n… log truncated in the viewer …\n");
|
||||||
|
}
|
||||||
|
Ok(LogBundleEntry { name, content })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_current_logs(root: &Path) -> Result<Vec<LogBundleEntry>, String> {
|
||||||
|
let mut entries = Vec::new();
|
||||||
|
|
||||||
|
for stream in Stream::ALL {
|
||||||
|
let path = root.join(stream.file_name());
|
||||||
|
let metadata = match fs::metadata(&path) {
|
||||||
|
Ok(metadata) => metadata,
|
||||||
|
Err(error) if error.kind() == io::ErrorKind::NotFound => continue,
|
||||||
|
Err(error) => {
|
||||||
|
return Err(format!(
|
||||||
|
"Could not read the current {}: {error}",
|
||||||
|
stream.file_name()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if metadata.len() == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut file = File::open(&path).map_err(|error| {
|
||||||
|
format!("Could not read the current {}: {error}", stream.file_name())
|
||||||
|
})?;
|
||||||
|
entries.push(read_log_entry(
|
||||||
|
stream.file_name().to_string(),
|
||||||
|
&mut file,
|
||||||
|
metadata.len(),
|
||||||
|
)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
entries.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
|
Ok(entries)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List the active session followed by the rotating ZIP bundles, newest first,
|
||||||
|
/// for the in-app log viewer.
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn list_log_bundles() -> Result<Vec<LogBundleInfo>, String> {
|
pub fn list_log_bundles() -> Result<Vec<LogBundleInfo>, String> {
|
||||||
let dir = logs_directory();
|
let dir = logs_directory();
|
||||||
@@ -401,6 +491,7 @@ pub fn list_log_bundles() -> Result<Vec<LogBundleInfo>, String> {
|
|||||||
return Ok(Vec::new());
|
return Ok(Vec::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let current = current_log_bundle(&dir);
|
||||||
let mut bundles = fs::read_dir(&dir)
|
let mut bundles = fs::read_dir(&dir)
|
||||||
.map_err(|error| format!("Could not read the logs folder: {error}"))?
|
.map_err(|error| format!("Could not read the logs folder: {error}"))?
|
||||||
.filter_map(|entry| entry.ok())
|
.filter_map(|entry| entry.ok())
|
||||||
@@ -411,26 +502,23 @@ pub fn list_log_bundles() -> Result<Vec<LogBundleInfo>, String> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let metadata = entry.metadata().ok()?;
|
let metadata = entry.metadata().ok()?;
|
||||||
let modified = metadata
|
|
||||||
.modified()
|
|
||||||
.ok()
|
|
||||||
.and_then(|time| time.duration_since(std::time::UNIX_EPOCH).ok())
|
|
||||||
.map(|duration| duration.as_millis() as u64)
|
|
||||||
.unwrap_or(0);
|
|
||||||
Some(LogBundleInfo {
|
Some(LogBundleInfo {
|
||||||
path: path.to_string_lossy().into_owned(),
|
path: path.to_string_lossy().into_owned(),
|
||||||
name,
|
name,
|
||||||
size: metadata.len(),
|
size: metadata.len(),
|
||||||
modified,
|
modified: modified_millis(&metadata),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
bundles.sort_by_key(|b| std::cmp::Reverse(b.modified));
|
bundles.sort_by_key(|b| std::cmp::Reverse(b.modified));
|
||||||
|
if let Some(current) = current {
|
||||||
|
bundles.insert(0, current);
|
||||||
|
}
|
||||||
Ok(bundles)
|
Ok(bundles)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read the launcher/osu/patcher logs out of one bundle.
|
/// Read the active logs or the launcher/osu/patcher logs out of an archive.
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn read_log_bundle(path: String) -> Result<Vec<LogBundleEntry>, String> {
|
pub fn read_log_bundle(path: String) -> Result<Vec<LogBundleEntry>, String> {
|
||||||
let dir = logs_directory();
|
let dir = logs_directory();
|
||||||
@@ -441,6 +529,9 @@ pub fn read_log_bundle(path: String) -> Result<Vec<LogBundleEntry>, String> {
|
|||||||
if !requested.starts_with(&root) {
|
if !requested.starts_with(&root) {
|
||||||
return Err("The log bundle is outside the logs folder".to_string());
|
return Err("The log bundle is outside the logs folder".to_string());
|
||||||
}
|
}
|
||||||
|
if requested == root {
|
||||||
|
return read_current_logs(&root);
|
||||||
|
}
|
||||||
|
|
||||||
let file = File::open(&requested)
|
let file = File::open(&requested)
|
||||||
.map_err(|error| format!("Could not read the log bundle: {error}"))?;
|
.map_err(|error| format!("Could not read the log bundle: {error}"))?;
|
||||||
@@ -456,20 +547,9 @@ pub fn read_log_bundle(path: String) -> Result<Vec<LogBundleEntry>, String> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bytes = Vec::new();
|
let name = entry.name().to_string();
|
||||||
entry
|
let size = entry.size();
|
||||||
.by_ref()
|
entries.push(read_log_entry(name, &mut entry, size)?);
|
||||||
.take(2 * 1024 * 1024)
|
|
||||||
.read_to_end(&mut bytes)
|
|
||||||
.map_err(|error| format!("Could not read a log entry: {error}"))?;
|
|
||||||
let mut content = String::from_utf8_lossy(&bytes).into_owned();
|
|
||||||
if entry.size() > bytes.len() as u64 {
|
|
||||||
content.push_str("\n… log truncated in the viewer …\n");
|
|
||||||
}
|
|
||||||
entries.push(LogBundleEntry {
|
|
||||||
name: entry.name().to_string(),
|
|
||||||
content,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.sort_by(|a, b| a.name.cmp(&b.name));
|
entries.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
@@ -634,4 +714,31 @@ mod tests {
|
|||||||
drop(current);
|
drop(current);
|
||||||
fs::remove_dir_all(dir).unwrap();
|
fs::remove_dir_all(dir).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn current_session_includes_active_logs() {
|
||||||
|
let dir = temp_dir("current");
|
||||||
|
let logs = Arc::new(LogSet::new(dir.clone()));
|
||||||
|
write_line(&logs, Stream::Launcher, "launcher current\n");
|
||||||
|
write_line(&logs, Stream::Osu, "osu current\n");
|
||||||
|
|
||||||
|
let current = current_log_bundle(&dir).expect("active logs should have a session");
|
||||||
|
assert_eq!(current.name, "Current session");
|
||||||
|
assert_eq!(current.path, dir.to_string_lossy());
|
||||||
|
assert!(current.size > 0);
|
||||||
|
|
||||||
|
let entries = read_current_logs(&dir).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
entries
|
||||||
|
.iter()
|
||||||
|
.map(|entry| entry.name.as_str())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
["launcher.log", "osu.log"]
|
||||||
|
);
|
||||||
|
assert_eq!(entries[0].content, "launcher current\n");
|
||||||
|
assert_eq!(entries[1].content, "osu current\n");
|
||||||
|
|
||||||
|
drop(logs);
|
||||||
|
fs::remove_dir_all(dir).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+50
-67
@@ -4,6 +4,7 @@ use std::sync::Mutex as StdMutex;
|
|||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use tauri::{AppHandle, RunEvent};
|
use tauri::{AppHandle, RunEvent};
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
use tokio::task::JoinHandle;
|
||||||
use tokio::time::{Duration, interval};
|
use tokio::time::{Duration, interval};
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
@@ -57,19 +58,15 @@ enum PresenceCommand {
|
|||||||
IsConnected(oneshot::Sender<bool>),
|
IsConnected(oneshot::Sender<bool>),
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ReconnectResult {
|
|
||||||
Connected(Box<AsyncDiscordIpcClient>),
|
|
||||||
Failed,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PresenceActor {
|
struct PresenceActor {
|
||||||
receiver: mpsc::Receiver<PresenceCommand>,
|
receiver: mpsc::Receiver<PresenceCommand>,
|
||||||
reconnect_rx: mpsc::Receiver<ReconnectResult>,
|
reconnect_rx: mpsc::Receiver<Box<AsyncDiscordIpcClient>>,
|
||||||
reconnect_tx: mpsc::Sender<ReconnectResult>,
|
reconnect_tx: mpsc::Sender<Box<AsyncDiscordIpcClient>>,
|
||||||
|
reconnect_task: Option<JoinHandle<()>>,
|
||||||
client: Option<AsyncDiscordIpcClient>,
|
client: Option<AsyncDiscordIpcClient>,
|
||||||
data: PresenceData,
|
data: PresenceData,
|
||||||
start_timestamp: i64,
|
start_timestamp: i64,
|
||||||
reconnecting: bool,
|
should_connect: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PresenceActor {
|
impl PresenceActor {
|
||||||
@@ -85,10 +82,11 @@ impl PresenceActor {
|
|||||||
receiver,
|
receiver,
|
||||||
reconnect_rx,
|
reconnect_rx,
|
||||||
reconnect_tx,
|
reconnect_tx,
|
||||||
|
reconnect_task: None,
|
||||||
client: None,
|
client: None,
|
||||||
data: PresenceData::default(),
|
data: PresenceData::default(),
|
||||||
start_timestamp: start,
|
start_timestamp: start,
|
||||||
reconnecting: false,
|
should_connect: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,17 +110,12 @@ impl PresenceActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(result) = self.reconnect_rx.recv() => {
|
Some(client) = self.reconnect_rx.recv() => {
|
||||||
self.reconnecting = false;
|
self.reconnect_task = None;
|
||||||
match result {
|
if self.should_connect {
|
||||||
ReconnectResult::Connected(client) => {
|
log::info!(target: "launcher", "Presence: reconnect succeeded");
|
||||||
log::info!(target: "launcher", "Presence: reconnect succeeded");
|
self.client = Some(*client);
|
||||||
self.client = Some(*client);
|
self.push_presence().await;
|
||||||
self.push_presence().await;
|
|
||||||
}
|
|
||||||
ReconnectResult::Failed => {
|
|
||||||
log::warn!(target: "launcher", "Presence: all reconnect attempts exhausted");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,15 +127,19 @@ impl PresenceActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn cmd_connect(&mut self, resp: oneshot::Sender<bool>) {
|
async fn cmd_connect(&mut self, resp: oneshot::Sender<bool>) {
|
||||||
|
self.should_connect = true;
|
||||||
if self.client.is_some() {
|
if self.client.is_some() {
|
||||||
let _ = resp.send(true);
|
let _ = resp.send(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if self.reconnect_task.is_some() {
|
||||||
|
let _ = resp.send(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
match try_connect_once().await {
|
match try_connect_once().await {
|
||||||
Some(client) => {
|
Some(client) => {
|
||||||
self.client = Some(client);
|
self.client = Some(client);
|
||||||
self.reconnecting = false;
|
|
||||||
self.push_presence().await;
|
self.push_presence().await;
|
||||||
let _ = resp.send(true);
|
let _ = resp.send(true);
|
||||||
}
|
}
|
||||||
@@ -158,6 +155,10 @@ impl PresenceActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn cmd_disconnect(&mut self, resp: oneshot::Sender<()>) {
|
async fn cmd_disconnect(&mut self, resp: oneshot::Sender<()>) {
|
||||||
|
self.should_connect = false;
|
||||||
|
if let Some(task) = self.reconnect_task.take() {
|
||||||
|
task.abort();
|
||||||
|
}
|
||||||
if let Some(mut client) = self.client.take() {
|
if let Some(mut client) = self.client.take() {
|
||||||
let _ = client.clear_activity().await;
|
let _ = client.clear_activity().await;
|
||||||
log::info!(target: "launcher", "Presence: disconnected");
|
log::info!(target: "launcher", "Presence: disconnected");
|
||||||
@@ -206,37 +207,37 @@ impl PresenceActor {
|
|||||||
e
|
e
|
||||||
);
|
);
|
||||||
self.client = None;
|
self.client = None;
|
||||||
|
self.should_connect = true;
|
||||||
self.spawn_reconnect_task();
|
self.spawn_reconnect_task();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_reconnect_task(&mut self) {
|
fn spawn_reconnect_task(&mut self) {
|
||||||
if self.reconnecting {
|
if self.reconnect_task.is_some() || !self.should_connect {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.reconnecting = true;
|
|
||||||
|
|
||||||
let tx = self.reconnect_tx.clone();
|
let tx = self.reconnect_tx.clone();
|
||||||
tokio::spawn(async move {
|
let task = tokio::spawn(async move {
|
||||||
const MAX_ATTEMPTS: u32 = 5;
|
let mut attempt: u32 = 0;
|
||||||
for attempt in 1..=MAX_ATTEMPTS {
|
loop {
|
||||||
let delay = Duration::from_secs(5 * attempt as u64);
|
attempt = attempt.saturating_add(1);
|
||||||
|
let delay = Duration::from_secs((5 * u64::from(attempt)).min(30));
|
||||||
log::info!(
|
log::info!(
|
||||||
target: "launcher",
|
target: "launcher",
|
||||||
"Presence: reconnect attempt {}/{} in {:?}…",
|
"Presence: reconnect attempt {} in {:?}…",
|
||||||
attempt,
|
attempt,
|
||||||
MAX_ATTEMPTS,
|
|
||||||
delay
|
delay
|
||||||
);
|
);
|
||||||
tokio::time::sleep(delay).await;
|
tokio::time::sleep(delay).await;
|
||||||
|
|
||||||
if let Some(client) = try_connect_once().await {
|
if let Some(client) = try_connect_once().await {
|
||||||
let _ = tx.send(ReconnectResult::Connected(Box::new(client))).await;
|
let _ = tx.send(Box::new(client)).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _ = tx.send(ReconnectResult::Failed).await;
|
|
||||||
});
|
});
|
||||||
|
self.reconnect_task = Some(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,45 +303,27 @@ pub async fn has_presence() -> bool {
|
|||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn update_activity(
|
pub fn update_activity(
|
||||||
state: Option<&str>,
|
state: &str,
|
||||||
details: Option<&str>,
|
details: &str,
|
||||||
large_image_key: Option<&str>,
|
large_image_key: &str,
|
||||||
large_image_text: Option<&str>,
|
large_image_text: &str,
|
||||||
small_image_key: Option<Option<String>>,
|
small_image_key: Option<String>,
|
||||||
small_image_text: Option<Option<String>>,
|
small_image_text: Option<String>,
|
||||||
button1: Option<Option<PresenceButton>>,
|
button1: Option<PresenceButton>,
|
||||||
button2: Option<Option<PresenceButton>>,
|
button2: Option<PresenceButton>,
|
||||||
show_timestamp: Option<bool>,
|
show_timestamp: bool,
|
||||||
) {
|
) {
|
||||||
let data = {
|
let data = {
|
||||||
let mut guard = PRESENCE_DATA.lock().unwrap();
|
let mut guard = PRESENCE_DATA.lock().unwrap();
|
||||||
if let Some(s) = state {
|
guard.state = state.to_string();
|
||||||
guard.state = s.to_string();
|
guard.details = details.to_string();
|
||||||
}
|
guard.large_image_key = large_image_key.to_string();
|
||||||
if let Some(d) = details {
|
guard.large_image_text = large_image_text.to_string();
|
||||||
guard.details = d.to_string();
|
guard.small_image_key = small_image_key;
|
||||||
}
|
guard.small_image_text = small_image_text;
|
||||||
if let Some(img) = large_image_key {
|
guard.dynamic_button = button1;
|
||||||
guard.large_image_key = img.to_string();
|
guard.secondary_button = button2;
|
||||||
}
|
guard.show_timestamp = show_timestamp;
|
||||||
if let Some(txt) = large_image_text {
|
|
||||||
guard.large_image_text = txt.to_string();
|
|
||||||
}
|
|
||||||
if let Some(key) = small_image_key {
|
|
||||||
guard.small_image_key = key;
|
|
||||||
}
|
|
||||||
if let Some(text) = small_image_text {
|
|
||||||
guard.small_image_text = text;
|
|
||||||
}
|
|
||||||
if let Some(b1) = button1 {
|
|
||||||
guard.dynamic_button = b1;
|
|
||||||
}
|
|
||||||
if let Some(b2) = button2 {
|
|
||||||
guard.secondary_button = b2;
|
|
||||||
}
|
|
||||||
if let Some(ts) = show_timestamp {
|
|
||||||
guard.show_timestamp = ts;
|
|
||||||
}
|
|
||||||
guard.clone()
|
guard.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-scrollbar {
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-scrollbar::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* Pause continuous visual work while the launcher is hidden or in the background. */
|
/* Pause continuous visual work while the launcher is hidden or in the background. */
|
||||||
main.app-inactive *,
|
main.app-inactive *,
|
||||||
main.app-inactive *::before,
|
main.app-inactive *::before,
|
||||||
|
|||||||
@@ -154,9 +154,9 @@
|
|||||||
<Terminal class="size-4" />
|
<Terminal class="size-4" />
|
||||||
</div>
|
</div>
|
||||||
<div class="min-w-0">
|
<div class="min-w-0">
|
||||||
<h2 id="log-viewer-title" class="text-sm font-semibold">Log bundles</h2>
|
<h2 id="log-viewer-title" class="text-sm font-semibold">Logs</h2>
|
||||||
<p class="truncate text-[10px] text-muted-foreground">
|
<p class="truncate text-[10px] text-muted-foreground">
|
||||||
Launcher, osu! and patcher output, grouped by session
|
Current session plus archived launcher, osu! and patcher output
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
<div
|
<div
|
||||||
class="flex shrink-0 items-center justify-between border-b border-theme-800 px-3 py-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground"
|
class="flex shrink-0 items-center justify-between border-b border-theme-800 px-3 py-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground"
|
||||||
>
|
>
|
||||||
<span>Bundles</span>
|
<span>Sessions</span>
|
||||||
<span>{bundles.length}</span>
|
<span>{bundles.length}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="min-h-0 flex-1 overflow-y-auto p-1.5">
|
<div class="min-h-0 flex-1 overflow-y-auto p-1.5">
|
||||||
@@ -202,8 +202,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else if bundles.length === 0}
|
{:else if bundles.length === 0}
|
||||||
<div class="p-3 text-[11px] leading-relaxed text-muted-foreground">
|
<div class="p-3 text-[11px] leading-relaxed text-muted-foreground">
|
||||||
No bundles yet. Logs are zipped on the next launcher restart or when a log reaches 5
|
No logs yet. The current session appears once the launcher writes its first line;
|
||||||
MiB.
|
archived bundles are created when logs rotate.
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#each bundles as bundle (bundle.path)}
|
{#each bundles as bundle (bundle.path)}
|
||||||
@@ -291,14 +291,14 @@
|
|||||||
class="flex h-full items-center justify-center gap-2 text-xs text-muted-foreground"
|
class="flex h-full items-center justify-center gap-2 text-xs text-muted-foreground"
|
||||||
>
|
>
|
||||||
<LoaderCircle class="size-4 animate-spin" />
|
<LoaderCircle class="size-4 animate-spin" />
|
||||||
Reading bundle…
|
Reading logs…
|
||||||
</div>
|
</div>
|
||||||
{:else if !selectedBundle}
|
{:else if !selectedBundle}
|
||||||
<div
|
<div
|
||||||
class="flex h-full flex-col items-center justify-center gap-2 text-center text-muted-foreground"
|
class="flex h-full flex-col items-center justify-center gap-2 text-center text-muted-foreground"
|
||||||
>
|
>
|
||||||
<Terminal class="size-8 opacity-40" />
|
<Terminal class="size-8 opacity-40" />
|
||||||
<p class="text-xs">Choose a log bundle to inspect it.</p>
|
<p class="text-xs">Choose a log session to inspect it.</p>
|
||||||
</div>
|
</div>
|
||||||
{:else if filteredLines.length === 0}
|
{:else if filteredLines.length === 0}
|
||||||
<div
|
<div
|
||||||
@@ -328,7 +328,7 @@
|
|||||||
<span>
|
<span>
|
||||||
{selectedBundle
|
{selectedBundle
|
||||||
? `${selectedBundle.name} · ${formatBytes(selectedBundle.size)}`
|
? `${selectedBundle.name} · ${formatBytes(selectedBundle.size)}`
|
||||||
: 'No bundle selected'}
|
: 'No session selected'}
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -12,13 +12,11 @@
|
|||||||
DISCORD_PRESENCE_PRESETS,
|
DISCORD_PRESENCE_PRESETS,
|
||||||
interpolatePresenceString,
|
interpolatePresenceString,
|
||||||
loadDiscordPresenceConfig,
|
loadDiscordPresenceConfig,
|
||||||
pushIdlePresenceFromConfig,
|
|
||||||
saveDiscordPresenceConfig,
|
saveDiscordPresenceConfig,
|
||||||
type DiscordPresenceConfig,
|
type DiscordPresenceConfig,
|
||||||
type PresenceVariableContext,
|
type PresenceVariableContext,
|
||||||
} from '$lib/discordPresenceConfig';
|
} from '$lib/discordPresenceConfig';
|
||||||
import { discordPresence, launcherVersion } from '$lib/global';
|
import { discordPresence, launcherVersion } from '$lib/global';
|
||||||
import * as presence from '$lib/presence';
|
|
||||||
import { currentUser } from '$lib/userAuthentication';
|
import { currentUser } from '$lib/userAuthentication';
|
||||||
import {
|
import {
|
||||||
Check,
|
Check,
|
||||||
@@ -206,10 +204,14 @@
|
|||||||
user?: Parameters<typeof currentUser.set>[0];
|
user?: Parameters<typeof currentUser.set>[0];
|
||||||
info?: Parameters<typeof currentUserInfo.set>[0];
|
info?: Parameters<typeof currentUserInfo.set>[0];
|
||||||
launcherVersion?: string;
|
launcherVersion?: string;
|
||||||
|
discordPresence?: boolean;
|
||||||
}>('sync-theme-editor-global-data', (event) => {
|
}>('sync-theme-editor-global-data', (event) => {
|
||||||
if (event.payload?.user) currentUser.set(event.payload.user);
|
if (event.payload?.user) currentUser.set(event.payload.user);
|
||||||
if (event.payload?.info) currentUserInfo.set(event.payload.info);
|
if (event.payload?.info) currentUserInfo.set(event.payload.info);
|
||||||
if (event.payload?.launcherVersion) launcherVersion.set(event.payload.launcherVersion);
|
if (event.payload?.launcherVersion) launcherVersion.set(event.payload.launcherVersion);
|
||||||
|
if (typeof event.payload?.discordPresence === 'boolean') {
|
||||||
|
discordPresence.set(event.payload.discordPresence);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
await emit('request-theme-editor-global-data');
|
await emit('request-theme-editor-global-data');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -469,18 +471,9 @@
|
|||||||
try {
|
try {
|
||||||
await saveDiscordPresenceConfig(workingConfig);
|
await saveDiscordPresenceConfig(workingConfig);
|
||||||
initialConfigJson = JSON.stringify(workingConfig);
|
initialConfigJson = JSON.stringify(workingConfig);
|
||||||
if ($discordPresence && (await presence.isConnected())) {
|
// The main window owns the live player stats and its presence config
|
||||||
await pushIdlePresenceFromConfig(
|
// store, so let it refresh and push the updated activity immediately.
|
||||||
{
|
await emit('discord-presence-config-saved');
|
||||||
user: $currentUser,
|
|
||||||
version: $launcherVersion || undefined,
|
|
||||||
rank: simRank,
|
|
||||||
pp: simPp,
|
|
||||||
accuracy: simAccuracy,
|
|
||||||
},
|
|
||||||
workingConfig
|
|
||||||
);
|
|
||||||
}
|
|
||||||
sileo.success({ title: 'Discord Rich Presence Saved', description: 'Activity updated' });
|
sileo.success({ title: 'Discord Rich Presence Saved', description: 'Activity updated' });
|
||||||
await handleClose();
|
await handleClose();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -247,6 +247,8 @@ export type IdlePresenceParams = {
|
|||||||
rank?: number | string;
|
rank?: number | string;
|
||||||
pp?: number | string;
|
pp?: number | string;
|
||||||
accuracy?: number | string;
|
accuracy?: number | string;
|
||||||
|
mode?: string;
|
||||||
|
action?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PlayingPresenceParams = {
|
export type PlayingPresenceParams = {
|
||||||
@@ -282,6 +284,8 @@ export const pushIdlePresenceFromConfig = async (
|
|||||||
rank: params?.rank,
|
rank: params?.rank,
|
||||||
pp: params?.pp,
|
pp: params?.pp,
|
||||||
accuracy: params?.accuracy,
|
accuracy: params?.accuracy,
|
||||||
|
mode: params?.mode,
|
||||||
|
action: params?.action ?? 'In Launcher',
|
||||||
version: params?.version,
|
version: params?.version,
|
||||||
profileUrl: params?.user?.id ? `https://ez-pp.farm/u/${params.user.id}` : 'https://ez-pp.farm',
|
profileUrl: params?.user?.id ? `https://ez-pp.farm/u/${params.user.id}` : 'https://ez-pp.farm',
|
||||||
};
|
};
|
||||||
|
|||||||
+9
-9
@@ -6,15 +6,15 @@ export type PresenceButtonPayload = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type PresenceActivityPayload = {
|
export type PresenceActivityPayload = {
|
||||||
state?: string;
|
state: string;
|
||||||
details?: string;
|
details: string;
|
||||||
largeImageKey?: string;
|
largeImageKey: string;
|
||||||
largeImageText?: string;
|
largeImageText: string;
|
||||||
smallImageKey?: string | null;
|
smallImageKey: string | null;
|
||||||
smallImageText?: string | null;
|
smallImageText: string | null;
|
||||||
button1?: PresenceButtonPayload | null;
|
button1: PresenceButtonPayload | null;
|
||||||
button2?: PresenceButtonPayload | null;
|
button2: PresenceButtonPayload | null;
|
||||||
showTimestamp?: boolean;
|
showTimestamp: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const connect = async () => await invoke('presence_connect');
|
export const connect = async () => await invoke('presence_connect');
|
||||||
|
|||||||
@@ -248,6 +248,7 @@
|
|||||||
osuStream: get(osuStream),
|
osuStream: get(osuStream),
|
||||||
serverPing: get(serverPing),
|
serverPing: get(serverPing),
|
||||||
launcherVersion: get(launcherVersion),
|
launcherVersion: get(launcherVersion),
|
||||||
|
discordPresence: get(discordPresence),
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
};
|
};
|
||||||
|
|||||||
+53
-22
@@ -21,6 +21,7 @@
|
|||||||
import { config } from '$lib/config';
|
import { config } from '$lib/config';
|
||||||
import { currentUserInfo } from '$lib/data';
|
import { currentUserInfo } from '$lib/data';
|
||||||
import {
|
import {
|
||||||
|
discordPresenceCustomConfig,
|
||||||
loadDiscordPresenceConfig,
|
loadDiscordPresenceConfig,
|
||||||
pushIdlePresenceFromConfig,
|
pushIdlePresenceFromConfig,
|
||||||
pushPlayingPresenceFromConfig,
|
pushPlayingPresenceFromConfig,
|
||||||
@@ -90,7 +91,6 @@
|
|||||||
startOpenTabletDriver,
|
startOpenTabletDriver,
|
||||||
stopOpenTabletDriver,
|
stopOpenTabletDriver,
|
||||||
} from '$lib/osuUtil';
|
} from '$lib/osuUtil';
|
||||||
import * as presence from '$lib/presence';
|
|
||||||
import {
|
import {
|
||||||
downloadAndInstallCommunityTheme,
|
downloadAndInstallCommunityTheme,
|
||||||
fetchCommunityThemeDetails,
|
fetchCommunityThemeDetails,
|
||||||
@@ -297,6 +297,10 @@
|
|||||||
let activeThemesTab = $state<'library' | 'workshop'>('library');
|
let activeThemesTab = $state<'library' | 'workshop'>('library');
|
||||||
let themeSavedUnlisten: (() => void) | undefined;
|
let themeSavedUnlisten: (() => void) | undefined;
|
||||||
let themePublishedUnlisten: (() => void) | undefined;
|
let themePublishedUnlisten: (() => void) | undefined;
|
||||||
|
let presenceConfigUnlisten: (() => void) | undefined;
|
||||||
|
let presenceConfigReady = $state(false);
|
||||||
|
let idlePresenceTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
let lastIdlePresenceSignature = '';
|
||||||
let refreshingThemes = $state(false);
|
let refreshingThemes = $state(false);
|
||||||
let reloadingActiveTheme = $state(false);
|
let reloadingActiveTheme = $state(false);
|
||||||
let revealedNsfw = $state<string[]>([]);
|
let revealedNsfw = $state<string[]>([]);
|
||||||
@@ -1125,6 +1129,46 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const currentStats = $derived($currentUserInfo?.stats?.[selectedGamemode]);
|
const currentStats = $derived($currentUserInfo?.stats?.[selectedGamemode]);
|
||||||
|
const currentPresenceContext = () => ({
|
||||||
|
rank: currentStats?.rank,
|
||||||
|
pp: currentStats?.pp,
|
||||||
|
accuracy: currentStats ? `${currentStats.acc.toFixed(2)}%` : undefined,
|
||||||
|
mode: getGamemodeName(modeIntToStr(selectedMode), typeIntToStr(selectedType)),
|
||||||
|
action: 'In Launcher',
|
||||||
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (!$discordPresence || !presenceConfigReady || $launching) {
|
||||||
|
lastIdlePresenceSignature = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = $currentUser;
|
||||||
|
const version = $launcherVersion || undefined;
|
||||||
|
const context = currentPresenceContext();
|
||||||
|
const cfg = $discordPresenceCustomConfig;
|
||||||
|
const signature = JSON.stringify({
|
||||||
|
userId: user?.id,
|
||||||
|
username: user?.name,
|
||||||
|
version,
|
||||||
|
context,
|
||||||
|
config: cfg,
|
||||||
|
});
|
||||||
|
if (signature === lastIdlePresenceSignature) return;
|
||||||
|
|
||||||
|
idlePresenceTimer = setTimeout(() => {
|
||||||
|
idlePresenceTimer = undefined;
|
||||||
|
lastIdlePresenceSignature = signature;
|
||||||
|
void pushIdlePresenceFromConfig({ user, version, ...context }, cfg);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (idlePresenceTimer !== undefined) {
|
||||||
|
clearTimeout(idlePresenceTimer);
|
||||||
|
idlePresenceTimer = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
let recentActivityIndex = $state(0);
|
let recentActivityIndex = $state(0);
|
||||||
const userEvents = $derived($currentUserInfo?.events ?? []);
|
const userEvents = $derived($currentUserInfo?.events ?? []);
|
||||||
const safeEventIndex = $derived(
|
const safeEventIndex = $derived(
|
||||||
@@ -1584,9 +1628,7 @@
|
|||||||
let presenceUpdater: number | undefined = undefined;
|
let presenceUpdater: number | undefined = undefined;
|
||||||
const beatmapCoverValidity = new SvelteMap<string, boolean>();
|
const beatmapCoverValidity = new SvelteMap<string, boolean>();
|
||||||
|
|
||||||
const isPresenceConnected = await presence.isConnected();
|
if ($discordPresence) {
|
||||||
|
|
||||||
if ($discordPresence && isPresenceConnected) {
|
|
||||||
let osuDetected = false;
|
let osuDetected = false;
|
||||||
presenceUpdater = window.setInterval(async () => {
|
presenceUpdater = window.setInterval(async () => {
|
||||||
if (!osuDetected) {
|
if (!osuDetected) {
|
||||||
@@ -1709,14 +1751,6 @@
|
|||||||
fadeGlobalVolume(0, $custom_theme_volume, 1500);
|
fadeGlobalVolume(0, $custom_theme_volume, 1500);
|
||||||
if (presenceUpdater) {
|
if (presenceUpdater) {
|
||||||
window.clearInterval(presenceUpdater);
|
window.clearInterval(presenceUpdater);
|
||||||
try {
|
|
||||||
await pushIdlePresenceFromConfig({
|
|
||||||
user: $currentUser,
|
|
||||||
version: $launcherVersion || undefined,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await new Promise((res) => setTimeout(res, 1000));
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
/* await replaceUIFiles(osuPath, true); */
|
/* await replaceUIFiles(osuPath, true); */
|
||||||
@@ -2009,18 +2043,14 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
loadDiscordPresenceConfig().then((cfg) => {
|
loadDiscordPresenceConfig().then(() => {
|
||||||
if ($discordPresence) {
|
presenceConfigReady = true;
|
||||||
pushIdlePresenceFromConfig(
|
|
||||||
{
|
|
||||||
user: $currentUser,
|
|
||||||
version: $launcherVersion || undefined,
|
|
||||||
},
|
|
||||||
cfg
|
|
||||||
).catch(() => {});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listen('discord-presence-config-saved', async () => {
|
||||||
|
await loadDiscordPresenceConfig();
|
||||||
|
}).then((unlisten) => (presenceConfigUnlisten = unlisten));
|
||||||
|
|
||||||
animate(ezppLogo, {
|
animate(ezppLogo, {
|
||||||
opacity: [0, 1],
|
opacity: [0, 1],
|
||||||
scale: [0.95, 1],
|
scale: [0.95, 1],
|
||||||
@@ -2075,6 +2105,7 @@
|
|||||||
window.clearInterval(animateInterval);
|
window.clearInterval(animateInterval);
|
||||||
themeSavedUnlisten?.();
|
themeSavedUnlisten?.();
|
||||||
themePublishedUnlisten?.();
|
themePublishedUnlisten?.();
|
||||||
|
presenceConfigUnlisten?.();
|
||||||
stopThemeScript();
|
stopThemeScript();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user