cloudiful-bevy-settings
Reusable Bevy settings framework for apps that keep their own action enums, field keys, localization layer, and UI messages.
What it provides
SettingActionHandler<Action>: app settings resource contract for validating and applying a narrowed settings actionRequestedSettingAction<Action>: adapter trait for app-defined UI/request messagesSettingFieldSpec<AppAction, FieldKey, TextKey>: generic field descriptor with label metadata and a control definitionSettingControlSpec<Action, FieldKey>: toggle, stepper, and select control variantsSettingSliderSpec<Action>: slider metadata for stepper-style controlsSettingSelectOption<Action>: select option descriptor with disabled-state supportSettingFieldSource<AppAction, Context, FieldKey, TextKey>: trait for producing field specs from app contextSettingSystemSet: sharedApplyActionsandSyncUischedule setsapply_setting_action(...): immediate helper for applying one app action to persistent settingschange_setting(...): message-driven bridge from UI/request messages into persistent settings updatesregister_setting_systems(...): helper that orders change systems before UI sync systems
What it does not provide
- app-specific settings resources
- app-specific action enums, field keys, or text-key enums
- widget rendering, button/slider/select UI components, or layout
- persistence bootstrapping beyond using
bevy-persistent - localized label assembly helpers or any localization runtime
This crate stays narrow on purpose: your app owns settings data, UI messages, field identities, and localization. This crate only coordinates schema/action flow and the system ordering around persistent settings updates.
Minimal end-to-end example
use *;
use ;
use ;
use ;
Schema Types
SettingFieldSpec is the generic description your UI layer can consume. Each
field has:
label: already-resolved display textlabel_key: optional app-defined text key for localization-aware UIscontrol: oneSettingControlSpecvariant
SettingControlSpec models the common settings control shapes:
Toggle { text, action }Stepper { key, value, decrease_action, increase_action, slider }Select { key, value, options }
Helpers on SettingFieldSpec keep construction compact:
toggle(...)stepper(...)select(...)with_label_key(...)with_slider(...)
Use SettingSliderSpec::new(...) when a stepper also needs slider metadata such
as range, precision, suffix text, and the fn(f32) -> Action mapper.
System Behavior
register_setting_systems(...) configures two ordered update sets:
SettingSystemSet::ApplyActionsSettingSystemSet::SyncUi
Put message-reading or direct action-application systems in ApplyActions.
Put systems that rebuild labels, refresh view state, or mirror settings back
into UI resources in SyncUi.
change_setting(...) reads Bevy messages, extracts the app action via
RequestedSettingAction, narrows it with TryFrom, checks can_apply, and
then updates the Persistent<T> resource.
apply_setting_action(...) is the same logic without message plumbing. Use it
when a system already has the action value in hand.