Browse Source

Improve ``mii-selector`` example and a few fixes

pull/78/head
TechiePi 2 years ago
parent
commit
a9569b5e5a
  1. 17
      ctru-rs/examples/mii-selector.rs
  2. 3
      ctru-rs/src/applets/mii_selector.rs
  3. 2
      ctru-rs/src/mii.rs

17
ctru-rs/examples/mii-selector.rs

@ -14,16 +14,15 @@ fn main() {
mii_selector.blacklist_user_mii(0.into()); mii_selector.blacklist_user_mii(0.into());
mii_selector.set_title("Great Mii Selector!"); mii_selector.set_title("Great Mii Selector!");
let result = mii_selector.launch(); let result = mii_selector.launch().unwrap();
println!("\x1b[0;0HIs Mii selected?: {:?}", result.is_mii_selected); println!("Is Mii selected?: {:?}", result.is_mii_selected);
println!("\x1b[1;0HValid checksum?: {:?}", result.valid_checksum()); println!("Mii type: {:?}", result.mii_type);
println!("\x1b[2;0HMii type: {:?}", result.mii_type); println!("Mii checksum: {:?}", result.checksum);
println!("\x1b[3;0HMii checksum: {:?}", result.checksum); println!("Name: {:?}", result.mii_data.name);
println!("\x1b[4;0HName: {:?}", result.name()); println!("Author: {:?}", result.mii_data.author_name);
println!("\x1b[5;0HAuthor: {:?}", result.author());
println!( println!(
"\x1b[6;0HDoes the Mii have moles?: {:?}", "Does the Mii have moles?: {:?}",
result.mii_data.mole_details.is_enabled result.mii_data.mole_details.is_enabled
); );

3
ctru-rs/src/applets/mii_selector.rs

@ -23,10 +23,12 @@ bitflags! {
} }
} }
#[derive(Clone, Debug)]
pub struct MiiSelector { pub struct MiiSelector {
config: Box<ctru_sys::MiiSelectorConf>, config: Box<ctru_sys::MiiSelectorConf>,
} }
#[derive(Clone, Debug)]
pub struct MiiSelectorReturn { pub struct MiiSelectorReturn {
pub mii_data: MiiData, pub mii_data: MiiData,
pub is_mii_selected: bool, pub is_mii_selected: bool,
@ -34,6 +36,7 @@ pub struct MiiSelectorReturn {
pub checksum: u16, pub checksum: u16,
} }
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MiiLaunchError { pub enum MiiLaunchError {
InvalidChecksum, InvalidChecksum,
} }

2
ctru-rs/src/mii.rs

@ -435,7 +435,7 @@ fn utf16_byte_pairs_to_string(data: &[u8]) -> String {
.map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]])) .map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]]))
.collect::<Vec<u16>>(); .collect::<Vec<u16>>();
String::from_utf16_lossy(raw_utf16_composed.as_slice()) String::from_utf16_lossy(raw_utf16_composed.as_slice()).replace("\0", "")
} }
/// Gets the values from the slice and concatenates them /// Gets the values from the slice and concatenates them

Loading…
Cancel
Save