Skip to main content

Module profiles

Module profiles 

Source
Expand description

Player profiles: a profile holds a player’s options, keys and saves, whatever the game keeps for each player. Each of those keeps the Storage key it would have without profiles, inside the profile: a profile’s key is its id’s prefix and that key (p1-settings, p2-slot_03, ProfileId::key). ProfileStore is the Storage of the current profile, and the computer’s own storage under it.

The list of profiles and which one was used last stay with the computer, under PROFILES_KEY (Profiles::to_ron). load reads it, makes the first profile on a first launch, and moves a player’s keys from before a game had profiles into it (migrate).

Structs§

Profile
One profile in the list.
ProfileId
A profile’s number. Never reused: a deleted profile’s number is never given to a new one, so nothing it left behind can turn up in another.
ProfileStore
The Storage of the profile in use: each key is read and written as that profile’s (ProfileId::key), and list lists only its keys, without their prefix. What stays with the computer (the list of profiles, whatever the game keeps per computer) goes through computer.
Profiles
The list of profiles, in the order they were made, and the one in use.

Enums§

ProfileError
Why a change to the list of profiles was refused.

Constants§

MAX_NAME_CHARS
The longest profile name, in characters.
MAX_PROFILES
The most profiles there can be.
PROFILES_KEY
Storage key of the list of profiles, kept per computer.
PROFILES_VERSION
The saved list’s format version.

Functions§

delete_keys
Deletes every key of the profile id from the computer’s storage. Tries them all; the first error, if any.
fits_every_profile
Whether key can be a key of any profile: whether the largest profile’s key for it (ProfileId::key) is a valid Storage key. A key a game keeps per player must be.
load
The list of profiles in storage, and warnings for the platform to log.
migrate
Makes the first profile, called name, and moves the player’s keys from before profiles (old_keys) into it, once.