pub struct Profile<const ACTIONS: usize, const SCORES: usize> {
pub brightness: Brightness,
pub screen_offset: ScreenOffset,
pub sfx_volume: u8,
pub music_volume: u8,
pub move_deadzone: u8,
pub look_deadzone: u8,
pub look_speed_percent: u8,
pub difficulty: u8,
pub flags: u8,
pub game_bytes: [u8; 8],
pub actions: ActionMap<ACTIONS>,
pub high_scores: [u32; SCORES],
}Expand description
A game profile shared by menus, input and memory-card persistence.
ACTIONS is the number of game-defined logical actions. SCORES is the
number of high-score slots (usually one per difficulty).
Fields§
§brightness: BrightnessPicture brightness: DEFAULT, DARKER 1..=5 or BRIGHTER 1..=5.
screen_offset: ScreenOffsetPicture position on the television, within 16 pixels each way.
sfx_volume: u8Sound-effect volume, 0..=100.
music_volume: u8Music volume, 0..=100.
move_deadzone: u8Left-stick deadzone in raw stick counts.
look_deadzone: u8Right-stick deadzone in raw stick counts.
look_speed_percent: u8Look-speed percentage.
difficulty: u8Game-selected difficulty index.
flags: u8Bit flags: bit 0 is FLAG_INVERT_Y, bits 1 through 7 belong to the
game. Prefer Self::set_game_flag so unrelated bits survive edits.
game_bytes: [u8; 8]Bytes reserved for the game’s own settings, zero by default and stored
verbatim (version 3 onward). The SDK never reads, clamps or interprets
them, so a game must range-check what it loads from its own slots.
Name each slot with a const index in the game, for example
const FOV_BYTE: usize = 0;. A slot a game has not written reads as 0,
including from a version 1 or 2 record, so make 0 mean “default”.
actions: ActionMap<ACTIONS>Logical action bindings.
high_scores: [u32; SCORES]Persistent high-score slots.
Implementations§
Source§impl<const ACTIONS: usize, const SCORES: usize> Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> Profile<ACTIONS, SCORES>
Sourcepub const fn new(actions: ActionMap<ACTIONS>) -> Self
pub const fn new(actions: ActionMap<ACTIONS>) -> Self
Construct a profile with common presentation/input defaults and the caller’s game-specific action map.
Sourcepub const fn encoded_len() -> usize
pub const fn encoded_len() -> usize
Exact encoded byte length for this profile shape (the current version).
Sourcepub fn sanitize(&mut self)
pub fn sanitize(&mut self)
Clamp user-controlled values to safe shared ranges. Flag bits are preserved because the game owns bits 1 through 7.
Sourcepub fn set_invert_y(&mut self, enabled: bool)
pub fn set_invert_y(&mut self, enabled: bool)
Enable or disable inverted vertical look.
Sourcepub const fn game_flags(&self) -> u8
pub const fn game_flags(&self) -> u8
Return the raw game-owned bits in the settings flag byte.
Sourcepub fn set_game_flag(&mut self, mask: u8, enabled: bool)
pub fn set_game_flag(&mut self, mask: u8, enabled: bool)
Set or clear the selected game-owned bits without changing any other
bits. Bit 0 is ignored even if it appears in mask.
Sourcepub fn submit_score(&mut self, slot: usize, score: u32) -> bool
pub fn submit_score(&mut self, slot: usize, score: u32) -> bool
Raise one high-score slot when score beats it. Returns true if the
profile changed and should be persisted.
Sourcepub fn encode(&self, out: &mut [u8]) -> Result<usize, CodecError>
pub fn encode(&self, out: &mut [u8]) -> Result<usize, CodecError>
Encode into out as a version 3 record, returning the bytes used.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, CodecError>
pub fn decode(bytes: &[u8]) -> Result<Self, CodecError>
Decode a profile of this exact action/score shape, from a record of the current version or of version 1 or 2. A version 1 record carries no picture options, so those read as their defaults; a record older than version 3 carries no game bytes, so those read as zero. Every other field is preserved.
Trait Implementations§
impl<const ACTIONS: usize, const SCORES: usize> Copy for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> Eq for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> StructuralPartialEq for Profile<ACTIONS, SCORES>
Auto Trait Implementations§
impl<const ACTIONS: usize, const SCORES: usize> Freeze for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> RefUnwindSafe for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> Send for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> Sync for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> Unpin for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> UnsafeUnpin for Profile<ACTIONS, SCORES>
impl<const ACTIONS: usize, const SCORES: usize> UnwindSafe for Profile<ACTIONS, SCORES>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)