chiark / gitweb /
wip keybindings
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Sep 2020 19:11:15 +0000 (20:11 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Sep 2020 19:11:15 +0000 (20:11 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
templates/script.ts
templates/session.tera

index f2a2ede0f9811d5d03cd9d0a80cef252e89f2ee2..53b759aab87018a57c11f73d97b2cda795d44c7b 100644 (file)
@@ -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<T> 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
   }
index ce3d6b228cae1c3625434117c66b044273c4d29d..50514302ec8368ae981be865240aa3e5666880fb 100644 (file)
@@ -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 = '<b>' + kk + '</bb>' + uo.desc;
+    ent.setAttribute('class','uokey-'+uo.kind);
+    ent.innerHTML = '<b>' + kk + '</b' + 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();
 }
index 829f460591943865c8f3b2f563eaedd2723ebc32..65b9e6554e5950362c1de5c317b69e8dc59c12bf 100644 (file)
@@ -7,8 +7,17 @@
      SPDX-License-Identifier: AGPL-3.0-or-later
      There is NO WARRANTY. -->
 <style>
-  div.uokeys: { }
-  div.uokey: { }
+  div.uokeys { display: flex; flex-wrap: wrap; }
+  div[class|=uokey] {
+    outline: 1px solid #000;
+    margin: 1px;
+    padding-left: 5px;
+    padding-right: 6.5px;
+  }
+  div.uokey-ClientExtra {
+    margin-left: auto;
+    margin-top: auto;
+  }
 </style>
 <h1>Hi {{nick | escape}}!</h1>
 <pre id="error"></pre>