chore: update version to 3.2.7 and refactor skin handling functions
This commit is contained in:
Generated
+1
-1
@@ -1239,7 +1239,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ezpplauncher"
|
||||
version = "3.2.5"
|
||||
version = "3.2.7"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"anyhow",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ezpplauncher"
|
||||
version = "3.2.5"
|
||||
version = "3.2.7"
|
||||
description = "EZPPLauncher redefined."
|
||||
authors = ["HorizonCode"]
|
||||
edition = "2024"
|
||||
|
||||
+12
-78
@@ -186,75 +186,6 @@ pub async fn get_beatmapsets_count(folder: String) -> Option<u64> {
|
||||
Some(beatmap_sets as u64)
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SkinInfo {
|
||||
pub name: String,
|
||||
pub author: Option<String>,
|
||||
pub modified: u64,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_skins(folder: String) -> Option<Vec<SkinInfo>> {
|
||||
use std::path::PathBuf;
|
||||
use std::time::UNIX_EPOCH;
|
||||
use tokio::fs;
|
||||
|
||||
let skins_folder = PathBuf::from(folder).join("Skins");
|
||||
|
||||
if !skins_folder.exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut entries = fs::read_dir(skins_folder).await.ok()?;
|
||||
|
||||
let mut skins = Vec::new();
|
||||
|
||||
while let Some(entry) = entries.next_entry().await.ok()? {
|
||||
if !entry.file_type().await.ok()?.is_dir() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let dir_path = entry.path();
|
||||
let skin_ini = dir_path.join("skin.ini");
|
||||
|
||||
if !skin_ini.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name = entry.file_name().to_string_lossy().to_string();
|
||||
|
||||
let author = fs::read_to_string(&skin_ini)
|
||||
.await
|
||||
.ok()
|
||||
.and_then(|content| {
|
||||
content.lines().find_map(|line| {
|
||||
let (key, value) = line.split_once(':')?;
|
||||
key.trim()
|
||||
.eq_ignore_ascii_case("Author")
|
||||
.then(|| value.trim().to_string())
|
||||
})
|
||||
});
|
||||
|
||||
let modified = entry
|
||||
.metadata()
|
||||
.await
|
||||
.ok()
|
||||
.and_then(|m| m.modified().ok())
|
||||
.and_then(|t| t.duration_since(UNIX_EPOCH).ok())
|
||||
.map(|d| d.as_secs())
|
||||
.unwrap_or(0);
|
||||
|
||||
skins.push(SkinInfo {
|
||||
name,
|
||||
author,
|
||||
modified,
|
||||
});
|
||||
}
|
||||
|
||||
Some(skins)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_skins_count(folder: String) -> Option<u64> {
|
||||
let path = PathBuf::from(folder);
|
||||
@@ -267,20 +198,23 @@ pub async fn get_skins_count(folder: String) -> Option<u64> {
|
||||
let mut count = 0;
|
||||
if let Ok(mut entries) = fs::read_dir(skins_folder).await {
|
||||
while let Ok(Some(entry)) = entries.next_entry().await {
|
||||
if entry.file_type().await.map_or(false, |ft| ft.is_dir()) {
|
||||
let dir_path = entry.path();
|
||||
if let Ok(mut files) = fs::read_dir(&dir_path).await {
|
||||
while let Ok(Some(file)) = files.next_entry().await {
|
||||
if file.path().extension().map_or(false, |ext| ext == "ini") {
|
||||
count += 1;
|
||||
break;
|
||||
}
|
||||
if let Ok(ft) = entry.file_type().await {
|
||||
if ft.is_dir() {
|
||||
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
|
||||
.unwrap_or(false);
|
||||
if has_ini {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Some(count);
|
||||
Some(count)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
@@ -18,13 +18,13 @@ use crate::{
|
||||
download_ezpp_launcher_update_files, encrypt_string, exit, extract_theme,
|
||||
find_osu_installation, get_beatmapsets_count, get_ezpp_launcher_update_files, get_hwid,
|
||||
get_launcher_version, get_osu_release_stream, get_osu_skin, get_osu_version, get_platform,
|
||||
get_skins, get_skins_count, has_net8, has_osuwinello, has_wmctrl,
|
||||
install_ezpp_launcher_update, is_open_tablet_driver_path_valid,
|
||||
is_open_tablet_driver_running, is_osu_running, open_url_in_browser, opened_urls,
|
||||
presence_connect, presence_disconnect, presence_is_connected, presence_update_button,
|
||||
presence_update_status, presence_update_user, read_theme_info, replace_ui_files,
|
||||
run_open_tablet_driver, run_osu, run_osu_updater, set_osu_config_values,
|
||||
set_osu_user_config_values, stop_open_tablet_driver, valid_osu_folder,
|
||||
get_skins_count, has_net8, has_osuwinello, has_wmctrl, install_ezpp_launcher_update,
|
||||
is_open_tablet_driver_path_valid, is_open_tablet_driver_running, is_osu_running,
|
||||
open_url_in_browser, opened_urls, presence_connect, presence_disconnect,
|
||||
presence_is_connected, presence_update_button, presence_update_status,
|
||||
presence_update_user, read_theme_info, replace_ui_files, run_open_tablet_driver, run_osu,
|
||||
run_osu_updater, set_osu_config_values, set_osu_user_config_values,
|
||||
stop_open_tablet_driver, valid_osu_folder,
|
||||
},
|
||||
state::AppState,
|
||||
};
|
||||
@@ -107,7 +107,6 @@ pub fn run() {
|
||||
find_osu_installation,
|
||||
valid_osu_folder,
|
||||
get_beatmapsets_count,
|
||||
get_skins,
|
||||
get_skins_count,
|
||||
get_osu_version,
|
||||
get_osu_release_stream,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "EZPPLauncher",
|
||||
"version": "3.2.5",
|
||||
"version": "3.2.7",
|
||||
"identifier": "farm.EZPPFarm.Launcher",
|
||||
"mainBinaryName": "ezpplauncher",
|
||||
"build": {
|
||||
|
||||
Reference in New Issue
Block a user