diff --git a/src/main.rs b/src/main.rs index 2a9ebaf..71ae3aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,22 +46,22 @@ mod test; #[allow(unused_imports)] use bevy_editor_pls::prelude::*; -const SETTINGS_FILE_PATH: &'static str = "settings.toml"; +const CONFIG_FILE_PATH: &'static str = "config.toml"; const KEYMAP_FILE_PATH: &'static str = "keymap.toml"; -fn save_settings(settings: Res) { - let settings_toml = toml::to_string(&*settings).unwrap(); - fs::write(SETTINGS_FILE_PATH, settings_toml).unwrap(); +fn save_config(config: Res) { + let config_toml = toml::to_string(&*config).unwrap(); + fs::write(CONFIG_FILE_PATH, config_toml).unwrap(); } #[bevy_main] fn main() { - if !Path::new(SETTINGS_FILE_PATH).is_file() { - let default_settings_toml = toml::to_string(&Settings::default()).unwrap(); - fs::write(SETTINGS_FILE_PATH, default_settings_toml).unwrap(); + if !Path::new(CONFIG_FILE_PATH).is_file() { + let default_config_toml = toml::to_string(&Config::default()).unwrap(); + fs::write(CONFIG_FILE_PATH, default_config_toml).unwrap(); } - let settings_toml = fs::read_to_string(SETTINGS_FILE_PATH).unwrap(); - let settings: Settings = toml::from_str(settings_toml.as_str()).unwrap(); + let config_toml = fs::read_to_string(CONFIG_FILE_PATH).unwrap(); + let config: Config = toml::from_str(config_toml.as_str()).unwrap(); if !Path::new(KEYMAP_FILE_PATH).is_file() { let default_keymap_toml = toml::to_string(&default_input_action_map()).unwrap(); @@ -72,7 +72,7 @@ fn main() { let player_movement = PlayerMovement { directions: VecDeque::new(), - timer: Timer::from_seconds(settings.player_move_speed, TimerMode::Repeating), + timer: Timer::from_seconds(config.player_move_speed, TimerMode::Repeating), }; let mut app = App::new(); @@ -110,7 +110,7 @@ fn main() { update_button_state, handle_audio_event, adjust_viewport, - save_settings.run_if(resource_changed_or_removed::()), + save_config.run_if(resource_changed_or_removed::()), (button_input_to_action, handle_actions).chain(), ), ) @@ -172,7 +172,7 @@ fn main() { app.init_resource::>() .insert_resource(input_action_map); - app.insert_resource(settings) + app.insert_resource(config) .insert_resource(player_movement) .insert_resource(AutoMoveState::default()); diff --git a/src/resources.rs b/src/resources.rs index 4aac05c..eeb309f 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -12,35 +12,35 @@ use std::collections::{HashMap, VecDeque}; use std::sync::Mutex; #[derive(Resource, Serialize, Deserialize)] -pub struct Settings { - /// Disable player movement animation. - pub instant_move: bool, +pub struct Config { /// Player movement animation speed, seconds per step. pub player_move_speed: f32, /// Make the floor look like a chessboard with alternating light square and dark square. pub even_square_shades: f32, - /// Audio volume + /// Audio volume. pub volume: f64, + /// Disable player movement animation. + pub instant_move: bool, /// Enable auto switch to next unsolved level when the current level is solved. pub auto_switch_to_next_unsolved_level: bool, - pub solver: SolverSettings, + pub solver: SolverConfig, } -impl Default for Settings { +impl Default for Config { fn default() -> Self { Self { - instant_move: false, player_move_speed: 0.1, even_square_shades: 0.1, volume: 0.5, + instant_move: false, auto_switch_to_next_unsolved_level: true, - solver: SolverSettings::default(), + solver: SolverConfig::default(), } } } #[derive(Serialize, Deserialize, Default)] -pub struct SolverSettings { +pub struct SolverConfig { pub strategy: Strategy, pub lower_bound_method: LowerBoundMethod, } diff --git a/src/systems/audio.rs b/src/systems/audio.rs index 909443e..e701b99 100644 --- a/src/systems/audio.rs +++ b/src/systems/audio.rs @@ -8,7 +8,7 @@ use crate::resources::*; pub fn handle_audio_event( audio: Res