Some more changes to GUI to better support high screen resolutions.

This commit is contained in:
LevelX2 2016-02-16 23:15:34 +01:00
parent f54c675c4b
commit 5ca4e3bc7a
9 changed files with 198 additions and 175 deletions

View file

@ -231,7 +231,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
if (username != null && !username.isEmpty()) {
text.append(getColoredText(userColor, username + userSeparator));
}
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.PAY)));
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.CHAT)));
this.txtConversation.append(text.toString());
}

View file

@ -95,7 +95,7 @@ public class ChatPanelSeparated extends ChatPanelBasic {
if (username != null && !username.isEmpty()) {
text.append(getColoredText(userColor, username + userSeparator));
}
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.PAY)));
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.CHAT)));
this.systemMessagesPane.append(text.toString());
}

View file

@ -43,7 +43,7 @@ public class MageTextArea extends JEditorPane {
//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);
final String basicText = ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG);
if (text.length() > 0) {
buffer.append(basicText);
}

View file

@ -1,5 +1,10 @@
package mage.client.components.ability;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import mage.client.util.ImageHelper;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
@ -12,12 +17,6 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
/**
* Dialog for choosing abilities.
*
@ -48,8 +47,8 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
private static final String IMAGE_RIGHT_PATH = "/game/right.png";
private static final String IMAGE_RIGHT_HOVERED_PATH = "/game/right_hovered.png";
private static Color SELECTED_COLOR = new Color(64,147,208);
private static Color BORDER_COLOR = new Color(0,0,0,50);
private static Color SELECTED_COLOR = new Color(64, 147, 208);
private static Color BORDER_COLOR = new Color(0, 0, 0, 50);
private boolean selected = false;
@ -59,7 +58,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
jScrollPane2.setOpaque(false);
jScrollPane2.getViewport().setOpaque(false);
UIManager.put( "ScrollBar.width", 17);
UIManager.put("ScrollBar.width", 17);
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
}
@ -67,13 +66,13 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
public AbilityPicker(List<Object> choices, String message) {
this.choices = choices;
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
if (message!= null) {
if (message != null) {
this.message = message + " (single-click)";
}
initComponents();
jScrollPane2.setOpaque(false);
jScrollPane2.getViewport().setOpaque(false);
UIManager.put( "ScrollBar.width", 17);
UIManager.put("ScrollBar.width", 17);
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
}
@ -84,7 +83,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
}
public void cleanUp() {
for(MouseListener ml: this.getMouseListeners()) {
for (MouseListener ml : this.getMouseListeners()) {
this.removeMouseListener(ml);
}
}
@ -93,7 +92,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
this.choices = new ArrayList<Object>();
this.selected = true; // to stop previous modal
for (Map.Entry<UUID, String> choice: choices.getChoices().entrySet()) {
for (Map.Entry<UUID, String> choice : choices.getChoices().entrySet()) {
this.choices.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
}
this.choices.add(new AbilityPickerAction(null, "Cancel"));
@ -186,28 +185,28 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
GroupLayout.TRAILING,
layout.createSequentialGroup().addContainerGap().add(
layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING,
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
GroupLayout.LEADING,
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
)
.addPreferredGap(LayoutStyle.RELATED)
.add(
layout.createParallelGroup(GroupLayout.TRAILING)
.add(
GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10)));
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
GroupLayout.LEADING,
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
)
.addPreferredGap(LayoutStyle.RELATED)
.add(
layout.createParallelGroup(GroupLayout.TRAILING)
.add(
GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10)));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
layout.createSequentialGroup().add(
layout.createParallelGroup(GroupLayout.LEADING).add(
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
.add(5, 5, 5)
.add(
layout.createParallelGroup(GroupLayout.BASELINE)
)
).add(layout.createSequentialGroup().add(8, 8, 8)))
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
.add(5, 5, 5)
.add(
layout.createParallelGroup(GroupLayout.BASELINE)
)
).add(layout.createSequentialGroup().add(8, 8, 8)))
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
}
@Override
@ -217,27 +216,25 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
if (notches < 0) {
if (index > 0) {
rows.setSelectedIndex(index-1);
rows.repaint();
}
} else {
if (index < choices.size() - 1) {
rows.setSelectedIndex(index+1);
rows.setSelectedIndex(index - 1);
rows.repaint();
}
} else if (index < choices.size() - 1) {
rows.setSelectedIndex(index + 1);
rows.repaint();
}
}
private void objectMouseClicked(MouseEvent event) {
int index = rows.getSelectedIndex();
AbilityPickerAction action = (AbilityPickerAction)choices.get(index);
AbilityPickerAction action = (AbilityPickerAction) choices.get(index);
action.actionPerformed(null);
}
public class ImageRenderer2 extends JEditorPane implements ListCellRenderer {
public final Map<String, String> cache = new HashMap<String, String>();
@Override
public Component getListCellRendererComponent(
javax.swing.JList list,
@ -252,7 +249,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
UI.setHTMLEditorKit(this);
setOpaque(false);
setBackground(new Color(0,0,0,0));
setBackground(new Color(0, 0, 0, 0));
String text = value.toString();
@ -298,17 +295,15 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
//text += "<br>";
if (text.length() > 0) {
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.PAY));
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG));
}
buffer.append("</b></body></html>");
return buffer;
}
}
class ImageRenderer extends DefaultListCellRenderer {
@Override
@ -364,7 +359,6 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
}
}
}*/
if (event instanceof MouseEvent) {
MouseEvent e = (MouseEvent) event;
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
@ -457,14 +451,14 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
@Override
public String toString() {
return (String)getValue(Action.NAME);
return (String) getValue(Action.NAME);
}
}
private void cancel() {
try {
session.sendPlayerBoolean(gameId, false);
session.sendPlayerBoolean(gameId, false);
} catch (Exception e) {
log.error("Couldn't cancel choose dialog: " + e, e);
}

View file

@ -1,16 +1,16 @@
/*
* 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
@ -20,12 +20,11 @@
* 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.deckeditor.table;
import java.awt.Dimension;
@ -69,7 +68,7 @@ import org.mage.card.arcane.UI;
/**
* Table Model for card list.
*
*
* @author nantuko
*/
public class TableModel extends AbstractTableModel implements ICardGrid {
@ -89,18 +88,18 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private boolean displayNoCopies = false;
private UpdateCountsCallback updateCountsCallback;
private final String column[] = { "Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set" };
private final String column[] = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set"};
private SortSetting sortSetting;
private int recentSortedColumn;
private boolean recentAscending;
private boolean numberEditable;
public TableModel() {
this.numberEditable = false;
}
}
public void clear() {
this.clearCardEventListeners();
this.clearCards();
@ -173,9 +172,9 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
if (cv.getId().equals(entry.getValue().getId())) {
if (count > 0) {
// replace by another card with the same name+setCode
String key1 = cv.getName()+cv.getExpansionSetCode()+cv.getCardNumber();
String key1 = cv.getName() + cv.getExpansionSetCode() + cv.getCardNumber();
for (CardView cardView : cards.values()) {
String key2 = cardView.getName()+cardView.getExpansionSetCode()+cardView.getCardNumber();
String key2 = cardView.getName() + cardView.getExpansionSetCode() + cardView.getCardNumber();
if ((key1).equals(key2)) {
view.set(j, cardView);
break;
@ -241,36 +240,36 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private Object getColumn(Object obj, int column) {
CardView c = (CardView) obj;
switch (column) {
case 0:
if (displayNoCopies) {
String key = c.getName() + c.getExpansionSetCode() + c.getCardNumber();
Integer count = cardsNoCopies.get(key);
return count != null ? count : "";
}
return "";
case 1:
return c.getName();
case 2:
String manaCost = "";
for (String m : c.getManaCost()) {
manaCost += m;
}
String castingCost = UI.getDisplayManaCost(manaCost);
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, ManaSymbols.Type.PAY);
return "<html>" + castingCost + "</html>";
case 3:
return CardHelper.getColor(c);
case 4:
return CardHelper.getType(c);
case 5:
return CardHelper.isCreature(c) ? c.getPower() + "/"
+ c.getToughness() : "-";
case 6:
return c.getRarity().toString();
case 7:
return c.getExpansionSetCode();
default:
return "error";
case 0:
if (displayNoCopies) {
String key = c.getName() + c.getExpansionSetCode() + c.getCardNumber();
Integer count = cardsNoCopies.get(key);
return count != null ? count : "";
}
return "";
case 1:
return c.getName();
case 2:
String manaCost = "";
for (String m : c.getManaCost()) {
manaCost += m;
}
String castingCost = UI.getDisplayManaCost(manaCost);
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, ManaSymbols.Type.TABLE);
return "<html>" + castingCost + "</html>";
case 3:
return CardHelper.getColor(c);
case 4:
return CardHelper.getType(c);
case 5:
return CardHelper.isCreature(c) ? c.getPower() + "/"
+ c.getToughness() : "-";
case 6:
return c.getRarity().toString();
case 7:
return c.getExpansionSetCode();
default:
return "error";
}
}
@ -282,7 +281,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
cards.put(card.getId(), card);
if (displayNoCopies) {
String key = card.getName()+card.getExpansionSetCode()+card.getCardNumber();
String key = card.getName() + card.getExpansionSetCode() + card.getCardNumber();
Integer count = 1;
if (cardsNoCopies.containsKey(key)) {
count = cardsNoCopies.get(key) + 1;
@ -291,7 +290,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
}
cardsNoCopies.put(key, count);
} else {
view.add(card);
view.add(card);
}
}
@ -473,6 +472,5 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
}
return super.isCellEditable(row, col); //To change body of generated methods, choose Tools | Templates.
}
}

