-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update theming and add pick list element
- Loading branch information
Showing
73 changed files
with
1,475 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,60 @@ | ||
use derive_new::new; | ||
use procedural::toggle; | ||
use ron::ser::PrettyConfig; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(toggle, new)] | ||
use super::ShadowDetail; | ||
#[cfg(feature = "debug")] | ||
use crate::debug::*; | ||
|
||
#[derive(Serialize, Deserialize, toggle)] | ||
pub struct GraphicsSettings { | ||
#[toggle] | ||
#[new(value = "true")] | ||
pub frame_limit: bool, | ||
#[toggle] | ||
#[new(value = "true")] | ||
pub show_interface: bool, | ||
pub shadow_detail: ShadowDetail, | ||
} | ||
|
||
impl Default for GraphicsSettings { | ||
fn default() -> Self { | ||
Self { | ||
frame_limit: true, | ||
show_interface: true, | ||
shadow_detail: ShadowDetail::Medium, | ||
} | ||
} | ||
} | ||
|
||
impl GraphicsSettings { | ||
pub fn new() -> Self { | ||
Self::load().unwrap_or_else(|| { | ||
#[cfg(feature = "debug")] | ||
print_debug!("failed to load graphics settings from {}filename{}", MAGENTA, NONE); | ||
|
||
Default::default() | ||
}) | ||
} | ||
|
||
pub fn load() -> Option<Self> { | ||
#[cfg(feature = "debug")] | ||
print_debug!("loading graphics settings from {}filename{}", MAGENTA, NONE); | ||
|
||
std::fs::read_to_string("client/graphics_settings.ron") | ||
.ok() | ||
.and_then(|data| ron::from_str(&data).ok()) | ||
} | ||
|
||
pub fn save(&self) { | ||
#[cfg(feature = "debug")] | ||
print_debug!("saving graphics settings to {}filename{}", MAGENTA, NONE); | ||
|
||
let data = ron::ser::to_string_pretty(self, PrettyConfig::new()).unwrap(); | ||
std::fs::write("client/graphics_settings.ron", data).expect("unable to write file"); | ||
} | ||
} | ||
|
||
impl Drop for GraphicsSettings { | ||
fn drop(&mut self) { | ||
self.save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.