feat: add osu skin retrieval functionality and integrate into loading and setup processes

This commit is contained in:
HorizonCode 2025-07-04 10:16:51 +02:00
parent 8c5e7ca6f2
commit 41608afae2
6 changed files with 53 additions and 11 deletions

View File

@ -198,6 +198,15 @@ pub fn get_skins_count(folder: String) -> Option<u64> {
return Some(count); return Some(count);
} }
#[tauri::command]
pub fn get_osu_skin(folder: String) -> String {
let path = PathBuf::from(folder);
let osu_user_config = get_osu_user_config(path.clone());
return osu_user_config
.and_then(|config| config.get("Skin").cloned())
.unwrap_or_else(|| "Default".to_string());
}
#[tauri::command] #[tauri::command]
pub fn get_osu_version(folder: String) -> String { pub fn get_osu_version(folder: String) -> String {
let path = PathBuf::from(folder); let path = PathBuf::from(folder);

View File

@ -6,7 +6,7 @@ pub mod utils;
use crate::commands::{ use crate::commands::{
find_osu_installation, get_beatmapsets_count, get_hwid, get_osu_release_stream, find_osu_installation, get_beatmapsets_count, get_hwid, get_osu_release_stream,
get_osu_version, get_skins_count, run_osu, run_osu_updater, set_osu_config_values, get_osu_version, get_skins_count, run_osu, run_osu_updater, set_osu_config_values,
set_osu_user_config_values, valid_osu_folder, set_osu_user_config_values, valid_osu_folder, get_osu_skin
}; };
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
@ -36,6 +36,7 @@ pub fn run() {
set_osu_user_config_values, set_osu_user_config_values,
run_osu_updater, run_osu_updater,
run_osu, run_osu,
get_osu_skin
]) ])
.plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())

View File

@ -22,6 +22,8 @@ export const skins = writable<number | undefined>(undefined);
export const osuStream = writable<string | undefined>(undefined); export const osuStream = writable<string | undefined>(undefined);
export const osuBuild = writable<string | undefined>(undefined); export const osuBuild = writable<string | undefined>(undefined);
export const currentSkin = writable<string>("");
let updateValues = true; let updateValues = true;
launching.subscribe((val) => (updateValues = !val)); launching.subscribe((val) => (updateValues = !val));

View File

@ -6,6 +6,7 @@
import * as Select from '@/components/ui/select'; import * as Select from '@/components/ui/select';
import { import {
beatmapSets, beatmapSets,
currentSkin,
currentView, currentView,
launching, launching,
osuBuild, osuBuild,
@ -121,6 +122,10 @@
if (skinsCount) { if (skinsCount) {
skins.set(skinsCount); skins.set(skinsCount);
} }
const skin: string = await invoke('get_osu_skin', {
folder: $osuInstallationPath,
});
currentSkin.set(skin);
} }
}; };
@ -266,6 +271,11 @@
}); });
if (skinCount) skins.set(skinCount); if (skinCount) skins.set(skinCount);
const skin: string = await invoke('get_osu_skin', {
folder: $osuInstallationPath,
});
currentSkin.set(skin);
launching.set(false); launching.set(false);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
@ -706,6 +716,16 @@
{/if} {/if}
</Badge> </Badge>
</span> </span>
<span class="text-sm text-muted-foreground font-semibold">Skin</span>
<span class="text-sm font-semibold text-end text-theme-50">
<Badge>
{#if $currentSkin}
{$currentSkin}
{:else}
<LoaderCircle class="animate-spin" size={17} />
{/if}
</Badge>
</span>
</div> </div>
</div> </div>
{:else if selectedTab === 'settings'} {:else if selectedTab === 'settings'}

View File

@ -4,6 +4,7 @@
import { import {
beatmapSets, beatmapSets,
currentLoadingInfo, currentLoadingInfo,
currentSkin,
currentView, currentView,
firstStartup, firstStartup,
osuBuild, osuBuild,
@ -136,6 +137,10 @@
folder: $osuInstallationPath, folder: $osuInstallationPath,
}); });
if (skinCount) skins.set(skinCount); if (skinCount) skins.set(skinCount);
const skin: string = await invoke('get_osu_skin', {
folder: $osuInstallationPath,
});
currentSkin.set(skin);
} }
} }

View File

@ -17,7 +17,7 @@
userSettings, userSettings,
} from '@/userSettings'; } from '@/userSettings';
import Label from '@/components/ui/label/label.svelte'; import Label from '@/components/ui/label/label.svelte';
import { beatmapSets, currentView, osuBuild, osuStream, skins } from '@/global'; import { beatmapSets, currentSkin, currentView, osuBuild, osuStream, skins } from '@/global';
import Launch from './Launch.svelte'; import Launch from './Launch.svelte';
import Confetti from 'svelte-confetti'; import Confetti from 'svelte-confetti';
@ -92,6 +92,11 @@
skins.set(skinsCount); skins.set(skinsCount);
} }
const skin: string = await invoke('get_osu_skin', {
folder: $osuInstallationPath,
});
currentSkin.set(skin);
const osuReleaseStream: string = await invoke('get_osu_release_stream', { const osuReleaseStream: string = await invoke('get_osu_release_stream', {
folder: $osuInstallationPath, folder: $osuInstallationPath,
}); });