From 86033e2d6a10345f76138cf109226e0d8e27774c Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 14 Jul 2025 19:39:37 +0200 Subject: [PATCH] chore: add patch stream selection --- src-tauri/src/commands.rs | 2 ++ src/lib/global.ts | 3 +++ src/lib/osuUtil.ts | 23 ++++++++++++++++++++--- src/pages/Launch.svelte | 39 ++++++++++++++++++++++++++++++++++++++- src/pages/Loading.svelte | 11 +++++++++++ 5 files changed, 74 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 3ae752c..edff056 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -444,6 +444,7 @@ pub struct UpdateFile { pub async fn get_ezpp_launcher_update_files( folder: String, update_url: String, + update_stream: String ) -> Result<(Vec, Vec), String> { let osu_path = PathBuf::from(folder); let client = Client::new(); @@ -451,6 +452,7 @@ pub async fn get_ezpp_launcher_update_files( let update_files = client .patch(update_url) .header("User-Agent", "EZPPLauncher") + .query(&[("stream", update_stream)]) .send() .await .map_err(|e| e.to_string())? diff --git a/src/lib/global.ts b/src/lib/global.ts index 382b02e..5305896 100644 --- a/src/lib/global.ts +++ b/src/lib/global.ts @@ -9,6 +9,9 @@ export const currentView = writable(Loading); export const launcherVersion = writable(''); export const newVersion = writable(undefined); +export const launcherStreams = writable(['stable']); +export const launcherStream = writable('stable'); + export const discordPresence = writable(false); export const presenceLoading = writable(false); diff --git a/src/lib/osuUtil.ts b/src/lib/osuUtil.ts index c9a85f3..3a9d394 100644 --- a/src/lib/osuUtil.ts +++ b/src/lib/osuUtil.ts @@ -1,8 +1,9 @@ import { invoke } from '@tauri-apps/api/core'; import type { UpdateFile, UpdateStatus } from './types'; 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 () => { 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) => await invoke('run_osu', { folder, patch }); -export const getEZPPLauncherUpdateFiles = async (folder: string) => { - const result = await invoke('get_ezpp_launcher_update_files', { folder, updateUrl }); +export const getEZPPLauncherStreams = async () => { + 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') { const [filesToDownload, updateFiles] = result as [UpdateFile[], UpdateFile[]]; return { diff --git a/src/pages/Launch.svelte b/src/pages/Launch.svelte index b1648cd..bc876fb 100644 --- a/src/pages/Launch.svelte +++ b/src/pages/Launch.svelte @@ -9,6 +9,8 @@ currentSkin, currentView, discordPresence, + launcherStream, + launcherStreams, launcherVersion, launching, newVersion, @@ -186,7 +188,7 @@ try { launchInfo = 'Looking for EZPPLauncher File updates...'; - const updateResult = await getEZPPLauncherUpdateFiles(osuPath); + const updateResult = await getEZPPLauncherUpdateFiles(osuPath, $launcherStream); if (updateResult) { if (updateResult.filesToDownload.length > 0) { @@ -1135,6 +1137,41 @@ onclick={browse_osu_installation}>Browse + +
+ +
+ test different versions of the patcher +
+
+
+ { + $userSettings.value('patcherStream').set(newStream); + launcherStream.set(newStream); + await $userSettings.save(); + }} + > + +
+ {$launcherStream} +
+
+ + {#each $launcherStreams as stream (stream)} + +
+ {stream} +
+
+ {/each} +
+
+
diff --git a/src/pages/Loading.svelte b/src/pages/Loading.svelte index 336de0b..d22d45b 100644 --- a/src/pages/Loading.svelte +++ b/src/pages/Loading.svelte @@ -7,6 +7,8 @@ currentSkin, currentView, firstStartup, + launcherStream, + launcherStreams, launcherVersion, newVersion, osuBuild, @@ -30,6 +32,7 @@ import { currentUserInfo } from '@/data'; import { getBeatmapSetsCount, + getEZPPLauncherStreams, getReleaseStream, getSkin, getSkinsCount, @@ -148,6 +151,14 @@ 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, { opacity: [1, 0], scale: [1, 1.05],