mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Closed #169: Make it possible to untap lands
This commit is contained in:
parent
dd9aec6a49
commit
29b84e0d92
24 changed files with 244 additions and 207 deletions
|
|
@ -43,7 +43,6 @@ import mage.client.util.gui.ArrowBuilder;
|
|||
import mage.remote.Session;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -117,6 +116,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Cancel");
|
||||
this.helper.setState("", false, "Cancel", true);
|
||||
this.helper.setUndoEnabled(false);
|
||||
break;
|
||||
case SELECT:
|
||||
this.btnLeft.setVisible(false);
|
||||
|
|
@ -149,7 +149,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.helper.setLinks(btnLeft, btnRight, btnSpecial);
|
||||
this.helper.setLinks(btnLeft, btnRight, btnSpecial, btnUndo);
|
||||
|
||||
this.helper.setVisible(true);
|
||||
}
|
||||
|
|
@ -205,7 +205,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void clear() {
|
||||
// stopModal();
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(false);
|
||||
this.btnSpecial.setVisible(false);
|
||||
|
|
@ -213,138 +212,14 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
logger.debug("feedback - clear");
|
||||
}
|
||||
|
||||
// public void clear0() {
|
||||
// stopModal();
|
||||
// }
|
||||
|
||||
// private synchronized void startModal() {
|
||||
//
|
||||
// try {
|
||||
// if (SwingUtilities.isEventDispatchThread()) {
|
||||
// EventQueue theQueue = getToolkit().getSystemEventQueue();
|
||||
// while (!selected) {
|
||||
// AWTEvent event = theQueue.getNextEvent();
|
||||
// Object source = event.getSource();
|
||||
// boolean dispatch = true;
|
||||
//
|
||||
// if (event instanceof MouseEvent) {
|
||||
// MouseEvent e = (MouseEvent) event;
|
||||
// MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
// if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
|
||||
// dispatch = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (dispatch) {
|
||||
// if (event instanceof ActiveEvent) {
|
||||
// ((ActiveEvent) event).dispatch();
|
||||
// } else if (source instanceof Component) {
|
||||
// ((Component) source).dispatchEvent(event);
|
||||
// } else if (source instanceof MenuComponent) {
|
||||
// ((MenuComponent) source).dispatchEvent(event);
|
||||
// } else {
|
||||
// logger.warn("Unable to dispatch: " + event);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// while (!selected) {
|
||||
// wait();
|
||||
// }
|
||||
// }
|
||||
// } catch (InterruptedException ignored) {
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private synchronized void stopModal() {
|
||||
// notifyAll();
|
||||
// }
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
btnRight = new javax.swing.JButton();
|
||||
btnLeft = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
//lblMessage = new javax.swing.JTextArea();
|
||||
lblMessage = new MageTextArea();
|
||||
btnSpecial = new javax.swing.JButton();
|
||||
|
||||
setBackground(new java.awt.Color(255,255,255,200));
|
||||
|
||||
btnRight.setText("Cancel");
|
||||
btnRight.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnRightActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
btnLeft.setText("OK");
|
||||
btnLeft.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnLeftActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
//lblMessage.setBackground(new java.awt.Color(204, 204, 204));
|
||||
/*lblMessage.setColumns(20);
|
||||
lblMessage.setEditable(false);
|
||||
lblMessage.setLineWrap(true);
|
||||
lblMessage.setRows(2);
|
||||
lblMessage.setWrapStyleWord(true);*/
|
||||
|
||||
lblMessage.setBorder(null);
|
||||
jScrollPane1.setViewportView(lblMessage);
|
||||
jScrollPane1.setBorder(null);
|
||||
|
||||
btnSpecial.setText("Special");
|
||||
btnSpecial.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnSpecialActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSpecial)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
|
||||
.addComponent(btnLeft)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnRight))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnRight)
|
||||
.addComponent(btnLeft)
|
||||
.addComponent(btnSpecial)))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public void customInitComponents() {
|
||||
btnRight = new javax.swing.JButton();
|
||||
btnLeft = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
lblMessage = new MageTextArea();
|
||||
btnSpecial = new javax.swing.JButton();
|
||||
btnUndo = new javax.swing.JButton();
|
||||
btnUndo.setVisible(true);
|
||||
|
||||
setBackground(new java.awt.Color(0,0,0,80));
|
||||
|
||||
|
|
@ -379,26 +254,18 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
JLabel jlabel = new JLabel();
|
||||
jlabel.setLayout(new BorderLayout());
|
||||
jlabel.add(jScrollPane1, BorderLayout.CENTER);
|
||||
btnUndo.setText("Undo");
|
||||
btnUndo.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnUndoActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
JLabel jlabel2 = new JLabel();
|
||||
jlabel2.setLayout(new FlowLayout());
|
||||
jlabel2.add(btnSpecial);
|
||||
jlabel2.add(btnLeft);
|
||||
jlabel2.add(btnRight);
|
||||
jlabel2.setPreferredSize(new Dimension(0, 35));
|
||||
|
||||
add(jlabel, BorderLayout.CENTER);
|
||||
add(jlabel2, BorderLayout.PAGE_END);
|
||||
}
|
||||
|
||||
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
|
||||
this.selected = true;
|
||||
// clear0();
|
||||
if (connectedDialog != null) {
|
||||
connectedDialog.hideDialog();
|
||||
}
|
||||
|
|
@ -414,7 +281,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
|
||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||
this.selected = true;
|
||||
// clear0();
|
||||
session.sendPlayerBoolean(gameId, true);
|
||||
AudioManager.playButtonCancel();
|
||||
}//GEN-LAST:event_btnLeftActionPerformed
|
||||
|
|
@ -423,6 +289,10 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
session.sendPlayerString(gameId, "special");
|
||||
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||
|
||||
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
||||
session.undo(gameId);
|
||||
}
|
||||
|
||||
public void setHelperPanel(HelperPanel helper) {
|
||||
this.helper = helper;
|
||||
}
|
||||
|
|
@ -443,9 +313,18 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void allowUndo(int bookmark) {
|
||||
this.helper.setUndoEnabled(true);
|
||||
}
|
||||
|
||||
public void disableUndo() {
|
||||
this.helper.setUndoEnabled(false);
|
||||
}
|
||||
|
||||
private javax.swing.JButton btnLeft;
|
||||
private javax.swing.JButton btnRight;
|
||||
private javax.swing.JButton btnSpecial;
|
||||
private javax.swing.JButton btnUndo;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
//private javax.swing.JTextArea lblMessage;
|
||||
private MageTextArea lblMessage;
|
||||
|
|
|
|||
|
|
@ -490,6 +490,14 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
} else {
|
||||
CombatManager.getInstance().hideCombat(gameId);
|
||||
}
|
||||
|
||||
System.out.println("Size: " + game.getStatesSavedSize());
|
||||
if (game.getStatesSavedSize() > 0) {
|
||||
feedbackPanel.allowUndo(game.getStatesSavedSize());
|
||||
} else {
|
||||
feedbackPanel.disableUndo();
|
||||
}
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@
|
|||
package mage.client.game;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import mage.client.components.MageTextArea;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Panel with buttons that copy the state of feedback panel.
|
||||
*
|
||||
|
|
@ -43,6 +44,7 @@ public class HelperPanel extends JPanel {
|
|||
private javax.swing.JButton btnLeft;
|
||||
private javax.swing.JButton btnRight;
|
||||
private javax.swing.JButton btnSpecial;
|
||||
private javax.swing.JButton btnUndo;
|
||||
//private javax.swing.JButton btnEndTurn;
|
||||
//private javax.swing.JButton btnStopTimer;
|
||||
|
||||
|
|
@ -52,6 +54,7 @@ public class HelperPanel extends JPanel {
|
|||
private javax.swing.JButton linkLeft;
|
||||
private javax.swing.JButton linkRight;
|
||||
private javax.swing.JButton linkSpecial;
|
||||
private javax.swing.JButton linkUndo;
|
||||
|
||||
public HelperPanel() {
|
||||
initComponents();
|
||||
|
|
@ -89,6 +92,9 @@ public class HelperPanel extends JPanel {
|
|||
btnRight = new JButton("Cancel");
|
||||
btnRight.setVisible(false);
|
||||
container.add(btnRight);
|
||||
btnUndo = new JButton("Undo");
|
||||
btnUndo.setVisible(false);
|
||||
container.add(btnUndo);
|
||||
|
||||
btnLeft.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
|
|
@ -122,6 +128,15 @@ public class HelperPanel extends JPanel {
|
|||
}}
|
||||
}
|
||||
});
|
||||
|
||||
btnUndo.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (linkUndo != null) {{
|
||||
linkUndo.doClick();
|
||||
}}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setState(String txtLeft, boolean leftVisible, String txtRight, boolean rightVisible) {
|
||||
|
|
@ -140,6 +155,10 @@ public class HelperPanel extends JPanel {
|
|||
this.btnSpecial.setText(txtSpecial);
|
||||
}
|
||||
|
||||
public void setUndoEnabled(boolean enabled) {
|
||||
this.btnUndo.setVisible(enabled);
|
||||
}
|
||||
|
||||
public void setRight(String txtRight, boolean rightVisible) {
|
||||
this.btnRight.setVisible(rightVisible);
|
||||
if (!txtRight.isEmpty()) {
|
||||
|
|
@ -147,10 +166,11 @@ public class HelperPanel extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void setLinks(JButton left, JButton right, JButton special) {
|
||||
public void setLinks(JButton left, JButton right, JButton special, JButton undo) {
|
||||
this.linkLeft = left;
|
||||
this.linkRight = right;
|
||||
this.linkSpecial = special;
|
||||
this.linkUndo = undo;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue