merge file from master

This commit is contained in:
Salco 2018-04-23 11:04:17 -04:00
commit eb0f196a7e
4372 changed files with 55156 additions and 17296 deletions

View file

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

View file

@ -80,7 +80,7 @@
1 [C16:104] Windfall
1 [C16:148] Far Wanderings
1 [C16:46] Thrasios, Triton Hero
1 [C16:346] Mountain
2 [C16:346] Mountain
2 [C16:347] Mountain
1 [C16:348] Mountain
1 [C16:105] Army of the Damned

View file

@ -66,6 +66,7 @@
1 [C17:158] Soul's Majesty
1 [C17:73] Spirit of the Hearth
1 [C17:224] Staff of Nin
1 [C17:7] Stalking Leonin
1 [C17:281] Stirring Wildwood
1 [C17:75] Sunspear Shikari
1 [C17:226] Swiftfoot Boots

View file

@ -1,23 +1,8 @@
NAME:Mormir Basic
3 [BFZ:259] Island
3 [BFZ:261] Swamp
3 [BFZ:250] Plains
3 [BFZ:272] Forest
3 [BFZ:260] Swamp
3 [BFZ:271] Forest
3 [BFZ:270] Forest
3 [BFZ:265] Mountain
2 [BFZ:254] Plains
3 [BFZ:264] Swamp
3 [BFZ:274] Forest
1 [BFZ:252] Plains
3 [BFZ:262] Swamp
3 [BFZ:251] Plains
2 [BFZ:273] Forest
3 [BFZ:258] Island
2 [BFZ:269] Mountain
3 [BFZ:268] Mountain
3 [BFZ:257] Island
3 [BFZ:267] Mountain
3 [BFZ:266] Mountain
2 [BFZ:255] Island
NAME:Mormir Basic
12 [BFZ:250a] Plains
12 [BFZ:260a] Swamp
12 [BFZ:270a] Forest
12 [BFZ:265a] Mountain
12 [BFZ:255a] Island
LAYOUT MAIN:(1,5)(COLOR_IDENTITY,true,5)|([BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a],[BFZ:270a])([BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a],[BFZ:265a])([BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a],[BFZ:260a])([BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a],[BFZ:255a])([BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a],[BFZ:250a])
LAYOUT SIDEBOARD:(0,0)(COLOR,true,5)|

View file

@ -0,0 +1,28 @@
2 [XLN:31] Raptor Companion
1 [XLN:135] Burning Sun's Avatar
2 [XLN:38] Slash of Talons
2 [XLN:36] Shining Aerosaur
1 [XLN:13] Goring Ceratops
3 [XLN:274] Mountain
3 [XLN:273] Mountain
2 [XLN:133] Bonded Horncrest
2 [XLN:275] Mountain
2 [XLN:30] Rallying Roar
3 [XLN:272] Mountain
2 [XLN:28] Pterodon Knight
2 [XLN:149] Lightning Strike
2 [XLN:146] Frenzied Raptor
4 [XLN:289] Stone Quarry
2 [XLN:288] Sun-Blessed Mount
2 [XLN:169] Tilonalli's Knight
1 [XLN:285] Huatli, Dinosaur Knight
2 [XLN:263] Plains
3 [XLN:262] Plains
3 [XLN:287] Huatli's Spurring
4 [XLN:286] Huatli's Snubhorn
2 [XLN:41] Territorial Hammerskull
3 [XLN:261] Plains
3 [XLN:260] Plains
2 [XLN:18] Kinjalli's Caller
LAYOUT MAIN:(1,4)(CARD_TYPE,false,50)|([XLN:13],[XLN:288],[XLN:288],[XLN:135],[XLN:18],[XLN:18],[XLN:286],[XLN:286],[XLN:286],[XLN:286],[XLN:31],[XLN:31],[XLN:169],[XLN:169],[XLN:146],[XLN:146],[XLN:41],[XLN:41],[XLN:133],[XLN:133],[XLN:28],[XLN:28],[XLN:36],[XLN:36])([XLN:287],[XLN:287],[XLN:287],[XLN:38],[XLN:38],[XLN:149],[XLN:149],[XLN:30],[XLN:30])([XLN:289],[XLN:289],[XLN:289],[XLN:289],[XLN:260],[XLN:260],[XLN:260],[XLN:261],[XLN:261],[XLN:261],[XLN:262],[XLN:262],[XLN:262],[XLN:263],[XLN:263],[XLN:272],[XLN:272],[XLN:272],[XLN:273],[XLN:273],[XLN:273],[XLN:274],[XLN:274],[XLN:274],[XLN:275],[XLN:275])([XLN:285])
LAYOUT SIDEBOARD:(0,0)(NONE,false,50)|

View file

@ -0,0 +1,23 @@
4 [HOU:193] Island
4 [HOU:192] Island
2 [AKH:41] Angler Drake
2 [HOU:29] Aerial Guide
2 [AKH:209] Weaver of Currents
2 [HOU:30] Aven Reedstalker
2 [AKH:219] Spring // Mind
4 [HOU:204] Woodland Stream
3 [HOU:54] Unsummon
3 [HOU:201] Avid Reclaimer
3 [AKH:179] Pouncing Cheetah
1 [HOU:200] Nissa, Genesis Mage
2 [HOU:203] Nissa's Encouragement
2 [HOU:115] Feral Prowler
4 [HOU:202] Brambleweft Behemoth
1 [AKH:196] Bounty of the Luxa
7 [HOU:199] Forest
1 [HOU:154] Reason // Believe
2 [HOU:143] River Hoopoe
2 [HOU:110] Ambuscade
7 [HOU:198] Forest
LAYOUT MAIN:(1,7)(CARD_TYPE,false,50)|([HOU:115],[HOU:115],[HOU:143],[HOU:143],[HOU:201],[HOU:201],[HOU:201],[AKH:179],[AKH:179],[AKH:179],[HOU:29],[HOU:29],[AKH:209],[AKH:209],[HOU:30],[HOU:30],[HOU:202],[HOU:202],[HOU:202],[HOU:202],[AKH:41],[AKH:41])([AKH:196])([AKH:219],[AKH:219])([HOU:54],[HOU:54],[HOU:54],[HOU:110],[HOU:110])([HOU:204],[HOU:204],[HOU:204],[HOU:204],[HOU:192],[HOU:192],[HOU:192],[HOU:192],[HOU:193],[HOU:193],[HOU:193],[HOU:193],[HOU:198],[HOU:198],[HOU:198],[HOU:198],[HOU:198],[HOU:198],[HOU:198],[HOU:199],[HOU:199],[HOU:199],[HOU:199],[HOU:199],[HOU:199],[HOU:199])([HOU:200])([HOU:154],[HOU:203],[HOU:203])
LAYOUT SIDEBOARD:(0,0)(NONE,false,50)|

View file

@ -104,6 +104,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static final String LITE_MODE_ARG = "-lite";
private static final String GRAY_MODE_ARG = "-gray";
private static final String FILL_SCREEN_ARG = "-fullscreen";
private static final String SKIP_DONE_SYMBOLS = "-skipDoneSymbols";
private static final String NOT_CONNECTED_TEXT = "<not connected>";
private static MageFrame instance;
@ -121,6 +122,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
//TODO: make gray theme, implement theme selector in preferences dialog
private static boolean grayMode = false;
private static boolean fullscreenMode = false;
private static boolean skipSmallSymbolGenerationForExisting = false;
private static final Map<UUID, ChatPanelBasic> CHATS = new HashMap<>();
private static final Map<UUID, GamePanel> GAMES = new HashMap<>();
@ -152,6 +154,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public static boolean isGray() {
return grayMode;
}
public static boolean isSkipSmallSymbolGenerationForExisting() {
return skipSmallSymbolGenerationForExisting;
}
@Override
public MageVersion getVersion() {
@ -613,7 +619,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)) {
@ -1191,6 +1197,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (arg.startsWith(FILL_SCREEN_ARG)) {
fullscreenMode = true;
}
if (arg.startsWith(SKIP_DONE_SYMBOLS)) {
skipSmallSymbolGenerationForExisting = true;
}
}
if (!liteMode) {
final SplashScreen splash = SplashScreen.getSplashScreen();

View file

@ -1083,6 +1083,22 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
repaint();
}
private void chooseMatching() {
Collection<CardView> toMatch = dragCardList();
for (DragCardGridListener l : listeners) {
for (CardView card : allCards) {
for (CardView aMatch : toMatch) {
if (card.getName().equals(aMatch.getName())) {
card.setSelected(true);
cardViews.get(card.getId()).update(card);
}
}
}
}
repaint();
}
private void showAll() {
for (DragCardGridListener l : listeners) {
@ -1217,7 +1233,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 +1283,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 +1304,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 +1312,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 +1364,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 +1396,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, "");
}
@ -1704,6 +1720,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JMenuItem invertSelection = new JMenuItem("Invert Selection");
invertSelection.addActionListener(e2 -> invertSelection());
menu.add(invertSelection);
JMenuItem chooseMatching = new JMenuItem("Choose Matching");
chooseMatching.addActionListener(e2 -> chooseMatching());
menu.add(chooseMatching);
// Show 'Duplicate Selection' for FREE_BUILDING
if (this.mode == Constants.DeckEditorMode.FREE_BUILDING) {

View file

@ -67,6 +67,10 @@ public class ManaPieChart extends JComponent {
for (int i = 0; i < slices.length; i++) {
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;

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;
@ -196,15 +197,15 @@ public class ChatPanelBasic extends javax.swing.JPanel {
Pattern profanityPattern = Pattern.compile(".*(1ab1a|1d1ot|13p3r|13sb1ans|13sbo|13s13|13sb1an|13sbo|13sy|1nbr3d|1nc3st|1njun|1ub3|\\Wbj|\\Wcum|\\Wdum|\\Wfag|\\Wfap|\\W[sf]uk|\\Wj1s|\\Wp3do|\\Wp33|\\Wpoo\\W|\\Wt1t|aho13|an1ngu|ana1|anus|ar3o1a|ar3o13|ary1an|axyx|axyxhat|axyxho13|axyxmast3r|axyxmunch|axyxw1p3|b1atch|b1gt1t|b1mbo|b1ow|b1tch|ba1s|bab3|bang|barf|bastard|bawdy|b3an3r|b3ard3dc1am|b3ast1a1ty|b3atch|b3at3r|b3av3r|b3otch|b3yotch|bo1nk|bod1y|bon3d|bon3r|bon3|bob|bot13|boty|bow31|br3ast|bug3r|bukak3|bung|busty|buxyx|c1t|caca|cahon3|cam31to3|carp3tmunch3r|cawk|c3rv1x|ch1nc|ch1nk|chod3|co1ta1|cockb1ock|cockho1st3r|cocknock3r|cocksmok3r|cocksuck3r|cock|condom|corksuck3r|crabs|cums1ut|cumshot|cumsta1n|cnt|cun1ngus|cuntfac3|cunthunt3r|cunt|d1ck|d1k3|d1do|d1mw1t|d1ng13|d1psh1p|dago|dam1t|damn1t|damn3d|damn|dawg13sty13|dog13sty13|dogysty13|dong|dop3y|douch3|drunk|dumb|dumas|dum|dumbas|dumy|dyk3|3jacu1at3|3n1arg3m3nt|3r3ct1on|3r3ct|3rot1c|3xtacy|3xtasy|f.ck|f1osy|f1st3d|f1st1ng|f1sty|fa1gt|fa1g|fack|fag1t|fag3d|fagot|fag|[sf]cuk|f31at1o|f31at3|f31ch1ng|f31ch3r|f31ch|f31tch3r|f31tch|foad|fobar|fond13|for3sk1n|fu.k|fudg3pack3r|[sf]uk|g1ans|g1go1o|ganja|ghay|gh3y|go1d3nshow3r|gonad|gok|gr1ngo|h1t13r|handjob|hardon|hokah|hok3r|homo|honky|hor|hotch|hot3r|horny|hump1ng|hump3d|hump|hym3n|j1sm|j1s3d|j1sm|j1s|jackas|jackho13|jackof|j3rk3d|j3rkof|j3rk|junk13|junky|k1an|k1k3|k1nky|knob3nd|kyk3|mams|masa|mast3rba|masturba|max1|m3ns3s|m3nstruat|m[sf]uck1ng|mofo|moron|moth3rf|mthrf|muf|n1ger|n1ga|n1mrod|n1ny|n1p13|nak3d|napa1m|napy|nas1|n3gro|noky|nympho|op1at3|op1um|ora1y|ora1|org13s|organ|orgasm|orgy|ovary|ovum|p1owb1t3r|p1mp|p1nko|p1s3d|p1sof|p1s|pak1|pant13|panty|past13|pasty|p3ck3r|p3doph1|p3p3|p3n1a1|p3n13|p3n1s|p3n3trat1on|p3n3trat3|p3rv3rs1on|p3yot3|pha1c|phuck|po1ack|po1ock|pontang|pop|pr1ck|pr1g|pron|pub1|pub3|punkas|punky|pus1|pusy|puto|qu1cky|qu1ck13|qu1m|qu3af|qu3ro|qu3rs|qu3r|r1mjob|r1tard|racy|rap1st|rap3d|rap3r|rap3|raunch|r31ch|r3cta1|r3ctum|r3ctus|r3tard|r3tar|rtard|rumpram3r|rump|s1av3|s13as|s1ut|sack|sad1s|scag|sch1ong|sch1so|scr3w|scrog|scrot|scrud|scum|s3aman|s3am3n|s3duc3|s3m3n|s3xua1|sh1t|skag|skank|sm3gma|smut|sn1p3r|snatch|sodom|sp1ck|sp1c|sp1k|sp3rm|spunk|st3amy|stfu|ston3d|str1p|strok3|stup1d|suck|sumofab1atch|t1nk13|t1t[sf]uck|tampon|tard|t3abag1ng|t3at|t3st1|t3st3|t3urd|thrust|tramp|trans|trashy|twat|ug1y|unw3d|ur1n3a|ut3rus|vag1na|vu1gar|vu1va|w1g3r|wang|wank3r|wank|w31n3r|w31rdo|w3dg13|w3n13|w3tback|w3w3|wh1t3y|wh1s|whor3).*");
Pattern profanity2Pattern = Pattern.compile(".*(1ab1a|1d1ot|13p3r|13sb1ans|13sbo|13s13|13sb1an|13sbo|13sy|1nbr3d|1nc3st|1njun|1ub3|\\Wbj|\\Wcum|\\Wdum|\\Wfag|\\Wfap|\\W[sf]uk|\\Wj1s|\\Wp3do|\\Wp3|\\Wpo\\W|\\Wt1t|aho13|an1ngu|ana1|anus|ar3o1a|ar3o13|ary1an|axyx|axyxhat|axyxho13|axyxmast3r|axyxmunch|axyxw1p3|b1atch|b1gt1t|b1mbo|b1ow|b1tch|ba1s|bab3|bang|barf|bastard|bawdy|b3an3r|b3ard3dc1am|b3ast1a1ty|b3atch|b3at3r|b3av3r|b3otch|b3yotch|bo1nk|bod1y|bon3d|bon3r|bon3|bob|bot13|boty|bow31|br3ast|bug3r|bukak3|bung|busty|buxyx|c1t|caca|cahon3|cam31to3|carp3tmunch3r|cawk|c3rv1x|ch1nc|ch1nk|chod3|co1ta1|cockb1ock|cockho1st3r|cocknock3r|cocksmok3r|cocksuck3r|cock|condom|corksuck3r|crabs|cums1ut|cumshot|cumsta1n|cnt|cun1ngus|cuntfac3|cunthunt3r|cunt|d1ck|d1k3|d1do|d1mw1t|d1ng13|d1psh1p|dago|dam1t|damn1t|damn3d|damn|dawg13sty13|dog13sty13|dogysty13|dong|dop3y|douch3|drunk|dumb|dum|dumas|dumbas|dumy|dyk3|3jacu1at3|3n1arg3m3nt|3r3ct1on|3r3ct|3rot1c|3xtacy|3xtasy|f.ck|f1osy|f1st3d|f1st1ng|f1sty|fa1gt|fa1g|fack|fag1t|fag3d|fagot|fag|[sf]cuk|f31at1o|f31at3|f31ch1ng|f31ch3r|f31ch|f31tch3r|f31tch|foad|fobar|fond13|for3sk1n|fu.k|fudg3pack3r|[sf]uk|g1ans|g1go1o|ganja|ghay|gh3y|go1d3nshow3r|gonad|gr1ngo|h1t13r|handjob|hardon|hokah|hok3r|homo|honky|hor|hotch|hot3r|horny|hump1ng|hump3d|hump|hym3n|j1sm|j1s3d|j1sm|j1s|jackas|jackho13|jackof|j3rk3d|j3rkof|j3rk|junk13|junky|k1an|k1k3|k1nky|knob3nd|kyk3|mams|masa|mast3rba|masturba|max1|m3ns3s|m3nstruat|m[sf]uck1ng|mofo|moron|moth3rf|mthrf|muf|n1ga|n1ger|n1mrod|n1ny|n1p13|nak3d|napa1m|napy|nas1|n3gro|noky|nympho|op1at3|op1um|ora1y|ora1|org13s|organ|orgasm|orgy|ovary|ovum|p1owb1t3r|p1mp|p1nko|p1s3d|p1sof|p1s|pak1|pant13|panty|past13|pasty|p3ck3r|p3doph1|p3p3|p3n1a1|p3n13|p3n1s|p3n3trat1on|p3n3trat3|p3rv3rs1on|p3yot3|pha1c|phuck|po1ack|po1ock|pontang|pop|porno|porn|pr1ck|pr1g|pron|pub1|pub3|punkas|punky|pus1|pusy|puto|qu1cky|qu1ck13|qu1m|qu3af|qu3ro|qu3rs|qu3r|r1mjob|r1tard|racy|rap1st|rap3d|rap3r|rap3|raunch|r31ch|r3cta1|r3ctum|r3ctus|r3tard|r3tar|rtard|rumpram3r|rump|s1av3|s13as|s1ut|sack|sad1s|scag|sch1ong|sch1so|scr3w|scrog|scrot|scrud|scum|s3aman|s3am3n|s3duc3|s3m3n|s3xua1|sh1t|skag|skank|sm3gma|smut|sn1p3r|snatch|sodom|sp1ck|sp1c|sp1k|sp3rm|spunk|st3amy|stfu|ston3d|str1p|strok3|stup1d|suck|sumofab1atch|t1nk13|t1t[sf]uck|tampon|tard|t3abag1ng|t3at|t3st1|t3st3|t3urd|thrust|tramp|trans|trashy|twat|ug1y|unw3d|ur1n3a|ut3rus|vag1na|vu1gar|vu1va|w1g3r|wang|wank3r|wank|w31n3r|w31rdo|w3dg13|w3n13|w3tback|w3w3|wh1t3y|wh1s|whor3).*");
private boolean containsSwearing(String message, String level) {
if (level.equals("0")) {
return false;
}
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");
}
}
@ -435,7 +436,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
this.txtMessage.repaint();
}
}
public void enableHyperlinks() {
txtConversation.enableHyperlinks();
}

View file

@ -3,14 +3,20 @@ 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;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import javax.swing.JPanel;
import javax.swing.Timer;
import mage.client.util.Command;
/**
@ -40,7 +46,9 @@ public class HoverButton extends JPanel implements MouseListener {
private String topText;
private Image topTextImage;
private Image topTextImageRight;
private String centerText;
private boolean wasHovered = false;
private boolean isHovered = false;
private boolean isSelected = false;
private boolean drawSet = false;
@ -49,16 +57,27 @@ 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 Color centerTextColor = new Color(200, 210, 0, 200);
private Color origCenterTextColor = new Color(200, 210, 0, 200);
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;
Timer faderGainLife = null;
Timer faderLoseLife = null;
private int loseX = 0;
private int gainX = 0;
private boolean doLoseFade = true;
private boolean doGainFade = true;
public HoverButton(String text, Image image, Rectangle size) {
this(text, image, image, null, image, size);
if (image == null) {
@ -90,6 +109,10 @@ public class HoverButton extends JPanel implements MouseListener {
Graphics2D g2d = (Graphics2D) g;
if (isEnabled()) {
if (isHovered || textAlwaysVisible) {
if (isHovered) {
wasHovered = true;
setCenterColor(Color.YELLOW);
}
g.drawImage(hoverImage, 0, 0, imageSize.width, imageSize.height, this);
if (text != null) {
if (textColor != null) {
@ -104,6 +127,10 @@ public class HoverButton extends JPanel implements MouseListener {
g2d.drawString(text, textOffsetX, textOffsetY);
}
} else {
if (wasHovered) {
wasHovered = false;
setCenterColor(origCenterTextColor);
}
g.drawImage(image, 0, 0, imageSize.width, imageSize.height, this);
}
if (isSelected) {
@ -134,6 +161,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;
}
drawCenteredStringWOutline(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) {
@ -155,6 +197,10 @@ public class HoverButton extends JPanel implements MouseListener {
}
}
public void setCenterColor(Color c) {
centerTextColor = c;
}
private int calculateOffset(Graphics2D g2d) {
if (textOffsetX == -1) { // calculate once
FontRenderContext frc = g2d.getFontRenderContext();
@ -298,13 +344,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 +363,108 @@ 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 drawCenteredStringWOutline(Graphics2D 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);
GlyphVector gv = font.createGlyphVector(g.getFontRenderContext(), text);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g.drawGlyphVector(gv, x, y);
g.translate(x - 1, y - 1);
for (int i = 0; i < text.length(); i++) {
g.setColor(Color.BLACK);
g.draw(gv.getGlyphOutline(i));
}
g.translate(-x + 1, -y + 1);
}
public void gainLifeDisplay() {
if (faderGainLife == null && doGainFade) {
doGainFade = false;
faderGainLife = new Timer(50, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
gainX++;
int alpha = Math.max(250 - gainX, 200);
setCenterColor(new Color(2 * gainX, 210, 255, alpha));
repaint();
if (gainX >= 100) {
setCenterColor(new Color(200, 210, 0, 200));
gainX = 100;
if (faderGainLife != null) {
faderGainLife.stop();
faderGainLife.setRepeats(false);
faderGainLife.setDelay(50000);
}
}
}
});
gainX = 0;
faderGainLife.setInitialDelay(25);
faderGainLife.setRepeats(true);
faderGainLife.start();
}
}
public void loseLifeDisplay() {
if (faderLoseLife == null && doLoseFade) {
doLoseFade = false;
faderLoseLife = new Timer(50, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
loseX++;
int alpha = Math.max(250 - loseX, 200);
setCenterColor(new Color(250 - loseX / 2, 130 + loseX, 0, alpha));
repaint();
if (loseX >= 100) {
setCenterColor(new Color(200, 210, 0, 200));
loseX = 100;
stopLifeDisplay();
if (faderLoseLife != null) {
faderLoseLife.stop();
faderLoseLife.setRepeats(false);
faderLoseLife.setDelay(50000);
}
}
}
});
loseX = 0;
faderLoseLife.setInitialDelay(25);
faderLoseLife.setRepeats(true);
faderLoseLife.start();
}
}
public void stopLifeDisplay() {
if (faderGainLife != null && gainX >= 100) {
faderGainLife.stop();
faderGainLife = null;
}
doGainFade = true;
if (faderLoseLife != null && loseX >= 100) {
faderLoseLife.stop();
faderLoseLife = null;
}
doLoseFade = true;
}
}

View file

@ -399,23 +399,23 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
JFrame jframe = new JFrame("Test");
List<Object> objectList = new ArrayList<>();
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
objectList.add("T: add {B} to your mana pool. {source} deals 1 damage to you.");
objectList.add("{T}: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {B} to your mana pool");
objectList.add("T: add {R}. 111111111111111111111111111");
objectList.add("T: add {B}. {source} deals 1 damage to you.");
objectList.add("{T}: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("T: add {B}");
objectList.add("Cancel");
AbilityPicker panel = new AbilityPicker(objectList, "Choose ability");
jframe.add(panel);
@ -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

@ -112,7 +112,7 @@ public class DialogContainer extends JPanel {
backgroundColor = new Color(0, 0, 50, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander and Emblems)");
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);

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

@ -108,16 +108,16 @@ public class DeckGeneratorDialog {
mainPanel.add(formatSetText, c);
// Format/set dropdown with search button
JPanel setPanel = new JPanel();
JPanel setPanel = new JPanel();
setPanel.setLayout(new javax.swing.BoxLayout(setPanel, javax.swing.BoxLayout.LINE_AXIS));
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 1;
c.gridy = 1;
c.ipadx = 30;
c.insets = new Insets(5, 10, 0, 10);
c.weightx = 0.80;
c.weightx = 0.80;
mainPanel.add(setPanel, c);
cbSets = new JComboBox<>(ConstructedFormats.getTypes());
cbSets.setSelectedIndex(0);
cbSets.setAlignmentX(0.0F);
@ -127,13 +127,14 @@ public class DeckGeneratorDialog {
if (prefSet != null) {
cbSets.setSelectedItem(prefSet);
}
JButton btn = new JButton();
btn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_32.png")));
btn.setToolTipText(FastSearchUtil.DEFAULT_EXPANSION_TOOLTIP_MESSAGE);
btn.setAlignmentX(1.0F);
btn.setPreferredSize(new java.awt.Dimension(32, 32));
btn.setAlignmentX(1.0F);
btn.setPreferredSize(new java.awt.Dimension(32, 32));
btn.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
FastSearchUtil.showFastSearchForStringComboBox(cbSets, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
}

View file

@ -444,7 +444,7 @@ public class DeckGeneratorPool
* @return if the ability is tapping to produce the mana the symbol represents.
*/
private boolean landTapsForAllowedColor(String ability, String symbol) {
return ability.matches(".*Add \\{" + symbol + "\\} to your mana pool.");
return ability.matches(".*Add \\{" + symbol + "\\}.");
}
/**

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) {
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);
@ -98,11 +99,11 @@ public class RatioAdjustingSliderPanel extends JPanel {
private void updateSliderPosition(int change, JStorageSlider source) {
int remaining = change;
while (remaining != 0) {
while (remaining != 0) {
// Get the currently indexed slider
JStorageSlider slider = storageSliders.get(sliderIndex);
// If it's not the slider that fired the event
if (slider != source) {
if (slider != source) {
// Check we don't go over the upper and lower bounds
if (remaining < 0 || (remaining > 0 && slider.getValue() > 0)) {
// Adjust the currently selected slider by +/- 1
@ -114,7 +115,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
// Select the next slider in the list of sliders
sliderIndex = (sliderIndex + 1) % storageSliders.size();
}
for (JStorageSlider slider : storageSliders) {
for (JStorageSlider slider : storageSliders) {
slider.setPreviousValue(slider.getValue());
}
}
@ -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);
@ -166,7 +167,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
return sliderPanel;
}
private static JLabel createChangingPercentageLabel(final JSlider slider) {
private static JLabel createChangingPercentageLabel(final JSlider slider) {
final JLabel label = new JLabel(" " + String.valueOf(slider.getValue()) + '%');
@ -174,7 +175,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
String value = String.valueOf(slider.getValue());
StringBuilder labelBuilder = new StringBuilder();
// Pad with spaces so all percentage labels are of equal size
for(int i = 0; i < (5-value.length()); i++) {
for (int i = 0; i < (5 - value.length()); i++) {
labelBuilder.append(" ");
}
labelBuilder.append(value);
@ -186,16 +187,16 @@ public class RatioAdjustingSliderPanel extends JPanel {
@Override
public void setEnabled(boolean enabled) {
for(JStorageSlider slider: sg.getSliders()) {
for (JStorageSlider slider : sg.getSliders()) {
slider.setEnabled(enabled);
}
for(JLabel label: textLabels) {
for (JLabel label : textLabels) {
label.setEnabled(enabled);
}
}
public void resetValues() {
for(JStorageSlider slider: sg.getSliders()) {
for (JStorageSlider slider : sg.getSliders()) {
slider.resetDefault();
}
}
@ -227,7 +228,4 @@ public class RatioAdjustingSliderPanel extends JPanel {
landSlider.previousValue = percentage;
}
}

View file

@ -4,12 +4,6 @@
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="bgView">
</Component>
<Component class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxMenuItem1">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="jCheckBoxMenuItem1"/>
</Properties>
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
@ -27,9 +21,9 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tbColor" alignment="0" max="32767" attributes="0"/>
<Component id="tbTypes" alignment="0" pref="1061" max="32767" attributes="0"/>
<Component id="cardSelectorBottomPanel" alignment="0" pref="1061" max="32767" attributes="0"/>
<Component id="tbTypes" alignment="0" pref="1057" max="32767" attributes="0"/>
<Component id="cardSelectorScrollPane" alignment="0" max="32767" attributes="0"/>
<Component id="cardSelectorBottomPanel" alignment="0" pref="1057" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -857,7 +851,7 @@
</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="Show only the first found card of every card name."/>
<Property name="focusable" type="boolean" value="false"/>

View file

@ -57,8 +57,6 @@ 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.dialog.CheckBoxList;
import mage.client.util.sets.ConstructedFormats;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -86,16 +84,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private final SortSetting sortSetting;
private static final Map<String, Integer> pdAllowed = new HashMap<>();
private final String TEST_MULTI_SET="Multiple Sets selected";
private final ActionListener searchAction = evt -> jButtonSearchActionPerformed(evt);
/**
* Creates new form CardSelector
*/
public CardSelector() {
sortSetting = SortSettingBase.getInstance();
initComponents();
cardGrid = new CardGrid();
@ -103,25 +97,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
initListViewComponents();
setGUISize();
currentView = mainModel; // by default we use List View
listCodeSelected = new CheckBoxList();
// remove the all option
boolean is_removeFinish=false;
String[] setCodes = ConstructedFormats.getTypes();
java.util.List<String> result = new ArrayList<>();
for(int i=0; (i<setCodes.length)&&(!is_removeFinish);i++)
{
String item = setCodes[i];
if(!item.equals(ConstructedFormats.ALL))
{
result.add(item);
}
}
listCodeSelected.setListData(result.toArray());
}
}
private void makeTransparent() {
this.addComponentListener(this);
@ -176,7 +152,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
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, "true")));
chkUnique.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_UNIQUE, "false")));
mainTable.addMouseListener(new MouseAdapter() {
@Override
@ -326,10 +302,11 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
}
}
return filter;
}
private CardCriteria buildCriteria() {
private CardCriteria buildCriteria() {
CardCriteria criteria = new CardCriteria();
criteria.black(this.tbBlack.isSelected());
criteria.blue(this.tbBlue.isSelected());
@ -381,53 +358,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
if (this.cbExpansionSet.isVisible()) {
if(listCodeSelected.getCheckedIndices().length <= 1)
{
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) {
java.util.List<String> setCodes = ConstructedFormats.getSetsByFormat(expansionSelection);
criteria.setCodes(setCodes.toArray(new String[0]));
}
}
else
{
java.util.List<String> setCodes = new ArrayList<>() ;
//java.util.List<String> listReceived=new ArrayList<>() ;
int[] choiseValue=listCodeSelected.getCheckedIndices();
ListModel x= listCodeSelected.getModel();
for(int itemIndex: choiseValue){
java.util.List<String> listReceived=ConstructedFormats.getSetsByFormat(x.getElementAt(itemIndex).toString());
listReceived.stream().filter((item) -> (setCodes.contains(item)==false)).forEachOrdered((item) -> {
setCodes.add(item);
});
}
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) {
java.util.List<String> setCodes = ConstructedFormats.getSetsByFormat(expansionSelection);
criteria.setCodes(setCodes.toArray(new String[0]));
}
}
/*if(cbSetTag!=null)
{
if(listCodeSelected != null)
{
boolean isAtLeastOneSelected=false;
java.util.List<String> setCodes = new ArrayList<>() ;
int[] choiseValue=listCodeSelected.getCheckedIndices();
ListModel x= listCodeSelected.getModel();
for(int itemIndex: choiseValue){
isAtLeastOneSelected=true;
setCodes.add(x.getElementAt(itemIndex).toString());
//LogLog.warn(x.getElementAt(itemIndex).toString());
}
if(isAtLeastOneSelected)
{
criteria.setCodes(setCodes.toArray(new String[0]));
}
}
}*/
return criteria;
}
@ -483,7 +419,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
private void filterCards() {
boolean fist_time =false;
FilterCard filter = buildFilter();
try {
java.util.List<Card> filteredCards = new ArrayList<>();
@ -510,7 +445,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
continue;
}
}
filteredCards.add(card);
filteredCards.add(card);
}
}
}
@ -572,7 +507,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private void initComponents() {
bgView = new javax.swing.ButtonGroup();
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
tbColor = new javax.swing.JToolBar();
tbRed = new javax.swing.JToggleButton();
tbGreen = new javax.swing.JToggleButton();
@ -625,9 +559,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
cardCountLabel = new javax.swing.JLabel();
cardCount = new javax.swing.JLabel();
jCheckBoxMenuItem1.setSelected(true);
jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");
tbColor.setFloatable(false);
tbColor.setRollover(true);
tbColor.setToolTipText("Hold the ALT-key while clicking to deselect all other colors or hold the CTRL-key to select only all other colors.");
@ -1143,7 +1074,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
});
chkUnique.setSelected(true);
chkUnique.setSelected(false);
chkUnique.setText("Unique");
chkUnique.setToolTipText("Show only the first found card of every card name.");
chkUnique.setFocusable(false);
@ -1245,9 +1176,9 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 1061, Short.MAX_VALUE)
.addComponent(cardSelectorBottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1061, Short.MAX_VALUE)
.addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE)
.addComponent(cardSelectorScrollPane)
.addComponent(cardSelectorBottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1263,24 +1194,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}// </editor-fold>//GEN-END:initComponents
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
if(!cbExpansionSet.getSelectedItem().toString().contains(TEST_MULTI_SET))
{
int index=cbExpansionSet.getSelectedIndex();
if(cbExpansionSet.getItemAt(0).contains(TEST_MULTI_SET))
{
cbExpansionSet.removeItemAt(0);
index--;
}
listCodeSelected.uncheckAll();
if(index > 0)
{
//ofset because all sets is removed from the list
listCodeSelected.setChecked(index-1, true);
}
}
filterCards();
}//GEN-LAST:event_cbExpansionSetActionPerformed
@ -1462,7 +1375,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}//GEN-LAST:event_chkRulesActionPerformed
private void btnExpansionSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExpansionSearchActionPerformed
FastSearchUtil.showFastSearchForStringComboBox(listCodeSelected, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
//
int[] choiseValue=listCodeSelected.getCheckedIndices();
@ -1569,10 +1481,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private TableModel mainModel;
private JTable mainTable;
private ICardGrid currentView;
static boolean isFirstTimeHere=true;
private CheckBoxList listCodeSelected;
private javax.swing.JComboBox<String> cbSetTag;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup bgView;
private javax.swing.JButton btnBooster;
@ -1596,7 +1505,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private javax.swing.JButton jButtonRemoveFromMain;
private javax.swing.JButton jButtonRemoveFromSideboard;
private javax.swing.JButton jButtonSearch;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JToolBar.Separator jSeparator1;
private javax.swing.JToolBar.Separator jSeparator2;
private javax.swing.JToolBar.Separator jSeparator3;

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

@ -177,7 +177,7 @@ public final class CollectionViewerPanel extends JPanel {
JCheckBox cardsOrTokens = new JCheckBox("Display Cards");
cardsOrTokens.setSelected(true);
cardsOrTokens.setForeground(Color.white);
cardsOrTokens.setToolTipText("Select to show Cards or Tokens(and emblems) for the chosen set");
cardsOrTokens.setToolTipText("Select to show Cards for the chosen set. When unselected, will show Tokens, Emblems and Planes for the set instead");
cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
buttonsPanel.add(cardsOrTokens);

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.*;
@ -56,11 +57,13 @@ import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.Rarity;
import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.permanent.PermanentToken;
import mage.game.permanent.token.Token;
import mage.view.CardView;
import mage.view.EmblemView;
import mage.view.PermanentView;
import mage.view.PlaneView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.ManaSymbols;
import org.mage.plugins.card.images.CardDownloadData;
@ -201,8 +204,6 @@ public class MageBook extends JComponent {
Image setImage = ManaSymbols.getSetSymbolImage(set);
if (setImage != null) {
tab.setOverlayImage(setImage);
} else {
System.out.println("Couldn't find symbol image: " + set + "-C.jpg");
}
tab.setSet(set);
tab.setBounds(0, y, 39, 120);
@ -250,7 +251,8 @@ public class MageBook extends JComponent {
} else {
updateCardStats(currentSet, false);
int numTokens = showTokens();
showEmblems(numTokens);
int numTokensEmblems = numTokens + showEmblems(numTokens);
int numTokensEmblemsPlanes = numTokens + showPlanes(numTokensEmblems);
}
}
@ -311,16 +313,17 @@ public class MageBook extends JComponent {
}
jLayeredPane.repaint();
return tokens.size();
}
return tokens.size();
return 0;
}
public void showEmblems(int numTokens) {
public int showEmblems(int numTokens) {
List<Emblem> emblems = getEmblems(currentPage, currentSet, numTokens);
// System.out.println ("Size of origins in " + currentSet + " = " + emblems.size());
int numEmblems = 0;
if (emblems != null && emblems.size() > 0) {
int size = emblems.size();
numEmblems = size;
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
// calculate the x offset of the second (right) page
@ -348,6 +351,7 @@ public class MageBook extends JComponent {
lastI++;
}
rectangle.setLocation(second_page_x, OFFSET_Y);
if (size + numTokens > conf.CARDS_PER_PAGE / 2) {
for (int i = lastI; i < size && i + numTokens < conf.CARDS_PER_PAGE; i++) {
Emblem emblem = emblems.get(i);
@ -358,6 +362,54 @@ public class MageBook extends JComponent {
jLayeredPane.repaint();
}
return numEmblems;
}
public int showPlanes(int numTokensEmblems) {
List<Plane> planes = getPlanes(currentPage, currentSet, numTokensEmblems);
int numPlanes = 0;
if (planes != null && planes.size() > 0) {
int size = planes.size();
numPlanes = size;
Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y);
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
numTokensEmblems = numTokensEmblems % conf.CARDS_PER_PAGE;
if (numTokensEmblems < conf.CARDS_PER_PAGE / 2) {
for (int z = 0; z < numTokensEmblems && z < conf.CARDS_PER_PAGE / 2; z++) {
rectangle = CardPosition.translatePosition(z, rectangle, conf);
}
} else {
rectangle.setLocation(second_page_x, OFFSET_Y);
for (int z = 0; z < numTokensEmblems - conf.CARDS_PER_PAGE / 2; z++) {
rectangle = CardPosition.translatePosition(z, rectangle, conf);
}
}
int lastI = 0;
for (int i = 0; i < size && i + numTokensEmblems < conf.CARDS_PER_PAGE / 2; i++) {
Plane plane = planes.get(i);
addPlane(plane, bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i + numTokensEmblems, rectangle, conf);
lastI++;
}
rectangle.setLocation(second_page_x, OFFSET_Y);
if (size + numTokensEmblems > conf.CARDS_PER_PAGE / 2) {
for (int i = lastI; i < size && i + numTokensEmblems < conf.CARDS_PER_PAGE; i++) {
Plane plane = planes.get(i);
addPlane(plane, bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i + numTokensEmblems - conf.CARDS_PER_PAGE / 2, rectangle, conf);
}
}
jLayeredPane.repaint();
}
return numPlanes;
}
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
@ -400,6 +452,7 @@ public class MageBook extends JComponent {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
}
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
newToken.removeSummoningSickness();
PermanentView theToken = new PermanentView(newToken, null, null, null);
theToken.setInViewerOnly(true);
final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true);
@ -414,6 +467,11 @@ public class MageBook extends JComponent {
addCard(cardView, bigCard, gameId, rectangle);
}
private void addPlane(Plane plane, BigCard bigCard, UUID gameId, Rectangle rectangle) {
CardView cardView = new CardView(new PlaneView(plane));
addCard(cardView, bigCard, gameId, rectangle);
}
private List<CardInfo> getCards(int page, String set) {
CardCriteria criteria = new CardCriteria();
criteria.setCodes(set);
@ -500,10 +558,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;
}
}
@ -523,16 +581,25 @@ public class MageBook extends JComponent {
}
int start = page * conf.CARDS_PER_PAGE;
int end = page * conf.CARDS_PER_PAGE + conf.CARDS_PER_PAGE;
if (end > tokens.size()) {
end = tokens.size();
int ttokens = getTotalNumTokens(set);
int temblems = getTotalNumEmblems(set);
int tplanes = getTotalNumPlanes(set);
int numTokensEmblemsPlanes = ttokens + temblems + tplanes;
if (end > numTokensEmblemsPlanes) {
end = numTokensEmblemsPlanes;
}
if (tokens.size() > end) {
if (numTokensEmblemsPlanes > end) {
pageRight.setVisible(true);
}
return tokens.subList(start, end);
end = Math.min(end, ttokens);
if (start < ttokens) {
return tokens.subList(start, end);
}
return null;
}
private List<Emblem> getEmblems(int page, String set, int numTokens) {
private List<Emblem> getEmblems(int page, String set, int numTokensEmblems) {
ArrayList<CardDownloadData> allEmblems = getTokenCardUrls();
ArrayList<Emblem> emblems = new ArrayList<>();
@ -541,7 +608,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;
}
@ -573,21 +640,138 @@ public class MageBook extends JComponent {
}
}
}
int totalTokens = getTotalNumTokens(set);
int start = 0;
if (!(page * conf.CARDS_PER_PAGE <= totalTokens && (page + 1) * conf.CARDS_PER_PAGE >= totalTokens)) {
start = page * conf.CARDS_PER_PAGE - totalTokens;
}
int end = emblems.size();
if ((page + 1) * conf.CARDS_PER_PAGE < numTokens + emblems.size()) {
end = (page + 1) * conf.CARDS_PER_PAGE - numTokens;
pageRight.setVisible(true);
if ((page + 1) * conf.CARDS_PER_PAGE < totalTokens + emblems.size()) {
end = (page + 1) * conf.CARDS_PER_PAGE - totalTokens;
}
if (emblems.size() > conf.CARDS_PER_PAGE) {
pageLeft.setVisible(true);
pageRight.setVisible(true);
}
start = Math.min(start, end);
return emblems.subList(start, end);
}
private List<Plane> getPlanes(int page, String set, int numTokensEmblems) {
ArrayList<CardDownloadData> allPlanes = getTokenCardUrls();
ArrayList<Plane> planes = new ArrayList<>();
for (CardDownloadData plane : allPlanes) {
if (plane.getSet().equals(set)) {
try {
String className = plane.getName();
if (plane.getTokenClassName() != null && plane.getTokenClassName().length() > 0) {
if (plane.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*plane.*")) {
className = plane.getTokenClassName();
className = "mage.game.command.planes." + className;
}
} else {
continue;
}
Class<?> c = Class.forName(className);
Constructor<?> cons = c.getConstructor();
Object newPlane = cons.newInstance();
if (newPlane != null && newPlane instanceof mage.game.command.Plane) {
((Plane) newPlane).setExpansionSetCodeForImage(set);
planes.add((Plane) newPlane);
}
} catch (ClassNotFoundException ex) {
// Swallow exception
} catch (NoSuchMethodException ex) {
// Swallow exception
} catch (SecurityException ex) {
// Swallow exception
} catch (InstantiationException ex) {
// Swallow exception
} catch (IllegalAccessException ex) {
// Swallow exception
} catch (IllegalArgumentException ex) {
// Swallow exception
} catch (InvocationTargetException ex) {
// Swallow exception
}
}
}
int totalTokens = getTotalNumTokens(set);
int totalTokensEmblems = totalTokens + getTotalNumEmblems(set);
int start = 0;
if (!(page * conf.CARDS_PER_PAGE <= totalTokensEmblems && (page + 1) * conf.CARDS_PER_PAGE >= totalTokensEmblems)) {
start = page * conf.CARDS_PER_PAGE - totalTokensEmblems;
pageRight.setVisible(true);
}
int end = planes.size();
if ((page + 1) * conf.CARDS_PER_PAGE < totalTokensEmblems + planes.size()) {
end = (page + 1) * conf.CARDS_PER_PAGE - totalTokensEmblems;
pageRight.setVisible(true);
} else {
pageRight.setVisible(false);
}
if (numTokensEmblems + planes.size() > conf.CARDS_PER_PAGE && page > 0) {
pageLeft.setVisible(true);
}
start = Math.min(start, end);
return planes.subList(start, end);
}
private int getTotalNumTokens(String set) {
ArrayList<CardDownloadData> allTokens = getTokenCardUrls();
int numTokens = 0;
for (CardDownloadData token : allTokens) {
if (token.getSet().equals(set)) {
String className = token.getName();
if (token.getTokenClassName() != null && token.getTokenClassName().length() > 0) {
if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*token.*")) {
numTokens++;
}
}
}
}
return numTokens;
}
private int getTotalNumEmblems(String set) {
ArrayList<CardDownloadData> allEmblems = getTokenCardUrls();
int numEmblems = 0;
for (CardDownloadData emblem : allEmblems) {
if (emblem.getSet().equals(set)) {
String className = emblem.getName();
if (emblem.getTokenClassName() != null && emblem.getTokenClassName().length() > 0) {
if (emblem.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
numEmblems++;
}
}
}
}
return numEmblems;
}
private int getTotalNumPlanes(String set) {
ArrayList<CardDownloadData> allPlanes = getTokenCardUrls();
int numPlanes = 0;
for (CardDownloadData plane : allPlanes) {
if (plane.getSet().equals(set)) {
String className = plane.getName();
if (plane.getTokenClassName() != null && plane.getTokenClassName().length() > 0) {
if (plane.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*plane.*")) {
numPlanes++;
}
}
}
}
return numPlanes;
}
private ImagePanel getImagePanel(String filename, ImagePanelStyle type) {
try {
InputStream is = this.getClass().getResourceAsStream(filename);
@ -666,7 +850,7 @@ public class MageBook extends JComponent {
setPreferredSize(new Dimension(conf.WIDTH, conf.HEIGHT));
setMinimumSize(new Dimension(conf.WIDTH, conf.HEIGHT));
addSetTabs();
showCards();
showCardsOrTokens();
}
/**

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,40 +34,62 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" 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"/>
<Component id="lblLandSet" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblIsland" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblPains" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblSwamp" alignment="1" min="-2" max="-2" 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"/>
<Component id="lblLandSet" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblIsland" alignment="1" min="-2" max="-2" attributes="0"/>
<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" max="-2" attributes="0">
<Component id="ckbFullArtLands" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="btnAutoAdd" alignment="0" pref="85" max="32767" 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"/>
</Group>
</Group>
<Group type="103" groupAlignment="0" 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">
<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>
<EmptySpace max="-2" 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"/>
</Group>
<Component id="panelSet" max="32767" attributes="0"/>
<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>
@ -79,35 +106,54 @@
<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="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 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="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 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="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 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="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 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>
<Component id="lblSwampIcon" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<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"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -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"/>

View file

@ -27,12 +27,13 @@
*/
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;
@ -49,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;
/**
*
@ -59,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;
@ -131,6 +132,27 @@ 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);
}
@ -139,9 +161,7 @@ public class AddLandDialog extends MageDialog {
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");
@ -166,6 +186,7 @@ public class AddLandDialog extends MageDialog {
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;
}
@ -193,20 +214,28 @@ 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();
@ -214,31 +243,67 @@ public class AddLandDialog extends MageDialog {
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);
@ -252,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" }));
@ -285,32 +343,50 @@ public class AddLandDialog extends MageDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMountain)
.addComponent(lblForest, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblLandSet, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblIsland, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPains, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblSwamp, javax.swing.GroupLayout.Alignment.TRAILING))
.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)
.addComponent(lblLandSet, javax.swing.GroupLayout.Alignment.TRAILING)
.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, false)
.addComponent(ckbFullArtLands)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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)
.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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(btnAutoAdd, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.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))))
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addComponent(panelSet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.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)
@ -322,30 +398,44 @@ public class AddLandDialog extends MageDialog {
.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.BASELINE)
.addComponent(lblIsland)
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.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.BASELINE)
.addComponent(lblMountain)
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.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.BASELINE)
.addComponent(lblPains)
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.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))
.addComponent(lblSwampIcon, 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(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(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(btnCancel))
.addContainerGap())
);
pack();
@ -386,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;
}
@ -427,13 +517,21 @@ public class AddLandDialog extends MageDialog {
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

@ -1,680 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* CheckBoxList.java
* Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand
*/
package mage.client.dialog;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.NoSuchElementException;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
/**
* An extended JList that contains CheckBoxes. If necessary a CheckBoxListItem
* wrapper is added around the displayed object in any of the Model methods,
* e.g., addElement. For methods returning objects the opposite takes place, the
* wrapper is removed and only the payload object is returned.
*
* @author fracpete (fracpete at waikato dot ac dot nz)
* @version $Revision: 10219 $
*/
public class CheckBoxList extends JList {
/** for serialization */
private static final long serialVersionUID = -4359573373359270258L;
/**
* represents an item in the CheckBoxListModel
*
* @author fracpete (fracpete at waikato dot ac dot nz)
* @version $Revision: 10219 $
*/
protected class CheckBoxListItem {
/** whether item is checked or not */
private boolean m_Checked = false;
/** the actual object */
private Object m_Content = null;
/**
* initializes the item with the given object and initially unchecked
*
* @param o the content object
*/
public CheckBoxListItem(Object o) {
this(o, false);
}
/**
* initializes the item with the given object and whether it's checked
* initially
*
* @param o the content object
* @param checked whether the item should be checked initially
*/
public CheckBoxListItem(Object o, boolean checked) {
m_Checked = checked;
m_Content = o;
}
/**
* returns the content object
*/
public Object getContent() {
return m_Content;
}
/**
* sets the checked state of the item
*/
public void setChecked(boolean value) {
m_Checked = value;
}
/**
* returns the checked state of the item
*/
public boolean getChecked() {
return m_Checked;
}
/**
* returns the string representation of the content object
*/
@Override
public String toString() {
return m_Content.toString();
}
/**
* returns true if the "payload" objects of the current and the given
* CheckBoxListItem are the same.
*
* @param o the CheckBoxListItem to check
* @throws IllegalArgumentException if the provided object is not a
* CheckBoxListItem
*/
@Override
public boolean equals(Object o) {
if (!(o instanceof CheckBoxListItem)) {
throw new IllegalArgumentException("Must be a CheckBoxListItem!");
}
return getContent().equals(((CheckBoxListItem) o).getContent());
}
}
/**
* A specialized model.
*
* @author fracpete (fracpete at waikato dot ac dot nz)
* @version $Revision: 10219 $
*/
@SuppressWarnings("rawtypes")
public class CheckBoxListModel extends DefaultListModel {
/** for serialization */
private static final long serialVersionUID = 7772455499540273507L;
/**
* initializes the model with no data.
*/
public CheckBoxListModel() {
super();
}
/**
* Constructs a CheckBoxListModel from an array of objects and then applies
* setModel to it.
*
* @param listData the data to use
*/
public CheckBoxListModel(Object[] listData) {
for (Object element : listData) {
addElement(element);
}
}
/**
* Constructs a CheckBoxListModel from a Vector and then applies setModel to
* it.
*/
public CheckBoxListModel(Vector listData) {
for (int i = 0; i < listData.size(); i++) {
addElement(listData.get(i));
}
}
/**
* Inserts the specified element at the specified position in this list.
*
* @param index index at which the specified element is to be inserted
* @param element element to be inserted
*/
@Override
public void add(int index, Object element) {
if (!(element instanceof CheckBoxListItem)) {
super.add(index, new CheckBoxListItem(element));
} else {
super.add(index, element);
}
}
/**
* Adds the specified component to the end of this list.
*
* @param obj the component to be added
*/
@Override
public void addElement(Object obj) {
if (!(obj instanceof CheckBoxListItem)) {
super.addElement(new CheckBoxListItem(obj));
} else {
super.addElement(obj);
}
}
/**
* Tests whether the specified object is a component in this list.
*
* @param elem the element to check
* @return true if the element is in the list
*/
@Override
public boolean contains(Object elem) {
if (!(elem instanceof CheckBoxListItem)) {
return super.contains(new CheckBoxListItem(elem));
} else {
return super.contains(elem);
}
}
/**
* Copies the components of this list into the specified array.
*
* @param anArray the array into which the components get copied
* @throws IndexOutOfBoundsException if the array is not big enough
*/
@Override
public void copyInto(Object[] anArray) {
if (anArray.length < getSize()) {
throw new IndexOutOfBoundsException("Array not big enough!");
}
for (int i = 0; i < getSize(); i++) {
anArray[i] = ((CheckBoxListItem) getElementAt(i)).getContent();
}
}
/**
* Returns the component at the specified index. Throws an
* ArrayIndexOutOfBoundsException if the index is negative or not less than
* the size of the list.
*
* @param index an index into this list
* @return the component at the specified index
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public Object elementAt(int index) {
return ((CheckBoxListItem) super.elementAt(index)).getContent();
}
/**
* Returns the first component of this list. Throws a NoSuchElementException
* if this vector has no components.
*
* @return the first component of this list
* @throws NoSuchElementException
*/
@Override
public Object firstElement() {
return ((CheckBoxListItem) super.firstElement()).getContent();
}
/**
* Returns the element at the specified position in this list.
*
* @param index of element to return
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public Object get(int index) {
return ((CheckBoxListItem) super.get(index)).getContent();
}
/**
* Returns the component at the specified index.
*
* @param index an index into this list
* @return the component at the specified index
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public Object getElementAt(int index) {
return ((CheckBoxListItem) super.getElementAt(index));//.getContent();
}
/**
* Searches for the first occurrence of elem.
*
* @param elem an object
* @return the index of the first occurrence of the argument in this list;
* returns -1 if the object is not found
*/
@Override
public int indexOf(Object elem) {
if (!(elem instanceof CheckBoxListItem)) {
return super.indexOf(new CheckBoxListItem(elem));
} else {
return super.indexOf(elem);
}
}
/**
* Searches for the first occurrence of elem, beginning the search at index.
*
* @param elem the desired component
* @param index the index from which to begin searching
* @return the index where the first occurrence of elem is found after
* index; returns -1 if the elem is not found in the list
*/
@Override
public int indexOf(Object elem, int index) {
if (!(elem instanceof CheckBoxListItem)) {
return super.indexOf(new CheckBoxListItem(elem), index);
} else {
return super.indexOf(elem, index);
}
}
/**
* Inserts the specified object as a component in this list at the specified
* index.
*
* @param obj the component to insert
* @param index where to insert the new component
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public void insertElementAt(Object obj, int index) {
if (!(obj instanceof CheckBoxListItem)) {
super.insertElementAt(new CheckBoxListItem(obj), index);
} else {
super.insertElementAt(obj, index);
}
}
/**
* Returns the last component of the list. Throws a NoSuchElementException
* if this vector has no components.
*
* @return the last component of the list
* @throws NoSuchElementException
*/
@Override
public Object lastElement() {
return ((CheckBoxListItem) super.lastElement()).getContent();
}
/**
* Returns the index of the last occurrence of elem.
*
* @param elem the desired component
* @return the index of the last occurrence of elem in the list; returns -1
* if the object is not found
*/
@Override
public int lastIndexOf(Object elem) {
if (!(elem instanceof CheckBoxListItem)) {
return super.lastIndexOf(new CheckBoxListItem(elem));
} else {
return super.lastIndexOf(elem);
}
}
/**
* Searches backwards for elem, starting from the specified index, and
* returns an index to it.
*
* @param elem the desired component
* @param index the index to start searching from
* @return the index of the last occurrence of the elem in this list at
* position less than index; returns -1 if the object is not found
*/
@Override
public int lastIndexOf(Object elem, int index) {
if (!(elem instanceof CheckBoxListItem)) {
return super.lastIndexOf(new CheckBoxListItem(elem), index);
} else {
return super.lastIndexOf(elem, index);
}
}
/**
* Removes the element at the specified position in this list. Returns the
* element that was removed from the list.
*
* @param index the index of the element to removed
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public Object remove(int index) {
return ((CheckBoxListItem) super.remove(index)).getContent();
}
/**
* Removes the first (lowest-indexed) occurrence of the argument from this
* list.
*
* @param obj the component to be removed
* @return true if the argument was a component of this list; false
* otherwise
*/
@Override
public boolean removeElement(Object obj) {
if (!(obj instanceof CheckBoxListItem)) {
return super.removeElement(new CheckBoxListItem(obj));
} else {
return super.removeElement(obj);
}
}
/**
* Replaces the element at the specified position in this list with the
* specified element.
*
* @param index index of element to replace
* @param element element to be stored at the specified position
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public Object set(int index, Object element) {
if (!(element instanceof CheckBoxListItem)) {
return ((CheckBoxListItem) super.set(index, new CheckBoxListItem(
element))).getContent();
} else {
return ((CheckBoxListItem) super.set(index, element)).getContent();
}
}
/**
* Sets the component at the specified index of this list to be the
* specified object. The previous component at that position is discarded.
*
* @param obj what the component is to be set to
* @param index the specified index
* @throws ArrayIndexOutOfBoundsException
*/
@Override
public void setElementAt(Object obj, int index) {
if (!(obj instanceof CheckBoxListItem)) {
super.setElementAt(new CheckBoxListItem(obj), index);
} else {
super.setElementAt(obj, index);
}
}
/**
* Returns an array containing all of the elements in this list in the
* correct order.
*
* @return an array containing the elements of the list
*/
@Override
public Object[] toArray() {
Object[] result;
Object[] internal;
int i;
internal = super.toArray();
result = new Object[internal.length];
for (i = 0; i < internal.length; i++) {
result[i] = ((CheckBoxListItem) internal[i]).getContent();
}
return result;
}
/**
* returns the checked state of the element at the given index
*
* @param index the index of the element to return the checked state for
* @return the checked state of the specifed element
*/
public boolean getChecked(int index) {
return ((CheckBoxListItem) super.getElementAt(index)).getChecked();
}
/**
* sets the checked state of the element at the given index
*
* @param index the index of the element to set the checked state for
* @param checked the new checked state
*/
public void setChecked(int index, boolean checked) {
((CheckBoxListItem) super.getElementAt(index)).setChecked(checked);
}
}
/**
* A specialized CellRenderer for the CheckBoxList
*
* @author fracpete (fracpete at waikato dot ac dot nz)
* @version $Revision: 10219 $
* @see CheckBoxList
*/
public class CheckBoxListRenderer extends JCheckBox implements
ListCellRenderer {
/** for serialization */
private static final long serialVersionUID = 1059591605858524586L;
/**
* Return a component that has been configured to display the specified
* value.
*
* @param list The JList we're painting.
* @param value The value returned by list.getModel().getElementAt(index).
* @param index The cells index.
* @param isSelected True if the specified cell was selected.
* @param cellHasFocus True if the specified cell has the focus.
* @return A component whose paint() method will render the specified value.
*/
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
setText(value.toString());
setSelected(((CheckBoxList) list).getChecked(index));
setBackground(isSelected ? list.getSelectionBackground() : list
.getBackground());
setForeground(isSelected ? list.getSelectionForeground() : list
.getForeground());
setFocusPainted(false);
return this;
}
}
/**
* initializes the list with an empty CheckBoxListModel
*/
public CheckBoxList() {
this(null);
}
/**
* initializes the list with the given CheckBoxListModel
*
* @param model the model to initialize with
*/
public CheckBoxList(CheckBoxListModel model) {
super();
if (model == null) {
model = this.new CheckBoxListModel();
}
setModel(model);
setCellRenderer(new CheckBoxListRenderer());
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
int index = locationToIndex(e.getPoint());
if (index != -1) {
setChecked(index, !getChecked(index));
repaint();
}
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if ((e.getKeyChar() == ' ') && (e.getModifiers() == 0)) {
int index = getSelectedIndex();
setChecked(index, !getChecked(index));
e.consume();
repaint();
}
}
});
}
/**
* sets the model - must be an instance of CheckBoxListModel
*
* @param model the model to use
* @throws IllegalArgumentException if the model is not an instance of
* CheckBoxListModel
* @see CheckBoxListModel
*/
@Override
public void setModel(ListModel model) {
if (!(model instanceof CheckBoxListModel)) {
if (model instanceof javax.swing.DefaultListModel) {
super.setModel((CheckBoxListModel)model);
}
else {
throw new IllegalArgumentException(
"Model must be an instance of CheckBoxListModel!");
}
}
else {
super.setModel(model);
}
}
/*public void setModel(DefaultListModel model) {
throw new IllegalArgumentException(
"Model must be an ins12313tance of CheckBoxListModel!");
}*/
/**
* Constructs a CheckBoxListModel from an array of objects and then applies
* setModel to it.
*
* @param listData the data to use
*/
@Override
public void setListData(Object[] listData) {
setModel(new CheckBoxListModel(listData));
}
/**
* Constructs a CheckBoxListModel from a Vector and then applies setModel to
* it.
*/
@Override
public void setListData(@SuppressWarnings("rawtypes") Vector listData) {
setModel(new CheckBoxListModel(listData));
}
/**
* returns the checked state of the element at the given index
*
* @param index the index of the element to return the checked state for
* @return the checked state of the specifed element
*/
public boolean getChecked(int index) {
return ((CheckBoxListModel) getModel()).getChecked(index);
}
/**
* sets the checked state of the element at the given index
*
* @param index the index of the element to set the checked state for
* @param checked the new checked state
*/
public void setChecked(int index, boolean checked) {
((CheckBoxListModel) getModel()).setChecked(index, checked);
}
/**
* returns an array with the indices of all checked items
*
* @return the indices of all items that are currently checked
*/
public int[] getCheckedIndices() {
Vector<Integer> list;
int[] result;
int i;
// traverse over model
list = new Vector<Integer>();
for (i = 0; i < getModel().getSize(); i++) {
if (getChecked(i)) {
list.add(new Integer(i));
}
}
// generate result array
result = new int[list.size()];
for (i = 0; i < list.size(); i++) {
result[i] = list.get(i).intValue();
}
return result;
}
public void checkAll() {
for (int i = 0; i < getModel().getSize(); i++) {
this.setChecked(i,true);
}
}
public void uncheckAll() {
int[] choiceToUncheck = this.getCheckedIndices();
for(int itemIndex: choiceToUncheck){
this.setChecked(itemIndex,false);
}
}
}

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

