From 0c9b650384b283370476903b08adabb5e1b20d51 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 13 Apr 2021 21:05:50 +0100 Subject: [PATCH] js: Provide ungrab_all_except (and PieceSet) Nothing calls the new function yet. Signed-off-by: Ian Jackson --- templates/script.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/script.ts b/templates/script.ts index 26c8b35e..0ad65c1f 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -840,6 +840,8 @@ type MouseFindClicked = null | { pinned: boolean }; +type PieceSet = { [piece: string]: true }; + function grab_clicked(clicked: PieceId[]) { for (let piece of clicked) { let p = pieces[piece]!; @@ -1015,14 +1017,18 @@ function p_bbox_contains(p: PieceInfo, test: Pos) { return true; } -function ungrab_all() { +function ungrab_all_except(dont: PieceSet | null) { for (let tpiece of Object.keys(pieces)) { + if (dont && dont[tpiece]) continue; let tp = pieces[tpiece]!; if (tp.held == us) { do_ungrab(tpiece,tp); } } } +function ungrab_all() { + ungrab_all_except(null); +} function set_grab_us(piece: PieceId, p: PieceInfo) { p.held = us; -- 2.30.2