From: Ian Jackson Date: Fri, 19 Mar 2021 00:05:40 +0000 (+0000) Subject: plumb GameState into add_ui_operations X-Git-Tag: otter-0.5.0~658 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=96757c3e15e369f5bb10bb024534855665ea3a13;p=otter.git plumb GameState into add_ui_operations Signed-off-by: Ian Jackson --- diff --git a/Cargo.toml b/Cargo.toml index d84893fa..14f68e55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,80 +1,88 @@ -# Copyright 2020-2021 Ian Jackson and contributors to Otter -# SPDX-License-Identifier: AGPL-3.0-or-later -# There is NO WARRANTY. -[package] -name = "otter" -authors = ["Ian Jackson "] -license = "AGPL-3.0-or-later" +[dependencies] +anyhow="1" +argparse="0.2" +backtrace="0.3" +boolinator="2" +cast_trait_object="0.1" +chrono="0.4" +chrono-tz="0.5" +delegate="0.5" +downcast-rs="1" +either="1" +enum_dispatch="0.3.5" +env_logger="0.8" +extend="1" +failure="0.1.8" +fehler="1" +fs2="0.4" +glob="0.3" +htmlescape="0.3" +inventory="0.1" +itertools="0.10" +lazy-init="0.5" +lazy_static="1" +libc="0.2" +log="0.4" +nix="0.20" +num="0.4" +num-derive="0.3" +num-traits="0.2" +once_cell="1" +ordered-float="2" +parking_lot="0.11" +percent-encoding="2" +pwd="1" +rand="0.8" +regex="1" +rmp="0.8" +rmp-serde="0.15" +serde_json="1" +serde_with="1" +structopt="0.3" +tempfile="3" +tera="0.11" +toml="0.5" +typetag="0.1.6" +uds="0.2" +url="2" +vecdeque-stableix="1" +void="1" -version = "0.3.0" -edition = "2018" +[dependencies.enum-map] +version="0.6" +features=["serde"] -[workspace] -members = ["wasm", "daemon", "wdriver", "apitest"] +[dependencies.flexi_logger] +version="0.17" +features=["specfile"] -[dependencies] +[dependencies.index_vec] +version="0.1.1" +features=["serde"] -otter-base = { path = "base" } +[dependencies.otter-base] +path="base" -anyhow = "1" -enum_dispatch = "0.3.5" -argparse = "0.2" -backtrace = "0.3" -boolinator = "2" -cast_trait_object = "0.1" -chrono = "0.4" -chrono-tz = "0.5" -delegate = "0.5" -downcast-rs = "1" -either = "1" -extend = "1" -enum-map = { version = "0.6", features = [ "serde" ] } -env_logger = "0.8" -failure = "0.1.8" # for pwd -flexi_logger = { version = "0.17", features = [ "specfile" ] } -fs2 = "0.4" -glob = "0.3" -htmlescape = "0.3" -index_vec = { version = "0.1.1", features = ['serde'] } -inventory = "0.1" -itertools = "0.10" -lazy-init = "0.5" -lazy_static = "1" -libc = "0.2" -log = "0.4" -nix = "0.20" -num = "0.4" -num-derive = "0.3" -once_cell = "1" -ordered-float = "2" -parking_lot = "0.11" -percent-encoding = "2" -pwd = "1" -rand = "0.8" -regex = "1" -rmp = "0.8" -rmp-serde = "0.15" -serde_json = "1" -tempfile = "3" -toml = "0.5" -typetag = "0.1.6" -uds = "0.2" -url = "2" -vecdeque-stableix = "1" -void = "1" +[dependencies.serde] +version="1" +features=["derive", "rc"] -slotmap = { features = ['serde'], git = "https://github.com/ijackson/slotmap", branch="entry-return-stale-key" } -# ^ MR not yet reviewed +[dependencies.slotmap] +branch="entry-return-stale-key" +git="https://github.com/ijackson/slotmap" +features=["serde"] -# This version wants to stay aligned with Rocket's, or we'll hve -# two copies of the templating engine in our executables! -tera = "0.11" +[dependencies.strum] +version="0.20" +features=["derive"] -# Repeated here because importing does not work properly -fehler = "1" -num-traits = "0.2" -serde = { version = "1", features = ["derive","rc"] } -serde_with = "1" -structopt = "0.3" -strum = { version = "0.20", features = ['derive'] } +[package] +edition="2018" +license="AGPL-3.0-or-later" +name="otter" +version="0.3.0" +authors=["Ian Jackson "] + +[workspace] +members=["wasm", "daemon", "wdriver", "apitest"] \ No newline at end of file diff --git a/apitest/Cargo.toml b/apitest/Cargo.toml index 46011c20..d348f404 100644 --- a/apitest/Cargo.toml +++ b/apitest/Cargo.toml @@ -1,34 +1,38 @@ -# Copyright 2020-2021 Ian Jackson and contributors to Otter -# SPDX-License-Identifier: AGPL-3.0-or-later -# There is NO WARRANTY. -[package] -name = "otter-api-tests" -authors = ["Ian Jackson "] -license = "AGPL-3.0-or-later" - -version = "0.0.1" -edition = "2018" +[[bin]] +name="at-otter" +path="at-otter.rs" [dependencies] -otter = { path = ".." } +ego-tree="0.6" +fehler="1" +humantime="2" +num-traits="0.2" +scraper="0.12" +structopt="0.3" + +[dependencies.otter] +path=".." -ego-tree = "0.6" -humantime = "2" -reqwest = { version = "0.11", features = ["blocking", "json", "stream"] } -scraper = "0.12" +[dependencies.reqwest] +version="0.11" +features=["blocking", "json", "stream"] -# Repeated here because importing does not work properly -fehler = "1" -num-traits = "0.2" -serde = { version = "1", features = ["derive","rc"] } -structopt = "0.3" -strum = { version = "0.20", features = ['derive'] } +[dependencies.serde] +version="1" +features=["derive", "rc"] + +[dependencies.strum] +version="0.20" +features=["derive"] [lib] -name = "otter_api_tests" -path = "apitest.rs" +name="otter_api_tests" +path="apitest.rs" -[[bin]] -name = "at-otter" -path = "at-otter.rs" +[package] +edition="2018" +license="AGPL-3.0-or-later" +name="otter-api-tests" +version="0.0.1" +authors=["Ian Jackson "] \ No newline at end of file diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 52516343..5f242365 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -1,35 +1,41 @@ -# Copyright 2020-2021 Ian Jackson and contributors to Otter -# SPDX-License-Identifier: AGPL-3.0-or-later -# There is NO WARRANTY. - -[package] -name = "otter-daemon" -authors = ["Ian Jackson "] -license = "AGPL-3.0-or-later" - -version = "0.0.1" -edition = "2018" [[bin]] -name = "daemon-otter" -path = "main.rs" +name="daemon-otter" +path="main.rs" [dependencies] -otter = { path = ".." } -otter-base = { path = "../base" } +fehler="1" +num-traits="0.2" +rocket_cors="0.5" +serde_with="1" +structopt="0.3" + +[dependencies.otter] +path=".." -rocket = { version = "^0.4.6", features=["sse"] } -rocket_cors = "0.5" +[dependencies.otter-base] +path="../base" -# Repeated here because importing does not work properly -fehler = "1" -num-traits = "0.2" -serde = { version = "1", features = ["derive","rc"] } -serde_with = "1" -structopt = "0.3" -strum = { version = "0.20", features = ['derive'] } +[dependencies.rocket] +version="^0.4.6" +features=["sse"] [dependencies.rocket_contrib] -version = "0.4" -default-features = false -features = ["tera_templates","helmet","json","serve"] +default-features=false +version="0.4" +features=["tera_templates", "helmet", "json", "serve"] + +[dependencies.serde] +version="1" +features=["derive", "rc"] + +[dependencies.strum] +version="0.20" +features=["derive"] + +[package] +edition="2018" +license="AGPL-3.0-or-later" +name="otter-daemon" +version="0.0.1" +authors=["Ian Jackson "] \ No newline at end of file diff --git a/daemon/session.rs b/daemon/session.rs index 04b64b53..f24016b8 100644 --- a/daemon/session.rs +++ b/daemon/session.rs @@ -138,7 +138,7 @@ fn session_inner(form: Json, pinned: gpc.pinned, angle: vangle, desc, - uos: &pri.ui_operations(gpc, ipc)?, + uos: &pri.ui_operations(&ig.gs, gpc, ipc)?, }; let for_piece = SessionPieceContext { diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index 19a62360..801e7f2d 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -94,7 +94,7 @@ fn preview(items: Vec) { 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()) + p.add_ui_operations(&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/gamestate.rs b/src/gamestate.rs index ad1ca4b8..a66ca304 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -128,7 +128,7 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static { #[throws(InternalError)] fn add_ui_operations(&self, _upd: &mut Vec, - _gpc: &GPiece) { } + _gs: &GameState, _gpc: &GPiece) { } fn ui_operation(&self, _a: ApiPieceOpArgs<'_>, _opname: &str, _wrc: WhatResponseToClientOp) diff --git a/src/hand.rs b/src/hand.rs index b5829107..8b9cc7f7 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -116,7 +116,8 @@ impl PieceTrait for Hand { } #[throws(InternalError)] - fn add_ui_operations(&self, upd: &mut Vec, gpc: &GPiece) { + fn add_ui_operations(&self, upd: &mut Vec, + _gs: &GameState, gpc: &GPiece) { upd.push(if_chain! { if let Some(xdata) = gpc.xdata.get::()?; if let Some(_owner) = &xdata.owner; diff --git a/src/pcrender.rs b/src/pcrender.rs index ed961ca3..f93e7ade 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -123,7 +123,7 @@ impl PieceRenderInstructions { zg : zlevel.zg, angle : pri.angle(gpc).to_compass(), pinned : gpc.pinned, - uos : pri.ui_operations(gpc, ipc)?, + uos : pri.ui_operations(gs, gpc, ipc)?, }; dbgc!(pri, ipc, gpc, r); r @@ -136,7 +136,7 @@ impl PieceRenderInstructions { let pri = self; let r = PreparedPieceImage { svg : pri.make_defs(ioccults, gs, gpc, ipc)?, - uos : pri.ui_operations(gpc, ipc)?, + uos : pri.ui_operations(gs, gpc, ipc)?, }; dbgc!(pri, ipc, gpc, r); r @@ -201,7 +201,7 @@ impl PieceRenderInstructions { } #[throws(InternalError)] - pub fn ui_operations(&self, gpc: &GPiece, ipc: &IPiece) + pub fn ui_operations(&self, gs: &GameState, gpc: &GPiece, ipc: &IPiece) -> Vec { let y = match self.occulted { @@ -221,7 +221,7 @@ impl PieceRenderInstructions { desc: Html::lit("flip"), }) } - ipc.show(y).add_ui_operations(&mut out, gpc)?; + ipc.show(y).add_ui_operations(&mut out, gs, gpc)?; out } } diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 9eb7021a..154e46a6 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -1,25 +1,22 @@ -[package] -name = "otter-wasm" -authors = ["Ian Jackson "] -license = "AGPL-3.0-or-later" - -version = "0.0.1" -edition = "2018" - -[lib] -name = "otter_wasm" -path = "wasm.rs" -crate-type = ["cdylib"] - [dependencies] +console_error_panic_hook="0.1" +fehler="1" +js-sys="0.3" +wasm-bindgen="= 0.2.70" +wee_alloc="0.4" -otter-base = { path = "../base" } +[dependencies.otter-base] +path="../base" -console_error_panic_hook = "0.1" -js-sys = "0.3" -wasm-bindgen = "= 0.2.70" -wee_alloc = "0.4" +[lib] +name="otter_wasm" +path="wasm.rs" +crate-type=["cdylib"] -# Repeated here because importing does not work properly -fehler = "1" +[package] +edition="2018" +license="AGPL-3.0-or-later" +name="otter-wasm" +version="0.0.1" +authors=["Ian Jackson "] \ No newline at end of file diff --git a/wdriver/Cargo.toml b/wdriver/Cargo.toml index 2a9bdd62..4e10399d 100644 --- a/wdriver/Cargo.toml +++ b/wdriver/Cargo.toml @@ -1,29 +1,30 @@ -# Copyright 2020-2021 Ian Jackson and contributors to Otter -# SPDX-License-Identifier: AGPL-3.0-or-later -# There is NO WARRANTY. -[package] -name = "otter-webdriver-tests" -authors = ["Ian Jackson "] -license = "AGPL-3.0-or-later" - -version = "0.0.1" -edition = "2018" +[[bin]] +name="wdriver" +path="wdriver.rs" [dependencies] -otter-api-tests = { path = "../apitest" } +fehler="1" +ndarray="0.14" +num-traits="0.2" +structopt="0.3" +thirtyfour_sync="0.22" +x11rb="0.8" -ndarray = "0.14" -thirtyfour_sync = "0.22" -x11rb = "0.8" +[dependencies.otter-api-tests] +path="../apitest" -# Repeated here because importing does not work properly -fehler = "1" -num-traits = "0.2" -serde = { version = "1", features = ["derive","rc"] } -structopt = "0.3" -strum = { version = "0.20", features = ['derive'] } +[dependencies.serde] +version="1" +features=["derive", "rc"] -[[bin]] -name = "wdriver" -path = "wdriver.rs" +[dependencies.strum] +version="0.20" +features=["derive"] + +[package] +edition="2018" +license="AGPL-3.0-or-later" +name="otter-webdriver-tests" +version="0.0.1" +authors=["Ian Jackson "] \ No newline at end of file