diff --git a/src/main.rs b/src/main.rs index d6d3970..a0080e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod audio; mod player; mod camera; mod world; +mod settings; use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode }; use bevy::prelude::*; @@ -10,6 +11,7 @@ fn main() { App::new() .add_systems(Startup, ( setup, + settings::setup, audio::setup, player::setup, world::setup, @@ -37,9 +39,16 @@ fn setup( fn handle_input( keyboard_input: Res>, + mut settings: Query<&mut settings::Settings>, mut app_exit_events: ResMut> ) { if keyboard_input.pressed(KeyCode::KeyQ) { app_exit_events.send(bevy::app::AppExit); } + if keyboard_input.just_pressed(KeyCode::F12) { + let result = settings.get_single_mut(); + if result.is_ok() { + result.unwrap().reset() + } + } } diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 0000000..b0c2285 --- /dev/null +++ b/src/settings.rs @@ -0,0 +1,31 @@ +use bevy::prelude::*; + +#[derive(Component)] +pub struct Settings { + pub mute_sfx: bool, + pub mute_music: bool, + pub volume_sfx: u8, + pub volume_music: u8, +} + +impl Default for Settings { + fn default() -> Self { + Settings { + mute_sfx: false, + mute_music: false, + volume_sfx: 100, + volume_music: 100, + } + } +} + +impl Settings { + pub fn reset(&mut self) { + println!("Resetting settings!"); + *self = Self::default(); + } +} + +pub fn setup(mut commands: Commands) { + commands.spawn(Settings::default()); +}