save/load avatar setting from config file
This commit is contained in:
parent
548386ef54
commit
377c2a4f0b
|
@ -147,6 +147,7 @@ pub fn setup(mut settings: ResMut<Settings>, prefs: Res<var::Preferences>) {
|
|||
settings.set_noise_cancellation_mode(prefs.noise_cancellation_mode);
|
||||
settings.third_person = prefs.third_person;
|
||||
settings.shadows_sun = prefs.shadows_sun;
|
||||
settings.ar_avatar = prefs.avatar;
|
||||
}
|
||||
|
||||
pub fn handle_game_event(
|
||||
|
|
|
@ -1281,6 +1281,7 @@ fn update_overlay_visibility(
|
|||
fn update_avatar(
|
||||
mut commands: Commands,
|
||||
mut settings: ResMut<Settings>,
|
||||
mut prefs: ResMut<var::Preferences>,
|
||||
asset_server: Res<AssetServer>,
|
||||
q_avatar: Query<(Entity, &SceneInstance), With<PlayerAvatar>>,
|
||||
q_player: Query<Entity, With<actor::Player>>,
|
||||
|
@ -1289,6 +1290,9 @@ fn update_avatar(
|
|||
if settings.ar_avatar >= PLAYER_AR_AVATARS.len() {
|
||||
settings.ar_avatar = settings.ar_avatar % PLAYER_AR_AVATARS.len();
|
||||
}
|
||||
prefs.avatar = settings.ar_avatar;
|
||||
prefs.save();
|
||||
|
||||
let ava = if let Some(ava) = PLAYER_AR_AVATARS.get(settings.ar_avatar) {
|
||||
ava
|
||||
} else {
|
||||
|
|
|
@ -456,6 +456,7 @@ pub struct Preferences {
|
|||
pub noise_cancellation_mode: usize,
|
||||
pub third_person: bool,
|
||||
pub shadows_sun: bool,
|
||||
pub avatar: usize,
|
||||
|
||||
#[serde(skip)]
|
||||
pub source_file: Option<String>,
|
||||
|
|
Loading…
Reference in a new issue