From: Ian Jackson Date: Wed, 30 Sep 2020 19:11:15 +0000 (+0100) Subject: wip keybindings X-Git-Tag: otter-0.2.0~816 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ac60af3d8dcae31471be7558c4f3df6f4f2812d9;p=otter.git wip keybindings Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index f2a2ede0..53b759aa 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -89,7 +89,7 @@ pub trait Outline : Send + Debug { } #[derive(Debug,Copy,Clone,Serialize,Deserialize)] -pub enum UoKind { Global, Piece, } +pub enum UoKind { Global, Piece, GlobalExtra, } pub type UoKey = char; @@ -274,6 +274,12 @@ impl PieceExt for T where T: Piece + ?Sized { desc: Html::lit("flip"), }) } + out.push(UoDescription { + kind: UoKind::GlobalExtra, + def_key: 'l'.into(), + opname: "lower".to_string(), + desc: Html::lit("lower (send to bottom)"), + }); self.add_ui_operations(&mut out)?; out } diff --git a/templates/script.ts b/templates/script.ts index ce3d6b22..50514302 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -46,7 +46,7 @@ type PlayerId = string; type Pos = [number, number]; type ClientSeq = number; type Generation = number; -type UoKind = "Global"| "Piece" | "ClientExtra"; +type UoKind = "Global"| "Piece" | "ClientExtra" | "GlobalExtra"; type UoDescription = { kind: UoKind; @@ -103,6 +103,7 @@ var status_node : HTMLElement; var uos_node : HTMLElement; const uo_kind_prec : { [kind: string]: number } = { + 'GlobalExtra' : 50, 'Global' : 100, 'Piece' : 200, 'ClientExtra' : 500, @@ -640,6 +641,7 @@ function test_swap_stack() { } function recompute_keybindings() { + uo_map = Object.create(null); for (let piece of Object.keys(pieces)) { let p = pieces[piece]; if (p.held != us) continue; @@ -681,8 +683,8 @@ function recompute_keybindings() { for (var kk of uo_keys) { let uo = uo_map[kk]!; let ent = document.createElement('div'); - ent.setAttribute('class','uokey'); - ent.innerHTML = '' + kk + '' + uo.desc; + ent.setAttribute('class','uokey-'+uo.kind); + ent.innerHTML = '' + kk + ' ' + uo.desc; out.appendChild(ent); } uos_node.firstChild!.replaceWith(out); @@ -755,6 +757,7 @@ function startup() { update_oe : (e as any).className, }) } + recompute_keybindings(); // test_swap_stack(); } diff --git a/templates/session.tera b/templates/session.tera index 829f4605..65b9e655 100644 --- a/templates/session.tera +++ b/templates/session.tera @@ -7,8 +7,17 @@ SPDX-License-Identifier: AGPL-3.0-or-later There is NO WARRANTY. -->

Hi {{nick | escape}}!