mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
Fixed some dialogs for human players that were not shown after a reconnect to a game (e.g choose mulligan, any use Yes/No choice, amount choice, Pile choice).
This commit is contained in:
parent
758f56792e
commit
39e62095e4
3 changed files with 69 additions and 85 deletions
|
|
@ -184,13 +184,7 @@ public class HelperPanel extends JPanel {
|
|||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (linkSpecial != null) {
|
||||
{
|
||||
// if (evt.getActionCommand().equals("automatic")) {
|
||||
// showPopupMenu(evt);
|
||||
// } else {
|
||||
clickButton(linkSpecial);
|
||||
// }
|
||||
}
|
||||
clickButton(linkSpecial);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Arrow extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = -4631054277822828303L;
|
||||
|
||||
private int startX;
|
||||
|
|
@ -27,21 +27,25 @@ public class Arrow extends JPanel {
|
|||
private Composite composite;
|
||||
private Color color = Color.red;
|
||||
|
||||
public Arrow () {
|
||||
public Arrow() {
|
||||
setOpaque(false);
|
||||
setOpacity(0.6f);
|
||||
}
|
||||
|
||||
protected void paintComponent (Graphics g) {
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
float ex = endX - startX;
|
||||
float ey = endY - startY;
|
||||
if (ex == 0 && ey == 0) return;
|
||||
float length = (float)Math.sqrt(ex * ex + ey * ey);
|
||||
float bendPercent = (float)Math.asin(ey / length);
|
||||
if (endX > startX) bendPercent = -bendPercent;
|
||||
if (ex == 0 && ey == 0) {
|
||||
return;
|
||||
}
|
||||
float length = (float) Math.sqrt(ex * ex + ey * ey);
|
||||
float bendPercent = (float) Math.asin(ey / length);
|
||||
if (endX > startX) {
|
||||
bendPercent = -bendPercent;
|
||||
}
|
||||
Area arrow = getArrow(length, bendPercent);
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.translate(startX, startY);
|
||||
g2d.rotate(Math.atan2(ey, ex));
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
|
@ -52,16 +56,16 @@ public class Arrow extends JPanel {
|
|||
g2d.draw(arrow);
|
||||
}
|
||||
|
||||
private Area getArrow (float length, float bendPercent) {
|
||||
private Area getArrow(float length, float bendPercent) {
|
||||
float p1x = 0, p1y = 0;
|
||||
float p2x = length, p2y = 0;
|
||||
float cx = length / 2, cy = length / 8f * bendPercent;
|
||||
|
||||
float adjSize, ex, ey, abs_e;
|
||||
adjSize = (float)(bodyWidth / 2 / Math.sqrt(2));
|
||||
adjSize = (float) (bodyWidth / 2 / Math.sqrt(2));
|
||||
ex = p2x - cx;
|
||||
ey = p2y - cy;
|
||||
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
|
||||
abs_e = (float) Math.sqrt(ex * ex + ey * ey);
|
||||
ex /= abs_e;
|
||||
ey /= abs_e;
|
||||
GeneralPath bodyPath = new GeneralPath();
|
||||
|
|
@ -71,10 +75,10 @@ public class Arrow extends JPanel {
|
|||
bodyPath.quadTo(cx, cy, p2x - (ey + ex) * adjSize, p2y + (ex - ey) * adjSize);
|
||||
bodyPath.closePath();
|
||||
|
||||
adjSize = (float)(headSize / Math.sqrt(2));
|
||||
adjSize = (float) (headSize / Math.sqrt(2));
|
||||
ex = p2x - cx;
|
||||
ey = p2y - cy;
|
||||
abs_e = (float)Math.sqrt(ex * ex + ey * ey);
|
||||
abs_e = (float) Math.sqrt(ex * ex + ey * ey);
|
||||
ex /= abs_e;
|
||||
ey /= abs_e;
|
||||
GeneralPath headPath = new GeneralPath();
|
||||
|
|
@ -88,23 +92,23 @@ public class Arrow extends JPanel {
|
|||
return area;
|
||||
}
|
||||
|
||||
public int getBodyWidth () {
|
||||
public int getBodyWidth() {
|
||||
return bodyWidth;
|
||||
}
|
||||
|
||||
public void setBodyWidth (int bodyWidth) {
|
||||
public void setBodyWidth(int bodyWidth) {
|
||||
this.bodyWidth = bodyWidth;
|
||||
}
|
||||
|
||||
public float getHeadSize () {
|
||||
public float getHeadSize() {
|
||||
return headSize;
|
||||
}
|
||||
|
||||
public void setHeadSize (float headSize) {
|
||||
public void setHeadSize(float headSize) {
|
||||
this.headSize = headSize;
|
||||
}
|
||||
|
||||
public void setArrowLocation (int startX, int startY, int endX, int endY) {
|
||||
public void setArrowLocation(int startX, int startY, int endX, int endY) {
|
||||
this.startX = startX;
|
||||
this.startY = startY;
|
||||
this.endX = endX;
|
||||
|
|
@ -112,7 +116,7 @@ public class Arrow extends JPanel {
|
|||
repaint();
|
||||
}
|
||||
|
||||
public void setOpacity (float opacity) {
|
||||
public void setOpacity(float opacity) {
|
||||
composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +124,7 @@ public class Arrow extends JPanel {
|
|||
this.color = color;
|
||||
}
|
||||
|
||||
public static void main (String[] args) {
|
||||
public static void main(String[] args) {
|
||||
final JFrame frame = new JFrame();
|
||||
frame.setLayout(new BorderLayout());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
|
@ -130,11 +134,13 @@ public class Arrow extends JPanel {
|
|||
frame.setResizable(false);
|
||||
frame.setVisible(true);
|
||||
frame.getContentPane().addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseMoved (MouseEvent e) {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
arrow.setArrowLocation(320, 240, e.getX(), e.getY());
|
||||
}
|
||||
|
||||
public void mouseDragged (MouseEvent e) {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue