Please test! Some changes to the display of user choices, showing also a longer text in tooltip window.

This commit is contained in:
LevelX2 2015-06-28 21:55:48 +02:00
parent cac04616f3
commit df3e6db569
352 changed files with 2277 additions and 2034 deletions

View file

@ -1,12 +1,17 @@
package mage.client.components;
import mage.client.util.Command;
import javax.swing.*;
import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.font.FontRenderContext;
import javax.swing.JPanel;
import mage.client.util.Command;
/**
* Image button with hover.
@ -48,6 +53,8 @@ public class HoverButton extends JPanel implements MouseListener {
static final Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
private boolean useMiniFont = false;
private boolean alignTextLeft = false;
public HoverButton(String text, Image image, Rectangle size) {
this(text, image, image, null, image, size);
if (image == null) {
@ -113,7 +120,7 @@ public class HoverButton extends JPanel implements MouseListener {
}
topTextOffsetX = calculateOffsetForTop(g2d, topText);
g2d.setColor(textBGColor);
g2d.drawString(topText, topTextOffsetX+1, 13);
g2d.drawString(topText, topTextOffsetX + 1, 13);
g2d.setColor(textColor);
g2d.drawString(topText, topTextOffsetX, 12);
}
@ -148,7 +155,11 @@ public class HoverButton extends JPanel implements MouseListener {
frc = g2d.getFontRenderContext();
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
}
textOffsetX = (imageSize.width - textWidth) / 2;
if (alignTextLeft) {
textOffsetX = 0;
} else {
textOffsetX = (imageSize.width - textWidth) / 2;
}
}
return textOffsetX;
}
@ -277,4 +288,8 @@ public class HoverButton extends JPanel implements MouseListener {
this.textAlwaysVisible = textAlwaysVisible;
}
public void setAlignTextLeft(boolean alignTextLeft) {
this.alignTextLeft = alignTextLeft;
}
}

View file

@ -1,19 +1,16 @@
package mage.client.components;
import java.awt.Color;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import javax.swing.text.JTextComponent;
/**
* Component for displaying text in mage.
* Supports drawing mana symbols.
* Component for displaying text in mage. Supports drawing mana symbols.
*
* @author nantuko
*/
public class MageTextArea extends JEditorPane {
public MageTextArea() {
@ -27,10 +24,10 @@ public class MageTextArea extends JEditorPane {
@Override
public void setText(String text) {
setText(text, 16);
setText(text, 0);
}
public void setText(String text, int fontSize) {
public void setText(String text, final int panelWidth) {
if (text == null) {
return;
}
@ -38,23 +35,36 @@ public class MageTextArea extends JEditorPane {
final StringBuilder buffer = new StringBuilder(512);
// Dialog is a java logical font family, so it should work on all systems
buffer.append("<html><body style='font-family:Dialog;font-size:");
buffer.append(fontSize);
buffer.append(16);
buffer.append("pt;margin:3px 3px 3px 3px;color: #FFFFFF'><b><center>");
text = text.replaceAll("#([^#]+)#", "<i>$1</i>");
// Don't know what it does (easy italc?) but it bugs with multiple #HTML color codes (LevelX2)
//text = text.replaceAll("#([^#]+)#", "<i>$1</i>");
//text = text.replaceAll("\\s*//\\s*", "<hr width='50%'>");
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
final String basicText = ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.PAY);
if (text.length() > 0) {
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.PAY));
buffer.append(basicText);
}
buffer.append("</b></center></body></html>");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MageTextArea.super.setText(buffer.toString());
//System.out.println(buffer.toString());
String promptText = buffer.toString();
MageTextArea.super.setText(promptText);
// in case the text don't fit in the panel a tooltip with the text is added
if (panelWidth > 0 && MageTextArea.this.getPreferredSize().getWidth() > panelWidth) {
// String tooltip = promptText
// .replace("color: #FFFFFF'>", "color: #111111'><p width='400'>")
// .replace("</body>", "</p></body>");
String tooltip = "<html><center><body style='font-family:Dialog;font-size:14;color: #FFFFFF'><p width='500'>" + basicText + "</p></body></html>";
MageTextArea.super.setToolTipText(tooltip);
} else {
MageTextArea.super.setToolTipText(null);
}
setCaretPosition(0);
}
});

