pub struct Profile<const ACTIONS: usize, const SCORES: usize> {
pub brightness: u8,
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 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: u8Display brightness, 0..=100.
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 such as FLAG_INVERT_Y.
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.
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 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, 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.
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)