From e6586d1f90b0a65e7bfcb164152f879b81d757e8 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 6 Apr 2021 20:07:10 +0100 Subject: [PATCH] Plumb sortkey through PieceTrait to otterlib Signed-off-by: Ian Jackson --- src/gamestate.rs | 1 + src/shapelib.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/gamestate.rs b/src/gamestate.rs index cb611ca3..544a84e7 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -210,6 +210,7 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static { } fn itemname(&self) -> &str; + fn sortkey(&self) -> Option<&str> { None } fn occultation_notify_hook(&self, _piece: PieceId) -> UnpreparedUpdates { None diff --git a/src/shapelib.rs b/src/shapelib.rs index ce7abd87..8e792fd6 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -201,6 +201,7 @@ impl OccultedPieceTrait for ItemOccultable { #[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)] pub struct ItemEnquiryData { pub itemname: GoodItemName, + pub sortkey: Option, pub f0desc: Html, pub f0bbox: Rect, } @@ -304,6 +305,7 @@ impl PieceTrait for Item { } fn itemname(&self) -> &str { &self.itemname } + fn sortkey(&self) -> Option<&str> { self.sort.as_ref().map(AsRef::as_ref) } } #[typetag::serde(name="LibItem")] @@ -474,6 +476,7 @@ impl Contents { let f0bbox = loaded.bbox_approx()?; let ier = ItemEnquiryData { itemname: k.to_owned(), + sortkey: v.sort.to_owned(), f0bbox, f0desc: loaded.describe_face(default())?, }; -- 2.30.2