@ -24,15 +24,14 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.client.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

@ -44,6 +44,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="chkSpectatorsAllowed" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
<Component id="chkPlaneChase" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="txtName" min="-2" pref="178" max="-2" attributes="0"/>
@ -156,6 +158,7 @@
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkRollbackTurnsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkSpectatorsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkPlaneChase" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
@ -284,6 +287,12 @@
<Property name="toolTipText" type="java.lang.String" value="Allow spectators to view your game."/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="chkPlaneChase">
<Properties>
<Property name="text" type="java.lang.String" value="Use PlaneChase"/>
<Property name="toolTipText" type="java.lang.String" value="Use the PlaneChase variant for your game."/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnFreeMulligans">
</Component>

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
*/
@ -103,6 +102,7 @@ public class NewTableDialog extends MageDialog {
cbGameType = new javax.swing.JComboBox();
chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
chkSpectatorsAllowed = new javax.swing.JCheckBox();
chkPlaneChase = new javax.swing.JCheckBox();
chkRated = new javax.swing.JCheckBox();
lblFreeMulligans = new javax.swing.JLabel();
spnFreeMulligans = new javax.swing.JSpinner();
@ -143,7 +143,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:");
@ -155,6 +155,9 @@ public class NewTableDialog extends MageDialog {
chkSpectatorsAllowed.setText("Allow Spectators");
chkSpectatorsAllowed.setToolTipText("<HTML>Allow spectators to watch.\n");
chkPlaneChase.setText("Use PlaneChase");
chkPlaneChase.setToolTipText("<HTML>Use planechase variant (suitable for all game types).\n");
chkRated.setText("Rated");
chkRated.setToolTipText("Indicates if matches will be rated.");
@ -237,7 +240,9 @@ public class NewTableDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13)
.addComponent(chkSpectatorsAllowed))
.addComponent(chkSpectatorsAllowed)
.addGap(13, 13, 13)
.addComponent(chkPlaneChase))
.addGroup(layout.createSequentialGroup()
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -332,7 +337,8 @@ public class NewTableDialog extends MageDialog {
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans)
.addComponent(chkRollbackTurnsAllowed)
.addComponent(chkSpectatorsAllowed))
.addComponent(chkSpectatorsAllowed)
.addComponent(chkPlaneChase))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType)))
@ -409,6 +415,7 @@ public class NewTableDialog extends MageDialog {
options.setWinsNeeded((Integer) this.spnNumWins.getValue());
options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected());
options.setSpectatorsAllowed(chkSpectatorsAllowed.isSelected());
options.setPlaneChase(chkPlaneChase.isSelected());
options.setRated(chkRated.isSelected());
options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
options.setPassword(this.txtPassword.getText());
@ -623,17 +630,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) {
versionStr = "1";
btnPreviousConfiguration1.requestFocus();
} else if (currentSettingVersion == 2) {
versionStr = "2";
btnPreviousConfiguration2.requestFocus();
} else {
btnPreviousConfiguration2.getParent().requestFocus();
switch (currentSettingVersion) {
case 1:
versionStr = "1";
btnPreviousConfiguration1.requestFocus();
break;
case 2:
versionStr = "2";
btnPreviousConfiguration2.requestFocus();
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, ""));
@ -667,6 +679,7 @@ public class NewTableDialog extends MageDialog {
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, "2")));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, "Yes").equals("Yes"));
this.chkSpectatorsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, "Yes").equals("Yes"));
this.chkPlaneChase.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, "No").equals("Yes"));
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, "No").equals("Yes"));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
@ -724,6 +737,8 @@ 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_PLANECHASE + versionStr, options.isPlaneChase() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
StringBuilder playerTypesString = new StringBuilder();
for (Object player : players) {
@ -749,6 +764,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
private javax.swing.JCheckBox chkSpectatorsAllowed;
private javax.swing.JCheckBox chkPlaneChase;
private javax.swing.JCheckBox chkRated;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;

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;
@ -589,9 +592,9 @@ public class NewTournamentDialog extends MageDialog {
} else {
for (JPanel panel : packPanels) {
JComboBox combo = findComboInComponent(panel);
if(combo != null) {
if (combo != null) {
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) combo.getSelectedItem()).getCode());
}else{
} else {
logger.error("Can't find combo component in " + panel.toString());
}
}
@ -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()) {
@ -926,7 +928,7 @@ public class NewTournamentDialog extends MageDialog {
public void actionPerformed(java.awt.event.ActionEvent evt) {
// search combo box near button (must be only one combo in panel)
JButton button = (JButton)evt.getSource();
JButton button = (JButton) evt.getSource();
JComboBox combo = findComboInComponent(button.getParent());
if (combo != null) {
@ -941,12 +943,12 @@ public class NewTournamentDialog extends MageDialog {
this.repaint();
}
private JComboBox findComboInComponent(Container panel){
private JComboBox findComboInComponent(Container panel) {
// search combo box near button (must be only one combo in panel)
JComboBox combo = null;
for(Component comp: panel.getComponents()){
if (comp instanceof JComboBox){
combo = (JComboBox)comp;
for (Component comp : panel.getComponents()) {
if (comp instanceof JComboBox) {
combo = (JComboBox) comp;
break;
}
}
@ -955,21 +957,21 @@ public class NewTournamentDialog extends MageDialog {
private void packActionPerformed(java.awt.event.ActionEvent evt) {
// fill all bottom combobox with same value
JComboBox curentCombo = (JComboBox)evt.getSource();
JComboBox curentCombo = (JComboBox) evt.getSource();
int newValue = curentCombo.getSelectedIndex();
// search start index
int startIndex = 0;
for(int i = 0; i < packPanels.size(); i++){
for (int i = 0; i < packPanels.size(); i++) {
JComboBox pack = findComboInComponent(packPanels.get(i));
if (pack.equals(curentCombo)){
if (pack.equals(curentCombo)) {
startIndex = i + 1;
break;
}
}
// change all from start index
for(int i = startIndex; i < packPanels.size(); i++){
for (int i = startIndex; i < packPanels.size(); i++) {
JComboBox pack = findComboInComponent(packPanels.get(i));
pack.setSelectedIndex(newValue);
}
@ -1128,7 +1130,7 @@ public class NewTournamentDialog extends MageDialog {
break;
}
}
}else{
} else {
logger.error("Can't find combo component in " + panel.toString());
}
}
@ -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

@ -22,22 +22,14 @@
<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"/>
</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"/>
<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>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -45,46 +37,21 @@
<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.setCursor(null );
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))
.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))))
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
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

@ -95,10 +95,10 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="main_game" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_gamelog" min="-2" pref="107" max="-2" attributes="0"/>
<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="121" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -200,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">
@ -295,16 +295,22 @@
<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="showPlayerNamesPermanently" alignment="0" max="32767" attributes="0"/>
<Component id="nonLandPermanentsInOnePile" alignment="0" max="32767" attributes="0"/>
<Component id="cbConfirmEmptyManaPool" alignment="0" max="32767" attributes="0"/>
<Component id="cbAllowRequestToShowHandCards" alignment="0" max="32767" attributes="0"/>
<Component id="cbShowStormCounter" alignment="0" max="32767" attributes="0"/>
<Component id="cbAskMoveToGraveOrder" alignment="0" max="32767" attributes="0"/>
<Component id="showAbilityPickerForced" alignment="0" max="32767" 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"/>
<Component id="cbConfirmEmptyManaPool" alignment="0" max="32767" attributes="0"/>
<Component id="cbAllowRequestToShowHandCards" alignment="0" max="32767" attributes="0"/>
<Component id="cbShowStormCounter" alignment="0" max="32767" attributes="0"/>
<Component id="cbAskMoveToGraveOrder" alignment="0" max="32767" attributes="0"/>
<Component id="showAbilityPickerForced" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="displayLifeOnAvatar" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="177" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -315,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"/>
@ -324,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>
@ -354,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"/>
@ -4274,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>
@ -4847,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>

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;
@ -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";
@ -236,6 +238,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins";
public static final String KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED = "newTableRollbackTurnsAllowed";
public static final String KEY_NEW_TABLE_SPECTATORS_ALLOWED = "newTableSpectatorsAllowed";
public static final String KEY_NEW_TABLE_PLANECHASE = "newTablePlaneChase";
public static final String KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans";
public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile";
public static final String KEY_NEW_TABLE_RANGE = "newTableRange";
@ -421,6 +424,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();
@ -700,7 +704,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)
@ -741,6 +745,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.");
@ -797,15 +811,19 @@ 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, 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)
.add(cbConfirmEmptyManaPool, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(cbAllowRequestToShowHandCards, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.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(177, Short.MAX_VALUE))
.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)
.add(cbConfirmEmptyManaPool, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(cbAllowRequestToShowHandCards, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.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))
.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)
@ -814,6 +832,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)
@ -822,8 +842,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");
@ -880,10 +899,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(main_game, 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_gamelog, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.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(121, Short.MAX_VALUE))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
main_card.getAccessibleContext().setAccessibleName("Game panel");
@ -1797,7 +1816,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);
@ -2372,7 +2391,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())
);
@ -2762,6 +2781,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);
@ -3225,6 +3245,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
}//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) {
@ -3331,6 +3355,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");
@ -3469,7 +3494,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));
@ -3928,6 +3953,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

