From f91c37fe03ca99040e8a844986e6c8914d937590 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 7 Apr 2021 18:41:59 +0100 Subject: [PATCH] Plumb ShowUnocculted through to ui_operation trait methods We're going to want this. Signed-off-by: Ian Jackson --- daemon/api.rs | 2 +- src/bin/otterlib.rs | 4 +++- src/clock.rs | 4 ++-- src/deck.rs | 5 +++-- src/gamestate.rs | 5 +++-- src/hand.rs | 4 ++-- src/pcrender.rs | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index 962ca70d..f79fe27a 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -605,7 +605,7 @@ api_route!{ }; } - ipc.show(y).ui_operation(a, &self.opname, self.wrc)? + ipc.show(y).ui_operation(y, a, &self.opname, self.wrc)? } } } diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index d9dd022e..474b2019 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -64,6 +64,8 @@ pub enum OutputKind { pub type ItemForOutput = (String, ItemEnquiryData); +pub const VIS: ShowUnocculted = ShowUnocculted::new_visible(); + #[throws(AE)] fn preview(items: Vec) { const BORDER: f64 = 1.; @@ -98,7 +100,7 @@ fn preview(items: Vec) { .context("load")?; // todo show occulted version too let mut uos = vec![]; - p.add_ui_operations(&mut uos, &GameState::dummy(), &GPiece::dummy()) + p.add_ui_operations(VIS, &mut uos, &GameState::dummy(), &GPiece::dummy()) .context("add uos")?; let uos = uos.into_iter().map(|uo| uo.opname).collect::>(); let spec = spec.clone(); diff --git a/src/clock.rs b/src/clock.rs index 1c84dc2c..706182dc 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -541,7 +541,7 @@ impl PieceTrait for Clock { } #[throws(InternalError)] - fn add_ui_operations(&self, upd: &mut Vec, + fn add_ui_operations(&self, _: ShowUnocculted, upd: &mut Vec, gs: &GameState, gpc: &GPiece) { let state: &State = gpc.xdata_exp()?; @@ -610,7 +610,7 @@ impl PieceTrait for Clock { } #[throws(ApiPieceOpError)] - fn ui_operation(&self, args: ApiPieceOpArgs<'_>, + fn ui_operation(&self, _: ShowUnocculted, args: ApiPieceOpArgs<'_>, opname: &str, _wrc: WhatResponseToClientOp) -> UpdateFromOpComplex { let ApiPieceOpArgs { gs,piece,player,ioccults,ipc,ig,.. } = args; diff --git a/src/deck.rs b/src/deck.rs index 80b233f0..26020797 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -128,7 +128,7 @@ impl PieceTrait for Deck { } #[throws(InternalError)] - fn add_ui_operations(&self, upd: &mut Vec, + fn add_ui_operations(&self, _: ShowUnocculted, upd: &mut Vec, gs: &GameState, gpc: &GPiece) { let state = self.state(gpc, &gs.occults)?; if state != Enabled { @@ -161,7 +161,8 @@ impl PieceTrait for Deck { } #[throws(ApiPieceOpError)] - fn ui_operation(&self, a: ApiPieceOpArgs<'_>, + fn ui_operation(&self, _: ShowUnocculted, + a: ApiPieceOpArgs<'_>, opname: &str, wrc: WhatResponseToClientOp) -> UpdateFromOpComplex { let ApiPieceOpArgs { gs,player,piece,ipieces,ioccults,to_recalculate,.. } = a; diff --git a/src/gamestate.rs b/src/gamestate.rs index f5aed30d..08b926b7 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -172,10 +172,11 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static { fn nfaces(&self) -> RawFaceId; #[throws(InternalError)] - fn add_ui_operations(&self, _upd: &mut Vec, + fn add_ui_operations(&self, _: ShowUnocculted, + _upd: &mut Vec, _gs: &GameState, _gpc: &GPiece) { } - fn ui_operation(&self, _a: ApiPieceOpArgs<'_>, + fn ui_operation(&self, _: ShowUnocculted, _a: ApiPieceOpArgs<'_>, _opname: &str, _wrc: WhatResponseToClientOp) -> Result { throw!(OE::BadOperation) diff --git a/src/hand.rs b/src/hand.rs index b94cf138..e09b1173 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -192,7 +192,7 @@ impl PieceTrait for Hand { } #[throws(InternalError)] - fn add_ui_operations(&self, upd: &mut Vec, + fn add_ui_operations(&self, _: ShowUnocculted, upd: &mut Vec, _gs: &GameState, gpc: &GPiece) { upd.push(if_chain! { if let Some(xdata) = gpc.xdata.get::()?; @@ -217,7 +217,7 @@ impl PieceTrait for Hand { } #[throws(ApiPieceOpError)] - fn ui_operation(&self, mut a: ApiPieceOpArgs<'_>, + fn ui_operation(&self, _: ShowUnocculted, mut a: ApiPieceOpArgs<'_>, opname: &str, wrc: WhatResponseToClientOp) -> UpdateFromOpComplex { if let Some(r) = { diff --git a/src/pcrender.rs b/src/pcrender.rs index 0e74b782..37a37283 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -241,7 +241,7 @@ impl PieceRenderInstructions { desc: Html::lit("flip").into(), }) } - ipc.show(y).add_ui_operations(&mut out, gs, gpc)?; + ipc.show(y).add_ui_operations(y, &mut out, gs, gpc)?; out } } -- 2.30.2