Skip to content

Commit 834d987

Browse files
committed
Merge branch 'thread_issue'
2 parents b555827 + f3421a7 commit 834d987

30 files changed

+146
-367
lines changed

Cargo.toml

+5-7
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@ semver = { version = "1", features = ["serde"] }
1818
num-derive = "0.4.0"
1919
num-traits = "0.2.15"
2020
walkdir = "2.3.3"
21-
parking_lot = "0.12.1"
22-
once_cell = "1.18.0"
21+
# parking_lot = "0.12.1"
2322
thiserror = "1.0.43"
24-
minreq = { version = "2", features = ["https-native", "json-using-serde"], optional = true }
2523
camino = "1"
2624
# Switch utilities
2725
skyline = { git = "https://github.com/Raytwo/skyline-rs", branch="preview" }
28-
skyline-web = "0.1"
2926
skyline-config = { git = "https://github.com/skyline-rs/skyline-config" }
30-
skyline-communicate = { git = "https://github.com/blu-dev/skyline-communicate" }
3127
# For the updater
3228
zip = { version = "0.6", default-features = false, features = ["deflate"], optional = true }
3329
gh-updater = { git = "https://github.com/blu-dev/gh-updater", default-features = false, features = ["native-tls"], optional = true }
30+
minreq = { version = "2", features = ["https-native", "json-using-serde"], optional = true }
3431
# For offset caching and legacy configuration
3532
toml = "0.5.11"
3633
serde = { version = "1", features = ["derive"] }
@@ -66,7 +63,7 @@ ninput = { git = "https://github.com/blu-dev/ninput" }
6663
# For Offset Searching
6764
lazysimd = { git = "https://github.com/Raytwo/lazysimd" }
6865
config = { path = "crates/config" }
69-
menus = { path = "crates/menus" }
66+
menus = { path = "crates/menus", optional = true }
7067

