From: Ian Jackson Date: Mon, 18 Apr 2022 09:18:00 +0000 (+0100) Subject: Add "p" argument to mouse_clicked_one X-Git-Tag: otter-1.1.0~483 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3907a04584ebf2ad5e9df9b35ccb86577d55c2e7;p=otter.git Add "p" argument to mouse_clicked_one Almost the callers have it and the one that doesn't (mouse_find_clicked) is about to need it in another of its branches. Signed-off-by: Ian Jackson --- diff --git a/templates/script.ts b/templates/script.ts index c24ef095..ab7b2ab6 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -993,8 +993,7 @@ function ungrab_clicked(clicked: PieceId[]) { do_ungrab_n(todo); } -function mouse_clicked_one(piece: PieceId): MouseFindClicked { - let p = pieces[piece]!; +function mouse_clicked_one(piece: PieceId, p: PieceInfo): MouseFindClicked { let held = p.held; let pinned = p.pinned; return { clicked: [piece], held, pinned }; @@ -1077,7 +1076,7 @@ function mouse_find_lowest(e: MouseEvent) { let piece = uelem.dataset.piece!; let p = pieces[piece]!; if (p_bbox_contains(p, clickpos)) { - return mouse_clicked_one(piece); + return mouse_clicked_one(piece, p); } } return null; @@ -1089,8 +1088,9 @@ function mouse_find_clicked(e: MouseEvent, note_already: PieceSet | null, ): MouseFindClicked { + let p = pieces[piece]!; if (special_count == null) { - return mouse_clicked_one(piece); + return mouse_clicked_one(piece, p); } else if (special_count == 0) { return mouse_find_lowest(e); } else { // special_count > 0