View file

@ -112,6 +112,25 @@ public class CardInfoWindowDialog extends MageDialog {
cards.cleanUp();
}
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
boolean changed = cards.loadCards(exile, bigCard, gameId, null);
String titel = name + " (" + exile.size() + ")";
setTitle(titel);
this.setTitelBarToolTip(titel);
if (exile.size() > 0) {
show();
if (changed) {
try {
this.setIcon(false);
} catch (PropertyVetoException ex) {
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
this.hideDialog();
}
}
public void loadCards(SimpleCardsView showCards, BigCard bigCard, UUID gameId) {
cards.loadCards(showCards, bigCard, gameId);
showAndPositionWindow();
@ -120,8 +139,9 @@ public class CardInfoWindowDialog extends MageDialog {
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
cards.loadCards(showCards, bigCard, gameId, null);
if (showType.equals(ShowType.GRAVEYARD)) {
setTitle(name + "'s Graveyard (" + showCards.size() + ")");
this.setTitelBarToolTip(name);
String titel = name + "'s Graveyard (" + showCards.size() + ")";
setTitle(titel);
this.setTitelBarToolTip(titel);
}
showAndPositionWindow();
}
@ -160,22 +180,6 @@ public class CardInfoWindowDialog extends MageDialog {
});
}
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
boolean changed = cards.loadCards(exile, bigCard, gameId, null);
if (exile.size() > 0) {
show();
if (changed) {
try {
this.setIcon(false);
} catch (PropertyVetoException ex) {
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
this.hideDialog();
}
}
/**
* 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

View file

@ -1150,21 +1150,21 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="590" max="32767" attributes="0"/>
<Component id="avatarPane" alignment="0" pref="590" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="359" max="32767" attributes="0"/>
<Component id="avatarPane" alignment="0" pref="359" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Container class="javax.swing.JScrollPane" name="avatarPane">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel9">
<Container class="javax.swing.JPanel" name="avatarPanel">
<Layout>
<DimensionLayout dim="0">
@ -1256,6 +1256,14 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Choose your avatar:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel10">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
@ -1328,14 +1336,6 @@
</DimensionLayout>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Choose your avatar:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel12">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">

View file

@ -420,12 +420,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtBattlefieldIBGMPath = new javax.swing.JTextField();
btnBattlefieldBGMBrowse = new javax.swing.JButton();
tabAvatars = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jPanel9 = new javax.swing.JPanel();
avatarPane = new javax.swing.JScrollPane();
avatarPanel = new javax.swing.JPanel();
jLabel12 = new javax.swing.JLabel();
jPanel10 = new javax.swing.JPanel();
jPanel13 = new javax.swing.JPanel();
jPanel11 = new javax.swing.JPanel();
jLabel12 = new javax.swing.JLabel();
jPanel12 = new javax.swing.JPanel();
jPanel14 = new javax.swing.JPanel();
jPanel15 = new javax.swing.JPanel();
@ -1190,6 +1190,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabsPanel.addTab("Sounds", tabSounds);
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel12.setText("Choose your avatar:");
jPanel10.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
@ -1229,9 +1232,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGap(0, 100, Short.MAX_VALUE)
);
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel12.setText("Choose your avatar:");
jPanel12.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
@ -1352,68 +1352,68 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGap(0, 100, Short.MAX_VALUE)
);
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
javax.swing.GroupLayout avatarPanelLayout = new javax.swing.GroupLayout(avatarPanel);
avatarPanel.setLayout(avatarPanelLayout);
avatarPanelLayout.setHorizontalGroup(
avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createSequentialGroup()
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel12))
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(avatarPanelLayout.createSequentialGroup()
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel19, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(avatarPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel13))))
.addGap(32, 32, 32)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
avatarPanelLayout.setVerticalGroup(
avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(avatarPanelLayout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(18, 18, 18)
.addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@ -1422,17 +1422,17 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGap(25, 25, 25))
);
jScrollPane1.setViewportView(jPanel9);
avatarPane.setViewportView(avatarPanel);
javax.swing.GroupLayout tabAvatarsLayout = new javax.swing.GroupLayout(tabAvatars);
tabAvatars.setLayout(tabAvatarsLayout);
tabAvatarsLayout.setHorizontalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
.addComponent(avatarPane, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
);
tabAvatarsLayout.setVerticalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
.addComponent(avatarPane, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
);
tabsPanel.addTab("Avatars", tabAvatars);
@ -2423,7 +2423,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static UserData getUserData() {
return new UserData(UserGroup.PLAYER,
getSelectedAvatar(),
PreferencesDialog.selectedAvatarId,
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
@ -2434,6 +2434,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane avatarPane;
private javax.swing.JPanel avatarPanel;
private javax.swing.JButton btnBattlefieldBGMBrowse;
private javax.swing.JButton btnBrowseBackgroundImage;
private javax.swing.JButton btnBrowseBattlefieldImage;
@ -2506,8 +2508,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JPanel jPanel19;
private javax.swing.JPanel jPanel20;
private javax.swing.JPanel jPanel21;
private javax.swing.JPanel jPanel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel labelPreferedImageLanguage;
private javax.swing.JLabel lblProxyPassword;
private javax.swing.JLabel lblProxyPort;

View file

@ -1,37 +1,36 @@
/*
* 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.
*/
* 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.
*/
/*
* FeedbackPanel.java
*
* Created on 23-Dec-2009, 9:54:01 PM
*/
package mage.client.game;
import java.awt.Component;
@ -61,6 +60,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(FeedbackPanel.class);
public enum FeedbackMode {
INFORM, QUESTION, CONFIRM, CANCEL, SELECT, END
}
@ -73,7 +73,9 @@ public class FeedbackPanel extends javax.swing.JPanel {
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
/** Creates new form FeedbackPanel */
/**
* Creates new form FeedbackPanel
*/
public FeedbackPanel() {
//initComponents();
customInitComponents();
@ -170,7 +172,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
while (c != null && !(c instanceof GamePane)) {
c = c.getParent();
}
if (c != null && ((GamePane)c).isVisible()) { // check if GamePanel still visible
if (c != null && ((GamePane) c).isVisible()) { // check if GamePanel still visible
FeedbackPanel.this.btnRight.doClick();
}
}
@ -181,8 +183,8 @@ public class FeedbackPanel extends javax.swing.JPanel {
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);
this.btnRight.setText((String) options.get("UI.right.btn.text"));
this.helper.setRight((String) options.get("UI.right.btn.text"), true);
}
if (options.containsKey("dialog")) {
connectedDialog = (MageDialog) options.get("dialog");
@ -224,7 +226,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
btnUndo = new javax.swing.JButton();
btnUndo.setVisible(true);
setBackground(new java.awt.Color(0,0,0,80));
setBackground(new java.awt.Color(0, 0, 0, 80));
btnRight.setText("Cancel");
btnRight.addActionListener(new java.awt.event.ActionListener() {
@ -294,7 +296,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
session.sendPlayerString(gameId, "special");
}//GEN-LAST:event_btnSpecialActionPerformed
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.UNDO, gameId, null);
}
@ -309,7 +311,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
public void setConnectedChatPanel(ChatPanel chatPanel) {
this.connectedChatPanel = chatPanel;
}
public void pressOKYesOrDone() {
if (btnLeft.getText().equals("OK") || btnLeft.getText().equals("Yes")) {
btnLeft.doClick();

View file

@ -1,40 +1,43 @@
/*
* 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.
*/
* 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 java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import mage.client.components.MageTextArea;
/**
@ -58,11 +61,15 @@ public class HelperPanel extends JPanel {
private javax.swing.JButton linkSpecial;
private javax.swing.JButton linkUndo;
private final int defaultDismissTimeout = ToolTipManager.sharedInstance().getDismissDelay();
private final Object tooltipBackground = UIManager.get("info");
public HelperPanel() {
initComponents();
}
private void initComponents() {
setBackground(new Color(0, 0, 0, 100));
//setLayout(new GridBagLayout());
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
@ -84,7 +91,7 @@ public class HelperPanel extends JPanel {
add(jPanel);
add(container);
btnSpecial = new JButton("Special");
btnSpecial.setVisible(false);
container.add(btnSpecial);
@ -101,22 +108,24 @@ public class HelperPanel extends JPanel {
btnLeft.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkLeft != null) {{
Thread worker = new Thread(){
@Override
public void run(){
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
setState("",false,"",false);
setSpecial("", false);
linkLeft.doClick();
}
});
}
};
worker.start();
}}
if (linkLeft != null) {
{
Thread worker = new Thread() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setState("", false, "", false);
setSpecial("", false);
linkLeft.doClick();
}
});
}
};
worker.start();
}
}
}
});
@ -124,13 +133,13 @@ public class HelperPanel extends JPanel {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkRight != null) {
Thread worker = new Thread(){
Thread worker = new Thread() {
@Override
public void run(){
SwingUtilities.invokeLater(new Runnable(){
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run(){
setState("",false,"",false);
public void run() {
setState("", false, "", false);
setSpecial("", false);
linkRight.doClick();
}
@ -145,42 +154,61 @@ public class HelperPanel extends JPanel {
btnSpecial.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkSpecial != null) {{
Thread worker = new Thread(){
@Override
public void run(){
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
setState("",false,"",false);
setSpecial("", false);
linkSpecial.doClick();
}
});
}
};
worker.start();
}}
if (linkSpecial != null) {
{
Thread worker = new Thread() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setState("", false, "", false);
setSpecial("", false);
linkSpecial.doClick();
}
});
}
};
worker.start();
}
}
}
});
btnUndo.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkUndo != null) {{
Thread worker = new Thread(){
@Override
public void run(){
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
linkUndo.doClick();
}
});
}
};
worker.start();
}}
if (linkUndo != null) {
{
Thread worker = new Thread() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
linkUndo.doClick();
}
});
}
};
worker.start();
}
}
}
});
textArea.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent me) {
ToolTipManager.sharedInstance().setDismissDelay(100000);
UIManager.put("info", Color.DARK_GRAY);
}
@Override
public void mouseExited(MouseEvent me) {
ToolTipManager.sharedInstance().setDismissDelay(defaultDismissTimeout);
UIManager.put("info", tooltipBackground);
}
});
}
@ -218,19 +246,20 @@ public class HelperPanel extends JPanel {
this.linkSpecial = special;
this.linkUndo = undo;
}
public void setMessage(String message) {
if (message.startsWith("Use alternative cost")) {
message = "Use alternative cost?";
} else if (message.contains("Use ")) {
if (message.length() < this.getWidth() / 10) {
message = getSmallText(message);
} else {
message = "Use ability?" + getSmallText(message.substring(0, this.getWidth() / 10));
}
}
textArea.setText(message);
// if (message.startsWith("Use alternative cost")) {
// message = "Use alternative cost?";
// } else if (message.contains("Use ")) {
// if (message.length() < this.getWidth() / 10) {
// message = getSmallText(message);
// } else {
// message = "Use ability?" + getSmallText(message.substring(0, this.getWidth() / 10));
// }
// }
textArea.setText(message, this.getWidth());
}
protected String getSmallText(String text) {
return "<div style='font-size:11pt'>" + text + "</div>";
}

View file

@ -328,8 +328,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
avatar.add(new JLabel());
avatar.add(new JLabel());
avatar.add(avatarFlag);
avatar.setAlignmentY(CENTER_ALIGNMENT);
avatarFlag.setHorizontalAlignment(JLabel.CENTER);
avatar.setAlignTextLeft(true);
avatarFlag.setHorizontalAlignment(JLabel.LEFT);
avatarFlag.setVerticalAlignment(JLabel.BOTTOM);
avatar.add(new JLabel());
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");