chiark / gitweb /
js: Allow special select of pinned things in in wresting mode
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Apr 2021 19:23:43 +0000 (20:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Apr 2021 20:21:28 +0000 (21:21 +0100)
We are going to reuse this code for drag select.  Might as well let
this work, although it is a bit exciting and I think right now you
can't be in wresting mode and also special select.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts

index 64c77fa085226718e4d4ccc9850b235d26ed764f..890566a4e58990063151cd628748efeeee2d5334 100644 (file)
@@ -853,7 +853,7 @@ function mouse_find_predicate(
 ): MouseFindClicked {
   let clicked: PieceId[];
   let held;
-  let pinned;
+  let pinned = false;
 
   clicked = [];
   let uelem = defs_marker;
@@ -866,18 +866,18 @@ function mouse_find_predicate(
     }
     let piece = uelem.dataset.piece!;
     let p = pieces[piece];
+    if (p.pinned && !wresting) continue;
     if (!predicate(p)) {
       continue;
     }
+    if (p.pinned) pinned = true;
     if (i > 0) {
-      if (p.pinned != pinned ||
-         p.held   != held) {
-       add_log_message(`Mixed pinned/held states!  Stopped after ${i}`);
+      if (p.held   != held) {
+       add_log_message(`Mixed held states!  Stopped after ${i}`);
        return null;
       }
     }
     clicked.push(piece);
-    pinned = p.pinned;
     held   = p.held;
   }
   if (clicked.length == 0) return null;