Merge pull request #46 from magefree/master

Merge https://github.com/magefree/mage
This commit is contained in:
L_J 2018-03-25 01:10:41 +01:00 committed by GitHub
commit 4378581042
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1385 changed files with 12422 additions and 5634 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@ syntax: glob
Mage.Client/*.dck
Mage.Client/db
Mage.Client/gamelogs
Mage.Client/gamelogsJson
Mage.Client/*.log
Mage.Client/plugins/images
Mage.Client/plugins/plugin.data

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<groupId>org.mage</groupId>

View file

@ -613,7 +613,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
private static MagePane getTopMost(MagePane exclude) {
public static MagePane getTopMost(MagePane exclude) {
MagePane topmost = null;
int best = Integer.MAX_VALUE;
for (Component frame : desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER)) {

View file

@ -1,7 +1,9 @@
package mage.client;
import java.util.*;
import mage.cards.decks.DeckCardLists;
import mage.client.chat.LocalCommands;
import mage.client.dialog.PreferencesDialog;
import mage.constants.ManaType;
import mage.constants.PlayerAction;
import mage.game.match.MatchOptions;
@ -14,8 +16,6 @@ import mage.remote.Session;
import mage.remote.SessionImpl;
import mage.view.*;
import java.util.*;
/**
* Created by IGOUDT on 15-9-2016.
*/
@ -26,6 +26,7 @@ public final class SessionHandler {
public static void startSession(MageFrame mageFrame) {
session = new SessionImpl(mageFrame);
session.setJsonLogActive("true".equals(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_LOG_AUTO_SAVE, "true")));
}
public static void ping() {

View file

@ -1217,7 +1217,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
String searchStr = "";
if (searchByTextField.getText().length() >= 3) {
useText = true;
searchStr = searchByTextField.getText().toLowerCase();
searchStr = searchByTextField.getText().toLowerCase(Locale.ENGLISH);
}
for (CardType cardType : selectByTypeButtons.keySet()) {
@ -1267,20 +1267,20 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
boolean s = card.isSelected();
// Name
if (!s) {
s |= card.getName().toLowerCase().contains(searchStr);
s |= card.getName().toLowerCase(Locale.ENGLISH).contains(searchStr);
}
// Sub & Super Types
if (!s) {
for (SuperType str : card.getSuperTypes()) {
s |= str.toString().toLowerCase().contains(searchStr);
s |= str.toString().toLowerCase(Locale.ENGLISH).contains(searchStr);
}
for (SubType str : card.getSubTypes()) {
s |= str.toString().toLowerCase().contains(searchStr);
s |= str.toString().toLowerCase(Locale.ENGLISH).contains(searchStr);
}
}
// Rarity
if (!s) {
s |= card.getRarity().toString().toLowerCase().contains(searchStr);
s |= card.getRarity().toString().toLowerCase(Locale.ENGLISH).contains(searchStr);
}
// Type line
if (!s) {
@ -1288,7 +1288,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
for (CardType type : card.getCardTypes()) {
t += ' ' + type.toString();
}
s |= t.toLowerCase().contains(searchStr);
s |= t.toLowerCase(Locale.ENGLISH).contains(searchStr);
}
// Casting cost
if (!s) {
@ -1296,12 +1296,12 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
for (String m : card.getManaCost()) {
mc += m;
}
s |= mc.toLowerCase().contains(searchStr);
s |= mc.toLowerCase(Locale.ENGLISH).contains(searchStr);
}
// Rules
if (!s) {
for (String str : card.getRules()) {
s |= str.toLowerCase().contains(searchStr);
s |= str.toLowerCase(Locale.ENGLISH).contains(searchStr);
}
}
card.setSelected(s);
@ -1348,21 +1348,21 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// Sub & Super Types
for (SuperType type : card.getSuperTypes()) {
t += ' ' + type.toString().toLowerCase();
t += ' ' + type.toString().toLowerCase(Locale.ENGLISH);
}
for (SubType str : card.getSubTypes()) {
t += " " + str.toString().toLowerCase();
t += " " + str.toString().toLowerCase(Locale.ENGLISH);
}
for (String qty : qtys.keySet()) {
int value = qtys.get(qty);
if (t.toLowerCase().contains(qty)) {
if (t.toLowerCase(Locale.ENGLISH).contains(qty)) {
qtys.put(qty, ++value);
}
// Rules
for (String str : card.getRules()) {
if (str.toLowerCase().contains(qty)) {
if (str.toLowerCase(Locale.ENGLISH).contains(qty)) {
qtys.put(qty, ++value);
}
}
@ -1380,10 +1380,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
mc = mc.replaceAll("\\{([WUBRG]).([WUBRG])\\}", "{$1}{$2}");
mc = mc.replaceAll("\\{", "#");
mc = mc.toLowerCase();
mc = mc.toLowerCase(Locale.ENGLISH);
for (String pip : pips.keySet()) {
int value = pips.get(pip);
while (mc.toLowerCase().contains(pip)) {
while (mc.toLowerCase(Locale.ENGLISH).contains(pip)) {
pips.put(pip, ++value);
mc = mc.replaceFirst(pip, "");
}

View file

@ -68,6 +68,10 @@ public class ManaPieChart extends JComponent {
total += slices[i].value;
}
if (total == 0.0D) {
return; //there are no slices or no slices with a value > 0, stop here
}
double curValue = 0.0D;
int startAngle = 0;
int lastAngle = 0;

View file

@ -39,6 +39,7 @@ import java.awt.Font;
import java.awt.event.KeyEvent;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -204,7 +205,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
}
message = '.' + message + '.';
message = message.toLowerCase();
message = message.toLowerCase(Locale.ENGLISH);
message = message.replaceAll("[a@]([s5][s5]+)", "axyx");
message = message.replaceAll("b.([t\\+][t\\+]+)", "buxyx");
message = message.replaceAll("(.)(\\1{1,})", "$1");
@ -280,11 +281,11 @@ public class ChatPanelBasic extends javax.swing.JPanel {
}
if (messageType == MessageType.WHISPER_FROM) {
if (username.equalsIgnoreCase(SessionHandler.getUserName())) {
if (message.toLowerCase().startsWith("profanity 0")) {
if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 0")) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "0");
} else if (message.toLowerCase().startsWith("profanity 1")) {
} else if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 1")) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "1");
} else if (message.toLowerCase().startsWith("profanity 2")) {
} else if (message.toLowerCase(Locale.ENGLISH).startsWith("profanity 2")) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAME_USE_PROFANITY_FILTER, "2");
}
}

View file

@ -3,6 +3,7 @@ package mage.client.components;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
@ -40,6 +41,7 @@ public class HoverButton extends JPanel implements MouseListener {
private String topText;
private Image topTextImage;
private Image topTextImageRight;
private String centerText;
private boolean isHovered = false;
private boolean isSelected = false;
@ -49,12 +51,15 @@ public class HoverButton extends JPanel implements MouseListener {
private Command observer = null;
private Command onHover = null;
private Color textColor = Color.white;
private final Rectangle centerTextArea = new Rectangle(5, 18, 75, 40);
private final Color centerTextColor = Color.YELLOW;
private final Color textBGColor = Color.black;
static final Font textFont = new Font("Arial", Font.PLAIN, 12);
static final Font textFontMini = new Font("Arial", Font.PLAIN, 11);
static final Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12);
static final Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
private boolean useMiniFont = false;
private boolean alignTextLeft = false;
@ -134,6 +139,21 @@ public class HoverButton extends JPanel implements MouseListener {
if (topTextImageRight != null) {
g.drawImage(topTextImageRight, this.getWidth() - 20, 3, this);
}
if (centerText != null) {
g2d.setColor(centerTextColor);
int fontSize = 40;
int val = Integer.parseInt(centerText);
if (val > 9999) {
fontSize = 24;
} else if (val > 999) {
fontSize = 28;
} else if (val > 99) {
fontSize = 34;
}
drawCenteredString(g2d, centerText, centerTextArea, new Font("Arial", Font.BOLD, fontSize));
}
g2d.setColor(textColor);
if (overlayImage != null) {
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
} else if (set != null) {
@ -298,13 +318,17 @@ public class HoverButton extends JPanel implements MouseListener {
public void setTopTextImage(Image topTextImage) {
this.topTextImage = topTextImage;
this.textOffsetX = -1; // rest for new clculation
this.textOffsetX = -1; // rest for new calculation
}
public void setTopTextImageRight(Image topTextImage) {
this.topTextImageRight = topTextImage;
}
public void setCenterText(String centerText) {
this.centerText = centerText;
}
public void setTextAlwaysVisible(boolean textAlwaysVisible) {
this.textAlwaysVisible = textAlwaysVisible;
}
@ -313,4 +337,24 @@ public class HoverButton extends JPanel implements MouseListener {
this.alignTextLeft = alignTextLeft;
}
/**
* Draw a String centered in the middle of a Rectangle.
*
* @param g The Graphics instance.
* @param text The String to draw.
* @param rect The Rectangle to center the text in.
* @param font
*/
public void drawCenteredString(Graphics g, String text, Rectangle rect, Font font) {
// Get the FontMetrics
FontMetrics metrics = g.getFontMetrics(font);
// Determine the X coordinate for the text
int x = rect.x + (rect.width - metrics.stringWidth(text)) / 2;
// Determine the Y coordinate for the text (note we add the ascent, as in java 2d 0 is top of the screen)
int y = rect.y + ((rect.height - metrics.getHeight()) / 2) + metrics.getAscent();
// Set the font
g.setFont(font);
// Draw the String
g.drawString(text, x, y);
}
}

View file

@ -438,7 +438,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
return choice;
}
choice = Jsoup.parse(choice).text(); // decode HTML entities and strip tags
return choice.substring(0, 1).toUpperCase() + choice.substring(1);
return choice.substring(0, 1).toUpperCase(Locale.ENGLISH) + choice.substring(1);
}
@Override

View file

@ -30,6 +30,7 @@ package mage.client.deck.generator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import mage.cards.Card;
@ -86,7 +87,7 @@ public final class DeckGenerator {
String selectedColors = genDialog.getSelectedColors();
List<ColoredManaSymbol> allowedColors = new ArrayList<>();
selectedColors = selectedColors != null ? selectedColors.toUpperCase() : getRandomColors("X");
selectedColors = selectedColors != null ? selectedColors.toUpperCase(Locale.ENGLISH) : getRandomColors("X");
String format = genDialog.getSelectedFormat();
List<String> setsToUse = ConstructedFormats.getSetsByFormat(format);

View file

@ -25,13 +25,13 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.deck.generator;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.swing.*;
/**
* @author Simown
@ -74,23 +74,24 @@ public class RatioAdjustingSliderPanel extends JPanel {
}
private static class AdjustingSliderGroup
{
private static class AdjustingSliderGroup {
private final ArrayList<JStorageSlider> storageSliders;
private int sliderIndex = 0;
AdjustingSliderGroup(JStorageSlider... sliders)
{
AdjustingSliderGroup(JStorageSlider... sliders) {
storageSliders = new ArrayList<>();
for (JStorageSlider slider : sliders) {
storageSliders.add(slider);
slider.addChangeListener(e -> fireSliderChangedEvent((JStorageSlider) e.getSource()));
}
}
public void fireSliderChangedEvent(JStorageSlider source) {
// We don't want to do anything if the value isn't changing
if(!source.getValueIsAdjusting())
if (!source.getValueIsAdjusting()) {
return;
}
// Update the slider depending on how much it's changed relative to its previous position
int change = (source.getValue() - source.getPreviousValue());
updateSliderPosition(change, source);
@ -156,7 +157,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
textLabels.add(titleLabel);
sliderPanel.add(titleLabel, BorderLayout.WEST);
// Slider
slider.setToolTipText("Percentage of " + label.trim().toLowerCase() + " in the generated deck.");
slider.setToolTipText("Percentage of " + label.trim().toLowerCase(Locale.ENGLISH) + " in the generated deck.");
sliderPanel.add(slider, BorderLayout.CENTER);
// Percentage
JLabel percentageLabel = createChangingPercentageLabel(slider);
@ -227,7 +228,4 @@ public class RatioAdjustingSliderPanel extends JPanel {
landSlider.previousValue = percentage;
}
}

View file

@ -851,9 +851,9 @@
</Component>
<Component class="javax.swing.JCheckBox" name="chkUnique">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="selected" type="boolean" value="false"/>
<Property name="text" type="java.lang.String" value="Unique"/>
<Property name="toolTipText" type="java.lang.String" value="Singleton rules."/>
<Property name="toolTipText" type="java.lang.String" value="Show only the first found card of every card name."/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@ -871,7 +871,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkUniqueActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButtonSearch">
<Properties>
<Property name="text" type="java.lang.String" value="Search"/>

View file

@ -51,6 +51,10 @@ import mage.client.MageFrame;
import mage.client.cards.*;
import mage.client.constants.Constants.SortBy;
import mage.client.deckeditor.table.TableModel;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_NAMES;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_RULES;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_TYPES;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_UNIQUE;
import mage.client.util.GUISizeHelper;
import mage.client.util.gui.FastSearchUtil;
import mage.client.util.sets.ConstructedFormats;
@ -144,9 +148,11 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
mainTable.setOpaque(false);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
// chkNames.setEnabled(true);
// chkTypes.setEnabled(true);
// chkRules.setEnabled(true);
chkNames.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_NAMES, "true")));
chkTypes.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_TYPES, "true")));
chkRules.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_RULES, "true")));
chkUnique.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_UNIQUE, "false")));
mainTable.addMouseListener(new MouseAdapter() {
@Override
@ -172,6 +178,10 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
public void cleanUp() {
this.cardGrid.clear();
this.mainModel.clear();
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_NAMES, Boolean.toString(chkNames.isSelected()));
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_RULES, Boolean.toString(chkRules.isSelected()));
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_TYPES, Boolean.toString(chkTypes.isSelected()));
MageFrame.getPreferences().put(KEY_DECK_EDITOR_SEARCH_UNIQUE, Boolean.toString(chkUnique.isSelected()));
}
public void changeGUISize() {
@ -1064,9 +1074,9 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
});
chkUnique.setSelected(true);
chkUnique.setSelected(false);
chkUnique.setText("Unique");
chkUnique.setToolTipText("Singleton results only.");
chkUnique.setToolTipText("Show only the first found card of every card name.");
chkUnique.setFocusable(false);
chkUnique.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
chkUnique.setMaximumSize(new java.awt.Dimension(69, 16));
@ -1079,7 +1089,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
});
jButtonSearch.setText("Search");
jButtonSearch.setToolTipText("Performs the search.");
jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
@ -1126,7 +1135,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
.addComponent(chkTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkRules, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(5, 5, 5)
.addComponent(chkUnique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(5, 5, 5)
.addComponent(cardCountLabel)
@ -1357,9 +1366,9 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
// TODO add your handling code here:
}//GEN-LAST:event_chkTypesActionPerformed
private void chkRulesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRulesActionPerformed
private void chkRulesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}//GEN-LAST:event_chkRulesActionPerformed
}
private void chkUniqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRulesActionPerformed
// TODO add your handling code here:
@ -1442,8 +1451,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private javax.swing.JCheckBox chkPennyDreadful;
private javax.swing.JCheckBox chkPiles;
private javax.swing.JCheckBox chkRules;
private javax.swing.JCheckBox chkUnique;
private javax.swing.JCheckBox chkTypes;
private javax.swing.JCheckBox chkUnique;
private javax.swing.JButton jButtonAddToMain;
private javax.swing.JButton jButtonAddToSideboard;
private javax.swing.JButton jButtonClean;

View file

@ -1125,7 +1125,7 @@ class DeckFilter extends FileFilter {
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i + 1).toLowerCase();
ext = s.substring(i + 1).toLowerCase(Locale.ENGLISH);
}
return (ext == null) ? false : ext.equals("dck");
}
@ -1149,10 +1149,10 @@ class ImportFilter extends FileFilter {
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i + 1).toLowerCase();
ext = s.substring(i + 1).toLowerCase(Locale.ENGLISH);
}
if (ext != null) {
if (ext.toLowerCase().equals("dec") || ext.toLowerCase().equals("mwdeck") || ext.toLowerCase().equals("txt") || ext.toLowerCase().equals("dek")) {
if (ext.toLowerCase(Locale.ENGLISH).equals("dec") || ext.toLowerCase(Locale.ENGLISH).equals("mwdeck") || ext.toLowerCase(Locale.ENGLISH).equals("txt") || ext.toLowerCase(Locale.ENGLISH).equals("dek")) {
return true;
}
}

View file

@ -1,5 +1,7 @@
package mage.client.deckeditor;
import mage.util.StreamUtils;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedWriter;
@ -39,15 +41,16 @@ public class DeckImportFromClipboardDialog extends JDialog {
}
private void onOK() {
BufferedWriter bw = null;
try {
File temp = File.createTempFile("cbimportdeck", ".txt");
BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
bw = new BufferedWriter(new FileWriter(temp));
bw.write(txtDeckList.getText());
bw.close();
tmpPath = temp.getPath();
} catch (IOException e) {
e.printStackTrace();
} finally {
StreamUtils.closeQuietly(bw);
}
dispose();

View file

@ -37,6 +37,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import javax.imageio.ImageIO;
import javax.swing.*;
@ -500,10 +501,10 @@ public class MageBook extends JComponent {
className = className.replaceAll("[^a-zA-Z0-9]", "");
className = "mage.game.permanent.token." + className + "Token";
if (token.getTokenClassName() != null && token.getTokenClassName().length() > 0) {
if (token.getTokenClassName().toLowerCase().matches(".*token.*")) {
if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*token.*")) {
className = token.getTokenClassName();
className = "mage.game.permanent.token." + className;
} else if (token.getTokenClassName().toLowerCase().matches(".*emblem.*")) {
} else if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
continue;
}
}
@ -541,7 +542,7 @@ public class MageBook extends JComponent {
try {
String className = emblem.getName();
if (emblem.getTokenClassName() != null && emblem.getTokenClassName().length() > 0) {
if (emblem.getTokenClassName().toLowerCase().matches(".*emblem.*")) {
if (emblem.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
className = emblem.getTokenClassName();
className = "mage.game.command.emblems." + className;
}

View file

@ -44,7 +44,6 @@ import mage.view.CardsView;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;

View file

@ -7,6 +7,11 @@
<Property name="text" type="java.lang.String" value="jButton2"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
</NonVisualComponents>
<Properties>
<Property name="title" type="java.lang.String" value="Add Land"/>
@ -29,8 +34,9 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblMountain" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblForest" alignment="1" min="-2" max="-2" attributes="0"/>
@ -39,32 +45,52 @@
<Component id="lblPains" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblSwamp" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblDeckSize" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="btnAutoAdd" pref="122" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="btnAdd" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="ckbFullArtLands" min="-2" max="-2" attributes="0"/>
<Component id="panelSet" min="-2" pref="219" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="spnForest" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblForestIcon" min="-2" pref="20" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="spnIsland" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblIslandIcon" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="spnMountain" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblMountainIcon" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="spnSwamp" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblSwampIcon" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="spnMountain" alignment="0" pref="85" max="32767" attributes="0"/>
<Component id="spnIsland" alignment="0" pref="85" max="32767" attributes="0"/>
<Component id="spnForest" alignment="0" max="32767" attributes="0"/>
</Group>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="spnSwamp" alignment="0" pref="85" max="32767" attributes="0"/>
<Component id="spnPlains" alignment="0" max="32767" attributes="0"/>
<Component id="spnDeckSize" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="btnAutoAdd" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="panelSet" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="spnPlains" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPlainsIcon" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
@ -74,38 +100,58 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblLandSet" min="-2" max="-2" attributes="0"/>
<Component id="panelSet" min="-2" max="-2" attributes="0"/>
<Component id="panelSet" min="-2" pref="23" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblForest" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnForest" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblForestIcon" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblIsland" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnIsland" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblIslandIcon" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblMountain" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnMountain" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblMountainIcon" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblPains" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnPlains" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblPlainsIcon" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblSwamp" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnSwamp" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="lblSwampIcon" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="ckbFullArtLands" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnAutoAdd" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblDeckSize" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnDeckSize" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnAutoAdd" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -120,7 +166,7 @@
</Component>
<Component class="javax.swing.JLabel" name="lblForest">
<Properties>
<Property name="text" type="java.lang.String" value="Forest"/>
<Property name="text" type="java.lang.String" value="Forest:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnForest">
@ -130,9 +176,23 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblForestIcon">
<Properties>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblIsland">
<Properties>
<Property name="text" type="java.lang.String" value="Island"/>
<Property name="text" type="java.lang.String" value="Island:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnIsland">
@ -142,9 +202,22 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblIslandIcon">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblMountain">
<Properties>
<Property name="text" type="java.lang.String" value="Mountain"/>
<Property name="text" type="java.lang.String" value="Mountain:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnMountain">
@ -154,9 +227,22 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblMountainIcon">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblPains">
<Properties>
<Property name="text" type="java.lang.String" value="Plains"/>
<Property name="text" type="java.lang.String" value="Plains:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnPlains">
@ -166,9 +252,22 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblPlainsIcon">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblSwamp">
<Properties>
<Property name="text" type="java.lang.String" value="Swamp"/>
<Property name="text" type="java.lang.String" value="Swamp:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnSwamp">
@ -178,9 +277,44 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblSwampIcon">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[22, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblDeckSize">
<Properties>
<Property name="text" type="java.lang.String" value="Deck size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnDeckSize">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnAutoAdd">
<Properties>
<Property name="text" type="java.lang.String" value="Suggest"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Propose related to the mana costs of the cards in the deck&lt;br&gt;&#xa;the number of lands to add to get to the set deck size."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAutoAddActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnAdd">
<Properties>
<Property name="text" type="java.lang.String" value="Add"/>
<Property name="toolTipText" type="java.lang.String" value="Add the selected number of basic lands to the deck."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddActionPerformed"/>
@ -194,14 +328,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnAutoAdd">
<Properties>
<Property name="text" type="java.lang.String" value="Suggest"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAutoAddActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="panelSet">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
@ -238,5 +364,11 @@
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="ckbFullArtLands">
<Properties>
<Property name="text" type="java.lang.String" value="Only use full art lands"/>
<Property name="toolTipText" type="java.lang.String" value="For example, lands from ZEN/UST/HOU"/>
</Properties>
</Component>
</SubComponents>
</Form>

View file

@ -27,15 +27,17 @@
*/
package mage.client.dialog;
import java.util.HashSet;
import java.awt.image.BufferedImage;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JLayeredPane;
import mage.Mana;
import mage.cards.Card;
import mage.cards.FrameStyle;
import mage.cards.decks.Deck;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
@ -48,6 +50,7 @@ import mage.client.util.gui.FastSearchUtil;
import mage.constants.Rarity;
import mage.util.RandomUtil;
import org.apache.log4j.Logger;
import org.mage.card.arcane.ManaSymbols;
/**
*
@ -58,7 +61,6 @@ public class AddLandDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(MageDialog.class);
private Deck deck;
private final Set<String> landSetCodes = new HashSet<>();
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
@ -130,17 +132,36 @@ public class AddLandDialog extends MageDialog {
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
spnDeckSize.setValue(DEFAULT_SEALED_DECK_CARD_NUMBER);
BufferedImage image = ManaSymbols.getSizedManaSymbol("G", 15);
if (image != null) {
lblForestIcon.setIcon(new ImageIcon(image));
}
image = ManaSymbols.getSizedManaSymbol("U", 15);
if (image != null) {
lblIslandIcon.setIcon(new ImageIcon(image));
}
image = ManaSymbols.getSizedManaSymbol("W", 15);
if (image != null) {
lblPlainsIcon.setIcon(new ImageIcon(image));
}
image = ManaSymbols.getSizedManaSymbol("R", 15);
if (image != null) {
lblMountainIcon.setIcon(new ImageIcon(image));
}
image = ManaSymbols.getSizedManaSymbol("B", 15);
if (image != null) {
lblSwampIcon.setIcon(new ImageIcon(image));
}
this.setVisible(true);
}
private void addLands(String landName, int number) {
private void addLands(String landName, int number, boolean useFullArt) {
String landSetName = (String) cbLandSet.getSelectedItem();
CardCriteria criteria = new CardCriteria();
if (landSetName.equals("<Random lands>")) {
criteria.setCodes(landSetCodes.toArray(new String[landSetCodes.size()]));
} else {
if (!landSetName.equals("<Random lands>")) {
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByName(landSetName);
if (expansionInfo == null) {
throw new IllegalArgumentException("Code of Set " + landSetName + " not found");
@ -157,9 +178,29 @@ public class AddLandDialog extends MageDialog {
cards = CardRepository.instance.findCards(criteria);
}
for (int i = 0; i < number; i++) {
int foundLands = 0;
int foundNoneAfter = 0;
for (int i = 0; foundLands != number && foundNoneAfter < 1000; i++) {
Card land = cards.get(RandomUtil.nextInt(cards.size())).getMockCard();
boolean useLand = !useFullArt;
if (useFullArt && (land.getFrameStyle() == FrameStyle.BFZ_FULL_ART_BASIC
|| land.getFrameStyle() == FrameStyle.UGL_FULL_ART_BASIC
|| land.getFrameStyle() == FrameStyle.UNH_FULL_ART_BASIC
|| land.getFrameStyle() == FrameStyle.UST_FULL_ART_BASIC
|| land.getFrameStyle() == FrameStyle.ZEN_FULL_ART_BASIC)) {
useLand = true;
}
if (useLand) {
deck.getCards().add(land);
foundLands++;
foundNoneAfter = 0;
} else {
foundNoneAfter++;
}
}
if (foundNoneAfter >= 1000 && useFullArt) {
MageFrame.getInstance().showMessage("Unable to add enough " + landName + "s. You encountered an error in adding chosen lands. Unable to find enough full art lands in the set " + landSetName + ".");
}
}
@ -173,51 +214,96 @@ public class AddLandDialog extends MageDialog {
private void initComponents() {
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
lblLandSet = new javax.swing.JLabel();
lblForest = new javax.swing.JLabel();
spnForest = new javax.swing.JSpinner();
lblForestIcon = new javax.swing.JLabel();
lblIsland = new javax.swing.JLabel();
spnIsland = new javax.swing.JSpinner();
lblIslandIcon = new javax.swing.JLabel();
lblMountain = new javax.swing.JLabel();
spnMountain = new javax.swing.JSpinner();
lblMountainIcon = new javax.swing.JLabel();
lblPains = new javax.swing.JLabel();
spnPlains = new javax.swing.JSpinner();
lblPlainsIcon = new javax.swing.JLabel();
lblSwamp = new javax.swing.JLabel();
spnSwamp = new javax.swing.JSpinner();
lblSwampIcon = new javax.swing.JLabel();
lblDeckSize = new javax.swing.JLabel();
spnDeckSize = new javax.swing.JSpinner();
btnAutoAdd = new javax.swing.JButton();
btnAdd = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
btnAutoAdd = new javax.swing.JButton();
panelSet = new javax.swing.JPanel();
cbLandSet = new javax.swing.JComboBox();
btnSetFastSearch = new javax.swing.JButton();
ckbFullArtLands = new javax.swing.JCheckBox();
jButton2.setText("jButton2");
jLabel1.setText("jLabel1");
setTitle("Add Land");
lblLandSet.setText("Set:");
lblForest.setText("Forest");
lblForest.setText("Forest:");
spnForest.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblIsland.setText("Island");
lblForestIcon.setToolTipText("");
lblForestIcon.setMaximumSize(new java.awt.Dimension(22, 20));
lblForestIcon.setMinimumSize(new java.awt.Dimension(22, 20));
lblForestIcon.setPreferredSize(new java.awt.Dimension(22, 20));
lblIsland.setText("Island:");
spnIsland.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblMountain.setText("Mountain");
lblIslandIcon.setMaximumSize(new java.awt.Dimension(22, 20));
lblIslandIcon.setMinimumSize(new java.awt.Dimension(22, 20));
lblIslandIcon.setPreferredSize(new java.awt.Dimension(22, 20));
lblMountain.setText("Mountain:");
spnMountain.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblPains.setText("Plains");
lblMountainIcon.setMaximumSize(new java.awt.Dimension(22, 20));
lblMountainIcon.setMinimumSize(new java.awt.Dimension(22, 20));
lblMountainIcon.setPreferredSize(new java.awt.Dimension(22, 20));
lblPains.setText("Plains:");
spnPlains.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblSwamp.setText("Swamp");
lblPlainsIcon.setMaximumSize(new java.awt.Dimension(22, 20));
lblPlainsIcon.setMinimumSize(new java.awt.Dimension(22, 20));
lblPlainsIcon.setPreferredSize(new java.awt.Dimension(22, 20));
lblSwamp.setText("Swamp:");
spnSwamp.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblSwampIcon.setMaximumSize(new java.awt.Dimension(22, 20));
lblSwampIcon.setMinimumSize(new java.awt.Dimension(22, 20));
lblSwampIcon.setPreferredSize(new java.awt.Dimension(22, 20));
lblDeckSize.setText("Deck size:");
spnDeckSize.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
btnAutoAdd.setText("Suggest");
btnAutoAdd.setToolTipText("<HTML>Propose related to the mana costs of the cards in the deck<br>\nthe number of lands to add to get to the set deck size.");
btnAutoAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAutoAddActionPerformed(evt);
}
});
btnAdd.setText("Add");
btnAdd.setToolTipText("Add the selected number of basic lands to the deck.");
btnAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddActionPerformed(evt);
@ -231,13 +317,6 @@ public class AddLandDialog extends MageDialog {
}
});
btnAutoAdd.setText("Suggest");
btnAutoAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAutoAddActionPerformed(evt);
}
});
panelSet.setLayout(new javax.swing.BoxLayout(panelSet, javax.swing.BoxLayout.LINE_AXIS));
cbLandSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
@ -255,12 +334,16 @@ public class AddLandDialog extends MageDialog {
});
panelSet.add(btnSetFastSearch);
ckbFullArtLands.setText("Only use full art lands");
ckbFullArtLands.setToolTipText("For example, lands from ZEN/UST/HOU");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMountain)
.addComponent(lblForest, javax.swing.GroupLayout.Alignment.TRAILING)
@ -268,26 +351,42 @@ public class AddLandDialog extends MageDialog {
.addComponent(lblIsland, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPains, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblSwamp, javax.swing.GroupLayout.Alignment.TRAILING))
.addComponent(lblDeckSize))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnAutoAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(spnMountain, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addComponent(spnIsland, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addComponent(spnForest, javax.swing.GroupLayout.Alignment.LEADING))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(spnSwamp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addComponent(spnPlains, javax.swing.GroupLayout.Alignment.LEADING)))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(panelSet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(btnCancel)
.addContainerGap())
.addComponent(ckbFullArtLands)
.addComponent(panelSet, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblForestIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblIslandIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblMountainIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblSwampIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnDeckSize, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnAutoAdd)))
.addGroup(layout.createSequentialGroup()
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPlainsIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -295,32 +394,47 @@ public class AddLandDialog extends MageDialog {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblLandSet)
.addComponent(panelSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(panelSet, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblForest)
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblForestIcon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblIsland)
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblIslandIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblMountain)
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblMountainIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPains)
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblPlainsIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblSwamp)
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblSwampIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ckbFullArtLands)
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnAutoAdd)
.addComponent(lblDeckSize)
.addComponent(spnDeckSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnAdd)
.addComponent(btnCancel)
.addComponent(btnAutoAdd))
.addComponent(btnCancel))
.addContainerGap())
);
@ -337,12 +451,13 @@ public class AddLandDialog extends MageDialog {
int nMountain = ((Number) spnMountain.getValue()).intValue();
int nPlains = ((Number) spnPlains.getValue()).intValue();
int nSwamp = ((Number) spnSwamp.getValue()).intValue();
boolean useFullArt = ckbFullArtLands.isSelected();
addLands("Forest", nForest);
addLands("Island", nIsland);
addLands("Mountain", nMountain);
addLands("Plains", nPlains);
addLands("Swamp", nSwamp);
addLands("Forest", nForest, useFullArt);
addLands("Island", nIsland, useFullArt);
addLands("Mountain", nMountain, useFullArt);
addLands("Plains", nPlains, useFullArt);
addLands("Swamp", nSwamp, useFullArt);
this.removeDialog();
}//GEN-LAST:event_btnAddActionPerformed
@ -361,7 +476,7 @@ public class AddLandDialog extends MageDialog {
int blue = 0;
int white = 0;
Set<Card> cards = deck.getCards();
int land_number = DEFAULT_SEALED_DECK_CARD_NUMBER - cards.size();
int land_number = ((Number) spnDeckSize.getValue()).intValue() - cards.size();
if (land_number < 0) {
land_number = 0;
}
@ -400,14 +515,23 @@ public class AddLandDialog extends MageDialog {
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnSetFastSearch;
private javax.swing.JComboBox cbLandSet;
private javax.swing.JCheckBox ckbFullArtLands;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel lblDeckSize;
private javax.swing.JLabel lblForest;
private javax.swing.JLabel lblForestIcon;
private javax.swing.JLabel lblIsland;
private javax.swing.JLabel lblIslandIcon;
private javax.swing.JLabel lblLandSet;
private javax.swing.JLabel lblMountain;
private javax.swing.JLabel lblMountainIcon;
private javax.swing.JLabel lblPains;
private javax.swing.JLabel lblPlainsIcon;
private javax.swing.JLabel lblSwamp;
private javax.swing.JLabel lblSwampIcon;
private javax.swing.JPanel panelSet;
private javax.swing.JSpinner spnDeckSize;
private javax.swing.JSpinner spnForest;
private javax.swing.JSpinner spnIsland;
private javax.swing.JSpinner spnMountain;

View file

@ -37,7 +37,6 @@ import java.awt.Dimension;
import java.awt.Point;
import java.beans.PropertyVetoException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.swing.ImageIcon;

View file

@ -43,6 +43,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.Writer;
import java.io.Closeable;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketException;
@ -51,11 +52,9 @@ import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@ -75,6 +74,7 @@ import mage.client.util.Config;
import mage.client.util.gui.countryBox.CountryItemEditor;
import mage.client.util.sets.ConstructedFormats;
import mage.remote.Connection;
import mage.utils.StreamUtils;
import org.apache.log4j.Logger;
/**
@ -567,6 +567,7 @@ public class ConnectDialog extends MageDialog {
private void findPublicServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
BufferedReader in = null;
Writer output = null;
try {
String serverUrl = PreferencesDialog.getCachedValue(KEY_CONNECTION_URL_SERVER_LIST, "http://xmage.de/files/server-list.txt");
if (serverUrl.contains("xmage.info/files/")) {
@ -620,7 +621,7 @@ public class ConnectDialog extends MageDialog {
}
List<String> servers = new ArrayList<>();
if (in != null) {
Writer output = null;
if (!URLNotFound) {
// write serverlist to be able to read if URL is not available
File file = new File("serverlist.txt");
@ -639,10 +640,6 @@ public class ConnectDialog extends MageDialog {
}
}
if (output != null) {
output.close();
}
in.close();
}
if (servers.isEmpty()) {
JOptionPane.showMessageDialog(null, "Couldn't find any server.");
@ -670,15 +667,12 @@ public class ConnectDialog extends MageDialog {
} catch (Exception ex) {
logger.error(ex, ex);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
}
}
StreamUtils.closeQuietly(in);
StreamUtils.closeQuietly(output);
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jProxySettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jProxySettingsButtonActionPerformed
PreferencesDialog.main(new String[]{PreferencesDialog.OPEN_CONNECTION_TAB});
}//GEN-LAST:event_jProxySettingsButtonActionPerformed
@ -723,14 +717,14 @@ public class ConnectDialog extends MageDialog {
}//GEN-LAST:event_btnFind2findPublicServerActionPerformed
private void connectXmageus(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connecXmageusW
private void connectXmageus(java.awt.event.ActionEvent evt) {
String serverAddress = "xmage.us";
this.txtServer.setText(serverAddress);
this.txtPort.setText("17171");
// Update userName and password according to the chosen server.
this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress));
}//GEN-LAST:event_connectXmageus
}
private void btnFlagSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFlagSearchActionPerformed
doFastFlagSearch();

View file

@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
@ -7,6 +7,7 @@
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>

View file

@ -25,14 +25,13 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.dialog;
import java.util.Locale;
import javax.swing.*;
import mage.client.SessionHandler;
import org.apache.log4j.Logger;
import javax.swing.*;
/**
* Feedback dialog.
*
@ -47,17 +46,19 @@ public class FeedbackDialog extends javax.swing.JDialog {
"Thank you or \"Devs, you are so cool!\"",
"Question or \"I'm so curious about\""};
/** Creates new form PreferencesDialog */
/**
* Creates new form PreferencesDialog
*/
public FeedbackDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
cbFeedbackType.setModel(new DefaultComboBoxModel(feedbackTypes));
}
/** 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.
/**
* 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
@ -259,16 +260,16 @@ public class FeedbackDialog extends javax.swing.JDialog {
if (type == null || type.isEmpty()) {
return "";
}
if (type.toLowerCase().startsWith("bug")) {
if (type.toLowerCase(Locale.ENGLISH).startsWith("bug")) {
return "bug";
}
if (type.toLowerCase().startsWith("feature")) {
if (type.toLowerCase(Locale.ENGLISH).startsWith("feature")) {
return "feature";
}
if (type.toLowerCase().startsWith("thank")) {
if (type.toLowerCase(Locale.ENGLISH).startsWith("thank")) {
return "thank";
}
if (type.toLowerCase().startsWith("question")) {
if (type.toLowerCase(Locale.ENGLISH).startsWith("question")) {
return "question";
}
return "";

View file

@ -233,6 +233,7 @@
</Component>
<Component class="javax.swing.JLabel" name="txtDurationGame">
<Properties>
<Property name="text" type="java.lang.String" value="Duration Game"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>

View file

@ -31,7 +31,6 @@
*
* Created on Jul 31, 2013, 9:41:00 AM
*/
package mage.client.dialog;
import java.awt.Color;
@ -63,9 +62,11 @@ public class GameEndDialog extends MageDialog {
private final DateFormat df = DateFormat.getDateTimeInstance();
/** Creates new form GameEndDialog
* @param gameEndView */
/**
* Creates new form GameEndDialog
*
* @param gameEndView
*/
public GameEndDialog(GameEndView gameEndView) {
initComponents();
@ -90,15 +91,15 @@ public class GameEndDialog extends MageDialog {
}
// game duration
txtDurationGame.setText(Format.getDuration(gameEndView.getStartTime(), gameEndView.getEndTime()));
txtDurationGame.setText(" " + Format.getDuration(gameEndView.getStartTime(), gameEndView.getEndTime()));
txtDurationGame.setToolTipText(new StringBuilder(df.format(gameEndView.getStartTime())).append(" - ").append(df.format(gameEndView.getEndTime())).toString());
// match duration
Calendar cal = Calendar.getInstance();
txtDurationMatch.setText(Format.getDuration(gameEndView.getMatchView().getStartTime(), cal.getTime()));
txtDurationMatch.setText(" " + Format.getDuration(gameEndView.getMatchView().getStartTime(), cal.getTime()));
txtDurationMatch.setToolTipText(new StringBuilder(df.format(gameEndView.getMatchView().getStartTime())).append(" - ").append(df.format(cal.getTime())).toString());
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(" ");
for (PlayerView player : gameEndView.getPlayers()) {
sb.append(player.getName()).append(" Life: ").append(player.getLife()).append(' ');
}
@ -146,10 +147,10 @@ public class GameEndDialog extends MageDialog {
this.setVisible(true);
}
/** 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.
/**
* 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
@ -223,6 +224,7 @@ public class GameEndDialog extends MageDialog {
lblDurationGame.setText("Duration game:");
txtDurationGame.setText("Duration Game");
txtDurationGame.setBorder(javax.swing.BorderFactory.createEtchedBorder());
lblLife.setText("Life at end:");
@ -290,7 +292,11 @@ public class GameEndDialog extends MageDialog {
tabPane.addTab("Statistics", tabStatistics);
btnOk.setText("OK");
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -27,6 +27,12 @@
*/
package mage.client.dialog;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.*;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@ -45,13 +51,6 @@ import mage.view.GameTypeView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -143,7 +142,7 @@ public class NewTableDialog extends MageDialog {
lbDeckType.setText("Deck Type:");
lbTimeLimit.setText("Time Limit:");
lbTimeLimit.setToolTipText("The active time a player may use to finish the match. If his or her time runs out, the player looses the current game.");
lbTimeLimit.setToolTipText("The active time a player may use to finish the match. If their time runs out, the player looses the current game.");
lblGameType.setText("Game Type:");
@ -623,17 +622,22 @@ public class NewTableDialog extends MageDialog {
* set the table settings from java prefs
*/
int currentSettingVersion = 0;
private void setGameSettingsFromPrefs(int version) {
currentSettingVersion = version;
String versionStr = "";
if (currentSettingVersion == 1) {
switch (currentSettingVersion) {
case 1:
versionStr = "1";
btnPreviousConfiguration1.requestFocus();
} else if (currentSettingVersion == 2) {
break;
case 2:
versionStr = "2";
btnPreviousConfiguration2.requestFocus();
} else {
break;
default:
btnPreviousConfiguration2.getParent().requestFocus();
break;
}
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, ""));
@ -724,6 +728,7 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
StringBuilder playerTypesString = new StringBuilder();
for (Object player : players) {

View file

@ -35,11 +35,14 @@ package mage.client.dialog;
import java.awt.*;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import mage.cards.decks.Deck;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.cards.repository.ExpansionInfo;
@ -764,7 +767,6 @@ public class NewTournamentDialog extends MageDialog {
this.spnNumPlayers.setModel(new SpinnerNumberModel(numPlayers, tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
createPlayers((Integer) spnNumPlayers.getValue() - 1);
this.spnNumSeats.setModel(new SpinnerNumberModel(2, 2, tournamentType.getMaxPlayers(), 1));
if (tournamentType.isLimited()) {
@ -1263,7 +1265,7 @@ class DeckFilter extends FileFilter {
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i + 1).toLowerCase();
ext = s.substring(i + 1).toLowerCase(Locale.ENGLISH);
}
return (ext == null) ? false : ext.equals("dck");
}

View file

@ -210,11 +210,11 @@ public class PickChoiceDialog extends MageDialog {
// load data to datamodel after filter or on startup
String filter = choice.getSearchText();
if (filter == null){ filter = ""; }
filter = filter.toLowerCase();
filter = filter.toLowerCase(Locale.ENGLISH);
this.dataModel.clear();
for(KeyValueItem item: this.allItems){
if(!choice.isSearchEnabled() || item.Value.toLowerCase().contains(filter)){
if(!choice.isSearchEnabled() || item.Value.toLowerCase(Locale.ENGLISH).contains(filter)){
this.dataModel.addElement(item);
}
}

View file

@ -22,69 +22,36 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="183" max="32767" attributes="0"/>
<Component id="panelCommands" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="spnAmount" min="-2" pref="74" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane1" alignment="0" pref="146" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="spnAmount" min="-2" pref="52" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="64" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="117" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnAmount" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="panelCommands" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="spnAmount">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnOk">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Properties>
<Property name="horizontalScrollBarPolicy" type="int" value="31"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
@ -94,10 +61,8 @@
<SubComponents>
<Component class="javax.swing.JTextPane" name="lblMessage">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="editable" type="boolean" value="false"/>
<Property name="text" type="java.lang.String" value="long text long text long text long text long text long text long text long text"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="null&#x9;" type="code"/>
</Property>
@ -107,5 +72,61 @@
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JSpinner" name="spnAmount">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelCommands">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnOk">
<Properties>
<Property name="text" type="java.lang.String" value="Choose"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="getRootPane().setDefaultButton(btnOk);"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="btnCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -35,6 +35,8 @@
package mage.client.dialog;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
import mage.client.MageFrame;
@ -57,6 +59,7 @@ public class PickNumberDialog extends MageDialog {
public void showDialog(int min, int max, String message) {
this.spnAmount.setModel(new SpinnerNumberModel(min, min, max, 1));
this.lblMessage.setContentType("text/html");
this.lblMessage.setText(message);
this.btnOk.setVisible(true);
this.btnCancel.setVisible(false);
@ -68,11 +71,34 @@ public class PickNumberDialog extends MageDialog {
}else{
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.getRootPane().setDefaultButton(this.btnOk); // restore default button after root panel change (no need actually)
// enable spinner's enter key like text (one enter press instead two)
// https://stackoverflow.com/questions/3873870/java-keylistener-not-firing-on-jspinner
((JSpinner.DefaultEditor)this.spnAmount.getEditor()).getTextField().addKeyListener(new KeyListener(){
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
btnOk.doClick();
}
}
@Override
public void keyTyped(KeyEvent e) {
}
});
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight());
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
// TODO: need to fix focus restore on second popup (it's not focues, test on Manamorphose)
this.setVisible(true);
}
@ -93,29 +119,62 @@ public class PickNumberDialog extends MageDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
spnAmount = new javax.swing.JSpinner();
btnCancel = new javax.swing.JButton();
btnOk = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
lblMessage = new javax.swing.JTextPane();
spnAmount.setModel(new javax.swing.SpinnerNumberModel(1, null, null, 1));
btnCancel.setText("Cancel");
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnOk.setText("OK");
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
spnAmount = new javax.swing.JSpinner();
panelCommands = new javax.swing.JPanel();
btnOk = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane1.setFocusable(false);
lblMessage.setBorder(null);
lblMessage.setEditable(false);
lblMessage.setText("long text long text long text long text long text long text long text long text");
lblMessage.setCursor(null );
lblMessage.setFocusable(false);
lblMessage.setOpaque(false);
jScrollPane1.setViewportView(lblMessage);
spnAmount.setModel(new javax.swing.SpinnerNumberModel(1, null, null, 1));
btnOk.setText("Choose");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
panelCommands.setLayout(panelCommandsLayout);
panelCommandsLayout.setHorizontalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)
.addContainerGap())
);
panelCommandsLayout.setVerticalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnOk)
.addComponent(btnCancel))
.addContainerGap())
);
getRootPane().setDefaultButton(btnOk);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -123,29 +182,22 @@ public class PickNumberDialog extends MageDialog {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
.addComponent(panelCommands, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(54, 54, 54))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel)
.addComponent(btnOk))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@ -167,6 +219,7 @@ public class PickNumberDialog extends MageDialog {
private javax.swing.JButton btnOk;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextPane lblMessage;
private javax.swing.JPanel panelCommands;
private javax.swing.JSpinner spnAmount;
// End of variables declaration//GEN-END:variables

View file

@ -25,16 +25,17 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="saveButton" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="exitButton" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="tabsPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -97,7 +98,7 @@
<Component id="main_gamelog" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_battlefield" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="154" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -121,9 +122,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="cbDraftLogAutoSave" max="32767" attributes="0"/>
<Component id="cbGameLogAutoSave" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbDraftLogAutoSave" min="-2" max="-2" attributes="0"/>
<Component id="cbGameJsonLogAutoSave" min="-2" max="-2" attributes="0"/>
<Component id="cbGameLogAutoSave" alignment="0" min="-2" pref="505" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@ -134,7 +136,10 @@
<Group type="102" attributes="0">
<Component id="cbGameLogAutoSave" alignment="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbDraftLogAutoSave" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="cbDraftLogAutoSave" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbGameJsonLogAutoSave" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -143,7 +148,7 @@
<Component class="javax.swing.JCheckBox" name="cbGameLogAutoSave">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Auto save game logs (to &quot;../Mage.Client/gamelogs/&quot; directory)"/>
<Property name="text" type="java.lang.String" value="Save game logs (to &quot;../Mage.Client/gamelogs/&quot; directory)"/>
<Property name="toolTipText" type="java.lang.String" value="The logs of all your games will be saved to the mentioned folder if this option is switched on."/>
</Properties>
<Events>
@ -153,13 +158,23 @@
<Component class="javax.swing.JCheckBox" name="cbDraftLogAutoSave">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Auto save draft logs (to &quot;../Mage.Client/gamelogs/&quot; directory)"/>
<Property name="text" type="java.lang.String" value="Save draft logs (to &quot;../Mage.Client/gamelogs/&quot; directory)"/>
<Property name="toolTipText" type="java.lang.String" value="The logs of all your games will be saved to the mentioned folder if this option is switched on."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbDraftLogAutoSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbGameJsonLogAutoSave">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Save JSON game logs (to &quot;../Mage.Client/gamelogsJson/&quot; directory)"/>
<Property name="toolTipText" type="java.lang.String" value="The JSON logs of all your games will be saved to the mentioned folder if this option is switched on."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameJsonLogAutoSaveActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="main_card">
@ -185,7 +200,7 @@
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="tooltipDelayLabel" pref="308" max="32767" attributes="0"/>
<Component id="tooltipDelayLabel" max="32767" attributes="0"/>
<Component id="tooltipDelay" alignment="1" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
@ -221,7 +236,7 @@
<Property name="toolTipText" type="java.lang.String" value="Write the card&apos;s name on the card to make the card name more recognizable."/>
<Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
<Color id="Standardcursor"/>
</Property>
</Properties>
<Events>
@ -252,7 +267,7 @@
<Property name="selected" type="boolean" value="true"/>
<Property name="toolTipText" type="java.lang.String" value="Show the path Xmage is expecting for this card&apos;s image (only displays if missing)"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
<Color id="Standardcursor"/>
</Property>
<Property name="label" type="java.lang.String" value="Display image path for missing images"/>
</Properties>
@ -280,6 +295,8 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="showPlayerNamesPermanently" alignment="0" max="32767" attributes="0"/>
<Component id="nonLandPermanentsInOnePile" alignment="0" max="32767" attributes="0"/>
@ -289,7 +306,11 @@
<Component id="cbAskMoveToGraveOrder" alignment="0" max="32767" attributes="0"/>
<Component id="showAbilityPickerForced" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="255" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="displayLifeOnAvatar" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -300,6 +321,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="showPlayerNamesPermanently" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="displayLifeOnAvatar" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="showAbilityPickerForced" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbAllowRequestToShowHandCards" min="-2" max="-2" attributes="0"/>
@ -309,7 +332,6 @@
<Component id="cbConfirmEmptyManaPool" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbAskMoveToGraveOrder" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -339,6 +361,17 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showPlayerNamesPermanentlyActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="displayLifeOnAvatar">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Display life on avatar image"/>
<Property name="toolTipText" type="java.lang.String" value="Display the player&apos;s life over its avatar image."/>
<Property name="horizontalAlignment" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="displayLifeOnAvatarActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="showAbilityPickerForced">
<Properties>
<Property name="selected" type="boolean" value="true"/>
@ -4259,7 +4292,7 @@
<Component id="panelCardImages" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelBackgroundImages" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="125" max="32767" attributes="0"/>
<EmptySpace pref="133" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -4318,7 +4351,7 @@
</Group>
<Component id="cbUseDefaultImageFolder" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="270" max="32767" attributes="0"/>
<EmptySpace min="0" pref="308" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -4832,7 +4865,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="avatarPane" pref="584" max="32767" attributes="0"/>
<Component id="avatarPane" pref="620" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -5743,7 +5776,7 @@
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="198" max="32767" attributes="0"/>
<EmptySpace pref="201" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -6008,7 +6041,7 @@
<Component id="keyToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="441" max="32767" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="478" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>

View file

@ -45,6 +45,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
@ -65,12 +66,11 @@ import javax.swing.filechooser.FileFilter;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.components.KeyBindButton;
import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MODE_ENABLE_BY_MULTICOLOR;
import mage.client.util.Config;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MODE_ENABLE_BY_MULTICOLOR;
import static mage.constants.Constants.DEFAULT_AVATAR_ID;
import static mage.constants.Constants.MAX_AVATAR_ID;
import static mage.constants.Constants.MIN_AVATAR_ID;
@ -79,6 +79,7 @@ import mage.players.net.UserGroup;
import mage.players.net.UserSkipPrioritySteps;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import mage.remote.Session;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
@ -96,6 +97,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_SHOW_FULL_IMAGE_PATH = "showFullImagePath";
public static final String KEY_PERMANENTS_IN_ONE_PILE = "nonLandPermanentsInOnePile";
public static final String KEY_SHOW_PLAYER_NAMES_PERMANENTLY = "showPlayerNamesPermanently";
public static final String KEY_DISPLAY_LIVE_ON_AVATAR = "displayLiveOnAvatar";
public static final String KEY_SHOW_ABILITY_PICKER_FORCED = "showAbilityPicker";
public static final String KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS = "gameAllowRequestShowHandCards";
public static final String KEY_GAME_SHOW_STORM_COUNTER = "gameShowStormCounter";
@ -122,6 +124,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave";
public static final String KEY_DRAFT_LOG_AUTO_SAVE = "draftLogAutoSave";
public static final String KEY_JSON_GAME_LOG_AUTO_SAVE = "gameLogJsonAutoSave";
public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault";
public static final String KEY_CARD_IMAGES_PATH = "cardImagesPath";
@ -191,6 +194,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_DECK_EDITOR_LAST_SORT = "deckEditorLastSort";
public static final String KEY_DECK_EDITOR_LAST_SEPARATE_CREATURES = "deckEditorLastSeparateCreatures";
public static final String KEY_DECK_EDITOR_SEARCH_NAMES = "deckEditorSearchNames";
public static final String KEY_DECK_EDITOR_SEARCH_TYPES = "deckEditorSearchTypes";
public static final String KEY_DECK_EDITOR_SEARCH_RULES = "deckEditorSearchRules";
public static final String KEY_DECK_EDITOR_SEARCH_UNIQUE = "deckEditorSearchUnique";
// positions of divider bars
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
public static final String KEY_TABLES_DIVIDER_LOCATION_2 = "tablePanelDividerLocation2";
@ -406,6 +414,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
main_gamelog = new javax.swing.JPanel();
cbGameLogAutoSave = new javax.swing.JCheckBox();
cbDraftLogAutoSave = new javax.swing.JCheckBox();
cbGameJsonLogAutoSave = new javax.swing.JCheckBox();
main_card = new javax.swing.JPanel();
showCardName = new javax.swing.JCheckBox();
tooltipDelayLabel = new javax.swing.JLabel();
@ -414,6 +423,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
main_game = new javax.swing.JPanel();
nonLandPermanentsInOnePile = new javax.swing.JCheckBox();
showPlayerNamesPermanently = new javax.swing.JCheckBox();
displayLifeOnAvatar = new javax.swing.JCheckBox();
showAbilityPickerForced = new javax.swing.JCheckBox();
cbAllowRequestToShowHandCards = new javax.swing.JCheckBox();
cbShowStormCounter = new javax.swing.JCheckBox();
@ -600,7 +610,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
main_gamelog.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Game log"));
cbGameLogAutoSave.setSelected(true);
cbGameLogAutoSave.setText("Auto save game logs (to \"../Mage.Client/gamelogs/\" directory)");
cbGameLogAutoSave.setText("Save game logs (to \"../Mage.Client/gamelogs/\" directory)");
cbGameLogAutoSave.setToolTipText("The logs of all your games will be saved to the mentioned folder if this option is switched on.");
cbGameLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -609,7 +619,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
});
cbDraftLogAutoSave.setSelected(true);
cbDraftLogAutoSave.setText("Auto save draft logs (to \"../Mage.Client/gamelogs/\" directory)");
cbDraftLogAutoSave.setText("Save draft logs (to \"../Mage.Client/gamelogs/\" directory)");
cbDraftLogAutoSave.setToolTipText("The logs of all your games will be saved to the mentioned folder if this option is switched on.");
cbDraftLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -617,15 +627,25 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
cbGameJsonLogAutoSave.setSelected(true);
cbGameJsonLogAutoSave.setText("Save JSON game logs (to \"../Mage.Client/gamelogsJson/\" directory)");
cbGameJsonLogAutoSave.setToolTipText("The JSON logs of all your games will be saved to the mentioned folder if this option is switched on.");
cbGameJsonLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbGameJsonLogAutoSaveActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout main_gamelogLayout = new org.jdesktop.layout.GroupLayout(main_gamelog);
main_gamelog.setLayout(main_gamelogLayout);
main_gamelogLayout.setHorizontalGroup(
main_gamelogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(main_gamelogLayout.createSequentialGroup()
.addContainerGap()
.add(main_gamelogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(cbDraftLogAutoSave, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(cbGameLogAutoSave, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(main_gamelogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(cbDraftLogAutoSave)
.add(cbGameJsonLogAutoSave)
.add(cbGameLogAutoSave, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 505, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
main_gamelogLayout.setVerticalGroup(
@ -633,7 +653,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(main_gamelogLayout.createSequentialGroup()
.add(cbGameLogAutoSave)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbDraftLogAutoSave))
.add(cbDraftLogAutoSave)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbGameJsonLogAutoSave)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
main_card.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card"));
@ -680,7 +703,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(6, 6, 6)
.add(main_cardLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(main_cardLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(tooltipDelayLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 308, Short.MAX_VALUE)
.add(tooltipDelayLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(tooltipDelay, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(main_cardLayout.createSequentialGroup()
.add(showCardName)
@ -721,6 +744,16 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
displayLifeOnAvatar.setSelected(true);
displayLifeOnAvatar.setText("Display life on avatar image");
displayLifeOnAvatar.setToolTipText("Display the player's life over its avatar image.");
displayLifeOnAvatar.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
displayLifeOnAvatar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
displayLifeOnAvatarActionPerformed(evt);
}
});
showAbilityPickerForced.setSelected(true);
showAbilityPickerForced.setText("Show ability picker for abilities or spells without costs");
showAbilityPickerForced.setToolTipText("This prevents you from accidently activating abilities without other costs than tapping or casting spells with 0 mana costs.");
@ -777,6 +810,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
main_gameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(main_gameLayout.createSequentialGroup()
.addContainerGap()
.add(main_gameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(main_gameLayout.createSequentialGroup()
.add(main_gameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(showPlayerNamesPermanently, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(nonLandPermanentsInOnePile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@ -785,7 +820,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(cbShowStormCounter, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(cbAskMoveToGraveOrder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(showAbilityPickerForced, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(255, Short.MAX_VALUE))
.add(0, 0, Short.MAX_VALUE))
.add(displayLifeOnAvatar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
main_gameLayout.setVerticalGroup(
main_gameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -794,6 +831,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(showPlayerNamesPermanently)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(displayLifeOnAvatar)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(showAbilityPickerForced)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbAllowRequestToShowHandCards)
@ -802,8 +841,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbConfirmEmptyManaPool)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbAskMoveToGraveOrder)
.addContainerGap())
.add(cbAskMoveToGraveOrder))
);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
@ -863,7 +901,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(main_gamelog, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(main_battlefield, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(154, Short.MAX_VALUE))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
main_card.getAccessibleContext().setAccessibleName("Game panel");
@ -1582,7 +1620,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbNumberOfDownloadThreads, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(cbUseDefaultImageFolder))
.add(0, 270, Short.MAX_VALUE)))
.add(0, 308, Short.MAX_VALUE)))
.addContainerGap())
);
panelCardImagesLayout.setVerticalGroup(
@ -1777,7 +1815,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(panelCardImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(panelBackgroundImages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(125, Short.MAX_VALUE))
.addContainerGap(133, Short.MAX_VALUE))
);
tabsPanel.addTab("Images", tabImages);
@ -2352,7 +2390,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabAvatarsLayout.setVerticalGroup(
tabAvatarsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabAvatarsLayout.createSequentialGroup()
.add(avatarPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 584, Short.MAX_VALUE)
.add(avatarPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 620, Short.MAX_VALUE)
.addContainerGap())
);
@ -2387,7 +2425,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(connection_serversLayout.createSequentialGroup()
.add(141, 141, 141)
.add(jLabel17)))
.addContainerGap(198, Short.MAX_VALUE))
.addContainerGap(201, Short.MAX_VALUE))
);
connection_serversLayout.setVerticalGroup(
connection_serversLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -2626,7 +2664,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(keyEndStep, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(keyToggleRecordMacro, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE)))
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)))
.addContainerGap())
);
tabControlsLayout.setVerticalGroup(
@ -2709,15 +2747,15 @@ public class PreferencesDialog extends javax.swing.JDialog {
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(0, 0, Short.MAX_VALUE)
.add(saveButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(exitButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(exitButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(6, 6, 6))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(tabsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@ -2742,6 +2780,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.showFullImagePath, KEY_SHOW_FULL_IMAGE_PATH, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.showPlayerNamesPermanently, KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.displayLifeOnAvatar, KEY_DISPLAY_LIVE_ON_AVATAR, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbShowStormCounter, KEY_GAME_SHOW_STORM_COUNTER, "true", "false", UPDATE_CACHE_POLICY);
@ -2749,6 +2788,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.cbAskMoveToGraveOrder, KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbDraftLogAutoSave, KEY_DRAFT_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbGameJsonLogAutoSave, KEY_JSON_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
String paramName = KEY_BATTLEFIELD_FEEDBACK_COLORIZING_MODE;
int paramValue = dialog.cbBattlefieldFeedbackColorizingMode.getSelectedIndex();
@ -3197,6 +3237,17 @@ public class PreferencesDialog extends javax.swing.JDialog {
}//GEN-LAST:event_cbBattlefieldFeedbackColorizingModeActionPerformed
private void cbGameJsonLogAutoSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameJsonLogAutoSaveActionPerformed
Session session = SessionHandler.getSession();
if (session != null) {
session.setJsonLogActive(cbGameJsonLogAutoSave.isSelected());
}
}//GEN-LAST:event_cbGameJsonLogAutoSaveActionPerformed
private void displayLifeOnAvatarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayLifeOnAvatarActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_displayLifeOnAvatarActionPerformed
private void showProxySettings() {
Connection.ProxyType proxyType = (Connection.ProxyType) cbProxyType.getSelectedItem();
switch (proxyType) {
@ -3303,6 +3354,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.showFullImagePath, KEY_SHOW_FULL_IMAGE_PATH, "true");
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
load(prefs, dialog.showPlayerNamesPermanently, KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
load(prefs, dialog.displayLifeOnAvatar, KEY_DISPLAY_LIVE_ON_AVATAR, "true");
load(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true");
load(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true");
load(prefs, dialog.cbShowStormCounter, KEY_GAME_SHOW_STORM_COUNTER, "true");
@ -3311,6 +3363,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
load(prefs, dialog.cbDraftLogAutoSave, KEY_DRAFT_LOG_AUTO_SAVE, "true");
load(prefs, dialog.cbGameJsonLogAutoSave, KEY_JSON_GAME_LOG_AUTO_SAVE, "true", "false");
String feedbackParam = "";
try {
@ -3440,7 +3493,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
private static void loadProxySettings(Preferences prefs) {
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase()));
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase(Locale.ENGLISH)));
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName);
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(Config.port));
@ -3865,6 +3918,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JCheckBox cbEnableGameSounds;
private javax.swing.JCheckBox cbEnableOtherSounds;
private javax.swing.JCheckBox cbEnableSkipButtonsSounds;
private javax.swing.JCheckBox cbGameJsonLogAutoSave;
private javax.swing.JCheckBox cbGameLogAutoSave;
private javax.swing.JComboBox cbNumberOfDownloadThreads;
private javax.swing.JCheckBox cbPassPriorityActivation;
@ -3898,6 +3952,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JCheckBox checkBoxUpkeepYou;
private javax.swing.JPanel connection_servers;
private javax.swing.JLabel controlsDescriptionLabel;
private javax.swing.JCheckBox displayLifeOnAvatar;
private javax.swing.JButton exitButton;
private javax.swing.JLabel fontSizeLabel;
private javax.swing.JPanel guiSizeBasic;

View file

@ -52,7 +52,6 @@ import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.MageDialogState;
import mage.constants.*;
import mage.game.events.PlayerQueryEvent;
import mage.game.turn.Phase;
import mage.view.*;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardPanel;

View file

@ -45,7 +45,6 @@ import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import mage.client.SessionHandler;
import mage.client.components.MageTextArea;

View file

@ -77,7 +77,6 @@ import mage.constants.ManaType;
import mage.counters.Counter;
import mage.counters.CounterType;
import mage.designations.DesignationType;
import mage.remote.Session;
import mage.utils.timer.PriorityTimer;
import mage.view.CardView;
import mage.view.ManaPoolView;
@ -93,13 +92,10 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private UUID playerId;
private UUID gameId;
private Session session;
private PlayerView player;
private BigCard bigCard;
private static final int AVATAR_COUNT = 77;
private static final String DEFAULT_AVATAR_PATH = "/avatars/" + DEFAULT_AVATAR_ID + ".jpg";
private static final int PANEL_WIDTH = 94;
@ -179,8 +175,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
public void update(PlayerView player) {
this.player = player;
updateAvatar();
int playerLife = player.getLife();
avatar.setCenterText("true".equals(MageFrame.getPreferences().get(PreferencesDialog.KEY_DISPLAY_LIVE_ON_AVATAR, "true"))
? String.valueOf(playerLife) : null);
updateAvatar();
if (playerLife > 99) {
Font font = lifeLabel.getFont();
font = font.deriveFont(9f);
@ -701,8 +700,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
// .addGroup(gl_panelBackground.createSequentialGroup()
// .addComponent(avatarFlag, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))
.addGap(8))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
@ -824,16 +821,12 @@ public class PlayerPanelExt extends javax.swing.JPanel {
protected void sizePlayerPanel(boolean smallMode) {
if (smallMode) {
avatar.setVisible(false);
// avatarFlag.setVisible(false);
// monarchIcon.setVisible(false);
btnPlayer.setVisible(true);
timerLabel.setVisible(true);
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
} else {
avatar.setVisible(true);
// avatarFlag.setVisible(true);
// monarchIcon.setVisible(true);
btnPlayer.setVisible(false);
timerLabel.setVisible(false);
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
@ -887,8 +880,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
private HoverButton avatar;
// private JLabel avatarFlag;
// private JLabel monarchIcon;
private JButton btnPlayer;
private ImagePanel life;
private ImagePanel poison;
@ -918,7 +909,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private JPanel energyExperiencePanel;
private HoverButton exileZone;
private HoverButton commandZone;
private HoverButton enchantPlayerViewZone;
private final Map<String, JLabel> manaLabels = new HashMap<>();
}

View file

@ -26,10 +26,12 @@ import mage.cards.MageCard;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
import mage.client.MageFrame;
import mage.client.MagePane;
import mage.client.SessionHandler;
import mage.client.cards.BigCard;
import mage.client.components.MageComponents;
import mage.client.dialog.PreferencesDialog;
import mage.client.game.GamePane;
import mage.client.plugins.impl.Plugins;
import mage.client.util.DefaultActionCallback;
import mage.client.util.gui.ArrowBuilder;
@ -367,6 +369,16 @@ public class MageActionCallback implements ActionCallback {
}
private void handleOverNewView(TransferData data) {
// Prevent to show tooltips from panes not in front
MagePane topPane = MageFrame.getTopMost(null);
if (topPane instanceof GamePane) {
if (!((GamePane) topPane).getGameId().equals(data.gameId)) {
return;
}
} else if (data.gameId != null) {
return;
}
hideTooltipPopup();
cancelTimeout();
Component parentComponent = SwingUtilities.getRoot(data.component);

View file

@ -190,16 +190,15 @@ public class CallbackClientImpl implements CallbackClient {
break;
}
case GAME_OVER: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
Session session = SessionHandler.getSession();
if (session.isJsonLogActive()) {
appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
ActionData actionData = appendJsonEvent("GAME_OVER", callback.getObjectId(), callback.getData());
String logFileName = "game-" + actionData.gameId + ".json";
S3Uploader.upload(logFileName, actionData.gameId.toString());
}
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
@ -408,11 +407,14 @@ public class CallbackClientImpl implements CallbackClient {
private ActionData appendJsonEvent(String name, UUID gameId, Object value) {
Session session = SessionHandler.getSession();
if (session.isJsonLogActive()) {
ActionData actionData = new ActionData(name, gameId);
actionData.value = value;
session.appendJsonLog(actionData);
return actionData;
}
return null;
}
private void createChatStartMessage(ChatPanelBasic chatPanel) {
chatPanel.setStartMessageDone(true);

View file

@ -31,18 +31,17 @@
*
* Created on 15-Dec-2009, 10:09:46 PM
*/
package mage.client.table;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import mage.client.MageFrame;
import mage.client.deck.generator.DeckGenerator;
import mage.client.util.Config;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.io.File;
import java.io.IOException;
/**
*
* @author BetaSteward_at_googlemail.com
@ -51,7 +50,9 @@ public class NewPlayerPanel extends javax.swing.JPanel {
private final JFileChooser fcSelectDeck;
/** Creates new form NewPlayerPanel */
/**
* Creates new form NewPlayerPanel
*/
public NewPlayerPanel() {
initComponents();
fcSelectDeck = new JFileChooser();
@ -86,7 +87,8 @@ public class NewPlayerPanel extends javax.swing.JPanel {
this.txtPlayerDeck.setText(file.getPath());
try {
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
} catch (IOException ex) { }
} catch (IOException ex) {
}
}
fcSelectDeck.setSelectedFile(null);
}
@ -111,7 +113,6 @@ public class NewPlayerPanel extends javax.swing.JPanel {
this.txtPlayerDeck.setText(deckFile);
}
public int getLevel() {
return (Integer) spnLevel.getValue();
}
@ -128,10 +129,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
this.btnPlayerDeck.setVisible(show);
}
/** 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.
/**
* 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
@ -211,7 +212,6 @@ public class NewPlayerPanel extends javax.swing.JPanel {
generateDeck();
}//GEN-LAST:event_btnGenerateActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnGenerate;
private javax.swing.JButton btnPlayerDeck;
@ -238,7 +238,7 @@ class DeckFilter extends FileFilter {
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
ext = s.substring(i + 1).toLowerCase(Locale.ENGLISH);
}
return (ext == null) ? false : ext.equals("dck");
}

View file

@ -28,6 +28,7 @@
package mage.client.util;
import java.util.Comparator;
import java.util.Locale;
import mage.view.CardView;
/**
@ -99,7 +100,7 @@ public class CardViewEDHPowerLevelComparator implements Comparator<CardView> {
boolean whenYouCast = false;
for (String str : card.getRules()) {
String s = str.toLowerCase();
String s = str.toLowerCase(Locale.ENGLISH);
annihilator |= s.contains("annihilator");
anyNumberOfTarget |= s.contains("any number");
buyback |= s.contains("buyback");
@ -332,16 +333,16 @@ public class CardViewEDHPowerLevelComparator implements Comparator<CardView> {
}
if (card.getCardTypes().contains("Plainswalker")) {
if (card.getName().toLowerCase().equals("jace, the mind sculptor")) {
if (card.getName().toLowerCase(Locale.ENGLISH).equals("jace, the mind sculptor")) {
thisMaxPower = Math.max(thisMaxPower, 6);
}
if (card.getName().toLowerCase().equals("ugin, the spirit dragon")) {
if (card.getName().toLowerCase(Locale.ENGLISH).equals("ugin, the spirit dragon")) {
thisMaxPower = Math.max(thisMaxPower, 5);
}
thisMaxPower = Math.max(thisMaxPower, 4);
}
String cn = card.getName().toLowerCase();
String cn = card.getName().toLowerCase(Locale.ENGLISH);
if (cn.equals("ancient tomb")
|| cn.equals("anafenza, the foremost")
|| cn.equals("arcum dagsson")

View file

@ -1,6 +1,5 @@
package mage.client.util;
import java.awt.event.MouseEvent;
import java.util.UUID;
import mage.client.SessionHandler;

View file

@ -1,13 +1,12 @@
package mage.client.util;
import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.Set;
import mage.client.MageFrame;
import mage.client.preference.MagePreferences;
import mage.view.ChatMessage;
import java.util.Arrays;
import java.util.Set;
public final class IgnoreList {
private static final String USAGE = "<br/><font color=yellow>\\ignore - shows current ignore list on this server."
@ -15,8 +14,8 @@ public final class IgnoreList {
+ "<br/>\\unignore [username] - remove a username from your ignore list on this server.</font>";
public static final int MAX_IGNORE_LIST_SIZE = 50;
public static Set<ChatMessage.MessageType> IGNORED_MESSAGE_TYPES =
ImmutableSet.of(ChatMessage.MessageType.TALK,
public static Set<ChatMessage.MessageType> IGNORED_MESSAGE_TYPES
= ImmutableSet.of(ChatMessage.MessageType.TALK,
ChatMessage.MessageType.WHISPER_FROM);
public static String usage() {
@ -45,22 +44,13 @@ public final class IgnoreList {
}
if (userIsIgnored(serverAddress, user)) {
return new StringBuilder()
.append(user)
.append(" is already on your ignore list on ")
.append(serverAddress)
.toString();
return user + " is already on your ignore list on " + serverAddress;
}
MagePreferences.addIgnoredUser(serverAddress, user);
updateTablesTable();
return new StringBuilder()
.append("Added ")
.append(user)
.append(" to your ignore list on ")
.append(serverAddress)
.toString();
return "Added " + user + " to your ignore list on " + serverAddress;
}
private static void updateTablesTable() {
@ -76,19 +66,9 @@ public final class IgnoreList {
}
if (MagePreferences.removeIgnoredUser(serverAddress, user)) {
updateTablesTable();
return new StringBuilder()
.append("Removed ")
.append(user)
.append(" from your ignore list on ")
.append(serverAddress)
.toString();
return "Removed " + user + " from your ignore list on " + serverAddress;
} else {
return new StringBuilder()
.append("No such user \"")
.append(user)
.append("\" on your ignore list on ")
.append(serverAddress)
.toString();
return "No such user \"" + user + "\" on your ignore list on " + serverAddress;
}
}

View file

@ -2,6 +2,7 @@ package mage.client.util.audio;
import java.awt.List;
import java.io.File;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.sound.sampled.*;
import mage.client.constants.Constants;
@ -38,7 +39,7 @@ public class MusicPlayer {
}
String filename;
for (File f : fileread) {
filename = f.getName().toLowerCase();
filename = f.getName().toLowerCase(Locale.ENGLISH);
if (filename.endsWith(".mp3") || filename.endsWith(".wav")) {
filelist.add(filename);
}

View file

@ -45,17 +45,13 @@ public class ArrowBuilder {
* Get the panel where all arrows are being drawn.
* @return
*/
public JPanel getArrowsManagerPanel() {
if (arrowsManagerPanel == null) {
synchronized (ArrowBuilder.class) {
public synchronized JPanel getArrowsManagerPanel() {
if (arrowsManagerPanel == null) {
arrowsManagerPanel = new JPanel();
arrowsManagerPanel.setVisible(true);
arrowsManagerPanel.setOpaque(false);
arrowsManagerPanel.setLayout(null);
}
}
}
return arrowsManagerPanel;
}

View file

@ -6,6 +6,7 @@ import java.awt.FlowLayout;
import java.awt.Image;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
@ -77,7 +78,7 @@ public class ColorsChooser extends JComboBox implements ListCellRenderer {
private void drawOn(JPanel panel, String value) {
List<Image> images = new ArrayList<>();
value = value.toUpperCase();
value = value.toUpperCase(Locale.ENGLISH);
for (int i = 0; i < value.length(); i++) {
char symbol = value.charAt(i);
Image image = ManaSymbols.getSizedManaSymbol(String.valueOf(symbol));

View file

@ -2,6 +2,7 @@ package mage.client.util.gui;
import java.awt.*;
import java.util.ArrayList;
import java.util.Locale;
import javax.swing.*;
import mage.client.MageFrame;
import mage.client.util.GUISizeHelper;
@ -65,7 +66,7 @@ public final class GuiDisplayUtil {
out.append(c);
}
}
return out.toString().toLowerCase();
return out.toString().toLowerCase(Locale.ENGLISH);
}
public static void keepComponentInsideScreen(int centerX, int centerY, Component component) {
@ -256,7 +257,7 @@ public final class GuiDisplayUtil {
rarity = card.getRarity().getCode();
}
if (card.getExpansionSetCode() != null) {
buffer.append(ManaSymbols.replaceSetCodeWithHTML(card.getExpansionSetCode().toUpperCase(), rarity, GUISizeHelper.symbolTooltipSize));
buffer.append(ManaSymbols.replaceSetCodeWithHTML(card.getExpansionSetCode().toUpperCase(Locale.ENGLISH), rarity, GUISizeHelper.symbolTooltipSize));
}
buffer.append("</td></tr></table>");

View file

@ -1,5 +1,7 @@
package mage.client.util.object;
import mage.utils.StreamUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@ -61,10 +63,9 @@ public final class SaveObjectUtil {
oos.writeObject(object);
oos.close();
} catch (FileNotFoundException e) {
return;
} catch (IOException io) {
return;
} catch (Exception e) {
} finally {
StreamUtils.closeQuietly(oos);
}
}
}

View file

@ -20,8 +20,6 @@ import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import mage.client.constants.Constants;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;

View file

@ -9,16 +9,13 @@ import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.view.StackAbilityView;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.images.ImageCache;
import mage.client.constants.Constants;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.UUID;

View file

@ -396,7 +396,7 @@ public abstract class CardRenderer {
/*
// Just draw the as a code
String code = cardView.getExpansionSetCode();
code = (code != null) ? code.toUpperCase() : "";
code = (code != null) ? code.toUpperCase(Locale.ENGLISH) : "";
FontMetrics metrics = g.getFontMetrics();
setSymbolWidth = metrics.stringWidth(code);
if (cardView.getRarity() == Rarity.COMMON) {

View file

@ -1,6 +1,14 @@
package org.mage.card.arcane;
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.RenderingHints;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageProducer;
@ -18,16 +26,22 @@ import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.swing.*;
import mage.cards.repository.ExpansionRepository;
import mage.client.constants.Constants;
import mage.client.constants.Constants.ResourceSetSize;
import mage.client.constants.Constants.ResourceSymbolSize;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import mage.utils.StreamUtils;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
@ -36,13 +50,6 @@ import org.apache.batik.transcoder.TranscodingHints;
import org.apache.batik.transcoder.image.ImageTranscoder;
import org.apache.batik.util.SVGConstants;
import org.apache.log4j.Logger;
import mage.client.constants.Constants;
import mage.client.constants.Constants.ResourceSymbolSize;
import mage.client.constants.Constants.ResourceSetSize;
import org.jdesktop.swingx.graphics.ShadowRenderer;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import org.mage.plugins.card.utils.CardImageUtils;
public final class ManaSymbols {
@ -71,9 +78,14 @@ public final class ManaSymbols {
private static final Map<String, Dimension> setImagesExist = new HashMap<>();
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
private static String cachedPath;
private static final String[] symbols = new String[]{"0", "1", "10", "11", "12", "15", "16", "2", "3", "4", "5", "6", "7", "8", "9", "B", "BG",
"BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU",
"WP", "UP", "BP", "RP", "GP", "X", "C", "E"};
private static final String[] symbols = new String[]{"0", "1", "10", "11", "12", "15", "16", "2", "3", "4", "5", "6", "7", "8", "9",
"B", "BG", "BR", "BP", "2B",
"G", "GU", "GW", "GP", "2G",
"R", "RG", "RW", "RP", "2R",
"S", "T",
"U", "UB", "UR", "UP", "2U",
"W", "WB", "WU", "WP", "2W",
"X", "C", "E"};
private static final JLabel labelRender = new JLabel(); // render mana text
@ -101,8 +113,7 @@ public final class ManaSymbols {
}
for (String symbol : symbols) {
try
{
try {
BufferedImage image = pngImages.get(symbol);
if (image != null) {
File newFile = new File(pngPath.getPath() + File.separator + symbol + ".png");
@ -222,7 +233,6 @@ public final class ManaSymbols {
// load SVG image
// base loader code: https://stackoverflow.com/questions/11435671/how-to-get-a-buffererimage-from-a-svg
// resize code: https://vibranttechie.wordpress.com/2015/05/15/svg-loading-to-javafx-stage-and-auto-scaling-when-stage-resize/
if (useShadow && ((resizeToWidth <= 0) || (resizeToHeight <= 0))) {
throw new IllegalArgumentException("Must use non zero sizes for shadow.");
}
@ -234,16 +244,21 @@ public final class ManaSymbols {
// These defaults emphasize quality and precision, and
// are more similar to the defaults of other SVG viewers.
// SVG documents can still override these defaults.
String css = "svg {" +
"shape-rendering: geometricPrecision;" +
"text-rendering: geometricPrecision;" +
"color-rendering: optimizeQuality;" +
"image-rendering: optimizeQuality;" +
"}";
String css = "svg {"
+ "shape-rendering: geometricPrecision;"
+ "text-rendering: geometricPrecision;"
+ "color-rendering: optimizeQuality;"
+ "image-rendering: optimizeQuality;"
+ "}";
File cssFile = File.createTempFile("batik-default-override-", ".css");
FileWriter w = new FileWriter(cssFile);
FileWriter w = null;
try {
w = new FileWriter(cssFile);
w.write(css);
w.close();
} finally {
StreamUtils.closeQuietly(w);
}
TranscodingHints transcoderHints = new TranscodingHints();
@ -275,7 +290,6 @@ public final class ManaSymbols {
try {
TranscoderInput input = new TranscoderInput(new FileInputStream(svgFile));
ImageTranscoder t = new ImageTranscoder() {
@Override
@ -293,8 +307,7 @@ public final class ManaSymbols {
t.transcode(input, null);
} catch (Exception e) {
throw new IOException("Couldn't convert svg file: " + svgFile + " , reason: " + e.getMessage());
}
finally {
} finally {
cssFile.delete();
}
@ -309,11 +322,12 @@ public final class ManaSymbols {
ImageProducer prod = new FilteredImageSource(originImage.getSource(), new RGBImageFilter() {
@Override
public int filterRGB(int x, int y, int rgb) {
if (rgb == 0)
if (rgb == 0) {
return 0;
else
} else {
return 0xff000000;
}
}
});
// create whe black image
Image shadow = Toolkit.getDefaultToolkit().createImage(prod);
@ -341,7 +355,6 @@ public final class ManaSymbols {
Color.GRAY);
return renderer.createShadow(base);
*/
//imagePointer[0];
}
@ -503,8 +516,7 @@ public final class ManaSymbols {
}
// fix double separator if size folder is not set
while(path.endsWith(File.separator))
{
while (path.endsWith(File.separator)) {
path = path.substring(0, path.length() - 1);
}
@ -533,8 +545,7 @@ public final class ManaSymbols {
}
// fix double separator if size folder is not set
while(path.endsWith(File.separator))
{
while (path.endsWith(File.separator)) {
path = path.substring(0, path.length() - 1);
}
@ -593,9 +604,6 @@ public final class ManaSymbols {
manaPanel.paint(gg);
g.drawImage(image, x, y, null);
*/
// OLD version with custom draw
Map<String, BufferedImage> sizedSymbols = manaImages.get(symbolWidth);
if (manaCost.isEmpty()) {
@ -608,6 +616,10 @@ public final class ManaSymbols {
while (tok.hasMoreTokens()) {
String symbol = tok.nextToken();
Image image = sizedSymbols.get(symbol);
if (image == null && symbol != null && symbol.length() == 2) {
String symbol2 = "" + symbol.charAt(1) + symbol.charAt(0);
image = sizedSymbols.get(symbol2);
}
if (image == null) {
// TEXT draw
@ -680,7 +692,6 @@ public final class ManaSymbols {
// mana cost to HTML images (urls to files)
// do not use it for new code - try to suppotr svg render
int symbolSize;
switch (type) {
case TABLE:
@ -711,13 +722,11 @@ public final class ManaSymbols {
}
// replace every {symbol} to <img> link
// ignore data backup
String replaced = value
.replace("{source}", "|source|")
.replace("{this}", "|this|");
// not need to add different images (width and height do the work)
// use best png size (generated on startup) TODO: add reload images after update
String htmlImagesPath = getResourceSymbolsPath(ResourceSymbolSize.PNG);
@ -774,4 +783,3 @@ public final class ManaSymbols {
return sizedSymbols.get(symbol);
}
}

View file

@ -34,6 +34,7 @@ import mage.util.SubTypeList;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
import static org.mage.card.arcane.ManaSymbols.getSizedManaSymbol;
/*
@ -119,6 +120,7 @@ public class ModernCardRenderer extends CardRenderer {
public static final BufferedImage BG_IMG_LAND = loadBackgroundImage("land");
public static final BufferedImage BG_IMG_VEHICLE = loadBackgroundImage("vehicle");
public static final BufferedImage BG_IMG_COLORLESS = loadBackgroundImage("colorless");
public static final BufferedImage BG_IMG_EXPEDITION = loadBackgroundImage("expedition");
public static final BufferedImage FRAME_INVENTION = loadFramePart("invention_frame");
@ -142,6 +144,12 @@ public class ModernCardRenderer extends CardRenderer {
public static final Color BOX_INVENTION = new Color(209, 97, 33);
public static final Color BOX_VEHICLE = new Color(155, 105, 60);
public static final Color BOX_UST_WHITE = new Color(240, 240, 220);
public static final Color BOX_UST_BLUE = new Color(10, 100, 180);
public static final Color BOX_UST_BLACK = new Color(28, 30, 28);
public static final Color BOX_UST_RED = new Color(229, 74, 32);
public static final Color BOX_UST_GREEN = new Color(7, 130, 53);
public static final Color BOX_WHITE_NIGHT = new Color(169, 160, 145);
public static final Color BOX_BLUE_NIGHT = new Color(46, 133, 176);
public static final Color BOX_BLACK_NIGHT = new Color(95, 90, 89);
@ -301,7 +309,15 @@ public class ModernCardRenderer extends CardRenderer {
// Just draw a brown rectangle
drawCardBack(g);
} else {
BufferedImage bg = getBackgroundImage(cardView.getColor(), cardView.getCardTypes(), cardView.getSubTypes());
if (cardView.getFrameStyle() == FrameStyle.UST_FULL_ART_BASIC) {
return;
}
boolean isExped = false;
if (cardView.getExpansionSetCode().equals("EXP")) {
isExped = true;
}
BufferedImage bg = getBackgroundImage(cardView.getColor(), cardView.getCardTypes(), cardView.getSubTypes(), isExped);
if (bg == null) {
return;
}
@ -339,6 +355,8 @@ public class ModernCardRenderer extends CardRenderer {
rect = new Rectangle2D.Float(0, 0, 1, 1);
} else if (isZendikarFullArtLand()) {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .84f);
} else if (isUnstableFullArtLand()) {
rect = new Rectangle2D.Float(.0f, .0f, 1.0f, 1.0f);
} else if (cardView.getFrameStyle().isFullArt() || (cardView.isToken())) {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .63f);
} else {
@ -361,6 +379,10 @@ public class ModernCardRenderer extends CardRenderer {
return cardView.getFrameStyle() == FrameStyle.BFZ_FULL_ART_BASIC || cardView.getFrameStyle() == FrameStyle.ZEN_FULL_ART_BASIC;
}
private boolean isUnstableFullArtLand() {
return cardView.getFrameStyle() == FrameStyle.UST_FULL_ART_BASIC;
}
protected boolean isSourceArtFullArt() {
int color = artImage.getRGB(0, artImage.getHeight() / 2);
return (((color & 0x00FF0000) > 0x00200000)
@ -380,7 +402,7 @@ public class ModernCardRenderer extends CardRenderer {
@Override
protected void drawArt(Graphics2D g) {
if (artImage != null && !cardView.isFaceDown()) {
if ((artImage != null || faceArtImage != null) && !cardView.isFaceDown()) {
boolean useFaceArt = false;
if (faceArtImage != null && !isZendikarFullArtLand()) {
@ -442,6 +464,7 @@ public class ModernCardRenderer extends CardRenderer {
// Get the border paint
Color boxColor = getBoxColor(frameColors, cardView.getCardTypes(), isTransformed);
Color additionalBoxColor = getAdditionalBoxColor(frameColors, cardView.getCardTypes(), isTransformed);
Paint textboxPaint = getTextboxPaint(frameColors, cardView.getCardTypes(), cardWidth);
Paint borderPaint = getBorderPaint(frameColors, cardView.getCardTypes(), cardWidth);
@ -450,6 +473,9 @@ public class ModernCardRenderer extends CardRenderer {
boxColor = BOX_INVENTION;
}
// Is this a Zendikar or Unstable land
boolean isZenUst = isZendikarFullArtLand() || isUnstableFullArtLand();
// Draw the main card content border
g.setPaint(borderPaint);
@ -458,7 +484,7 @@ public class ModernCardRenderer extends CardRenderer {
g.drawRect(
totalContentInset, typeLineY,
contentWidth - 1, cardHeight - borderWidth * 3 - typeLineY - 1);
} else if (!isZendikarFullArtLand()) {
} else if (!isZenUst) {
g.drawRect(
totalContentInset, totalContentInset,
contentWidth - 1, cardHeight - borderWidth * 3 - totalContentInset - 1);
@ -471,7 +497,7 @@ public class ModernCardRenderer extends CardRenderer {
g.setPaint(textboxPaint);
}
if (!isZendikarFullArtLand()) {
if (!isZenUst) {
g.fillRect(
totalContentInset + 1, typeLineY,
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
@ -485,7 +511,7 @@ public class ModernCardRenderer extends CardRenderer {
cardWidth / 16, cardHeight - typeLineY - boxHeight - borderWidth * 3);
}
if (cardView.getFrameStyle() != FrameStyle.KLD_INVENTION && !isZendikarFullArtLand()) {
if (cardView.getFrameStyle() != FrameStyle.KLD_INVENTION && !isZenUst) {
// Draw a shadow highlight at the right edge of the content frame
g.setColor(new Color(0, 0, 0, 100));
g.fillRect(
@ -505,7 +531,7 @@ public class ModernCardRenderer extends CardRenderer {
contentInset,
borderPaint, boxColor);
// Draw the type line box
if (!isZendikarFullArtLand()) {
if (!isZenUst) {
CardRendererUtils.drawRoundedBox(g,
borderWidth, typeLineY,
cardWidth - 2 * borderWidth, boxHeight,
@ -542,27 +568,12 @@ public class ModernCardRenderer extends CardRenderer {
contentWidth - nameOffset, boxHeight);
// Draw the textbox rules
if (!isZendikarFullArtLand()) {
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 2, typeLineY + boxHeight + 2,
contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3);
} else {
if (isZendikarFullArtLand()) {
int x = totalContentInset;
int y = typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset;
int w = contentWidth;
int h = boxHeight - 4;
CardRendererUtils.drawZendikarLandBox(g,
x, y, w, h,
contentInset,
borderPaint, boxColor);
drawTypeLine(g, getCardSuperTypeLine(),
totalContentInset + contentInset, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset,
contentWidth / 2 - boxHeight, boxHeight - 4, false);
drawTypeLine(g, getCardSubTypeLine(),
totalContentInset + 4 * contentWidth / 7 + boxHeight, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset,
3 * contentWidth / 7 - boxHeight - contentInset, boxHeight - 4, true);
if (cardView.getFrameStyle() == FrameStyle.ZEN_FULL_ART_BASIC) {
// Draw curved lines (old Zendikar land style) - bigger (around 6%) inset on curve on bottom than inset (around 4.5%) on top...
int x2 = x + contentWidth;
@ -584,9 +595,63 @@ public class ModernCardRenderer extends CardRenderer {
boxColor, borderPaint);
}
// If an expedition, needs the rules box to be visible.
if (cardView.getExpansionSetCode().equals("EXP")) {
// Draw a small separator between the type line and box, and shadow
// at the left of the texbox, and above the name line
g.setPaint(textboxPaint);
float alpha = 0.55f;
AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
Composite origc = g.getComposite();
g.setComposite(comp);
g.setBackground(new Color(155, 0, 0, 150));
g.fillRect(
totalContentInset + 1, typeLineY - boxHeight,
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
g.setComposite(origc);
g.fillRect(
totalContentInset - 1, totalContentInset - 1,
contentWidth + 1, 1);
g.fillRect(
totalContentInset + 1, typeLineY - boxHeight,
contentWidth - 2, 1);
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 2, typeLineY - boxHeight,
contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3, true);
}
CardRendererUtils.drawZendikarLandBox(g,
x, y, w, h,
contentInset,
borderPaint, boxColor);
drawTypeLine(g, getCardSuperTypeLine(),
totalContentInset + contentInset, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset,
contentWidth / 2 - boxHeight, boxHeight - 4, false);
drawTypeLine(g, getCardSubTypeLine(),
totalContentInset + 4 * contentWidth / 7 + boxHeight, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset,
3 * contentWidth / 7 - boxHeight - contentInset, boxHeight - 4, true);
drawRulesText(g, textboxKeywords, textboxRules,
x, y,
w, h);
w, h, false);
} else if (isUnstableFullArtLand()) {
int x = 0;
int y = 0;
int w = cardWidth;
int h = cardHeight;
// Curve ends at 60 out of 265
drawUSTCurves(g, image, x, y, w, h,
0, 0,
additionalBoxColor, borderPaint);
} else if (!isZenUst) {
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 2, typeLineY + boxHeight + 2,
contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3, false);
}
// Draw the bottom right stuff
@ -698,6 +763,82 @@ public class ModernCardRenderer extends CardRenderer {
g2.draw(innercurve);
}
public void drawUSTCurves(Graphics2D g2, BufferedImage image, int x, int y, int x2, int y2,
int topxdelta, int endydelta,
Color boxColor, Paint paint) {
BufferedImage artToUse = artImage;
int srcW = x2;
int srcH = y2;
if (artToUse != null) {
srcW = artToUse.getWidth();
srcH = artToUse.getHeight();
}
g2.setPaint(paint);
// Dimensions: 534 height, 384 width, 34 offset at top, 41 offset at bottom. Curve at bottom right is from an ellipse: 245 high, 196 wide, with center offset from
// right side by 36 (so top left is at: (width - 159, height - 41 -196) center at: 41+127 = width - 36, height - 168)
int scan_width = 384;
int scan_height = 534;
int scan_ew = 196;
int scan_eh = 254;
int offset_ew = 159;
int offset_eh = 41;
int middle_ew = 52;
int middle_eh = 26;
// Bottom left side arc
int ex = (offset_ew - scan_ew) * x2 / scan_width;
int ey = y2 - (offset_eh + scan_eh) * y2 / scan_height;
int bot_ey = y2 - offset_eh * y2 / scan_height;
int ew = scan_ew * x2 / scan_width;
int eh = scan_eh * y2 / scan_height;
int end_curve_ex = ex + ew / 2;
Arc2D arc = new Arc2D.Double(ex, ey, ew, eh, 180, 90, Arc2D.OPEN);
// Bottom right side arc
ex = x2 - offset_ew * x2 / scan_width;
ey = y2 - (offset_eh + scan_eh) * y2 / scan_height;
bot_ey = y2 - offset_eh * y2 / scan_height;
Arc2D arc2 = new Arc2D.Double(ex, ey, ew, eh, 270, 90, Arc2D.OPEN);
// Middle bump.. 52x26
int mid_ex = x2 / 2 - middle_ew * x2 / (scan_width * 2);
int mid_ey = bot_ey - middle_eh * y2 / (scan_height * 2);
int end_mid_ex = x2 / 2 + middle_ew * x2 / (scan_width * 2);
Arc2D arc3 = new Arc2D.Double(mid_ex, mid_ey, middle_ew * x2 / scan_width, middle_eh * y2 / scan_height, 180, -180, Arc2D.OPEN);
Path2D.Double curve = new Path2D.Double();
curve.moveTo(0, 0);
curve.lineTo(0, bot_ey);
curve.append(arc, true);
curve.lineTo(mid_ex, bot_ey);
curve.append(arc3, true);
curve.lineTo(x2 - ew / 2, bot_ey);
curve.append(arc2, true);
curve.lineTo(x2, 0);
curve.lineTo(0, 0);
g2.setClip(curve);
if (artToUse != null) {
artToUse = artImage.getSubimage(0, 0, srcW, srcH);
g2.drawImage(artToUse, 0, 0, x2, y2, null);
}
g2.setClip(null);
g2.setStroke(new BasicStroke(3));
g2.draw(arc);
g2.draw(new Rectangle(end_curve_ex, bot_ey, mid_ex - end_curve_ex, 0));
g2.draw(arc3);
g2.draw(new Rectangle(end_mid_ex, bot_ey, mid_ex - end_curve_ex, 0));
g2.draw(arc2);
g2.setStroke(new BasicStroke(1));
g2.setColor(boxColor);
}
// Draw the name line
protected void drawNameLine(Graphics2D g, String baseName, String manaCost, int x, int y, int w, int h) {
// Width of the mana symbols
@ -962,7 +1103,7 @@ public class ModernCardRenderer extends CardRenderer {
return layout;
}
protected void drawRulesText(Graphics2D g, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules, int x, int y, int w, int h) {
protected void drawRulesText(Graphics2D g, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules, int x, int y, int w, int h, boolean forceRules) {
// Gather all rules to render
List<TextboxRule> allRules = new ArrayList<>(rules);
@ -973,15 +1114,23 @@ public class ModernCardRenderer extends CardRenderer {
allRules.add(0, keywordsRule);
}
if (isUnstableFullArtLand()) {
return;
}
// Basic mana draw mana symbol in textbox (for basic lands)
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.isLand() || isZendikarFullArtLand()) {
if (!forceRules && (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.isLand() || isZendikarFullArtLand())) {
if (!isZendikarFullArtLand()) {
drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
return;
} else // Big circle in the middle for Zendikar lands
if (allRules.size() == 1) {
// Size of mana symbol = 9/4 * h, 3/4h above line
if (allRules.get(0) instanceof TextboxBasicManaRule) {
drawBasicManaSymbol(g, x + w / 2 - 9 * h / 8 + 1, y - 3 * h / 4, 9 * h / 4, 9 * h / 4, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
} else {
drawBasicManaSymbol(g, x + w / 2 - h - h / 8, y - 3 * h / 4, 9 * h / 4, 9 * h / 4, cardView.getFrameColor().toString());
}
return;
} else {
if (allRules.size() > 1) {
@ -1043,8 +1192,16 @@ public class ModernCardRenderer extends CardRenderer {
private void drawBasicManaSymbol(Graphics2D g, int x, int y, int w, int h, String symbol) {
String symbs = symbol;
if (getSizedManaSymbol(symbol) != null) {
ManaSymbols.draw(g, symbs, x, y, w, Color.black, 2);
}
if (symbol.length() == 2) {
String symbs2 = "" + symbol.charAt(1) + symbol.charAt(0);
if (getSizedManaSymbol(symbs2) != null) {
ManaSymbols.draw(g, symbs2, x, y, w, Color.black, 2);
}
}
}
// Get the first line of the textbox, the keyword string
private static String getKeywordRulesString(ArrayList<TextboxRule> keywords) {
@ -1275,10 +1432,13 @@ public class ModernCardRenderer extends CardRenderer {
// Determine which background image to use from a set of colors
// and the current card.
protected static BufferedImage getBackgroundImage(ObjectColor colors, Collection<CardType> types, SubTypeList subTypes) {
protected static BufferedImage getBackgroundImage(ObjectColor colors, Collection<CardType> types, SubTypeList subTypes, boolean isExped) {
if (subTypes.contains(SubType.VEHICLE)) {
return BG_IMG_VEHICLE;
} else if (types.contains(CardType.LAND)) {
if (isExped) {
return BG_IMG_EXPEDITION;
}
return BG_IMG_LAND;
} else if (types.contains(CardType.ARTIFACT)) {
return BG_IMG_ARTIFACT;
@ -1332,6 +1492,23 @@ public class ModernCardRenderer extends CardRenderer {
}
}
protected Color getAdditionalBoxColor(ObjectColor colors, Collection<CardType> types, boolean isNightCard) {
if (isUnstableFullArtLand()) {
if (colors.isWhite()) {
return BOX_UST_WHITE;
} else if (colors.isBlue()) {
return BOX_UST_BLUE;
} else if (colors.isBlack()) {
return BOX_UST_BLACK;
} else if (colors.isRed()) {
return BOX_UST_RED;
} else if (colors.isGreen()) {
return BOX_UST_GREEN;
}
}
return getBoxColor(colors, types, isNightCard);
}
// Get the border color for a single color
protected static Color getBorderColor(ObjectColor color) {
if (color.isWhite()) {

View file

@ -272,7 +272,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
// Draw the textbox rules
drawRulesText(g, half.keywords, half.rules,
2, typeLineY + boxHeight + 2 - 4,
half.cw - 4, half.ch - typeLineY - boxHeight);
half.cw - 4, half.ch - typeLineY - boxHeight, false);
}
private Graphics2D getUnmodifiedHalfContext(Graphics2D g) {

View file

@ -13,7 +13,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.view.CardView;
import org.apache.log4j.Logger;
import org.apache.log4j.jmx.LoggerDynamicMBean;
/**
*

View file

@ -1,5 +1,7 @@
package org.mage.card.arcane;
import mage.utils.StreamUtils;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
@ -72,8 +74,8 @@ public final class UI {
}
public static ImageIcon getImageIcon (String path) {
InputStream stream = null;
try {
InputStream stream;
stream = UI.class.getResourceAsStream(path);
if (stream == null && new File(path).exists()) {
stream = new FileInputStream(path);
@ -86,6 +88,8 @@ public final class UI {
return new ImageIcon(data);
} catch (IOException ex) {
throw new RuntimeException("Error reading image: " + path);
} finally {
StreamUtils.closeQuietly(stream);
}
}

View file

@ -7,6 +7,7 @@ import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Locale;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
@ -16,8 +17,8 @@ import javax.swing.SwingUtilities;
@SuppressWarnings({"rawtypes", "unchecked"})
public final class Util {
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase().contains("windows");
public static final boolean isMac = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac");
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows");
public static final ThreadPoolExecutor threadPool;
static private int threadCount;
@ -36,10 +37,14 @@ public final class Util {
}
public static void broadcast(byte[] data, int port) throws IOException {
DatagramSocket socket = new DatagramSocket();
DatagramSocket socket = null;
try {
socket = new DatagramSocket();
broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces());
} finally {
socket.close();
}
}
private static void broadcast(DatagramSocket socket, byte[] data, int port, Enumeration<NetworkInterface> ifaces)
throws IOException {

View file

@ -9,7 +9,6 @@ import com.google.common.collect.AbstractIterator;
import java.io.File;
import static java.lang.String.format;
import java.util.Iterator;
import mage.client.constants.Constants;
import org.mage.plugins.card.dl.DownloadJob;
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
@ -76,8 +75,9 @@ public class GathererSymbols implements Iterable<DownloadJob> {
File dst = new File(dir, symbol + ".gif");
/**
* Handle a bug on Gatherer where a few symbols are missing at the large size.
* Fall back to using the medium symbol for those cases.
* Handle a bug on Gatherer where a few symbols are missing
* at the large size. Fall back to using the medium symbol
* for those cases.
*/
int modSizeIndex = sizeIndex;
if (sizeIndex == 2) {

View file

@ -3,6 +3,7 @@ package org.mage.plugins.card.dl.sources;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import mage.client.dialog.PreferencesDialog;
@ -368,7 +369,7 @@ public enum MagicCardsImageSource implements CardImageSource {
String preferedLanguage = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PREF_LANGUAGE, "en");
StringBuilder url = new StringBuilder("http://magiccards.info/scans/").append(preferedLanguage).append('/');
url.append(set.toLowerCase()).append('/').append(collectorId);
url.append(set.toLowerCase(Locale.ENGLISH)).append('/').append(collectorId);
if (card.isTwoFacedCard()) {
url.append(card.isSecondSide() ? "b" : "a");
@ -395,7 +396,7 @@ public enum MagicCardsImageSource implements CardImageSource {
if (card.getType() > 0) {
name = name + ' ' + card.getType();
}
name = name.replaceAll(" ", "-").replace(",", "").toLowerCase();
name = name.replaceAll(" ", "-").replace(",", "").toLowerCase(Locale.ENGLISH);
String set = "not-supported-set";
if (setNameTokenReplacement.containsKey(card.getSet())) {
set = setNameTokenReplacement.get(card.getSet());

View file

@ -31,6 +31,7 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.mage.plugins.card.images.CardDownloadData;
@ -257,7 +258,7 @@ public enum MagidexImageSource implements CardImageSource {
@Override
public String generateURL(CardDownloadData card) throws Exception {
String cardDownloadName = card.getDownloadName().toLowerCase();
String cardDownloadName = card.getDownloadName().toLowerCase(Locale.ENGLISH);
String cardSet = card.getSet();
if (cardDownloadName == null || cardSet == null) {

View file

@ -25,9 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.plugins.card.dl.sources;
import java.util.Locale;
import org.mage.plugins.card.images.CardDownloadData;
/**
@ -38,7 +38,6 @@ import org.mage.plugins.card.images.CardDownloadData;
*
* @author LevelX2
*/
public enum MtgImageSource implements CardImageSource {
instance;
@ -66,7 +65,7 @@ public enum MtgImageSource implements CardImageSource {
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
}
StringBuilder url = new StringBuilder("http://mtgimage.com/set/");
url.append(cardSet.toUpperCase()).append('/');
url.append(cardSet.toUpperCase(Locale.ENGLISH)).append('/');
if (card.isSplitCard()) {
url.append(card.getDownloadName().replaceAll(" // ", ""));

View file

@ -40,6 +40,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.prefs.Preferences;
@ -317,13 +318,13 @@ public enum MythicspoilerComSource implements CardImageSource {
private Map<String, String> getSetLinks(String cardSet) {
Map<String, String> setLinks = new HashMap<>();
try {
String setNames = setsAliases.get(cardSet.toLowerCase());
String setNames = setsAliases.get(cardSet.toLowerCase(Locale.ENGLISH));
Set<String> aliasesStart = new HashSet<>();
if (cardNameAliasesStart.containsKey(cardSet)) {
aliasesStart.addAll(cardNameAliasesStart.get(cardSet));
}
if (setNames == null) {
setNames = cardSet.toLowerCase();
setNames = cardSet.toLowerCase(Locale.ENGLISH);
}
Preferences prefs = MageFrame.getPreferences();
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
@ -423,7 +424,7 @@ public enum MythicspoilerComSource implements CardImageSource {
return null;
}
Map<String, String> setLinks = sets.computeIfAbsent(cardSet, k -> getSetLinks(cardSet));
String searchName = card.getDownloadName().toLowerCase()
String searchName = card.getDownloadName().toLowerCase(Locale.ENGLISH)
.replaceAll(" ", "")
.replaceAll("\\.", "")
.replaceAll("&", "and")

View file

@ -3,6 +3,7 @@ package org.mage.plugins.card.dl.sources;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.mage.plugins.card.images.CardDownloadData;
@ -280,7 +281,7 @@ public enum ScryfallImageSource implements CardImageSource {
if (setNameReplacement.containsKey(setName)) {
setName = setNameReplacement.get(setName);
}
return setName.toLowerCase();
return setName.toLowerCase(Locale.ENGLISH);
}
private static final Map<String, String> setNameReplacement = new HashMap<String, String>() {

View file

@ -9,6 +9,7 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.util.StreamUtils;
import org.mage.plugins.card.dl.DownloadJob;
import static org.mage.card.arcane.ManaSymbols.getSymbolFileNameAsSVG;
@ -106,20 +107,21 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
if (destFile.exists() && (destFile.length() > 0)){
continue;
}
FileOutputStream stream = null;
try {
// base64 transform
String data64 = foundedData.get(searchCode);
Base64.Decoder dec = Base64.getDecoder();
byte[] fileData = dec.decode(data64);
FileOutputStream stream = new FileOutputStream(destFile);
stream = new FileOutputStream(destFile);
stream.write(fileData);
stream.close();
LOGGER.info("New svg symbol downloaded: " + needCode);
} catch (Exception e) {
LOGGER.error("Can't decode svg icon and save to file: " + destFile.getPath() + ", reason: " + e.getMessage());
} finally {
StreamUtils.closeQuietly(stream);
}
}
}

View file

@ -38,6 +38,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@ -97,7 +98,7 @@ public enum TokensMtgImageSource implements CardImageSource {
private String getEmblemName(String originalName) {
for (SubType subType : SubType.getPlaneswalkerTypes(true)) {
if (originalName.toLowerCase().contains(subType.toString().toLowerCase())) {
if (originalName.toLowerCase(Locale.ENGLISH).contains(subType.toString().toLowerCase(Locale.ENGLISH))) {
return subType.getDescription() + " Emblem";
}
}
@ -111,13 +112,13 @@ public enum TokensMtgImageSource implements CardImageSource {
int type = card.getType();
// handle emblems
if (name.toLowerCase().contains("emblem")) {
if (name.toLowerCase(Locale.ENGLISH).contains("emblem")) {
name = getEmblemName(name);
}
// we should replace some set names
if (SET_NAMES_REPLACEMENT.containsKey(set.toLowerCase())) {
set = SET_NAMES_REPLACEMENT.get(set.toLowerCase());
if (SET_NAMES_REPLACEMENT.containsKey(set.toLowerCase(Locale.ENGLISH))) {
set = SET_NAMES_REPLACEMENT.get(set.toLowerCase(Locale.ENGLISH));
}
// Image URL contains token number
@ -187,7 +188,7 @@ public enum TokensMtgImageSource implements CardImageSource {
@Override
public boolean isImageProvided(String setCode, String cardName) {
String searchName = cardName;
if (cardName.toLowerCase().contains("emblem")) {
if (cardName.toLowerCase(Locale.ENGLISH).contains("emblem")) {
searchName = getEmblemName(cardName);
}
try {

View file

@ -39,6 +39,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@ -460,12 +461,16 @@ public enum WizardCardsImageSource implements CardImageSource {
setsAliases.put("ZEN", "Zendikar");
languageAliases = new HashMap<>();
languageAliases.put("en", "English");
languageAliases.put("es", "Spanish");
languageAliases.put("jp", "Japanese");
languageAliases.put("it", "Italian");
languageAliases.put("fr", "French");
languageAliases.put("cn", "Chinese Simplified");
languageAliases.put("de", "German");
languageAliases.put("ko", "Korean");
languageAliases.put("pt", "Portuguese (Brazil)");
languageAliases.put("ru", "Russian");
}
@Override
@ -493,7 +498,7 @@ public enum WizardCardsImageSource implements CardImageSource {
if (setLinks == null || setLinks.isEmpty()) {
return null;
}
String searchKey = card.getDownloadName().toLowerCase().replace(" ", "").replace("&", "//");
String searchKey = card.getDownloadName().toLowerCase(Locale.ENGLISH).replace(" ", "").replace("&", "//");
String link = setLinks.get(searchKey);
if (link == null) {
int length = collectorId.length();
@ -576,7 +581,7 @@ public enum WizardCardsImageSource implements CardImageSource {
}
}
Integer preferedMultiverseId = getLocalizedMultiverseId(preferedLanguage, multiverseId);
setLinks.put(cardName.toLowerCase() + numberChar, generateLink(preferedMultiverseId));
setLinks.put(cardName.toLowerCase(Locale.ENGLISH) + numberChar, generateLink(preferedMultiverseId));
}
}
}
@ -652,11 +657,11 @@ public enum WizardCardsImageSource implements CardImageSource {
}
}
Integer landMultiverseId = Integer.parseInt(variation.attr("href").replaceAll("[^\\d]", ""));
setLinks.put((cardName).toLowerCase() + colNumb, generateLink(landMultiverseId));
setLinks.put((cardName).toLowerCase(Locale.ENGLISH) + colNumb, generateLink(landMultiverseId));
iteration++;
}
} else {
setLinks.put(cardName.toLowerCase(), generateLink(multiverseId));
setLinks.put(cardName.toLowerCase(Locale.ENGLISH), generateLink(multiverseId));
}
}
@ -697,8 +702,10 @@ public enum WizardCardsImageSource implements CardImageSource {
private String normalizeName(String name) {
//Split card
if (name.contains("//")) {
if (name.indexOf('(') > 0) {
name = name.substring(0, name.indexOf('(') - 1);
}
}
//Special timeshifted name
if (name.startsWith("XX")) {
name = name.substring(name.indexOf('(') + 1, name.length() - 1);
@ -756,7 +763,7 @@ public enum WizardCardsImageSource implements CardImageSource {
// setLinks.putAll(getLandVariations(multiverseId, cardName));
// } else {
// Integer preferedMultiverseId = getLocalizedMultiverseId(preferedLanguage, multiverseId);
// setLinks.put(cardName.toLowerCase(), generateLink(preferedMultiverseId));
// setLinks.put(cardName.toLowerCase(Locale.ENGLISH), generateLink(preferedMultiverseId));
// }
// } catch (IOException | NumberFormatException ex) {
// logger.error("Exception when parsing the wizards page: " + ex.getMessage());

View file

@ -1,8 +1,8 @@
package org.mage.plugins.card.images;
import mage.util.CardUtil;
import java.util.Locale;
import java.util.Objects;
import mage.util.CardUtil;
/**
*
@ -190,7 +190,7 @@ public class CardDownloadData {
private String lastDitchTokenDescriptor() {
String tmpName = this.name.replaceAll("[^a-zA-Z0-9]", "");
String descriptor = tmpName + "....";
descriptor = descriptor.toUpperCase();
descriptor = descriptor.toUpperCase(Locale.ENGLISH);
return descriptor;
}

View file

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -23,6 +24,7 @@ import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.sets.ConstructedFormats;
import mage.remote.Connection;
import mage.util.StreamUtils;
import net.java.truevfs.access.TFile;
import net.java.truevfs.access.TFileOutputStream;
import net.java.truevfs.access.TVFS;
@ -504,23 +506,23 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
tokenClassName = params[6].trim();
}
if (params[1].toLowerCase().equals("generate") && params[2].startsWith("TOK:")) {
if (params[1].toLowerCase(Locale.ENGLISH).equals("generate") && params[2].startsWith("TOK:")) {
String set = params[2].substring(4);
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true);
card.setTokenClassName(tokenClassName);
list.add(card);
// logger.debug("Token: " + set + "/" + card.getName() + " type: " + type);
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM:")) {
} else if (params[1].toLowerCase(Locale.ENGLISH).equals("generate") && params[2].startsWith("EMBLEM:")) {
String set = params[2].substring(7);
CardDownloadData card = new CardDownloadData("Emblem " + params[3], set, "0", false, type, "", "", true, fileName);
card.setTokenClassName(tokenClassName);
list.add(card);
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM-:")) {
} else if (params[1].toLowerCase(Locale.ENGLISH).equals("generate") && params[2].startsWith("EMBLEM-:")) {
String set = params[2].substring(8);
CardDownloadData card = new CardDownloadData(params[3] + " Emblem", set, "0", false, type, "", "", true, fileName);
card.setTokenClassName(tokenClassName);
list.add(card);
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM!:")) {
} else if (params[1].toLowerCase(Locale.ENGLISH).equals("generate") && params[2].startsWith("EMBLEM!:")) {
String set = params[2].substring(8);
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true, fileName);
card.setTokenClassName(tokenClassName);
@ -744,34 +746,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
}
}
/*
if(!destFile.getParentFile().exists()){
destFile.getParentFile().mkdirs();
}
*/
/*
// WTF start?! TODO: wtf
File existingFile = new File(imagePath.replaceFirst("\\w{3}.zip", ""));
if (existingFile.exists()) {
try {
new TFile(existingFile).cp_rp(outputFile);
} catch (IOException e) {
logger.error("Error while copying file " + card.getName(), e);
}
synchronized (sync) {
update(cardIndex + 1, count);
}
existingFile.delete();
File parent = existingFile.getParentFile();
if (parent != null && parent.isDirectory() && parent.list().length == 0) {
parent.delete();
}
return;
}
// WTF end?!
*/
// START to download
cardImageSource.doPause(url.getPath());
URLConnection httpConn = url.openConnection(p);
httpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
@ -781,18 +755,18 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
if (responseCode == 200) {
// download OK
// save data to temp
BufferedOutputStream out;
try (BufferedInputStream in = new BufferedInputStream(httpConn.getInputStream())) {
out = new BufferedOutputStream(new TFileOutputStream(fileTempImage));
OutputStream out = null;
OutputStream tfileout = null;
InputStream in = null;
try {
in = new BufferedInputStream(httpConn.getInputStream());
tfileout = new TFileOutputStream(fileTempImage);
out = new BufferedOutputStream(tfileout);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) != -1) {
// user cancelled
if (cancel) {
in.close();
out.flush();
out.close();
// stop download, save current state and exit
TFile archive = destFile.getTopLevelArchive();
///* not need to unmout/close - it's auto action
@ -803,8 +777,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
} catch (Exception e) {
logger.error("Can't close archive file: " + e.getMessage(), e);
}
}//*/
}
try {
TFile.rm(fileTempImage);
} catch (Exception e) {
@ -815,9 +788,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
out.write(buf, 0, len);
}
}
// TODO: remove to finnaly section?
out.flush();
out.close();
finally {
StreamUtils.closeQuietly(in);
StreamUtils.closeQuietly(out);
StreamUtils.closeQuietly(tfileout);
}
// TODO: add two faces card correction? (WTF)
// SAVE final data
@ -846,81 +822,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
}
}
/*
// Logger.getLogger(this.getClass()).info(url.toString());
boolean useTempFile = false;
int responseCode = 0;
URLConnection httpConn = null;
if (temporaryFile != null && temporaryFile.length() > 100) {
useTempFile = true;
} else {
cardImageSource.doPause(url.getPath());
httpConn = url.openConnection(p);
httpConn.connect();
responseCode = ((HttpURLConnection) httpConn).getResponseCode();
}
if (responseCode == 200 || useTempFile) {
if (!useTempFile) {
BufferedOutputStream out;
try (BufferedInputStream in = new BufferedInputStream(httpConn.getInputStream())) {
//try (BufferedInputStream in = new BufferedInputStream(url.openConnection(p).getInputStream())) {
out = new BufferedOutputStream(new TFileOutputStream(temporaryFile));
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) != -1) {
// user cancelled
if (cancel) {
in.close();
out.flush();
out.close();
temporaryFile.delete();
return;
}
out.write(buf, 0, len);
}
}
out.flush();
out.close();
}
// TODO: WTF?! start
if (card != null && card.isTwoFacedCard()) {
BufferedImage image = ImageIO.read(temporaryFile);
if (image.getHeight() == 470) {
BufferedImage renderedImage = new BufferedImage(265, 370, BufferedImage.TYPE_INT_RGB);
renderedImage.getGraphics();
Graphics2D graphics2D = renderedImage.createGraphics();
if (card.isTwoFacedCard() && card.isSecondSide()) {
graphics2D.drawImage(image, 0, 0, 265, 370, 313, 62, 578, 432, null);
} else {
graphics2D.drawImage(image, 0, 0, 265, 370, 41, 62, 306, 432, null);
}
graphics2D.dispose();
writeImageToFile(renderedImage, outputFile);
} else {
outputFile.getParentFile().mkdirs();
new TFile(temporaryFile).cp_rp(outputFile);
}
//temporaryFile.delete();
} else {
outputFile.getParentFile().mkdirs();
new TFile(temporaryFile).cp_rp(outputFile);
}
// WTF?! end
} else {
if (card != null && !useSpecifiedPaths) {
logger.warn("Image download for " + card.getName()
+ (!card.getDownloadName().equals(card.getName()) ? " downloadname: " + card.getDownloadName() : "")
+ '(' + card.getSet() + ") failed - responseCode: " + responseCode + " url: " + url.toString());
}
if (logger.isDebugEnabled()) { // Shows the returned html from the request to the web server
logger.debug("Returned HTML ERROR:\n" + convertStreamToString(((HttpURLConnection) httpConn).getErrorStream()));
}
}
*/
} catch (AccessDeniedException e) {
logger.error("Can't access to files: " + card.getName() + "(" + card.getSet() + "). Try rebooting your system to remove the file lock.");
} catch (Exception e) {
@ -932,26 +833,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
update(cardIndex + 1, count);
}
}
// private void writeImageToFile(BufferedImage image, TFile file) throws IOException {
// Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
//
// ImageWriter writer = (ImageWriter) iter.next();
// ImageWriteParam iwp = writer.getDefaultWriteParam();
// iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
// iwp.setCompressionQuality(0.96f);
//
// File tempFile = new File(getImagesDir() + File.separator + image.hashCode() + file.getName());
// FileImageOutputStream output = new FileImageOutputStream(tempFile);
// writer.setOutput(output);
// IIOImage image2 = new IIOImage(image, null, null);
// writer.write(null, image2, iwp);
// writer.dispose();
// output.close();
//
// new TFile(tempFile).cp_rp(file);
// tempFile.delete();
// }
}
private void update(int card, int count) {

View file

@ -12,14 +12,10 @@ public class SettingsManager {
private static SettingsManager settingsManager = null;
public static SettingsManager getIntance() {
if (settingsManager == null) {
synchronized (SettingsManager.class) {
public static synchronized SettingsManager getIntance() {
if (settingsManager == null) {
settingsManager = new SettingsManager();
}
}
}
return settingsManager;
}

View file

@ -4,6 +4,7 @@ import java.io.File;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.HashMap;
import java.util.Locale;
import java.util.prefs.Preferences;
import mage.client.MageFrame;
import mage.client.constants.Constants;
@ -116,7 +117,7 @@ public final class CardImageUtils {
}
public static String updateSet(String cardSet, boolean forUrl) {
String set = cardSet.toLowerCase();
String set = cardSet.toLowerCase(Locale.ENGLISH);
if (set.equals("con")) {
set = "cfx";
}
@ -172,7 +173,7 @@ public final class CardImageUtils {
throw new IllegalArgumentException("Card " + card.getName() + " have empty set.");
}
String set = updateSet(card.getSet(), false).toUpperCase(); // TODO: research auto-replace... old code?
String set = updateSet(card.getSet(), false).toUpperCase(Locale.ENGLISH); // TODO: research auto-replace... old code?
if (card.isToken()) {
return buildImagePathToSetAsToken(set);
@ -236,7 +237,7 @@ public final class CardImageUtils {
if (dirFile.exists() && !imageFile.exists()) {
// search like names
for (String fileName : dirFile.list()) {
if (fileName.toLowerCase().equals(finalFileName.toLowerCase())) {
if (fileName.toLowerCase(Locale.ENGLISH).equals(finalFileName.toLowerCase(Locale.ENGLISH))) {
finalFileName = fileName;
break;
}

View file

@ -11,6 +11,7 @@ import java.awt.image.FilteredImageSource;
import java.awt.image.WritableRaster;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.imageio.ImageIO;
import mage.client.util.gui.BufferedImageBuilder;
@ -20,7 +21,6 @@ import org.mage.plugins.card.utils.Transparency;
public enum ImageManagerImpl implements ImageManager {
instance;
ImageManagerImpl() {
init();
}
@ -31,7 +31,7 @@ public enum ImageManagerImpl implements ImageManager {
"Main2", "Cleanup", "Next_Turn"};
phasesImages = new HashMap<>();
for (String name : phases) {
Image image = getImageFromResource("/phases/phase_" + name.toLowerCase() + ".png", new Rectangle(36, 36));
Image image = getImageFromResource("/phases/phase_" + name.toLowerCase(Locale.ENGLISH) + ".png", new Rectangle(36, 36));
phasesImages.put(name, image);
}
}

View file

@ -3,6 +3,7 @@ package org.mage.plugins.theme;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Locale;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.*;
@ -49,7 +50,7 @@ public class ThemePluginImpl implements ThemePlugin {
return false;
}
for (File f : filelist) {
String filename = f.getName().toLowerCase();
String filename = f.getName().toLowerCase(Locale.ENGLISH);
if (filename != null && (filename.endsWith(".png") || filename.endsWith(".jpg")
|| filename.endsWith(".bmp"))) {
flist.add(filename);
@ -149,9 +150,7 @@ public class ThemePluginImpl implements ThemePlugin {
return bgPanel;
}
private ImagePanel createImagePanelInstance() {
if (background == null) {
synchronized (ThemePluginImpl.class) {
private synchronized ImagePanel createImagePanelInstance() {
if (background == null) {
String filename = "/background.png";
try {
@ -189,8 +188,6 @@ public class ThemePluginImpl implements ThemePlugin {
return null;
}
}
}
}
return new ImagePanel(background, ImagePanelStyle.SCALED);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-common</artifactId>

View file

@ -28,6 +28,7 @@
package mage.remote;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
@ -89,6 +90,7 @@ public class SessionImpl implements Session {
private static boolean debugMode = false;
private boolean canceled = false;
private boolean jsonLogActive = false;
static {
debugMode = System.getProperty("debug.mage") != null;
@ -892,12 +894,20 @@ public class SessionImpl implements Session {
@Override
public void appendJsonLog(ActionData actionData) {
if (isJsonLogActive()) {
String dir = "gamelogsJson";
File saveDir = new File(dir);
//Existence check
if (!saveDir.exists()) {
saveDir.mkdirs();
}
actionData.sessionId = getSessionId();
String logFileName = "game-" + actionData.gameId + ".json";
String logFileName = dir + File.separator + "game-" + actionData.gameId + ".json";
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(logFileName, true)))) {
out.println(actionData.toJson());
} catch (IOException e) {
System.err.println(e);
logger.error("Cant write JSON game log file - " + logFileName, e);
}
}
}
@ -1308,7 +1318,7 @@ public class SessionImpl implements Session {
if (isConnected()) {
ActionData actionData = new ActionData("SEND_PLAYER_ACTION", gameId, getSessionId());
actionData.value = data;
actionData.value = passPriorityAction + (data != null ? " " + data.toString() : "");
appendJsonLog(actionData);
server.sendPlayerAction(passPriorityAction, gameId, sessionId, data);
@ -1634,6 +1644,16 @@ public class SessionImpl implements Session {
}
}
@Override
public boolean isJsonLogActive() {
return jsonLogActive;
}
@Override
public void setJsonLogActive(boolean jsonLogActive) {
this.jsonLogActive = jsonLogActive;
}
}
class MageAuthenticator extends Authenticator {

View file

@ -37,4 +37,8 @@ public interface ClientData {
String getUserName();
boolean updatePreferencesForServer(UserData userData);
void setJsonLogActive(boolean active);
boolean isJsonLogActive();
}

View file

@ -40,8 +40,8 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
*/
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 27;
public final static String MAGE_VERSION_MINOR_PATCH = "V4";
public final static int MAGE_VERSION_PATCH = 28;
public final static String MAGE_VERSION_MINOR_PATCH = "V1";
public final static String MAGE_VERSION_INFO = "";
private final int major;

View file

@ -0,0 +1,30 @@
package mage.utils;
import java.io.Closeable;
public final class StreamUtils {
/***
* Quietly closes the closable, ignoring nulls and exceptions
* @param c - the closable to be closed
*/
public static void closeQuietly(Closeable c) {
if (c != null) {
try {
c.close();
}
catch (Exception e) {
}
}
}
public static void closeQuietly(AutoCloseable ac) {
if (ac != null) {
try {
ac.close();
}
catch (Exception e) {
}
}
}
}

View file

@ -988,7 +988,7 @@ public class CardView extends SimpleCardView {
public String getColorText() {
String color = getColor().getDescription();
return color.substring(0, 1).toUpperCase() + color.substring(1);
return color.substring(0, 1).toUpperCase(Locale.ENGLISH) + color.substring(1);
}
public String getTypeText() {

View file

@ -27,7 +27,6 @@
*/
package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
@ -79,11 +78,11 @@ public class GameEndView implements Serializable {
}
if (you != null) {
if (you.hasWon()) {
gameInfo = new StringBuilder("You won the game on turn ").append(game.getTurnNum()).append('.').toString();
gameInfo = "You won the game on turn " + game.getTurnNum() + ".";
} else if (winner > 0) {
gameInfo = new StringBuilder("You lost the game on turn ").append(game.getTurnNum()).append('.').toString();
gameInfo = "You lost the game on turn " + game.getTurnNum() + ".";
} else {
gameInfo = new StringBuilder("Game is a draw on Turn ").append(game.getTurnNum()).append('.').toString();
gameInfo = "Game is a draw on Turn " + game.getTurnNum() + ".";
}
}
matchView = new MatchView(table);

View file

@ -27,18 +27,14 @@
*/
package mage.view;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.Serializable;
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.costs.Cost;
import mage.cards.Card;
@ -60,8 +56,6 @@ import mage.game.stack.StackObject;
import mage.players.Player;
import mage.watchers.common.CastSpellLastTurnWatcher;
import org.apache.log4j.Logger;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
*
@ -105,7 +99,12 @@ public class GameView implements Serializable {
}
}
for (StackObject stackObject : state.getStack()) {
if (stackObject instanceof StackAbility) {
if (stackObject instanceof Spell) {
// Spell
CardView spellView = new CardView((Spell) stackObject, game, stackObject.getControllerId().equals(createdForPlayerId));
spellView.paid = ((Spell) stackObject).getSpellAbility().getManaCostsToPay().isPaid();
stack.put(stackObject.getId(), spellView);
} else if (stackObject instanceof StackAbility) {
// Stack Ability
MageObject object = game.getObject(stackObject.getSourceId());
Card card = game.getCard(stackObject.getSourceId());
@ -161,9 +160,7 @@ public class GameView implements Serializable {
LOGGER.debug("Stack Object for stack ability not found: " + stackObject.getStackAbility().getRule());
}
} else {
// Spell
stack.put(stackObject.getId(), new CardView((Spell) stackObject, game, stackObject.getControllerId().equals(createdForPlayerId)));
checkPaid(stackObject.getId(), (Spell) stackObject);
LOGGER.fatal("Unknown type of StackObject: " + stackObject.getName() + ' ' + stackObject.toString() + ' ' + stackObject.getClass().toString());
}
//stackOrder.add(stackObject.getId());
}
@ -223,21 +220,6 @@ public class GameView implements Serializable {
cardView.paid = true;
}
private void checkPaid(UUID uuid, Spell spell) {
for (Cost cost : spell.getSpellAbility().getManaCostsToPay()) {
if (!cost.isPaid()) {
return;
}
}
CardView cardView = stack.get(uuid);
cardView.paid = true;
}
private void setPaid(UUID uuid) {
CardView cardView = stack.get(uuid);
cardView.paid = true;
}
private void updateLatestCardView(Game game, Card card, UUID stackId) {
if (!card.isTransformable()) {
return;

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-counter-plugin</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-plugins</artifactId>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<groupId>org.mage</groupId>

View file

@ -31,14 +31,8 @@
*
* Created on 20-Jan-2010, 9:37:07 PM
*/
package mage.server.console;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@ -46,8 +40,13 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.swing.*;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import org.apache.log4j.Logger;
/**
*
@ -60,7 +59,9 @@ public class ConnectDialog extends JDialog {
private Connection connection;
private ConnectTask task;
/** Creates new form ConnectDialog */
/**
* Creates new form ConnectDialog
*/
public ConnectDialog() {
initComponents();
cbProxyType.setModel(new DefaultComboBoxModel(Connection.ProxyType.values()));
@ -73,7 +74,7 @@ public class ConnectDialog extends JDialog {
this.chkAutoConnect.setSelected(Boolean.parseBoolean(ConsoleFrame.getPreferences().get("autoConnect", "false")));
this.txtProxyServer.setText(ConsoleFrame.getPreferences().get("proxyAddress", "localhost"));
this.txtProxyPort.setText(ConsoleFrame.getPreferences().get("proxyPort", Integer.toString(17171)));
this.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(ConsoleFrame.getPreferences().get("proxyType", "NONE").toUpperCase()));
this.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(ConsoleFrame.getPreferences().get("proxyType", "NONE").toUpperCase(Locale.ENGLISH)));
this.txtProxyUserName.setText(ConsoleFrame.getPreferences().get("proxyUsername", ""));
this.txtPasswordField.setText(ConsoleFrame.getPreferences().get("proxyPassword", ""));
this.showProxySettings();
@ -87,13 +88,11 @@ public class ConnectDialog extends JDialog {
this.pnlProxy.setVisible(true);
this.pnlProxyAuth.setVisible(false);
this.pnlProxySettings.setVisible(true);
}
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.HTTP) {
} else if (cbProxyType.getSelectedItem() == Connection.ProxyType.HTTP) {
this.pnlProxy.setVisible(true);
this.pnlProxyAuth.setVisible(true);
this.pnlProxySettings.setVisible(true);
}
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.NONE) {
} else if (cbProxyType.getSelectedItem() == Connection.ProxyType.NONE) {
this.pnlProxy.setVisible(false);
this.pnlProxyAuth.setVisible(false);
this.pnlProxySettings.setVisible(false);
@ -115,10 +114,10 @@ public class ConnectDialog extends JDialog {
Arrays.fill(input, '0');
}
/** 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.
/**
* 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
@ -424,15 +423,15 @@ public class ConnectDialog extends JDialog {
if (result) {
lblStatus.setText("");
connected();
}
else {
} else {
lblStatus.setText("Could not connect");
}
} catch (InterruptedException ex) {
logger.fatal("Update Players Task error", ex);
} catch (ExecutionException ex) {
logger.fatal("Update Players Task error", ex);
} catch (CancellationException ex) {}
} catch (CancellationException ex) {
}
}
}
@ -441,7 +440,6 @@ public class ConnectDialog extends JDialog {
this.setVisible(false);
}
private void keyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_keyTyped
char c = evt.getKeyChar();
if (!Character.isDigit(c)) {
@ -495,7 +493,10 @@ public class ConnectDialog extends JDialog {
logger.error(ex, ex);
} finally {
if (in != null) {
try { in.close(); } catch (Exception e) {}
try {
in.close();
} catch (Exception e) {
}
}
}
}//GEN-LAST:event_jButton1ActionPerformed
@ -508,7 +509,6 @@ public class ConnectDialog extends JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_txtPasswordFieldActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnConnect;

View file

@ -308,7 +308,6 @@
</Component>
<Component class="javax.swing.JTextField" name="jUserName">
<Properties>
<Property name="text" type="java.lang.String" value=""/>
<Property name="name" type="java.lang.String" value="Username" noResource="true"/>
</Properties>
</Component>

View file

@ -107,6 +107,10 @@ public class ConsolePanel extends javax.swing.JPanel {
}
}
public JTextField getjUserName() {
return jUserName;
}
/**
* 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
@ -280,7 +284,6 @@ public class ConsolePanel extends javax.swing.JPanel {
}
});
jUserName.setText("");
jUserName.setName("Username"); // NOI18N
jLabel1.setText("Username:");
@ -364,8 +367,13 @@ public class ConsolePanel extends javax.swing.JPanel {
}//GEN-LAST:event_btnMuteUserActionPerformed
private void btnDeActivateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeActivateActionPerformed
String userName;
if (!getjUserName().getText().isEmpty()) {
userName = getjUserName().getText();
} else {
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
String userName = (String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME);
userName = (String) tableUserModel.getValueAt(row, TableUserModel.POS_USER_NAME);
}
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to active?", "WARNING",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
@ -416,7 +424,7 @@ public class ConsolePanel extends javax.swing.JPanel {
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSplitPane jSplitPane1;
public javax.swing.JTextField jUserName;
private javax.swing.JTextField jUserName;
private javax.swing.JLabel lblMinutes;
private javax.swing.JSpinner spinnerMuteDurationMinutes;
private javax.swing.JTable tblTables;
@ -597,10 +605,10 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
List<UserView> users = session.getUsers();
if (!panel.jUserName.getText().equals("")) {
if (!panel.getjUserName().getText().equals("")) {
List<UserView> users2 = new ArrayList<>();
for (UserView user : users) {
if (user.getUserName().toUpperCase().matches(".*" + panel.jUserName.getText().toUpperCase() + ".*")) {
if (user.getUserName().toUpperCase(Locale.ENGLISH).matches(".*" + panel.getjUserName().getText().toUpperCase(Locale.ENGLISH) + ".*")) {
users2.add(user);
}
}
@ -651,6 +659,10 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
panel.update(view.get(0));
}
public ConsolePanel getPanel() {
return panel;
}
@Override
protected void done() {
try {
@ -682,10 +694,10 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
Collection<TableView> tableViews = session.getTables(roomId);
if (!panel.jUserName.getText().equals("")) {
if (!panel.getjUserName().getText().equals("")) {
Collection<TableView> tableViews2 = new ArrayList<>();
for (TableView table : tableViews) {
if (table.getControllerName().toUpperCase().matches(".*" + panel.jUserName.getText().toUpperCase() + ".*")) {
if (table.getControllerName().toUpperCase(Locale.ENGLISH).matches(".*" + panel.getjUserName().getText().toUpperCase(Locale.ENGLISH) + ".*")) {
tableViews2.add(table);
}
}

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-deck-constructed</artifactId>

View file

@ -275,7 +275,7 @@ public class Commander extends Constructed {
boolean whenYouCast = false;
for (String str : card.getRules()) {
String s = str.toLowerCase();
String s = str.toLowerCase(Locale.ENGLISH);
annihilator |= s.contains("annihilator");
anyNumberOfTarget |= s.contains("any number");
buyback |= s.contains("buyback");
@ -521,16 +521,16 @@ public class Commander extends Constructed {
}
if (card.isPlaneswalker()) {
if (card.getName().toLowerCase().equals("jace, the mind sculptor")) {
if (card.getName().toLowerCase(Locale.ENGLISH).equals("jace, the mind sculptor")) {
thisMaxPower = Math.max(thisMaxPower, 6);
}
if (card.getName().toLowerCase().equals("ugin, the spirit dragon")) {
if (card.getName().toLowerCase(Locale.ENGLISH).equals("ugin, the spirit dragon")) {
thisMaxPower = Math.max(thisMaxPower, 5);
}
thisMaxPower = Math.max(thisMaxPower, 4);
}
String cn = card.getName().toLowerCase();
String cn = card.getName().toLowerCase(Locale.ENGLISH);
if (cn.equals("ancient tomb")
|| cn.equals("anafenza, the foremost")
|| cn.equals("arcum dagsson")
@ -678,7 +678,7 @@ public class Commander extends Constructed {
ObjectColor color = null;
for (Card commander : deck.getSideboard()) {
int thisMaxPower = 0;
String cn = commander.getName().toLowerCase();
String cn = commander.getName().toLowerCase(Locale.ENGLISH);
if (color == null) {
color = commander.getColor(null);
} else {

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-deck-limited</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-canadianhighlanderduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-commanderduel</artifactId>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-commanderfreeforall</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-freeforall</artifactId>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-freeformcommanderfreeforall</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-momirduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-momirfreeforall</artifactId>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-pennydreadfulcommanderfreeforall</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-tinyleadersduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-game-twoplayerduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-player-ai-draftbot</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.27</version>
<version>1.4.28</version>
</parent>
<artifactId>mage-player-ai-ma</artifactId>

Some files were not shown because too many files have changed in this diff Show more