chiark / gitweb /
hidden: Add ShowUnocculted to ui_operations
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Mar 2021 16:22:37 +0000 (16:22 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Mar 2021 16:22:37 +0000 (16:22 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/otterlib.rs
src/gamestate.rs
src/hand.rs
src/pcrender.rs

index ec14edca25efa22a9d1627911b81aac346c3c337..ccbd406eae87cc26f1edb98ea5d32dbebedfca3d 100644 (file)
@@ -95,7 +95,8 @@ fn preview(items: Vec<ItemForOutput>) {
       let loaded = spec.clone().load().context("load")?;
       let p = loaded.p; // xxx show occulted version too
       let mut uos = vec![];
-      p.add_ui_operations(&mut uos, &GPiece::dummy()).context("add uos")?;
+      p.add_ui_operations(&mut uos, &GPiece::dummy(), unocc_ok)
+        .context("add uos")?;
       let uos = uos.into_iter().map(|uo| uo.opname).collect::<Vec<_>>();
       let spec = spec.clone();
 
index 1e233fe09cda4a949e0263cb23e31c9be8e9ea2d..853d753225433a68f0994cbc1ea013156940a3e2 100644 (file)
@@ -134,7 +134,7 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static {
 
   #[throws(InternalError)]
   fn add_ui_operations(&self, _upd: &mut Vec<UoDescription>,
-                       _gpc: &GPiece) { }
+                       _gpc: &GPiece, _y: ShowUnocculted) { }
 
   fn ui_operation(&self, _a: ApiPieceOpArgs<'_>,
                   _opname: &str, _wrc: WhatResponseToClientOp)
index 7776e2ff7cd44f1216820acb86f850f1b41c27b5..5a51e7c7385f9585a0ff304b3c9e022856e14dde 100644 (file)
@@ -116,7 +116,7 @@ impl PieceTrait for Hand {
 
   #[throws(InternalError)]
   fn add_ui_operations(&self, upd: &mut Vec<UoDescription>,
-                       gpc: &GPiece) {
+                       gpc: &GPiece, _: ShowUnocculted) {
     upd.push(if_chain! {
       if let Some(xdata) = gpc.xdata.get::<HandState>()?;
       if let Some(_owner) = &xdata.owner;
index 34c9237568981e922c5df3ef4cf7c75bbc7b1b23..24491e5cf7b0196583ca3fea3eda9c6e18f9c2df 100644 (file)
@@ -189,10 +189,10 @@ impl PieceRenderInstructions {
 
   #[throws(InternalError)]
   pub fn ui_operations(&self, gpc: &GPiece, p: &dyn PieceTrait)
-                   -> Vec<UoDescription>
+                       -> Vec<UoDescription>
   {
-    match self.occulted {
-      PriOcculted::Visible(_)                            => (),
+    let y = match self.occulted {
+      PriOcculted::Visible(y)                            => y,
       PriOcculted::Occulted | PriOcculted::Displaced(..) => return vec![],
     };
 
@@ -208,7 +208,7 @@ impl PieceRenderInstructions {
         desc: Html::lit("flip"),
       })
     }
-    p.add_ui_operations(&mut out, gpc)?;
+    p.add_ui_operations(&mut out, gpc, y)?;
     out
   }
 }