From 38416ef37c0692ec1e022752bf91c734079943d8 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 26 May 2019 16:42:45 -0400 Subject: [PATCH] Show disclaimer once Former-commit-id: f4937dba2caca207b02deb18ad209a8435e65b61 --- voxygen/src/main.rs | 4 ++++ voxygen/src/menu/main/mod.rs | 3 +++ voxygen/src/menu/main/ui.rs | 10 ++++++---- voxygen/src/settings.rs | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index f81f17c803..1be0b4426c 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -81,6 +81,10 @@ pub trait PlayState { fn main() { // Set up the global state. let mut settings = Settings::load(); + // Save settings to add new fields or create the file if it is not already there + // TODO: Handle this result. + settings.save_to_file(); + let window = Window::new(&settings).expect("Failed to create window!"); // Initialize logging. diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 7d2957dce4..e738697894 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -117,6 +117,9 @@ impl PlayState for MainMenuState { return PlayStateResult::Push(Box::new(StartSingleplayerState::new())); } MainMenuEvent::Quit => return PlayStateResult::Shutdown, + MainMenuEvent::DisclaimerClosed => { + global_state.settings.show_disclaimer = false + } } } diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 2bd084f4b8..44e395f972 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -90,6 +90,7 @@ pub enum Event { }, StartSingleplayer, Quit, + DisclaimerClosed, } pub struct MainMenuUi { @@ -129,11 +130,11 @@ impl MainMenuUi { login_error: None, connecting: None, show_servers: false, - show_disclaimer: true, + show_disclaimer: global_state.settings.show_disclaimer, } } - fn update_layout(&mut self, global_state: &GlobalState) -> Vec { + fn update_layout(&mut self, global_state: &mut GlobalState) -> Vec { let mut events = Vec::new(); let ref mut ui_widgets = self.ui.set_widgets(); let version = env!("CARGO_PKG_VERSION"); @@ -209,8 +210,9 @@ impl MainMenuUi { .set(self.ids.disc_button, ui_widgets) .was_clicked() { - self.show_disclaimer = false - }; + self.show_disclaimer = false; + events.push(Event::DisclaimerClosed); + } } else { // TODO: Don't use macros for this? // Input fields diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index d92d5bd626..ba8565138a 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -13,6 +13,7 @@ pub struct Settings { pub log: Log, pub graphics: GraphicsSettings, pub audio: AudioSettings, + pub show_disclaimer: bool, } /// `ControlSettings` contains keybindings. @@ -117,6 +118,7 @@ impl Default for Settings { sfx_volume: 0.5, audio_device: None, }, + show_disclaimer: true, } } }