Module preferences

Source
Expand description

Validated live presentation settings, separate from persistence and simulation.

try_apply changes audio/graphics without saving; try_apply_with_feedback also publishes a visual policy. Games opt in with sync_feedback before emitting accepted events and before sampling presentation, including while a local menu is open. Neither operation advances or pauses gameplay, networking or replay. Motion/flash policy is session-local: the existing preferences save format is unchanged. Hosts own persistence and resolution of system motion vs explicit user choices. Renderer state, audio and this policy belong to the calling thread.

Structs§

ApplyOutcome
Result of applying a complete validated preference snapshot.
Preferences
Device-local presentation preferences, separate from gameplay control bindings.
UiApplyOutcome
Result for the separate UI channel. A token change requires layout/paint/hit reconstruction, including a contrast-only change (authored styles may differ). This reports adoption by the session, not adoption by any game/renderer.
UiPreferences
Validated UI choices, independent of motion/flash, graphics and saved preferences. Private fields prevent an invalid value from entering the live session. Standard text is 1x; the player’s existing Large choice maps to 1.5x. Explicit contrast indices are 0 (Normal) and 1 (HighContrast), never “system”. No game is restyled until it opts into ui_preferences and Self::theme.

Enums§

UiPreferenceError
Rejected snapshots leave every live channel unchanged.

Constants§

UI_PREFERENCES_VERSION
Version of the session-local UI snapshot and browser setter contract.

Functions§

apply_ui_preferences
Publish a validated UI choice without persistence, renderer rebuild or gameplay mutation. Consumers rebuild their own layout from UiPreferences::theme. Use UiPreferences::default() for an explicit UI-only reset; see its example.
apply_ui_snapshot_v1
Validate/apply the versioned browser contract. Numeric 1 accepts (also when unchanged); 0 rejects without any side effects, including last-field failure. This deliberately excludes motion/flash: old feedback consumers stay independent.
current
Snapshot actual audio and underlying graphics settings, excluding temporary URL/environment look/quality overrides and queued, unapplied detail edits. This is not the saved user snapshot: direct mixer/renderer calls are visible.
feedback_policy
Current session-local visual policy. Hosts can inspect it to suppress their own animation/particles; already emitted external effects cannot be recalled.
set_feedback_policy
Publish an already validated visual policy; returns whether it changed. Does not write preferences, change audio/graphics, or touch a simulation clock. Controllers receive it on their next sync_feedback call.
sync_feedback
Apply the shared visual policy to an actual feedback consumer, returning whether its policy changed. Call before accepted-event emission and frame sampling, even with no simulation tick or while local menus are open.
try_apply
Validate and apply a complete audio/graphics snapshot without persisting it. Invalid fields return StorageError::Invalid before any change. Unchanged settings avoid mixer setters and graphics refresh; runtime drift is repaired. Existing visual policy and explicit URL/environment overrides are preserved.
try_apply_with_feedback
Apply audio, graphics and visual policy together. Invalid preferences leave every setting, including the shared feedback policy, unchanged. Policy inputs are validated by FeedbackPolicy::new. No persistence or controller polling occurs; use sync_feedback in the presentation owner.
ui_preferences
Read the calling thread’s session-local UI choice. See UiPreferences.