This commit is contained in:
libccy 2017-02-11 14:03:12 +08:00
parent 540a4e438a
commit 1f4b70149e
1 changed files with 291 additions and 23 deletions

View File

@ -20930,9 +20930,10 @@
for(var i=0;i<game.players.length;i++){
game.players[i].unprompt();
}
while(_status.dragline.length){
_status.dragline.shift().delete();
for(var i=0;i<_status.dragline.length;i++){
if(_status.dragline[i]) _status.dragline[i].remove();
}
_status.dragline.length=0;
},
swapSeat:function(player1,player2,prompt,behind){
if(behind){
@ -30866,9 +30867,8 @@
if(_status.mousedragging&&e.touches.length){
e.preventDefault();
var items=document.elementsFromPoint(e.touches[0].clientX,e.touches[0].clientY);
for(var i=0;i<items.length;i++){
var item=items[i];
var item=document.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY);
while(item){
if(lib.config.enable_touchdragline&&_status.mouseleft&&!game.chess){
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
@ -31009,11 +31009,209 @@
}
return;
}
item=item.parentNode;
}
_status.mouseleft=true;
_status.dragstatuschanged=null;
}
},
windowtouchmove_tmp:function(e){
e.preventDefault();
if(window.inSplash) return;
if(_status.draggingroundmenu){
delete _status._swipeorigin;
if(ui.roundmenu._dragorigin&&ui.roundmenu._dragtransform&&e.touches.length){
var translate=ui.roundmenu._dragtransform.slice(0);
var dx=e.touches[0].clientX/game.documentZoom-ui.roundmenu._dragorigin.clientX/game.documentZoom;
var dy=e.touches[0].clientY/game.documentZoom-ui.roundmenu._dragorigin.clientY/game.documentZoom;
translate[0]+=dx;
translate[1]+=dy;
if(dx*dx+dy*dy>100){
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&&ex<item.offsetLeft+item.offsetWidth&&
ey>item.offsetTop&&ey<item.offsetTop+item.offsetHeight)){
var targetfixed=false;
if(itemtype=='player'){
if(get.select(_status.event.selectTarget)[1]==-1){
targetfixed=true;
}
}
if(!targetfixed&&item.classList.contains('selectable')&&_status.dragstatuschanged!=item){
if(items) _status.mouseleft=true;
_status.dragstatuschanged=item;
_status.clicked=false;
_status.dragged=false;
var notbefore=itemtype=='player'&&!item.classList.contains('selected');
ui.click[itemtype].call(item);
if(item.classList.contains('selected')){
if(notbefore){
_status.lastdragchange.push(item);
item._lastdragchange=[exx,eyy];
}
}
else{
_status.lastdragchange.remove(item);
for(var i=0;i<ui.touchlines.length;i++){
if(ui.touchlines[i]._origin==item){
ui.touchlines[i].delete();
ui.touchlines.splice(i--,1);
}
}
}
_status.selectionfull=true;
if(_status.event.filterButton&&ui.selected.buttons.length<get.select(_status.event.selectButton)[1]){
_status.selectionfull=false;
}
else if(_status.event.filterCard&&ui.selected.cards.length<get.select(_status.event.selectCard)[1]){
_status.selectionfull=false;
}
else if(_status.event.filterTarget&&ui.selected.targets.length<get.select(_status.event.selectTarget)[1]){
_status.selectionfull=false;
}
}
}
return;
}
if(items){
iwhile++
item=items[iwhile];
}
else{
item=item.parentNode;
}
}
if(items) _status.mouseleft=true;
_status.dragstatuschanged=null;
}
},
windowtouchend:function(e){
if(window.inSplash) return;
if(e.touches.length==1&&!_status.dragged&&!_status.draggingtouchdialog){
@ -31198,7 +31396,13 @@
dialogs[i].delete();
}
var node=_status.currentmouseenter;
var items=document.elementsFromPoint(e.clientX,e.clientY);
var items,item,iwhile,item0;
if(document.elementsFromPoint){
items=document.elementsFromPoint(e.clientX,e.clientY);
}
else{
item0=document.elementFromPoint(e.clientX,e.clientY);
}
if(_status.mousedragging){
e.preventDefault();
if(lib.config.enable_dragline){
@ -31221,12 +31425,16 @@
i++;
}
if(!_status.multitarget){
for(;i<_status.lastdragchange.length;i++){
var exy=_status.lastdragchange[i]._lastdragchange;
for(var j=0;j<_status.lastdragchange.length;j++){
i+=j;
var exy=_status.lastdragchange[j]._lastdragchange;
_status.dragline[i]=game.linexy(startPoint0.concat([exy[0],exy[1]]),'drag',_status.dragline[i]);
}
}
_status.dragline.splice(i);
var remained=_status.dragline.splice(i+1);
for(var j=0;j<remained.length;j++){
if(remained[j]) remained[j].remove();
}
// ui.canvas.width=ui.arena.offsetWidth;
// ui.canvas.height=ui.arena.offsetHeight;
@ -31260,10 +31468,16 @@
// }
}
for(var i=0;i<items.length;i++){
var item=items[i];
if(items){
iwhile=0;
item=items[0];
}
else{
item=item0;
}
while(item){
if(item==_status.mousedragorigin){
if(_status.mouseleft){
if((items&&_status.mouseleft)||(!items&&get.utc()-_status.lastmouseutc>=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];
}
_status.mouseleft=true;
else{
item=item.parentNode;
}
}
if(items) _status.mouseleft=true;
_status.dragstatuschanged=null;
}
else{
for(var i=0;i<items.length;i++){
var item=items[i];
if(items){
iwhile=0;
item=items[0];
}
else{
item=item0;
}
while(item){
if(item==node&&!node._mouseentercreated){
ui.click.mouseentercancel();
var hoveration;
@ -31362,6 +31589,13 @@
},hoveration);
break;
}
if(items){
iwhile++;
item=items[iwhile];
}
else{
item=item.parentNode;
}
}
if(_status.draggingdialog){
var ddialog=_status.draggingdialog;
@ -31392,9 +31626,22 @@
for(var i=0;i<dialogs.length;i++){
dialogs[i].delete();
}
var items=document.elementsFromPoint(e.clientX,e.clientY);
for(var i=0;i<items.length;i++){
var item=items[i];
var items,item,iwhile,item0;
if(document.elementsFromPoint){
items=document.elementsFromPoint(e.clientX,e.clientY);
}
else{
item=document.elementFromPoint(e.clientX,e.clientY);
item0=item;
}
if(items){
iwhile=0;
item=items[0];
}
else{
item=item0;
}
while(item){
var itemtype=get.itemtype(item);
if(itemtype=='button') break;
if(itemtype=='dialog'&&
@ -31416,6 +31663,13 @@
}
return;
}
if(items){
iwhile++;
item=items[iwhile];
}
else{
item=item.parentNode;
}
}
var evt=_status.event;
@ -31423,8 +31677,14 @@
if(!ui.arena.classList.contains('selecting')) return;
if(!evt.isMine()) return;
for(var i=0;i<items.length;i++){
var item=items[i];
if(items){
iwhile=0;
item=items[0];
}
else{
item=item0;
}
while(item){
var itemtype=get.itemtype(item);
if(itemtype=='card'||itemtype=='button'||itemtype=='player'){
if(item.classList.contains('selectable')&&
@ -31438,10 +31698,18 @@
_status.mouseleft=false;
_status.selectionfull=false;
_status.multitarget=false;
_status.lastmouseutc=get.utc();
}
}
return;
}
if(items){
iwhile++;
item=items[iwhile];
}
else{
item=item.parentNode;
}
}
},
cardtouchstart:function(e){
@ -31527,7 +31795,7 @@
else{
var tmpflag=false;
_status.mousedown=false;
if(_status.mousedragging&&_status.mouseleft){
if(_status.mousedragging&&(_status.mouseleft||!document.elementsFromPoint)){
if(game.check()){
if(ui.confirm){
ui.confirm.close();