2 Commits

3 changed files with 54 additions and 4 deletions

View File

@@ -196,7 +196,7 @@ pub fn get_osu_version(folder: String) -> String {
let osu_user_config = get_osu_user_config(path.clone());
return osu_user_config
.and_then(|config| config.get("LastVersion").cloned())
.unwrap_or_else(|| "failed.".to_string());
.unwrap_or_else(|| "failed".to_string());
}
#[tauri::command]

View File

@@ -1,3 +1,5 @@
use std::fs;
use std::io::Write;
use std::path::Path;
pub fn check_folder_completeness<P: AsRef<Path>>(folder_path: P, required_files: &[&str]) -> f32 {
@@ -45,6 +47,53 @@ pub fn get_osu_user_config<P: AsRef<Path>>(
return Some(config_map);
}
pub fn set_osu_user_config_value<P: AsRef<Path>>(
osu_folder_path: P,
key: &str,
value: &str,
) -> std::io::Result<()> {
// Determine the config file path
let current_user = std::env::var("USERNAME").unwrap_or_else(|_| "Admin".to_string());
let osu_config_path = osu_folder_path
.as_ref()
.join(format!("osu!.{}.cfg", current_user));
// Read existing config into a Vec of lines
let mut lines = if osu_config_path.exists() {
fs::read_to_string(&osu_config_path)?
.lines()
.map(|line| line.to_string())
.collect::<Vec<String>>()
} else {
Vec::new()
};
let mut found = false;
for line in lines.iter_mut() {
if let Some((existing_key, _)) = line.split_once(" = ") {
if existing_key.trim() == key {
*line = format!("{} = {}", key, value);
found = true;
break;
}
}
}
// If the key was not found, append it
if !found {
lines.push(format!("{} = {}", key, value));
}
// Write back the file
let mut file = fs::File::create(&osu_config_path)?;
for line in lines {
writeln!(file, "{}", line)?;
}
Ok(())
}
pub fn get_osu_config<P: AsRef<Path>>(
osu_folder_path: P,
) -> Option<std::collections::HashMap<String, String>> {

View File

@@ -13,7 +13,6 @@
let mouseY = $state(0);
let lastMouseX = $state(0);
let lastMouseY = $state(0);
let rotation = $state(0);
let isMouseDown = $state(false);
let isHoveringInteractive = $state(false);
let dragStartX = $state(0);
@@ -51,13 +50,15 @@
const dist = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
if (!applyRotation && isMouseDown && dist > 10) applyRotation = true;
if (!applyRotation && isMouseDown && dist > 80) applyRotation = true;
let newDegrees = (Math.atan2(-deltaX, deltaY) * 180) / Math.PI + 24.3;
let diff = (newDegrees - degrees) % 360;
if (diff < -180) diff += 360;
if (diff > 180) diff -= 360;
if (isMouseDown && applyRotation) {
degrees += diff;
} else {
@@ -99,6 +100,7 @@
? (t - 1) ** 7 + 1
: Math.pow(2, -10 * t) * Math.sin((t - 0.075) * 20.94) + 1 - 0.0005 * t,
});
lastMouseX = mouseX;
lastMouseY = mouseY;
};
@@ -122,7 +124,6 @@
};
const handleMouseUp = () => {
rotation = 0;
isMouseDown = false;
applyRotation = false;
animate(cursorInner, {