Additional panel on the bottom with the buttons linked to feedback panel (should be easier to use).

This commit is contained in:
magenoxx 2011-06-08 20:13:51 +04:00
parent e0d1ab226f
commit 7ca04d4cf7
4 changed files with 146 additions and 7 deletions

View file

@ -74,7 +74,8 @@ public class Cards extends javax.swing.JPanel {
public Cards(boolean skipAddingScrollPane) {
initComponents(skipAddingScrollPane);
setOpaque(false);
cardArea.setOpaque(false);
//cardArea.setOpaque(false);
setBackgroundColor(new Color(0,0,0,100));
if (!skipAddingScrollPane) {
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
@ -90,7 +91,7 @@ public class Cards extends javax.swing.JPanel {
*/
public void setBackgroundColor(Color color) {
cardArea.setOpaque(true);
cardArea.setBackground(new Color(0,0,0,100));
cardArea.setBackground(color);
}
public void setBorder(Border border) {
@ -137,7 +138,8 @@ public class Cards extends javax.swing.JPanel {
if (changed) {
layoutCards(getCardDimension());
}
cardArea.setVisible(cards.size() > 0);
cardArea.setPreferredSize(new Dimension(cards.size() * (Config.dimensions.frameWidth + GAP_X), Config.dimensions.frameHeight));
cardArea.revalidate();
cardArea.repaint();

View file

@ -89,47 +89,60 @@ public class FeedbackPanel extends javax.swing.JPanel {
case INFORM:
this.btnLeft.setVisible(false);
this.btnRight.setVisible(false);
this.helper.setState("", false, "", false);
break;
case QUESTION:
this.btnLeft.setVisible(true);
this.btnLeft.setText("Yes");
this.btnRight.setVisible(true);
this.btnRight.setText("No");
this.helper.setState("Yes", true, "Yes", true);
break;
case CONFIRM:
this.btnLeft.setVisible(true);
this.btnLeft.setText("OK");
this.btnRight.setVisible(true);
this.btnRight.setText("Cancel");
this.helper.setState("Ok", true, "Cancel", true);
break;
case CANCEL:
this.btnLeft.setVisible(false);
this.btnRight.setVisible(true);
this.btnRight.setText("Cancel");
this.helper.setState("", false, "Cancel", true);
break;
case SELECT:
this.btnLeft.setVisible(false);
this.btnRight.setVisible(true);
this.btnRight.setText("Done");
this.helper.setState("", false, "Done", true);
break;
}
this.btnSpecial.setVisible(special);
this.btnSpecial.setText("Special");
this.helper.setSpecial("Special", special);
if (message.contains("P}")) {
this.btnSpecial.setVisible(true);
this.btnSpecial.setText("Pay 2 life");
this.helper.setSpecial("Pay 2 life", true);
}
handleOptions(options);
this.revalidate();
this.repaint();
if (modal)
this.helper.setLinks(btnLeft, btnRight, btnSpecial);
if (modal) {
this.helper.setVisible(false);
startModal();
} else {
this.helper.setVisible(true);
}
}
private void handleOptions(Map<String, Serializable> options) {
if (options != null) {
if (options.containsKey("UI.right.btn.text")) {
this.btnRight.setText((String)options.get("UI.right.btn.text"));
this.helper.setRight((String)options.get("UI.right.btn.text"), true);
}
}
}
@ -288,6 +301,9 @@ public class FeedbackPanel extends javax.swing.JPanel {
session.sendPlayerString(gameId, "special");
}//GEN-LAST:event_btnSpecialActionPerformed
public void setHelperPanel(HelperPanel helper) {
this.helper = helper;
}
private javax.swing.JButton btnLeft;
private javax.swing.JButton btnRight;
@ -295,4 +311,5 @@ public class FeedbackPanel extends javax.swing.JPanel {
private javax.swing.JScrollPane jScrollPane1;
//private javax.swing.JTextArea lblMessage;
private MageTextArea lblMessage;
private HelperPanel helper;
}

View file

@ -89,7 +89,7 @@ public class GamePanel extends javax.swing.JPanel {
initComponents();
hand.setHScrollSpeed(8);
hand.setBackgroundColor(new Color(0,0,0,100));
hand.setBackgroundColor(new Color(0, 0, 0, 100));
combat = new CombatDialog();
pickNumber = new PickNumberDialog();
MageFrame.getDesktop().add(combat, JLayeredPane.POPUP_LAYER);
@ -769,6 +769,10 @@ public class GamePanel extends javax.swing.JPanel {
jPanel.setBackground(new Color(0,0,0,0));
jPanel.add(hand);
HelperPanel helper = new HelperPanel();
helper.setBackground(new Color(0, 0, 0, 80));
helper.setPreferredSize(new Dimension(0, 35));
setOpaque(false);
jPanel.setOpaque(false);
jScrollPane1.setOpaque(false);
@ -778,8 +782,11 @@ public class GamePanel extends javax.swing.JPanel {
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(8);
setLayout(new java.awt.BorderLayout());
add(jScrollPane1, java.awt.BorderLayout.CENTER);
setLayout(new BorderLayout());
add(jScrollPane1, BorderLayout.CENTER);
add(helper, BorderLayout.PAGE_END);
feedbackPanel.setHelperPanel(helper);
}
private JPanel jPanel;

View file

@ -0,0 +1,113 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.game;
import javax.swing.*;
import java.awt.*;
/**
* Panel with buttons that copy the state of feedback panel.
*
* @author ayrat
*/
public class HelperPanel extends JPanel {
private javax.swing.JButton btnLeft;
private javax.swing.JButton btnRight;
private javax.swing.JButton btnSpecial;
private javax.swing.JButton linkLeft;
private javax.swing.JButton linkRight;
private javax.swing.JButton linkSpecial;
public HelperPanel() {
btnSpecial = new JButton("Special");
btnSpecial.setVisible(false);
add(btnSpecial);
btnLeft = new JButton("OK");
btnLeft.setVisible(false);
add(btnLeft);
btnRight = new JButton("Cancel");
btnRight.setVisible(false);
add(btnRight);
btnLeft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkLeft != null) {{
setState("",false,"",false);
setSpecial("", false);
linkLeft.doClick();
}}
}
});
btnRight.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkRight != null) {{
setState("",false,"",false);
setSpecial("", false);
linkRight.doClick();
}}
}
});
btnSpecial.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkSpecial != null) {{
setState("",false,"",false);
setSpecial("", false);
linkSpecial.doClick();
}}
}
});
}
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);
}
public void setSpecial(String txtSpecial, boolean specialVisible) {
this.btnSpecial.setVisible(specialVisible);
this.btnSpecial.setText(txtSpecial);
}
public void setRight(String txtRight, boolean rightVisible) {
this.btnRight.setVisible(rightVisible);
this.btnRight.setText(txtRight);
}
public void setLinks(JButton left, JButton right, JButton special) {
this.linkLeft = left;
this.linkRight = right;
this.linkSpecial = special;
}
}