From 9852275a95a451e390208668f8d3521b23fc72b4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 12 Jul 2020 16:41:53 +0100 Subject: [PATCH] wip halo --- templates/script.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/templates/script.ts b/templates/script.ts index e3e4bf33..b90a5bf4 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -25,9 +25,10 @@ // // currently-displayed version of the piece // to allow addition/removal of selected indication -// contains 1 or 2 subelements: -// first is straight from server and not modified -// second is possible +// contains 1 or 3 subelements: +// one is straight from server and not modified +// one is possible +// one is possible // // #select{} // generated by server, referenced by JS in pelem for selection @@ -82,6 +83,7 @@ var pieces_marker : SVGGraphicsElement; var defs_marker : SVGGraphicsElement; var logdiv : HTMLElement; var status_node : HTMLElement; +var halo : PieceId | null; type PlayerInfo = { dasharray : string, @@ -221,8 +223,8 @@ function set_grab(piece: PieceId, p: PieceInfo, owner: PlayerId) { display_grab(piece,p); } function display_grab(piece: PieceId, p: PieceInfo) { - var nelem = document.createElementNS(svg_ns,'use'); piece_undisplay_grab(piece, p); + var nelem = document.createElementNS(svg_ns,'use'); nelem.setAttributeNS(null,'href','#select'+piece); let da = players[p.held!]!.dasharray; nelem.setAttributeNS(null,'stroke-dasharray',da); @@ -352,6 +354,7 @@ pieceops.Modify = function p.pelem= piece_element('piece',piece)!; p.uelem.setAttributeNS(null, "x", info.pos[0]+""); p.uelem.setAttributeNS(null, "y", info.pos[1]+""); + if (halo == piece) { halo = null } piece_checkconflict(piece,p); if (info.held == null) { set_ungrab(piece,p); @@ -434,6 +437,18 @@ messages.Recorded = function } function piece_checkconflict(piece: PieceId, p: PieceInfo) { + if (halo != piece) { + if (halo != null) { + console.log('UNHALOING',halo); + piece_undisplay_ancillary(p, "#halo"+halo); + } + console.log('HALOING',piece); + halo = piece; + var nelem = document.createElementNS(svg_ns,'use'); + nelem.setAttributeNS(null,'href','#halo'+piece); + p.pelem.prepend(nelem); + } + if (p.cseq == null) { return; } p.cseq = null; add_log_message('Conflict! - simultaneous update'); -- 2.30.2