This commit is contained in:
libccy 2017-02-11 11:43:16 +08:00
parent 824c9a02a2
commit 540a4e438a
2 changed files with 116 additions and 57 deletions

View File

@ -13,7 +13,8 @@
ai:{}, ai:{},
lastdragchange:[], lastdragchange:[],
skillaudio:[], skillaudio:[],
dieClose:[] dieClose:[],
dragline:[],
}; };
var lib={ var lib={
configprefix:'noname_0.9_', configprefix:'noname_0.9_',
@ -19254,6 +19255,7 @@
var opacity=1; var opacity=1;
var color=[255,255,255]; var color=[255,255,255];
var dashed=false; var dashed=false;
var drag=false;
if(typeof arguments[1]=='object'){ if(typeof arguments[1]=='object'){
for(var i in arguments[1]){ for(var i in arguments[1]){
switch(i){ switch(i){
@ -19276,11 +19278,33 @@
else if(color=='green'){ else if(color=='green'){
color=[141, 255, 216]; color=[141, 255, 216];
} }
var node=ui.create.div('.linexy.hidden'); var node;
node.style.transitionDuration=(total/3000)+'s'; if(arguments[1]=='drag'){
node.style.left=from[0]+'px'; color=[236, 201, 71];
node.style.top=from[1]+'px'; drag=true;
node.style.background='linear-gradient(transparent,rgba('+color.toString()+','+opacity+'),rgba('+color.toString()+','+opacity+'))'; if(arguments[2]){
node=arguments[2]
}
else{
node=ui.create.div('.linexy.drag');
node.style.left=from[0]+'px';
node.style.top=from[1]+'px';
node.style.background='linear-gradient(transparent,rgba('+color.toString()+','+opacity+'),rgba('+color.toString()+','+opacity+'))';
if(game.chess){
ui.chess.appendChild(node);
}
else{
ui.arena.appendChild(node);
}
}
}
else{
node=ui.create.div('.linexy.hidden');
node.style.left=from[0]+'px';
node.style.top=from[1]+'px';
node.style.background='linear-gradient(transparent,rgba('+color.toString()+','+opacity+'),rgba('+color.toString()+','+opacity+'))';
node.style.transitionDuration=(total/3000)+'s';
}
var dy=to[1]-from[1]; var dy=to[1]-from[1];
var dx=to[0]-from[0]; var dx=to[0]-from[0];
var deg=Math.atan(Math.abs(dy)/Math.abs(dx))/Math.PI*180; var deg=Math.atan(Math.abs(dy)/Math.abs(dx))/Math.PI*180;
@ -19300,23 +19324,30 @@
deg+=270; deg+=270;
} }
} }
node.style.transform='rotate('+(-deg)+'deg) scaleY(0)'; if(drag){
node.style.height=get.xyDistance(from,to)+'px'; node.style.transform='rotate('+(-deg)+'deg)';
if(game.chess){ node.style.height=get.xyDistance(from,to)+'px';
ui.chess.appendChild(node);
} }
else{ else{
ui.arena.appendChild(node); node.style.transform='rotate('+(-deg)+'deg) scaleY(0)';
node.style.height=get.xyDistance(from,to)+'px';
if(game.chess){
ui.chess.appendChild(node);
}
else{
ui.arena.appendChild(node);
}
ui.refresh(node);
node.show();
node.style.transform='rotate('+(-deg)+'deg) scaleY(1)';
node.listenTransition(function(){
setTimeout(function(){
if(node.classList.contains('removing')) return;
node.delete();
},total/3);
});
} }
ui.refresh(node); return node;
node.show();
node.style.transform='rotate('+(-deg)+'deg) scaleY(1)';
node.listenTransition(function(){
setTimeout(function(){
if(node.classList.contains('removing')) return;
node.delete();
},total/3);
});
}, },
_linexy:function(path){ _linexy:function(path){
var from=[path[0],path[1]]; var from=[path[0],path[1]];
@ -20899,6 +20930,9 @@
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
game.players[i].unprompt(); game.players[i].unprompt();
} }
while(_status.dragline.length){
_status.dragline.shift().delete();
}
}, },
swapSeat:function(player1,player2,prompt,behind){ swapSeat:function(player1,player2,prompt,behind){
if(behind){ if(behind){
@ -30832,8 +30866,9 @@
if(_status.mousedragging&&e.touches.length){ if(_status.mousedragging&&e.touches.length){
e.preventDefault(); e.preventDefault();
var item=document.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY); var items=document.elementsFromPoint(e.touches[0].clientX,e.touches[0].clientY);
while(item){ for(var i=0;i<items.length;i++){
var item=items[i];
if(lib.config.enable_touchdragline&&_status.mouseleft&&!game.chess){ if(lib.config.enable_touchdragline&&_status.mouseleft&&!game.chess){
ui.canvas.width=ui.arena.offsetWidth; ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight; ui.canvas.height=ui.arena.offsetHeight;
@ -30974,7 +31009,6 @@
} }
return; return;
} }
item=item.parentNode;
} }
_status.mouseleft=true; _status.mouseleft=true;
_status.dragstatuschanged=null; _status.dragstatuschanged=null;
@ -31164,44 +31198,70 @@
dialogs[i].delete(); dialogs[i].delete();
} }
var node=_status.currentmouseenter; var node=_status.currentmouseenter;
var sourceitem=document.elementFromPoint(e.clientX,e.clientY); var items=document.elementsFromPoint(e.clientX,e.clientY);
if(_status.mousedragging){ if(_status.mousedragging){
e.preventDefault(); e.preventDefault();
if(lib.config.enable_dragline){ if(lib.config.enable_dragline){
ui.canvas.width=ui.arena.offsetWidth; var i=0;
ui.canvas.height=ui.arena.offsetHeight; var startPoint0=[_status.mousedragging.clientX/game.documentZoom-ui.arena.offsetLeft,_status.mousedragging.clientY/game.documentZoom-ui.arena.offsetTop];
var ctx=ui.ctx; var startPoint=startPoint0;
ctx.shadowBlur=5; var endPoint;
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){ if(_status.multitarget){
for(var i=0;i<_status.lastdragchange.length;i++){ for(;i<_status.lastdragchange.length;i++){
var exy=_status.lastdragchange[i]._lastdragchange; var exy=_status.lastdragchange[i]._lastdragchange;
ctx.lineTo(exy[0],exy[1]); endPoint=[exy[0],exy[1]];
_status.dragline[i]=game.linexy(startPoint.concat(endPoint),'drag',_status.dragline[i]);
startPoint=endPoint;
} }
} }
if(!_status.selectionfull){ if(!_status.selectionfull){
ctx.lineTo(e.clientX/game.documentZoom-ui.arena.offsetLeft,e.clientY/game.documentZoom-ui.arena.offsetTop); endPoint=[e.clientX/game.documentZoom-ui.arena.offsetLeft,e.clientY/game.documentZoom-ui.arena.offsetTop];
_status.dragline[i]=game.linexy(startPoint.concat(endPoint),'drag',_status.dragline[i]);
startPoint=endPoint;
i++;
} }
ctx.stroke();
if(!_status.multitarget){ if(!_status.multitarget){
for(var i=0;i<_status.lastdragchange.length;i++){ for(;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; var exy=_status.lastdragchange[i]._lastdragchange;
ctx.lineTo(exy[0],exy[1]); _status.dragline[i]=game.linexy(startPoint0.concat([exy[0],exy[1]]),'drag',_status.dragline[i]);
ctx.stroke();
} }
} }
_status.dragline.splice(i);
// 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.clientX/game.documentZoom-ui.arena.offsetLeft,e.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();
// }
// }
} }
var item=sourceitem; for(var i=0;i<items.length;i++){
while(item){ var item=items[i];
if(item==_status.mousedragorigin){ if(item==_status.mousedragorigin){
if(_status.mouseleft){ if(_status.mouseleft){
_status.mousedragging=null; _status.mousedragging=null;
@ -31260,14 +31320,13 @@
} }
return; return;
} }
item=item.parentNode;
} }
_status.mouseleft=true; _status.mouseleft=true;
_status.dragstatuschanged=null; _status.dragstatuschanged=null;
} }
else{ else{
var item=sourceitem; for(var i=0;i<items.length;i++){
while(item){ var item=items[i];
if(item==node&&!node._mouseentercreated){ if(item==node&&!node._mouseentercreated){
ui.click.mouseentercancel(); ui.click.mouseentercancel();
var hoveration; var hoveration;
@ -31303,7 +31362,6 @@
},hoveration); },hoveration);
break; break;
} }
item=item.parentNode;
} }
if(_status.draggingdialog){ if(_status.draggingdialog){
var ddialog=_status.draggingdialog; var ddialog=_status.draggingdialog;
@ -31334,9 +31392,9 @@
for(var i=0;i<dialogs.length;i++){ for(var i=0;i<dialogs.length;i++){
dialogs[i].delete(); dialogs[i].delete();
} }
var sourceitem=document.elementFromPoint(e.clientX,e.clientY); var items=document.elementsFromPoint(e.clientX,e.clientY);
var item=sourceitem; for(var i=0;i<items.length;i++){
while(item){ var item=items[i];
var itemtype=get.itemtype(item); var itemtype=get.itemtype(item);
if(itemtype=='button') break; if(itemtype=='button') break;
if(itemtype=='dialog'&& if(itemtype=='dialog'&&
@ -31358,7 +31416,6 @@
} }
return; return;
} }
item=item.parentNode;
} }
var evt=_status.event; var evt=_status.event;
@ -31366,8 +31423,8 @@
if(!ui.arena.classList.contains('selecting')) return; if(!ui.arena.classList.contains('selecting')) return;
if(!evt.isMine()) return; if(!evt.isMine()) return;
item=sourceitem; for(var i=0;i<items.length;i++){
while(item){ var item=items[i];
var itemtype=get.itemtype(item); var itemtype=get.itemtype(item);
if(itemtype=='card'||itemtype=='button'||itemtype=='player'){ if(itemtype=='card'||itemtype=='button'||itemtype=='player'){
if(item.classList.contains('selectable')&& if(item.classList.contains('selectable')&&
@ -31385,7 +31442,6 @@
} }
return; return;
} }
item=item.parentNode;
} }
}, },
cardtouchstart:function(e){ cardtouchstart:function(e){

View File

@ -719,6 +719,9 @@ table {
box-shadow: rgba(0,0,0,0.5) 0 0 2px; box-shadow: rgba(0,0,0,0.5) 0 0 2px;
transform-origin: top center; transform-origin: top center;
} }
.linexy.drag{
transition-property: none !important;
}
#me,#mebg { #me,#mebg {
width: 100%; width: 100%;
height: 140px; height: 140px;