From 377c2a4f0b12aa7f8e2fa1e1253b12520d0cf992 Mon Sep 17 00:00:00 2001 From: yuni Date: Mon, 17 Jun 2024 01:43:23 +0200 Subject: [PATCH] save/load avatar setting from config file --- src/game.rs | 1 + src/hud.rs | 4 ++++ src/var.rs | 1 + 3 files changed, 6 insertions(+) diff --git a/src/game.rs b/src/game.rs index 6e016d3..6b7f413 100644 --- a/src/game.rs +++ b/src/game.rs @@ -147,6 +147,7 @@ pub fn setup(mut settings: ResMut, prefs: Res) { 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( diff --git a/src/hud.rs b/src/hud.rs index 2379123..e0ab981 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -1281,6 +1281,7 @@ fn update_overlay_visibility( fn update_avatar( mut commands: Commands, mut settings: ResMut, + mut prefs: ResMut, asset_server: Res, q_avatar: Query<(Entity, &SceneInstance), With>, q_player: Query>, @@ -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 { diff --git a/src/var.rs b/src/var.rs index 0551e5b..30c14a4 100644 --- a/src/var.rs +++ b/src/var.rs @@ -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,