7168
[patch.crates-io]
7269
nnsdk = { git = "https://github.com/ultimate-research/nnsdk-rs"}
@@ -75,8 +72,9 @@ native-tls = { git = "https://github.com/skyline-rs/rust-native-tls", rev = "f20
7572
crc32fast = { git = "https://github.com/srijs/rust-crc32fast", rev = "e9c65bd" }
7673

7774
[features]
78-
default = ["online"]
75+
default = ["online", "ui"]
7976
online = ["zip", "gh-updater", "minreq"]
77+
ui = ["menus"]
8078

8179
[profile.dev]
8280
panic = "abort"

crates/config/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ skyline-config = { git = "https://github.com/skyline-rs/skyline-config" }
1616
walkdir = "2.3.3"
1717
thiserror = "1.0.43"
1818
semver = { version = "1", features = ["serde"] }
19-
once_cell = "1.18.0"
20-
parking_lot = "0.12.1"
2119
camino = "1"
2220
lazysimd = { git = "https://github.com/Raytwo/lazysimd" }

crates/config/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
#![feature(lazy_cell)]
2+
13
use std::{
24
collections::{HashMap, HashSet},
35
path::PathBuf,
4-
sync::Mutex,
6+
sync::{LazyLock, Mutex, RwLock},
57
};
68

79
use log::info;
8-
use once_cell::sync::Lazy;
9-
use parking_lot::RwLock;
1010
use semver::Version;
1111
use skyline::nn;
1212
use skyline_config::*;
@@ -16,9 +16,8 @@ use walkdir::WalkDir;
1616
use crate::utils::env::get_arcropolis_version;
1717

1818
mod utils;
19-
mod offsets;
2019

21-
pub static GLOBAL_CONFIG: Lazy<Mutex<StorageHolder<ArcStorage>>> = Lazy::new(|| {
20+
pub static GLOBAL_CONFIG: LazyLock<Mutex<StorageHolder<ArcStorage>>> = LazyLock::new(|| {
2221
let mut storage = StorageHolder::new(ArcStorage::new());
2322
let version: Result<Version, _> = storage.get_field("version");
2423

@@ -115,7 +114,7 @@ pub fn skip_title_scene() -> bool {
115114
pub static REGION: RwLock<Region> = RwLock::new(Region::UsEnglish);
116115

117116
pub fn region() -> Region {
118-
*REGION.read()
117+
*REGION.read().unwrap()
119118
}
120119

121120
pub fn logger_level() -> String {

crates/config/src/offsets.rs

-72
This file was deleted.

crates/config/src/utils.rs

+2-123
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use skyline::nn;
22

33
pub mod env {
4-
use once_cell::sync::Lazy;
54
use semver::Version;
6-
use std::str::FromStr;
5+
use std::{str::FromStr, sync::LazyLock};
76

87
use super::*;
98

@@ -13,7 +12,7 @@ pub mod env {
1312
Emulator,
1413
}
1514

16-
static PLATFORM: Lazy<RunEnvironment> = Lazy::new(|| {
15+
static PLATFORM: LazyLock<RunEnvironment> = LazyLock::new(|| {
1716
let base_addr = unsafe { skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as u64 };
1817

1918
if base_addr == 0x8004000 || base_addr == 0x8504000 {
@@ -79,123 +78,3 @@ pub mod paths {
7978
Utf8PathBuf::from("sd:/ultimate/arcropolis/cache").join(get_game_version().to_string())
8079
}
8180
}
82-
83-
pub mod save {
84-
use super::*;
85-
use smash_arc::Region;
86-
use std::io::{Read, Result, Seek, SeekFrom};
87-
88-
#[repr(u8)]
89-
#[derive(Debug)]
90-
pub enum SaveLanguageId {
91-
Japanese = 0,
92-
English,
93-
French,
94-
Spanish,
95-
German,
96-
Italian,
97-
Dutch,
98-
Russian,
99-
Chinese,
100-
Taiwanese,
101-
Korean,
102-
}
103-
104-
impl From<u8> for SaveLanguageId {
105-
fn from(byte: u8) -> Self {
106-
match byte {
107-
0 => Self::Japanese,
108-
1 => Self::English,
109-
2 => Self::French,
110-
3 => Self::Spanish,
111-
4 => Self::German,
112-
5 => Self::Italian,
113-
6 => Self::Dutch,
114-
7 => Self::Russian,
115-
8 => Self::Chinese,
116-
9 => Self::Taiwanese,
117-
10 => Self::Korean,
118-
_ => Self::English,
119-
}
120-
}
121-
}
122-
123-
pub fn mount_save(mount_path: &str) {
124-
// TODO: Call nn::fs::CheckMountName
125-
// This provides a UserHandle and sets the User in a Open state to be used.
126-
let handle = nn::account::try_open_preselected_user().expect("OpenPreselectedUser should not return false");
127-
// Obtain the UID for this user
128-
let uid = nn::account::get_user_id(&handle).expect("GetUserId should return a valid Uid");
129-
130-
unsafe { nn::fs::MountSaveData(skyline::c_str(&format!("{}\0", mount_path)), &uid) };
131-
132-
// This closes the UserHandle, making it unusable, and sets the User in a Closed state.
133-
// Smash will crash if you don't do it.
134-
nn::account::close_user(handle);
135-
}
136-
137-
pub fn unmount_save(mount_path: &str) {
138-
// TODO: Call nn::fs::CheckMountName
139-
unsafe { nn::fs::Unmount(skyline::c_str(&format!("{}\0", mount_path))) };
140-
}
141-
142-
pub fn get_language_id_in_savedata() -> Result<SaveLanguageId> {
143-
let mut file = std::fs::File::open("save:/save_data/system_data.bin")?;
144-
file.seek(SeekFrom::Start(0x3c6098)).unwrap();
145-
let mut language_code = [0u8];
146-
file.read_exact(&mut language_code).unwrap();
147-
drop(file);
148-
149-
Ok(SaveLanguageId::from(language_code[0]))
150-
}
151-
152-
// pub fn get_system_region_from_language_id(language: SaveLanguageId) -> Region {
153-
// let system_locale_id = unsafe { *(skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *const u8).add(crate::offsets::system_locale_id()) };
154-
155-
// // let system_region_map = unsafe {
156-
// // std::slice::from_raw_parts(
157-
// // (skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *const u32).add(0x4740f90 / 4),
158-
// // 14,
159-
// // )
160-
// // };
161-
162-
// let system_region_map: &[u32] = &[0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4];
163-
164-
// let system_region = system_region_map[system_locale_id as usize];
165-
166-
// match language {
167-
// SaveLanguageId::Japanese => Region::Japanese,
168-
// SaveLanguageId::English => {
169-
// if system_region == 1 {
170-
// // US
171-
// Region::UsEnglish
172-
// } else {
173-
// Region::EuEnglish
174-
// }
175-
// },
176-
// SaveLanguageId::French => {
177-
// if system_region == 1 {
178-
// // US
179-
// Region::UsFrench
180-
// } else {
181-
// Region::EuFrench
182-
// }
183-
// },
184-
// SaveLanguageId::Spanish => {
185-
// if system_region == 1 {
186-
// // US
187-
// Region::UsSpanish
188-
// } else {
189-
// Region::EuSpanish
190-
// }
191-
// },
192-
// SaveLanguageId::German => Region::EuGerman,
193-
// SaveLanguageId::Dutch => Region::EuDutch,
194-
// SaveLanguageId::Italian => Region::EuItalian,
195-
// SaveLanguageId::Russian => Region::EuRussian,
196-
// SaveLanguageId::Chinese => Region::ChinaChinese,
197-
// SaveLanguageId::Taiwanese => Region::TaiwanChinese,
198-
// SaveLanguageId::Korean => Region::Korean,
199-
// }
200-
// }
201-
}

crates/menus/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ smash-arc = { git = "https://github.com/jam1garner/smash-arc" }
1616
skyline = { git = "https://github.com/Raytwo/skyline-rs", branch="preview" }
1717
config = { path = "../config" }
1818
semver = { version = "1", features = ["serde"] }
19-
once_cell = "1.18.0"
20-
parking_lot = "0.12.1"
2119
camino = "1"
2220
minreq = { version = "2", features = ["https-native", "json-using-serde"] }
2321

crates/menus/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(lazy_cell)]
2+
13
pub mod arcadia;
24
pub use arcadia::*;
35
pub mod workspaces;

crates/menus/src/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use skyline::nn;
22

33
pub mod env {
4-
use once_cell::sync::Lazy;
54
use semver::Version;
65
use std::str::FromStr;
6+
use std::sync::LazyLock;
77

88
use super::*;
99

@@ -13,7 +13,7 @@ pub mod env {
1313
Emulator,
1414
}
1515

16-
static PLATFORM: Lazy<RunEnvironment> = Lazy::new(|| {
16+
static PLATFORM: LazyLock<RunEnvironment> = LazyLock::new(|| {
1717
let base_addr = unsafe { skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as u64 };
1818

1919
if base_addr == 0x8004000 || base_addr == 0x8504000 {

src/api.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ pub extern "C" fn arcrop_api_version() -> &'static ApiVersion {
3333
&API_VERSION
3434
}
3535

36-
pub fn show_dialog(text: &str) {
37-
skyline_web::DialogOk::ok(text);
38-
}
39-
4036
#[no_mangle]
4137
pub extern "C" fn arcrop_require_api_version(major: u32, minor: u32) {
4238
if major > API_VERSION.major || (major == API_VERSION.major && minor > API_VERSION.minor) {
@@ -47,13 +43,13 @@ pub extern "C" fn arcrop_require_api_version(major: u32, minor: u32) {
4743
}
4844

4945
fn show_arcrop_update_prompt() -> ! {
50-
show_dialog("Your ARCropolis version is older than one of your plugins supports, an update is required");
46+
skyline::error::show_error(69, "ARCropolis API error, press Details.\0", "Your ARCropolis version is older than one of your plugins supports, an update is required");
5147

5248
unsafe { skyline::nn::oe::ExitApplication() }
5349
}
5450

5551
fn show_plugin_update_prompt() -> ! {
56-
show_dialog("Your ARCropolis version is too new for one of your plugins, it must be updated to support this API version");
52+
skyline::error::show_error(69, "ARCropolis API error, press Details.\0", "Your ARCropolis version is too new for one of your plugins, it must be updated to support this API version");
5753

5854
unsafe { skyline::nn::oe::ExitApplication() }
5955
}

0 commit comments

Comments
 (0)