New helper component

This commit is contained in:
magenoxx 2012-06-27 14:25:12 +04:00
parent 2a9fc12f26
commit c2a517f1b3
3 changed files with 59 additions and 22 deletions

View file

@ -95,7 +95,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
this.btnLeft.setText("Yes");
this.btnRight.setVisible(true);
this.btnRight.setText("No");
this.helper.setState("Yes", true, "Yes", true);
this.helper.setState("Yes", true, "No", true);
break;
case CONFIRM:
this.btnLeft.setVisible(true);
@ -120,7 +120,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
this.btnLeft.setVisible(false);
this.btnRight.setVisible(true);
this.btnRight.setText("OK");
this.helper.setState("", false, "Done", true);
this.helper.setState("", false, "OK", true);
ArrowBuilder.removeAllArrows();
break;
}

View file

@ -852,8 +852,8 @@ public class GamePanel extends javax.swing.JPanel {
}
});
endButtonTip = new JLabel("<-- Press this button to end the turn");
endButtonTip.setForeground(Color.white);
//endButtonTip = new JLabel("<-- Press this button to end the turn");
//endButtonTip.setForeground(Color.white);
jPhases.add(untap);
jPhases.add(upkeep);
@ -864,10 +864,19 @@ public class GamePanel extends javax.swing.JPanel {
jPhases.add(combatButton);
jPhases.add(main2);
jPhases.add(endOfTurn);
jPhases.add(endButtonTip);
//jPhases.add(endButtonTip);
pnlReplay.setOpaque(false);
HelperPanel helper = new HelperPanel();
helper.setPreferredSize(new Dimension(100, 30));
helper.addEndTurnListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
session.sendPlayerInteger(gameId, 0);
}
}
});
feedbackPanel.setHelperPanel(helper);
jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
@ -884,18 +893,20 @@ public class GamePanel extends javax.swing.JPanel {
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
)))
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
)))
);
gl_jPanel3.setVerticalGroup(
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(jPhases, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(pnlGameInfo, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_jPanel3.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(jPhases, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(pnlGameInfo, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
);
jPanel3.setLayout(gl_jPanel3);

View file

@ -29,6 +29,8 @@
package mage.client.game;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
/**
* Panel with buttons that copy the state of feedback panel.
@ -40,22 +42,36 @@ public class HelperPanel extends JPanel {
private javax.swing.JButton btnLeft;
private javax.swing.JButton btnRight;
private javax.swing.JButton btnSpecial;
private javax.swing.JButton btnEndTurn;
//private javax.swing.JButton btnStopTimer;
private javax.swing.JButton linkLeft;
private javax.swing.JButton linkRight;
private javax.swing.JButton linkSpecial;
public HelperPanel() {
setBackground(new Color(0, 0, 0, 100));
setLayout(new GridBagLayout());
setOpaque(false);
btnSpecial = new JButton("Special");
btnSpecial.setVisible(false);
add(btnSpecial);
btnLeft = new JButton("OK");
btnLeft.setVisible(false);
btnLeft.setEnabled(false);
add(btnLeft);
btnRight = new JButton("Cancel");
btnRight.setVisible(false);
btnRight.setEnabled(false);
add(btnRight);
//btnStopTimer = new JButton("Stop timer");
//btnStopTimer.setToolTipText("Stop auto phase skipping timer");
//add(btnStopTimer);
btnEndTurn = new JButton("End Turn");
btnEndTurn.setToolTipText("End The Turn");
add(btnEndTurn);
btnLeft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkLeft != null) {{
@ -88,10 +104,14 @@ public class HelperPanel extends JPanel {
}
public void setState(String txtLeft, boolean leftVisible, String txtRight, boolean rightVisible) {
this.btnLeft.setVisible(leftVisible);
this.btnLeft.setText(txtLeft);
this.btnRight.setVisible(rightVisible);
this.btnRight.setText(txtRight);
this.btnLeft.setEnabled(leftVisible);
if (!txtLeft.isEmpty()) {
this.btnLeft.setText(txtLeft);
}
this.btnRight.setEnabled(rightVisible);
if (!txtRight.isEmpty()) {
this.btnRight.setText(txtRight);
}
}
public void setSpecial(String txtSpecial, boolean specialVisible) {
@ -100,8 +120,10 @@ public class HelperPanel extends JPanel {
}
public void setRight(String txtRight, boolean rightVisible) {
this.btnRight.setVisible(rightVisible);
this.btnRight.setText(txtRight);
this.btnRight.setEnabled(rightVisible);
if (!txtRight.isEmpty()) {
this.btnRight.setText(txtRight);
}
}
public void setLinks(JButton left, JButton right, JButton special) {
@ -109,4 +131,8 @@ public class HelperPanel extends JPanel {
this.linkRight = right;
this.linkSpecial = special;
}
public void addEndTurnListener(MouseListener mouseListener) {
this.btnEndTurn.addMouseListener(mouseListener);
}
}