From: Ian Jackson Date: Sat, 3 Oct 2020 11:00:50 +0000 (+0100) Subject: Revert "piece_set_zlevel: provide oldbot_piece" X-Git-Tag: otter-0.2.0~780 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a5153b4c8c9bda46c87f2bedf29825d6cb1039bb;p=otter.git Revert "piece_set_zlevel: provide oldbot_piece" This was for "lower" but actually this wants to be more complicated. This reverts commit d57aa1a27fcfb65d12580a786af6193f0c8d6b4c. --- diff --git a/templates/script.ts b/templates/script.ts index 76f77f9c..940bed1e 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -559,7 +559,7 @@ function drag_mousemove(e: MouseEvent) { if (dragraise > 0 && ddr2 >= dragraise*dragraise) { dragging |= DRAGGING.RAISED; console.log('CHECK RAISE ', dragraise, dragraise*dragraise, ddr2); - piece_set_zlevel(piece,p, (oldbot_piece, oldtop_piece) => { + piece_set_zlevel(piece,p, (oldtop_piece) => { let oldtop_p = pieces[oldtop_piece]!; let z = oldtop_p.z + 1; p.z = z; @@ -666,7 +666,7 @@ function piece_modify(piece: PieceId, p: PieceInfo, info: PieceStateMessage, p.uelem.setAttributeNS(null, "y", info.pos[1]+""); p.held = info.held; p.pinned = info.pinned; - piece_set_zlevel(piece,p, (oldbot_piece, oldtop_piece)=>{ + piece_set_zlevel(piece,p, (oldtop_piece)=>{ p.z = info.z; p.zg = info.zg; p.uos = info.uos; @@ -693,8 +693,7 @@ pieceops.Insert = function */ function piece_set_zlevel(piece: PieceId, p: PieceInfo, - modify : (oldbot_piece: PieceId, oldtop_piece: PieceId) => void - ) { + modify : (oldtop_piece: PieceId) => void) { // Calls modify, which should set .z and/or .gz, and/or // make any necessary API call. // @@ -706,10 +705,7 @@ function piece_set_zlevel(piece: PieceId, p: PieceInfo, let oldtop_elem = (defs_marker.previousElementSibling! as unknown as SVGGraphicsElement); let oldtop_piece = oldtop_elem.dataset.piece!; - let oldbot_elem = (pieces_marker.nextElementSibling! as - unknown as SVGGraphicsElement); - let oldbot_piece = oldbot_elem.dataset.piece!; - modify(oldbot_piece, oldtop_piece); + modify(oldtop_piece); let ins_before = defs_marker let earlier_elem; @@ -759,7 +755,7 @@ pieceops.Move = function pieceops.SetZLevel = function (piece,p, info: { z: number, zg: Generation }) { - piece_set_zlevel(piece,p, (oldbot_piece, oldtop_piece)=>{ + piece_set_zlevel(piece,p, (oldtop_piece)=>{ let oldtop_p = pieces[oldtop_piece]!; p.z = info.z; p.zg = info.zg; @@ -785,7 +781,7 @@ messages.Recorded = function } if (j.zg != null) { var zg_new = j.zg; // type narrowing doesn't propagate :-/ - piece_set_zlevel(piece,p, (oldbot_piece, oldtop_piece: PieceId)=>{ + piece_set_zlevel(piece,p, (oldtop_piece: PieceId)=>{ p.zg = zg_new; }); }