mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Merge branch 'master' into add-minimum-rating-option
This commit is contained in:
commit
e7d129a074
568 changed files with 21414 additions and 6453 deletions
|
|
@ -1,5 +1,15 @@
|
|||
package mage.client.cards;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.swing.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.MageCard;
|
||||
import mage.cards.decks.DeckCardInfo;
|
||||
|
|
@ -20,17 +30,6 @@ import mage.view.CardsView;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardRenderer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by StravantUser on 2016-09-20.
|
||||
*/
|
||||
|
|
@ -1408,13 +1407,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
while (regexMatcher.find()) {
|
||||
String val = regexMatcher.group(1);
|
||||
int colorless_val = Integer.parseInt(val);
|
||||
|
||||
|
||||
int total_c_pip = 0;
|
||||
if (pips.get("#c}") != null) {
|
||||
if (pips.get("#c}") != null) {
|
||||
total_c_pip = pips.get("#c}");
|
||||
}
|
||||
pips.put("#c}", colorless_val + total_c_pip);
|
||||
|
||||
|
||||
int cmc_pip_value = 0;
|
||||
if (pips_at_cmcs.get(cmc + "##c}") != null) {
|
||||
cmc_pip_value = pips_at_cmcs.get(cmc + "##c}");
|
||||
|
|
@ -2032,6 +2031,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
private int getCardWidth() {
|
||||
if (GUISizeHelper.editorCardDimension == null) {
|
||||
return 200;
|
||||
}
|
||||
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.client.deck.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -7,6 +6,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
|
|
@ -123,9 +123,9 @@ public final class DeckGenerator {
|
|||
* non-creatures, lands (including non-basic). Fixes the deck, adjusting for
|
||||
* size and color of the cards retrieved.
|
||||
*
|
||||
* @param deckSize how big the deck is to generate.
|
||||
* @param deckSize how big the deck is to generate.
|
||||
* @param allowedColors which colors are allowed in the deck.
|
||||
* @param setsToUse which sets to use to retrieve cards for this deck.
|
||||
* @param setsToUse which sets to use to retrieve cards for this deck.
|
||||
* @return the final deck to use.
|
||||
*/
|
||||
private static Deck generateDeck(int deckSize, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) {
|
||||
|
|
@ -180,9 +180,9 @@ public final class DeckGenerator {
|
|||
* non-creatures are retrieved separately to ensure the deck contains a
|
||||
* reasonable mix of both.
|
||||
*
|
||||
* @param criteria the criteria to search for in the database.
|
||||
* @param criteria the criteria to search for in the database.
|
||||
* @param spellCount the number of spells that match the criteria needed in
|
||||
* the deck.
|
||||
* the deck.
|
||||
*/
|
||||
private static void generateSpells(CardCriteria criteria, int spellCount) {
|
||||
List<CardInfo> cardPool = CardRepository.instance.findCards(criteria);
|
||||
|
|
@ -233,7 +233,7 @@ public final class DeckGenerator {
|
|||
* in this deck. Usually the lands will be well balanced relative to the
|
||||
* color of cards.
|
||||
*
|
||||
* @param criteria the criteria of the lands to search for in the database.
|
||||
* @param criteria the criteria of the lands to search for in the database.
|
||||
* @param landsCount the amount of lands required for this deck.
|
||||
* @param basicLands information about the basic lands from the sets used.
|
||||
*/
|
||||
|
|
@ -310,10 +310,10 @@ public final class DeckGenerator {
|
|||
* filled.
|
||||
*
|
||||
* @param landsNeeded how many remaining lands are needed.
|
||||
* @param percentage the percentage needed for each color in the final deck.
|
||||
* @param count how many of each color can be produced by non-basic lands.
|
||||
* @param basicLands list of information about basic lands from the
|
||||
* database.
|
||||
* @param percentage the percentage needed for each color in the final deck.
|
||||
* @param count how many of each color can be produced by non-basic lands.
|
||||
* @param basicLands list of information about basic lands from the
|
||||
* database.
|
||||
*/
|
||||
private static void addBasicLands(int landsNeeded, Map<String, Double> percentage, Map<String, Integer> count, Map<String, List<CardInfo>> basicLands) {
|
||||
|
||||
|
|
@ -360,15 +360,14 @@ public final class DeckGenerator {
|
|||
/**
|
||||
* Return a random basic land of the chosen color.
|
||||
*
|
||||
* @param color the color the basic land should produce.
|
||||
* @param color the color the basic land should produce.
|
||||
* @param basicLands list of information about basic lands from the
|
||||
* database.
|
||||
* database.
|
||||
* @return a single basic land that produces the color needed.
|
||||
*/
|
||||
private static Card getBasicLand(ColoredManaSymbol color, Map<String, List<CardInfo>> basicLands) {
|
||||
String landName = DeckGeneratorPool.getBasicLandName(color.toString());
|
||||
List<CardInfo> basicLandsInfo = basicLands.get(landName);
|
||||
return basicLandsInfo.get(RandomUtil.nextInt(basicLandsInfo.size() - 1)).getMockCard().copy();
|
||||
return basicLandsInfo.get(RandomUtil.nextInt(basicLandsInfo.size())).getMockCard().copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
/*
|
||||
/*
|
||||
* CardSelector.java
|
||||
*
|
||||
* Created on Feb 18, 2010, 2:49:03 PM
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
/*
|
||||
/*
|
||||
* DeckEditorPane.java
|
||||
*
|
||||
* Created on Dec 17, 2009, 9:21:42 AM
|
||||
|
|
@ -98,14 +96,13 @@ public class DeckEditorPane extends MagePane {
|
|||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
|
||||
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DeckEditorPanel getPanel() {
|
||||
|
|
|
|||
|
|
@ -192,6 +192,15 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnGenDeck">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Generate"/>
|
||||
<Property name="name" type="java.lang.String" value="btnGenDeck" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGenDeckActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSubmit">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Submit"/>
|
||||
|
|
@ -210,7 +219,7 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitTimerActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="JComponent" name="cardInfoPane">
|
||||
<Component class="org.mage.plugins.card.info.CardInfoPaneImpl" name="cardInfoPane">
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
|
||||
</Component>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.decks.Deck;
|
||||
|
|
@ -29,18 +37,6 @@ import mage.view.CardView;
|
|||
import mage.view.SimpleCardView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -55,7 +51,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private UUID tableId;
|
||||
private DeckEditorMode mode;
|
||||
private int timeout;
|
||||
private Timer countdown;
|
||||
private javax.swing.Timer countdown;
|
||||
private UpdateDeckTask updateDeckTask;
|
||||
private int timeToSubmit = -1;
|
||||
|
||||
|
|
@ -75,7 +71,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
jPanel1.setOpaque(false);
|
||||
jSplitPane1.setOpaque(false);
|
||||
restoreDividerLocationsAndDeckAreaSettings();
|
||||
countdown = new Timer(1000,
|
||||
countdown = new javax.swing.Timer(1000,
|
||||
e -> {
|
||||
if (--timeout > 0) {
|
||||
setTimeout(timeout);
|
||||
|
|
@ -209,7 +205,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
this.btnGenDeck.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
this.btnLoad.setVisible(false);
|
||||
this.btnNew.setVisible(false);
|
||||
this.btnNew.setVisible(false);
|
||||
this.btnSubmit.setVisible(false);
|
||||
this.btnSubmitTimer.setVisible(false);
|
||||
this.cardSelector.loadCards(this.bigCard);
|
||||
|
|
@ -456,7 +452,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
CardView cardView = (CardView) event.getSource();
|
||||
int numberToSet = event.getNumber();
|
||||
int cardsFound = 0;
|
||||
List<Card> toDelete = new ArrayList<>();
|
||||
java.util.List<Card> toDelete = new ArrayList<>();
|
||||
for (Card card : cards) {
|
||||
if (card.getName().equals(cardView.getName())
|
||||
&& Objects.equals(card.getCardNumber(), cardView.getCardNumber())
|
||||
|
|
@ -689,7 +685,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
btnGenDeck.setText("Generate");
|
||||
btnGenDeck.setName("btnGenDeck");
|
||||
btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
|
||||
|
||||
txtTimeRemaining.setEditable(false);
|
||||
txtTimeRemaining.setForeground(java.awt.Color.red);
|
||||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
|
|
@ -699,89 +694,89 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(lblDeckName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSave)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnLoad)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnNew)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnExit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnImport)
|
||||
.addContainerGap()
|
||||
.addComponent(btnGenDeck)
|
||||
.addContainerGap()
|
||||
.addComponent(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap()));
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(lblDeckName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSave)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnLoad)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnNew)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnExit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnImport)
|
||||
.addContainerGap()
|
||||
.addComponent(btnGenDeck)
|
||||
.addContainerGap()
|
||||
.addComponent(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap()));
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDeckName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnSave)
|
||||
.addComponent(btnLoad)
|
||||
.addComponent(btnNew)
|
||||
.addComponent(btnExit))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnGenDeck)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit)
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtTimeRemaining))
|
||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDeckName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnSave)
|
||||
.addComponent(btnLoad)
|
||||
.addComponent(btnNew)
|
||||
.addComponent(btnExit))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnGenDeck)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit)
|
||||
.addComponent(btnSubmitTimer))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtTimeRemaining))
|
||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
||||
}
|
||||
|
||||
private void processAndShowImportErrors(StringBuilder errorMessages){
|
||||
private void processAndShowImportErrors(StringBuilder errorMessages) {
|
||||
// show up errors list
|
||||
if (errorMessages.length() > 0){
|
||||
if (errorMessages.length() > 0) {
|
||||
String mes = "Founded problems with deck: \n\n" + errorMessages.toString();
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), mes.substring(0, Math.min(1000, mes.length())), "Errors while loading deck", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
|
|
@ -813,7 +808,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
|
||||
} catch (GameException e1) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||
}finally {
|
||||
} finally {
|
||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
|
@ -845,7 +840,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
} catch (GameException e1) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||
}finally {
|
||||
} finally {
|
||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
|
@ -1063,7 +1058,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
refreshDeck();
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private mage.client.cards.BigCard bigCard;
|
||||
private javax.swing.JButton btnExit;
|
||||
|
|
|
|||
|
|
@ -3,15 +3,28 @@ package mage.client.deckeditor;
|
|||
import mage.util.StreamUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class DeckImportFromClipboardDialog extends JDialog {
|
||||
|
||||
private static final String FORMAT_TEXT =
|
||||
"// Example:\n" +
|
||||
"//1 Library of Congress\n" +
|
||||
"//1 Cryptic Gateway\n" +
|
||||
"//1 Azami, Lady of Scrolls\n" +
|
||||
"// NB: This is slow as, and will lock your screen :)\n" +
|
||||
"\n" +
|
||||
"// Your current clipboard:\n";
|
||||
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JButton buttonCancel;
|
||||
|
|
@ -21,6 +34,9 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
|
||||
public DeckImportFromClipboardDialog() {
|
||||
initComponents();
|
||||
|
||||
onRefreshClipboard();
|
||||
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
|
@ -40,6 +56,15 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
}
|
||||
|
||||
private Optional<String> getClipboardStringData() {
|
||||
try {
|
||||
return Optional.of((String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor));
|
||||
} catch (HeadlessException | UnsupportedFlavorException | IOException e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
|
|
@ -60,6 +85,10 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
dispose();
|
||||
}
|
||||
|
||||
private void onRefreshClipboard() {
|
||||
txtDeckList.setText(FORMAT_TEXT + getClipboardStringData().orElse(""));
|
||||
}
|
||||
|
||||
public String getTmpPath() {
|
||||
return tmpPath;
|
||||
}
|
||||
|
|
@ -143,7 +172,7 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
|
||||
txtDeckList.setMinimumSize(new Dimension(250, 400));
|
||||
txtDeckList.setPreferredSize(new Dimension(550, 400));
|
||||
txtDeckList.setText("// Example:\n//1 Library of Congress\n//1 Cryptic Gateway\n//1 Azami, Lady of Scrolls\n// NB: This is slow as, and will lock your screen :)");
|
||||
txtDeckList.setText(FORMAT_TEXT);
|
||||
JScrollPane txtScrollableDeckList = new JScrollPane(txtDeckList);
|
||||
panel3.add(txtScrollableDeckList, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
|
||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
package mage.client.deckeditor.table;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.view.CardView;
|
||||
|
||||
|
|
@ -94,8 +95,8 @@ public class MageCardComparator implements Comparator<CardView> {
|
|||
break;
|
||||
// Rarity
|
||||
case 6:
|
||||
aCom = a.getRarity().toString();
|
||||
bCom = b.getRarity().toString();
|
||||
aCom = a.getRarity().getSorting();
|
||||
bCom = b.getRarity().getSorting();
|
||||
break;
|
||||
// Set name
|
||||
case 7:
|
||||
|
|
|
|||
|
|
@ -340,8 +340,8 @@
|
|||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/flags/us.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="W"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Connect to vaporservermtg.com (USA)"/>
|
||||
<Property name="text" type="java.lang.String" value="P"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Connect to mtg.powersofwar.com (USA)"/>
|
||||
<Property name="actionCommand" type="java.lang.String" value="connectXmageus"/>
|
||||
<Property name="alignmentY" type="float" value="0.0"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
|
|
|
|||
|
|
@ -270,8 +270,8 @@ public class ConnectDialog extends MageDialog {
|
|||
});
|
||||
|
||||
btnFind3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flags/us.png"))); // NOI18N
|
||||
btnFind3.setText("W");
|
||||
btnFind3.setToolTipText("Connect to vaporservermtg.com (USA)");
|
||||
btnFind3.setText("P");
|
||||
btnFind3.setToolTipText("Connect to mtg.powersofwar.com (USA)");
|
||||
btnFind3.setActionCommand("connectXmageus");
|
||||
btnFind3.setAlignmentY(0.0F);
|
||||
btnFind3.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
|
|
@ -688,7 +688,7 @@ public class ConnectDialog extends MageDialog {
|
|||
}//GEN-LAST:event_btnFind2findPublicServerActionPerformed
|
||||
|
||||
private void connectXmageus(java.awt.event.ActionEvent evt) {
|
||||
String serverAddress = "vapormtgserver.com";
|
||||
String serverAddress = "mtg.powersofwar.com";
|
||||
this.txtServer.setText(serverAddress);
|
||||
this.txtPort.setText("17171");
|
||||
// Update userName and password according to the chosen server.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import mage.cards.repository.ExpansionRepository;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.table.TournamentPlayerPanel;
|
||||
import mage.client.util.IgnoreList;
|
||||
import mage.client.util.gui.FastSearchUtil;
|
||||
import mage.constants.MatchTimeLimit;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
|
|
@ -607,6 +608,9 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.getMatchOptions().setLimited(false);
|
||||
}
|
||||
|
||||
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
|
||||
tOptions.getMatchOptions().setBannedUsers(IgnoreList.ignoreList(serverAddress));
|
||||
|
||||
tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
|
||||
tOptions.getMatchOptions().setSkillLevel((SkillLevel) this.cbSkillLevel.getSelectedItem());
|
||||
tOptions.getMatchOptions().setWinsNeeded((Integer) this.spnNumWins.getValue());
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import mage.view.CardView;
|
|||
import mage.view.PermanentView;
|
||||
import net.xeoh.plugins.base.PluginManager;
|
||||
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
||||
import net.xeoh.plugins.base.util.uri.ClassURI;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.CardPluginImpl;
|
||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||
|
|
@ -46,13 +48,15 @@ public enum Plugins implements MagePlugins {
|
|||
|
||||
@Override
|
||||
public void loadPlugins() {
|
||||
|
||||
LOGGER.info("Loading plugins...");
|
||||
pm = PluginManagerFactory.createPluginManager();
|
||||
pm.addPluginsFrom(new File(PLUGINS_DIRECTORY + File.separator).toURI());
|
||||
this.cardPlugin = new CardPluginImpl();
|
||||
pm.addPluginsFrom(new ClassURI(CardPluginImpl.class).toURI());
|
||||
pm.addPluginsFrom(new ClassURI(ThemePluginImpl.class).toURI());
|
||||
|
||||
this.cardPlugin = pm.getPlugin(CardPlugin.class);
|
||||
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
||||
this.themePlugin = new ThemePluginImpl();
|
||||
this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||
LOGGER.info("Done.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
case GAME_CHOOSE_ABILITY: {
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
appendJsonEvent("GAME_CHOOSE_PILE", callback.getObjectId(), callback.getData());
|
||||
appendJsonEvent("GAME_CHOOSE_ABILITY", callback.getObjectId(), callback.getData());
|
||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,163 +1,193 @@
|
|||
|
||||
|
||||
/*
|
||||
* TablesPanel.java
|
||||
*
|
||||
* Created on 15-Dec-2009, 10:54:01 PM
|
||||
*/
|
||||
package mage.client.table;
|
||||
* TablesPanel.java
|
||||
*
|
||||
* Created on 15-Dec-2009, 10:54:01 PM
|
||||
*/
|
||||
package mage.client.table;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.chat.ChatPanelBasic;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.dialog.*;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_FILTER_SETTINGS;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_1;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_2;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_3;
|
||||
import mage.client.util.ButtonColumn;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.client.util.IgnoreList;
|
||||
import mage.client.util.MageTableRowSorter;
|
||||
import mage.client.util.URLHandler;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.client.util.gui.TableUtil;
|
||||
import mage.constants.*;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.players.PlayerType;
|
||||
import mage.remote.MageRemoteException;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.ocpsoft.prettytime.Duration;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import org.ocpsoft.prettytime.units.JustNow;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.chat.ChatPanelBasic;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.dialog.*;
|
||||
import mage.client.util.*;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.client.util.gui.TableUtil;
|
||||
import mage.constants.*;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.players.PlayerType;
|
||||
import mage.remote.MageRemoteException;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.UserRequestMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardRendererUtils;
|
||||
import org.ocpsoft.prettytime.Duration;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import org.ocpsoft.prettytime.units.JustNow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TablesPanel extends javax.swing.JPanel {
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
|
||||
import static mage.client.dialog.PreferencesDialog.*;
|
||||
|
||||
private final TableTableModel tableModel;
|
||||
private final MatchesTableModel matchesModel;
|
||||
private UUID roomId;
|
||||
private UpdateTablesTask updateTablesTask;
|
||||
private UpdatePlayersTask updatePlayersTask;
|
||||
private UpdateMatchesTask updateMatchesTask;
|
||||
private JoinTableDialog joinTableDialog;
|
||||
private NewTableDialog newTableDialog;
|
||||
private NewTournamentDialog newTournamentDialog;
|
||||
private final GameChooser gameChooser;
|
||||
private java.util.List<String> messages;
|
||||
private int currentMessage;
|
||||
private final MageTableRowSorter activeTablesSorter;
|
||||
private final MageTableRowSorter completedTablesSorter;
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TablesPanel extends javax.swing.JPanel {
|
||||
|
||||
private final ButtonColumn actionButton1;
|
||||
private final ButtonColumn actionButton2;
|
||||
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
|
||||
|
||||
final JToggleButton[] filterButtons;
|
||||
private final TableTableModel tableModel;
|
||||
private final MatchesTableModel matchesModel;
|
||||
private UUID roomId;
|
||||
private UpdateTablesTask updateTablesTask;
|
||||
private UpdatePlayersTask updatePlayersTask;
|
||||
private UpdateMatchesTask updateMatchesTask;
|
||||
private JoinTableDialog joinTableDialog;
|
||||
private NewTableDialog newTableDialog;
|
||||
private NewTournamentDialog newTournamentDialog;
|
||||
private final GameChooser gameChooser;
|
||||
private java.util.List<String> messages;
|
||||
private int currentMessage;
|
||||
private final MageTableRowSorter activeTablesSorter;
|
||||
private final MageTableRowSorter completedTablesSorter;
|
||||
|
||||
// time formater
|
||||
private PrettyTime timeFormater = new PrettyTime();
|
||||
private final ButtonColumn actionButton1;
|
||||
private final ButtonColumn actionButton2;
|
||||
|
||||
// time ago renderer
|
||||
TableCellRenderer timeAgoCellRenderer = new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
Date d = (Date) value;
|
||||
label.setText(timeFormater.format(d));
|
||||
return label;
|
||||
}
|
||||
};
|
||||
final JToggleButton[] filterButtons;
|
||||
|
||||
// duration renderer
|
||||
TableCellRenderer durationCellRenderer = new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
Long ms = (Long) value;
|
||||
// time formater
|
||||
private PrettyTime timeFormater = new PrettyTime();
|
||||
|
||||
if (ms != 0) {
|
||||
Duration dur = timeFormater.approximateDuration(new Date(ms));
|
||||
label.setText((timeFormater.formatDuration(dur)));
|
||||
} else {
|
||||
label.setText("");
|
||||
}
|
||||
return label;
|
||||
}
|
||||
};
|
||||
// time ago renderer
|
||||
TableCellRenderer timeAgoCellRenderer = new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
Date d = (Date) value;
|
||||
label.setText(timeFormater.format(d));
|
||||
return label;
|
||||
}
|
||||
};
|
||||
|
||||
// datetime render
|
||||
TableCellRenderer datetimeCellRenderer = new DefaultTableCellRenderer() {
|
||||
DateFormat datetimeFormater = new SimpleDateFormat("HH:mm:ss");
|
||||
// duration renderer
|
||||
TableCellRenderer durationCellRenderer = new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
Long ms = (Long) value;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
Date d = (Date) value;
|
||||
if (d != null) {
|
||||
label.setText(datetimeFormater.format(d));
|
||||
} else {
|
||||
label.setText("");
|
||||
}
|
||||
if (ms != 0) {
|
||||
Duration dur = timeFormater.approximateDuration(new Date(ms));
|
||||
label.setText((timeFormater.formatDuration(dur)));
|
||||
} else {
|
||||
label.setText("");
|
||||
}
|
||||
return label;
|
||||
}
|
||||
};
|
||||
|
||||
return label;
|
||||
}
|
||||
};
|
||||
// datetime render
|
||||
TableCellRenderer datetimeCellRenderer = new DefaultTableCellRenderer() {
|
||||
DateFormat datetimeFormater = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
/**
|
||||
* Creates new form TablesPanel
|
||||
*/
|
||||
public TablesPanel() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
Date d = (Date) value;
|
||||
if (d != null) {
|
||||
label.setText(datetimeFormater.format(d));
|
||||
} else {
|
||||
label.setText("");
|
||||
}
|
||||
|
||||
tableModel = new TableTableModel();
|
||||
matchesModel = new MatchesTableModel();
|
||||
gameChooser = new GameChooser();
|
||||
return label;
|
||||
}
|
||||
};
|
||||
|
||||
initComponents();
|
||||
// tableModel.setSession(session);
|
||||
// skill renderer
|
||||
TableCellRenderer skillCellRenderer = new DefaultTableCellRenderer() {
|
||||
|
||||
// formater
|
||||
timeFormater.setLocale(Locale.ENGLISH);
|
||||
JustNow jn = timeFormater.getUnit(JustNow.class);
|
||||
jn.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
|
||||
// base panel to render
|
||||
private JPanel renderPanel = new JPanel();
|
||||
private ImageIcon skillIcon = new ImageIcon(this.getClass().getResource("/info/yellow_star_16.png"));
|
||||
|
||||
// 1. TABLE CURRENT
|
||||
tableTables.createDefaultColumnsFromModel();
|
||||
activeTablesSorter = new MageTableRowSorter(tableModel);
|
||||
tableTables.setRowSorter(activeTablesSorter);
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
|
||||
// get table text cell settings
|
||||
DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
|
||||
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
String skillCode = baseComp.getText();
|
||||
|
||||
// apply settings to render panel from parent
|
||||
renderPanel.setOpaque(baseComp.isOpaque());
|
||||
renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground()));
|
||||
renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground()));
|
||||
renderPanel.setBorder(baseComp.getBorder());
|
||||
|
||||
// create each skill symbol as child label
|
||||
renderPanel.removeAll();
|
||||
renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS));
|
||||
for (char skillSymbol : skillCode.toCharArray()) {
|
||||
JLabel symbolLabel = new JLabel();
|
||||
symbolLabel.setBorder(new EmptyBorder(0, 3, 0, 0));
|
||||
symbolLabel.setIcon(skillIcon);
|
||||
renderPanel.add(symbolLabel);
|
||||
}
|
||||
|
||||
return renderPanel;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates new form TablesPanel
|
||||
*/
|
||||
public TablesPanel() {
|
||||
|
||||
tableModel = new TableTableModel();
|
||||
matchesModel = new MatchesTableModel();
|
||||
gameChooser = new GameChooser();
|
||||
|
||||
initComponents();
|
||||
// tableModel.setSession(session);
|
||||
|
||||
// formater
|
||||
timeFormater.setLocale(Locale.ENGLISH);
|
||||
JustNow jn = timeFormater.getUnit(JustNow.class);
|
||||
jn.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
|
||||
|
||||
// 1. TABLE CURRENT
|
||||
tableTables.createDefaultColumnsFromModel();
|
||||
activeTablesSorter = new MageTableRowSorter(tableModel);
|
||||
tableTables.setRowSorter(activeTablesSorter);
|
||||
|
||||
// time ago
|
||||
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_CREATED).setCellRenderer(timeAgoCellRenderer);
|
||||
// skill level
|
||||
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_SKILL).setCellRenderer(skillCellRenderer);
|
||||
|
||||
// time ago
|
||||
tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_CREATED).setCellRenderer(timeAgoCellRenderer);
|
||||
/* date sorter (not need, default is good - see getColumnClass)
|
||||
activeTablesSorter.setComparator(TableTableModel.COLUMN_CREATED, new Comparator<Date>() {
|
||||
@Override
|
||||
|
|
@ -166,6 +196,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
});*/
|
||||
|
||||
// default sort by created date (last games from above)
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new RowSorter.SortKey(TableTableModel.COLUMN_CREATED, SortOrder.DESCENDING));
|
||||
|
|
@ -322,17 +353,22 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
addTableDoubleClickListener(tableCompleted, closedTableAction);
|
||||
}
|
||||
|
||||
private void addTableDoubleClickListener(JTable table, Action action) {
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
int row = table.rowAtPoint(e.getPoint());
|
||||
if (e.getClickCount() == 2 && row != -1) {
|
||||
action.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "" + row));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void addTableDoubleClickListener(JTable table, Action action) {
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
int dataRow = table.convertRowIndexToModel(selRow);
|
||||
if (dataRow != -1) {
|
||||
action.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "" + dataRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
saveGuiSettings();
|
||||
|
|
@ -620,15 +656,16 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
formatFilterList.add(RowFilter.regexFilter("^Momir Basic|^Constructed - Pauper|^Constructed - Frontier|^Constructed - Extended|^Constructed - Eternal|^Constructed - Historical|^Constructed - Super|^Constructed - Freeform|^Australian Highlander|^Canadian Highlander|^Constructed - Old", TableTableModel.COLUMN_DECK_TYPE));
|
||||
}
|
||||
|
||||
// skill
|
||||
java.util.List<RowFilter<Object, Object>> skillFilterList = new ArrayList<>();
|
||||
if (btnSkillBeginner.isSelected()) {
|
||||
skillFilterList.add(RowFilter.regexFilter(SkillLevel.BEGINNER.toString(), TableTableModel.COLUMN_SKILL));
|
||||
skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.BEGINNER, true), TableTableModel.COLUMN_SKILL));
|
||||
}
|
||||
if (btnSkillCasual.isSelected()) {
|
||||
skillFilterList.add(RowFilter.regexFilter(SkillLevel.CASUAL.toString(), TableTableModel.COLUMN_SKILL));
|
||||
if (btnSkillCasual.isSelected()) {
|
||||
skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.CASUAL, true), TableTableModel.COLUMN_SKILL));
|
||||
}
|
||||
if (btnSkillSerious.isSelected()) {
|
||||
skillFilterList.add(RowFilter.regexFilter(SkillLevel.SERIOUS.toString(), TableTableModel.COLUMN_SKILL));
|
||||
skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.SERIOUS, true), TableTableModel.COLUMN_SKILL));
|
||||
}
|
||||
|
||||
String ratedMark = TableTableModel.RATED_VALUE_YES;
|
||||
|
|
@ -1356,6 +1393,31 @@ class TableTableModel extends AbstractTableModel {
|
|||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
public String getSkillLevelAsCode(SkillLevel skill, boolean asRegExp) {
|
||||
String res;
|
||||
switch (skill) {
|
||||
case BEGINNER:
|
||||
res = "*";
|
||||
break;
|
||||
case CASUAL:
|
||||
res = "**";
|
||||
break;
|
||||
case SERIOUS:
|
||||
res = "***";
|
||||
break;
|
||||
default:
|
||||
res = "";
|
||||
break;
|
||||
}
|
||||
|
||||
// regexp format for search table rows
|
||||
if (asRegExp) {
|
||||
res = String.format("^%s$", res.replace("*", "\\*"));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return tables.length;
|
||||
|
|
@ -1386,7 +1448,7 @@ class TableTableModel extends AbstractTableModel {
|
|||
case 7:
|
||||
return tables[arg0].getCreateTime(); // use cell render, not format here
|
||||
case 8:
|
||||
return tables[arg0].getSkillLevel();
|
||||
return this.getSkillLevelAsCode(tables[arg0].getSkillLevel(), false);
|
||||
case 9:
|
||||
return tables[arg0].isRated() ? RATED_VALUE_YES : RATED_VALUE_NO;
|
||||
case 10:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.client.util;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -33,38 +32,41 @@ public final class Config {
|
|||
|
||||
static {
|
||||
Properties p = new Properties();
|
||||
try(FileInputStream fis =new FileInputStream(new File("config/config.properties"))) {
|
||||
boolean fileFound = true;
|
||||
try (FileInputStream fis = new FileInputStream(new File("config/config.properties"))) {
|
||||
p.load(fis);
|
||||
} catch (IOException ex) {
|
||||
logger.fatal("Config error ", ex);
|
||||
fileFound = false;
|
||||
}
|
||||
serverName = p.getProperty("server-name");
|
||||
port = Integer.parseInt(p.getProperty("port"));
|
||||
remoteServer = p.getProperty("remote-server");
|
||||
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
|
||||
cardScalingFactorEnlarged = Double.valueOf(p.getProperty("card-scaling-factor-enlarged"));
|
||||
handScalingFactor = Double.valueOf(p.getProperty("hand-scaling-factor"));
|
||||
defaultGameType = p.getProperty("default-game-type", "Human");
|
||||
defaultDeckPath = p.getProperty("default-deck-path");
|
||||
defaultOtherPlayerIndex = p.getProperty("default-other-player-index");
|
||||
defaultComputerName = p.getProperty("default-computer-name");
|
||||
if (fileFound) {
|
||||
serverName = p.getProperty("server-name");
|
||||
port = Integer.parseInt(p.getProperty("port"));
|
||||
remoteServer = p.getProperty("remote-server");
|
||||
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
|
||||
cardScalingFactorEnlarged = Double.valueOf(p.getProperty("card-scaling-factor-enlarged"));
|
||||
handScalingFactor = Double.valueOf(p.getProperty("hand-scaling-factor"));
|
||||
defaultGameType = p.getProperty("default-game-type", "Human");
|
||||
defaultDeckPath = p.getProperty("default-deck-path");
|
||||
defaultOtherPlayerIndex = p.getProperty("default-other-player-index");
|
||||
defaultComputerName = p.getProperty("default-computer-name");
|
||||
|
||||
dimensions = new CardDimensions(cardScalingFactor);
|
||||
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
|
||||
// activate instead this part, to run the UI editor for some panels without error
|
||||
// serverName = "localhost";
|
||||
// port = 17171;
|
||||
// remoteServer = "mage-server";
|
||||
// cardScalingFactor = 0.4;
|
||||
// cardScalingFactorEnlarged = 0.5;
|
||||
// handScalingFactor = 1.3;
|
||||
// defaultGameType = p.getProperty("default-game-type", "Human");
|
||||
// defaultDeckPath = "";
|
||||
// defaultOtherPlayerIndex = "1";
|
||||
// defaultComputerName = "Computer";
|
||||
//
|
||||
// dimensions = new CardDimensions(cardScalingFactor);
|
||||
// dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
|
||||
dimensions = new CardDimensions(cardScalingFactor);
|
||||
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
|
||||
} else { // Take some default valies for netbeans design view
|
||||
serverName = "localhost";
|
||||
port = 17171;
|
||||
remoteServer = "mage-server";
|
||||
cardScalingFactor = 0.4;
|
||||
cardScalingFactorEnlarged = 0.5;
|
||||
handScalingFactor = 1.3;
|
||||
defaultGameType = p.getProperty("default-game-type", "Human");
|
||||
defaultDeckPath = "";
|
||||
defaultOtherPlayerIndex = "1";
|
||||
defaultComputerName = "AI Computer";
|
||||
|
||||
dimensions = new CardDimensions(cardScalingFactor);
|
||||
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import mage.view.ChatMessage;
|
|||
|
||||
public final class IgnoreList {
|
||||
|
||||
private static final String USAGE = "<br/><font color=yellow>\\ignore - shows current ignore list on this server."
|
||||
+ "<br/>\\ignore [username] - add a username to your ignore list on this server."
|
||||
private static final String USAGE = "<br/><font color=yellow>\\ignore - shows your ignore list on this server."
|
||||
+ "<br/>\\ignore [username] - add username to ignore list (they won't be able to chat or join to your game)."
|
||||
+ "<br/>\\unignore [username] - remove a username from your ignore list on this server.</font>";
|
||||
|
||||
public static final int MAX_IGNORE_LIST_SIZE = 50;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import java.util.Map;
|
|||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.constants.SetType;
|
||||
import static mage.constants.SetType.EXPANSION;
|
||||
import static mage.constants.SetType.SUPPLEMENTAL;
|
||||
import mage.deck.Standard;
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +66,13 @@ public final class ConstructedFormats {
|
|||
underlyingSetCodesPerFormat.put(CUSTOM, new ArrayList<>());
|
||||
final Map<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
||||
formats.clear(); // prevent NPE on sorting if this is not the first try
|
||||
|
||||
// Because this is also called in Netbeans Design view, but the object does not exist in that case,
|
||||
// we have to return here to prevent exception in design view. (Does not hurt at design time)
|
||||
if (!ExpansionRepository.instance.instanceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
||||
expansionInfo.put(set.getName(), set);
|
||||
formats.add(set.getName());
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.mage.card.arcane;
|
||||
|
||||
import java.awt.*;
|
||||
|
|
@ -63,26 +58,26 @@ public final class CardRendererUtils {
|
|||
int plus_b = (int) ((255 - b) / 2);
|
||||
|
||||
return new Color(r + plus_r,
|
||||
g + plus_g,
|
||||
b + plus_b,
|
||||
alpha);
|
||||
g + plus_g,
|
||||
b + plus_b,
|
||||
alpha);
|
||||
}
|
||||
|
||||
|
||||
public static Color abitdarker(Color c) {
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
int alpha = c.getAlpha();
|
||||
|
||||
int plus_r = (int) (Math.min (255 - r, r) / 2);
|
||||
int plus_g = (int) (Math.min (255 - g, g) / 2);
|
||||
int plus_b = (int) (Math.min (255 - b, b) / 2);
|
||||
int plus_r = (int) (Math.min(255 - r, r) / 2);
|
||||
int plus_g = (int) (Math.min(255 - g, g) / 2);
|
||||
int plus_b = (int) (Math.min(255 - b, b) / 2);
|
||||
|
||||
return new Color(r - plus_r,
|
||||
g - plus_g,
|
||||
b - plus_b,
|
||||
alpha);
|
||||
}
|
||||
g - plus_g,
|
||||
b - plus_b,
|
||||
alpha);
|
||||
}
|
||||
|
||||
// Draw a rounded box with a 2-pixel border
|
||||
// Used on various card parts.
|
||||
|
|
@ -192,4 +187,12 @@ public final class CardRendererUtils {
|
|||
.replaceAll("<i>", "")
|
||||
.replaceAll("</i>", "");
|
||||
}
|
||||
|
||||
public static Color copyColor(Color color) {
|
||||
if (color != null) {
|
||||
return new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@ import java.awt.*;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public final class ManaSymbolsCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
// base panel to render
|
||||
private JPanel manaPanel = new JPanel();
|
||||
private JPanel renderPanel = new JPanel();
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
|
|
@ -20,47 +23,47 @@ public final class ManaSymbolsCellRenderer extends DefaultTableCellRenderer {
|
|||
|
||||
// get table text cell settings
|
||||
DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
|
||||
JLabel baseLabel = (JLabel)baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
// apply settings to mana panel from parent
|
||||
manaPanel.setOpaque(baseLabel.isOpaque());
|
||||
manaPanel.setForeground(baseLabel.getForeground());
|
||||
manaPanel.setBackground(baseLabel.getBackground());
|
||||
renderPanel.setOpaque(baseComp.isOpaque());
|
||||
renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground()));
|
||||
renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground()));
|
||||
renderPanel.setBorder(baseComp.getBorder());
|
||||
|
||||
// icons size with margin
|
||||
int symbolWidth = GUISizeHelper.symbolTableSize;
|
||||
int symbolHorizontalMargin = 2;
|
||||
|
||||
// create each mana symbol as child label
|
||||
String manaCost = (String)value;
|
||||
manaPanel.removeAll();
|
||||
manaPanel.setLayout(new BoxLayout(manaPanel, BoxLayout.X_AXIS));
|
||||
if(manaCost != null){
|
||||
String manaCost = (String) value;
|
||||
renderPanel.removeAll();
|
||||
renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS));
|
||||
if (manaCost != null) {
|
||||
StringTokenizer tok = new StringTokenizer(manaCost, " ");
|
||||
while (tok.hasMoreTokens()) {
|
||||
String symbol = tok.nextToken();
|
||||
|
||||
JLabel symbolLabel = new JLabel();
|
||||
//symbolLabel.setBorder(new LineBorder(new Color(150, 150, 150))); // debug
|
||||
symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin,0, 0));
|
||||
symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin, 0, 0));
|
||||
|
||||
BufferedImage image = ManaSymbols.getSizedManaSymbol(symbol, symbolWidth);
|
||||
if (image != null){
|
||||
if (image != null) {
|
||||
// icon
|
||||
symbolLabel.setIcon(new ImageIcon(image));
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
// text
|
||||
symbolLabel.setText("{" + symbol + "}");
|
||||
symbolLabel.setOpaque(baseLabel.isOpaque());
|
||||
symbolLabel.setForeground(baseLabel.getForeground());
|
||||
symbolLabel.setBackground(baseLabel.getBackground());
|
||||
symbolLabel.setOpaque(baseComp.isOpaque());
|
||||
symbolLabel.setForeground(baseComp.getForeground());
|
||||
symbolLabel.setBackground(baseComp.getBackground());
|
||||
}
|
||||
|
||||
manaPanel.add(symbolLabel);
|
||||
renderPanel.add(symbolLabel);
|
||||
}
|
||||
}
|
||||
|
||||
return manaPanel;
|
||||
return renderPanel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
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;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Quercitron, JayDi85
|
||||
*/
|
||||
|
|
@ -234,9 +230,16 @@ public enum ScryfallImageSource implements CardImageSource {
|
|||
supportedSets.add("M19");
|
||||
supportedSets.add("GS1");
|
||||
supportedSets.add("GRN");
|
||||
supportedSets.add("GK1");
|
||||
supportedSets.add("GNT");
|
||||
supportedSets.add("UMA");
|
||||
supportedSets.add("PUMA");
|
||||
//
|
||||
supportedSets.add("EURO");
|
||||
supportedSets.add("GPX");
|
||||
supportedSets.add("ATH");
|
||||
supportedSets.add("GRC");
|
||||
supportedSets.add("ANA");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -247,25 +250,43 @@ public enum ScryfallImageSource implements CardImageSource {
|
|||
String localizedCode = languageAliases.getOrDefault(preferredLanguage, defaultCode);
|
||||
// loc example: https://api.scryfall.com/cards/xln/121/ru?format=image
|
||||
|
||||
// TODO: do not use API at all? It's can help with scryfall request limits (1 request instead 2)
|
||||
// WARNING, some cards haven't direct images and uses random GUID:
|
||||
// As example: Raging Ravine - https://scryfall.com/card/uma/249/raging-ravine
|
||||
// https://img.scryfall.com/cards/large/front/5/4/54f41726-e0bb-4154-a2db-4b68b50f5032.jpg
|
||||
String baseUrl = null;
|
||||
String alternativeUrl = null;
|
||||
|
||||
// direct links to images (non localization)
|
||||
if (baseUrl == null) {
|
||||
String linkCode = card.getSet() + "/" + card.getName();
|
||||
if (directDownloadLinks.containsKey(linkCode)) {
|
||||
baseUrl = directDownloadLinks.get(linkCode);
|
||||
|
||||
// set/card/number
|
||||
String linkCode1 = card.getSet() + "/" + card.getName() + "/" + card.getCollectorId();
|
||||
if (directDownloadLinks.containsKey(linkCode1)) {
|
||||
baseUrl = directDownloadLinks.get(linkCode1);
|
||||
alternativeUrl = null;
|
||||
}
|
||||
|
||||
// set/card
|
||||
String linkCode2 = card.getSet() + "/" + card.getName();
|
||||
if (directDownloadLinks.containsKey(linkCode2)) {
|
||||
baseUrl = directDownloadLinks.get(linkCode2);
|
||||
alternativeUrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
// special card number like "103a" already compatible
|
||||
// special card number like "103a" and "U123" already compatible
|
||||
if (baseUrl == null && card.isCollectorIdWithStr()) {
|
||||
baseUrl = "https://img.scryfall.com/cards/large/" + localizedCode + "/" + formatSetName(card.getSet()) + "/"
|
||||
+ card.getCollectorId() + ".jpg";
|
||||
alternativeUrl = "https://img.scryfall.com/cards/large/" + defaultCode + "/" + formatSetName(card.getSet()) + "/"
|
||||
+ card.getCollectorId() + ".jpg";
|
||||
// WARNING, after 2018 it's not compatible and some new sets have GUID files instead card numbers
|
||||
// TODO: replace card number links to API calls (need test with lands, alternative images and double faces), replace not working images by direct links
|
||||
if (card.getCollectorId().startsWith("U")) {
|
||||
// fix for Ultimate Box Topper (PUMA) -- need to use API
|
||||
// ignored and go to API call at the end
|
||||
} else {
|
||||
baseUrl = "https://img.scryfall.com/cards/large/" + localizedCode + "/" + formatSetName(card.getSet()) + "/"
|
||||
+ card.getCollectorId() + ".jpg";
|
||||
alternativeUrl = "https://img.scryfall.com/cards/large/" + defaultCode + "/" + formatSetName(card.getSet()) + "/"
|
||||
+ card.getCollectorId() + ".jpg";
|
||||
}
|
||||
}
|
||||
|
||||
// double faced cards do not supports by API (need direct link for img)
|
||||
|
|
@ -376,6 +397,74 @@ public enum ScryfallImageSource implements CardImageSource {
|
|||
put("DPAP/Soul of Ravnica", "https://img.scryfall.com/cards/large/en/pdp14/1.jpg");
|
||||
put("DPAP/Soul of Zendikar", "https://img.scryfall.com/cards/large/en/pdp14/2.jpg");
|
||||
|
||||
// Gateway Promos -- xmage uses one set (GRC), but scryfall store it by years
|
||||
// 2006 - https://scryfall.com/sets/pgtw
|
||||
put("GRC/Fiery Temper", "https://img.scryfall.com/cards/large/en/pgtw/3.jpg");
|
||||
put("GRC/Icatian Javelineers", "https://img.scryfall.com/cards/large/en/pgtw/2.jpg");
|
||||
put("GRC/Wood Elves", "https://img.scryfall.com/cards/large/en/pgtw/1.jpg");
|
||||
// 2007 - https://scryfall.com/sets/pg07
|
||||
put("GRC/Boomerang", "https://img.scryfall.com/cards/large/en/pg07/4.jpg");
|
||||
put("GRC/Calciderm", "https://img.scryfall.com/cards/large/en/pg07/5.jpg");
|
||||
put("GRC/Dauntless Dourbark", "https://img.scryfall.com/cards/large/en/pg07/12.jpg");
|
||||
put("GRC/Llanowar Elves", "https://img.scryfall.com/cards/large/en/pg07/9.jpg");
|
||||
put("GRC/Mind Stone", "https://img.scryfall.com/cards/large/en/pg07/11.jpg");
|
||||
put("GRC/Mogg Fanatic", "https://img.scryfall.com/cards/large/en/pg07/10.jpg");
|
||||
put("GRC/Reckless Wurm", "https://img.scryfall.com/cards/large/en/pg07/6.jpg");
|
||||
put("GRC/Yixlid Jailer", "https://img.scryfall.com/cards/large/en/pg07/7.jpg");
|
||||
put("GRC/Zoetic Cavern", "https://img.scryfall.com/cards/large/en/pg07/8.jpg");
|
||||
// 2008a - https://scryfall.com/sets/pg08
|
||||
put("GRC/Boggart Ram-Gang", "https://img.scryfall.com/cards/large/en/pg08/17.jpg");
|
||||
put("GRC/Cenn's Tactician", "https://img.scryfall.com/cards/large/en/pg08/14.jpg");
|
||||
put("GRC/Duergar Hedge-Mage", "https://img.scryfall.com/cards/large/en/pg08/19.jpg");
|
||||
put("GRC/Gravedigger", "https://img.scryfall.com/cards/large/en/pg08/16.jpg");
|
||||
put("GRC/Lava Axe", "https://img.scryfall.com/cards/large/en/pg08/13.jpg");
|
||||
put("GRC/Oona's Blackguard", "https://img.scryfall.com/cards/large/en/pg08/15.jpg");
|
||||
put("GRC/Selkie Hedge-Mage", "https://img.scryfall.com/cards/large/en/pg08/20.jpg");
|
||||
put("GRC/Wilt-Leaf Cavaliers", "https://img.scryfall.com/cards/large/en/pg08/18.jpg");
|
||||
|
||||
// Wizards Play Network Promos -- xmage uses one set (GRC), but scryfall store it by years
|
||||
// 2008b - https://scryfall.com/sets/pwpn
|
||||
put("GRC/Sprouting Thrinax", "https://img.scryfall.com/cards/large/en/pwpn/21.jpg");
|
||||
put("GRC/Woolly Thoctar", "https://img.scryfall.com/cards/large/en/pwpn/22.jpg");
|
||||
// 2009 - https://scryfall.com/sets/pwp09
|
||||
put("GRC/Hellspark Elemental", "https://img.scryfall.com/cards/large/en/pwp09/25.jpg");
|
||||
put("GRC/Kor Duelist", "https://img.scryfall.com/cards/large/en/pwp09/32.jpg");
|
||||
put("GRC/Marisi's Twinclaws", "https://img.scryfall.com/cards/large/en/pwp09/26.jpg");
|
||||
put("GRC/Mind Control", "https://img.scryfall.com/cards/large/en/pwp09/30.jpg");
|
||||
put("GRC/Path to Exile", "https://img.scryfall.com/cards/large/en/pwp09/24.jpg");
|
||||
put("GRC/Rise from the Grave", "https://img.scryfall.com/cards/large/en/pwp09/31.jpg");
|
||||
put("GRC/Slave of Bolas", "https://img.scryfall.com/cards/large/en/pwp09/27.jpg");
|
||||
put("GRC/Vampire Nighthawk", "https://img.scryfall.com/cards/large/en/pwp09/33.jpg");
|
||||
// 2010 - https://scryfall.com/sets/pwp10
|
||||
put("GRC/Kor Firewalker", "https://img.scryfall.com/cards/large/en/pwp10/36.jpg");
|
||||
put("GRC/Leatherback Baloth", "https://img.scryfall.com/cards/large/en/pwp10/37.jpg");
|
||||
put("GRC/Syphon Mind", "https://img.scryfall.com/cards/large/en/pwp10/40.jpg");
|
||||
put("GRC/Pathrazer of Ulamog", "https://img.scryfall.com/cards/large/en/pwp10/46.jpg");
|
||||
put("GRC/Curse of Wizardry", "https://img.scryfall.com/cards/large/en/pwp10/47.jpg");
|
||||
put("GRC/Fling/50", "https://img.scryfall.com/cards/large/en/pwp10/50.jpg"); // same card but different year
|
||||
put("GRC/Sylvan Ranger/51", "https://img.scryfall.com/cards/large/en/pwp10/51.jpg"); // same card but different year
|
||||
put("GRC/Plague Stinger", "https://img.scryfall.com/cards/large/en/pwp10/59.jpg");
|
||||
put("GRC/Golem's Heart", "https://img.scryfall.com/cards/large/en/pwp10/60.jpg");
|
||||
put("GRC/Skinrender", "https://img.scryfall.com/cards/large/en/pwp10/63.jpg");
|
||||
// 2011 - https://scryfall.com/sets/pwp11
|
||||
put("GRC/Auramancer", "https://img.scryfall.com/cards/large/en/pwp11/77.jpg");
|
||||
put("GRC/Bloodcrazed Neonate", "https://img.scryfall.com/cards/large/en/pwp11/83.jpg");
|
||||
put("GRC/Boneyard Wurm", "https://img.scryfall.com/cards/large/en/pwp11/84.jpg");
|
||||
put("GRC/Circle of Flame", "https://img.scryfall.com/cards/large/en/pwp11/78.jpg");
|
||||
put("GRC/Curse of the Bloody Tome", "https://img.scryfall.com/cards/large/en/pwp11/80.jpg");
|
||||
put("GRC/Fling/69", "https://img.scryfall.com/cards/large/en/pwp11/69.jpg"); // same card but different year
|
||||
put("GRC/Master's Call", "https://img.scryfall.com/cards/large/en/pwp11/64.jpg");
|
||||
put("GRC/Maul Splicer", "https://img.scryfall.com/cards/large/en/pwp11/72.jpg");
|
||||
put("GRC/Plague Myr", "https://img.scryfall.com/cards/large/en/pwp11/65.jpg");
|
||||
put("GRC/Shrine of Burning Rage", "https://img.scryfall.com/cards/large/en/pwp11/73.jpg");
|
||||
put("GRC/Signal Pest", "https://img.scryfall.com/cards/large/en/pwp11/66.jpg");
|
||||
put("GRC/Sylvan Ranger/70", "https://img.scryfall.com/cards/large/en/pwp11/70.jpg"); // same card but different year
|
||||
put("GRC/Tormented Soul", "https://img.scryfall.com/cards/large/en/pwp11/76.jpg");
|
||||
put("GRC/Vault Skirge", "https://img.scryfall.com/cards/large/en/pwp11/71.jpg");
|
||||
// 2012 - https://scryfall.com/sets/pwp12
|
||||
put("GRC/Curse of Thirst", "https://img.scryfall.com/cards/large/en/pwp12/81.jpg");
|
||||
put("GRC/Gather the Townsfolk", "https://img.scryfall.com/cards/large/en/pwp12/79.jpg");
|
||||
put("GRC/Nearheath Stalker", "https://img.scryfall.com/cards/large/en/pwp12/82.jpg");
|
||||
|
||||
// TODO: remove Grand Prix fix after scryfall fix image's link (that's link must be work: https://img.scryfall.com/cards/large/en/pgpx/2016b.jpg )
|
||||
put("GPX/Sword of Feast and Famine", "https://img.scryfall.com/cards/large/en/pgpx/1%E2%98%85.jpg");
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@ public final class ImageCache {
|
|||
// legitimate, happens when a card has no image
|
||||
return null;
|
||||
} catch (ComputationException ex) {
|
||||
// too low memory
|
||||
if (ex.getCause() instanceof NullPointerException) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue