From 1f4b70149efa938a6d70b510a4b1dae3050364b5 Mon Sep 17 00:00:00 2001 From: libccy Date: Sat, 11 Feb 2017 14:03:12 +0800 Subject: [PATCH] c --- game/game.js | 314 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 291 insertions(+), 23 deletions(-) diff --git a/game/game.js b/game/game.js index 1e5a456e7..9ee44ed77 100644 --- a/game/game.js +++ b/game/game.js @@ -20930,9 +20930,10 @@ for(var i=0;i100){ + if(ui.roundmenu._resetTimeout){ + clearTimeout(ui.roundmenu._resetTimeout); + delete ui.roundmenu._resetTimeout; + } + } + ui.roundmenu._dragtouches=e.touches[0]; + ui.click.checkroundtranslate(translate); + } + _status.clicked=true; + } + else if(_status.draggingtouchdialog){ + delete _status._swipeorigin; + if(_status.draggingtouchdialog._dragorigin&&_status.draggingtouchdialog._dragtransform&&e.touches.length){ + var translate=_status.draggingtouchdialog._dragtransform.slice(0); + var dx=e.touches[0].clientX/game.documentZoom-_status.draggingtouchdialog._dragorigin.clientX/game.documentZoom; + var dy=e.touches[0].clientY/game.documentZoom-_status.draggingtouchdialog._dragorigin.clientY/game.documentZoom; + translate[0]+=dx; + translate[1]+=dy; + _status.draggingtouchdialog._dragtouches=e.touches[0]; + ui.click.checkdialogtranslate(translate,_status.draggingtouchdialog); + } + _status.clicked=true; + } + else if(_status._swipeorigin&&e.touches[0]){ + _status._swipeorigin.touches=e.touches[0]; + } + + if(_status.mousedragging&&e.touches.length){ + e.preventDefault(); + + var items,item,iwhile,item0; + if(document.elementsFromPoint){ + items=document.elementsFromPoint(e.touches[0].clientX,e.touches[0].clientY); + } + else{ + item0=document.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY); + } + + if(items){ + iwhile=0; + item=items[0]; + } + else{ + item=item0; + } + while(item){ + if(lib.config.enable_touchdragline&&_status.mouseleft&&!game.chess){ + var i=0; + var startPoint0=[_status.mousedragging.clientX/game.documentZoom-ui.arena.offsetLeft,_status.mousedragging.clientY/game.documentZoom-ui.arena.offsetTop]; + var startPoint=startPoint0; + var endPoint; + if(_status.multitarget){ + for(;i<_status.lastdragchange.length;i++){ + var exy=_status.lastdragchange[i]._lastdragchange; + endPoint=[exy[0],exy[1]]; + _status.dragline[i]=game.linexy(startPoint.concat(endPoint),'drag',_status.dragline[i]); + startPoint=endPoint; + } + } + if(!_status.selectionfull){ + endPoint=[e.touches[0].clientX/game.documentZoom-ui.arena.offsetLeft,e.touches[0].clientY/game.documentZoom-ui.arena.offsetTop]; + _status.dragline[i]=game.linexy(startPoint.concat(endPoint),'drag',_status.dragline[i]); + startPoint=endPoint; + i++; + } + if(!_status.multitarget){ + for(;i<_status.lastdragchange.length;i++){ + var exy=_status.lastdragchange[i]._lastdragchange; + _status.dragline[i]=game.linexy(startPoint0.concat([exy[0],exy[1]]),'drag',_status.dragline[i]); + } + } + var remained=_status.dragline.splice(i); + while(remained.length){ + remained.shift().remove(); + } + // ui.canvas.width=ui.arena.offsetWidth; + // ui.canvas.height=ui.arena.offsetHeight; + // var ctx=ui.ctx; + // ctx.shadowBlur=5; + // ctx.shadowColor='rgba(0,0,0,0.3)'; + // ctx.strokeStyle='white'; + // ctx.lineWidth=3; + // ctx.setLineDash([8,2]); + // + // ctx.beginPath(); + // + // ctx.moveTo(_status.mousedragging.clientX/game.documentZoom-ui.arena.offsetLeft,_status.mousedragging.clientY/game.documentZoom-ui.arena.offsetTop); + // + // if(_status.multitarget){ + // for(var i=0;i<_status.lastdragchange.length;i++){ + // var exy=_status.lastdragchange[i]._lastdragchange; + // ctx.lineTo(exy[0],exy[1]); + // } + // } + // if(!_status.selectionfull){ + // ctx.lineTo(e.touches[0].clientX/game.documentZoom-ui.arena.offsetLeft,e.touches[0].clientY/game.documentZoom-ui.arena.offsetTop); + // } + // ctx.stroke(); + // if(!_status.multitarget){ + // for(var i=0;i<_status.lastdragchange.length;i++){ + // ctx.moveTo(_status.mousedragging.clientX/game.documentZoom-ui.arena.offsetLeft,_status.mousedragging.clientY/game.documentZoom-ui.arena.offsetTop); + // var exy=_status.lastdragchange[i]._lastdragchange; + // ctx.lineTo(exy[0],exy[1]); + // ctx.stroke(); + // } + // } + } + + if(item==_status.mousedragorigin){ + if(_status.mouseleft){ + _status.mousedragging=null; + _status.mousedragorigin=null; + _status.clicked=false; + game.uncheck(); + game.check(); + _status.clicked=true; + } + return; + } + var itemtype=get.itemtype(item); + if(itemtype=='card'||itemtype=='button'||itemtype=='player'){ + if(items) _status.mouseleft=true; + var ex=e.touches[0].clientX/game.documentZoom-ui.arena.offsetLeft; + var ey=e.touches[0].clientY/game.documentZoom-ui.arena.offsetTop; + var exx=ex,eyy=ey; + if(game.chess){ + ex-=-ui.chessContainer.scrollLeft+ui.chess.offsetLeft; + ey-=-ui.chessContainer.scrollTop+ui.chess.offsetTop; + } + if(itemtype!='player'||(ex>item.offsetLeft&&exitem.offsetTop&&ey=1000)){ _status.mousedragging=null; _status.mousedragorigin=null; _status.clicked=false; @@ -31275,7 +31489,7 @@ } var itemtype=get.itemtype(item); if(itemtype=='card'||itemtype=='button'||itemtype=='player'){ - _status.mouseleft=true; + if(items) _status.mouseleft=true; var ex=e.clientX/game.documentZoom-ui.arena.offsetLeft; var ey=e.clientY/game.documentZoom-ui.arena.offsetTop; var exx=ex,eyy=ey; @@ -31292,7 +31506,7 @@ } } if(!targetfixed&&item.classList.contains('selectable')&&_status.dragstatuschanged!=item){ - _status.mouseleft=true; + if(items) _status.mouseleft=true; _status.dragstatuschanged=item; _status.clicked=false; var notbefore=itemtype=='player'&&!item.classList.contains('selected'); @@ -31320,13 +31534,26 @@ } return; } + if(items){ + iwhile++; + item=items[iwhile]; + } + else{ + item=item.parentNode; + } } - _status.mouseleft=true; + if(items) _status.mouseleft=true; _status.dragstatuschanged=null; } else{ - for(var i=0;i