Ship floating launcher, automatic discovery and bounded media search improvements
This commit is contained in:
1 parent
01279a6b25
commit
521966a2ac
43 files changed
+3165
-267
No files matched your search
@@ -23,10 +23,16 @@ fn default_background_opacity() -> u8 {
|
||||
const SETTINGS_VERSION: u32 = 2;
|
||||
const MAX_SETTINGS_BYTES: u64 = 128 * 1024;
|
||||
|
||||
fn default_automatic_indexing() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Settings {
|
||||
pub version: u32,
|
||||
#[serde(default = "default_automatic_indexing")]
|
||||
pub automatic_indexing: bool,
|
||||
#[serde(default)]
|
||||
pub background_material: BackgroundMaterial,
|
||||
#[serde(default = "default_background_opacity")]
|
||||
@@ -43,6 +49,7 @@ impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
version: SETTINGS_VERSION,
|
||||
automatic_indexing: true,
|
||||
background_material: BackgroundMaterial::default(),
|
||||
background_opacity: default_background_opacity(),
|
||||
roots: Vec::new(),
|
||||
@@ -57,8 +64,8 @@ impl Settings {
|
||||
if self.version != SETTINGS_VERSION {
|
||||
return Err(format!("Unsupported settings version {}", self.version));
|
||||
}
|
||||
if !(70..=100).contains(&self.background_opacity) {
|
||||
return Err("Background opacity must be between 70 and 100 percent.".into());
|
||||
if !(40..=100).contains(&self.background_opacity) {
|
||||
return Err("Background opacity must be between 40 and 100 percent.".into());
|
||||
}
|
||||
if !(1..=8).contains(&self.cpu_threads) {
|
||||
return Err("CPU threads must be between 1 and 8.".into());
|
||||
@@ -265,11 +272,11 @@ mod appearance_tests {
|
||||
assert_eq!(store.value.background_opacity, 90);
|
||||
let mut next = store.value.clone();
|
||||
next.background_material = BackgroundMaterial::Glass;
|
||||
next.background_opacity = 70;
|
||||
next.background_opacity = 40;
|
||||
store.save(next.clone()).unwrap();
|
||||
assert_eq!(SettingsStore::load(path.clone()).unwrap().value, next);
|
||||
let bytes = fs::read(&path).unwrap();
|
||||
for opacity in [0, 69, 101, 255] {
|
||||
for opacity in [0, 39, 101, 255] {
|
||||
let mut invalid = next.clone();
|
||||
invalid.background_opacity = opacity;
|
||||
assert!(store.save(invalid).is_err());
|
||||
|
||||
Reference in new issue
Block a user