Browse Source

Finish MiiSelector applet documentation

pull/134/head
Andrea Ciliberti 1 year ago
parent
commit
fafe3c3dbf
  1. 2
      ctru-rs/examples/mii-selector.rs
  2. 26
      ctru-rs/src/applets/mii_selector.rs

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

@ -10,7 +10,7 @@ fn main() {
let _console = Console::new(gfx.top_screen.borrow_mut()); let _console = Console::new(gfx.top_screen.borrow_mut());
let mut mii_selector = MiiSelector::new(); let mut mii_selector = MiiSelector::new();
mii_selector.set_options(Options::MII_SELECTOR_CANCEL); mii_selector.set_options(Options::ENABLE_CANCEL);
mii_selector.set_initial_index(3); mii_selector.set_initial_index(3);
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!");

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

@ -5,9 +5,9 @@
use crate::mii::MiiData; use crate::mii::MiiData;
use bitflags::bitflags; use bitflags::bitflags;
use std::{ffi::CString, error::Error, fmt}; use std::{error::Error, ffi::CString, fmt};
/// Index of a Mii used to configure some parameters of the Mii Selector. /// Index of a Mii on the Mii Selector interface.
#[derive(Debug, Clone, Copy, Eq, PartialEq)] #[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Index { pub enum Index {
/// Specific Mii index. /// Specific Mii index.
@ -32,21 +32,21 @@ pub enum MiiType {
bitflags! { bitflags! {
/// Options to configure the [MiiSelector]. /// Options to configure the [MiiSelector].
/// ///
/// <h1>Example</h1> /// <h1>Example</h1>
/// ///
/// ```no_run /// ```no_run
/// # use std::error::Error; /// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> { /// # fn main() -> Result<(), Box<dyn Error>> {
/// # /// #
/// use ctru::applets::mii_selector::{MiiSelector, Options}; /// use ctru::applets::mii_selector::{MiiSelector, Options};
/// ///
/// // Setup a `MiiSelector` that can be cancelled and that makes Guest Miis available to select. /// // Setup a `MiiSelector` that can be cancelled and that makes Guest Miis available to select.
/// let opts = Options::ENABLE_CANCEL & Options::ENABLE_GUESTS; /// let opts = Options::ENABLE_CANCEL & Options::ENABLE_GUESTS;
/// ///
/// let mut mii_selector = MiiSelector::new(); /// let mut mii_selector = MiiSelector::new();
/// mii_selector.set_options(opts); /// mii_selector.set_options(opts);
/// ///
/// let result = mii_selector.launch()?; /// let result = mii_selector.launch()?;
/// # /// #
/// # Ok(()) /// # Ok(())
@ -58,14 +58,14 @@ bitflags! {
const ENABLE_CANCEL = ctru_sys::MIISELECTOR_CANCEL; const ENABLE_CANCEL = ctru_sys::MIISELECTOR_CANCEL;
/// Make guest Miis available to select. /// Make guest Miis available to select.
const ENABLE_GUESTS = ctru_sys::MIISELECTOR_GUESTS; const ENABLE_GUESTS = ctru_sys::MIISELECTOR_GUESTS;
/// Show on the top screen. /// Show the Mii Selector window on the top screen.
const USE_TOP_SCREEN = ctru_sys::MIISELECTOR_TOP; const USE_TOP_SCREEN = ctru_sys::MIISELECTOR_TOP;
/// Start on the guests' page. Requires [Options::ENABLE_GUESTS]. /// Start the Mii Selector on the guests' page. Requires [Options::ENABLE_GUESTS].
const START_WITH_GUESTS = ctru_sys::MIISELECTOR_GUESTSTART; const START_WITH_GUESTS = ctru_sys::MIISELECTOR_GUESTSTART;
} }
} }
/// Configuration object to setup the Mii Selector applet. /// Configuration structure to setup the Mii Selector applet.
/// ///
/// # Example /// # Example
/// ```no_run /// ```no_run
@ -132,7 +132,7 @@ impl MiiSelector {
} }
/// Set the options of the Mii Selector. /// Set the options of the Mii Selector.
/// ///
/// This will overwrite any previously saved options. /// This will overwrite any previously saved options.
#[doc(alias = "miiSelectorSetOptions")] #[doc(alias = "miiSelectorSetOptions")]
pub fn set_options(&mut self, options: Options) { pub fn set_options(&mut self, options: Options) {
@ -184,7 +184,7 @@ impl MiiSelector {
} }
/// Set where the cursor will start at. /// Set where the cursor will start at.
/// ///
/// If there's no Mii at that index, the cursor will start at the Mii with the index 0. /// If there's no Mii at that index, the cursor will start at the Mii with the index 0.
pub fn set_initial_index(&mut self, index: usize) { pub fn set_initial_index(&mut self, index: usize) {
// This function is static inline in libctru // This function is static inline in libctru
@ -193,7 +193,7 @@ impl MiiSelector {
} }
/// Launch the Mii Selector. /// Launch the Mii Selector.
/// ///
/// Depending on the configuration, the Mii Selector window will appear either on the bottom screen (default behaviour) or the top screen (see [Options::USE_TOP_SCREEN]). /// Depending on the configuration, the Mii Selector window will appear either on the bottom screen (default behaviour) or the top screen (see [Options::USE_TOP_SCREEN]).
#[doc(alias = "miiSelectorLaunch")] #[doc(alias = "miiSelectorLaunch")]
pub fn launch(&mut self) -> Result<Selection, LaunchError> { pub fn launch(&mut self) -> Result<Selection, LaunchError> {

Loading…
Cancel
Save