diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index f8626c12d..1ee590e4d 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -10,11 +10,9 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" toml = "0.5.11" log = "0.4.19" -smash-arc = { git = "https://github.com/jam1garner/smash-arc" } +smash-arc = { git = "https://github.com/jam1garner/smash-arc", default-features = false} skyline = { git = "https://github.com/Raytwo/skyline-rs", branch="preview" } skyline-config = { git = "https://github.com/skyline-rs/skyline-config" } -walkdir = "2.3.3" thiserror = "1.0.43" semver = { version = "1", features = ["serde"] } camino = "1" -lazysimd = { git = "https://github.com/Raytwo/lazysimd" } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 643cde9dc..cb5f48257 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -11,7 +11,6 @@ use semver::Version; use skyline::nn; use skyline_config::*; use smash_arc::{Hash40, Region}; -use walkdir::WalkDir; use crate::utils::env::get_arcropolis_version; @@ -63,34 +62,6 @@ fn generate_default_config(storage: &mut StorageHolder) - storage.set_field("workspace", "Default") } -fn convert_legacy_to_presets() -> HashSet { - let mut presets: HashSet = HashSet::new(); - - // TODO: Turn this into a map and use Collect - for entry in WalkDir::new(crate::utils::paths::mods()).max_depth(1).into_iter().flatten() { - let path = entry.path(); - - // If the mod isn't disabled, add it to the preset - if path - .file_name() - .and_then(|name| name.to_str()) - .map(|name| !name.starts_with('.')) - .unwrap_or(false) - { - presets.insert(Hash40::from(path.to_str().unwrap())); - } else { - // TODO: Check if the destination already exists, because it'll definitely happen, and when someone opens an issue about it and you'll realize you knew ahead of time, you'll feel dumb. But right this moment, you decided not to do anything. - std::fs::rename( - path, - format!("{}/{}", crate::utils::paths::mods(), &path.file_name().unwrap().to_str().unwrap()[1..]), - ) - .unwrap(); - } - } - - presets -} - pub fn auto_update_enabled() -> bool { GLOBAL_CONFIG.lock().unwrap().get_flag("auto_update") } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index bcdeed621..c9e1b55b0 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -1,48 +1,6 @@ -use skyline::nn; - pub mod env { use semver::Version; - use std::{str::FromStr, sync::LazyLock}; - - use super::*; - - #[non_exhaustive] - pub enum RunEnvironment { - Switch, - Emulator, - } - - static PLATFORM: LazyLock = LazyLock::new(|| { - let base_addr = unsafe { skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as u64 }; - - if base_addr == 0x8004000 || base_addr == 0x8504000 { - RunEnvironment::Emulator - } else { - RunEnvironment::Switch - } - }); - - pub fn get_running_env() -> &'static RunEnvironment { - &PLATFORM - } - - pub fn is_hardware() -> bool { - matches!(get_running_env(), RunEnvironment::Switch) - } - - pub fn is_emulator() -> bool { - matches!(get_running_env(), RunEnvironment::Emulator) - } - - /// Wrapper function for getting the version string of the game from nnSdk - pub fn get_game_version() -> Version { - unsafe { - // TODO: Implement this in nnsdk-rs - let mut version_string = nn::oe::DisplayVersion { name: [0x00; 16] }; - nn::oe::GetDisplayVersion(&mut version_string); - Version::from_str(&skyline::from_c_str(version_string.name.as_ptr())).expect("Smash's version should parse as a proper semver.") - } - } + use std::str::FromStr; pub fn get_arcropolis_version() -> Version { Version::from_str(env!("CARGO_PKG_VERSION")).expect("ARCropolis' version should follow proper semver.") @@ -50,31 +8,9 @@ pub mod env { } pub mod paths { - use super::env::get_game_version; use camino::Utf8PathBuf; - use std::io; - - pub fn ensure_paths_exist() -> io::Result<()> { - std::fs::create_dir_all(mods())?; - std::fs::create_dir_all(config())?; - std::fs::create_dir_all(logs())?; - std::fs::create_dir_all(cache())?; - Ok(()) - } pub fn mods() -> Utf8PathBuf { Utf8PathBuf::from("sd:/ultimate/mods") } - - pub fn config() -> Utf8PathBuf { - Utf8PathBuf::from("sd:/ultimate/arcropolis/config") - } - - pub fn logs() -> Utf8PathBuf { - Utf8PathBuf::from("sd:/ultimate/arcropolis/logs") - } - - pub fn cache() -> Utf8PathBuf { - Utf8PathBuf::from("sd:/ultimate/arcropolis/cache").join(get_game_version().to_string()) - } } diff --git a/src/api.rs b/src/api.rs index 885370348..105142e99 100644 --- a/src/api.rs +++ b/src/api.rs @@ -5,10 +5,6 @@ pub mod utils; pub mod lua; pub use callback::*; -pub use event::*; -pub use file::*; -pub use utils::*; -pub use lua::*; #[repr(C)] pub struct ApiVersion { diff --git a/src/lib.rs b/src/lib.rs index b34b36732..f167e20a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,6 @@ use std::{ collections::HashMap, fmt, io::{BufWriter, Write}, path::{Path, PathBuf}, str::FromStr, sync::{LazyLock, RwLock} }; -use api::file; use arcropolis_api::Event; use log::LevelFilter; use thiserror::Error; diff --git a/src/replacement/addition.rs b/src/replacement/addition.rs index 9790f42d2..b8631c96c 100644 --- a/src/replacement/addition.rs +++ b/src/replacement/addition.rs @@ -636,7 +636,7 @@ pub fn add_dir_info_with_base(ctx: &mut AdditionContext, path: &Path, base: &Pat let base_dir_info = *ctx.get_dir_info_from_hash_ctx(base_dir_info_path.path.hash40()).unwrap(); // Get the newly added dirinfo - let mut dir_info = ctx.get_dir_info_from_hash_ctx_mut(dir_info_path.path.hash40()).unwrap(); + let dir_info = ctx.get_dir_info_from_hash_ctx_mut(dir_info_path.path.hash40()).unwrap(); // Set dir_info values to the base dirinfo dir_info.path.set_index(base_dir_info.path.index());