View file

@ -24,6 +24,9 @@ public class GUISizeHelper {
public static String basicSymbolSize = "small";
public static int symbolCardSize = 15;
public static int symbolTableSize = 15;
public static int symbolChatSize = 15;
public static int symbolDialogSize = 15;
public static int symbolTooltipSize = 15;
public static int symbolPaySize = 15;
public static int symbolEditorSize = 15;
@ -71,6 +74,7 @@ public class GUISizeHelper {
tableFont = new java.awt.Font("Arial", 0, tableFontSize);
tableRowHeight = tableFontSize + 4;
tableHeaderHeight = tableFontSize + 10;
symbolTableSize = tableFontSize;
flagHeight = tableFontSize - 2;
balloonTooltipFont = new Font("Arial", 0, tableFontSize);
if (tableFontSize > 15) {
@ -87,9 +91,11 @@ public class GUISizeHelper {
int dialogFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_DIALOG_FONT_SIZE, 14);
menuFont = new Font("Arial", 0, dialogFontSize);
gameRequestsFont = new Font("Arial", 0, dialogFontSize);
symbolDialogSize = dialogFontSize;
int chatFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CHAT_FONT_SIZE, 14);
chatFont = new java.awt.Font("Arial", 0, chatFontSize);
symbolChatSize = chatFontSize;
int symbolSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_SYMBOL_SIZE, 14);
// Set basic symbol size

View file

@ -195,7 +195,7 @@ public class GuiDisplayUtil {
manaCost += m;
}
String castingCost = UI.getDisplayManaCost(manaCost);
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, ManaSymbols.Type.CARD);
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, ManaSymbols.Type.TOOLTIP);
int symbolCount = 0;
int offset = 0;
@ -344,7 +344,7 @@ public class GuiDisplayUtil {
// legal = legal.replace("\r\n", "<div style='font-size:5pt'></div>");
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this" : card.getName());
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this" : card.getName());
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.CARD));
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.TOOLTIP));
}
buffer.append("<br></body></html>");