diff --git a/Cargo.lock b/Cargo.lock index 838ed38..c9eee49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -460,7 +460,7 @@ dependencies = [ [[package]] name = "reffect" -version = "0.2.2" +version = "0.2.3" dependencies = [ "base64", "dlopen2", diff --git a/Cargo.toml b/Cargo.toml index 7916c52..1366566 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reffect" -version = "0.2.2" +version = "0.2.3" authors = ["Zerthox"] edition = "2021" description = "Customizable effect & resource displays" diff --git a/src/trigger/progress/threshold/mod.rs b/src/trigger/progress/threshold/mod.rs index dddf2a8..582b166 100644 --- a/src/trigger/progress/threshold/mod.rs +++ b/src/trigger/progress/threshold/mod.rs @@ -13,12 +13,12 @@ use nexus::imgui::{ComboBoxFlags, Ui}; use serde::{Deserialize, Serialize}; #[derive(Debug, Default, Clone, Serialize, Deserialize)] -#[serde(default)] pub struct ProgressThreshold { /// Threshold type. pub threshold_type: ThresholdType, /// Amount type. + #[serde(default)] // TODO: move up after migration period pub amount_type: AmountType, } @@ -72,3 +72,19 @@ impl RenderOptions for ProgressThreshold { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::serde_migrate::Migrate; + + #[test] + fn migrate() { + let old_json = "{ \"Between\": [1, 23] }"; + + let result = serde_json::from_str::>(&old_json); + assert!(result.is_ok()); + let threshold = result.unwrap().inner; + assert_eq!(threshold.threshold_type, ThresholdType::Between(1.0, 23.0)); + } +} diff --git a/src/trigger/progress/threshold/threshold_type.rs b/src/trigger/progress/threshold/threshold_type.rs index cc6c3b5..37f442a 100644 --- a/src/trigger/progress/threshold/threshold_type.rs +++ b/src/trigger/progress/threshold/threshold_type.rs @@ -1,7 +1,9 @@ use serde::{Deserialize, Serialize}; use strum::{AsRefStr, EnumIter, IntoStaticStr, VariantArray}; -#[derive(Debug, Default, Clone, AsRefStr, IntoStaticStr, EnumIter, Serialize, Deserialize)] +#[derive( + Debug, Default, Clone, PartialEq, AsRefStr, IntoStaticStr, EnumIter, Serialize, Deserialize, +)] pub enum ThresholdType { /// Always met. Always,