@ -33,6 +33,25 @@
*/
package mage.client.game;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.cards.MagePermanent;
import mage.client.cards.BigCard;
import mage.client.cards.Permanent;
@ -45,16 +64,6 @@ import mage.client.util.layout.impl.OldCardLayoutStrategy;
import mage.view.CounterView;
import mage.view.PermanentView;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
/**
*
* @author BetaSteward_at_googlemail.com
@ -155,12 +164,13 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
} else {
if (!changed) {
changed = oldMagePermanent.getOriginalPermanent().isCreature() != permanent.isCreature();
// Check if there was a chnage in the permanets that are the permanent attached to
if (!changed) {
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
int s2 = oldMagePermanent.getLinks().size();
if (s1 != s2) {
int attachments = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
int attachmentsBefore = oldMagePermanent.getLinks().size();
if (attachments != attachmentsBefore) {
changed = true;
} else if (s1 > 0) {
} else if (attachments > 0) {
Set<UUID> attachmentIds = new HashSet<>(permanent.getAttachments());
for (MagePermanent magePermanent : oldMagePermanent.getLinks()) {
if (!attachmentIds.contains(magePermanent.getOriginalPermanent().getId())) {
@ -174,14 +184,16 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
}
}
}
// Check if permanents it now attached to another or no permanent
if (!changed) {
UUID u1 = oldMagePermanent.getOriginalPermanent().getAttachedTo();
UUID u2 = permanent.getAttachedTo();
if (u1 == null && u2 != null || u2 == null && u1 != null
|| (u1 != null && !u1.equals(u2))) {
UUID attachedToIdBefore = oldMagePermanent.getOriginalPermanent().getAttachedTo();
UUID attachedToId = permanent.getAttachedTo();
if (attachedToIdBefore == null && attachedToId != null || attachedToId == null && attachedToIdBefore != null
|| (attachedToIdBefore != null && !attachedToIdBefore.equals(attachedToId))) {
changed = true;
}
}
// Check for changes in the counters of the permanent
if (!changed) {
List<CounterView> counters1 = oldMagePermanent.getOriginalPermanent().getCounters();
List<CounterView> counters2 = permanent.getCounters();

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;
@ -117,6 +113,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private int avatarId = -1;
private String flagName;
private String basicTooltipText;
private static final Map<UUID, Integer> playerLives = new HashMap<>();
private PriorityTimer timer;
@ -179,8 +176,32 @@ public class PlayerPanelExt extends javax.swing.JPanel {
public void update(PlayerView player) {
this.player = player;
updateAvatar();
int pastLife = player.getLife();
if (playerLives != null) {
if (playerLives.containsKey(player.getPlayerId())) {
pastLife = playerLives.get(player.getPlayerId());
}
playerLives.put(player.getPlayerId(), player.getLife());
}
int playerLife = player.getLife();
boolean displayLife = "true".equals(MageFrame.getPreferences().get(PreferencesDialog.KEY_DISPLAY_LIVE_ON_AVATAR, "true"));
avatar.setCenterText(displayLife ? String.valueOf(playerLife) : null);
if (displayLife) {
if (playerLife != pastLife) {
if (playerLife > pastLife) {
avatar.gainLifeDisplay();
} else if (playerLife < pastLife) {
avatar.loseLifeDisplay();
}
} else if (playerLife == pastLife) {
avatar.stopLifeDisplay();
}
}
updateAvatar();
if (playerLife > 99) {
Font font = lifeLabel.getFont();
font = font.deriveFont(9f);
@ -701,8 +722,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 +843,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 +902,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 +931,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

@ -2,7 +2,6 @@ package mage.client.plugins;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import javax.swing.*;
@ -33,7 +32,7 @@ public interface MagePlugins {
boolean isCounterPluginLoaded();
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, boolean topRow);
int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> permanents, boolean topRow);
void downloadSymbols();

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

@ -3,12 +3,10 @@ package mage.client.plugins.impl;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.cards.MageCard;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
@ -30,9 +28,8 @@ import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import org.apache.log4j.Logger;
import org.mage.plugins.card.CardPluginImpl;
import org.mage.plugins.theme.ThemePluginImpl;
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
import org.mage.plugins.theme.ThemePluginImpl;
public enum Plugins implements MagePlugins {
instance;
@ -47,7 +44,6 @@ public enum Plugins implements MagePlugins {
private static final MageActionCallback mageActionCallback = new MageActionCallback();
private final Map<String, String> sortingOptions = new HashMap<>();
@Override
public void loadPlugins() {
@ -125,7 +121,7 @@ public enum Plugins implements MagePlugins {
}
@Override
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, boolean topRow) {
public int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> permanents, boolean topRow) {
if (this.cardPlugin != null) {
return this.cardPlugin.sortPermanents(ui, permanents, PreferencesDialog.getCachedValue("nonLandPermanentsInOnePile", "false").equals("true"), topRow);
}

View file

@ -24,25 +24,24 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
/*
/*
* NewPlayerPanel.java
*
* 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,9 +113,8 @@ public class NewPlayerPanel extends javax.swing.JPanel {
this.txtPlayerDeck.setText(deckFile);
}
public int getLevel() {
return (Integer)spnLevel.getValue();
return (Integer) spnLevel.getValue();
}
public void showLevel(boolean show) {
@ -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;
@ -237,10 +237,10 @@ class DeckFilter extends FileFilter {
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i + 1).toLowerCase(Locale.ENGLISH);
}
return (ext==null)?false:ext.equals("dck");
return (ext == null) ? false : ext.equals("dck");
}
@Override
@ -248,4 +248,4 @@ class DeckFilter extends FileFilter {
return "Deck Files";
}
}
}

View file

@ -60,6 +60,7 @@ 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.*;
@ -579,7 +580,7 @@ public class TablesPanel extends javax.swing.JPanel {
this.jPanelBottom.setVisible(false);
} else {
this.jPanelBottom.setVisible(true);
this.jLabelFooterText.setText(serverMessages.get(0));
URLHandler.handleMessage(serverMessages.get(0), this.jLabelFooterText);
this.jButtonFooterNext.setVisible(serverMessages.size() > 1);
}
}
@ -1283,7 +1284,9 @@ public class TablesPanel extends javax.swing.JPanel {
if (currentMessage >= messages.size()) {
currentMessage = 0;
}
this.jLabelFooterText.setText(messages.get(currentMessage));
URLHandler.RemoveMouseAdapter(jLabelFooterText);
URLHandler.handleMessage(messages.get(currentMessage), this.jLabelFooterText);
}
}
}//GEN-LAST:event_jButtonFooterNextActionPerformed

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

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.client.util;
import java.util.List;
@ -44,7 +43,7 @@ public final class CardsViewUtil {
public static CardsView convertSimple(SimpleCardsView view) {
CardsView cards = new CardsView();
for (SimpleCardView simple: view.values()) {
for (SimpleCardView simple : view.values()) {
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
if (card != null) {
@ -54,15 +53,14 @@ public final class CardsViewUtil {
return cards;
}
public static CardsView convertSimple(SimpleCardsView view, Map<String, Card> loadedCards) {
CardsView cards = new CardsView();
for (SimpleCardView simple: view.values()) {
for (SimpleCardView simple : view.values()) {
String key = simple.getExpansionSetCode() + '_' + simple.getCardNumber();
Card card = loadedCards.get(key);
if(card == null)
{
if (card == null) {
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
card = cardInfo != null ? cardInfo.getMockCard() : null;
loadedCards.put(key, card);
@ -79,12 +77,15 @@ public final class CardsViewUtil {
CardsView cards = new CardsView();
for (CommandObjectView commandObject : view) {
if(commandObject instanceof EmblemView ){
CardView cardView = new CardView((EmblemView)commandObject);
if (commandObject instanceof EmblemView) {
CardView cardView = new CardView((EmblemView) commandObject);
cards.put(commandObject.getId(), cardView);
}
else if(commandObject instanceof CommanderView ){
cards.put(commandObject.getId(),(CommanderView)commandObject);
} else if (commandObject instanceof PlaneView) {
CardView cardView = null;
cardView = new CardView((PlaneView) commandObject);
cards.put(commandObject.getId(), cardView);
} else if (commandObject instanceof CommanderView) {
cards.put(commandObject.getId(), (CommanderView) commandObject);
}
}

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

@ -0,0 +1,117 @@
/*
* 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 mage.client.util;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JLabel;
/**
*
* @author Dahny
*/
public class URLHandler {
private static MouseAdapter currentMouseAdapter;
/**
* This method makes a URL in a message click-able and converts the message
* into HTML.
*
* @param message: The selected message
* @param label: The message of the day label
*/
public static void handleMessage(String message, JLabel label) {
String url = detectURL(message);
if (!url.equals("")) {
label.addMouseListener(createMouseAdapter(url));
}
label.setText(convertToHTML(message));
}
public static void RemoveMouseAdapter(JLabel label) {
label.removeMouseListener(currentMouseAdapter);
currentMouseAdapter = null;
}
private static MouseAdapter createMouseAdapter(String url) {
currentMouseAdapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 0) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
URI uri = new URI(url);
desktop.browse(uri);
} catch (IOException | URISyntaxException ex) {
// do nothing
}
}
}
}
};
return currentMouseAdapter;
}
public static String convertToHTML(String input) {
String s = input;
String output = "<html>";
// separate the input by spaces
String[] parts = s.split("\\s+");
for (String item : parts) {
try {
URL url = new URL(item);
// The item is already a valid URL
output = output + "<a href=\"" + url + "\">" + url + "</a> ";
} catch (MalformedURLException e) {
//The item might still be a URL
if (item.startsWith("www.")) {
output = output + "<a href=\"" + item + "\">" + item + "</a> ";
} else {
output = output + item + " ";
}
}
}
output = output + "</html>";
return output;
}
public static String detectURL(String input) {
String s = input;
String output = "";
// separate the input by spaces
String[] parts = s.split("\\s+");
for (String item : parts) {
try {
URL url = new URL(item);
// The item is already a valid URL
output = url.toString();
} catch (MalformedURLException e) {
//The item might still be a URL
if (item.startsWith("www.")) {
output = "http://" + item;
}
}
}
return output;
}
}

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,16 +45,12 @@ public class ArrowBuilder {
* Get the panel where all arrows are being drawn.
* @return
*/
public JPanel getArrowsManagerPanel() {
public synchronized JPanel getArrowsManagerPanel() {
if (arrowsManagerPanel == null) {
synchronized (ArrowBuilder.class) {
if (arrowsManagerPanel == null) {
arrowsManagerPanel = new JPanel();
arrowsManagerPanel.setVisible(true);
arrowsManagerPanel.setOpaque(false);
arrowsManagerPanel.setLayout(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

@ -4,23 +4,20 @@ import mage.choices.ChoiceImpl;
import mage.client.dialog.PickCheckBoxDialog;
import mage.client.dialog.PickChoiceDialog;
//import java.util.ArrayList;
import mage.client.dialog.CheckBoxList;
import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
//import javax.swing.text.Position;
//import org.apache.log4j.helpers.LogLog;
/**
*
* @author JayDi85
*/
public class FastSearchUtil {
public static String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set(s) or expansion(s)";
public static String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set(s) or expansion(s)";
public class FastSearchUtil {
public static String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set or expansion";
public static String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set or expansion";
/**
* Show fast choice modal dialog with incremental searching for any string combobox components
@ -72,10 +69,10 @@ public class FastSearchUtil {
* Show fast choice modal dialog with incremental searching for any string CheckBoxList components
* @param combo CheckBoxList control with default data model
* @param chooseMessage caption message for dialog
*/
*/
public static void showFastSearchForStringComboBox(CheckBoxList combo, String chooseMessage){
// fast search/choice dialog for string combobox
// fast search/choice dialog for string combobox
mage.choices.Choice choice = new ChoiceImpl(false);
// collect data from expansion combobox (String)
@ -86,11 +83,10 @@ public class FastSearchUtil {
for(int i = 0; i < comboModel.size(); i++){
item = comboModel.getElementAt(i).toString();
choiceItems.put(item, item);
choiceSorting.put(item, i); // need so sorting
}
choice.setKeyChoices(choiceItems);
choice.setSortData(choiceSorting);
choice.setMessage(chooseMessage);
@ -100,10 +96,12 @@ public class FastSearchUtil {
needSelectValue = comboModel.firstElement().toString();
// ask for new value
PickCheckBoxDialog dlg = new PickCheckBoxDialog(combo);
dlg.setWindowSize(300, 500);
dlg.showDialog(choice, needSelectValue);
if(choice.isChosen()){
if(choice.isChosen()){
item = choice.getChoiceKey();
// compatible select for object's models (use setSelectedIndex instead setSelectedObject)
@ -113,14 +111,5 @@ public class FastSearchUtil {
}
}
}
/*
int[] choiseValue=combo.getCheckedIndices();
ListModel x= combo.getModel();
for(int itemIndex: choiseValue){
LogLog.warn(String.format("%d:%s",itemIndex,x.getElementAt(itemIndex).toString()));
}
*/
}
}

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,6 +1,7 @@
package mage.client.util.layout.impl;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.Map;
import java.util.UUID;
@ -30,72 +31,167 @@ public class OldCardLayoutStrategy implements CardLayoutStrategy {
*/
private static final int ATTACHMENT_MIN_DY_OFFSET = 12;
final class AttachmentLayoutInfos {
private int columns;
private int attachments;
public AttachmentLayoutInfos(int columns, int attachments) {
this.columns = columns;
this.attachments = attachments;
}
public int getColumns() {
return columns;
}
public int getAttachments() {
return attachments;
}
public void increaseAttachments() {
attachments++;
}
public void increaseColumns() {
columns++;
}
}
@Override
public void doLayout(BattlefieldPanel battlefieldPanel, int width) {
Map<UUID, MagePermanent> permanents = battlefieldPanel.getPermanents();
JLayeredPane jPanel = battlefieldPanel.getMainPanel();
JLayeredPane mainPanel = battlefieldPanel.getMainPanel();
int height = Plugins.instance.sortPermanents(battlefieldPanel.getUiComponentsList(), permanents.values(), battlefieldPanel.isTopPanelBattlefield());
jPanel.setPreferredSize(new Dimension(width - 30, height));
// does the basic layout of rows and colums
int height = Plugins.instance.sortPermanents(battlefieldPanel.getUiComponentsList(), permanents, battlefieldPanel.isTopPanelBattlefield());
mainPanel.setPreferredSize(new Dimension(width - 30, height));
for (PermanentView permanent : battlefieldPanel.getBattlefield().values()) {
if (permanent.getAttachments() != null) {
groupAttachments(battlefieldPanel, jPanel, permanents, permanent);
if (permanent.getAttachments() != null && !permanent.isAttachedTo()) { // Layout only permanents that are not attached to other permanents itself
groupAttachments(battlefieldPanel, mainPanel, permanents, permanent);
}
}
}
private void groupAttachments(JLayeredPane jLayeredPane, JLayeredPane jPanel, Map<UUID, MagePermanent> permanents, PermanentView permanent) {
MagePermanent perm = permanents.get(permanent.getId());
if (perm == null) {
private void groupAttachments(BattlefieldPanel battlefieldPanel, JLayeredPane mainPanel, Map<UUID, MagePermanent> permanents, PermanentView permanentWithAttachmentsView) {
MagePermanent permWithAttachments = permanents.get(permanentWithAttachmentsView.getId());
if (permWithAttachments == null) {
return;
}
int position = jLayeredPane.getPosition(perm);
perm.getLinks().clear();
Rectangle rectangleBaseCard = perm.getBounds();
// Calculate how many vertical columns are needed and number of attachements
AttachmentLayoutInfos attachmentLayoutInfos = calculateNeededNumberOfVerticalColumns(0, battlefieldPanel, permanents, permanentWithAttachmentsView);
int position = battlefieldPanel.getPosition(permWithAttachments); // relative position within the layer
// permWithAttachments.getLinks().clear();
Rectangle rectangleBaseCard = permWithAttachments.getBounds();
if (!Plugins.instance.isCardPluginLoaded()) {
for (UUID attachmentId : permanent.getAttachments()) {
permWithAttachments.getLinks().clear();
for (UUID attachmentId : permanentWithAttachmentsView.getAttachments()) {
MagePermanent link = permanents.get(attachmentId);
if (link != null) {
perm.getLinks().add(link);
permWithAttachments.getLinks().add(link);
rectangleBaseCard.translate(20, 20);
link.setBounds(rectangleBaseCard);
jLayeredPane.setPosition(link, ++position);
battlefieldPanel.setPosition(link, ++position);
}
}
} else {
int index = permanent.getAttachments().size();
for (UUID attachmentId : permanent.getAttachments()) {
MagePermanent link = permanents.get(attachmentId);
if (link != null) {
link.setBounds(rectangleBaseCard);
perm.getLinks().add(link);
int dyOffset = Math.max(perm.getHeight() / 10, ATTACHMENT_MIN_DY_OFFSET);
if (index == 1) {
rectangleBaseCard.translate(Math.max(perm.getWidth() / 10, ATTACHMENTS_MIN_DX_OFFSET), dyOffset); // do it once
} else {
rectangleBaseCard.translate(0, dyOffset);
}
perm.setBounds(rectangleBaseCard);
jLayeredPane.moveToFront(link);
jLayeredPane.moveToFront(perm);
jPanel.setComponentZOrder(link, index);
index--;
}
}
jPanel.setComponentZOrder(perm, index);
layoutAttachements(rectangleBaseCard.getX(), attachmentLayoutInfos.getColumns(),
attachmentLayoutInfos.getAttachments(), permanentWithAttachmentsView, permanents, battlefieldPanel, mainPanel, rectangleBaseCard);
mainPanel.setComponentZOrder(permWithAttachments, 0);
}
}
private void layoutAttachements(double baseX, // basic x position
int maxCul, // number of attachments levels
int ZOrder,
PermanentView permanentWithAttachmentsView,
Map<UUID, MagePermanent> permanents,
BattlefieldPanel battlefieldPanel,
JLayeredPane mainPanel,
Rectangle rectangleBaseCard) {
MagePermanent permWithAttachments = permanents.get(permanentWithAttachmentsView.getId());
if (permWithAttachments == null) {
return;
}
int col = getVerticalCul(permanentWithAttachmentsView, battlefieldPanel); // from right to left [2][1][0]
int currentAttachmentCol = col + 1;
permWithAttachments.getLinks().clear();
int VerticalIndex = permanentWithAttachmentsView.getAttachments().size();
for (UUID attachmentId : permanentWithAttachmentsView.getAttachments()) {
PermanentView attachedPermanentView = battlefieldPanel.getBattlefield().get(attachmentId);
if (attachedPermanentView != null && attachedPermanentView.getAttachments() != null && !attachedPermanentView.getAttachments().isEmpty()) {
layoutAttachements(baseX, maxCul, ZOrder, attachedPermanentView, permanents, battlefieldPanel, mainPanel, rectangleBaseCard);
}
MagePermanent attachedPermanent = permanents.get(attachmentId);
if (attachedPermanent != null) {
// reset x position
Point point = new Point();
point.setLocation(baseX + (maxCul - currentAttachmentCol) * Math.max(permWithAttachments.getWidth() / 10, ATTACHMENTS_MIN_DX_OFFSET), rectangleBaseCard.getY());
rectangleBaseCard.setLocation(point);
attachedPermanent.setBounds(rectangleBaseCard); // set position first to the same as of the permanent it is attached to
permWithAttachments.getLinks().add(attachedPermanent);
int dyOffset = Math.max(permWithAttachments.getHeight() / 10, ATTACHMENT_MIN_DY_OFFSET); // calculate y offset
if (VerticalIndex == 1) {
rectangleBaseCard.translate(Math.max(permWithAttachments.getWidth() / 10, ATTACHMENTS_MIN_DX_OFFSET), dyOffset); // do it once
} else {
rectangleBaseCard.translate(0, dyOffset);
}
permWithAttachments.setBounds(rectangleBaseCard);
battlefieldPanel.moveToFront(attachedPermanent);
battlefieldPanel.moveToFront(permWithAttachments);
mainPanel.setComponentZOrder(attachedPermanent, ZOrder--);
VerticalIndex--;
}
}
}
private AttachmentLayoutInfos calculateNeededNumberOfVerticalColumns(int currentCol, BattlefieldPanel battlefieldPanel, Map<UUID, MagePermanent> permanents, PermanentView permanentWithAttachmentsView) {
int maxCol = ++currentCol;
int attachments = 0;
for (UUID attachmentId : permanentWithAttachmentsView.getAttachments()) {
PermanentView attachedPermanent = battlefieldPanel.getBattlefield().get(attachmentId);
if (attachedPermanent != null) {
attachments++;
if (attachedPermanent.getAttachments() != null && !attachedPermanent.getAttachments().isEmpty()) {
AttachmentLayoutInfos attachmentLayoutInfos = calculateNeededNumberOfVerticalColumns(currentCol, battlefieldPanel, permanents, attachedPermanent);
if (attachmentLayoutInfos.getColumns() > maxCol) {
maxCol = attachmentLayoutInfos.getColumns();
attachments += attachmentLayoutInfos.getAttachments();
}
}
}
}
return new AttachmentLayoutInfos(maxCol, attachments);
}
// The root permanent is col 0. An attachment attached to the root is col 1. And an attachement attached to the first attachment is col 2. etc.
private int getVerticalCul(PermanentView permanentView, BattlefieldPanel battlefieldPanel) {
int cul = 0;
if (permanentView.isAttachedTo()) {
PermanentView attachedToPermanent = battlefieldPanel.getBattlefield().get(permanentView.getAttachedTo());
if (attachedToPermanent != null) {
cul = getVerticalCul(attachedToPermanent, battlefieldPanel);
}
cul++;
}
return cul;
}
@Override
public int getDefaultZOrder() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void onAdd(BattlefieldPanel jLayeredPane) {
public void onAdd(BattlefieldPanel jLayeredPane
) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

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

@ -625,9 +625,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
if (gameCard.hideInfo()) {
return;
}
if (this.contains(e.getPoint())) {
return;
}
if (tooltipShowing) {
synchronized (this) {
if (tooltipShowing) {

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

@ -31,16 +31,21 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
import javax.imageio.ImageIO;
import javax.swing.*;
import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame;
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;
@ -56,7 +61,7 @@ public final class ManaSymbols {
private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
private static final Map<Integer, Map<String, BufferedImage>> manaImages = new HashMap<>();
private static final Map<String, Map<String, Image>> setImages = new HashMap<>();
private static final Map<String, Map<String, Image>> setImages = new ConcurrentHashMap<>();
private static final HashSet<String> onlyMythics = new HashSet<>();
private static final HashSet<String> withoutSymbols = new HashSet<>();
@ -76,7 +81,7 @@ 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", "BP", "2B",
"G", "GU", "GW", "GP", "2G",
@ -166,37 +171,39 @@ public final class ManaSymbols {
} catch (Exception e) {
}
}
// generate small size
try {
File file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM));
if (!file.exists()) {
file.mkdirs();
}
String pathRoot = getResourceSetsPath(ResourceSetSize.SMALL) + set;
for (String code : codes) {
file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + code + ".png");
if (file.exists()) {
continue;
}
file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + code + ".jpg");
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
try {
int width = image.getWidth(null);
int height = image.getHeight(null);
if (height > 0) {
int dx = 0;
if (set.equals("M10") || set.equals("M11") || set.equals("M12")) {
dx = 6;
}
Rectangle r = new Rectangle(15 + dx, (int) (height * (15.0f + dx) / width));
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
File newFile = new File(getResourceSetsPath(ResourceSetSize.SMALL) + set + '-' + code + ".png");
ImageIO.write(resized, "png", newFile);
}
} catch (Exception e) {
File newFile = new File(pathRoot + '-' + code + ".png");
if(!(MageFrame.isSkipSmallSymbolGenerationForExisting() && newFile.exists())){// skip if option enabled and file already exists
file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + code + ".png");
if (file.exists()) {
file.delete();
continue;
}
file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + code + ".jpg");
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
try {
int width = image.getWidth(null);
int height = image.getHeight(null);
if (height > 0) {
int dx = 0;
if (set.equals("M10") || set.equals("M11") || set.equals("M12")) {
dx = 6;
}
Rectangle r = new Rectangle(15 + dx, (int) (height * (15.0f + dx) / width));
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
ImageIO.write(resized, "png", newFile);
}
} catch (Exception e) {
if (file.exists()) {
file.delete();
}
}
}
}
@ -204,7 +211,6 @@ public final class ManaSymbols {
} catch (Exception e) {
}
}
// mark loaded images
// TODO: delete that code, images draw-show must dynamicly
File file;
@ -225,7 +231,6 @@ public final class ManaSymbols {
}
public static BufferedImage loadSVG(File svgFile, int resizeToWidth, int resizeToHeight, boolean useShadow) throws IOException {
// debug: disable shadow gen, need to test it
useShadow = false;
@ -249,10 +254,15 @@ public final class ManaSymbols {
+ "color-rendering: optimizeQuality;"
+ "image-rendering: optimizeQuality;"
+ "}";
File cssFile = File.createTempFile("batik-default-override-", ".css");
FileWriter w = new FileWriter(cssFile);
w.write(css);
w.close();
FileWriter w = null;
try {
w = new FileWriter(cssFile);
w.write(css);
} finally {
StreamUtils.closeQuietly(w);
}
TranscodingHints transcoderHints = new TranscodingHints();
@ -284,7 +294,6 @@ public final class ManaSymbols {
try {
TranscoderInput input = new TranscoderInput(new FileInputStream(svgFile));
ImageTranscoder t = new ImageTranscoder() {
@Override
@ -419,17 +428,17 @@ public final class ManaSymbols {
}
private static boolean loadSymbolImages(int size) {
// load all symbols to cash
// load all symbols to cache
// priority: SVG -> GIF
// gif remain for backward compatibility
boolean fileErrors = false;
HashMap<String, BufferedImage> sizedSymbols = new HashMap<>();
for (String symbol : symbols) {
//boolean fileErrors = false;
AtomicBoolean fileErrors = new AtomicBoolean(false);
Map<String, BufferedImage> sizedSymbols = new ConcurrentHashMap<>();
IntStream.range(0, symbols.length).parallel().forEach(i-> {
String symbol = symbols[i];
BufferedImage image = null;
File file = null;
File file;
// svg
file = getSymbolFileNameAsSVG(symbol);
@ -451,13 +460,13 @@ public final class ManaSymbols {
if (image != null) {
sizedSymbols.put(symbol, image);
} else {
fileErrors = true;
fileErrors.set(true);
LOGGER.warn("SVG or GIF symbol can't be load: " + symbol);
}
}
});
manaImages.put(size, sizedSymbols);
return !fileErrors;
return !fileErrors.get();
}
private static void renameSymbols(String path) {
@ -554,8 +563,8 @@ public final class ManaSymbols {
public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth, Color symbolsTextColor, int symbolMarginX) {
if (!manaImages.containsKey(symbolWidth)) {
loadSymbolImages(symbolWidth);
}
}
// TODO: replace with jlabel render (look at table rendere)?
/*
@ -605,12 +614,16 @@ public final class ManaSymbols {
return;
}
manaCost = manaCost.replace("\\", "");
manaCost = manaCost.replace("\\", "");
manaCost = UI.getDisplayManaCost(manaCost);
StringTokenizer tok = new StringTokenizer(manaCost, " ");
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

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;
/*
@ -72,13 +73,13 @@ public class ModernCardRenderer extends CardRenderer {
BufferedImage img = CardRendererUtils.toBufferedImage(icon.getImage());
return new TexturePaint(img, new Rectangle(0, 0, img.getWidth(), img.getHeight()));
}
private static BufferedImage loadBackgroundImage(String name) {
URL url = ModernCardRenderer.class.getResource("/cardrender/background_texture_" + name + ".png");
ImageIcon icon = new ImageIcon(url);
BufferedImage img = CardRendererUtils.toBufferedImage(icon.getImage());
return img;
}
}
private static BufferedImage loadFramePart(String name) {
URL url = ModernCardRenderer.class.getResource("/cardrender/" + name + ".png");
@ -108,7 +109,7 @@ public class ModernCardRenderer extends CardRenderer {
public static final Paint BG_TEXTURE_ARTIFACT = loadBackgroundTexture("artifact");
public static final Paint BG_TEXTURE_LAND = loadBackgroundTexture("land");
public static final Paint BG_TEXTURE_VEHICLE = loadBackgroundTexture("vehicle");
public static final BufferedImage BG_IMG_WHITE = loadBackgroundImage("white");
public static final BufferedImage BG_IMG_BLUE = loadBackgroundImage("blue");
public static final BufferedImage BG_IMG_BLACK = loadBackgroundImage("black");
@ -119,7 +120,8 @@ 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");
public static final Color BORDER_WHITE = new Color(216, 203, 188);
@ -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;
}
@ -318,12 +334,12 @@ public class ModernCardRenderer extends CardRenderer {
cardWidth - borderWidth * 2, cornerRadius * 4,
cornerRadius * 2, cornerRadius * 2);
a.add(new Area(rr2));
// Draw the M15 rounded "swoosh" at the bottom
Rectangle r = new Rectangle(borderWidth + contentInset, cardHeight - borderWidth * 5, cardWidth - borderWidth * 2 - contentInset * 2, borderWidth * 2);
a.add(new Area(r));
g.setClip(a);
g.drawImage(bg, 0, 0, cardWidth, cardHeight, 0, 0, bgw, bgh, BOX_BLUE, null);
g.drawImage(bg, 0, 0, cardWidth, cardHeight, 0, 0, bgw, bgh, BOX_BLUE, null);
g.setClip(null);
}
}
@ -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
drawBasicManaSymbol(g, x + w / 2 - 9 * h / 8 + 1, y - 3 * h / 4, 9 * h / 4, 9 * h / 4, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
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,7 +1192,15 @@ public class ModernCardRenderer extends CardRenderer {
private void drawBasicManaSymbol(Graphics2D g, int x, int y, int w, int h, String symbol) {
String symbs = symbol;
ManaSymbols.draw(g, symbs, x, y, w, Color.black, 2);
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
@ -1272,13 +1429,16 @@ public class ModernCardRenderer extends CardRenderer {
return new Color(71, 86, 101);
}
}
// 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;
@ -1299,7 +1459,7 @@ public class ModernCardRenderer extends CardRenderer {
return BG_IMG_COLORLESS;
}
}
// Get the box color for the given colors
protected Color getBoxColor(ObjectColor colors, Collection<CardType> types, boolean isNightCard) {
if (cardView.isAbility()) {
@ -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;
/**
*
@ -23,7 +22,7 @@ public final class TextboxRuleParser {
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);
private static final Pattern BasicManaAbility = Pattern.compile("\\{T\\}: Add \\{(\\w)\\} to your mana pool\\.");
private static final Pattern BasicManaAbility = Pattern.compile("\\{T\\}: Add \\{(\\w)\\}\\.");
private static final Pattern LevelAbilityPattern = Pattern.compile("Level (\\d+)-?(\\d*)(\\+?)");
private static final Pattern LoyaltyAbilityPattern = Pattern.compile("^(\\+|\\-)(\\d+|X): ");
private static final Pattern SimpleKeywordPattern = Pattern.compile("^(\\w+( \\w+)?)\\s*(\\([^\\)]*\\))?\\s*$");

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

@ -1,5 +1,7 @@
package org.mage.card.arcane;
import mage.util.StreamUtils;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
@ -7,6 +9,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 +19,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,9 +39,13 @@ public final class Util {
}
public static void broadcast(byte[] data, int port) throws IOException {
DatagramSocket socket = new DatagramSocket();
broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces());
socket.close();
DatagramSocket socket = null;
try {
socket = new DatagramSocket();
broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces());
} finally {
StreamUtils.closeQuietly(socket);
}
}
private static void broadcast(DatagramSocket socket, byte[] data, int port, Enumeration<NetworkInterface> ifaces)

View file

@ -1,5 +1,21 @@
package org.mage.plugins.card;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLayeredPane;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
@ -25,15 +41,6 @@ import org.mage.plugins.card.dl.sources.ScryfallSymbolsSource;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* {@link CardPlugin} implementation.
*
@ -128,7 +135,7 @@ public class CardPluginImpl implements CardPlugin {
}
@Override
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, boolean nonPermanentsOwnRow, boolean topPanel) {
public int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> permanents, boolean nonPermanentsOwnRow, boolean topPanel) {
//TODO: add caching
//requires to find out is position have been changed that includes:
//adding/removing permanents, type change
@ -149,7 +156,7 @@ public class CardPluginImpl implements CardPlugin {
outerLoop:
//
for (MagePermanent permanent : permanents) {
for (MagePermanent permanent : permanents.values()) {
if (!permanent.isLand() || permanent.isCreature()) {
continue;
}
@ -196,8 +203,13 @@ public class CardPluginImpl implements CardPlugin {
Stack stack = new Stack();
if (permanent.getOriginalPermanent().getAttachments() != null) {
stack.setMaxAttachedCount(permanent.getOriginalPermanent().getAttachments().size());
if (permanent.getOriginalPermanent().getAttachments() != null
&& !permanent.getOriginalPermanent().getAttachments().isEmpty()
&& !permanent.getOriginalPermanent().isAttachedTo()) {
// get the number of all attachements and sub attachments
AttachmentLayoutInfos ali = calculateNeededNumberOfVerticalColumns(0, permanents, permanent);
stack.setMaxAttachedCount(ali.getAttachments());
stack.setAttachmentColumns(ali.getColumns());
}
stack.add(permanent);
@ -411,6 +423,25 @@ public class CardPluginImpl implements CardPlugin {
return height - cardSpacingY + GUTTER_Y * 2;
}
private AttachmentLayoutInfos calculateNeededNumberOfVerticalColumns(int currentCol, Map<UUID, MagePermanent> permanents, MagePermanent permanentWithAttachments) {
int maxCol = ++currentCol;
int attachments = 0;
for (UUID attachmentId : permanentWithAttachments.getOriginalPermanent().getAttachments()) {
MagePermanent attachedPermanent = permanents.get(attachmentId);
if (attachedPermanent != null) {
attachments++;
if (attachedPermanent.getOriginalPermanent().getAttachments() != null && !attachedPermanent.getOriginalPermanent().getAttachments().isEmpty()) {
AttachmentLayoutInfos attachmentLayoutInfos = calculateNeededNumberOfVerticalColumns(currentCol, permanents, attachedPermanent);
if (attachmentLayoutInfos.getColumns() > maxCol) {
maxCol = attachmentLayoutInfos.getColumns();
attachments += attachmentLayoutInfos.getAttachments();
}
}
}
}
return new AttachmentLayoutInfos(maxCol, attachments);
}
private enum RowType {
land, creature, other, attached;
@ -438,13 +469,13 @@ public class CardPluginImpl implements CardPlugin {
super(16);
}
public Row(Collection<MagePermanent> permanents, RowType type) {
public Row(Map<UUID, MagePermanent> permanents, RowType type) {
this();
addAll(permanents, type);
}
private void addAll(Collection<MagePermanent> permanents, RowType type) {
for (MagePermanent permanent : permanents) {
private void addAll(Map<UUID, MagePermanent> permanents, RowType type) {
for (MagePermanent permanent : permanents.values()) {
if (!type.isType(permanent)) {
continue;
}
@ -455,7 +486,9 @@ public class CardPluginImpl implements CardPlugin {
Stack stack = new Stack();
stack.add(permanent);
if (permanent.getOriginalPermanent().getAttachments() != null) {
stack.setMaxAttachedCount(permanent.getOriginalPermanent().getAttachments().size());
AttachmentLayoutInfos ali = calculateNeededNumberOfVerticalColumns(0, permanents, permanent);
stack.setMaxAttachedCount(ali.getAttachments());
stack.setAttachmentColumns(ali.getColumns());
}
add(stack);
}
@ -499,13 +532,14 @@ public class CardPluginImpl implements CardPlugin {
* Max attached object count attached to single permanent in the stack.
*/
private int maxAttachedCount = 0;
private int attachmentColumns = 0;
public Stack() {
super(8);
}
private int getWidth() {
return cardWidth + (size() - 1) * stackSpacingX + cardSpacingX;
return cardWidth + (size() - 1) * stackSpacingX + cardSpacingX + (12 * attachmentColumns);
}
private int getHeight() {
@ -519,6 +553,37 @@ public class CardPluginImpl implements CardPlugin {
public void setMaxAttachedCount(int maxAttachedCount) {
this.maxAttachedCount = maxAttachedCount;
}
public void setAttachmentColumns(int attachmentColumns) {
this.attachmentColumns = attachmentColumns;
}
}
private final class AttachmentLayoutInfos {
private int columns;
private int attachments;
public AttachmentLayoutInfos(int columns, int attachments) {
this.columns = columns;
this.attachments = attachments;
}
public int getColumns() {
return columns;
}
public int getAttachments() {
return attachments;
}
public void increaseAttachments() {
attachments++;
}
public void increaseColumns() {
columns++;
}
}
/**
@ -552,8 +617,7 @@ public class CardPluginImpl implements CardPlugin {
for (DownloadJob job : it) {
g.getDownloader().add(job);
}
*/
*/
it = new DirectLinksForDownload();
for (DownloadJob job : it) {
g.getDownloader().add(job);

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

@ -24,35 +24,34 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package org.mage.plugins.card.dl.sources;
import java.util.Locale;
import org.mage.plugins.card.images.CardDownloadData;
/**
* Site was shutdown by wizards Feb. 2015
*
*
*
*
*
*
*
*
* @author LevelX2
*/
public enum MtgImageSource implements CardImageSource {
public enum MtgImageSource implements CardImageSource {
instance;
instance;
@Override
public String getSourceName() {
return "mtgimage.com";
}
@Override
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
@ -66,9 +65,9 @@ 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()) {
if (card.isSplitCard()) {
url.append(card.getDownloadName().replaceAll(" // ", ""));
} else {
url.append(card.getDownloadName().replaceAll(" ", "%20"));
@ -98,12 +97,12 @@ public enum MtgImageSource implements CardImageSource {
public float getAverageSize() {
return 70.0f;
}
@Override
public int getTotalImages() {
return -1;
}
@Override
public boolean isTokenSource() {
return false;
@ -112,4 +111,4 @@ public enum MtgImageSource implements CardImageSource {
@Override
public void doPause(String httpImageUrl) {
}
}
}

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;
@ -255,6 +256,7 @@ public enum MythicspoilerComSource implements CardImageSource {
supportedSets.add("XLN");
supportedSets.add("UST");
supportedSets.add("RIX");
supportedSets.add("DOM");
sets = new LinkedHashMap<>();
setsAliases = new HashMap<>();
@ -317,13 +319,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 +425,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;
@ -209,7 +210,7 @@ public enum ScryfallImageSource implements CardImageSource {
supportedSets.add("WMCQ");
supportedSets.add("PPRO");
supportedSets.add("A25");
// supportedSets.add("DOM");
supportedSets.add("DOM");
// supportedSets.add("M19");
}
@ -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;
@ -269,7 +270,7 @@ public enum WizardCardsImageSource implements CardImageSource {
supportedSets.add("UST"); // Unstable
supportedSets.add("RIX"); // Rivals of Ixalan
supportedSets.add("A25"); // Masters 25
// supportedSets.add("DOM"); // Dominaria
supportedSets.add("DOM"); // Dominaria
// supportedSets.add("M19"); // Core 2019
sets = new HashMap<>();
@ -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));
}
}
@ -758,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;
/**
*
@ -134,7 +134,7 @@ public class CardDownloadData {
return CardUtil.parseCardNumberAsInt(collectorId);
}
public boolean isCollectorIdWithStr(){
public boolean isCollectorIdWithStr() {
// card have special numbers like "103a", "180b" (scryfall style)
return !getCollectorId().equals(getCollectorIdAsInt().toString());
}
@ -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,27 +506,32 @@ 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);
list.add(card);
} else if (params[1].toLowerCase(Locale.ENGLISH).equals("generate") && params[2].startsWith("PLANE:")) {
String set = params[2].substring(6);
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true, fileName);
card.setTokenClassName(tokenClassName);
list.add(card);
}
} else {
logger.error("wrong format for image urls: " + line);
@ -744,34 +751,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 +760,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 +782,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 +793,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 +827,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 +838,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,13 +12,9 @@ public class SettingsManager {
private static SettingsManager settingsManager = null;
public static SettingsManager getIntance() {
public static synchronized SettingsManager getIntance() {
if (settingsManager == null) {
synchronized (SettingsManager.class) {
if (settingsManager == null) {
settingsManager = new SettingsManager();
}
}
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,18 +21,17 @@ import org.mage.plugins.card.utils.Transparency;
public enum ImageManagerImpl implements ImageManager {
instance;
ImageManagerImpl() {
init();
}
public void init() {
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"Main2", "Cleanup", "Next_Turn"};
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"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);
}
}
@ -339,10 +339,10 @@ public enum ImageManagerImpl implements ImageManager {
}
return imageSkipYourNextTurnButton;
}
@Override
public Image getToggleRecordMacroButtonImage() {
if(imageToggleRecordMacroButton == null) {
if (imageToggleRecordMacroButton == null) {
imageToggleRecordMacroButton = getBufferedImageFromResource("/buttons/toggle_macro.png");
}
return imageToggleRecordMacroButton;
@ -414,7 +414,7 @@ public enum ImageManagerImpl implements ImageManager {
private static BufferedImage triggeredAbilityIcon;
private static BufferedImage activatedAbilityIcon;
private static BufferedImage lookedAtIcon;
private static BufferedImage revealedIcon;
private static BufferedImage revealedIcon;
private static BufferedImage exileIcon;
private static BufferedImage imageCopyIcon;
private static BufferedImage imageCounterGreen;

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,47 +150,43 @@ public class ThemePluginImpl implements ThemePlugin {
return bgPanel;
}
private ImagePanel createImagePanelInstance() {
private synchronized ImagePanel createImagePanelInstance() {
if (background == null) {
synchronized (ThemePluginImpl.class) {
if (background == null) {
String filename = "/background.png";
try {
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) {
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
background = ImageIO.read(is);
} else {
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
if (path != null && !path.isEmpty()) {
try {
File f = new File(path);
if (f != null) {
background = ImageIO.read(f);
}
} catch (Exception e) {
background = null;
}
}
}
if (background == null) {
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
background = ImageIO.read(is);
}
if (background == null) {
String filename = "/background.png";
try {
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) {
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
background = ImageIO.read(is);
} else {
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
if (path != null && !path.isEmpty()) {
try {
File f = new File(path);
if (f != null) {
background = ImageIO.read(f);
}
} catch (Exception e) {
background = null;
}
}
}
if (background == null) {
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
background = ImageIO.read(is);
}
if (background == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
}
return new ImagePanel(background, ImagePanelStyle.SCALED);
}

View file

@ -85,6 +85,24 @@
|Generate|EMBLEM:M14|Liliana of the Dark Realms||Emblem Liliana|LilianaOfTheDarkRealmsEmblem|
|Generate|EMBLEM:MMA|Elspeth, Knight Errant||Emblem Elspeth|ElspethKnightErrantEmblem|
|Generate|EMBLEM:RIX|Huatli, Radiant Champion||Emblem Huatli|HuatliRadiantChampionEmblem|
|Generate|PLANE:PCA|Plane - Academy At Tolaria West|||AcademyAtTolariaWestPlane|
|Generate|PLANE:PCA|Plane - Agyrem|||AgyremPlane|
|Generate|PLANE:PCA|Plane - Akoum|||AkoumPlane|
|Generate|PLANE:PCA|Plane - Astral Arena|||AstralArenaPlane|
|Generate|PLANE:PCA|Plane - Bant|||BantPlane|
|Generate|PLANE:PCA|Plane - Edge Of Malacol|||EdgeOfMalacolPlane|
|Generate|PLANE:PCA|Plane - Feeding Grounds|||FeedingGroundsPlane|
|Generate|PLANE:PCA|Plane - Fields of Summer|||FieldsOfSummerPlane|
|Generate|PLANE:PCA|Plane - Hedron Fields of Agadeem|||HedronFieldsOfAgadeemPlane|
|Generate|PLANE:PCA|Plane - Lethe Lake|||LetheLakePlane|
|Generate|PLANE:PCA|Plane - Naya|||NayaPlane|
|Generate|PLANE:PCA|Plane - Tazeem|||TazeemPlane|
|Generate|PLANE:PCA|Plane - The Dark Barony|||TheDarkBaronyPlane|
|Generate|PLANE:PCA|Plane - The Eon Fog|||TheEonFogPlane|
|Generate|PLANE:PCA|Plane - Truga Jungle|||TrugaJunglePlane|
|Generate|PLANE:PCA|Plane - Turri Island|||TurriIslandPlane|
|Generate|PLANE:PCA|Plane - Undercity Reaches|||UndercityReachesPlane|
|Generate|TOK:PCA|Eldrazi|||EldraziAnnihilatorToken|
|Generate|TOK:10E|Ape|||PongifyApeToken|
|Generate|TOK:10E|Dragon|||DragonToken2|
|Generate|TOK:10E|Goblin|||GoblinToken|
@ -1124,4 +1142,4 @@
|Generate|TOK:ZEN|Snake|||SnakeToken|
|Generate|TOK:ZEN|Vampire||
|Generate|TOK:ZEN|Wolf|||WolfToken|
|Generate|TOK:ZEN|Zombie Giant|||QuestForTheGravelordZombieToken|
|Generate|TOK:ZEN|Zombie Giant|||QuestForTheGravelordZombieToken|

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -73,6 +73,6 @@ dd3evg=ddaevg
dd3gvl=ddagvl
dd3jvc=ddajvc
# Remove setname as soon as the images can be downloaded
ignore.urls=TOK,M19,DOM,H17
ignore.urls=TOK,M19,H17
# sets ordered by release time (newest goes first)
token.lookup.order=M19,A25,DOM,E02,RIX,UST,XLN,IMA,H17,C17,V17,E01,DDT,CMA,HOU,MM3,DDS,AKH,DD3DVD,DD3EVG,DD3GVL,DD3JVC,H09,AER,PCA,C16,V16,MPS,KLD,DDR,CN2,EMN,EMA,SOI,DDQ,CP,CMA,ARENA,SUS,APAC,EURO,UGIN,C15,OGW,EXP,DDP,BFZ,DRB,V09,V10,V11,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC

View file

@ -218,9 +218,9 @@ Saproling, T3, G, 1|1, -, Creature - Saproling, Warren Mahy, -
ROE - Rise of the Eldrazi (2010-04-23)
Eldrazi Spawn, 1a, -, -, -, Creature - Eldrazi Spawn, Aleksi Briclot, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 1b, -, -, -, Creature - Eldrazi Spawn, Mark Tedin, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 1c, -, -, -, Creature - Eldrazi Spawn, Veronique Meignaud, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 1a, -, -, -, Creature - Eldrazi Spawn, Aleksi Briclot, Sacrifice this creature: Add {1}.
Eldrazi Spawn, 1b, -, -, -, Creature - Eldrazi Spawn, Mark Tedin, Sacrifice this creature: Add {1}.
Eldrazi Spawn, 1c, -, -, -, Creature - Eldrazi Spawn, Veronique Meignaud, Sacrifice this creature: Add {1}.
Elemental, 2, R, *|*, -, Creature - Elemental, Jung Park, -
Hellion, 1, R, 4|4, -, Creature - Hellion, Anthony Francisco, -
Ooze, 4, G, *|*, -, Creature - Ooze, Daniel Ljunggren, -
@ -312,7 +312,7 @@ Sorin Emblem, 3, -, -, -, Emblem - Sorin, Michael Komrack, Creatures you control
DDI - Duel Decks: Venser vs. Koth (2012-03-30)
Koth Emblem, E1, -, -, -, Emblem - Koth, Eric Deschamps, Mountains you control have Tap: This land deals 1 damage to target creature or player.'
Koth Emblem, E1, -, -, -, Emblem - Koth, Eric Deschamps, Mountains you control have Tap: This land deals 1 damage to any target.'
Venser Emblem, E2, -, -, -, Emblem - Venser, Eric Deschamps, Whenever you cast a spell<6C> exile target permanent.
FNM - Friday Night Magic (2012-04-01)
@ -348,7 +348,7 @@ Hellion, 1, R, 4|4, -, Creature - Hellion, Anthony Francisco, -
Beast, 8, G, 3|3, -, Creature - Beast, John Donahue, -
Saproling, 9, G, 1|1, -, Creature - Saproling, Brad Rigney, -
Wurm, 10, G, 6|6, -, Creature - Wurm, Anthony Francisco, -
Liliana Emblem, 11, -, -, -, Emblem - Liliana, D. Alexander Gregory, Swamps you control have Tap: Add {B}{B}{B}{B} to your mana pool.'
Liliana Emblem, 11, -, -, -, Emblem - Liliana, D. Alexander Gregory, Swamps you control have Tap: Add {B}{B}{B}{B}.'
DDJ - Duel Decks: Izzet vs. Golgari (2012-09-07)
@ -424,7 +424,7 @@ Elemental, 8, R, 1|1, -, Creature - Elemental, Winona Nelson, -
Beast, 9, G, 3|3, -, Creature - Beast, John Donahue, -
Saproling, 10, G, 1|1, -, Creature - Saproling, Brad Rigney, -
Wolf, 11, G, 2|2, -, Creature - Wolf, Lars Grant-West, -
Liliana Emblem, 12, -, -, -, Emblem - Liliana, D. Alexander Gregory, Swamps you control have Tap: Add {B}{B}{B}{B} to your mana pool.'
Liliana Emblem, 12, -, -, -, Emblem - Liliana, D. Alexander Gregory, Swamps you control have Tap: Add {B}{B}{B}{B}.'
Garruk Emblem, 13, -, -, -, Emblem - Garruk, Karl Kopinski, Whenever you cast a creature spell<6C> you may search your library for a creature card<72> put it onto the battlefield<6C> then shuffle your library.
Sliver, T1, -, 1|1, League, Creature - Sliver, Vincent Proce, -
@ -461,7 +461,7 @@ Zombie, 6, B, 2|2, -, Enchantment Creature - Zombie, Winona Nelson, -
Elemental, 7, R, 3|1, -, Enchantment Creature - Elemental, Greg Staples, -
Centaur, 8, G, 3|3, -, Enchantment Creature - Centaur, Ryan Barger, -
Wolf, 9, G, 2|2, -, Creature - Wolf, Raoul Vitale, -
Gold, 10, -, -, -, Artifact, Richard Wright, Sacrifice this artifact: Add one mana of any color to your mana pool.
Gold, 10, -, -, -, Artifact, Richard Wright, Sacrifice this artifact: Add one mana of any color.
Kiora Emblem, 11, -, -, -, Emblem - Kiora, Scott M. Fischer, At the beginning of your end step<65> put a 9/9 blue Kraken creature token onto the battlefield.
DDM - Duel Decks: Jace vs. Vraska (2014-03-14)
@ -561,7 +561,7 @@ Beast, 019, G, 3|3, -, Creature - Beast, Dave Allsop, -
Beast, 020, G, 4|4, -, Creature - Beast, Steve Prescott, -
Elemental, 021, G, 5|3, -, Creature - Elemental, Nils Hamm, -
Elephant, 022, G, 3|3, -, Creature - Elephant, Lars Grant-West, -
Elf Druid, 023, G, 1|1, -, Creature - Elf Druid, Raymond Swanland, {T}: Add {G} to your mana pool.
Elf Druid, 023, G, 1|1, -, Creature - Elf Druid, Raymond Swanland, {T}: Add {G}.
Elf Warrior, 024, G, 1|1, -, Creature - Elf Warrior, William O'Connor, -
Treefolk, 025, G, *|*, -, Creature - Treefolk, Filip Burburan, -
Wolf, 026, G, 2|2, -, Creature - Wolf, Daren Bader, -
@ -625,9 +625,9 @@ Narset Emblem, 008, -, -, -, Emblem - Narset, Magali Villeneuve, Your opponents
MM2 - Modern Masters 2015 Edition (2015-05-22)
Eldrazi Spawn, 001, -, -, -, Creature - Eldrazi Spawn, Aleksi Briclot, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 002, -, -, -, Creature - Eldrazi Spawn, Mark Tedin, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 003, -, -, -, Creature - Eldrazi Spawn, Veronique Meignaud, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 001, -, -, -, Creature - Eldrazi Spawn, Aleksi Briclot, Sacrifice this creature: Add {1}.
Eldrazi Spawn, 002, -, -, -, Creature - Eldrazi Spawn, Mark Tedin, Sacrifice this creature: Add {1}.
Eldrazi Spawn, 003, -, -, -, Creature - Eldrazi Spawn, Veronique Meignaud, Sacrifice this creature: Add {1}.
Soldier, 004, W, 1|1, -, Creature - Soldier, Greg Staples, -
Spirit, 005, W, 1|1, -, Creature - Spirit, Mike Sass, Flying
Faerie Rogue, 006, B, 1|1, -, Creature - Faerie Rogue, Dave Allsop, Flying
@ -661,18 +661,18 @@ Chandra Emblem, 014, -, -, -, Emblem - Chandra, Eric Deschamps, At the beginning
DDP - Duel Decks: Zendikar vs. Eldrazi (2015-08-28)
Eldrazi Spawn, 076, -, -, -, Creature - Eldrazi Spawn, Aleksi Briclot, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 077, -, -, -, Creature - Eldrazi Spawn, Veronique Meignaud, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 078, -, -, -, Creature - Eldrazi Spawn, Mark Tedin, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Spawn, 076, -, -, -, Creature - Eldrazi Spawn, Aleksi Briclot, Sacrifice this creature: Add {1}.
Eldrazi Spawn, 077, -, -, -, Creature - Eldrazi Spawn, Veronique Meignaud, Sacrifice this creature: Add {1}.
Eldrazi Spawn, 078, -, -, -, Creature - Eldrazi Spawn, Mark Tedin, Sacrifice this creature: Add {1}.
Hellion, 1, R, 4|4, -, Creature - Hellion, Anthony Francisco, -
Plant, 080, G, -, -, Creature - Plant, Daren Bader, -
BFZ - Battle for Zendikar (2015-10-09)
Eldrazi, 001, -, 10|10, -, Creature - Eldrazi, Jack Wang, -
Eldrazi Scion, 002, -, 1|1, -, Creature - Eldrazi Scion, Izzy, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 003, -, 1|1, -, Creature - Eldrazi Scion, Winona Nelson, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 004, -, 1|1, -, Creature - Eldrazi Scion, Svetlin Velinov, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 002, -, 1|1, -, Creature - Eldrazi Scion, Izzy, Sacrifice this creature: Add {1}.
Eldrazi Scion, 003, -, 1|1, -, Creature - Eldrazi Scion, Winona Nelson, Sacrifice this creature: Add {1}.
Eldrazi Scion, 004, -, 1|1, -, Creature - Eldrazi Scion, Svetlin Velinov, Sacrifice this creature: Add {1}.
Knight Ally, 005, W, 2|2, -, Creature - Knight Ally, Josu Hernaiz, -
Kor Ally, 006, W, 1|1, -, Creature - Kor Ally, Jeremy Wilson, -
Octopus, 007, U, 8|8, -, Creature - Octopus, Craig J Spearing, -
@ -709,16 +709,16 @@ Elemental, 020, U R, 5|5, -, Creature - Elemental, Randy Gallegos, Flying
Snake, 021, G U, 1|1, -, Creature - Snake, Christopher Moeller, -
Spirit, 022, W B, 1|1, -, Creature - Spirit, Cliff Childs, Flying
Spirit, 023, W B, *|*, -, Enchantment Creature - Spirit, Adam Paquette, This creature's power and toughness are each equal to the number of experience counters you have.
Gold, 024, -, -, -, Artifact, Richard Wright, Sacrifice this artifact: Add one mana of any color to your mana pool.
Gold, 024, -, -, -, Artifact, Richard Wright, Sacrifice this artifact: Add one mana of any color.
OGW - Oath of the Gatewatch (2016-01-22)
Eldrazi Scion, 001, -, 1|1, -, Creature - Eldrazi Scion, Izzy, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 002, -, 1|1, -, Creature - Eldrazi Scion, Craig J Spearing, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 003, -, 1|1, -, Creature - Eldrazi Scion, Svetlin Velinov, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 004, -, 1|1, -, Creature - Eldrazi Scion, Izzy, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 005, -, 1|1, -, Creature - Eldrazi Scion, Winona Nelson, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 006, -, 1|1, -, Creature - Eldrazi Scion, Svetlin Velinov, Sacrifice this creature: Add {1} to your mana pool.
Eldrazi Scion, 001, -, 1|1, -, Creature - Eldrazi Scion, Izzy, Sacrifice this creature: Add {1}.
Eldrazi Scion, 002, -, 1|1, -, Creature - Eldrazi Scion, Craig J Spearing, Sacrifice this creature: Add {1}.
Eldrazi Scion, 003, -, 1|1, -, Creature - Eldrazi Scion, Svetlin Velinov, Sacrifice this creature: Add {1}.
Eldrazi Scion, 004, -, 1|1, -, Creature - Eldrazi Scion, Izzy, Sacrifice this creature: Add {1}.
Eldrazi Scion, 005, -, 1|1, -, Creature - Eldrazi Scion, Winona Nelson, Sacrifice this creature: Add {1}.
Eldrazi Scion, 006, -, 1|1, -, Creature - Eldrazi Scion, Svetlin Velinov, Sacrifice this creature: Add {1}.
Angel, 007, W, 3|3, -, Creature - Angel, Anastasia Ovchinnikova, Flying
Zombie, 008, B, 2|2, -, Creature - Zombie, Kev Walker, -
Elemental, 009, R, 3|1, -, Creature - Elemental, Raymond Swanland, -
@ -732,7 +732,7 @@ Human Soldier, 002, W, 1|1, -, Creature - Human Soldier, Deruchenko Alexander, -
Spirit, 003, W, 1|1, -, Creature - Spirit, Jason A. Engle, Flying
Vampire Knight, 004, B, 1|1, -, Creature - Vampire Knight, Deruchenko Alexander, Lifelink
Zombie, 005, B, 2|2, -, Creature - Zombie, Craig J Spearing, -
Devil, 006, R, 1|1, -, Creature - Devil, Wayne England, When this creature dies<65> it deals 1 damage to target creature or player.
Devil, 006, R, 1|1, -, Creature - Devil, Wayne England, When this creature dies<65> it deals 1 damage to any target.
Insect, 007, G, 1|1, -, Creature - Insect, Christopher Moeller, -
Ooze, 008, G, 3|3, -, Creature - Ooze, Nils Hamm, -
Wolf, 009, G, 2|2, -, Creature - Wolf, Aaron Miller, -
@ -744,7 +744,7 @@ Clue, 014, -, -, -, Artifact - Clue, Cliff Childs, {2} Sacrifice this Artifac
Clue, 015, -, -, -, Artifact - Clue, James Paick, {2} Sacrifice this Artifact: Draw a card.
Clue, 016, -, -, -, Artifact - Clue, Franz Vohwinkel, {2} Sacrifice this Artifact: Draw a card.
Jace Emblem, 017, -, -, -, Emblem - Jace, Tyler Jacobson, Whenever an opponent casts his or her first spell each turn<72> counter that spell.
Arlinn Emblem, 018, -, -, -, Emblem - Arlinn, Winona Nelson, Creatures you control have haste and '{T}: This creature deals damage equal to its power to target creature or player.'
Arlinn Emblem, 018, -, -, -, Emblem - Arlinn, Winona Nelson, Creatures you control have haste and '{T}: This creature deals damage equal to its power to any target.'
SWS - Star Wars Custom set

Can't render this file because it contains an unexpected character in line 549 and column 140.

View file

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

View file

@ -2,7 +2,6 @@ package mage.interfaces.plugin;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import javax.swing.*;
@ -27,7 +26,7 @@ public interface CardPlugin extends Plugin {
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel);
int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel);
/**
* Download various symbols (mana, tap, set).

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 = 28;
public final static String MAGE_VERSION_MINOR_PATCH = "V0";
public final static int MAGE_VERSION_PATCH = 29;
public final static String MAGE_VERSION_MINOR_PATCH = "V2";
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

@ -54,6 +54,7 @@ import mage.target.Targets;
import mage.util.SubTypeList;
import com.google.gson.annotations.Expose;
import mage.game.command.Plane;
/**
* @author BetaSteward_at_googlemail.com
@ -520,6 +521,14 @@ public class CardView extends SimpleCardView {
Emblem emblem = (Emblem) object;
this.rarity = Rarity.SPECIAL;
this.rules = emblem.getAbilities().getRules(emblem.getName());
} else if (object instanceof Plane) {
this.mageObjectType = MageObjectType.PLANE;
Plane plane = (Plane) object;
this.rarity = Rarity.SPECIAL;
this.frameStyle = FrameStyle.M15_NORMAL;
// Display in landscape/rotated/on its side
this.rotate = true;
this.rules = plane.getAbilities().getRules(plane.getName());
}
if (this.rarity == null && object instanceof StackAbility) {
StackAbility stackAbility = (StackAbility) object;
@ -556,6 +565,21 @@ public class CardView extends SimpleCardView {
this.rarity = Rarity.COMMON;
}
public CardView(PlaneView plane) {
this(true);
this.gameObject = true;
this.id = plane.getId();
this.mageObjectType = MageObjectType.PLANE;
this.name = plane.getName();
this.displayName = name;
this.rules = plane.getRules();
// Display the plane in landscape (similar to Fused cards)
this.rotate = true;
this.frameStyle = FrameStyle.M15_NORMAL;
this.expansionSetCode = plane.getExpansionSetCode();
this.rarity = Rarity.COMMON;
}
public CardView(Designation designation, StackAbility stackAbility) {
this(true);
this.gameObject = true;
@ -745,6 +769,9 @@ public class CardView extends SimpleCardView {
@Override
public String getExpansionSetCode() {
if (expansionSetCode == null) {
expansionSetCode = "";
}
return expansionSetCode;
}
@ -988,7 +1015,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

@ -40,6 +40,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.GameState;
import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.target.targetpointer.TargetPointer;
@ -118,6 +119,9 @@ public class CardsView extends LinkedHashMap<UUID, CardView> {
abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new EmblemView((Emblem) sourceObject)));
abilityView.setName(((Emblem) sourceObject).getName());
// abilityView.setExpansionSetCode(sourceCard.getExpansionSetCode());
} else if (sourceObject instanceof Plane) {
abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new PlaneView((Plane) sourceObject)));
abilityView.setName(((Plane) sourceObject).getName());
}
break;
}

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;
@ -51,6 +47,7 @@ import mage.game.Game;
import mage.game.GameState;
import mage.game.combat.CombatGroup;
import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentToken;
@ -60,8 +57,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 +100,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());
@ -140,6 +140,12 @@ public class GameView implements Serializable {
stack.put(stackObject.getId(),
new StackAbilityView(game, (StackAbility) stackObject, object.getName(), cardView));
checkPaid(stackObject.getId(), ((StackAbility) stackObject));
} else if (object instanceof Plane) {
CardView cardView = new CardView(new PlaneView((Plane) object));
((StackAbility) stackObject).setName(((Plane) object).getName());
stack.put(stackObject.getId(),
new StackAbilityView(game, (StackAbility) stackObject, object.getName(), cardView));
checkPaid(stackObject.getId(), ((StackAbility) stackObject));
} else if (object instanceof Designation) {
Designation designation = (Designation) game.getObject(object.getId());
if (designation != null) {
@ -161,9 +167,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 +227,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

@ -0,0 +1,57 @@
package mage.view;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import mage.cards.Card;
import mage.game.command.Plane;
/**
* @author spjspj
*/
public class PlaneView implements CommandObjectView, Serializable {
protected UUID id;
protected String name;
protected String expansionSetCode;
protected List<String> rules;
public PlaneView(Plane plane, Card sourceCard) {
id = plane.getId();
name = "Plane " + sourceCard.getName();
if (plane.getExpansionSetCodeForImage() == null) {
expansionSetCode = sourceCard.getExpansionSetCode();
} else {
expansionSetCode = plane.getExpansionSetCodeForImage();
}
rules = plane.getAbilities().getRules(sourceCard.getName());
}
public PlaneView(Plane plane) {
id = plane.getId();
name = plane.getName();
expansionSetCode = plane.getExpansionSetCodeForImage();
rules = plane.getAbilities().getRules(plane.getName());
}
@Override
public String getExpansionSetCode() {
return expansionSetCode;
}
@Override
public String getName() {
return name;
}
@Override
public UUID getId() {
return id;
}
@Override
public List<String> getRules() {
return rules;
}
}

View file

@ -43,6 +43,7 @@ import mage.game.GameState;
import mage.game.command.CommandObject;
import mage.game.command.Commander;
import mage.game.command.Emblem;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.players.net.UserData;
@ -141,6 +142,10 @@ public class PlayerView implements Serializable {
if (emblem.getControllerId().equals(this.playerId)) {
commandList.add(new EmblemView(emblem));
}
} else if (commandObject instanceof Plane) {
Plane plane = (Plane) commandObject;
// Planes are universal and all players can see them.
commandList.add(new PlaneView(plane));
} else if (commandObject instanceof Commander) {
Commander commander = (Commander) commandObject;
if (commander.getControllerId().equals(this.playerId)) {

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-plugins</artifactId>
<version>1.4.28</version>
<version>1.4.29</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.28</version>
<version>1.4.29</version>
</parent>
<artifactId>mage-plugins</artifactId>

View file

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

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