From: Ian Jackson Date: Tue, 6 Apr 2021 19:07:10 +0000 (+0100) Subject: Plumb sortkey through PieceTrait to otterlib X-Git-Tag: otter-0.5.0~144 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e6586d1f90b0a65e7bfcb164152f879b81d757e8;p=otter.git Plumb sortkey through PieceTrait to otterlib Signed-off-by: Ian Jackson --- 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())?, };