From 17b6a16ec7af0119d669114a817508038a8435a1 Mon Sep 17 00:00:00 2001 From: Leon Liu Date: Tue, 31 Dec 2024 19:18:02 +0900 Subject: [PATCH] update --- src-common/src/models/loot_filter.rs | 44 +++++++++++------------ src/components/filter.rs | 11 +++--- src/components/filter_detail.rs | 53 ++++++++++++++++++++++++++-- 3 files changed, 79 insertions(+), 29 deletions(-) diff --git a/src-common/src/models/loot_filter.rs b/src-common/src/models/loot_filter.rs index 2104f43..0048a87 100644 --- a/src-common/src/models/loot_filter.rs +++ b/src-common/src/models/loot_filter.rs @@ -13,7 +13,7 @@ impl Filter { id: Uuid::new_v4(), enabled: true, name: "".to_string(), - lines: HashMap::new(), + rule: Default::default(), remain: FilterRemain::Leaf(Default::default()), } } @@ -23,7 +23,7 @@ impl Filter { id: Uuid::new_v4(), enabled: true, name: "".to_string(), - lines: HashMap::new(), + rule: Default::default(), remain: FilterRemain::Group(Default::default()), } } @@ -35,7 +35,7 @@ pub struct Filter { pub id: uuid::Uuid, pub enabled: bool, pub name: String, - pub lines: HashMap, + pub rule: FilterRule, pub remain: FilterRemain, } @@ -75,29 +75,29 @@ pub struct Color { pub type Level = RangedNumber<1, 100>; #[cfg_attr(feature = "store", derive(reactive_stores::Store))] -#[derive(Serialize, Deserialize, Debug, Clone)] -pub enum Line { - Class(Vec), - BaseType(Vec), - AreaLevel(Op, Level), - DropLevel(Op, Level), - ItemLevel(Op, Level), - Rarity(Op, ItemRarity), - Sockets(Op, u32), - Quality(Op, u32), - StackSize(Op, u32), +#[derive(Serialize, Deserialize, Debug, Clone, Default)] +pub struct FilterRule { + pub class: Option>, + pub base_type: Option>, + pub area_level: Option<(Op, Level)>, + pub drop_level: Option<(Op, Level)>, + pub item_level: Option<(Op, Level)>, + pub rarity: Option<(Op, ItemRarity)>, + pub sockets: Option<(Op, u32)>, + pub quality: Option<(Op, u32)>, + pub stack_size: Option<(Op, u32)>, // waystones - WaystoneTier(Op, RangedNumber<1, 16>), + pub waystone_tier: Option<(Op, RangedNumber<1, 16>)>, // effects - SetFontSize(RangedNumber<1, 45>), - SetTextColor(Color), - SetBorderColor(Color), - SetBackgroundColor(Color), - PlayAlertSound(RangedNumber<1, 16>, RangedNumber<0, 300>), - PlayEffect(GameColor), - MinimapIcon(RangedNumber<0, 2>, GameColor, MinimapIconShape), + pub set_font_size: Option>, + pub set_text_color: Option, + pub set_border_color: Option, + pub set_background_color: Option, + pub play_alert_sound: Option<(RangedNumber<1, 16>, RangedNumber<0, 300>)>, + pub play_effect: Option, + pub minimap_icon: Option<(RangedNumber<0, 2>, GameColor, MinimapIconShape)>, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/components/filter.rs b/src/components/filter.rs index 3919108..5dfe377 100644 --- a/src/components/filter.rs +++ b/src/components/filter.rs @@ -103,11 +103,11 @@ fn group( { - on_action.run((a,)); + Action::Select(mut v) => { + v.push(filter); + on_action.run((Action::Select(v),)); } } } diff --git a/src/components/filter_detail.rs b/src/components/filter_detail.rs index 8ee2f39..918896c 100644 --- a/src/components/filter_detail.rs +++ b/src/components/filter_detail.rs @@ -1,12 +1,61 @@ use leptos::prelude::*; -use reactive_stores::Field; -use src_common::models::loot_filter::Filter; +use reactive_stores::{Field, OptionStoreExt}; +use src_common::models::loot_filter::{ + Filter, FilterLeafStoreFields, FilterRemain, FilterRemainStoreFields, FilterRule, + FilterRuleStoreFields, FilterStoreFields, +}; #[component] pub fn FilterDetail(#[prop(into)] filter: Vec>) -> impl IntoView { + let (first, rest) = filter.split_first().unwrap(); view! {

Filter details:

+ {match first.remain().get_untracked() { + FilterRemain::Leaf(_) => { + let leaf = first.remain().leaf_0().unwrap(); + Some( + view! { +
+ + + +
+ }, + ) + } + FilterRemain::Group(_) => None, + }} + + } +} + +#[component] +pub fn RuleDetail(#[prop(into)] rule: Field) -> impl IntoView { + let class = view! { + + + + + + + + + + + + }; + view! { + + {class} +
} }