Merge pull request #3 from magefree/master

Updating fork to base repo
This commit is contained in:
Tyler Moore 2019-04-24 12:51:54 -07:00 committed by GitHub
commit 0513b4eb9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5233 changed files with 112294 additions and 41165 deletions

2
.gitignore vendored
View file

@ -78,6 +78,7 @@ Mage.Tests/Mage.log
Mage.Tests/watchdog.log Mage.Tests/watchdog.log
# Mage # Mage
*.log
Mage/target Mage/target
# Mage.Updater # Mage.Updater
@ -91,6 +92,7 @@ Mage.Verify/AllCards.json.zip
Mage.Verify/AllSets.json.zip Mage.Verify/AllSets.json.zip
Mage.Verify/AllCards.json Mage.Verify/AllCards.json
Mage.Verify/AllSets.json Mage.Verify/AllSets.json
Mage.Verify/db
releases releases
Utils/author.txt Utils/author.txt

View file

@ -3,3 +3,10 @@ dist: trusty
language: java language: java
before_install: before_install:
- echo "MAVEN_OPTS='-Xmx2g'" > ~/.mavenrc - echo "MAVEN_OPTS='-Xmx2g'" > ~/.mavenrc
# addons:
# sonarcloud:
# organization: "magefree"
# token:
# secure: SONAR_TOKEN
# script:
# - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar

View file

@ -1,3 +0,0 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
SplashScreen-Image: splash.jpg

View file

@ -6,10 +6,9 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>1.4.31</version> <version>1.4.35</version>
</parent> </parent>
<groupId>org.mage</groupId>
<artifactId>mage-client</artifactId> <artifactId>mage-client</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Mage Client</name> <name>Mage Client</name>
@ -52,12 +51,11 @@
<dependency> <dependency>
<groupId>com.mortennobel</groupId> <groupId>com.mortennobel</groupId>
<artifactId>java-image-scaling</artifactId> <artifactId>java-image-scaling</artifactId>
<version>0.8.5</version> <version>0.8.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.collections</groupId> <groupId>com.google.guava</groupId>
<artifactId>google-collections</artifactId> <artifactId>guava</artifactId>
<version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.swinglabs</groupId> <groupId>org.swinglabs</groupId>
@ -67,12 +65,12 @@
<dependency> <dependency>
<groupId>org.jetlang</groupId> <groupId>org.jetlang</groupId>
<artifactId>jetlang</artifactId> <artifactId>jetlang</artifactId>
<version>0.2.9</version> <version>0.2.23</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.amazonaws</groupId> <groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId> <artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.286</version> <version>1.11.498</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.jgoodies</groupId> <groupId>com.jgoodies</groupId>
@ -109,13 +107,13 @@
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.5.2</version> <version>1.11.3</version>
</dependency> </dependency>
<dependency> <dependency>
<artifactId>truevfs-profile-base</artifactId> <artifactId>truevfs-profile-base</artifactId>
<groupId>net.java.truevfs</groupId> <groupId>net.java.truevfs</groupId>
<type>jar</type> <type>jar</type>
<version>0.10.8</version> <version>0.11.1</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>truevfs-access-swing</artifactId> <artifactId>truevfs-access-swing</artifactId>
@ -130,7 +128,7 @@
<dependency> <dependency>
<groupId>com.googlecode.soundlibs</groupId> <groupId>com.googlecode.soundlibs</groupId>
<artifactId>mp3spi</artifactId> <artifactId>mp3spi</artifactId>
<version>1.9.5-1</version> <version>1.9.5.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javazoom</groupId> <groupId>javazoom</groupId>
@ -155,14 +153,14 @@
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-transcoder</artifactId> <artifactId>batik-transcoder</artifactId>
<version>1.7</version> <version>1.11</version>
</dependency> </dependency>
<!-- svg support end --> <!-- svg support end -->
<dependency> <dependency>
<groupId>org.ocpsoft.prettytime</groupId> <groupId>org.ocpsoft.prettytime</groupId>
<artifactId>prettytime</artifactId> <artifactId>prettytime</artifactId>
<version>3.2.7.Final</version> <version>4.0.2.Final</version>
</dependency> </dependency>
</dependencies> </dependencies>
<!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ --> <!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ -->
@ -194,11 +192,13 @@
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<configuration> <configuration>
<archive> <archive>
<manifestFile>${manifest.file}</manifestFile>
<manifest> <manifest>
<addClasspath>true</addClasspath> <addClasspath>true</addClasspath>
<mainClass>mage.client.MageFrame</mainClass> <mainClass>mage.client.MageFrame</mainClass>
</manifest> </manifest>
<manifestEntries>
<SplashScreen-Image>splash.jpg</SplashScreen-Image>
</manifestEntries>
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>

View file

@ -1,22 +1,22 @@
NAME:Douglas Scheinberg's Séance Combo NAME:Douglas Scheinberg's Séance Combo
1 [AVR:42] Alchemist's Apprentice 1 [AVR:42] Alchemist's Apprentice
4 [RTR:1] Angel of Serenity 4 [RTR:1] Angel of Serenity
1 [ISD:68] Mirror-Mad Phantasm 1 [ISD:68] Mirror-Mad Phantasm
2 [ISD:248] Sulfur Falls 2 [ISD:248] Sulfur Falls
4 [RTR:249] Transguild Promenade 4 [RTR:249] Transguild Promenade
3 [RTR:247] Steam Vents 3 [RTR:247] Steam Vents
1 [AVR:1] Angel of Glory's Rise 1 [AVR:1] Angel of Glory's Rise
4 [ISD:122] Unburial Rites 4 [ISD:122] Unburial Rites
4 [RTR:201] Supreme Verdict 4 [RTR:201] Supreme Verdict
1 [ISD:55] Forbidden Alchemy 1 [ISD:55] Forbidden Alchemy
1 [ISD:61] Laboratory Maniac 1 [ISD:61] Laboratory Maniac
3 [ISD:238] Clifftop Retreat 3 [ISD:238] Clifftop Retreat
3 [ISD:43] Armored Skaab 3 [ISD:43] Armored Skaab
2 [GTC:245] Sacred Foundry 2 [GTC:245] Sacred Foundry
4 [M13:69] Sphinx of Uthuun 4 [M13:69] Sphinx of Uthuun
3 [M13:225] Glacial Fortress 3 [M13:225] Glacial Fortress
4 [RTR:172] Izzet Charm 4 [RTR:172] Izzet Charm
2 [AVR:229] Slayers' Stronghold 2 [AVR:229] Slayers' Stronghold
2 [AVR:226] Cavern of Souls 2 [AVR:226] Cavern of Souls
4 [DKA:87] Faithless Looting 4 [DKA:87] Faithless Looting
4 [RTR:241] Hallowed Fountain 4 [RTR:241] Hallowed Fountain

View file

@ -1,31 +1,31 @@
NAME:Emmanuel Ramírez's Reanimator NAME:Emmanuel Ramírez's Reanimator
4 [ISD:170] Avacyn's Pilgrim 4 [ISD:170] Avacyn's Pilgrim
2 [ISD:249] Woodland Cemetery 2 [ISD:249] Woodland Cemetery
3 [M13:159] Acidic Slime 3 [M13:159] Acidic Slime
3 [ISD:196] Mulch 3 [ISD:196] Mulch
1 [ISD:239] Gavony Township 1 [ISD:239] Gavony Township
3 [ISD:15] Fiend Hunter 3 [ISD:15] Fiend Hunter
3 [RTR:1] Angel of Serenity 3 [RTR:1] Angel of Serenity
2 [AVR:226] Cavern of Souls 2 [AVR:226] Cavern of Souls
4 [AVR:32] Restoration Angel 4 [AVR:32] Restoration Angel
2 [ISD:242] Isolated Chapel 2 [ISD:242] Isolated Chapel
4 [RTR:248] Temple Garden 4 [RTR:248] Temple Garden
4 [RTR:243] Overgrown Tomb 4 [RTR:243] Overgrown Tomb
3 [M13:160] Arbor Elf 3 [M13:160] Arbor Elf
4 [M13:193] Thragtusk 4 [M13:193] Thragtusk
2 [DGM:103] Sin Collector 2 [DGM:103] Sin Collector
4 [RTR:165] Grisly Salvage 4 [RTR:165] Grisly Salvage
3 [M13:229] Sunpetal Grove 3 [M13:229] Sunpetal Grove
3 [RTR:270] Forest 3 [RTR:270] Forest
2 [GTC:242] Godless Shrine 2 [GTC:242] Godless Shrine
4 [ISD:122] Unburial Rites 4 [ISD:122] Unburial Rites
SB: 1 [RTR:148] Centaur Healer SB: 1 [RTR:148] Centaur Healer
SB: 2 [DKA:17] Ray of Revelation SB: 2 [DKA:17] Ray of Revelation
SB: 1 [M13:159] Acidic Slime SB: 1 [M13:159] Acidic Slime
SB: 2 [ISD:181] Garruk Relentless SB: 2 [ISD:181] Garruk Relentless
SB: 2 [RTR:141] Abrupt Decay SB: 2 [RTR:141] Abrupt Decay
SB: 1 [ISD:15] Fiend Hunter SB: 1 [ISD:15] Fiend Hunter
SB: 2 [RTR:213] Deathrite Shaman SB: 2 [RTR:213] Deathrite Shaman
SB: 1 [DGM:103] Sin Collector SB: 1 [DGM:103] Sin Collector
SB: 2 [RTR:178] Loxodon Smiter SB: 2 [RTR:178] Loxodon Smiter
SB: 1 [ISD:115] Sever the Bloodline SB: 1 [ISD:115] Sever the Bloodline

View file

@ -1,33 +1,33 @@
NAME:Frédéric Mercier's Esper Control NAME:Frédéric Mercier's Esper Control
2 [M13:26] Planar Cleansing 2 [M13:26] Planar Cleansing
1 [RTR:250] Plains 1 [RTR:250] Plains
4 [M13:225] Glacial Fortress 4 [M13:225] Glacial Fortress
2 [GTC:63] Devour Flesh 2 [GTC:63] Devour Flesh
4 [ISD:83] Think Twice 4 [ISD:83] Think Twice
4 [RTR:145] Azorius Charm 4 [RTR:145] Azorius Charm
2 [ISD:78] Snapcaster Mage 2 [ISD:78] Snapcaster Mage
2 [GTC:249] Watery Grave 2 [GTC:249] Watery Grave
1 [RTR:82] Ultimate Price 1 [RTR:82] Ultimate Price
1 [RTR:156] Dramatic Rescue 1 [RTR:156] Dramatic Rescue
2 [GPT:157] Godless Shrine 2 [GPT:157] Godless Shrine
3 [AVR:32] Restoration Angel 3 [AVR:32] Restoration Angel
4 [M13:43] Augur of Bolas 4 [M13:43] Augur of Bolas
4 [ISD:242] Isolated Chapel 4 [ISD:242] Isolated Chapel
4 [RTR:201] Supreme Verdict 4 [RTR:201] Supreme Verdict
2 [MIR:61] Dissipate 2 [MIR:61] Dissipate
1 [RTR:256] Island 1 [RTR:256] Island
1 [RTR:255] Island 1 [RTR:255] Island
4 [ISD:245] Nephalia Drownyard 4 [ISD:245] Nephalia Drownyard
4 [RTR:241] Hallowed Fountain 4 [RTR:241] Hallowed Fountain
4 [M13:223] Drowned Catacomb 4 [M13:223] Drowned Catacomb
4 [RTR:200] Sphinx's Revelation 4 [RTR:200] Sphinx's Revelation
SB: 1 [WWK:26] Dispel SB: 1 [WWK:26] Dispel
SB: 3 [AVR:104] Gloom Surgeon SB: 3 [AVR:104] Gloom Surgeon
SB: 2 [M11:96] Duress SB: 2 [M11:96] Duress
SB: 2 [ISD:236] Witchbane Orb SB: 2 [ISD:236] Witchbane Orb
SB: 1 [RTR:18] Rest in Peace SB: 1 [RTR:18] Rest in Peace
SB: 1 [RTR:36] Dispel SB: 1 [RTR:36] Dispel
SB: 1 [SOK:158] Pithing Needle SB: 1 [SOK:158] Pithing Needle
SB: 1 [RTR:47] Psychic Spiral SB: 1 [RTR:47] Psychic Spiral
SB: 2 [M13:56] Jace, Memory Adept SB: 2 [M13:56] Jace, Memory Adept
SB: 1 [M12:69] Negate SB: 1 [M12:69] Negate

View file

@ -1,36 +1,36 @@
NAME:Jérémy Dezani's Jund Midrange NAME:Jérémy Dezani's Jund Midrange
4 [M13:170] Farseek 4 [M13:170] Farseek
3 [AVR:129] Bonfire of the Damned 3 [AVR:129] Bonfire of the Damned
1 [DKA:76] Tragic Slip 1 [DKA:76] Tragic Slip
4 [ISD:249] Woodland Cemetery 4 [ISD:249] Woodland Cemetery
2 [RTR:141] Abrupt Decay 2 [RTR:141] Abrupt Decay
3 [ISD:105] Liliana of the Veil 3 [ISD:105] Liliana of the Veil
3 [M13:222] Dragonskull Summit 3 [M13:222] Dragonskull Summit
1 [RTR:82] Ultimate Price 1 [RTR:82] Ultimate Price
2 [ISD:243] Kessig Wolf Run 2 [ISD:243] Kessig Wolf Run
1 [M13:217] Staff of Nin 1 [M13:217] Staff of Nin
1 [M13:101] Murder 1 [M13:101] Murder
4 [GTC:247] Stomping Ground 4 [GTC:247] Stomping Ground
3 [ISD:215] Olivia Voldaren 3 [ISD:215] Olivia Voldaren
2 [M13:174] Garruk, Primal Hunter 2 [M13:174] Garruk, Primal Hunter
2 [RTR:188] Rakdos's Return 2 [RTR:188] Rakdos's Return
4 [DKA:140] Huntmaster of the Fells 4 [DKA:140] Huntmaster of the Fells
4 [RTR:243] Overgrown Tomb 4 [RTR:243] Overgrown Tomb
2 [M13:160] Arbor Elf 2 [M13:160] Arbor Elf
4 [M13:193] Thragtusk 4 [M13:193] Thragtusk
4 [RTR:238] Blood Crypt 4 [RTR:238] Blood Crypt
2 [M13:228] Rootbound Crag 2 [M13:228] Rootbound Crag
1 [RTR:101] Mizzium Mortars 1 [RTR:101] Mizzium Mortars
1 [RTR:157] Dreadbore 1 [RTR:157] Dreadbore
2 [RTR:270] Forest 2 [RTR:270] Forest
SB: 1 [RTR:188] Rakdos's Return SB: 1 [RTR:188] Rakdos's Return
SB: 1 [AVR:129] Bonfire of the Damned SB: 1 [AVR:129] Bonfire of the Damned
SB: 1 [DKA:76] Tragic Slip SB: 1 [DKA:76] Tragic Slip
SB: 2 [M13:159] Acidic Slime SB: 2 [M13:159] Acidic Slime
SB: 1 [RTR:141] Abrupt Decay SB: 1 [RTR:141] Abrupt Decay
SB: 1 [DKA:149] Grafdigger's Cage SB: 1 [DKA:149] Grafdigger's Cage
SB: 2 [M13:90] Duress SB: 2 [M13:90] Duress
SB: 1 [M13:219] Tormod's Crypt SB: 1 [M13:219] Tormod's Crypt
SB: 3 [RTR:197] Slaughter Games SB: 3 [RTR:197] Slaughter Games
SB: 1 [RTR:101] Mizzium Mortars SB: 1 [RTR:101] Mizzium Mortars
SB: 1 [AVR:149] Pillar of Flame SB: 1 [AVR:149] Pillar of Flame

View file

@ -1,32 +1,32 @@
NAME:Philipp Schönegger's Miracles NAME:Philipp Schönegger's Miracles
4 [C13:341] Island 4 [C13:341] Island
4 [CHK:268] Sensei's Divining Top 4 [CHK:268] Sensei's Divining Top
4 [ONS:316] Flooded Strand 4 [ONS:316] Flooded Strand
2 [AVR:20] Entreat the Angels 2 [AVR:20] Entreat the Angels
3 [WWK:31] Jace, the Mind Sculptor 3 [WWK:31] Jace, the Mind Sculptor
3 [ISD:78] Snapcaster Mage 3 [ISD:78] Snapcaster Mage
4 [ALL:42] Force of Will 4 [ALL:42] Force of Will
2 [ZEN:211] Arid Mesa 2 [ZEN:211] Arid Mesa
2 [M12:73] Ponder 2 [M12:73] Ponder
1 [MMA:70] Vendilion Clique 1 [MMA:70] Vendilion Clique
4 [CMD:40] Brainstorm 4 [CMD:40] Brainstorm
1 [LEG:248] Karakas 1 [LEG:248] Karakas
2 [7ED:67] Counterspell 2 [7ED:67] Counterspell
3 [CSP:31] Counterbalance 3 [CSP:31] Counterbalance
4 [AVR:38] Terminus 4 [AVR:38] Terminus
4 [ZEN:223] Scalding Tarn 4 [ZEN:223] Scalding Tarn
2 [ZEN:67] Spell Pierce 2 [ZEN:67] Spell Pierce
2 [C13:337] Plains 2 [C13:337] Plains
2 [3ED:306] Volcanic Island 2 [3ED:306] Volcanic Island
3 [3ED:304] Tundra 3 [3ED:304] Tundra
4 [DDF:22] Swords to Plowshares 4 [DDF:22] Swords to Plowshares
SB: 1 [5ED:262] Pyroblast SB: 1 [5ED:262] Pyroblast
SB: 1 [AVR:20] Entreat the Angels SB: 1 [AVR:20] Entreat the Angels
SB: 3 [CMD:46] Flusterstorm SB: 3 [CMD:46] Flusterstorm
SB: 2 [4ED:236] Red Elemental Blast SB: 2 [4ED:236] Red Elemental Blast
SB: 1 [TSB:6] Disenchant SB: 1 [TSB:6] Disenchant
SB: 2 [MMA:204] Engineered Explosives SB: 2 [MMA:204] Engineered Explosives
SB: 1 [7ED:67] Counterspell SB: 1 [7ED:67] Counterspell
SB: 1 [RTR:201] Supreme Verdict SB: 1 [RTR:201] Supreme Verdict
SB: 1 [MMA:70] Vendilion Clique SB: 1 [MMA:70] Vendilion Clique
SB: 2 [RTR:18] Rest in Peace SB: 2 [RTR:18] Rest in Peace

View file

@ -1,42 +1,42 @@
NAME:Stefan Böttcher's Deathblade NAME:Stefan Böttcher's Deathblade
1 [WWK:134] Creeping Tar Pit 1 [WWK:134] Creeping Tar Pit
4 [RTR:213] Deathrite Shaman 4 [RTR:213] Deathrite Shaman
1 [AVR:20] Entreat the Angels 1 [AVR:20] Entreat the Angels
2 [C13:63] True-Name Nemesis 2 [C13:63] True-Name Nemesis
2 [WWK:31] Jace, the Mind Sculptor 2 [WWK:31] Jace, the Mind Sculptor
3 [ISD:78] Snapcaster Mage 3 [ISD:78] Snapcaster Mage
3 [MMA:75] Dark Confidant 3 [MMA:75] Dark Confidant
1 [MMA:70] Vendilion Clique 1 [MMA:70] Vendilion Clique
1 [NPH:130] Batterskull 1 [NPH:130] Batterskull
1 [ARB:85] Zealous Persecution 1 [ARB:85] Zealous Persecution
4 [CMD:40] Brainstorm 4 [CMD:40] Brainstorm
2 [THS:107] Thoughtseize 2 [THS:107] Thoughtseize
1 [MMA:204] Engineered Explosives 1 [MMA:204] Engineered Explosives
1 [BOK:163] Umezawa's Jitte 1 [BOK:163] Umezawa's Jitte
1 [3ED:298] Scrubland 1 [3ED:298] Scrubland
1 [C13:337] Plains 1 [C13:337] Plains
3 [3ED:305] Underground Sea 3 [3ED:305] Underground Sea
3 [3ED:304] Tundra 3 [3ED:304] Tundra
4 [DDF:22] Swords to Plowshares 4 [DDF:22] Swords to Plowshares
1 [3ED:303] Tropical Island 1 [3ED:303] Tropical Island
1 [C13:341] Island 1 [C13:341] Island
3 [ONS:316] Flooded Strand 3 [ONS:316] Flooded Strand
1 [C13:345] Swamp 1 [C13:345] Swamp
1 [ZEN:219] Marsh Flats 1 [ZEN:219] Marsh Flats
2 [TMP:340] Wasteland 2 [TMP:340] Wasteland
1 [LEG:248] Karakas 1 [LEG:248] Karakas
1 [MMA:219] Academy Ruins 1 [MMA:219] Academy Ruins
1 [7ED:67] Counterspell 1 [7ED:67] Counterspell
3 [ONS:321] Polluted Delta 3 [ONS:321] Polluted Delta
3 [ZEN:67] Spell Pierce 3 [ZEN:67] Spell Pierce
3 [WWK:20] Stoneforge Mystic 3 [WWK:20] Stoneforge Mystic
SB: 1 [ISD:105] Liliana of the Veil SB: 1 [ISD:105] Liliana of the Veil
SB: 1 [RTR:155] Detention Sphere SB: 1 [RTR:155] Detention Sphere
SB: 3 [ALL:42] Force of Will SB: 3 [ALL:42] Force of Will
SB: 1 [RTR:201] Supreme Verdict SB: 1 [RTR:201] Supreme Verdict
SB: 3 [M11:21] Leyline of Sanctity SB: 3 [M11:21] Leyline of Sanctity
SB: 1 [MBS:138] Sword of Feast and Famine SB: 1 [MBS:138] Sword of Feast and Famine
SB: 2 [NPH:74] Surgical Extraction SB: 2 [NPH:74] Surgical Extraction
SB: 1 [THS:65] Swan Song SB: 1 [THS:65] Swan Song
SB: 1 [MMA:213] Relic of Progenitus SB: 1 [MMA:213] Relic of Progenitus
SB: 1 [NMS:111] Reverent Silence SB: 1 [NMS:111] Reverent Silence

View file

@ -1,6 +0,0 @@
XMage.de 1 (Europe/Germany) fast :xmage.de:17171
old xmage.de (Europe/Germany) :185.3.232.200:17171
XMage Players MTG:xmageplayersmtg.ddns.net:17171
XMage.tahiti :xmage.tahiti.one:443
Seedds Server (Asia) :115.29.203.80:17171
localhost -> connect to your local server (must be started):localhost:17171

View file

@ -1,6 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Container class="javax.swing.JPopupMenu" name="popupDebug">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuDebugTestModalDialog">
<Properties>
<Property name="text" type="java.lang.String" value="Test Modal Dialogs"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestModalDialogActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Container>
</NonVisualComponents>
<Properties> <Properties>
<Property name="defaultCloseOperation" type="int" value="0"/> <Property name="defaultCloseOperation" type="int" value="0"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@ -26,7 +44,7 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="desktopPane" alignment="0" pref="769" max="32767" attributes="0"/> <Component id="desktopPane" alignment="0" pref="838" max="32767" attributes="0"/>
<Component id="mageToolbar" alignment="0" max="32767" attributes="0"/> <Component id="mageToolbar" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -85,7 +103,6 @@
<Property name="toolTipText" type="java.lang.String" value="By changing the settings in the preferences window you can adjust the look and behaviour of xmage."/> <Property name="toolTipText" type="java.lang.String" value="By changing the settings in the preferences window you can adjust the look and behaviour of xmage."/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPreferencesActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPreferencesActionPerformed"/>
@ -101,7 +118,6 @@
<Property name="toolTipText" type="java.lang.String" value="Connect to or disconnect from a XMage server."/> <Property name="toolTipText" type="java.lang.String" value="Connect to or disconnect from a XMage server."/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnConnectActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnConnectActionPerformed"/>
@ -118,7 +134,6 @@
<Property name="toolTipText" type="java.lang.String" value="Start the deck editor to create or modify decks."/> <Property name="toolTipText" type="java.lang.String" value="Start the deck editor to create or modify decks."/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDeckEditorActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDeckEditorActionPerformed"/>
@ -131,11 +146,10 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/menu/collection.png"/> <Image iconType="3" name="/menu/collection.png"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Viewer"/> <Property name="text" type="java.lang.String" value="Card Viewer"/>
<Property name="toolTipText" type="java.lang.String" value="Card viewer to show the cards of sets. "/> <Property name="toolTipText" type="java.lang.String" value="Card viewer to show the cards of sets. "/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCollectionViewerActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCollectionViewerActionPerformed"/>
@ -152,7 +166,6 @@
<Property name="toolTipText" type="java.lang.String" value="Send some feedback to the developers."/> <Property name="toolTipText" type="java.lang.String" value="Send some feedback to the developers."/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSendFeedbackActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSendFeedbackActionPerformed"/>
@ -169,7 +182,6 @@
<Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Load the mana and other card symbols from the internet.&lt;br&gt;&#xa;Otherwise you only see the replacement sequence like {U} for blue mana symbol.&lt;br&gt;&#xa;You need to do that only once."/> <Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Load the mana and other card symbols from the internet.&lt;br&gt;&#xa;Otherwise you only see the replacement sequence like {U} for blue mana symbol.&lt;br&gt;&#xa;You need to do that only once."/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSymbolsActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSymbolsActionPerformed"/>
@ -186,7 +198,6 @@
<Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Load card images from external sources."/> <Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Load card images from external sources."/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImagesActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImagesActionPerformed"/>
@ -200,10 +211,9 @@
<Image iconType="3" name="/menu/about.png"/> <Image iconType="3" name="/menu/about.png"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="About"/> <Property name="text" type="java.lang.String" value="About"/>
<Property name="toolTipText" type="java.lang.String" value="Some information about the developers."/> <Property name="toolTipText" type="java.lang.String" value="About app"/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="4"/> <Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAboutActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAboutActionPerformed"/>
@ -211,6 +221,22 @@
</Component> </Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator7"> <Component class="javax.swing.JToolBar$Separator" name="jSeparator7">
</Component> </Component>
<Component class="javax.swing.JButton" name="btnDebug">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/menu/connect.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Debug"/>
<Property name="toolTipText" type="java.lang.String" value="Show debug tools"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnDebugMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JToolBar$Separator" name="separatorDebug">
</Component>
<Component class="javax.swing.JLabel" name="jMemUsageLabel"> <Component class="javax.swing.JLabel" name="jMemUsageLabel">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="2"/> <Property name="horizontalAlignment" type="int" value="2"/>

View file

@ -1,24 +1,11 @@
package mage.client; package mage.client;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import mage.cards.action.ActionCallback; import mage.cards.action.ActionCallback;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.cards.repository.CardScanner;
import mage.cards.repository.ExpansionRepository;
import mage.cards.repository.RepositoryUtil;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.chat.ChatPanelBasic; import mage.client.chat.ChatPanelBasic;
import mage.client.components.*; import mage.client.components.*;
@ -47,6 +34,7 @@ import mage.client.util.stats.UpdateMemUsageTask;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle; import mage.components.ImagePanelStyle;
import mage.constants.PlayerAction; import mage.constants.PlayerAction;
import mage.game.draft.RateCard;
import mage.interfaces.MageClient; import mage.interfaces.MageClient;
import mage.interfaces.callback.CallbackClient; import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
@ -63,12 +51,28 @@ import net.java.truevfs.access.TConfig;
import net.java.truevfs.kernel.spec.FsAccessOption; import net.java.truevfs.kernel.spec.FsAccessOption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.card.arcane.ManaSymbols; import org.mage.card.arcane.ManaSymbols;
import org.mage.plugins.card.images.DownloadPictures; import org.mage.plugins.card.images.DownloadPicturesService;
import org.mage.plugins.card.info.CardInfoPaneImpl; import org.mage.plugins.card.info.CardInfoPaneImpl;
import org.mage.plugins.card.utils.impl.ImageManagerImpl; import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com, JayDi85
*/ */
public class MageFrame extends javax.swing.JFrame implements MageClient { public class MageFrame extends javax.swing.JFrame implements MageClient {
@ -83,17 +87,19 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static final String PASSWORD_ARG = "-pw"; private static final String PASSWORD_ARG = "-pw";
private static final String SERVER_ARG = "-server"; private static final String SERVER_ARG = "-server";
private static final String PORT_ARG = "-port"; private static final String PORT_ARG = "-port";
private static final String DEBUG_ARG = "-debug";
private static final String NOT_CONNECTED_TEXT = "<not connected>"; private static final String NOT_CONNECTED_TEXT = "<not connected>";
private static MageFrame instance; private static MageFrame instance;
private final ConnectDialog connectDialog; private final ConnectDialog connectDialog;
private WhatsNewDialog whatsNewDialog; // can be null
private final ErrorDialog errorDialog; private final ErrorDialog errorDialog;
private static CallbackClient callbackClient; private static CallbackClient callbackClient;
private static final Preferences PREFS = Preferences.userNodeForPackage(MageFrame.class); private static final Preferences PREFS = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title; private JLabel title;
private Rectangle titleRectangle; private Rectangle titleRectangle;
private static final MageVersion VERSION = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO); private static final MageVersion VERSION = new MageVersion(MageFrame.class);
private Connection currentConnection; private Connection currentConnection;
private static MagePane activeFrame; private static MagePane activeFrame;
private static boolean liteMode = false; private static boolean liteMode = false;
@ -105,6 +111,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static String startPassword = ""; private static String startPassword = "";
private static String startServer = "localhost"; private static String startServer = "localhost";
private static int startPort = -1; private static int startPort = -1;
private static boolean debugMode = false;
private static final Map<UUID, ChatPanelBasic> CHATS = new HashMap<>(); private static final Map<UUID, ChatPanelBasic> CHATS = new HashMap<>();
private static final Map<UUID, GamePanel> GAMES = new HashMap<>(); private static final Map<UUID, GamePanel> GAMES = new HashMap<>();
@ -136,7 +143,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public static boolean isGray() { public static boolean isGray() {
return grayMode; return grayMode;
} }
public static boolean isSkipSmallSymbolGenerationForExisting() { public static boolean isSkipSmallSymbolGenerationForExisting() {
return skipSmallSymbolGenerationForExisting; return skipSmallSymbolGenerationForExisting;
} }
@ -212,6 +219,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
LOGGER.fatal(null, ex); LOGGER.fatal(null, ex);
} }
// DATA PREPARE
RepositoryUtil.bootstrapLocalDb();
// re-create database on empty (e.g. after new build cleaned db on startup)
if (RepositoryUtil.CARD_DB_RECREATE_BY_CLIENT_SIDE && RepositoryUtil.isDatabaseEmpty()) {
LOGGER.info("DB: creating cards database");
CardScanner.scan();
LOGGER.info("Done.");
}
if (RateCard.PRELOAD_CARD_RATINGS_ON_STARTUP) {
RateCard.bootstrapCardsAndRatings();
}
ManaSymbols.loadImages(); ManaSymbols.loadImages();
Plugins.instance.loadPlugins(); Plugins.instance.loadPlugins();
@ -227,6 +246,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
SessionHandler.startSession(this); SessionHandler.startSession(this);
callbackClient = new CallbackClientImpl(this); callbackClient = new CallbackClientImpl(this);
connectDialog = new ConnectDialog(); connectDialog = new ConnectDialog();
try {
whatsNewDialog = new WhatsNewDialog();
} catch (NoClassDefFoundError e) {
// JavaFX is not supported on old MacOS with OpenJDK
// https://bugs.openjdk.java.net/browse/JDK-8202132
LOGGER.error("JavaFX is not supported by your system. What's new page will be disabled.", e);
whatsNewDialog = null;
}
desktopPane.add(connectDialog, JLayeredPane.MODAL_LAYER); desktopPane.add(connectDialog, JLayeredPane.MODAL_LAYER);
errorDialog = new ErrorDialog(); errorDialog = new ErrorDialog();
errorDialog.setLocation(100, 100); errorDialog.setLocation(100, 100);
@ -281,7 +308,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (Plugins.instance.isCounterPluginLoaded()) { if (Plugins.instance.isCounterPluginLoaded()) {
int i = Plugins.instance.getGamesPlayed(); int i = Plugins.instance.getGamesPlayed();
JLabel label = new JLabel(" Games played: " + String.valueOf(i)); JLabel label = new JLabel(" Games played: " + i);
desktopPane.add(label, JLayeredPane.DEFAULT_LAYER + 1); desktopPane.add(label, JLayeredPane.DEFAULT_LAYER + 1);
label.setVisible(true); label.setVisible(true);
label.setForeground(Color.white); label.setForeground(Color.white);
@ -313,6 +340,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
SystemUtil.toggleMacOSFullScreenMode(this); SystemUtil.toggleMacOSFullScreenMode(this);
} }
} }
// run what's new checks (loading in background)
SwingUtilities.invokeLater(() -> {
showWhatsNewDialog(false);
});
} }
private void setWindowTitle() { private void setWindowTitle() {
@ -321,61 +353,76 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
+ ((SessionHandler.getSession() != null && SessionHandler.isConnected()) ? SessionHandler.getVersionInfo() : NOT_CONNECTED_TEXT)); + ((SessionHandler.getSession() != null && SessionHandler.isConnected()) ? SessionHandler.getVersionInfo() : NOT_CONNECTED_TEXT));
} }
private void updateTooltipContainerSizes() {
JPanel cardPreviewContainer;
BigCard bigCard;
JPanel cardPreviewContainerRotated;
BigCard bigCardRotated;
try {
cardPreviewContainer = (JPanel) UI.getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
bigCard = (BigCard) UI.getComponent(MageComponents.CARD_PREVIEW_PANE);
cardPreviewContainerRotated = (JPanel) UI.getComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED);
bigCardRotated = (BigCard) UI.getComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED);
} catch (InterruptedException e) {
LOGGER.fatal("Can't update tooltip panel sizes");
Thread.currentThread().interrupt();
return;
}
int height = GUISizeHelper.enlargedImageHeight;
int width = (int) ((float) height * (float) 0.64);
bigCard.setSize(width, height);
cardPreviewContainer.setBounds(0, 0, width + 80, height + 30);
bigCardRotated.setSize(height, width + 30);
cardPreviewContainerRotated.setBounds(0, 0, height + 80, width + 100 + 30);
}
private void addTooltipContainer() { private void addTooltipContainer() {
final JEditorPane cardInfoPane = (JEditorPane) Plugins.instance.getCardInfoPane(); JEditorPane cardInfoPane = (JEditorPane) Plugins.instance.getCardInfoPane();
if (cardInfoPane == null) { if (cardInfoPane == null) {
LOGGER.fatal("Can't find card tooltip plugin");
return; return;
} }
cardInfoPane.setLocation(40, 40); cardInfoPane.setLocation(40, 40);
cardInfoPane.setBackground(new Color(0, 0, 0, 0)); cardInfoPane.setBackground(new Color(0, 0, 0, 0));
UI.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
MageRoundPane popupContainer = new MageRoundPane(); MageRoundPane popupContainer = new MageRoundPane();
popupContainer.setLayout(null); popupContainer.setLayout(null);
popupContainer.add(cardInfoPane); popupContainer.add(cardInfoPane);
popupContainer.setVisible(false); popupContainer.setVisible(false);
desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER); desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER);
UI.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
UI.addComponent(MageComponents.POPUP_CONTAINER, popupContainer); UI.addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
// preview panel normal
JPanel cardPreviewContainer = new JPanel(); JPanel cardPreviewContainer = new JPanel();
cardPreviewContainer.setOpaque(false); cardPreviewContainer.setOpaque(false);
cardPreviewContainer.setLayout(null); cardPreviewContainer.setLayout(null);
BigCard bigCard = new BigCard();
int height = GUISizeHelper.enlargedImageHeight;
int width = (int) ((float) height * (float) 0.64);
bigCard.setSize(width, height);
bigCard.setLocation(40, 40);
bigCard.setBackground(new Color(0, 0, 0, 0));
cardPreviewContainer.add(bigCard);
cardPreviewContainer.setVisible(false); cardPreviewContainer.setVisible(false);
cardPreviewContainer.setBounds(0, 0, width + 80, height + 30); desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER);
UI.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard);
UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer); UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer);
desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER); BigCard bigCard = new BigCard();
bigCard.setLocation(40, 40);
bigCard.setBackground(new Color(0, 0, 0, 0));
cardPreviewContainer.add(bigCard);
UI.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard);
// preview panel rotated
JPanel cardPreviewContainerRotated = new JPanel(); JPanel cardPreviewContainerRotated = new JPanel();
cardPreviewContainerRotated.setOpaque(false); cardPreviewContainerRotated.setOpaque(false);
cardPreviewContainerRotated.setLayout(null); cardPreviewContainerRotated.setLayout(null);
bigCard = new BigCard(true);
bigCard.setSize(height, width + 30);
bigCard.setLocation(40, 40);
bigCard.setBackground(new Color(0, 0, 0, 0));
cardPreviewContainerRotated.add(bigCard);
cardPreviewContainerRotated.setVisible(false); cardPreviewContainerRotated.setVisible(false);
cardPreviewContainerRotated.setBounds(0, 0, height + 80, width + 100 + 30); desktopPane.add(cardPreviewContainerRotated, JLayeredPane.POPUP_LAYER);
UI.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCard);
UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated); UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated);
desktopPane.add(cardPreviewContainerRotated, JLayeredPane.POPUP_LAYER);
BigCard bigCardRotated = new BigCard(true);
bigCardRotated.setLocation(40, 40);
bigCardRotated.setBackground(new Color(0, 0, 0, 0));
cardPreviewContainerRotated.add(bigCardRotated);
UI.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCardRotated);
updateTooltipContainerSizes();
} }
private void setGUISizeTooltipContainer() { private void setGUISizeTooltipContainer() {
@ -547,8 +594,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
container.repaint(); container.repaint();
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOGGER.fatal("MageFrame error", e);
Thread.currentThread().interrupt();
} }
// Nothing to do // Nothing to do
if (activeFrame == frame) { if (activeFrame == frame) {
return; return;
@ -717,6 +766,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
boolean autoConnectParamValue = startUser != null || Boolean.parseBoolean(PREFS.get("autoConnect", "false")); boolean autoConnectParamValue = startUser != null || Boolean.parseBoolean(PREFS.get("autoConnect", "false"));
boolean status = false; boolean status = false;
if (autoConnectParamValue) { if (autoConnectParamValue) {
LOGGER.info("Auto-connecting to " + MagePreferences.getServerAddress());
status = performConnect(false); status = performConnect(false);
} }
return status; return status;
@ -724,10 +774,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private boolean performConnect(boolean reconnect) { private boolean performConnect(boolean reconnect) {
if (currentConnection == null || !reconnect) { if (currentConnection == null || !reconnect) {
String server = MagePreferences.getServerAddress(); String server = MagePreferences.getLastServerAddress();
int port = MagePreferences.getServerPort(); int port = MagePreferences.getLastServerPort();
String userName = MagePreferences.getUserName(server); String userName = MagePreferences.getLastServerUser();
String password = MagePreferences.getPassword(server); String password = MagePreferences.getLastServerPassword();
String proxyServer = PREFS.get("proxyAddress", ""); String proxyServer = PREFS.get("proxyAddress", "");
int proxyPort = Integer.parseInt(PREFS.get("proxyPort", "0")); int proxyPort = Integer.parseInt(PREFS.get("proxyPort", "0"));
ProxyType proxyType = ProxyType.valueByText(PREFS.get("proxyType", "None")); ProxyType proxyType = ProxyType.valueByText(PREFS.get("proxyType", "None"));
@ -739,6 +789,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
currentConnection.setPassword(password); currentConnection.setPassword(password);
currentConnection.setHost(server); currentConnection.setHost(server);
currentConnection.setPort(port); currentConnection.setPort(port);
// force to redownload db on updates
boolean redownloadDatabase = (ExpansionRepository.instance.getSetByCode("GRN") == null || CardRepository.instance.findCard("Island") == null);
currentConnection.setForceDBComparison(redownloadDatabase);
String allMAC = ""; String allMAC = "";
try { try {
allMAC = Connection.getMAC(); allMAC = Connection.getMAC();
@ -760,7 +813,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
prepareAndShowTablesPane(); prepareAndShowTablesPane();
return true; return true;
} else { } else {
showMessage("Unable to connect to server"); showMessage("Unable connect to server: " + SessionHandler.getLastConnectError());
} }
} finally { } finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
@ -781,6 +834,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
popupDebug = new javax.swing.JPopupMenu();
menuDebugTestModalDialog = new javax.swing.JMenuItem();
desktopPane = new MageJDesktop(); desktopPane = new MageJDesktop();
mageToolbar = new javax.swing.JToolBar(); mageToolbar = new javax.swing.JToolBar();
btnPreferences = new javax.swing.JButton(); btnPreferences = new javax.swing.JButton();
@ -799,8 +854,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
jSeparatorImages = new javax.swing.JToolBar.Separator(); jSeparatorImages = new javax.swing.JToolBar.Separator();
btnAbout = new javax.swing.JButton(); btnAbout = new javax.swing.JButton();
jSeparator7 = new javax.swing.JToolBar.Separator(); jSeparator7 = new javax.swing.JToolBar.Separator();
btnDebug = new javax.swing.JButton();
separatorDebug = new javax.swing.JToolBar.Separator();
jMemUsageLabel = new javax.swing.JLabel(); jMemUsageLabel = new javax.swing.JLabel();
menuDebugTestModalDialog.setText("Test Modal Dialogs");
menuDebugTestModalDialog.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuDebugTestModalDialogActionPerformed(evt);
}
});
popupDebug.add(menuDebugTestModalDialog);
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(1024, 768)); setMinimumSize(new java.awt.Dimension(1024, 768));
@ -818,7 +883,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnPreferences.setToolTipText("By changing the settings in the preferences window you can adjust the look and behaviour of xmage."); btnPreferences.setToolTipText("By changing the settings in the preferences window you can adjust the look and behaviour of xmage.");
btnPreferences.setFocusable(false); btnPreferences.setFocusable(false);
btnPreferences.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnPreferences.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnPreferences.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnPreferences.addActionListener(new java.awt.event.ActionListener() { btnPreferences.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreferencesActionPerformed(evt); btnPreferencesActionPerformed(evt);
@ -831,7 +895,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnConnect.setToolTipText("Connect to or disconnect from a XMage server."); btnConnect.setToolTipText("Connect to or disconnect from a XMage server.");
btnConnect.setFocusable(false); btnConnect.setFocusable(false);
btnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnConnect.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnConnect.addActionListener(new java.awt.event.ActionListener() { btnConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConnectActionPerformed(evt); btnConnectActionPerformed(evt);
@ -845,7 +908,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnDeckEditor.setToolTipText("Start the deck editor to create or modify decks."); btnDeckEditor.setToolTipText("Start the deck editor to create or modify decks.");
btnDeckEditor.setFocusable(false); btnDeckEditor.setFocusable(false);
btnDeckEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnDeckEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnDeckEditor.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnDeckEditor.addActionListener(new java.awt.event.ActionListener() { btnDeckEditor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeckEditorActionPerformed(evt); btnDeckEditorActionPerformed(evt);
@ -855,11 +917,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
mageToolbar.add(jSeparator2); mageToolbar.add(jSeparator2);
btnCollectionViewer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/collection.png"))); // NOI18N btnCollectionViewer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/collection.png"))); // NOI18N
btnCollectionViewer.setText("Viewer"); btnCollectionViewer.setText("Card Viewer");
btnCollectionViewer.setToolTipText("Card viewer to show the cards of sets. "); btnCollectionViewer.setToolTipText("Card viewer to show the cards of sets. ");
btnCollectionViewer.setFocusable(false); btnCollectionViewer.setFocusable(false);
btnCollectionViewer.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnCollectionViewer.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnCollectionViewer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnCollectionViewer.addActionListener(new java.awt.event.ActionListener() { btnCollectionViewer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCollectionViewerActionPerformed(evt); btnCollectionViewerActionPerformed(evt);
@ -873,7 +934,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnSendFeedback.setToolTipText("Send some feedback to the developers."); btnSendFeedback.setToolTipText("Send some feedback to the developers.");
btnSendFeedback.setFocusable(false); btnSendFeedback.setFocusable(false);
btnSendFeedback.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnSendFeedback.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnSendFeedback.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSendFeedback.addActionListener(new java.awt.event.ActionListener() { btnSendFeedback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSendFeedbackActionPerformed(evt); btnSendFeedbackActionPerformed(evt);
@ -887,7 +947,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnSymbols.setToolTipText("<HTML>Load the mana and other card symbols from the internet.<br>\nOtherwise you only see the replacement sequence like {U} for blue mana symbol.<br>\nYou need to do that only once."); btnSymbols.setToolTipText("<HTML>Load the mana and other card symbols from the internet.<br>\nOtherwise you only see the replacement sequence like {U} for blue mana symbol.<br>\nYou need to do that only once.");
btnSymbols.setFocusable(false); btnSymbols.setFocusable(false);
btnSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnSymbols.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSymbols.addActionListener(new java.awt.event.ActionListener() { btnSymbols.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSymbolsActionPerformed(evt); btnSymbolsActionPerformed(evt);
@ -901,7 +960,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnImages.setToolTipText("<HTML>Load card images from external sources."); btnImages.setToolTipText("<HTML>Load card images from external sources.");
btnImages.setFocusable(false); btnImages.setFocusable(false);
btnImages.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnImages.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnImages.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnImages.addActionListener(new java.awt.event.ActionListener() { btnImages.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImagesActionPerformed(evt); btnImagesActionPerformed(evt);
@ -912,10 +970,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/about.png"))); // NOI18N btnAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/about.png"))); // NOI18N
btnAbout.setText("About"); btnAbout.setText("About");
btnAbout.setToolTipText("Some information about the developers."); btnAbout.setToolTipText("About app");
btnAbout.setFocusable(false); btnAbout.setFocusable(false);
btnAbout.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnAbout.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnAbout.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnAbout.addActionListener(new java.awt.event.ActionListener() { btnAbout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAboutActionPerformed(evt); btnAboutActionPerformed(evt);
@ -924,6 +981,19 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
mageToolbar.add(btnAbout); mageToolbar.add(btnAbout);
mageToolbar.add(jSeparator7); mageToolbar.add(jSeparator7);
btnDebug.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/connect.png"))); // NOI18N
btnDebug.setText("Debug");
btnDebug.setToolTipText("Show debug tools");
btnDebug.setFocusable(false);
btnDebug.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnDebug.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnDebugMouseClicked(evt);
}
});
mageToolbar.add(btnDebug);
mageToolbar.add(separatorDebug);
jMemUsageLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jMemUsageLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jMemUsageLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/memory.png"))); // NOI18N jMemUsageLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/menu/memory.png"))); // NOI18N
jMemUsageLabel.setText("100% Free mem"); jMemUsageLabel.setText("100% Free mem");
@ -934,16 +1004,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 769, Short.MAX_VALUE) .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2) .addGap(2, 2, 2)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)) .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
); );
pack(); pack();
@ -1009,8 +1079,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
downloadImages(); downloadImages();
}//GEN-LAST:event_btnImagesActionPerformed }//GEN-LAST:event_btnImagesActionPerformed
private void menuDebugTestModalDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDebugTestModalDialogActionPerformed
final TestModalDialog dialog = new TestModalDialog();
dialog.showDialog();
}//GEN-LAST:event_menuDebugTestModalDialogActionPerformed
private void btnDebugMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnDebugMouseClicked
popupDebug.show(evt.getComponent(), 0, evt.getComponent().getHeight());
}//GEN-LAST:event_btnDebugMouseClicked
public void downloadImages() { public void downloadImages() {
DownloadPictures.startDownload(); DownloadPicturesService.startDownload();
} }
public void exitApp() { public void exitApp() {
@ -1160,7 +1239,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(final String args[]) { public static void main(final String[] args) {
// Workaround for #451 // Workaround for #451
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
LOGGER.info("Starting MAGE client version " + VERSION); LOGGER.info("Starting MAGE client version " + VERSION);
@ -1168,7 +1247,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.fatal(null, e)); Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.fatal(null, e));
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
String arg = args[i]; String arg = args[i];
@ -1184,22 +1263,25 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (arg.startsWith(SKIP_DONE_SYMBOLS)) { if (arg.startsWith(SKIP_DONE_SYMBOLS)) {
skipSmallSymbolGenerationForExisting = true; skipSmallSymbolGenerationForExisting = true;
} }
if (arg.startsWith(USER_ARG)){ if (arg.startsWith(USER_ARG)) {
startUser = args[i+1]; startUser = args[i + 1];
i++; i++;
} }
if (arg.startsWith(PASSWORD_ARG)){ if (arg.startsWith(PASSWORD_ARG)) {
startPassword = args[i+1]; startPassword = args[i + 1];
i++; i++;
} }
if (arg.startsWith(SERVER_ARG)){ if (arg.startsWith(SERVER_ARG)) {
startServer = args[i+1]; startServer = args[i + 1];
i++; i++;
} }
if (arg.startsWith(PORT_ARG)){ if (arg.startsWith(PORT_ARG)) {
startPort = Integer.valueOf(args[i+1]); startPort = Integer.valueOf(args[i + 1]);
i++; i++;
} }
if (arg.startsWith(DEBUG_ARG)) {
debugMode = true;
}
} }
if (!liteMode) { if (!liteMode) {
final SplashScreen splash = SplashScreen.getSplashScreen(); final SplashScreen splash = SplashScreen.getSplashScreen();
@ -1212,14 +1294,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
} }
instance = new MageFrame(); instance = new MageFrame();
if( startUser != null){ // debug menu
instance.separatorDebug.setVisible(debugMode);
instance.btnDebug.setVisible(debugMode);
if (startUser != null) {
instance.currentConnection = new Connection(); instance.currentConnection = new Connection();
instance.currentConnection.setUsername(startUser); instance.currentConnection.setUsername(startUser);
instance.currentConnection.setHost(startServer); instance.currentConnection.setHost(startServer);
if (startPort > 0){ if (startPort > 0) {
instance.currentConnection.setPort(startPort); instance.currentConnection.setPort(startPort);
}else { } else {
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port)); instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
} }
PreferencesDialog.setProxyInformation(instance.currentConnection); PreferencesDialog.setProxyInformation(instance.currentConnection);
@ -1234,6 +1320,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private javax.swing.JButton btnAbout; private javax.swing.JButton btnAbout;
private javax.swing.JButton btnCollectionViewer; private javax.swing.JButton btnCollectionViewer;
private javax.swing.JButton btnConnect; private javax.swing.JButton btnConnect;
private javax.swing.JButton btnDebug;
private javax.swing.JButton btnDeckEditor; private javax.swing.JButton btnDeckEditor;
private javax.swing.JButton btnImages; private javax.swing.JButton btnImages;
private javax.swing.JButton btnPreferences; private javax.swing.JButton btnPreferences;
@ -1250,6 +1337,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private javax.swing.JToolBar.Separator jSeparatorImages; private javax.swing.JToolBar.Separator jSeparatorImages;
private javax.swing.JToolBar.Separator jSeparatorSymbols; private javax.swing.JToolBar.Separator jSeparatorSymbols;
private javax.swing.JToolBar mageToolbar; private javax.swing.JToolBar mageToolbar;
private javax.swing.JMenuItem menuDebugTestModalDialog;
private javax.swing.JPopupMenu popupDebug;
private javax.swing.JToolBar.Separator separatorDebug;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private static final long serialVersionUID = -9104885239063142218L; private static final long serialVersionUID = -9104885239063142218L;
@ -1329,28 +1419,30 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
@Override @Override
public void disconnected(final boolean errorCall) { public void disconnected(final boolean askToReconnect) {
if (SwingUtilities.isEventDispatchThread()) { // Returns true if the current thread is an AWT event dispatching thread. if (SwingUtilities.isEventDispatchThread()) { // Returns true if the current thread is an AWT event dispatching thread.
LOGGER.info("DISCONNECTED (Event Dispatch Thread)"); // REMOTE task, e.g. connecting
LOGGER.info("Disconnected from remote task");
setConnectButtonText(NOT_CONNECTED_TEXT); setConnectButtonText(NOT_CONNECTED_TEXT);
disableButtons(); disableButtons();
hideGames(); hideGames();
hideTables(); hideTables();
} else { } else {
LOGGER.info("DISCONNECTED (NO Event Dispatch Thread)"); // USER mode, e.g. user plays and got disconnect
LOGGER.info("Disconnected from user mode");
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
setConnectButtonText(NOT_CONNECTED_TEXT); SessionHandler.disconnect(false); // user already disconnected, can't do any online actions like quite chat
disableButtons(); setConnectButtonText(NOT_CONNECTED_TEXT);
hideGames(); disableButtons();
hideTables(); hideGames();
SessionHandler.disconnect(false); hideTables();
if (errorCall) { if (askToReconnect) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect?"); UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + MagePreferences.getLastServerAddress() + "?");
message.setButton1("No", null); message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT); message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message); showUserRequestDialog(message);
} }
} }
); );
} }
} }
@ -1380,7 +1472,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
Plugins.instance.downloadSymbols(); Plugins.instance.downloadSymbols();
break; break;
case CLIENT_DOWNLOAD_CARD_IMAGES: case CLIENT_DOWNLOAD_CARD_IMAGES:
DownloadPictures.startDownload(); DownloadPicturesService.startDownload();
break; break;
case CLIENT_DISCONNECT: case CLIENT_DISCONNECT:
if (SessionHandler.isConnected()) { if (SessionHandler.isConnected()) {
@ -1509,7 +1601,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
balloonTip.setFont(GUISizeHelper.balloonTooltipFont); balloonTip.setFont(GUISizeHelper.balloonTooltipFont);
addTooltipContainer(); updateTooltipContainerSizes();
}
public void showWhatsNewDialog(boolean forceToShowPage) {
if (whatsNewDialog != null) {
whatsNewDialog.checkUpdatesAndShow(forceToShowPage);
}
} }
} }

View file

@ -1,76 +1,78 @@
/* /*
* MagePane.java * MagePane.java
* *
* Created on 15-Dec-2009, 9:34:25 PM * Created on 15-Dec-2009, 9:34:25 PM
*/ */
package mage.client; package mage.client;
import java.awt.AWTEvent; import java.awt.*;
import java.awt.KeyboardFocusManager;
/** /**
* * @author BetaSteward_at_googlemail.com
* @author BetaSteward_at_googlemail.com */
*/ public abstract class MagePane extends javax.swing.JLayeredPane {
public abstract class MagePane extends javax.swing.JLayeredPane {
private String title = "no title set"; private String title = "no title set";
/** /**
* Creates new form MagePane * Creates new form MagePane
*/ */
public MagePane() { public MagePane() {
initComponents(); initComponents();
} }
public void changeGUISize() { public void changeGUISize() {
} }
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
public String getTitle() { public String getTitle() {
return title; return title;
} }
public void hideFrame() { public void hideFrame() {
MageFrame.deactivate(this); MageFrame.deactivate(this);
} }
public void removeFrame() { public void removeFrame() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
MageFrame.deactivate(this); MageFrame.deactivate(this);
MageFrame.getDesktop().remove(this); MageFrame.getDesktop().remove(this);
} }
public void activated() { public void activated() {
} }
public void deactivated() { public void deactivated() {
} }
public void handleEvent(AWTEvent event) { public void handleEvent(AWTEvent event) {
} }
/** public Container getContentPane() {
* This method is called from within the constructor to initialize the form. return this;
* 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
private void initComponents() {
setBorder(null); /**
* 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
private void initComponents() {
}// </editor-fold>//GEN-END:initComponents setBorder(null);
// Variables declaration - do not modify//GEN-BEGIN:variables }// </editor-fold>//GEN-END:initComponents
// End of variables declaration//GEN-END:variables
} // Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

View file

@ -1,6 +1,5 @@
package mage.client; package mage.client;
import java.util.*;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
import mage.client.chat.LocalCommands; import mage.client.chat.LocalCommands;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
@ -15,20 +14,30 @@ import mage.remote.MageRemoteException;
import mage.remote.Session; import mage.remote.Session;
import mage.remote.SessionImpl; import mage.remote.SessionImpl;
import mage.view.*; import mage.view.*;
import org.apache.log4j.Logger;
import java.util.*;
/** /**
* Created by IGOUDT on 15-9-2016. * Created by IGOUDT on 15-9-2016.
*/ */
public final class SessionHandler { public final class SessionHandler {
private static final Logger logger = Logger.getLogger(SessionHandler.class);
private static Session session; private static Session session;
private static String lastConnectError = "";
private SessionHandler(){
}
public static void startSession(MageFrame mageFrame) { public static void startSession(MageFrame mageFrame) {
session = new SessionImpl(mageFrame); session = new SessionImpl(mageFrame);
session.setJsonLogActive("true".equals(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_LOG_AUTO_SAVE, "true"))); session.setJsonLogActive("true".equals(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_LOG_AUTO_SAVE, "true")));
} }
public static void ping() { public static void ping() {
session.ping(); session.ping();
} }
@ -46,7 +55,17 @@ public final class SessionHandler {
} }
public static boolean connect(Connection connection) { public static boolean connect(Connection connection) {
return session.connect(connection); lastConnectError = "";
if (session.connect(connection)) {
return true;
} else {
lastConnectError = session.getLastError();
return false;
}
}
public static String getLastConnectError() {
return lastConnectError;
} }
public static boolean stopConnecting() { public static boolean stopConnecting() {
@ -169,7 +188,7 @@ public final class SessionHandler {
try { try {
return session.getTournament(tournamentId); return session.getTournament(tournamentId);
} catch (MageRemoteException e) { } catch (MageRemoteException e) {
e.printStackTrace(); logger.info(e);
return null; return null;
} }
@ -263,7 +282,7 @@ public final class SessionHandler {
try { try {
return session.getRoomUsers(roomId); return session.getRoomUsers(roomId);
} catch (MageRemoteException e) { } catch (MageRemoteException e) {
e.printStackTrace(); logger.info(e);
return Collections.emptyList(); return Collections.emptyList();
} }
} }
@ -272,8 +291,8 @@ public final class SessionHandler {
try { try {
return session.getFinishedMatches(roomId); return session.getFinishedMatches(roomId);
} catch (MageRemoteException e) { } catch (MageRemoteException e) {
e.printStackTrace(); logger.info(e);
return new ArrayList<>(); return Collections.emptyList();
} }
} }
@ -289,8 +308,8 @@ public final class SessionHandler {
try { try {
return session.getTables(roomId); return session.getTables(roomId);
} catch (MageRemoteException e) { } catch (MageRemoteException e) {
e.printStackTrace(); logger.info(e);
return new ArrayList<>(); return Collections.emptyList();
} }
} }

View file

@ -77,7 +77,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
this.gameId = gameId; this.gameId = gameId;
this.card = card; this.card = card;
this.bigCard = bigCard; this.bigCard = bigCard;
small = new BufferedImage(Config.dimensions.frameWidth, Config.dimensions.frameHeight, BufferedImage.TYPE_INT_RGB); small = new BufferedImage(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight(), BufferedImage.TYPE_INT_RGB);
backgroundName = getBackgroundName(); backgroundName = getBackgroundName();
background = ImageHelper.getBackground(card, backgroundName); background = ImageHelper.getBackground(card, backgroundName);
@ -129,7 +129,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gSmall.setColor(Color.BLACK); gSmall.setColor(Color.BLACK);
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.frameWidth, Config.dimensions.frameHeight), 0, 0, this); gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()), 0, 0, this);
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE)); gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET); gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
@ -145,16 +145,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.dispose(); gImage.dispose();
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize)); gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.getNameFontSize()));
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.contentXOffset, Config.dimensions.nameYOffset); gSmall.drawString(card.getName()+"TEST2", Config.dimensions.getContentXOffset(), Config.dimensions.getNameYOffset());
if (card.isCreature()) { if (card.isCreature()) {
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop); gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
} else if (card.isPlanesWalker()) { } else if (card.isPlanesWalker()) {
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop); gSmall.drawString(card.getLoyalty(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
} }
if (!card.getCardTypes().isEmpty()) { if (!card.getCardTypes().isEmpty()) {
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset); gSmall.drawString(cardType, Config.dimensions.getContentXOffset(), Config.dimensions.getTypeYOffset());
} }
drawText(); drawText();
@ -287,7 +287,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
setMinimumSize(getPreferredSize()); setMinimumSize(getPreferredSize());
setOpaque(false); setOpaque(false);
setPreferredSize(new Dimension(dimension.frameWidth, dimension.frameHeight)); setPreferredSize(new Dimension(dimension.getFrameWidth(), dimension.getFrameHeight()));
setLayout(null); setLayout(null);
jScrollPane1.setBorder(null); jScrollPane1.setBorder(null);
@ -304,7 +304,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
add(jScrollPane1); add(jScrollPane1);
jScrollPane1.setBounds(20, 110, 130, 100); jScrollPane1.setBounds(20, 110, 130, 100);
jScrollPane1.setBounds(new Rectangle(dimension.contentXOffset, dimension.textYOffset, dimension.textWidth, dimension.textHeight)); jScrollPane1.setBounds(new Rectangle(dimension.getContentXOffset(), dimension.getTextYOffset(), dimension.getTextWidth(), dimension.getTextHeight()));
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@Override @Override
@ -355,11 +355,11 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
tooltipPopup.hide(); tooltipPopup.hide();
} }
PopupFactory factory = PopupFactory.getSharedInstance(); PopupFactory factory = PopupFactory.getSharedInstance();
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40); tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup.show(); tooltipPopup.show();
//hack to get tooltipPopup to resize to fit text //hack to get tooltipPopup to resize to fit text
tooltipPopup.hide(); tooltipPopup.hide();
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40); tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup.show(); tooltipPopup.show();
tooltipShowing = true; tooltipShowing = true;

View file

@ -1,4 +1,3 @@
package mage.client.cards; package mage.client.cards;
import mage.cards.MageCard; import mage.cards.MageCard;
@ -71,6 +70,14 @@ public class CardArea extends JPanel implements MouseListener {
this.verticalCardOffset = verticalCardOffset; this.verticalCardOffset = verticalCardOffset;
} }
private void fixDialogSize() {
// fix panel size (must include scrolls)
Dimension newSize = new Dimension(cardArea.getPreferredSize());
newSize.width += 20;
newSize.height += 20;
this.setPreferredSize(newSize);
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) { public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
this.reloaded = true; this.reloaded = true;
cardArea.removeAll(); cardArea.removeAll();
@ -85,6 +92,8 @@ public class CardArea extends JPanel implements MouseListener {
this.revalidate(); this.revalidate();
this.repaint(); this.repaint();
fixDialogSize();
} }
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, UUID gameId) { public void loadCardsNarrow(CardsView showCards, BigCard bigCard, UUID gameId) {
@ -98,6 +107,8 @@ public class CardArea extends JPanel implements MouseListener {
this.revalidate(); this.revalidate();
this.repaint(); this.repaint();
fixDialogSize();
} }
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) { private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) {
@ -106,7 +117,7 @@ public class CardArea extends JPanel implements MouseListener {
addCard(card, bigCard, gameId, rectangle); addCard(card, bigCard, gameId, rectangle);
rectangle.translate(cardDimension.width, 0); rectangle.translate(cardDimension.width, 0);
} }
cardArea.setPreferredSize(new Dimension(cardDimension.width * showCards.size(), cardDimension.height)); cardArea.setPreferredSize(new Dimension(cardDimension.width * showCards.size(), cardDimension.height + verticalCardOffset));
} }
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) { private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
@ -221,7 +232,7 @@ public class CardArea extends JPanel implements MouseListener {
if (e.isAltDown()) { if (e.isAltDown()) {
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK); cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
} else { } else {
cardEventSource.fireEvent(((MageCard) obj).getOriginal(),ClientEventType.DOUBLE_CLICK); cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
} }
} }
} }

View file

@ -14,7 +14,7 @@ import mage.client.util.ClientEventType;
import mage.client.util.Event; import mage.client.util.Event;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.client.util.Listener; import mage.client.util.Listener;
import mage.utils.CardUtil; import mage.utils.CardColorUtil;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CardsView; import mage.view.CardsView;
import org.mage.card.arcane.CardPanel; import org.mage.card.arcane.CardPanel;
@ -172,8 +172,8 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
} }
break; break;
case COLOR_IDENTITY: case COLOR_IDENTITY:
if (CardUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules()) if (CardColorUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules())
!= CardUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) { != CardColorUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) {
curColumn++; curColumn++;
curRow = 0; curRow = 0;
} }
@ -404,8 +404,8 @@ class CardColorDetailedIdentity implements Comparator<MageCard> {
@Override @Override
public int compare(MageCard o1, MageCard o2) { public int compare(MageCard o1, MageCard o2) {
int val = CardUtil.getColorIdentitySortValue(o1.getOriginal().getManaCost(), o1.getOriginal().getColor(), o1.getOriginal().getRules()) int val = CardColorUtil.getColorIdentitySortValue(o1.getOriginal().getManaCost(), o1.getOriginal().getColor(), o1.getOriginal().getRules())
- CardUtil.getColorIdentitySortValue(o2.getOriginal().getManaCost(), o2.getOriginal().getColor(), o2.getOriginal().getRules()); - CardColorUtil.getColorIdentitySortValue(o2.getOriginal().getManaCost(), o2.getOriginal().getColor(), o2.getOriginal().getRules());
if (val == 0) { if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName()); return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
} else { } else {

View file

@ -1,349 +1,339 @@
/* /*
* Cards.java * Cards.java
* *
* Created on Dec 18, 2009, 10:40:12 AM * Created on Dec 18, 2009, 10:40:12 AM
*/ */
package mage.client.cards; package mage.client.cards;
import java.awt.Color; import mage.cards.MageCard;
import java.awt.Component; import mage.client.plugins.impl.Plugins;
import java.awt.Dimension; import mage.client.util.CardsViewUtil;
import java.util.ArrayList; import mage.client.util.Config;
import java.util.Iterator; import mage.client.util.GUISizeHelper;
import java.util.LinkedHashMap; import mage.view.*;
import java.util.Map; import org.apache.log4j.Logger;
import java.util.Map.Entry; import org.mage.card.arcane.CardPanel;
import java.util.UUID;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.client.util.GUISizeHelper;
import mage.view.CardView;
import mage.view.CardsView;
import mage.view.PermanentView;
import mage.view.SimpleCardsView;
import mage.view.StackAbilityView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardPanel;
/** import javax.swing.border.Border;
* import javax.swing.border.EmptyBorder;
* @author BetaSteward_at_googlemail.com import java.awt.*;
*/ import java.util.*;
public class Cards extends javax.swing.JPanel { import java.util.Map.Entry;
private static final Logger LOGGER = Logger.getLogger(Cards.class); /**
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0); * @author BetaSteward_at_googlemail.com
*/
public class Cards extends javax.swing.JPanel {
private final Map<UUID, MageCard> cards = new LinkedHashMap<>(); private static final Logger LOGGER = Logger.getLogger(Cards.class);
private boolean dontDisplayTapped = false; private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
private String zone;
private int minOffsetY = 0; private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
private boolean dontDisplayTapped = false;
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
private String zone;
/** private int minOffsetY = 0;
* Defines whether component should be visible whenever there is no objects
* within. True by default.
*/
private boolean isVisibleIfEmpty = true;
private Dimension cardDimension; /**
* Defines whether component should be visible whenever there is no objects
* within. True by default.
*/
private boolean isVisibleIfEmpty = true;
/** private Dimension cardDimension;
* Creates new form Cards
*/
public Cards() {
this(false);
}
public Cards(boolean skipAddingScrollPane) { /**
initComponents(skipAddingScrollPane); * Creates new form Cards
setOpaque(false); */
//cardArea.setOpaque(false); public Cards() {
setBackgroundColor(new Color(0, 0, 0, 100)); this(false);
if (!skipAddingScrollPane) { }
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
jScrollPane1.setBorder(EMPTY_BORDER);
}
if (Plugins.instance.isCardPluginLoaded()) {
cardArea.setLayout(null);
}
cardArea.setBorder(EMPTY_BORDER);
setGUISize();
}
public void cleanUp() { public Cards(boolean skipAddingScrollPane) {
} initComponents(skipAddingScrollPane);
setOpaque(false);
//cardArea.setOpaque(false);
setBackgroundColor(new Color(0, 0, 0, 100));
if (!skipAddingScrollPane) {
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
jScrollPane1.setBorder(EMPTY_BORDER);
}
if (Plugins.instance.isCardPluginLoaded()) {
cardArea.setLayout(null);
}
cardArea.setBorder(EMPTY_BORDER);
setGUISize();
}
public void changeGUISize() { public void cleanUp() {
setGUISize(); }
for (MageCard mageCard : cards.values()) {
mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
mageCard.updateArtImage();
mageCard.doLayout();
}
layoutCards();
sizeCards(cardDimension);
}
private void setGUISize() { public void changeGUISize() {
if (jScrollPane1 != null) { setGUISize();
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0)); for (MageCard mageCard : cards.values()) {
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize)); mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
} mageCard.updateArtImage();
} mageCard.doLayout();
}
layoutCards();
sizeCards(getCardDimension());
}
/** private void setGUISize() {
* Sets components background color if (jScrollPane1 != null) {
* jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
* @param color jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
*/ }
public void setBackgroundColor(Color color) { }
setBackground(color);
cardArea.setOpaque(true);
cardArea.setBackground(color);
}
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) { /**
this.isVisibleIfEmpty = isVisibleIfEmpty; * Sets components background color
} *
* @param color
*/
public void setBackgroundColor(Color color) {
setBackground(color);
cardArea.setOpaque(true);
cardArea.setBackground(color);
}
@Override public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
public void setBorder(Border border) { this.isVisibleIfEmpty = isVisibleIfEmpty;
super.setBorder(border); }
if (jScrollPane1 != null) {
jScrollPane1.setViewportBorder(border);
jScrollPane1.setBorder(border);
}
}
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) { @Override
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, true); public void setBorder(Border border) {
} super.setBorder(border);
if (jScrollPane1 != null) {
jScrollPane1.setViewportBorder(border);
jScrollPane1.setBorder(border);
}
}
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, boolean revertOrder) { public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
boolean changed = false; return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, true);
}
// remove objects no longer on the stack from display public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, boolean revertOrder) {
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) { boolean changed = false;
Entry<UUID, MageCard> entry = i.next();
if (!cardsView.containsKey(entry.getKey())) {
removeCard(entry.getKey());
i.remove();
changed = true;
}
}
// Workaround for bug leaving display of objects on the stack (issue #213 https://github.com/magefree/mage/issues/213) // remove objects no longer on the stack from display
if (cardsView.isEmpty() && countCards() > 0) { for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext(); ) {
// problem happens with transformable cards Entry<UUID, MageCard> entry = i.next();
LOGGER.fatal("Card object on the cards panel was not removed"); if (!cardsView.containsKey(entry.getKey())) {
for (Component comp : cardArea.getComponents()) { removeCard(entry.getKey());
if (comp instanceof Card) { i.remove();
Card card = (Card) comp; changed = true;
LOGGER.fatal("Card name:" + card.getName() + " type:" + card.getType(null)); }
} else if (comp instanceof MageCard) { }
MageCard mageCard = (MageCard) comp;
LOGGER.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
} else {
LOGGER.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
}
cardArea.remove(comp);
}
}
java.util.List<CardView> orderedList = new ArrayList<>(); // Workaround for bug leaving display of objects on the stack (issue #213 https://github.com/magefree/mage/issues/213)
if (revertOrder) { if (cardsView.isEmpty() && countCards() > 0) {
// order objects for display // problem happens with transformable cards
for (CardView card : cardsView.values()) { LOGGER.fatal("Card object on the cards panel was not removed");
orderedList.add(0, card); for (Component comp : cardArea.getComponents()) {
} if (comp instanceof Card) {
} else { Card card = (Card) comp;
orderedList.addAll(cardsView.values()); LOGGER.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
} } else if (comp instanceof MageCard) {
MageCard mageCard = (MageCard) comp;
LOGGER.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
} else {
LOGGER.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
}
cardArea.remove(comp);
}
}
// add objects to the panel java.util.List<CardView> orderedList = new ArrayList<>();
for (CardView card : orderedList) { if (revertOrder) {
if (dontDisplayTapped) { // order objects for display
if (card instanceof PermanentView) { for (CardView card : cardsView.values()) {
((PermanentView) card).overrideTapped(false); orderedList.add(0, card);
} }
} } else {
if (card instanceof StackAbilityView) { orderedList.addAll(cardsView.values());
CardView tmp = ((StackAbilityView) card).getSourceCard(); }
tmp.overrideRules(card.getRules());
tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets());
tmp.overrideId(card.getId());
tmp.setAbilityType(card.getAbilityType());
card = tmp;
} else {
card.setAbilityType(null);
}
if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId);
changed = true;
}
cards.get(card.getId()).update(card);
}
if (changed) { // add objects to the panel
layoutCards(); for (CardView card : orderedList) {
} if (dontDisplayTapped) {
if (card instanceof PermanentView) {
((PermanentView) card).overrideTapped(false);
}
}
if (card instanceof StackAbilityView) {
CardView tmp = ((StackAbilityView) card).getSourceCard();
tmp.overrideRules(card.getRules());
tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets());
tmp.overrideId(card.getId());
tmp.setAbilityType(card.getAbilityType());
card = tmp;
} else {
card.setAbilityType(null);
}
if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId);
changed = true;
}
cards.get(card.getId()).update(card);
}
if (!isVisibleIfEmpty) { if (changed) {
cardArea.setVisible(!cards.isEmpty()); layoutCards();
} }
sizeCards(getCardDimension()); if (!isVisibleIfEmpty) {
this.revalidate(); cardArea.setVisible(!cards.isEmpty());
this.repaint(); }
return changed; sizeCards(getCardDimension());
} this.revalidate();
this.repaint();
public void sizeCards(Dimension cardDimension) { return changed;
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20)); }
cardArea.revalidate();
cardArea.repaint();
}
public int getNumberOfCards() { public void sizeCards(Dimension cardDimension) {
return cards.size(); cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
} cardArea.revalidate();
cardArea.repaint();
}
private Dimension getCardDimension() { public int getNumberOfCards() {
if (cardDimension == null) { return cards.size();
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); }
}
return cardDimension;
}
public void setCardDimension(Dimension dimension) { private Dimension getCardDimension() {
this.cardDimension = dimension; if (cardDimension == null) {
for (Component component : cardArea.getComponents()) { cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
if (component instanceof CardPanel) { }
component.setBounds(0, 0, dimension.width, dimension.height); return cardDimension;
} }
}
layoutCards();
}
private void addCard(CardView card, BigCard bigCard, UUID gameId) { public void setCardDimension(Dimension dimension) {
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true); this.cardDimension = dimension;
if (zone != null) { for (Component component : cardArea.getComponents()) {
mageCard.setZone(zone); if (component instanceof CardPanel) {
} component.setBounds(0, 0, dimension.width, dimension.height);
cards.put(card.getId(), mageCard); }
cardArea.add(mageCard); }
definePosition(mageCard); layoutCards();
mageCard.setCardAreaRef(cardArea); }
}
private void definePosition(MageCard card) { private void addCard(CardView card, BigCard bigCard, UUID gameId) {
int dx = 0; MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
for (Component comp : cardArea.getComponents()) { if (zone != null) {
if (!comp.equals(card)) { mageCard.setZone(zone);
dx = Math.max(dx, (int) comp.getLocation().getX()); }
} cards.put(card.getId(), mageCard);
} cardArea.add(mageCard);
dx += ((CardPanel) card).getCardWidth() + GAP_X; definePosition(mageCard);
card.setLocation(dx, (int) card.getLocation().getY()); mageCard.setCardAreaRef(cardArea);
} }
private void removeCard(UUID cardId) { private void definePosition(MageCard card) {
for (Component comp : cardArea.getComponents()) { int dx = 0;
if (comp instanceof Card) { for (Component comp : cardArea.getComponents()) {
if (((Card) comp).getCardId().equals(cardId)) { if (!comp.equals(card)) {
cardArea.remove(comp); dx = Math.max(dx, (int) comp.getLocation().getX());
} }
} else if (comp instanceof MageCard) { }
if (((MageCard) comp).getOriginal().getId().equals(cardId)) { dx += ((CardPanel) card).getCardWidth() + GAP_X;
cardArea.remove(comp); card.setLocation(dx, (int) card.getLocation().getY());
} }
}
}
}
private int countCards() { private void removeCard(UUID cardId) {
return cardArea.getComponentCount(); for (Component comp : cardArea.getComponents()) {
} if (comp instanceof Card) {
if (((Card) comp).getCardId().equals(cardId)) {
cardArea.remove(comp);
}
} else if (comp instanceof MageCard) {
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
cardArea.remove(comp);
}
}
}
}
/** private int countCards() {
* This method is called from within the constructor to initialize the form. return cardArea.getComponentCount();
* 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
private void initComponents(boolean skipAddingScrollPane) {
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
setLayout(new java.awt.BorderLayout());
cardArea = new javax.swing.JPanel(); /**
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0)); * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents(boolean skipAddingScrollPane) {
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
setLayout(new java.awt.BorderLayout());
if (skipAddingScrollPane) { cardArea = new javax.swing.JPanel();
add(cardArea, java.awt.BorderLayout.CENTER); cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
} else{
jScrollPane1 = new javax.swing.JScrollPane();
jScrollPane1.setViewportView(cardArea);
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
add(jScrollPane1, java.awt.BorderLayout.CENTER);
}
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables if (skipAddingScrollPane) {
private javax.swing.JPanel cardArea; add(cardArea, java.awt.BorderLayout.CENTER);
private javax.swing.JScrollPane jScrollPane1; } else {
// End of variables declaration//GEN-END:variables jScrollPane1 = new javax.swing.JScrollPane();
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
jScrollPane1.setViewportView(cardArea);
add(jScrollPane1, java.awt.BorderLayout.CENTER);
}
}// </editor-fold>//GEN-END:initComponents
public void setDontDisplayTapped(boolean dontDisplayTapped) { // Variables declaration - do not modify//GEN-BEGIN:variables
this.dontDisplayTapped = dontDisplayTapped; private javax.swing.JPanel cardArea;
} private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
public void setHScrollSpeed(int unitIncrement) { public void setDontDisplayTapped(boolean dontDisplayTapped) {
if (jScrollPane1 != null) { this.dontDisplayTapped = dontDisplayTapped;
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement); }
}
}
public void setVScrollSpeed(int unitIncrement) { public void setHScrollSpeed(int unitIncrement) {
if (jScrollPane1 != null) { if (jScrollPane1 != null) {
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement); jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
} }
} }
private void layoutCards() { public void setVScrollSpeed(int unitIncrement) {
java.util.List<CardPanel> cardsToLayout = new ArrayList<>(); if (jScrollPane1 != null) {
// get all the card panels jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
for (Component component : cardArea.getComponents()) { }
if (component instanceof CardPanel) { }
cardsToLayout.add((CardPanel) component);
}
}
// sort the cards
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
// relocate the cards
int dx = 0;
for (Component component : cardsToLayout) {
component.setLocation(dx, Math.max(component.getLocation().y, minOffsetY));
dx += ((CardPanel) component).getCardWidth() + GAP_X;
}
}
public void setZone(String zone) { private void layoutCards() {
this.zone = zone; java.util.List<CardPanel> cardsToLayout = new ArrayList<>();
} // get all the card panels
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
cardsToLayout.add((CardPanel) component);
}
}
// sort the cards
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
// relocate the cards
int dx = 0;
for (Component component : cardsToLayout) {
component.setLocation(dx, Math.max(component.getLocation().y, minOffsetY));
dx += ((CardPanel) component).getCardWidth() + GAP_X;
}
}
public void setMinOffsetY(int minOffsetY) { public void setZone(String zone) {
this.minOffsetY = minOffsetY; this.zone = zone;
} }
}
public void setMinOffsetY(int minOffsetY) {
this.minOffsetY = minOffsetY;
}
}

View file

@ -77,6 +77,12 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
for (MouseListener ml : cardArea.getMouseListeners()) { for (MouseListener ml : cardArea.getMouseListeners()) {
cardArea.removeMouseListener(ml); cardArea.removeMouseListener(ml);
} }
for (Component comp : cardArea.getComponents()) {
if (comp instanceof CardPanel) {
((CardPanel) comp).cleanUp();
}
}
cardArea.removeAll();
} }
if (mainTable != null) { if (mainTable != null) {
for (MouseListener ml : mainTable.getMouseListeners()) { for (MouseListener ml : mainTable.getMouseListeners()) {
@ -86,13 +92,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
if (currentView != null) { if (currentView != null) {
currentView.clearCardEventListeners(); currentView.clearCardEventListeners();
} }
for (Component comp : cardArea.getComponents()) {
if (comp instanceof CardPanel) {
((CardPanel) comp).cleanUp();
}
}
mageCards.clear(); mageCards.clear();
cardArea.removeAll();
this.bigCard = null; this.bigCard = null;
} }
@ -270,12 +271,14 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
mageCards = new LinkedHashMap<>(); mageCards = new LinkedHashMap<>();
//Find card view //Find card view
for (UUID uuid : cards.keySet()) { for (Map.Entry<UUID, CardView> view : cards.entrySet()) {
UUID uuid = view.getKey();
CardView cardView = view.getValue();
if (oldMageCards.containsKey(uuid)) { if (oldMageCards.containsKey(uuid)) {
mageCards.put(uuid, oldMageCards.get(uuid)); mageCards.put(uuid, oldMageCards.get(uuid));
oldMageCards.remove(uuid); oldMageCards.remove(uuid);
} else { } else {
mageCards.put(uuid, addCard(cards.get(uuid), bigCard, gameId)); mageCards.put(uuid, addCard(cardView, bigCard, gameId));
} }
} }
//Remove unused cards //Remove unused cards

View file

@ -84,7 +84,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
for (int i = 1; i < maxRows; i++) { for (int i = 1; i < maxRows; i++) {
scale = (double) (this.getHeight()/i) / Constants.FRAME_MAX_HEIGHT; scale = (double) (this.getHeight()/i) / Constants.FRAME_MAX_HEIGHT;
cardDimension = new CardDimensions(scale); cardDimension = new CardDimensions(scale);
maxCards = this.getWidth() / (cardDimension.frameWidth + offsetX); maxCards = this.getWidth() / (cardDimension.getFrameWidth() + offsetX);
if ((maxCards * i) >= booster.size()) { if ((maxCards * i) >= booster.size()) {
numColumns = booster.size() / i; numColumns = booster.size() / i;
if (booster.size() % i > 0) { if (booster.size() % i > 0) {
@ -95,8 +95,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
} }
if (cardDimension != null) { if (cardDimension != null) {
Rectangle rectangle = new Rectangle(cardDimension.frameWidth, cardDimension.frameHeight); Rectangle rectangle = new Rectangle(cardDimension.getFrameWidth(), cardDimension.getFrameHeight());
Dimension dimension = new Dimension(cardDimension.frameWidth, cardDimension.frameHeight); Dimension dimension = new Dimension(cardDimension.getFrameWidth(), cardDimension.getFrameHeight());
List<CardView> sortedCards = new ArrayList<>(booster.values()); List<CardView> sortedCards = new ArrayList<>(booster.values());
sortedCards.sort(new CardViewRarityComparator()); sortedCards.sort(new CardViewRarityComparator());
@ -105,7 +105,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
cardImg.addMouseListener(this); cardImg.addMouseListener(this);
add(cardImg); add(cardImg);
cardImg.update(card); cardImg.update(card);
rectangle.setLocation(curColumn * (cardDimension.frameWidth + offsetX) + offsetX, curRow * (rectangle.height + offsetY) + offsetY); rectangle.setLocation(curColumn * (cardDimension.getFrameWidth() + offsetX) + offsetX, curRow * (rectangle.height + offsetY) + offsetY);
cardImg.setBounds(rectangle); cardImg.setBounds(rectangle);
cardImg.setCardBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height); cardImg.setCardBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height);

View file

@ -1,5 +1,16 @@
package mage.client.cards; package mage.client.cards;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.swing.*;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardInfo;
@ -20,34 +31,17 @@ import mage.view.CardsView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRenderer; import org.mage.card.arcane.CardRenderer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* Created by StravantUser on 2016-09-20. * Created by StravantUser on 2016-09-20.
*/ */
public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarget { public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarget {
private final static Logger LOGGER = Logger.getLogger(DragCardGrid.class); private static final Logger LOGGER = Logger.getLogger(DragCardGrid.class);
private Constants.DeckEditorMode mode; private Constants.DeckEditorMode mode;
@Override @Override
public Collection<CardView> dragCardList() { public Collection<CardView> dragCardList() {
ArrayList<CardView> selectedCards = new ArrayList<>(); return allCards.stream().filter(CardView::isSelected).collect(Collectors.toCollection(ArrayList::new));
for (CardView card : allCards) {
if (card.isSelected()) {
selectedCards.add(card);
}
}
return selectedCards;
} }
@Override @Override
@ -63,8 +57,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Don't remove the cards, no target // Don't remove the cards, no target
} else { } else {
// Remove dragged cards // Remove dragged cards
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (int i = 0; i < stack.size(); ++i) { for (int i = 0; i < stack.size(); ++i) {
CardView card = stack.get(i); CardView card = stack.get(i);
if (card.isSelected()) { if (card.isSelected()) {
@ -161,7 +155,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} }
// Get the appropirate stack // Get the appropirate stack
ArrayList<CardView> stack; List<CardView> stack;
if (rowIndex < cardGrid.size() && col < cardGrid.get(0).size()) { if (rowIndex < cardGrid.size() && col < cardGrid.get(0).size()) {
stack = cardGrid.get(rowIndex).get(col); stack = cardGrid.get(rowIndex).get(col);
} else { } else {
@ -201,8 +195,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// If we're dragging onto ourself, erase the old cards (just null them out, we will // If we're dragging onto ourself, erase the old cards (just null them out, we will
// compact the grid removing the null gaps / empty rows & cols later) // compact the grid removing the null gaps / empty rows & cols later)
if (source == this) { if (source == this) {
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (int i = 0; i < stack.size(); ++i) { for (int i = 0; i < stack.size(); ++i) {
if (cards.contains(stack.get(i))) { if (cards.contains(stack.get(i))) {
stack.set(i, null); stack.set(i, null);
@ -242,7 +236,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Add a new row if needed // Add a new row if needed
if (rowIndex >= cardGrid.size()) { if (rowIndex >= cardGrid.size()) {
ArrayList<ArrayList<CardView>> newRow = new ArrayList<>(); List<List<CardView>> newRow = new ArrayList<>();
if (!cardGrid.isEmpty()) { if (!cardGrid.isEmpty()) {
for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) { for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) {
newRow.add(new ArrayList<>()); newRow.add(new ArrayList<>());
@ -287,7 +281,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Add a new row if needed // Add a new row if needed
if (rowIndex >= cardGrid.size()) { if (rowIndex >= cardGrid.size()) {
ArrayList<ArrayList<CardView>> newRow = new ArrayList<>(); List<List<CardView>> newRow = new ArrayList<>();
if (!cardGrid.isEmpty()) { if (!cardGrid.isEmpty()) {
for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) { for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) {
newRow.add(new ArrayList<>()); newRow.add(new ArrayList<>());
@ -305,7 +299,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} }
// Get the appropirate stack // Get the appropirate stack
ArrayList<CardView> stack = cardGrid.get(rowIndex).get(col); List<CardView> stack = cardGrid.get(rowIndex).get(col);
// Figure out position in the stack based on the offsetIntoRow // Figure out position in the stack based on the offsetIntoRow
int stackInsertIndex = (offsetIntoStack + cardTopHeight / 2) / cardTopHeight; int stackInsertIndex = (offsetIntoStack + cardTopHeight / 2) / cardTopHeight;
@ -376,8 +370,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} }
public void removeSelection() { public void removeSelection() {
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (int i = 0; i < stack.size(); ++i) { for (int i = 0; i < stack.size(); ++i) {
CardView card = stack.get(i); CardView card = stack.get(i);
if (card.isSelected()) { if (card.isSelected()) {
@ -395,11 +389,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
public DeckCardLayout getCardLayout() { public DeckCardLayout getCardLayout() {
// 2D Array to put entries into // 2D Array to put entries into
java.util.List<java.util.List<java.util.List<DeckCardInfo>>> info = new ArrayList<>(); List<List<List<DeckCardInfo>>> info = new ArrayList<>();
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
java.util.List<java.util.List<DeckCardInfo>> row = new ArrayList<>(); List<List<DeckCardInfo>> row = new ArrayList<>();
info.add(row); info.add(row);
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
row.add(stack.stream() row.add(stack.stream()
.map(card -> new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode())) .map(card -> new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode()))
.collect(Collectors.toList())); .collect(Collectors.toList()));
@ -545,12 +539,12 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
public static final int COUNT_LABEL_HEIGHT = 20; public static final int COUNT_LABEL_HEIGHT = 20;
public static final int GRID_PADDING = 10; public static final int GRID_PADDING = 10;
private final static ImageIcon INSERT_ROW_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_row.png")); private static final ImageIcon INSERT_ROW_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_row.png"));
private final static ImageIcon INSERT_COL_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_col.png")); private static final ImageIcon INSERT_COL_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_col.png"));
// All of the current card views // All of the current card views
private final Map<UUID, MageCard> cardViews = new LinkedHashMap<>(); private final Map<UUID, MageCard> cardViews = new LinkedHashMap<>();
private final ArrayList<CardView> allCards = new ArrayList<>(); private final List<CardView> allCards = new ArrayList<>();
// Card listeners // Card listeners
private final CardEventSource eventSource = new CardEventSource(); private final CardEventSource eventSource = new CardEventSource();
@ -579,8 +573,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
final JSlider cardSizeSlider; final JSlider cardSizeSlider;
final JLabel cardSizeSliderLabel; final JLabel cardSizeSliderLabel;
final Map<Sort, AbstractButton> sortButtons = new HashMap<>(); final Map<Sort, AbstractButton> sortButtons = new EnumMap<>(Sort.class);
final HashMap<CardType, AbstractButton> selectByTypeButtons = new HashMap<>(); final Map<CardType, AbstractButton> selectByTypeButtons = new EnumMap<>(CardType.class);
final JLabel deckNameAndCountLabel; final JLabel deckNameAndCountLabel;
final JLabel landCountLabel; final JLabel landCountLabel;
@ -612,11 +606,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// The outermost array contains multiple rows of stacks of cards // The outermost array contains multiple rows of stacks of cards
// The next inner array represents a row of stacks of cards // The next inner array represents a row of stacks of cards
// The innermost array represents a single vertical stack of cards // The innermost array represents a single vertical stack of cards
private ArrayList<ArrayList<ArrayList<CardView>>> cardGrid; private List<List<List<CardView>>> cardGrid;
private ArrayList<Integer> maxStackSize = new ArrayList<>(); private List<Integer> maxStackSize = new ArrayList<>();
private final ArrayList<ArrayList<JLabel>> stackCountLabels = new ArrayList<>(); private final List<List<JLabel>> stackCountLabels = new ArrayList<>();
private Sort cardSort = Sort.CMC; private Sort cardSort = Sort.CMC;
private final ArrayList<CardType> selectByTypeSelected = new ArrayList<>(); private final List<CardType> selectByTypeSelected = new ArrayList<>();
private boolean separateCreatures = true; private boolean separateCreatures = true;
public enum Role { public enum Role {
@ -640,7 +634,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
public boolean separateCreatures; public boolean separateCreatures;
public int cardSize; public int cardSize;
private final static Pattern parser = Pattern.compile("\\(([^,]*),([^,]*),([^)]*)\\)"); private static final Pattern parser = Pattern.compile("\\(([^,]*),([^,]*),([^)]*)\\)");
public static Settings parse(String str) { public static Settings parse(String str) {
Matcher m = parser.matcher(str); Matcher m = parser.matcher(str);
@ -811,7 +805,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
insertArrow = new JLabel(); insertArrow = new JLabel();
insertArrow.setSize(20, 20); insertArrow.setSize(20, 20);
insertArrow.setVisible(false); insertArrow.setVisible(false);
cardContent.add(insertArrow, new Integer(1000)); cardContent.add(insertArrow, 1000);
// Selection panel // Selection panel
selectionPanel = new SelectionBox(); selectionPanel = new SelectionBox();
@ -918,7 +912,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
ButtonGroup selectByTypeModeGroup = new ButtonGroup(); ButtonGroup selectByTypeModeGroup = new ButtonGroup();
for (final CardType cardType : CardType.values()) { for (final CardType cardType : CardType.values()) {
if (cardType == cardType.CONSPIRACY) { if (cardType == CardType.CONSPIRACY) {
multiplesButton = new JToggleButton("Multiples"); multiplesButton = new JToggleButton("Multiples");
selectByTypeButtons.put(cardType, multiplesButton); selectByTypeButtons.put(cardType, multiplesButton);
selectByTypeMode.add(multiplesButton); selectByTypeMode.add(multiplesButton);
@ -1046,8 +1040,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
* Deselect all cards in this DragCardGrid * Deselect all cards in this DragCardGrid
*/ */
public void deselectAll() { public void deselectAll() {
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (CardView card : stack) { for (CardView card : stack) {
if (card.isSelected()) { if (card.isSelected()) {
card.setSelected(false); card.setSelected(false);
@ -1167,9 +1161,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} else { } else {
stackEndIndex = (y2 - curY) / cardTopHeight; stackEndIndex = (y2 - curY) / cardTopHeight;
} }
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(rowIndex); List<List<CardView>> gridRow = cardGrid.get(rowIndex);
for (int col = 0; col < gridRow.size(); ++col) { for (int col = 0; col < gridRow.size(); ++col) {
ArrayList<CardView> stack = gridRow.get(col); List<CardView> stack = gridRow.get(col);
int stackBottomBegin = curY + cardTopHeight * (stack.size()); int stackBottomBegin = curY + cardTopHeight * (stack.size());
int stackBottomEnd = curY + cardTopHeight * (stack.size() - 1) + cardHeight; int stackBottomEnd = curY + cardTopHeight * (stack.size() - 1) + cardHeight;
for (int i = 0; i < stack.size(); ++i) { for (int i = 0; i < stack.size(); ++i) {
@ -1202,8 +1196,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Resort the existing cards based on the current sort // Resort the existing cards based on the current sort
public void resort() { public void resort() {
// First null out the grid and trim it down // First null out the grid and trim it down
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
stack.clear(); stack.clear();
} }
} }
@ -1244,8 +1238,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
if (cardType == CardType.CONSPIRACY) { if (cardType == CardType.CONSPIRACY) {
HashMap<String, CardView> cardNames = new HashMap<>(); HashMap<String, CardView> cardNames = new HashMap<>();
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (CardView card : stack) { for (CardView card : stack) {
if (cardNames.get(card.getName()) == null) { if (cardNames.get(card.getName()) == null) {
cardNames.put(card.getName(), card); cardNames.put(card.getName(), card);
@ -1263,10 +1257,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
continue; continue;
} }
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (CardView card : stack) { for (CardView card : stack) {
boolean s = card.isSelected() | card.getCardTypes().contains(cardType); boolean s = card.isSelected() || card.getCardTypes().contains(cardType);
card.setSelected(s); card.setSelected(s);
cardViews.get(card.getId()).update(card); cardViews.get(card.getId()).update(card);
} }
@ -1277,13 +1271,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} }
if (useText) { if (useText) {
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (CardView card : stack) { for (CardView card : stack) {
boolean s = card.isSelected(); boolean s = card.isSelected();
// Name // Name
if (!s) { if (!s) {
s |= card.getName().toLowerCase(Locale.ENGLISH).contains(searchStr); s = card.getName().toLowerCase(Locale.ENGLISH).contains(searchStr);
} }
// Sub & Super Types // Sub & Super Types
if (!s) { if (!s) {
@ -1355,21 +1349,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
qtys.put("wastes", 0); qtys.put("wastes", 0);
manaCounts = new HashMap<>(); manaCounts = new HashMap<>();
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (CardView card : stack) { for (CardView card : stack) {
// Type line // Type line
String t = ""; String t = card.getCardTypes().stream().map(CardType::toString).collect(Collectors.joining(" "));
for (CardType type : card.getCardTypes()) { t += card.getSuperTypes().stream().map(st -> st.toString().toLowerCase(Locale.ENGLISH)).collect(Collectors.joining(" "));
t += ' ' + type.toString(); t += card.getSubTypes().stream().map(st -> st.toString().toLowerCase(Locale.ENGLISH)).collect(Collectors.joining(" "));
}
// Sub & Super Types
for (SuperType type : card.getSuperTypes()) {
t += ' ' + type.toString().toLowerCase(Locale.ENGLISH);
}
for (SubType str : card.getSubTypes()) {
t += " " + str.toString().toLowerCase(Locale.ENGLISH);
}
for (String qty : qtys.keySet()) { for (String qty : qtys.keySet()) {
int value = qtys.get(qty); int value = qtys.get(qty);
@ -1408,13 +1394,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
while (regexMatcher.find()) { while (regexMatcher.find()) {
String val = regexMatcher.group(1); String val = regexMatcher.group(1);
int colorless_val = Integer.parseInt(val); int colorless_val = Integer.parseInt(val);
int total_c_pip = 0; int total_c_pip = 0;
if (pips.get("#c}") != null) { if (pips.get("#c}") != null) {
total_c_pip = pips.get("#c}"); total_c_pip = pips.get("#c}");
} }
pips.put("#c}", colorless_val + total_c_pip); pips.put("#c}", colorless_val + total_c_pip);
int cmc_pip_value = 0; int cmc_pip_value = 0;
if (pips_at_cmcs.get(cmc + "##c}") != null) { if (pips_at_cmcs.get(cmc + "##c}") != null) {
cmc_pip_value = pips_at_cmcs.get(cmc + "##c}"); cmc_pip_value = pips_at_cmcs.get(cmc + "##c}");
@ -1495,7 +1481,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} }
public void blingDeck() { public void blingDeck() {
if (!(this.mode == Constants.DeckEditorMode.FREE_BUILDING)) { if (this.mode != Constants.DeckEditorMode.FREE_BUILDING) {
return; return;
} }
@ -1504,8 +1490,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
return; return;
} }
HashMap<String, Integer> pimpedSets = new HashMap<>(); Map<String, Integer> pimpedSets = new HashMap<>();
HashMap<CardView, Integer> pimpedCards = new HashMap<>(); Map<CardView, Integer> pimpedCards = new HashMap<>();
pimpedSets.put("CP", 1); pimpedSets.put("CP", 1);
pimpedSets.put("JR", 1); pimpedSets.put("JR", 1);
pimpedSets.put("MPS", 1); pimpedSets.put("MPS", 1);
@ -1530,8 +1516,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
String[] sets = pimpedSets.keySet().toArray(new String[pimpedSets.keySet().size()]); String[] sets = pimpedSets.keySet().toArray(new String[pimpedSets.keySet().size()]);
Boolean didModify = false; Boolean didModify = false;
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
for (CardView card : stack) { for (CardView card : stack) {
if (card.getSuperTypes().contains(SuperType.BASIC)) { if (card.getSuperTypes().contains(SuperType.BASIC)) {
continue; continue;
@ -1581,9 +1567,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Remove all of the cards not in the cardsView // Remove all of the cards not in the cardsView
boolean didModify = false; // Until contested boolean didModify = false; // Until contested
for (int i = 0; i < cardGrid.size(); ++i) { for (int i = 0; i < cardGrid.size(); ++i) {
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(i); List<List<CardView>> gridRow = cardGrid.get(i);
for (int j = 0; j < gridRow.size(); ++j) { for (int j = 0; j < gridRow.size(); ++j) {
ArrayList<CardView> stack = gridRow.get(j); List<CardView> stack = gridRow.get(j);
for (int k = 0; k < stack.size(); ++k) { for (int k = 0; k < stack.size(); ++k) {
CardView card = stack.get(k); CardView card = stack.get(k);
if (!cardsView.containsKey(card.getId())) { if (!cardsView.containsKey(card.getId())) {
@ -1627,21 +1613,21 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
loadSettings(Settings.parse(layout.getSettings())); loadSettings(Settings.parse(layout.getSettings()));
// Traverse the cards once and track them so we can pick ones to insert into the grid // Traverse the cards once and track them so we can pick ones to insert into the grid
Map<String, Map<String, ArrayList<CardView>>> trackedCards = new HashMap<>(); Map<String, Map<String, List<CardView>>> trackedCards = new HashMap<>();
for (CardView newCard : cardsView.values()) { for (CardView newCard : cardsView.values()) {
if (!cardViews.containsKey(newCard.getId())) { if (!cardViews.containsKey(newCard.getId())) {
// Add the new card // Add the new card
addCardView(newCard, false); addCardView(newCard, false);
// Add the new card to tracking // Add the new card to tracking
Map<String, ArrayList<CardView>> forSetCode; Map<String, List<CardView>> forSetCode;
if (trackedCards.containsKey(newCard.getExpansionSetCode())) { if (trackedCards.containsKey(newCard.getExpansionSetCode())) {
forSetCode = trackedCards.get(newCard.getExpansionSetCode()); forSetCode = trackedCards.get(newCard.getExpansionSetCode());
} else { } else {
forSetCode = new HashMap<>(); forSetCode = new HashMap<>();
trackedCards.put(newCard.getExpansionSetCode(), forSetCode); trackedCards.put(newCard.getExpansionSetCode(), forSetCode);
} }
ArrayList<CardView> list; List<CardView> list;
if (forSetCode.containsKey(newCard.getCardNumber())) { if (forSetCode.containsKey(newCard.getCardNumber())) {
list = forSetCode.get(newCard.getCardNumber()); list = forSetCode.get(newCard.getCardNumber());
} else { } else {
@ -1655,16 +1641,16 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Now go through the layout and use it to build the cardGrid // Now go through the layout and use it to build the cardGrid
cardGrid = new ArrayList<>(); cardGrid = new ArrayList<>();
maxStackSize = new ArrayList<>(); maxStackSize = new ArrayList<>();
for (java.util.List<java.util.List<DeckCardInfo>> row : layout.getCards()) { for (List<List<DeckCardInfo>> row : layout.getCards()) {
ArrayList<ArrayList<CardView>> gridRow = new ArrayList<>(); List<List<CardView>> gridRow = new ArrayList<>();
int thisMaxStackSize = 0; int thisMaxStackSize = 0;
cardGrid.add(gridRow); cardGrid.add(gridRow);
for (java.util.List<DeckCardInfo> stack : row) { for (List<DeckCardInfo> stack : row) {
ArrayList<CardView> gridStack = new ArrayList<>(); ArrayList<CardView> gridStack = new ArrayList<>();
gridRow.add(gridStack); gridRow.add(gridStack);
for (DeckCardInfo info : stack) { for (DeckCardInfo info : stack) {
if (trackedCards.containsKey(info.getSetCode()) && trackedCards.get(info.getSetCode()).containsKey(info.getCardNum())) { if (trackedCards.containsKey(info.getSetCode()) && trackedCards.get(info.getSetCode()).containsKey(info.getCardNum())) {
ArrayList<CardView> candidates List<CardView> candidates
= trackedCards.get(info.getSetCode()).get(info.getCardNum()); = trackedCards.get(info.getSetCode()).get(info.getCardNum());
if (!candidates.isEmpty()) { if (!candidates.isEmpty()) {
gridStack.add(candidates.remove(0)); gridStack.add(candidates.remove(0));
@ -1679,8 +1665,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Check that there aren't any "orphans" not referenced in the layout. There should // Check that there aren't any "orphans" not referenced in the layout. There should
// never be any under normal operation, but as a failsafe in case the user screwed with // never be any under normal operation, but as a failsafe in case the user screwed with
// the file in an invalid way, sort them into the grid so that they aren't just left hanging. // the file in an invalid way, sort them into the grid so that they aren't just left hanging.
for (Map<String, ArrayList<CardView>> tracked : trackedCards.values()) { for (Map<String, List<CardView>> tracked : trackedCards.values()) {
for (ArrayList<CardView> orphans : tracked.values()) { for (List<CardView> orphans : tracked.values()) {
for (CardView orphan : orphans) { for (CardView orphan : orphans) {
LOGGER.info("Orphan when setting with layout: "); LOGGER.info("Orphan when setting with layout: ");
sortIntoGrid(orphan); sortIntoGrid(orphan);
@ -1734,7 +1720,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
AbstractButton button = selectByTypeButtons.get(cardType); AbstractButton button = selectByTypeButtons.get(cardType);
String text = cardType.toString(); String text = cardType.toString();
int numCards = getCount(cardType); int numCards = getCount(cardType);
if (cardType == cardType.CONSPIRACY) { if (cardType == CardType.CONSPIRACY) {
continue; continue;
} }
@ -1909,7 +1895,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
maxStackSize.add(0, 0); maxStackSize.add(0, 0);
} }
// What row to add it to? // What row to add it to?
ArrayList<ArrayList<CardView>> targetRow; List<List<CardView>> targetRow;
if (separateCreatures && !newCard.isCreature()) { if (separateCreatures && !newCard.isCreature()) {
// Ensure row 2 exists // Ensure row 2 exists
if (cardGrid.size() < 2) { if (cardGrid.size() < 2) {
@ -1930,7 +1916,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
for (int currentColumn = 0; currentColumn < cardGrid.get(0).size(); ++currentColumn) { for (int currentColumn = 0; currentColumn < cardGrid.get(0).size(); ++currentColumn) {
// Find an item from this column // Find an item from this column
CardView cardInColumn = null; CardView cardInColumn = null;
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (CardView card : gridRow.get(currentColumn)) { for (CardView card : gridRow.get(currentColumn)) {
cardInColumn = card; cardInColumn = card;
break; break;
@ -1975,9 +1961,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
private void trimGrid() { private void trimGrid() {
// Compact stacks and rows // Compact stacks and rows
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) { for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) {
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(rowIndex); List<List<CardView>> gridRow = cardGrid.get(rowIndex);
int rowMaxStackSize = 0; int rowMaxStackSize = 0;
for (ArrayList<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
// Clear out nulls in the stack // Clear out nulls in the stack
for (int i = 0; i < stack.size(); ++i) { for (int i = 0; i < stack.size(); ++i) {
if (stack.get(i) == null) { if (stack.get(i) == null) {
@ -2001,15 +1987,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
if (!cardGrid.isEmpty()) { if (!cardGrid.isEmpty()) {
for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) { for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) {
boolean hasContent = false; // Until contested boolean hasContent = false; // Until contested
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) { for (List<List<CardView>> aCardGrid : cardGrid) {
if (!cardGrid.get(rowIndex).get(colIndex).isEmpty()) { if (!aCardGrid.get(colIndex).isEmpty()) {
hasContent = true; hasContent = true;
break; break;
} }
} }
if (!hasContent) { if (!hasContent) {
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) { for (List<List<CardView>> aCardGrid : cardGrid) {
cardGrid.get(rowIndex).remove(colIndex); aCardGrid.remove(colIndex);
} }
--colIndex; --colIndex;
} }
@ -2018,13 +2004,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Clean up extra column header count labels // Clean up extra column header count labels
while (stackCountLabels.size() > cardGrid.size()) { while (stackCountLabels.size() > cardGrid.size()) {
ArrayList<JLabel> labels = stackCountLabels.remove(cardGrid.size()); List<JLabel> labels = stackCountLabels.remove(cardGrid.size());
for (JLabel label : labels) { for (JLabel label : labels) {
cardContent.remove(label); cardContent.remove(label);
} }
} }
int colCount = cardGrid.isEmpty() ? 0 : cardGrid.get(0).size(); int colCount = cardGrid.isEmpty() ? 0 : cardGrid.get(0).size();
for (ArrayList<JLabel> labels : stackCountLabels) { for (List<JLabel> labels : stackCountLabels) {
while (labels.size() > colCount) { while (labels.size() > colCount) {
cardContent.remove(labels.remove(colCount)); cardContent.remove(labels.remove(colCount));
} }
@ -2032,6 +2018,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
} }
private int getCardWidth() { private int getCardWidth() {
if (GUISizeHelper.editorCardDimension == null) {
return 200;
}
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod); return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
} }
@ -2054,9 +2043,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
int maxWidth = 0; int maxWidth = 0;
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) { for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) {
int rowMaxStackSize = 0; int rowMaxStackSize = 0;
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(rowIndex); List<List<CardView>> gridRow = cardGrid.get(rowIndex);
for (int colIndex = 0; colIndex < gridRow.size(); ++colIndex) { for (int colIndex = 0; colIndex < gridRow.size(); ++colIndex) {
ArrayList<CardView> stack = gridRow.get(colIndex); List<CardView> stack = gridRow.get(colIndex);
// Stack count label // Stack count label
if (stackCountLabels.size() <= rowIndex) { if (stackCountLabels.size() <= rowIndex) {

View file

@ -5,11 +5,13 @@ import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent; import javax.swing.JComponent;
class Slice { class Slice implements Serializable {
double value; double value;
Color color; Color color;
@ -22,7 +24,7 @@ class Slice {
public class ManaPieChart extends JComponent { public class ManaPieChart extends JComponent {
ArrayList<Slice> slices = new ArrayList<Slice>(); private List<Slice> slices = new ArrayList<>();
ManaPieChart() { ManaPieChart() {
} }

View file

@ -49,7 +49,7 @@ public class Permanent extends Card {
super(permanent, bigCard, dimensions, gameId); super(permanent, bigCard, dimensions, gameId);
this.setSize(this.getPreferredSize()); this.setSize(this.getPreferredSize());
this.permanent = permanent; this.permanent = permanent;
tappedImage = new BufferedImage(Config.dimensions.frameHeight, Config.dimensions.frameWidth, BufferedImage.TYPE_INT_RGB); tappedImage = new BufferedImage(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth(), BufferedImage.TYPE_INT_RGB);
} }
public UUID getPermanentId() { public UUID getPermanentId() {
@ -173,10 +173,10 @@ public class Permanent extends Card {
g2.setColor(Color.BLACK); g2.setColor(Color.BLACK);
} }
if (permanent.isTapped()) { if (permanent.isTapped()) {
g2.drawRect(0, 0, Config.dimensions.frameHeight - 1, Config.dimensions.frameWidth - 1); g2.drawRect(0, 0, Config.dimensions.getFrameHeight() - 1, Config.dimensions.getFrameWidth() - 1);
} }
else { else {
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1); g2.drawRect(0, 0, Config.dimensions.getFrameWidth() - 1, Config.dimensions.getFrameHeight() - 1);
} }
} }
@ -185,7 +185,7 @@ public class Permanent extends Card {
Graphics2D g = (Graphics2D) tappedImage.getGraphics(); Graphics2D g = (Graphics2D) tappedImage.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(TransformedImageCache.getRotatedResizedImage(small, dimension.frameWidth, dimension.frameHeight, Math.toRadians(90.0)), 0, 0, this); g.drawImage(TransformedImageCache.getRotatedResizedImage(small, dimension.getFrameWidth(), dimension.getFrameHeight(), Math.toRadians(90.0)), 0, 0, this);
g.dispose(); g.dispose();
} }
@ -206,10 +206,10 @@ public class Permanent extends Card {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if (permanent != null && permanent.isTapped()) { if (permanent != null && permanent.isTapped()) {
return new Dimension(Config.dimensions.frameHeight, Config.dimensions.frameWidth); return new Dimension(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth());
} }
else { else {
return new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); return new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
} }
} }
@ -229,7 +229,7 @@ public class Permanent extends Card {
tooltipPopup.hide(); tooltipPopup.hide();
} }
PopupFactory factory = PopupFactory.getSharedInstance(); PopupFactory factory = PopupFactory.getSharedInstance();
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?Config.dimensions.frameHeight:Config.dimensions.frameWidth); int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? Config.dimensions.getFrameHeight() : Config.dimensions.getFrameWidth());
int y = (int) this.getLocationOnScreen().getY() + 40; int y = (int) this.getLocationOnScreen().getY() + 40;
tooltipPopup = factory.getPopup(this, tooltipText, x, y); tooltipPopup = factory.getPopup(this, tooltipText, x, y);
tooltipPopup.show(); tooltipPopup.show();

View file

@ -47,6 +47,7 @@
<SubComponents> <SubComponents>
<Component class="mage.client.components.ColorPane" name="txtConversation"> <Component class="mage.client.components.ColorPane" name="txtConversation">
<Properties> <Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder/> <EmptyBorder/>

View file

@ -224,7 +224,6 @@ public class ChatPanelBasic extends javax.swing.JPanel {
StringBuilder text = new StringBuilder(); StringBuilder text = new StringBuilder();
if (time != null) { if (time != null) {
text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + ": ")); text.append(getColoredText(TIMESTAMP_COLOR, timeFormatter.format(time) + ": "));
//this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
} }
String userColor; String userColor;
String textColor; String textColor;
@ -239,11 +238,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
userColor = USER_INFO_COLOR; userColor = USER_INFO_COLOR;
break; break;
default: default:
if (parentChatRef != null) { userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
} else {
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
}
textColor = MESSAGE_COLOR; textColor = MESSAGE_COLOR;
userSeparator = ": "; userSeparator = ": ";
} }
@ -366,6 +361,7 @@ public class ChatPanelBasic extends javax.swing.JPanel {
jScrollPaneTxt.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); jScrollPaneTxt.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
jScrollPaneTxt.setPreferredSize(new java.awt.Dimension(32767, 32767)); jScrollPaneTxt.setPreferredSize(new java.awt.Dimension(32767, 32767));
txtConversation.setEditable(false);
txtConversation.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); txtConversation.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
txtConversation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N txtConversation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
txtConversation.setFocusCycleRoot(false); txtConversation.setFocusCycleRoot(false);

View file

@ -55,11 +55,7 @@ public class ChatPanelSeparated extends ChatPanelBasic {
userColor = USER_INFO_COLOR; userColor = USER_INFO_COLOR;
break; break;
default: default:
if (parentChatRef != null) { userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
} else {
userColor = SessionHandler.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
}
textColor = MESSAGE_COLOR; textColor = MESSAGE_COLOR;
userSeparator = ": "; userSeparator = ": ";
} }

View file

@ -14,6 +14,9 @@ import java.util.UUID;
public final class LocalCommands { public final class LocalCommands {
private LocalCommands(){}
/** /**
* Handler for commands that do not require server interaction, i.e settings etc * Handler for commands that do not require server interaction, i.e settings etc
* @param chatId * @param chatId

View file

@ -1,118 +1,176 @@
package mage.client.components; package mage.client.components;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPopupMenu;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import javax.swing.*;
import java.awt.event.*;
/** /**
* * @author Campbell Suter <znix@znix.xyz>, JayDi85
* @author Campbell Suter <znix@znix.xyz>
*/ */
public class KeyBindButton extends JButton implements ActionListener { public class KeyBindButton extends JButton implements ActionListener {
private final PreferencesDialog preferences; private final PreferencesDialog preferences;
private final String key; private final String key;
private PopupItem item; private PopupItem item;
private JPopupMenu menu; private JPopupMenu menu;
private int keyCode; private int keyCode;
private String text; private int modifierCode;
private String text;
/** /**
* For the IDE only, do not use! * For the IDE only, do not use!
*/ */
public KeyBindButton() { public KeyBindButton() {
this(null, null); this(null, null);
} }
public KeyBindButton(PreferencesDialog preferences, String key) { public KeyBindButton(PreferencesDialog preferences, String key) {
this.preferences = preferences; this.preferences = preferences;
this.key = key; this.key = key;
addActionListener(this); addActionListener(this);
fixText(); fixText();
} }
private JPopupMenu getMenu() { private JPopupMenu createPopupMenu() {
menu = new JPopupMenu(); menu = new JPopupMenu();
menu.add(item = new PopupItem()); menu.add(item = new PopupItem());
return menu; return menu;
} }
private void applyNewKeycode(int code) { private void applyNewKeycode(int code, int modifier) {
preferences.getKeybindButtons().stream() // clear used keys
.filter(b -> b != KeyBindButton.this) preferences.getKeybindButtons().stream()
.filter(b -> { .filter(b -> b != KeyBindButton.this)
return b.keyCode == code; .filter(b -> {
return b.keyCode == code && b.modifierCode == modifier;
}) })
.forEach(b -> b.setKeyCode(0)); .forEach(b -> {
b.setKeyCode(0);
b.setModifierCode(0);
});
setKeyCode(code); // set new
menu.setVisible(false); setKeyCode(code);
} setModifierCode(modifier);
menu.setVisible(false);
}
private void fixText() { private void fixText() {
if (keyCode == 0) { if (keyCode == 0) {
text = "<None>"; text = "<none>";
} else { } else {
text = KeyEvent.getKeyText(keyCode); String codeStr = KeyEvent.getKeyText(keyCode);
} String modStr = KeyEvent.getKeyModifiersText(modifierCode);
repaint(); text = (modStr.isEmpty() ? "" : modStr + " + ") + codeStr;
} }
repaint();
}
public void setKeyCode(int keyCode) { public void setKeyCode(int keyCode) {
this.keyCode = keyCode; this.keyCode = keyCode;
switch (keyCode) { switch (keyCode) {
case KeyEvent.VK_ESCAPE: case KeyEvent.VK_ESCAPE:
case KeyEvent.VK_SPACE: case KeyEvent.VK_SPACE:
keyCode = 0; this.keyCode = 0;
} }
fixText(); fixText();
setSize(getPreferredSize()); //setSize(getPreferredSize());
} }
public int getKeyCode() { public int getKeyCode() {
return keyCode; return keyCode;
} }
@Override public void setModifierCode(int modifierCode) {
public String getText() { this.modifierCode = modifierCode;
return text;
}
public String getKey() { // only single modifier allowed
return key; if (!(modifierCode == InputEvent.ALT_MASK
} || modifierCode == InputEvent.CTRL_MASK
|| modifierCode == InputEvent.SHIFT_MASK)) {
this.modifierCode = 0;
}
fixText();
//setSize(getPreferredSize());
}
@Override public int getModifierCode() {
public void actionPerformed(ActionEvent e) { return modifierCode;
getMenu().show(this, 0, 0); }
item.requestFocusInWindow();
}
private class PopupItem extends JLabel implements KeyListener { @Override
public String getText() {
return text;
}
public PopupItem() { public String getKey() {
super("Press a key"); return key;
addKeyListener(this); }
setFocusable(true);
}
@Override @Override
public void keyTyped(KeyEvent e) { public void actionPerformed(ActionEvent e) {
} JPopupMenu m = createPopupMenu();
m.setPopupSize(this.getWidth(), this.getHeight());
m.show(this, 0, 0);
item.requestFocusInWindow();
}
@Override private class PopupItem extends JLabel implements KeyListener {
public void keyPressed(KeyEvent e) {
applyNewKeycode(e.getKeyCode());
}
@Override public PopupItem() {
public void keyReleased(KeyEvent e) { super("Press a key");
} addKeyListener(this);
setFocusable(true);
}
} @Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
// cancel on ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
menu.setVisible(false);
return;
}
// clear on SPACE
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
setKeyCode(0);
setModifierCode(0);
menu.setVisible(false);
return;
}
// ignore multiple mod keys
switch (e.getModifiers()) {
case KeyEvent.CTRL_MASK:
case KeyEvent.SHIFT_MASK:
case KeyEvent.ALT_MASK:
case 0:
break;
default:
return;
}
// skip single mod keys without chars
switch (e.getKeyCode()) {
case KeyEvent.VK_CONTROL:
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_ALT:
return;
}
// all done, can save
applyNewKeycode(e.getKeyCode(), e.getModifiers());
}
@Override
public void keyReleased(KeyEvent e) {
}
}
} }

View file

@ -15,6 +15,8 @@ public class KeyboundButton extends JButton {
private final String text; private final String text;
private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13); private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13);
private boolean tinting = false;
public KeyboundButton(String key) { public KeyboundButton(String key) {
text = PreferencesDialog.getCachedKeyText(key); text = PreferencesDialog.getCachedKeyText(key);
} }
@ -25,7 +27,11 @@ public class KeyboundButton extends JButton {
Graphics sg = g.create(); Graphics sg = g.create();
try { try {
ui.update(sg, this); ui.update(sg, this);
sg.setColor(Color.white); if (tinting) {
sg.setColor(new Color(0, 0, 0, 32));
sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6);
}
sg.setColor(tinting ? Color.lightGray : Color.white);
sg.setFont(keyFont); sg.setFont(keyFont);
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text); int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
@ -37,4 +43,10 @@ public class KeyboundButton extends JButton {
} }
} }
} }
public void setTint(boolean tinting) {
this.tinting = tinting;
repaint();
}
} }

View file

@ -22,15 +22,9 @@ public class MageJDesktop extends JDesktopPane {
public void updateUI() { public void updateUI() {
if ("Nimbus".equals(UIManager.getLookAndFeel().getName())) { if ("Nimbus".equals(UIManager.getLookAndFeel().getName())) {
UIDefaults map = new UIDefaults(); UIDefaults map = new UIDefaults();
Painter painter = new Painter() { Painter painter = (g, c, w, h) -> {
g.setColor( UIManager.getDefaults().getColor("desktop") );
final Color color = null; g.fillRect(0,0,w,h);
@Override
public void paint(Graphics2D g, Object c, int w, int h) {
g.setColor(color == null ? UIManager.getDefaults().getColor("desktop") : color);
g.fillRect(0,0,w,h);
}
}; };
map.put("DesktopPane[Enabled].backgroundPainter", painter); map.put("DesktopPane[Enabled].backgroundPainter", painter);
putClientProperty("Nimbus.Overrides", map); putClientProperty("Nimbus.Overrides", map);

View file

@ -1,20 +1,21 @@
package mage.client.components; package mage.client.components;
import com.google.common.base.Function; import java.awt.*;
import com.google.common.collect.MapMaker;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import javax.swing.JPanel;
import mage.client.util.ImageCaches; import javax.swing.*;
import org.jdesktop.swingx.graphics.GraphicsUtilities; import org.jdesktop.swingx.graphics.GraphicsUtilities;
import org.jdesktop.swingx.graphics.ShadowRenderer; import org.jdesktop.swingx.graphics.ShadowRenderer;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import mage.client.util.ImageCaches;
import mage.client.util.SoftValuesLoadingCache;
/** /**
* Mage round pane with transparency. Used for tooltips. * Mage round pane with transparency. Used for tooltips.
* *
@ -26,17 +27,15 @@ public class MageRoundPane extends JPanel {
private int Y_OFFSET = 30; private int Y_OFFSET = 30;
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
private Color backgroundColor = defaultBackgroundColor; private Color backgroundColor = defaultBackgroundColor;
private static final int alpha = 0; private static final SoftValuesLoadingCache<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE; private static final SoftValuesLoadingCache<Key, BufferedImage> IMAGE_CACHE;
private static final Map<Key, BufferedImage> IMAGE_CACHE;
static { static {
SHADOW_IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<ShadowKey, BufferedImage>) key -> createShadowImage(key))); SHADOW_IMAGE_CACHE = ImageCaches.register(SoftValuesLoadingCache.from(MageRoundPane::createShadowImage));
IMAGE_CACHE = ImageCaches.register(SoftValuesLoadingCache.from(MageRoundPane::createImage));
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<Key, BufferedImage>) key -> createImage(key)));
} }
private final static class ShadowKey { private static final class ShadowKey {
final int width; final int width;
final int height; final int height;
@ -76,7 +75,7 @@ public class MageRoundPane extends JPanel {
} }
} }
private final static class Key { private static final class Key {
final int width; final int width;
final int height; final int height;
@ -136,7 +135,7 @@ public class MageRoundPane extends JPanel {
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
g.drawImage(IMAGE_CACHE.get(new Key(getWidth(), getHeight(), X_OFFSET, Y_OFFSET, backgroundColor)), 0, 0, null); g.drawImage(IMAGE_CACHE.getOrThrow(new Key(getWidth(), getHeight(), X_OFFSET, Y_OFFSET, backgroundColor)), 0, 0, null);
} }
private static BufferedImage createImage(Key key) { private static BufferedImage createImage(Key key) {
@ -150,7 +149,7 @@ public class MageRoundPane extends JPanel {
Graphics2D g2 = image.createGraphics(); Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
BufferedImage shadow = SHADOW_IMAGE_CACHE.get(new ShadowKey(w, h)); BufferedImage shadow = SHADOW_IMAGE_CACHE.getOrThrow(new ShadowKey(w, h));
{ {
int xOffset = (shadow.getWidth() - w) / 2; int xOffset = (shadow.getWidth() - w) / 2;
@ -163,8 +162,8 @@ public class MageRoundPane extends JPanel {
/** /**
* Add white translucent substrate * Add white translucent substrate
*/ */
/*if (alpha != 0) { /*if (ALPHA != 0) {
g2.setColor(new Color(255, 255, 255, alpha)); g2.setColor(new Color(255, 255, 255, ALPHA));
g2.fillRoundRect(x, y, w, h, arc, arc); g2.fillRoundRect(x, y, w, h, arc, arc);
}*/ }*/
g2.setColor(key.backgroundColor); g2.setColor(key.backgroundColor);

View file

@ -1,9 +1,8 @@
package mage.client.components.ability; package mage.client.components.ability;
import mage.client.SessionHandler; import mage.client.SessionHandler;
import mage.client.dialog.MageDialog;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.remote.Session; import mage.remote.Session;
import mage.view.AbilityPickerView; import mage.view.AbilityPickerView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -17,8 +16,8 @@ import org.mage.card.arcane.UI;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*;
import java.util.List; import java.util.List;
import java.util.*;
/** /**
* Dialog for choosing abilities. * Dialog for choosing abilities.
@ -112,10 +111,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
this.selected = false; // back to false - waiting for selection this.selected = false; // back to false - waiting for selection
setVisible(true); setVisible(true);
Point centered = SettingsManager.instance.getComponentPosition(DIALOG_WIDTH, DIALOG_HEIGHT); MageDialog.makeWindowCentered(this, DIALOG_WIDTH, DIALOG_HEIGHT);
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
//startModal(); //startModal();
} }
@ -188,28 +184,28 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
GroupLayout.TRAILING, GroupLayout.TRAILING,
layout.createSequentialGroup().addContainerGap().add( layout.createSequentialGroup().addContainerGap().add(
layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING,
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add( layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
GroupLayout.LEADING, GroupLayout.LEADING,
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING) layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
) )
.addPreferredGap(LayoutStyle.RELATED) .addPreferredGap(LayoutStyle.RELATED)
.add( .add(
layout.createParallelGroup(GroupLayout.TRAILING) layout.createParallelGroup(GroupLayout.TRAILING)
.add( .add(
GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10))); GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10)));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add( layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
layout.createSequentialGroup().add( layout.createSequentialGroup().add(
layout.createParallelGroup(GroupLayout.LEADING).add( layout.createParallelGroup(GroupLayout.LEADING).add(
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE) layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
.add(5, 5, 5) .add(5, 5, 5)
.add( .add(
layout.createParallelGroup(GroupLayout.BASELINE) layout.createParallelGroup(GroupLayout.BASELINE)
) )
).add(layout.createSequentialGroup().add(8, 8, 8))) ).add(layout.createSequentialGroup().add(8, 8, 8)))
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add( .addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap( layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE))); LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
} }
@Override @Override

View file

@ -16,7 +16,7 @@ public class BackgroundPainter extends AbstractPainter {
private final Color bgColor = Color.black; private final Color bgColor = Color.black;
static final float bgalpha = 0.6f; static final float BACKGROUND_ALPHA = 0.6f;
public BackgroundPainter() { public BackgroundPainter() {
super(); super();
@ -25,7 +25,7 @@ public class BackgroundPainter extends AbstractPainter {
@Override @Override
protected void doPaint(Graphics2D g2, Object o, int i, int i1) { protected void doPaint(Graphics2D g2, Object o, int i, int i1) {
float alpha = bgalpha; float alpha = BACKGROUND_ALPHA;
Component c = (Component)o; Component c = (Component)o;
Composite composite = g2.getComposite(); Composite composite = g2.getComposite();
if (composite instanceof AlphaComposite) { if (composite instanceof AlphaComposite) {

View file

@ -0,0 +1,8 @@
package mage.client.components.ext;
public enum MessageDialogType {
INFO,
WARNING,
ERROR,
FLASH_INFO
}

View file

@ -1,13 +0,0 @@
package mage.client.components.ext;
/**
* @author mw, noxx
*/
public class MessageDlg {
MessageDlg() {}
public enum Types {
Info, Warning, Error, FlashInfo
}
}

View file

@ -1,6 +1,6 @@
package mage.client.components.ext.dlg; package mage.client.components.ext.dlg;
import mage.client.components.ext.MessageDlg; import mage.client.components.ext.MessageDialogType;
import mage.client.components.ext.dlg.impl.ChoiceDialog; import mage.client.components.ext.dlg.impl.ChoiceDialog;
import mage.client.components.ext.dlg.impl.StackDialog; import mage.client.components.ext.dlg.impl.StackDialog;
@ -37,146 +37,99 @@ public class DialogContainer extends JPanel {
setLayout(null); setLayout(null);
drawContainer = true; drawContainer = true;
if (dialogType == DialogManager.MTGDialogs.MessageDialog) { switch (dialogType) {
//backgroundColor = new Color(0, 255, 255, 60); case MESSAGE:
if (params.type == MessageDlg.Types.Warning) { //backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(255, 0, 0, 90); if (params.type == MessageDialogType.WARNING) {
} else { backgroundColor = new Color(255, 0, 0, 90);
backgroundColor = new Color(0, 0, 0, 90); } else {
backgroundColor = new Color(0, 0, 0, 90);
}
alpha = 0;
//MessageDlg dlg = new MessageDlg(params);
//add(dlg);
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
//dlg.updateSize(params.rect.width, params.rect.height);
break;
case STACK: {
//backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(0, 0, 0, 50);
alpha = 0;
StackDialog dlg = new StackDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
//int width = Math.min(params.rect.width - 80, 600);
int width = params.rect.width;
int height = params.rect.height - 80;
dlg.updateSize(width, height);
break;
} }
alpha = 0;
//MessageDlg dlg = new MessageDlg(params);
//add(dlg);
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
//dlg.updateSize(params.rect.width, params.rect.height);
} else if (dialogType == DialogManager.MTGDialogs.StackDialog) {
//backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(0, 0, 0, 50);
alpha = 0;
StackDialog dlg = new StackDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
//int width = Math.min(params.rect.width - 80, 600);
int width = params.rect.width;
int height = params.rect.height - 80;
dlg.updateSize(width, height);
}
/* /*
else if (dialogType == DialogManager.MTGDialogs.CombatDialog) { else if (dialogType == DialogManager.MTGDialogs.COMBAT) {
backgroundColor = new Color(0, 0, 0, 60); backgroundColor = new Color(0, 0, 0, 60);
alpha = 0; alpha = 0;
CombatDialog dlg = new CombatDialog(params); COMBAT dlg = new COMBAT(params);
add(dlg); add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10); dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80); dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
}*/ else if (dialogType == DialogManager.MTGDialogs.ChoiceDialog) { }*/
case CHOICE: {
//backgroundColor = new Color(200, 200, 172, 120); //backgroundColor = new Color(200, 200, 172, 120);
//backgroundColor = new Color(180, 150, 200, 120); //backgroundColor = new Color(180, 150, 200, 120);
//backgroundColor = new Color(0, 255, 0, 60); //backgroundColor = new Color(0, 255, 0, 60);
//backgroundColor = new Color(139, 46, 173, 20); //backgroundColor = new Color(139, 46, 173, 20);
backgroundColor = new Color(0, 0, 0, 110); backgroundColor = new Color(0, 0, 0, 110);
//backgroundColor = new Color(139, 46, 173, 0); //backgroundColor = new Color(139, 46, 173, 0);
alpha = 0; alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Choose"); ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
add(dlg); add(dlg);
//GameManager.getManager().setCurrentChoiceDlg(dlg); //GameManager.getManager().setCurrentChoiceDlg(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10); dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80); dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.GraveDialog) { break;
}
backgroundColor = new Color(0, 0, 0, 110); case GRAVEYARD: {
alpha = 0; backgroundColor = new Color(0, 0, 0, 110);
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
add(dlg); alpha = 0;
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10); ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
dlg.updateSize(params.rect.width - 80, params.rect.height - 80); add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
} else if (dialogType == DialogManager.MTGDialogs.ExileDialog) { dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
backgroundColor = new Color(250, 250, 250, 50); break;
}
alpha = 0; case EXILE: {
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
add(dlg); backgroundColor = new Color(250, 250, 250, 50);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80); alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
} else if (dialogType == DialogManager.MTGDialogs.EmblemsDialog) { add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
backgroundColor = new Color(0, 0, 50, 110); dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
alpha = 0; break;
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)"); }
add(dlg); case EMBLEMS: {
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80); backgroundColor = new Color(0, 0, 50, 110);
} /*else if (dialogType == DialogManager.MTGDialogs.GraveDialog) { alpha = 0;
backgroundColor = new Color(20, 20, 20, 120); ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
alpha = 0; add(dlg);
GraveDialog dlg = new GraveDialog(params); dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
add(dlg); dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80); break;
} else if (dialogType == DialogManager.MTGDialogs.RevealDialog) {
backgroundColor = new Color(90, 135, 190, 80);
alpha = 0;
RevealDialog dlg = new RevealDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.AssignDamageDialog) {
backgroundColor = new Color(255, 255, 255, 130);
alpha = 0;
AssignDamageDialog dlg = new AssignDamageDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.ManaChoiceDialog) {
backgroundColor = new Color(0, 255, 255, 60);
alpha = 20;
ManaChoiceDialog dlg = new ManaChoiceDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
//isGradient = true;
gradient = ImageManager.getGradientImage();
if (gradient != null) {
b = ImageToBufferedImage.toBufferedImage(gradient);
b = Transparency.makeImageTranslucent(b, 0.35);
Rectangle2D tr = new Rectangle2D.Double(0, 0, params.rect.width, params.rect.height);
//gradient = gradient.getScaledInstance(w, h, Image.SCALE_SMOOTH);
tp = new TexturePaint(b, tr);
} }
} else if (dialogType == DialogManager.MTGDialogs.ChooseDeckDialog) {
MWDeckPanel deckPanel = new MWDeckPanel(params.getDeckList(), params.isAI);
deckPanel.setVisible(true);
deckPanel.setBounds(0,0,480,320);
add(deckPanel);
drawContainer = false;
} else if (dialogType == DialogManager.MTGDialogs.ChooseCommonDialog) {
MWChoosePanel choosePanel = new MWChoosePanel(params.getObjectList(), params.getTitle());
choosePanel.setVisible(true);
choosePanel.setBounds(0,0,440,240);
add(choosePanel);
drawContainer = false;
} else if (dialogType == DialogManager.MTGDialogs.AboutDialog) {
backgroundColor = new Color(255, 255, 255, 120);
alpha = 0;
AboutDialog dlg = new AboutDialog();
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
} }
*/
} }
public void cleanUp() { public void cleanUp() {

View file

@ -20,7 +20,7 @@ import java.util.UUID;
public class DialogManager extends JComponent implements MouseListener, public class DialogManager extends JComponent implements MouseListener,
MouseMotionListener { MouseMotionListener {
private final static Map<UUID, DialogManager> dialogManagers = new HashMap<>(); private static final Map<UUID, DialogManager> dialogManagers = new HashMap<>();
public static DialogManager getManager(UUID gameId) { public static DialogManager getManager(UUID gameId) {
if (!dialogManagers.containsKey(gameId)) { if (!dialogManagers.containsKey(gameId)) {
@ -39,8 +39,8 @@ public class DialogManager extends JComponent implements MouseListener,
} }
public enum MTGDialogs { public enum MTGDialogs {
none, AboutDialog, MessageDialog, StackDialog, AssignDamageDialog, ManaChoiceDialog, ChoiceDialog, EmblemsDialog, GraveDialog, DialogContainer, CombatDialog, NONE, ABOUT, MESSAGE, STACK, ASSIGN_DAMAGE, MANA_CHOICE, CHOICE, EMBLEMS, GRAVEYARD, DialogContainer, COMBAT,
ChooseDeckDialog, ChooseCommonDialog, RevealDialog, ExileDialog CHOOSE_DECK, CHOOSE_COMMON, REVEAL, EXILE
} }
/** /**
@ -58,7 +58,7 @@ public class DialogManager extends JComponent implements MouseListener,
} }
} }
private MTGDialogs currentDialog = MTGDialogs.none; private MTGDialogs currentDialog = MTGDialogs.NONE;
private DialogContainer dialogContainer = null; private DialogContainer dialogContainer = null;
@ -133,7 +133,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId; params.gameId = gameId;
params.feedbackPanel = feedbackPanel; params.feedbackPanel = feedbackPanel;
params.setCards(cards); params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.StackDialog, params); dialogContainer = new DialogContainer(MTGDialogs.STACK, params);
dialogContainer.setVisible(true); dialogContainer.setVisible(true);
add(dialogContainer); add(dialogContainer);
@ -163,7 +163,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId; params.gameId = gameId;
//params.feedbackPanel = feedbackPanel; //params.feedbackPanel = feedbackPanel;
params.setCards(cards); params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.GraveDialog, params); dialogContainer = new DialogContainer(MTGDialogs.GRAVEYARD, params);
dialogContainer.setVisible(true); dialogContainer.setVisible(true);
add(dialogContainer); add(dialogContainer);
@ -192,7 +192,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.bigCard = bigCard; params.bigCard = bigCard;
params.gameId = gameId; params.gameId = gameId;
params.setCards(cards); params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.ExileDialog, params); dialogContainer = new DialogContainer(MTGDialogs.EXILE, params);
dialogContainer.setVisible(true); dialogContainer.setVisible(true);
add(dialogContainer); add(dialogContainer);
@ -222,7 +222,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId; params.gameId = gameId;
//params.feedbackPanel = feedbackPanel; //params.feedbackPanel = feedbackPanel;
params.setCards(cards); params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.EmblemsDialog, params); dialogContainer = new DialogContainer(MTGDialogs.EMBLEMS, params);
dialogContainer.setVisible(true); dialogContainer.setVisible(true);
add(dialogContainer); add(dialogContainer);
@ -248,7 +248,7 @@ public class DialogManager extends JComponent implements MouseListener,
removeAll(); removeAll();
} }
this.currentDialog = MTGDialogs.none; this.currentDialog = MTGDialogs.NONE;
setVisible(false); setVisible(false);
@ -312,6 +312,7 @@ public class DialogManager extends JComponent implements MouseListener,
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
} }
@Override @Override
@ -360,7 +361,7 @@ public class DialogManager extends JComponent implements MouseListener,
public void mouseWheelMoved(MouseWheelEvent e) { public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation(); int notches = e.getWheelRotation();
// System.out.println("outx:"+notches); // System.out.println("outx:"+notches);
// if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) { // if (currentDialog != null && currentDialog.equals(MTGDialogs.CHOOSE_COMMON)) {
// System.out.println("out:"+1); // System.out.println("out:"+1);
// } // }
} }

View file

@ -1,13 +1,14 @@
package mage.client.components.ext.dlg; package mage.client.components.ext.dlg;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.components.ext.MessageDlg; import mage.client.components.ext.MessageDialogType;
import mage.client.game.FeedbackPanel; import mage.client.game.FeedbackPanel;
import mage.view.CardsView; import mage.view.CardsView;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
/** /**
@ -18,7 +19,7 @@ import java.util.UUID;
public class DlgParams { public class DlgParams {
public Rectangle rect; public Rectangle rect;
public MessageDlg.Types type; public MessageDialogType type;
public BigCard bigCard; public BigCard bigCard;
public FeedbackPanel feedbackPanel; public FeedbackPanel feedbackPanel;
public UUID gameId; public UUID gameId;
@ -26,19 +27,19 @@ public class DlgParams {
private int playerID; private int playerID;
private CardsView cards; private CardsView cards;
private ArrayList<String> stringList; private java.util.List<String> stringList;
//private ArrayList<DeckInfo> deckList; //private ArrayList<DeckInfo> deckList;
private ArrayList<Object> objectList; private java.util.List<Object> objectList;
private String title; private String title;
private int opponentID; private int opponentID;
boolean isOptional = false; private boolean isOptional = false;
boolean isChooseAbility = false; private boolean isChooseAbility = false;
boolean isCancelStopsPlaying = true; private boolean isCancelStopsPlaying = true;
boolean isAI = false; private boolean isAI = false;
public HashSet<String> manaChoices = new HashSet<>(); private Set<String> manaChoices = new HashSet<>();
public int getPlayerID() { public int getPlayerID() {
return playerID; return playerID;
@ -74,11 +75,11 @@ public class DlgParams {
this.message = message; this.message = message;
} }
public HashSet<String> getManaChoices() { public Set<String> getManaChoices() {
return manaChoices; return manaChoices;
} }
public void setManaChoices(HashSet<String> manaChoices) { public void setManaChoices(Set<String> manaChoices) {
this.manaChoices = manaChoices; this.manaChoices = manaChoices;
} }
@ -98,7 +99,7 @@ public class DlgParams {
this.isChooseAbility = isChooseAbility; this.isChooseAbility = isChooseAbility;
} }
public ArrayList<String> getStringList() { public java.util.List<String> getStringList() {
return stringList; return stringList;
} }
@ -114,7 +115,7 @@ public class DlgParams {
this.deckList = deckList; this.deckList = deckList;
}*/ }*/
public ArrayList<Object> getObjectList() { public java.util.List<Object> getObjectList() {
return objectList; return objectList;
} }

View file

@ -10,7 +10,7 @@ import java.awt.*;
/** /**
* @author mw, noxx * @author mw, noxx
*/ */
abstract public class IDialogPanel extends JXPanel { public abstract class IDialogPanel extends JXPanel {
private DlgParams params; private DlgParams params;
private Dimension cardDimension; private Dimension cardDimension;
@ -71,7 +71,7 @@ abstract public class IDialogPanel extends JXPanel {
protected Dimension getCardDimension() { protected Dimension getCardDimension() {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
} }
return cardDimension; return cardDimension;
} }

View file

@ -50,11 +50,12 @@ public class ChoiceDialog extends IDialogPanel {
private boolean isCancelStopsPlaying = true; private boolean isCancelStopsPlaying = true;
private final DlgParams params; private final DlgParams params;
private final String title; private final String title;
/** /**
* This is the default constructor * This is the default constructor
*
* @param params * @param params
* @param title * @param title
*/ */
@ -130,18 +131,18 @@ public class ChoiceDialog extends IDialogPanel {
return; return;
} }
ArrayList<Component> toRemove = new ArrayList<>(); java.util.List<Component> toRemove = new ArrayList<>();
for (int i = getComponentCount() - 1; i > 0; i--) { for (int i = getComponentCount() - 1; i > 0; i--) {
Component o = getComponent(i); Component o = getComponent(i);
if (o instanceof MageCard) { if (o instanceof MageCard) {
toRemove.add(o); toRemove.add(o);
} }
} }
for (int i = 0; i < toRemove.size(); i++) { for (Component aToRemove : toRemove) {
remove(toRemove.get(i)); remove(aToRemove);
} }
ArrayList<CardView> cardList = new ArrayList<>(cards.values()); java.util.List<CardView> cardList = new ArrayList<>(cards.values());
int width = SettingsManager.instance.getCardSize().width; int width = SettingsManager.instance.getCardSize().width;
int height = SettingsManager.instance.getCardSize().height; int height = SettingsManager.instance.getCardSize().height;
@ -163,7 +164,7 @@ public class ChoiceDialog extends IDialogPanel {
CardView card = cardList.get(i); CardView card = cardList.get(i);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true); MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
cardImg.setLocation(dx, dy + j*(height + 30)); cardImg.setLocation(dx, dy + j * (height + 30));
add(cardImg); add(cardImg);
dx += (width + 20); dx += (width + 20);
@ -237,11 +238,8 @@ public class ChoiceDialog extends IDialogPanel {
int h = getDlgParams().rect.height - 90; int h = getDlgParams().rect.height - 90;
jButtonNextPage.setBounds(new Rectangle(w / 2 + 45, h - 50, 60, 60)); jButtonNextPage.setBounds(new Rectangle(w / 2 + 45, h - 50, 60, 60));
if (maxPages > 1) { jButtonNextPage.setVisible(maxPages > 1);
jButtonNextPage.setVisible(true);
} else {
jButtonNextPage.setVisible(false);
}
jButtonNextPage.setObserver(new Command() { jButtonNextPage.setObserver(new Command() {
private static final long serialVersionUID = -3174360416099554104L; private static final long serialVersionUID = -3174360416099554104L;

View file

@ -85,11 +85,6 @@ public class StackDialog extends IDialogPanel {
jTitle.setFont(new Font("Dialog", Font.BOLD, 14)); jTitle.setFont(new Font("Dialog", Font.BOLD, 14));
jTitle.setText("Current stack: "); jTitle.setText("Current stack: ");
/*jTitle2 = new CustomLabel();
jTitle2.setBounds(new Rectangle(5, 5 + SettingsManager.getInstance().getCardSize().height + 30, 129, 20));
jTitle2.setFont(new Font("Dialog", Font.BOLD, 14));
jTitle2.setText("Spell targets:");*/
this.setLayout(null); this.setLayout(null);
jLayeredPane.setLayout(null); jLayeredPane.setLayout(null);

View file

@ -78,7 +78,6 @@ public enum MageTray {
tray.add(trayIcon); tray.add(trayIcon);
} catch (AWTException e) { } catch (AWTException e) {
log.error("TrayIcon could not be added: ", e); log.error("TrayIcon could not be added: ", e);
return;
} }
} catch (Exception e) { } catch (Exception e) {

View file

@ -94,7 +94,6 @@ public final class Constants {
public interface IO { public interface IO {
String DEFAULT_IMAGES_DIR = "plugins" + File.separator + "images" + File.separator; String DEFAULT_IMAGES_DIR = "plugins" + File.separator + "images" + File.separator;
String IMAGE_PROPERTIES_FILE = "image.url.properties";
} }
public enum DeckEditorMode { public enum DeckEditorMode {

View file

@ -1,4 +1,3 @@
package mage.client.deck.generator; package mage.client.deck.generator;
import java.util.ArrayList; import java.util.ArrayList;
@ -7,6 +6,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.cards.repository.CardCriteria; import mage.cards.repository.CardCriteria;
@ -123,9 +123,9 @@ public final class DeckGenerator {
* non-creatures, lands (including non-basic). Fixes the deck, adjusting for * non-creatures, lands (including non-basic). Fixes the deck, adjusting for
* size and color of the cards retrieved. * size and color of the cards retrieved.
* *
* @param deckSize how big the deck is to generate. * @param deckSize how big the deck is to generate.
* @param allowedColors which colors are allowed in the deck. * @param allowedColors which colors are allowed in the deck.
* @param setsToUse which sets to use to retrieve cards for this deck. * @param setsToUse which sets to use to retrieve cards for this deck.
* @return the final deck to use. * @return the final deck to use.
*/ */
private static Deck generateDeck(int deckSize, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) { private static Deck generateDeck(int deckSize, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) {
@ -180,9 +180,9 @@ public final class DeckGenerator {
* non-creatures are retrieved separately to ensure the deck contains a * non-creatures are retrieved separately to ensure the deck contains a
* reasonable mix of both. * reasonable mix of both.
* *
* @param criteria the criteria to search for in the database. * @param criteria the criteria to search for in the database.
* @param spellCount the number of spells that match the criteria needed in * @param spellCount the number of spells that match the criteria needed in
* the deck. * the deck.
*/ */
private static void generateSpells(CardCriteria criteria, int spellCount) { private static void generateSpells(CardCriteria criteria, int spellCount) {
List<CardInfo> cardPool = CardRepository.instance.findCards(criteria); List<CardInfo> cardPool = CardRepository.instance.findCards(criteria);
@ -233,7 +233,7 @@ public final class DeckGenerator {
* in this deck. Usually the lands will be well balanced relative to the * in this deck. Usually the lands will be well balanced relative to the
* color of cards. * color of cards.
* *
* @param criteria the criteria of the lands to search for in the database. * @param criteria the criteria of the lands to search for in the database.
* @param landsCount the amount of lands required for this deck. * @param landsCount the amount of lands required for this deck.
* @param basicLands information about the basic lands from the sets used. * @param basicLands information about the basic lands from the sets used.
*/ */
@ -310,10 +310,10 @@ public final class DeckGenerator {
* filled. * filled.
* *
* @param landsNeeded how many remaining lands are needed. * @param landsNeeded how many remaining lands are needed.
* @param percentage the percentage needed for each color in the final deck. * @param percentage the percentage needed for each color in the final deck.
* @param count how many of each color can be produced by non-basic lands. * @param count how many of each color can be produced by non-basic lands.
* @param basicLands list of information about basic lands from the * @param basicLands list of information about basic lands from the
* database. * database.
*/ */
private static void addBasicLands(int landsNeeded, Map<String, Double> percentage, Map<String, Integer> count, Map<String, List<CardInfo>> basicLands) { private static void addBasicLands(int landsNeeded, Map<String, Double> percentage, Map<String, Integer> count, Map<String, List<CardInfo>> basicLands) {
@ -360,15 +360,14 @@ public final class DeckGenerator {
/** /**
* Return a random basic land of the chosen color. * Return a random basic land of the chosen color.
* *
* @param color the color the basic land should produce. * @param color the color the basic land should produce.
* @param basicLands list of information about basic lands from the * @param basicLands list of information about basic lands from the
* database. * database.
* @return a single basic land that produces the color needed. * @return a single basic land that produces the color needed.
*/ */
private static Card getBasicLand(ColoredManaSymbol color, Map<String, List<CardInfo>> basicLands) { private static Card getBasicLand(ColoredManaSymbol color, Map<String, List<CardInfo>> basicLands) {
String landName = DeckGeneratorPool.getBasicLandName(color.toString()); String landName = DeckGeneratorPool.getBasicLandName(color.toString());
List<CardInfo> basicLandsInfo = basicLands.get(landName); List<CardInfo> basicLandsInfo = basicLands.get(landName);
return basicLandsInfo.get(RandomUtil.nextInt(basicLandsInfo.size() - 1)).getMockCard().copy(); return basicLandsInfo.get(RandomUtil.nextInt(basicLandsInfo.size())).getMockCard().copy();
} }
} }

View file

@ -1,66 +1,59 @@
package mage.client.deck.generator; package mage.client.deck.generator;
import java.util.ArrayList; import com.google.common.collect.ImmutableList;
import java.util.List;
public enum DeckGeneratorCMC { public enum DeckGeneratorCMC {
Low( Low(ImmutableList.<CMC>builder()
new ArrayList<CMC>() {{ .add(new CMC(0, 2, 0.60f))
add(new CMC(0, 2, 0.60f)); .add(new CMC(3, 4, 0.30f))
add(new CMC(3, 4, 0.30f)); .add(new CMC(5, 6, 0.10f)).build(),
add(new CMC(5, 6, 0.10f)); ImmutableList.<CMC>builder()
}}, .add(new CMC(0, 2, 0.65f))
new ArrayList<CMC>() {{ .add(new CMC(3, 4, 0.30f))
add(new CMC(0, 2, 0.65f)); .add(new CMC(5, 5, 0.05f)).build()),
add(new CMC(3, 4, 0.30f)); Default(ImmutableList.<CMC>builder()
add(new CMC(5, 5, 0.05f)); .add(new CMC(0, 2, 0.20f))
}}), .add(new CMC(3, 5, 0.50f))
Default( .add(new CMC(6, 7, 0.25f))
new ArrayList<CMC>() {{ .add(new CMC(8, 100, 0.05f)).build(),
add(new CMC(0, 2, 0.20f)); ImmutableList.<CMC>builder()
add(new CMC(3, 5, 0.50f)); .add(new CMC(0, 2, 0.30f))
add(new CMC(6, 7, 0.25f)); .add(new CMC(3, 4, 0.45f))
add(new CMC(8, 100, 0.05f)); .add(new CMC(5, 6, 0.20f))
}}, .add(new CMC(7, 100, 0.05f)).build()),
new ArrayList<CMC>() {{
add(new CMC(0, 2, 0.30f));
add(new CMC(3, 4, 0.45f));
add(new CMC(5, 6, 0.20f));
add(new CMC(7, 100, 0.05f));
}}),
High(
new ArrayList<CMC>() {{
add(new CMC(0, 2, 0.05f));
add(new CMC(3, 5, 0.35f));
add(new CMC(6, 7, 0.40f));
add(new CMC(8, 100, 0.15f));
}},
new ArrayList<CMC>() {{
add(new CMC(0, 2, 0.10f));
add(new CMC(3, 4, 0.30f));
add(new CMC(5, 6, 0.45f));
add(new CMC(7, 100, 0.15f));
}});
private final ArrayList<CMC> poolCMCs60; High(ImmutableList.<CMC>builder().
private final ArrayList<CMC> poolCMCs40; add(new CMC(0, 2, 0.05f))
.add(new CMC(3, 5, 0.35f))
.add(new CMC(6, 7, 0.40f))
.add(new CMC(8, 100, 0.15f)).build(),
ImmutableList.<CMC>builder().
add(new CMC(0, 2, 0.10f))
.add(new CMC(3, 4, 0.30f))
.add(new CMC(5, 6, 0.45f))
.add(new CMC(7, 100, 0.15f)).build());
DeckGeneratorCMC(ArrayList<CMC> CMCs60, ArrayList<CMC> CMCs40) { private final List<CMC> poolCMCs60;
private final List<CMC> poolCMCs40;
DeckGeneratorCMC(List<CMC> CMCs60, List<CMC> CMCs40) {
this.poolCMCs60 = CMCs60; this.poolCMCs60 = CMCs60;
this.poolCMCs40 = CMCs40; this.poolCMCs40 = CMCs40;
} }
public ArrayList<CMC> get40CardPoolCMC() { public List<CMC> get40CardPoolCMC() {
return this.poolCMCs40; return this.poolCMCs40;
} }
public ArrayList<CMC> get60CardPoolCMC() { public List<CMC> get60CardPoolCMC() {
return this.poolCMCs60; return this.poolCMCs60;
} }
static class CMC static class CMC {
{
public final int min; public final int min;
public final int max; public final int max;
public final float percentage; public final float percentage;
@ -68,12 +61,12 @@ public enum DeckGeneratorCMC {
/** /**
* Constructs a CMC range given a minimum and maximum, and the percentage of cards that are in this range. * Constructs a CMC range given a minimum and maximum, and the percentage of cards that are in this range.
* @param min the minimum CMC a card in this range can be. *
* @param max the maximum CMC a card in this range can be. * @param min the minimum CMC a card in this range can be.
* @param max the maximum CMC a card in this range can be.
* @param percentage the percentage of cards in the range (min, max) * @param percentage the percentage of cards in the range (min, max)
*/ */
CMC(int min, int max, float percentage) CMC(int min, int max, float percentage) {
{
this.min = min; this.min = min;
this.max = max; this.max = max;
this.percentage = percentage; this.percentage = percentage;
@ -81,19 +74,19 @@ public enum DeckGeneratorCMC {
/** /**
* Sets the amount of cards needed in this CMC range. * Sets the amount of cards needed in this CMC range.
*
* @param amount the number of cards needed. * @param amount the number of cards needed.
*/ */
public void setAmount(int amount) public void setAmount(int amount) {
{
this.amount = amount; this.amount = amount;
} }
/** /**
* Gets the number of cards needed in this CMC range. * Gets the number of cards needed in this CMC range.
*
* @return the number of cards needed in this CMC range. * @return the number of cards needed in this CMC range.
*/ */
public int getAmount() public int getAmount() {
{
return this.amount; return this.amount;
} }
} }

View file

@ -1,17 +1,5 @@
package mage.client.deck.generator; package mage.client.deck.generator;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import mage.cards.Sets;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
@ -19,8 +7,20 @@ import mage.client.util.gui.ColorsChooser;
import mage.client.util.gui.FastSearchUtil; import mage.client.util.gui.FastSearchUtil;
import mage.client.util.sets.ConstructedFormats; import mage.client.util.sets.ConstructedFormats;
import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import static mage.cards.decks.DeckFormats.XMAGE;
/** /**
*
* @author Simown * @author Simown
*/ */
public class DeckGeneratorDialog { public class DeckGeneratorDialog {
@ -328,7 +328,7 @@ public class DeckGeneratorDialog {
tmp.getParentFile().mkdirs(); tmp.getParentFile().mkdirs();
tmp.createNewFile(); tmp.createNewFile();
deck.setName(deckName); deck.setName(deckName);
Sets.saveDeck(tmp.getAbsolutePath(), deck.getDeckCardLists()); XMAGE.getExporter().writeDeck(tmp.getAbsolutePath(), deck.getDeckCardLists());
cleanUp(); cleanUp();
return tmp.getAbsolutePath(); return tmp.getAbsolutePath();
} catch (Exception e) { } catch (Exception e) {

View file

@ -136,7 +136,7 @@ public class DeckGeneratorPool
int cardCount = getCardCount((card.getName())); int cardCount = getCardCount((card.getName()));
// No need to check if the land is valid for the colors chosen // No need to check if the land is valid for the colors chosen
// They are all filtered before searching for lands to include in the deck. // They are all filtered before searching for lands to include in the deck.
return (cardCount < 4); return (cardCount < (isSingleton ? 1 : 4));
} }

View file

@ -143,7 +143,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
private static JLabel createChangingPercentageLabel(final JSlider slider) { private static JLabel createChangingPercentageLabel(final JSlider slider) {
final JLabel label = new JLabel(" " + String.valueOf(slider.getValue()) + '%'); final JLabel label = new JLabel(" " + slider.getValue() + '%');
slider.addChangeListener(e -> { slider.addChangeListener(e -> {
String value = String.valueOf(slider.getValue()); String value = String.valueOf(slider.getValue());

View file

@ -1,35 +1,21 @@
/*
/*
* CardSelector.java * CardSelector.java
* *
* Created on Feb 18, 2010, 2:49:03 PM * Created on Feb 18, 2010, 2:49:03 PM
*/ */
package mage.client.deckeditor; package mage.client.deckeditor;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Map.Entry;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import mage.MageObject; import mage.MageObject;
import mage.ObjectColor; import mage.ObjectColor;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.cards.Sets; import mage.cards.Sets;
import mage.cards.repository.CardCriteria; import mage.cards.repository.*;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.*; import mage.client.cards.*;
import mage.client.constants.Constants.SortBy; import mage.client.constants.Constants.SortBy;
import mage.client.deckeditor.table.TableModel; import mage.client.deckeditor.table.TableModel;
import mage.client.dialog.CheckBoxList; import mage.client.dialog.CheckBoxList;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_NAMES;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_RULES;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_TYPES;
import static mage.client.dialog.PreferencesDialog.KEY_DECK_EDITOR_SEARCH_UNIQUE;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.client.util.gui.FastSearchUtil; import mage.client.util.gui.FastSearchUtil;
import mage.client.util.sets.ConstructedFormats; import mage.client.util.sets.ConstructedFormats;
@ -43,12 +29,21 @@ import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.mageobject.ColorlessPredicate; import mage.filter.predicate.mageobject.ColorlessPredicate;
import mage.filter.predicate.other.CardTextPredicate; import mage.filter.predicate.other.CardTextPredicate;
import mage.filter.predicate.other.ExpansionSetPredicate; import mage.filter.predicate.other.ExpansionSetPredicate;
import mage.game.events.Listener;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CardsView; import mage.view.CardsView;
import org.mage.card.arcane.ManaSymbolsCellRenderer; import org.mage.card.arcane.ManaSymbolsCellRenderer;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Map.Entry;
import static mage.client.dialog.PreferencesDialog.*;
/** /**
*
* @author BetaSteward_at_googlemail.com, nantuko * @author BetaSteward_at_googlemail.com, nantuko
*/ */
public class CardSelector extends javax.swing.JPanel implements ComponentListener, DragCardTarget { public class CardSelector extends javax.swing.JPanel implements ComponentListener, DragCardTarget {
@ -58,6 +53,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private boolean limited = false; private boolean limited = false;
private final SortSetting sortSetting; private final SortSetting sortSetting;
private static final Map<String, Integer> pdAllowed = new HashMap<>(); private static final Map<String, Integer> pdAllowed = new HashMap<>();
private static Listener<RepositoryEvent> setsDbListener = null;
private final String TEST_MULTI_SET = "Multiple Sets selected"; private final String TEST_MULTI_SET = "Multiple Sets selected";
@ -76,15 +72,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
currentView = mainModel; // by default we use List View currentView = mainModel; // by default we use List View
listCodeSelected = new CheckBoxList(); listCodeSelected = new CheckBoxList();
// remove the all option
boolean is_removeFinish = false;
String[] setCodes = ConstructedFormats.getTypes(); String[] setCodes = ConstructedFormats.getTypes();
java.util.List<String> result = new ArrayList<>(); java.util.List<String> result = new ArrayList<>();
for (int i = 0; (i < setCodes.length) && (!is_removeFinish); i++) { for (String item : setCodes) {
String item = setCodes[i]; if (!item.equals(ConstructedFormats.ALL_SETS)) {
if (!item.equals(ConstructedFormats.ALL)) {
result.add(item); result.add(item);
} }
} }
@ -165,7 +158,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
/** /**
* Free all references * Free all references
*
*/ */
public void cleanUp() { public void cleanUp() {
this.cardGrid.clear(); this.cardGrid.clear();
@ -255,7 +247,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
predicates.add(new ColorPredicate(ObjectColor.WHITE)); predicates.add(new ColorPredicate(ObjectColor.WHITE));
} }
if (this.tbColorless.isSelected()) { if (this.tbColorless.isSelected()) {
predicates.add(new ColorlessPredicate()); predicates.add(ColorlessPredicate.instance);
} }
filter.add(Predicates.or(predicates)); filter.add(Predicates.or(predicates));
@ -365,9 +357,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
for (int itemIndex : choiseValue) { for (int itemIndex : choiseValue) {
java.util.List<String> listReceived = ConstructedFormats.getSetsByFormat(x.getElementAt(itemIndex).toString()); java.util.List<String> listReceived = ConstructedFormats.getSetsByFormat(x.getElementAt(itemIndex).toString());
listReceived.stream().filter((item) -> (setCodes.contains(item) == false)).forEachOrdered((item) -> { listReceived.stream().filter(item -> !setCodes.contains(item)).forEachOrdered(setCodes::add);
setCodes.add(item);
});
} }
criteria.setCodes(setCodes.toArray(new String[0])); criteria.setCodes(setCodes.toArray(new String[0]));
} }
@ -505,6 +495,11 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
} }
private void reloadSetsCombobox() {
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes());
cbExpansionSet.setModel(model);
}
/** /**
* This method is called from within the constructor to initialize the form. * 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 * WARNING: Do NOT modify this code. The content of this method is always
@ -575,8 +570,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbRed.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_red_off.png"))); // NOI18N tbRed.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_red_off.png"))); // NOI18N
tbRed.setSelected(true); tbRed.setSelected(true);
tbRed.setToolTipText("<html><font color='red'><strong>Red</strong></font><br/>" tbRed.setToolTipText("<html><font color='red'><strong>Red</strong></font><br/>"
+ tbColor.getToolTipText()); + tbColor.getToolTipText());
tbRed.setActionCommand("Red"); tbRed.setActionCommand("Red");
tbRed.setFocusable(false); tbRed.setFocusable(false);
tbRed.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbRed.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -666,7 +661,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbColor.add(tbColorless); tbColor.add(tbColorless);
tbColor.add(jSeparator1); tbColor.add(jSeparator1);
cbExpansionSet.setModel(new DefaultComboBoxModel<>(ConstructedFormats.getTypes())); reloadSetsCombobox();
cbExpansionSet.setMaximumSize(new java.awt.Dimension(250, 25)); cbExpansionSet.setMaximumSize(new java.awt.Dimension(250, 25));
cbExpansionSet.setMinimumSize(new java.awt.Dimension(250, 25)); cbExpansionSet.setMinimumSize(new java.awt.Dimension(250, 25));
cbExpansionSet.setName("cbExpansionSet"); // NOI18N cbExpansionSet.setName("cbExpansionSet"); // NOI18N
@ -676,6 +671,17 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
cbExpansionSetActionPerformed(evt); cbExpansionSetActionPerformed(evt);
} }
}); });
// auto-update sets list on changes
setsDbListener = new Listener<RepositoryEvent>() {
@Override
public void event(RepositoryEvent event) {
if (event.getEventType().equals(RepositoryEvent.RepositoryEventType.DB_UPDATED)) {
reloadSetsCombobox();
// TODO: auto-refresh cards list
}
}
};
ExpansionRepository.instance.subscribe(setsDbListener);
tbColor.add(cbExpansionSet); tbColor.add(cbExpansionSet);
btnExpansionSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_32.png"))); // NOI18N btnExpansionSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_32.png"))); // NOI18N
@ -735,8 +741,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbLand.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_land.png"))); // NOI18N tbLand.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_land.png"))); // NOI18N
tbLand.setSelected(true); tbLand.setSelected(true);
tbLand.setToolTipText("<html><strong>Land</strong><br/>" tbLand.setToolTipText("<html><strong>Land</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbLand.setActionCommand("Lands"); tbLand.setActionCommand("Lands");
tbLand.setFocusable(false); tbLand.setFocusable(false);
tbLand.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbLand.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -750,8 +756,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbCreatures.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_creatures.png"))); // NOI18N tbCreatures.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_creatures.png"))); // NOI18N
tbCreatures.setSelected(true); tbCreatures.setSelected(true);
tbCreatures.setToolTipText("<html><strong>Creatures</strong><br/>" tbCreatures.setToolTipText("<html><strong>Creatures</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbCreatures.setActionCommand("Creatures"); tbCreatures.setActionCommand("Creatures");
tbCreatures.setFocusable(false); tbCreatures.setFocusable(false);
tbCreatures.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbCreatures.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -765,8 +771,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbArifiacts.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_artifact.png"))); // NOI18N tbArifiacts.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_artifact.png"))); // NOI18N
tbArifiacts.setSelected(true); tbArifiacts.setSelected(true);
tbArifiacts.setToolTipText("<html><strong>Artifacts</strong><br/>" tbArifiacts.setToolTipText("<html><strong>Artifacts</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbArifiacts.setActionCommand("Artifacts"); tbArifiacts.setActionCommand("Artifacts");
tbArifiacts.setFocusable(false); tbArifiacts.setFocusable(false);
tbArifiacts.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbArifiacts.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -780,8 +786,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbSorceries.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_sorcery.png"))); // NOI18N tbSorceries.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_sorcery.png"))); // NOI18N
tbSorceries.setSelected(true); tbSorceries.setSelected(true);
tbSorceries.setToolTipText("<html><strong>Sorceries</strong><br/>" tbSorceries.setToolTipText("<html><strong>Sorceries</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbSorceries.setActionCommand("Soceries"); tbSorceries.setActionCommand("Soceries");
tbSorceries.setFocusable(false); tbSorceries.setFocusable(false);
tbSorceries.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbSorceries.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -795,8 +801,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbInstants.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_instant.png"))); // NOI18N tbInstants.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_instant.png"))); // NOI18N
tbInstants.setSelected(true); tbInstants.setSelected(true);
tbInstants.setToolTipText("<html><strong>Instants</strong><br/>" tbInstants.setToolTipText("<html><strong>Instants</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbInstants.setActionCommand("Instants"); tbInstants.setActionCommand("Instants");
tbInstants.setFocusable(false); tbInstants.setFocusable(false);
tbInstants.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbInstants.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -810,8 +816,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbEnchantments.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_enchantment.png"))); // NOI18N tbEnchantments.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_enchantment.png"))); // NOI18N
tbEnchantments.setSelected(true); tbEnchantments.setSelected(true);
tbEnchantments.setToolTipText("<html><strong>Enchantments</strong><br/>" tbEnchantments.setToolTipText("<html><strong>Enchantments</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbEnchantments.setActionCommand("Enchantments"); tbEnchantments.setActionCommand("Enchantments");
tbEnchantments.setFocusable(false); tbEnchantments.setFocusable(false);
tbEnchantments.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbEnchantments.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -825,8 +831,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbPlaneswalkers.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_planeswalker.png"))); // NOI18N tbPlaneswalkers.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_planeswalker.png"))); // NOI18N
tbPlaneswalkers.setSelected(true); tbPlaneswalkers.setSelected(true);
tbPlaneswalkers.setToolTipText("<html><strong>Planeswalker</strong><br/>" tbPlaneswalkers.setToolTipText("<html><strong>Planeswalker</strong><br/>"
+ tbTypes.getToolTipText()); + tbTypes.getToolTipText());
tbPlaneswalkers.setActionCommand("Planeswalkers"); tbPlaneswalkers.setActionCommand("Planeswalkers");
tbPlaneswalkers.setFocusable(false); tbPlaneswalkers.setFocusable(false);
tbPlaneswalkers.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbPlaneswalkers.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -907,8 +913,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbCommon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_common_20.png"))); // NOI18N tbCommon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_common_20.png"))); // NOI18N
tbCommon.setSelected(true); tbCommon.setSelected(true);
tbCommon.setToolTipText("<html><strong>Common</strong><br/>" tbCommon.setToolTipText("<html><strong>Common</strong><br/>"
+ tbRarities.getToolTipText()); + tbRarities.getToolTipText());
tbCommon.setActionCommand("Common"); tbCommon.setActionCommand("Common");
tbCommon.setFocusable(false); tbCommon.setFocusable(false);
tbCommon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbCommon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -922,8 +928,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbUncommon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_uncommon_20.png"))); // NOI18N tbUncommon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_uncommon_20.png"))); // NOI18N
tbUncommon.setSelected(true); tbUncommon.setSelected(true);
tbUncommon.setToolTipText("<html><strong>Uncommon</strong><br/>" tbUncommon.setToolTipText("<html><strong>Uncommon</strong><br/>"
+ tbRarities.getToolTipText()); + tbRarities.getToolTipText());
tbUncommon.setActionCommand("Uncommon"); tbUncommon.setActionCommand("Uncommon");
tbUncommon.setFocusable(false); tbUncommon.setFocusable(false);
tbUncommon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbUncommon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -937,8 +943,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbRare.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_rare_20.png"))); // NOI18N tbRare.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_rare_20.png"))); // NOI18N
tbRare.setSelected(true); tbRare.setSelected(true);
tbRare.setToolTipText("<html><strong>Rare</strong><br/>" tbRare.setToolTipText("<html><strong>Rare</strong><br/>"
+ tbRarities.getToolTipText()); + tbRarities.getToolTipText());
tbRare.setActionCommand("Rare"); tbRare.setActionCommand("Rare");
tbRare.setFocusable(false); tbRare.setFocusable(false);
tbRare.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbRare.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -952,8 +958,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbMythic.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_mythic_20.png"))); // NOI18N tbMythic.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_mythic_20.png"))); // NOI18N
tbMythic.setSelected(true); tbMythic.setSelected(true);
tbMythic.setToolTipText("<html><strong>Mythic</strong><br/>" tbMythic.setToolTipText("<html><strong>Mythic</strong><br/>"
+ tbRarities.getToolTipText()); + tbRarities.getToolTipText());
tbMythic.setActionCommand("Mythic"); tbMythic.setActionCommand("Mythic");
tbMythic.setFocusable(false); tbMythic.setFocusable(false);
tbMythic.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbMythic.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -967,8 +973,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbSpecial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_special_20.png"))); // NOI18N tbSpecial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_special_20.png"))); // NOI18N
tbSpecial.setSelected(true); tbSpecial.setSelected(true);
tbSpecial.setToolTipText("<html><strong>Special</strong><br/>" tbSpecial.setToolTipText("<html><strong>Special</strong><br/>"
+ tbRarities.getToolTipText()); + tbRarities.getToolTipText());
tbSpecial.setActionCommand("Special"); tbSpecial.setActionCommand("Special");
tbSpecial.setFocusable(false); tbSpecial.setFocusable(false);
tbSpecial.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); tbSpecial.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -1121,59 +1127,59 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
javax.swing.GroupLayout cardSelectorBottomPanelLayout = new javax.swing.GroupLayout(cardSelectorBottomPanel); javax.swing.GroupLayout cardSelectorBottomPanelLayout = new javax.swing.GroupLayout(cardSelectorBottomPanel);
cardSelectorBottomPanel.setLayout(cardSelectorBottomPanelLayout); cardSelectorBottomPanel.setLayout(cardSelectorBottomPanelLayout);
cardSelectorBottomPanelLayout.setHorizontalGroup( cardSelectorBottomPanelLayout.setHorizontalGroup(
cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cardSelectorBottomPanelLayout.createSequentialGroup() .addGroup(cardSelectorBottomPanelLayout.createSequentialGroup()
.addGap(6, 6, 6) .addGap(6, 6, 6)
.addComponent(jButtonAddToMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonAddToMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2) .addGap(2, 2, 2)
.addComponent(jButtonRemoveFromMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonRemoveFromMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(1, 1, 1) .addGap(1, 1, 1)
.addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2) .addGap(2, 2, 2)
.addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonSearch) .addComponent(jButtonSearch)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonClean) .addComponent(jButtonClean)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkNames, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chkNames, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chkTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkRules, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chkRules, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(5, 5, 5) .addGap(5, 5, 5)
.addComponent(chkUnique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chkUnique, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(5, 5, 5) .addGap(5, 5, 5)
.addComponent(cardCountLabel) .addComponent(cardCountLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cardCount, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cardCount, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
cardSelectorBottomPanelLayout.setVerticalGroup( cardSelectorBottomPanelLayout.setVerticalGroup(
cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cardSelectorBottomPanelLayout.createSequentialGroup() .addGroup(cardSelectorBottomPanelLayout.createSequentialGroup()
.addGap(4, 4, 4) .addGap(4, 4, 4)
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(chkTypes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chkTypes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chkRules, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chkRules, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chkUnique, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chkUnique, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chkNames, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chkNames, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(cardSelectorBottomPanelLayout.createSequentialGroup() .addGroup(cardSelectorBottomPanelLayout.createSequentialGroup()
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButtonRemoveFromMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonRemoveFromMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonSearch) .addComponent(jButtonSearch)
.addComponent(jButtonClean) .addComponent(jButtonClean)
.addComponent(cardCount) .addComponent(cardCount)
.addComponent(jButtonAddToMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonAddToMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cardCountLabel))) .addComponent(cardCountLabel)))
.addGap(0, 0, Short.MAX_VALUE))) .addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
cardCountLabel.getAccessibleContext().setAccessibleName("cardCountLabel"); cardCountLabel.getAccessibleContext().setAccessibleName("cardCountLabel");
@ -1182,22 +1188,22 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE) .addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE)
.addComponent(cardSelectorScrollPane) .addComponent(cardSelectorScrollPane)
.addComponent(cardSelectorBottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE) .addComponent(cardSelectorBottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(tbColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tbColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(tbTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tbTypes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(cardSelectorScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE) .addComponent(cardSelectorScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(cardSelectorBottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(cardSelectorBottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents

View file

@ -55,7 +55,7 @@ public class DeckArea extends javax.swing.JPanel {
public int dividerLocationLimited; public int dividerLocationLimited;
public int dividerLocationNormal; public int dividerLocationNormal;
private final static Pattern parser = Pattern.compile("([^|]*)\\|([^|]*)\\|([^|]*)\\|([^|]*)"); private static final Pattern parser = Pattern.compile("([^|]*)\\|([^|]*)\\|([^|]*)\\|([^|]*)");
public static Settings parse(String s) { public static Settings parse(String s) {
Matcher m = parser.matcher(s); Matcher m = parser.matcher(s);

View file

@ -1,8 +1,8 @@
<?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.JInternalFrameFormInfo"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<SyntheticProperties> <SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="formSizePolicy" type="int" value="2"/>
</SyntheticProperties> </SyntheticProperties>
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
@ -14,22 +14,35 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-97,0,0,5,14"/>
</AuxValues> </AuxValues>
<Layout> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="deckEditorPanel1" alignment="0" pref="885" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="deckEditorPanel1" alignment="0" pref="626" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents> <SubComponents>
<Component class="mage.client.deckeditor.DeckEditorPanel" name="deckEditorPanel1"> <Component class="mage.client.deckeditor.DeckEditorPanel" name="deckEditorPanel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 32767]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 10]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalGlue"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
</Component> </Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,24 +1,17 @@
/*
* DeckEditorPane.java
*
* Created on Dec 17, 2009, 9:21:42 AM
*/
package mage.client.deckeditor; package mage.client.deckeditor;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.client.MagePane; import mage.client.MagePane;
import mage.client.constants.Constants.DeckEditorMode; import mage.client.constants.Constants.DeckEditorMode;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class DeckEditorPane extends MagePane { public class DeckEditorPane extends MagePane {
@ -79,17 +72,10 @@ public class DeckEditorPane extends MagePane {
private void initComponents() { private void initComponents() {
deckEditorPanel1 = new mage.client.deckeditor.DeckEditorPanel(); deckEditorPanel1 = new mage.client.deckeditor.DeckEditorPanel();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 32767));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); getContentPane().add(deckEditorPanel1, java.awt.BorderLayout.CENTER);
this.setLayout(layout); getContentPane().add(filler1, java.awt.BorderLayout.NORTH);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deckEditorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deckEditorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void initComponents(Component container) { private void initComponents(Component container) {
@ -98,14 +84,13 @@ public class DeckEditorPane extends MagePane {
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE) .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE) .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
); );
} }
public DeckEditorPanel getPanel() { public DeckEditorPanel getPanel() {
@ -114,6 +99,7 @@ public class DeckEditorPane extends MagePane {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.deckeditor.DeckEditorPanel deckEditorPanel1; private mage.client.deckeditor.DeckEditorPanel deckEditorPanel1;
private javax.swing.Box.Filler filler1;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -17,21 +17,21 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jPanel1" min="-2" pref="261" max="-2" attributes="0"/> <Component id="panelLeft" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="jSplitPane1" pref="604" max="32767" attributes="0"/> <Component id="panelRight" pref="890" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> <Component id="panelLeft" alignment="0" max="32767" attributes="0"/>
<Component id="jSplitPane1" alignment="1" pref="615" max="32767" attributes="0"/> <Component id="panelRight" alignment="1" pref="808" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1"> <Container class="javax.swing.JSplitPane" name="panelRight">
<Properties> <Properties>
<Property name="orientation" type="int" value="0"/> <Property name="orientation" type="int" value="0"/>
<Property name="resizeWeight" type="double" value="0.5"/> <Property name="resizeWeight" type="double" value="0.5"/>
@ -49,171 +49,427 @@
<Component class="mage.client.deckeditor.DeckArea" name="deckArea"> <Component class="mage.client.deckeditor.DeckArea" name="deckArea">
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/> <JSplitPaneConstraints position="bottom"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="jPanel1"> <Container class="javax.swing.JPanel" name="panelLeft">
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Component id="panelDeck" alignment="1" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/> <Component id="bigCard" alignment="0" max="32767" attributes="0"/>
<Component id="lblDeckName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtDeckName" pref="189" max="32767" attributes="0"/>
</Group>
<Component id="bigCard" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSave" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnLoad" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnNew" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnExit" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnImport" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnGenDeck" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnAddLand" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSubmit" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Component id="panelDeck" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <EmptySpace max="32767" attributes="0"/>
<Component id="txtDeckName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblDeckName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnSave" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnLoad" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnNew" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnExit" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnImport" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnGenDeck" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnAddLand" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnSubmit" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="159" max="32767" attributes="0"/>
<Component id="bigCard" min="-2" max="-2" attributes="0"/> <Component id="bigCard" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="org.mage.plugins.card.info.CardInfoPaneImpl" name="cardInfoPane">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="Plugins.instance.getCardInfoPane()"/>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="if (cardInfoPane != null &amp;&amp; System.getProperty(&quot;testCardInfo&quot;) != null) {&#xa; cardInfoPane.setPreferredSize(new Dimension(170, 150));&#xa; cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(200, 0, 0)));&#xa; isShowCardInfo = true;&#xa; } else {&#xa; cardInfoPane = new JLabel();&#xa; cardInfoPane.setVisible(false);&#xa; }"/>
<AuxValue name="JavaCodeGenerator_DeclarationPost" type="java.lang.String" value="*/"/>
<AuxValue name="JavaCodeGenerator_DeclarationPre" type="java.lang.String" value="private JComponent cardInfoPane;&#xa;/*"/>
</AuxValues>
</Component>
<Component class="mage.client.cards.BigCard" name="bigCard"> <Component class="mage.client.cards.BigCard" name="bigCard">
</Component>
<Container class="javax.swing.JPanel" name="panelDeck">
<Properties> <Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="opaque" type="boolean" value="false"/>
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder/>
</Border>
</Property>
</Properties> </Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtDeckName"> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
</Component> <Property name="axis" type="int" value="1"/>
<Component class="javax.swing.JLabel" name="lblDeckName"> </Layout>
<Properties> <SubComponents>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Container class="javax.swing.JPanel" name="panelDeckName">
<ComponentRef name="txtDeckName"/> <Properties>
</Property> <Property name="opaque" type="boolean" value="false"/>
<Property name="text" type="java.lang.String" value="Deck Name:"/> </Properties>
</Properties>
</Component> <Layout>
<Component class="javax.swing.JButton" name="btnSave"> <DimensionLayout dim="0">
<Properties> <Group type="103" groupAlignment="0" attributes="0">
<Property name="text" type="java.lang.String" value="Save"/> <Group type="102" attributes="0">
</Properties> <EmptySpace min="-2" max="-2" attributes="0"/>
<Events> <Component id="lblDeckName" min="-2" max="-2" attributes="0"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/> <EmptySpace max="-2" attributes="0"/>
</Events> <Component id="txtDeckName" pref="175" max="32767" attributes="0"/>
</Component> <EmptySpace max="-2" attributes="0"/>
<Component class="javax.swing.JButton" name="btnLoad"> </Group>
<Properties> </Group>
<Property name="text" type="java.lang.String" value="Load"/> </DimensionLayout>
</Properties> <DimensionLayout dim="1">
<Events> <Group type="103" groupAlignment="0" attributes="0">
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLoadActionPerformed"/> <Group type="102" attributes="0">
</Events> <Group type="103" groupAlignment="3" attributes="0">
</Component> <Component id="txtDeckName" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component class="javax.swing.JButton" name="btnNew"> <Component id="lblDeckName" alignment="3" min="-2" max="-2" attributes="0"/>
<Properties> </Group>
<Property name="text" type="java.lang.String" value="New"/> <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Properties> </Group>
<Events> </Group>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNewActionPerformed"/> </DimensionLayout>
</Events> </Layout>
</Component> <SubComponents>
<Component class="javax.swing.JButton" name="btnExit"> <Component class="javax.swing.JLabel" name="lblDeckName">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Exit"/> <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
</Properties> <Color blue="ff" green="ff" red="ff" type="rgb"/>
<Events> </Property>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnExitActionPerformed"/> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
</Events> <ComponentRef name="txtDeckName"/>
</Component> </Property>
<Component class="javax.swing.JButton" name="btnImport"> <Property name="text" type="java.lang.String" value="Deck Name:"/>
<Properties> </Properties>
<Property name="text" type="java.lang.String" value="Import"/> </Component>
<Property name="name" type="java.lang.String" value="btnImport" noResource="true"/> <Component class="javax.swing.JTextField" name="txtDeckName">
</Properties> </Component>
<Events> </SubComponents>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImportActionPerformed"/> </Container>
</Events> <Container class="javax.swing.JPanel" name="panelDeckCreate">
</Component> <Properties>
<Component class="javax.swing.JButton" name="btnAddLand"> <Property name="opaque" type="boolean" value="false"/>
<Properties> </Properties>
<Property name="text" type="java.lang.String" value="Add Land"/>
<Property name="name" type="java.lang.String" value="btnAddLand" noResource="true"/> <Layout>
</Properties> <DimensionLayout dim="0">
<Events> <Group type="103" groupAlignment="0" attributes="0">
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/> <Group type="102" attributes="0">
</Events> <EmptySpace max="-2" attributes="0"/>
</Component> <Component id="btnNew" min="-2" pref="100" max="-2" attributes="0"/>
<Component class="javax.swing.JButton" name="btnSubmit"> <EmptySpace max="-2" attributes="0"/>
<Properties> <Component id="btnGenDeck" min="-2" pref="100" max="-2" attributes="0"/>
<Property name="text" type="java.lang.String" value="Submit"/> <EmptySpace pref="40" max="32767" attributes="0"/>
<Property name="name" type="java.lang.String" value="btnSubmit" noResource="true"/> </Group>
</Properties> </Group>
<Events> </DimensionLayout>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitActionPerformed"/> <DimensionLayout dim="1">
</Events> <Group type="103" groupAlignment="0" attributes="0">
</Component> <Group type="102" alignment="0" attributes="0">
<Component class="javax.swing.JButton" name="btnSubmitTimer"> <EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<Properties> <Group type="103" groupAlignment="0" attributes="0">
<Property name="text" type="java.lang.String" value="Submit in 1 minute"/> <Component id="btnGenDeck" pref="30" max="32767" attributes="0"/>
<Property name="name" type="java.lang.String" value="btnSubmitTimer" noResource="true"/> <Component id="btnNew" alignment="0" pref="30" max="32767" attributes="0"/>
</Properties> </Group>
<Events> </Group>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitTimerActionPerformed"/> </Group>
</Events> </DimensionLayout>
</Component> </Layout>
<Component class="JComponent" name="cardInfoPane"> <SubComponents>
</Component> <Component class="javax.swing.JButton" name="btnNew">
<Component class="javax.swing.JTextField" name="txtTimeRemaining"> <Properties>
</Component> <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/state_active.png"/>
</Property>
<Property name="text" type="java.lang.String" value="NEW"/>
<Property name="iconTextGap" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNewActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnGenDeck">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/card_panel.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Random"/>
<Property name="iconTextGap" type="int" value="1"/>
<Property name="name" type="java.lang.String" value="btnGenDeck" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGenDeckActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelDeckLoad">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnLoad" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnImport" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="btnLoad" pref="0" max="32767" attributes="0"/>
<Component id="btnImport" pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnLoad">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/search_24.png"/>
</Property>
<Property name="text" type="java.lang.String" value="LOAD"/>
<Property name="iconTextGap" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLoadActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnImport">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/deck_in.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Import"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="btnImport" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImportActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelDeckSave">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSave" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnExport" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="btnSave" pref="30" max="32767" attributes="0"/>
<Component id="btnExport" pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnSave">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/sideboard_out.png"/>
</Property>
<Property name="text" type="java.lang.String" value="SAVE"/>
<Property name="iconTextGap" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnExport">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/deck_out.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Export"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="btnImport" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnExportActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelDeckDraft">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSubmit" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSubmitTimer" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" 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="0" attributes="0">
<Group type="102" attributes="0">
<Component id="btnSubmit" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="btnSubmitTimer" alignment="0" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnSubmit">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/state_finished.png"/>
</Property>
<Property name="text" type="java.lang.String" value="SUBMIT"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="btnSubmit" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnSubmitTimer">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="9" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/state_finished.png"/>
</Property>
<Property name="text" type="java.lang.String" value="&lt;html&gt;Submit&lt;br&gt;in 1 min"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="btnSubmitTimer" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSubmitTimerActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelDeckLands">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnAddLand" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="146" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnAddLand" pref="30" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnAddLand">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/type_land.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Lands"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="btnAddLand" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelDeckExit">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnExit" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtTimeRemaining" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="11" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnExit" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="txtTimeRemaining" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnExit">
<Properties>
<Property name="text" type="java.lang.String" value="Exit"/>
<Property name="iconTextGap" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnExitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtTimeRemainingActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents> </SubComponents>
</Container> </Container>
</SubComponents> </SubComponents>

View file

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Export to clipboard"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 400]"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelCommands" alignment="1" max="32767" attributes="0"/>
<Component id="panelData" alignment="0" pref="364" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="labelData" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboFormats" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="labelData" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboFormats" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Component id="panelData" pref="520" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelCommands" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="panelData">
<Properties>
<Property name="horizontalScrollBarPolicy" type="int" value="32"/>
<Property name="verticalScrollBarPolicy" type="int" value="22"/>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JEditorPane" name="editData">
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="labelData">
<Properties>
<Property name="text" type="java.lang.String" value="Choose deck format:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelCommands">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="buttonCopy" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonOK" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="buttonCancel" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="buttonOK" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<Component id="buttonCopy" alignment="1" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOK">
<Properties>
<Property name="text" type="java.lang.String" value="Copy"/>
<Property name="toolTipText" type="java.lang.String" value="Import deck from current text"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOKActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCopy">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/copy_24.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Copy current text to clipboard"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCopyActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JComboBox" name="comboFormats">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="comboFormatsItemStateChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Form>

View file

@ -0,0 +1,236 @@
package mage.client.deckeditor;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckFormats;
import mage.cards.decks.exporter.DeckExporter;
import mage.client.MageFrame;
import mage.client.dialog.MageDialog;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
/**
* @author JayDi85
*/
public class DeckExportClipboardDialog extends MageDialog {
private Deck deck;
private ArrayList<DeckFormats> formats = new ArrayList<>();
public DeckExportClipboardDialog() {
initComponents();
}
public void showDialog(Deck deck) {
this.deck = deck;
// formats combobox
formats.clear();
comboFormats.removeAllItems();
for (DeckFormats df : DeckFormats.values()) {
formats.add(df);
comboFormats.addItem(df.getExporter().getDescription());
}
if (comboFormats.getItemCount() > 0) {
comboFormats.setSelectedIndex(0);
}
onRefreshData();
this.setModal(true);
this.setResizable(true);
getRootPane().setDefaultButton(buttonOK);
// windows settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.makeWindowCentered();
// Close on "ESC"
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setVisible(true);
}
private void setClipboardStringData(String text) {
try {
StringSelection data = new StringSelection(text);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(data, data);
} catch (HeadlessException e) {
//e.printStackTrace();
}
}
private void onOK() {
onCopyToClipboard();
this.removeDialog();
}
private void onCancel() {
this.removeDialog();
}
private void onRefreshData() {
int formatIndex = comboFormats.getSelectedIndex();
if (formatIndex < 0 || formatIndex >= formats.size()) {
return;
}
DeckExporter exporter = formats.get(formatIndex).getExporter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exporter.writeDeck(baos, deck.getDeckCardLists());
editData.setText(baos.toString());
editData.setCaretPosition(0);
}
private void onCopyToClipboard() {
setClipboardStringData(editData.getText());
}
/**
* 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
private void initComponents() {
panelData = new javax.swing.JScrollPane();
editData = new javax.swing.JEditorPane();
labelData = new javax.swing.JLabel();
panelCommands = new javax.swing.JPanel();
buttonOK = new javax.swing.JButton();
buttonCancel = new javax.swing.JButton();
buttonCopy = new javax.swing.JButton();
comboFormats = new javax.swing.JComboBox<>();
setTitle("Export to clipboard");
setMinimumSize(new java.awt.Dimension(400, 400));
panelData.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
panelData.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
panelData.setViewportView(editData);
labelData.setText("Choose deck format:");
buttonOK.setText("Copy");
buttonOK.setToolTipText("Import deck from current text");
buttonOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOKActionPerformed(evt);
}
});
buttonCancel.setText("Close");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
buttonCopy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/copy_24.png"))); // NOI18N
buttonCopy.setToolTipText("Copy current text to clipboard");
buttonCopy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCopyActionPerformed(evt);
}
});
javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
panelCommands.setLayout(panelCommandsLayout);
panelCommandsLayout.setHorizontalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createSequentialGroup()
.addComponent(buttonCopy, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
);
panelCommandsLayout.setVerticalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(buttonCopy, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
comboFormats.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
comboFormats.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
comboFormatsItemStateChanged(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelCommands, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelData, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(labelData)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboFormats, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(8, 8, 8)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(labelData)
.addComponent(comboFormats, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(10, 10, 10)
.addComponent(panelData, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
onCancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOKActionPerformed
onOK();
}//GEN-LAST:event_buttonOKActionPerformed
private void buttonCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCopyActionPerformed
onCopyToClipboard();
}//GEN-LAST:event_buttonCopyActionPerformed
private void comboFormatsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboFormatsItemStateChanged
onRefreshData();
}//GEN-LAST:event_comboFormatsItemStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonCopy;
private javax.swing.JButton buttonOK;
private javax.swing.JComboBox<String> comboFormats;
private javax.swing.JEditorPane editData;
private javax.swing.JLabel labelData;
private javax.swing.JPanel panelCommands;
private javax.swing.JScrollPane panelData;
// End of variables declaration//GEN-END:variables
}

View file

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Import from clipboard"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 400]"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="panelCommands" max="32767" attributes="0"/>
<Component id="panelData" alignment="0" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="labelData" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelData" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelData" pref="440" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelCommands" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="panelData">
<Properties>
<Property name="horizontalScrollBarPolicy" type="int" value="32"/>
<Property name="verticalScrollBarPolicy" type="int" value="22"/>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JEditorPane" name="editData">
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="labelData">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="editData"/>
</Property>
<Property name="text" type="java.lang.String" value="Deck in text format to import:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelCommands">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="buttonPaste" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace pref="128" max="32767" attributes="0"/>
<Component id="buttonOK" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="buttonCancel" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="buttonOK" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<Component id="buttonPaste" alignment="1" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOK">
<Properties>
<Property name="text" type="java.lang.String" value="Import"/>
<Property name="toolTipText" type="java.lang.String" value="Import deck from current text"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOKActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonPaste">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/paste_24.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Paste text from clipboard"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPasteActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -0,0 +1,210 @@
package mage.client.deckeditor;
import mage.client.MageFrame;
import mage.client.dialog.MageDialog;
import mage.util.DeckUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.Optional;
/**
* @author JayDi85
*/
public class DeckImportClipboardDialog extends MageDialog {
private static final String FORMAT_TEXT =
"// Example:\n" +
"//1 Library of Congress\n" +
"//1 Cryptic Gateway\n" +
"//1 Azami, Lady of Scrolls\n" +
"// NB: This is slow as, and will lock your screen :)\n" +
"\n" +
"// Your current clipboard:\n" +
"\n";
private String tmpPath;
public DeckImportClipboardDialog() {
initComponents();
}
public void showDialog() {
this.tmpPath = "";
onRefreshClipboard();
this.setModal(true);
this.setResizable(true);
getRootPane().setDefaultButton(buttonOK);
// windows settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.makeWindowCentered();
// Close on "ESC"
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setVisible(true);
}
private Optional<String> getClipboardStringData() {
try {
return Optional.of((String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor));
} catch (HeadlessException | UnsupportedFlavorException | IOException e) {
//e.printStackTrace();
}
return Optional.empty();
}
private void onOK() {
tmpPath = DeckUtil.writeTextToTempFile(editData.getText());
this.removeDialog();
}
private void onCancel() {
this.removeDialog();
}
private void onRefreshClipboard() {
editData.setText(FORMAT_TEXT + getClipboardStringData().orElse(""));
editData.setCaretPosition(FORMAT_TEXT.length());
}
public String getTmpPath() {
return tmpPath;
}
/**
* 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
private void initComponents() {
panelData = new javax.swing.JScrollPane();
editData = new javax.swing.JEditorPane();
labelData = new javax.swing.JLabel();
panelCommands = new javax.swing.JPanel();
buttonOK = new javax.swing.JButton();
buttonCancel = new javax.swing.JButton();
buttonPaste = new javax.swing.JButton();
setTitle("Import from clipboard");
setMinimumSize(new java.awt.Dimension(400, 400));
panelData.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
panelData.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
panelData.setViewportView(editData);
labelData.setLabelFor(editData);
labelData.setText("Deck in text format to import:");
buttonOK.setText("Import");
buttonOK.setToolTipText("Import deck from current text");
buttonOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOKActionPerformed(evt);
}
});
buttonCancel.setText("Close");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
buttonPaste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/paste_24.png"))); // NOI18N
buttonPaste.setToolTipText("Paste text from clipboard");
buttonPaste.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPasteActionPerformed(evt);
}
});
javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
panelCommands.setLayout(panelCommandsLayout);
panelCommandsLayout.setHorizontalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createSequentialGroup()
.addComponent(buttonPaste, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 128, Short.MAX_VALUE)
.addComponent(buttonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
);
panelCommandsLayout.setVerticalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(buttonPaste, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(panelCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(panelData, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(labelData)
.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(labelData)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelData, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
onCancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOKActionPerformed
onOK();
}//GEN-LAST:event_buttonOKActionPerformed
private void buttonPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPasteActionPerformed
onRefreshClipboard();
}//GEN-LAST:event_buttonPasteActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonOK;
private javax.swing.JButton buttonPaste;
private javax.swing.JEditorPane editData;
private javax.swing.JLabel labelData;
private javax.swing.JPanel panelCommands;
private javax.swing.JScrollPane panelData;
// End of variables declaration//GEN-END:variables
}

View file

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="mage.client.deckeditor.DeckImportFromClipboardDialog">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="540" height="500"/>
</constraints>
<properties>
<minimumSize width="540" height="450"/>
</properties>
<border type="none"/>
<children>
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="98af6">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Import"/>
</properties>
</component>
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cancel"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="e3588" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:d:noGrow"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f8bac" class="javax.swing.JEditorPane" binding="txtDeckList">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
<forms defaultalign-horz="false" defaultalign-vert="false"/>
</constraints>
<properties>
<minimumSize width="250" height="400"/>
<preferredSize width="550" height="400"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View file

@ -1,157 +0,0 @@
package mage.client.deckeditor;
import mage.util.StreamUtils;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.*;
public class DeckImportFromClipboardDialog extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JEditorPane txtDeckList;
private String tmpPath;
public DeckImportFromClipboardDialog() {
initComponents();
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(e -> onOK());
buttonCancel.addActionListener(e -> onCancel());
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
onCancel();
}
});
// Close on "ESC"
contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
private void onOK() {
BufferedWriter bw = null;
try {
File temp = File.createTempFile("cbimportdeck", ".txt");
bw = new BufferedWriter(new FileWriter(temp));
bw.write(txtDeckList.getText());
tmpPath = temp.getPath();
} catch (IOException e) {
e.printStackTrace();
} finally {
StreamUtils.closeQuietly(bw);
}
dispose();
}
private void onCancel() {
dispose();
}
public String getTmpPath() {
return tmpPath;
}
private void initComponents() {
contentPane = new JPanel();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
buttonOK = new JButton();
buttonCancel = new JButton();
JPanel panel3 = new JPanel();
txtDeckList = new JEditorPane();
{
contentPane.setMinimumSize(new Dimension(540, 450));
contentPane.setBorder(new javax.swing.border.CompoundBorder(
new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
"Import from Clipboard", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12),
java.awt.Color.BLACK), contentPane.getBorder()));
contentPane.addPropertyChangeListener(e -> {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
}
});
contentPane.addPropertyChangeListener(e -> {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
}
});
contentPane.setLayout(new GridBagLayout());
((GridBagLayout) contentPane.getLayout()).columnWidths = new int[]{0, 0};
((GridBagLayout) contentPane.getLayout()).rowHeights = new int[]{0, 0, 0};
((GridBagLayout) contentPane.getLayout()).columnWeights = new double[]{0.01, 1.0E-4};
((GridBagLayout) contentPane.getLayout()).rowWeights = new double[]{0.01, 0.0, 1.0E-4};
{
panel1.setLayout(new GridBagLayout());
((GridBagLayout) panel1.getLayout()).columnWidths = new int[]{0, 0, 0};
((GridBagLayout) panel1.getLayout()).rowHeights = new int[]{0, 0};
((GridBagLayout) panel1.getLayout()).columnWeights = new double[]{0.0, 0.01, 1.0E-4};
((GridBagLayout) panel1.getLayout()).rowWeights = new double[]{0.01, 1.0E-4};
{
panel2.setLayout(new GridBagLayout());
((GridBagLayout) panel2.getLayout()).columnWidths = new int[]{0, 4, 0, 0};
((GridBagLayout) panel2.getLayout()).rowHeights = new int[]{0, 0};
((GridBagLayout) panel2.getLayout()).columnWeights = new double[]{0.01, 0.0, 0.01, 1.0E-4};
((GridBagLayout) panel2.getLayout()).rowWeights = new double[]{0.0, 1.0E-4};
//---- buttonOK ----
buttonOK.setText("Import");
panel2.add(buttonOK, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
//---- buttonCancel ----
buttonCancel.setText("Cancel");
panel2.add(buttonCancel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
}
panel1.add(panel2, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
}
contentPane.add(panel1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
{
panel3.setLayout(new GridBagLayout());
((GridBagLayout) panel3.getLayout()).columnWidths = new int[]{0, 0};
((GridBagLayout) panel3.getLayout()).rowHeights = new int[]{0, 0};
((GridBagLayout) panel3.getLayout()).columnWeights = new double[]{0.0, 1.0E-4};
((GridBagLayout) panel3.getLayout()).rowWeights = new double[]{1.0, 1.0E-4};
txtDeckList.setMinimumSize(new Dimension(250, 400));
txtDeckList.setPreferredSize(new Dimension(550, 400));
txtDeckList.setText("// Example:\n//1 Library of Congress\n//1 Cryptic Gateway\n//1 Azami, Lady of Scrolls\n// NB: This is slow as, and will lock your screen :)");
JScrollPane txtScrollableDeckList = new JScrollPane(txtDeckList);
panel3.add(txtScrollableDeckList, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
}
contentPane.add(panel3, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
}
}
}

View file

@ -10,7 +10,7 @@ import mage.client.dialog.PreferencesDialog;
public class SortSettingBase extends SortSetting { public class SortSettingBase extends SortSetting {
private final static SortSettingBase instance = new SortSettingBase(); private static final SortSettingBase instance = new SortSettingBase();
public static SortSettingBase getInstance() { public static SortSettingBase getInstance() {
return instance; return instance;

View file

@ -10,7 +10,7 @@ import mage.client.dialog.PreferencesDialog;
public class SortSettingDeck extends SortSetting { public class SortSettingDeck extends SortSetting {
private final static SortSettingDeck instance = new SortSettingDeck(); private static final SortSettingDeck instance = new SortSettingDeck();
public static SortSettingDeck getInstance() { public static SortSettingDeck getInstance() {
return instance; return instance;

View file

@ -10,7 +10,7 @@ import mage.client.dialog.PreferencesDialog;
*/ */
public class SortSettingDraft extends SortSetting { public class SortSettingDraft extends SortSetting {
private final static SortSettingDraft instance = new SortSettingDraft(); private static final SortSettingDraft instance = new SortSettingDraft();
public static SortSettingDraft getInstance() { public static SortSettingDraft getInstance() {
return instance; return instance;

View file

@ -1,27 +1,19 @@
package mage.client.deckeditor.collection.viewer; package mage.client.deckeditor.collection.viewer;
import java.awt.Color; import mage.cards.repository.ExpansionRepository;
import java.awt.Component; import mage.cards.repository.RepositoryEvent;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.gui.FastSearchUtil; import mage.client.util.gui.FastSearchUtil;
import mage.client.util.sets.ConstructedFormats; import mage.client.util.sets.ConstructedFormats;
import mage.game.events.Listener;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
/** /**
* Pane with big card and mage book. * Pane with big card and mage book.
* *
@ -33,6 +25,7 @@ public final class CollectionViewerPanel extends JPanel {
protected static final String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig"; protected static final String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig";
private static final String FORMAT_CONFIG_KEY = "collectionViewerFormat"; private static final String FORMAT_CONFIG_KEY = "collectionViewerFormat";
private static Listener<RepositoryEvent> setsDbListener = null;
public CollectionViewerPanel() { public CollectionViewerPanel() {
initComponents(); initComponents();
@ -49,6 +42,12 @@ public final class CollectionViewerPanel extends JPanel {
this.bigCard = null; this.bigCard = null;
} }
private void reloadFormatCombobox() {
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes());
formats.setModel(model);
formats.setSelectedItem(ConstructedFormats.getDefault());
}
public void initComponents() { public void initComponents() {
buttonsPanel = new javax.swing.JPanel(); buttonsPanel = new javax.swing.JPanel();
buttonsPanel.setOpaque(false); buttonsPanel.setOpaque(false);
@ -74,8 +73,27 @@ public final class CollectionViewerPanel extends JPanel {
setPanel.setAlignmentX(Component.LEFT_ALIGNMENT); setPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
buttonsPanel.add(setPanel); buttonsPanel.add(setPanel);
// combo set // combo set
formats = new JComboBox<>(ConstructedFormats.getTypes()); formats = new JComboBox<>();
formats.setSelectedItem(ConstructedFormats.getDefault()); reloadFormatCombobox();
// auto-update sets list on changes
setsDbListener = new Listener<RepositoryEvent>() {
@Override
public void event(RepositoryEvent event) {
if (event.getEventType().equals(RepositoryEvent.RepositoryEventType.DB_UPDATED)) {
reloadFormatCombobox();
}
}
};
ExpansionRepository.instance.subscribe(setsDbListener);
// update cards on format combobox changes
formats.addActionListener(e -> {
if (mageBook != null) {
String format = (String) formats.getSelectedItem();
MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
mageBook.updateDispayedSets(format);
}
});
formats.setAlignmentX(0.0F); formats.setAlignmentX(0.0F);
formats.setMinimumSize(new Dimension(50, 25)); formats.setMinimumSize(new Dimension(50, 25));
formats.setPreferredSize(new Dimension(50, 25)); formats.setPreferredSize(new Dimension(50, 25));
@ -104,12 +122,12 @@ public final class CollectionViewerPanel extends JPanel {
small3x3 = new JRadioButton("3x3"); small3x3 = new JRadioButton("3x3");
small3x3.setForeground(Color.white); small3x3.setForeground(Color.white);
boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3).equals(MageBook.LAYOUT_3x3); boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3).equals(MageBook.LAYOUT_3X3);
small3x3.setSelected(selected3x3); small3x3.setSelected(selected3x3);
small3x3.addActionListener(e -> { small3x3.addActionListener(e -> {
big4x4.setSelected(false); big4x4.setSelected(false);
mageBook.updateSize(MageBook.LAYOUT_3x3); mageBook.updateSize(MageBook.LAYOUT_3X3);
MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3); MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3);
}); });
buttonsPanel.add(small3x3); buttonsPanel.add(small3x3);
@ -118,8 +136,8 @@ public final class CollectionViewerPanel extends JPanel {
big4x4.setSelected(!selected3x3); big4x4.setSelected(!selected3x3);
big4x4.addActionListener(e -> { big4x4.addActionListener(e -> {
small3x3.setSelected(false); small3x3.setSelected(false);
mageBook.updateSize(MageBook.LAYOUT_4x4); mageBook.updateSize(MageBook.LAYOUT_4X4);
MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_4x4); MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_4X4);
}); });
buttonsPanel.add(big4x4); buttonsPanel.add(big4x4);
@ -155,14 +173,6 @@ public final class CollectionViewerPanel extends JPanel {
cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected())); cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
buttonsPanel.add(cardsOrTokens); buttonsPanel.add(cardsOrTokens);
formats.addActionListener(e -> {
if (mageBook != null) {
String format = (String) formats.getSelectedItem();
MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
mageBook.updateDispayedSets(format);
}
});
buttonsPanel.add(Box.createVerticalGlue()); buttonsPanel.add(Box.createVerticalGlue());
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

View file

@ -1,20 +1,5 @@
package mage.client.deckeditor.collection.viewer; package mage.client.deckeditor.collection.viewer;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import static java.lang.Math.min;
import java.lang.reflect.Constructor;
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.*;
import mage.cards.*; import mage.cards.*;
import mage.cards.repository.CardCriteria; import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo; import mage.cards.repository.CardInfo;
@ -24,14 +9,16 @@ import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.components.HoverButton; import mage.client.components.HoverButton;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.*; import mage.client.util.Config;
import mage.client.util.ImageHelper;
import mage.client.util.NaturalOrderCardNumberComparator;
import mage.client.util.audio.AudioManager; import mage.client.util.audio.AudioManager;
import mage.client.util.sets.ConstructedFormats; import mage.client.util.sets.ConstructedFormats;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle; import mage.components.ImagePanelStyle;
import mage.constants.Rarity;
import mage.game.command.Emblem; import mage.game.command.Emblem;
import mage.game.command.Plane; import mage.game.command.Plane;
import mage.game.draft.RateCard;
import mage.game.permanent.PermanentToken; import mage.game.permanent.PermanentToken;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
import mage.view.CardView; import mage.view.CardView;
@ -41,7 +28,20 @@ import mage.view.PlaneView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.card.arcane.ManaSymbols; import org.mage.card.arcane.ManaSymbols;
import org.mage.plugins.card.images.CardDownloadData; import org.mage.plugins.card.images.CardDownloadData;
import static org.mage.plugins.card.images.DownloadPictures.getTokenCardUrls;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.*;
import static java.lang.Math.min;
import static org.mage.plugins.card.images.DownloadPicturesService.getTokenCardUrls;
/** /**
* Mage book with cards and page flipping. * Mage book with cards and page flipping.
@ -52,15 +52,15 @@ public class MageBook extends JComponent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static final String LAYOUT_3x3 = "small"; public static final String LAYOUT_3X3 = "small";
public static final String LAYOUT_4x4 = "big"; public static final String LAYOUT_4X4 = "big";
public MageBook(BigCard bigCard) { public MageBook(BigCard bigCard) {
super(); super();
this.bigCard = bigCard; this.bigCard = bigCard;
this.setsToDisplay = ConstructedFormats.getSetsByFormat(ConstructedFormats.getDefault()); this.setsToDisplay = ConstructedFormats.getSetsByFormat(ConstructedFormats.getDefault());
boolean selected3x3 = MageFrame.getPreferences().get(CollectionViewerPanel.LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3).equals(MageBook.LAYOUT_3x3); boolean selected3x3 = MageFrame.getPreferences().get(CollectionViewerPanel.LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3).equals(MageBook.LAYOUT_3X3);
this.conf = selected3x3 ? new _3x3Configuration() : new _4x4Configuration(); this.conf = selected3x3 ? new _3x3Configuration() : new _4x4Configuration();
initComponents(); initComponents();
} }
@ -250,7 +250,7 @@ public class MageBook extends JComponent {
// calculate the x offset of the second (right) page // calculate the x offset of the second (right) page
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X; - (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
rectangle.setLocation(second_page_x, OFFSET_Y); rectangle.setLocation(second_page_x, OFFSET_Y);
for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) { for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) {
@ -265,7 +265,7 @@ public class MageBook extends JComponent {
public int showTokens() { public int showTokens() {
jLayeredPane.removeAll(); jLayeredPane.removeAll();
List<Token> tokens = getTokens(currentPage, currentSet); List<Token> tokens = getTokens(currentPage, currentSet);
if (tokens != null && tokens.size() > 0) { if (tokens != null && !tokens.isEmpty()) {
int size = tokens.size(); int size = tokens.size();
Rectangle rectangle = new Rectangle(); Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y); rectangle.translate(OFFSET_X, OFFSET_Y);
@ -277,7 +277,7 @@ public class MageBook extends JComponent {
// calculate the x offset of the second (right) page // calculate the x offset of the second (right) page
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X; - (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
rectangle.setLocation(second_page_x, OFFSET_Y); rectangle.setLocation(second_page_x, OFFSET_Y);
for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) { for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) {
@ -295,37 +295,45 @@ public class MageBook extends JComponent {
public int showEmblems(int numTokens) { public int showEmblems(int numTokens) {
List<Emblem> emblems = getEmblems(currentPage, currentSet, numTokens); List<Emblem> emblems = getEmblems(currentPage, currentSet, numTokens);
int numEmblems = 0; int numEmblems = 0;
if (emblems != null && emblems.size() > 0) { if (emblems != null && !emblems.isEmpty()) {
int size = emblems.size(); int size = emblems.size();
numEmblems = size; numEmblems = size;
Rectangle rectangle = new Rectangle(); Rectangle rectangle = new Rectangle();
rectangle.translate(OFFSET_X, OFFSET_Y); rectangle.translate(OFFSET_X, OFFSET_Y);
// calculate the x offset of the second (right) page // calculate the x offset of the second (right) page
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X; - (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
// Already have numTokens tokens presented. Appending the emblems to the end of these. // Already have numTokens tokens presented. Appending the emblems to the end of these.
numTokens = numTokens % conf.CARDS_PER_PAGE; numTokens = numTokens % conf.CARDS_PER_PAGE;
if (numTokens < conf.CARDS_PER_PAGE / 2) { if (numTokens < conf.CARDS_PER_PAGE / 2) {
// page 1 with tokens
for (int z = 0; z < numTokens && z < conf.CARDS_PER_PAGE / 2; z++) { for (int z = 0; z < numTokens && z < conf.CARDS_PER_PAGE / 2; z++) {
rectangle = CardPosition.translatePosition(z, rectangle, conf); rectangle = CardPosition.translatePosition(z, rectangle, conf);
} }
} else { } else {
// page 2 with tokens
rectangle.setLocation(second_page_x, OFFSET_Y); rectangle.setLocation(second_page_x, OFFSET_Y);
for (int z = 0; z < numTokens - conf.CARDS_PER_PAGE / 2; z++) { for (int z = 0; z < numTokens - conf.CARDS_PER_PAGE / 2; z++) {
rectangle = CardPosition.translatePosition(z, rectangle, conf); rectangle = CardPosition.translatePosition(z, rectangle, conf);
} }
} }
// page 1 with emblems after tokens
int lastI = 0; int lastI = 0;
boolean needContinueFromPage1 = false;
for (int i = 0; i < size && i + numTokens < conf.CARDS_PER_PAGE / 2; i++) { for (int i = 0; i < size && i + numTokens < conf.CARDS_PER_PAGE / 2; i++) {
Emblem emblem = emblems.get(i); Emblem emblem = emblems.get(i);
addEmblem(emblem, bigCard, null, rectangle); addEmblem(emblem, bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i + numTokens, rectangle, conf); rectangle = CardPosition.translatePosition(i + numTokens, rectangle, conf);
lastI++; lastI++;
needContinueFromPage1 = true;
} }
rectangle.setLocation(second_page_x, OFFSET_Y); // page 2 with emblems after tokens
if (needContinueFromPage1) {
rectangle.setLocation(second_page_x, OFFSET_Y);
}
if (size + numTokens > conf.CARDS_PER_PAGE / 2) { if (size + numTokens > conf.CARDS_PER_PAGE / 2) {
for (int i = lastI; i < size && i + numTokens < conf.CARDS_PER_PAGE; i++) { for (int i = lastI; i < size && i + numTokens < conf.CARDS_PER_PAGE; i++) {
Emblem emblem = emblems.get(i); Emblem emblem = emblems.get(i);
@ -350,29 +358,37 @@ public class MageBook extends JComponent {
rectangle.translate(OFFSET_X, OFFSET_Y); rectangle.translate(OFFSET_X, OFFSET_Y);
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X; - (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
numTokensEmblems = numTokensEmblems % conf.CARDS_PER_PAGE; numTokensEmblems = numTokensEmblems % conf.CARDS_PER_PAGE;
if (numTokensEmblems < conf.CARDS_PER_PAGE / 2) { if (numTokensEmblems < conf.CARDS_PER_PAGE / 2) {
// page 1 with tokens/emblems
for (int z = 0; z < numTokensEmblems && z < conf.CARDS_PER_PAGE / 2; z++) { for (int z = 0; z < numTokensEmblems && z < conf.CARDS_PER_PAGE / 2; z++) {
rectangle = CardPosition.translatePosition(z, rectangle, conf); rectangle = CardPosition.translatePosition(z, rectangle, conf);
} }
} else { } else {
// page 2 with tokens/emblems
rectangle.setLocation(second_page_x, OFFSET_Y); rectangle.setLocation(second_page_x, OFFSET_Y);
for (int z = 0; z < numTokensEmblems - conf.CARDS_PER_PAGE / 2; z++) { for (int z = 0; z < numTokensEmblems - conf.CARDS_PER_PAGE / 2; z++) {
rectangle = CardPosition.translatePosition(z, rectangle, conf); rectangle = CardPosition.translatePosition(z, rectangle, conf);
} }
} }
// page 1 with planes after tokens/emblems
int lastI = 0; int lastI = 0;
boolean needContinueFromPage1 = false;
for (int i = 0; i < size && i + numTokensEmblems < conf.CARDS_PER_PAGE / 2; i++) { for (int i = 0; i < size && i + numTokensEmblems < conf.CARDS_PER_PAGE / 2; i++) {
Plane plane = planes.get(i); Plane plane = planes.get(i);
addPlane(plane, bigCard, null, rectangle); addPlane(plane, bigCard, null, rectangle);
rectangle = CardPosition.translatePosition(i + numTokensEmblems, rectangle, conf); rectangle = CardPosition.translatePosition(i + numTokensEmblems, rectangle, conf);
lastI++; lastI++;
needContinueFromPage1 = true;
} }
rectangle.setLocation(second_page_x, OFFSET_Y); // page 2 with planes after tokens/emblems
if (needContinueFromPage1) {
rectangle.setLocation(second_page_x, OFFSET_Y);
}
if (size + numTokensEmblems > conf.CARDS_PER_PAGE / 2) { if (size + numTokensEmblems > conf.CARDS_PER_PAGE / 2) {
for (int i = lastI; i < size && i + numTokensEmblems < conf.CARDS_PER_PAGE; i++) { for (int i = lastI; i < size && i + numTokensEmblems < conf.CARDS_PER_PAGE; i++) {
Plane plane = planes.get(i); Plane plane = planes.get(i);
@ -388,30 +404,44 @@ public class MageBook extends JComponent {
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) { private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
} }
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true); final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
cardImg.setBounds(rectangle); cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10); jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(card); cardImg.update(card);
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight); cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.getFrameWidth(), cardDimensions.getFrameHeight());
cardImg.setCardCaptionTopOffset(8); // card caption below real card caption to see full name even with mana icons cardImg.setCardCaptionTopOffset(8); // card caption below real card caption to see full name even with mana icons
// card number label // card number label
JLabel cardNumber = new JLabel(); JLabel cardNumber = new JLabel();
int dy = -5; // image panel have empty space in bottom (bug?), need to move label up int dy = -5; // image panel have empty space in bottom (bug?), need to move label up
cardNumber.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.frameWidth, 20); cardNumber.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.getFrameWidth(), 20);
cardNumber.setHorizontalAlignment(SwingConstants.CENTER); cardNumber.setHorizontalAlignment(SwingConstants.CENTER);
//cardNumber.setBorder(BorderFactory.createLineBorder(new Color(180, 50, 150), 3, true)); //cardNumber.setBorder(BorderFactory.createLineBorder(new Color(180, 50, 150), 3, true));
cardNumber.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD)); cardNumber.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD));
cardNumber.setText(card.getCardNumber()); cardNumber.setText(card.getCardNumber());
jLayeredPane.add(cardNumber); jLayeredPane.add(cardNumber);
// draft rating label (
JLabel draftRating = new JLabel();
dy = -5 * 2 + cardNumber.getHeight(); // under card number
draftRating.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.getFrameWidth(), 20);
draftRating.setHorizontalAlignment(SwingConstants.CENTER);
//draftRating.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 150), 3, true));
draftRating.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD));
if (card.getOriginalCard() != null) {
draftRating.setText("draft rating: " + RateCard.rateCard(card.getOriginalCard(), null));
} else {
draftRating.setText("");
}
jLayeredPane.add(draftRating);
} }
private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) { private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
} }
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null); PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
newToken.removeSummoningSickness(); newToken.removeSummoningSickness();
@ -421,7 +451,7 @@ public class MageBook extends JComponent {
cardImg.setBounds(rectangle); cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10); jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(theToken); cardImg.update(theToken);
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight); cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.getFrameWidth(), cardDimensions.getFrameHeight());
} }
private void addEmblem(Emblem emblem, BigCard bigCard, UUID gameId, Rectangle rectangle) { private void addEmblem(Emblem emblem, BigCard bigCard, UUID gameId, Rectangle rectangle) {
@ -602,13 +632,13 @@ public class MageBook extends JComponent {
} }
} }
} }
int totalTokens = getTotalNumTokens(set); int totalTokens = getTotalNumTokens(set);
int start = 0; int start = 0;
if (!(page * conf.CARDS_PER_PAGE <= totalTokens && (page + 1) * conf.CARDS_PER_PAGE >= totalTokens)) { if (!(page * conf.CARDS_PER_PAGE <= totalTokens && (page + 1) * conf.CARDS_PER_PAGE >= totalTokens)) {
start = page * conf.CARDS_PER_PAGE - totalTokens; start = page * conf.CARDS_PER_PAGE - totalTokens;
} }
int end = emblems.size(); int end = emblems.size();
if ((page + 1) * conf.CARDS_PER_PAGE < totalTokens + emblems.size()) { if ((page + 1) * conf.CARDS_PER_PAGE < totalTokens + emblems.size()) {
end = (page + 1) * conf.CARDS_PER_PAGE - totalTokens; end = (page + 1) * conf.CARDS_PER_PAGE - totalTokens;
@ -659,7 +689,7 @@ public class MageBook extends JComponent {
} }
} }
} }
int totalTokens = getTotalNumTokens(set); int totalTokens = getTotalNumTokens(set);
int totalTokensEmblems = totalTokens + getTotalNumEmblems(set); int totalTokensEmblems = totalTokens + getTotalNumEmblems(set);
int start = 0; int start = 0;
@ -667,7 +697,7 @@ public class MageBook extends JComponent {
start = page * conf.CARDS_PER_PAGE - totalTokensEmblems; start = page * conf.CARDS_PER_PAGE - totalTokensEmblems;
pageRight.setVisible(true); pageRight.setVisible(true);
} }
int end = planes.size(); int end = planes.size();
if ((page + 1) * conf.CARDS_PER_PAGE < totalTokensEmblems + planes.size()) { if ((page + 1) * conf.CARDS_PER_PAGE < totalTokensEmblems + planes.size()) {
end = (page + 1) * conf.CARDS_PER_PAGE - totalTokensEmblems; end = (page + 1) * conf.CARDS_PER_PAGE - totalTokensEmblems;
@ -797,10 +827,10 @@ public class MageBook extends JComponent {
public void updateSize(String size) { public void updateSize(String size) {
switch (size) { switch (size) {
case LAYOUT_3x3: case LAYOUT_3X3:
this.conf = new _3x3Configuration(); this.conf = new _3x3Configuration();
break; break;
case LAYOUT_4x4: case LAYOUT_4X4:
this.conf = new _4x4Configuration(); this.conf = new _4x4Configuration();
break; break;
default: default:
@ -825,8 +855,8 @@ public class MageBook extends JComponent {
public static Rectangle translatePosition(int index, Rectangle r, Configuration conf) { public static Rectangle translatePosition(int index, Rectangle r, Configuration conf) {
Rectangle rect = new Rectangle(r); Rectangle rect = new Rectangle(r);
rect.translate((cardDimensions.frameWidth + GAP_X) * conf.dx[index], rect.translate((cardDimensions.getFrameWidth() + GAP_X) * conf.dx[index],
(cardDimensions.frameHeight + GAP_Y) * conf.dy[index]); (cardDimensions.getFrameHeight() + GAP_Y) * conf.dy[index]);
return rect; return rect;
} }

View file

@ -26,10 +26,12 @@
*/ */
package mage.client.deckeditor.table; package mage.client.deckeditor.table;
import java.util.Comparator;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.game.draft.RateCard;
import mage.view.CardView; import mage.view.CardView;
import org.apache.log4j.Logger;
import java.util.Comparator;
/** /**
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View * {@link MageCard} comparator. Used to sort cards in Deck Editor Table View
@ -39,6 +41,8 @@ import mage.view.CardView;
*/ */
public class MageCardComparator implements Comparator<CardView> { public class MageCardComparator implements Comparator<CardView> {
private static final Logger logger = Logger.getLogger(MageCardComparator.class);
private final int column; private final int column;
private final boolean ascending; private final boolean ascending;
@ -49,14 +53,12 @@ public class MageCardComparator implements Comparator<CardView> {
@Override @Override
public int compare(CardView a, CardView b) { public int compare(CardView a, CardView b) {
Comparable aCom = null; Comparable aCom = 1;
Comparable bCom = null; Comparable bCom = 1;
switch (column) { switch (column) {
// #skip // #skip
case 0: case 0:
aCom = 1;
bCom = 1;
break; break;
// Name // Name
case 1: case 1:
@ -107,6 +109,10 @@ public class MageCardComparator implements Comparator<CardView> {
aCom = Integer.parseInt(a.getCardNumber().replaceAll("[\\D]", "")); aCom = Integer.parseInt(a.getCardNumber().replaceAll("[\\D]", ""));
bCom = Integer.parseInt(b.getCardNumber().replaceAll("[\\D]", "")); bCom = Integer.parseInt(b.getCardNumber().replaceAll("[\\D]", ""));
break; break;
case 9:
aCom = RateCard.rateCard(a.getOriginalCard(), null);
bCom = RateCard.rateCard(b.getOriginalCard(), null);
break;
default: default:
break; break;
} }

View file

@ -1,4 +1,3 @@
package mage.client.deckeditor.table; package mage.client.deckeditor.table;
import mage.client.MageFrame; import mage.client.MageFrame;
@ -13,6 +12,7 @@ import mage.client.util.Event;
import mage.client.util.Listener; import mage.client.util.Listener;
import mage.client.util.gui.GuiDisplayUtil; import mage.client.util.gui.GuiDisplayUtil;
import mage.constants.EnlargeMode; import mage.constants.EnlargeMode;
import mage.game.draft.RateCard;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CardsView; import mage.view.CardsView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -25,8 +25,8 @@ import javax.swing.table.TableColumnModel;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List; import java.util.List;
import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
/** /**
@ -51,8 +51,9 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private boolean displayNoCopies = false; private boolean displayNoCopies = false;
private UpdateCountsCallback updateCountsCallback; private UpdateCountsCallback updateCountsCallback;
private final String column[] = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set", "#"}; private final String[] column = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set", "Card number", "Draft Rating"};
public final int COLUMN_INDEX_COST = 2; public final int COLUMN_INDEX_COST = 2;
public final int COLUMN_INDEX_RATING = 9;
private SortSetting sortSetting; private SortSetting sortSetting;
private int recentSortedColumn; private int recentSortedColumn;
@ -239,6 +240,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
return c.getExpansionSetCode(); return c.getExpansionSetCode();
case 8: case 8:
return c.getCardNumber(); return c.getCardNumber();
case 9:
return RateCard.rateCard(c.getOriginalCard(), null);
default: default:
return "error"; return "error";
} }
@ -246,8 +249,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private void addCard(CardView card, BigCard bigCard, UUID gameId) { private void addCard(CardView card, BigCard bigCard, UUID gameId) {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, cardDimension = new Dimension(Config.dimensions.getFrameWidth(),
Config.dimensions.frameHeight); Config.dimensions.getFrameHeight());
} }
cards.put(card.getId(), card); cards.put(card.getId(), card);

View file

@ -27,14 +27,23 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel3" alignment="0" max="32767" attributes="0"/> <Component id="jLabel3" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="btnWhatsNew" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
<Component id="lblVersion" min="-2" max="-2" attributes="0"/> <Component id="btnOk" min="-2" pref="100" max="-2" attributes="0"/>
</Group> </Group>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="btnOk" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="0" max="32767" attributes="0"/> <Component id="jLabel4" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblVersion" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -54,8 +63,11 @@
<Component id="jLabel3" min="-2" pref="21" max="-2" attributes="0"/> <Component id="jLabel3" min="-2" pref="21" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/> <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="71" max="32767" attributes="0"/> <EmptySpace pref="68" max="32767" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnOk" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnWhatsNew" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -64,7 +76,7 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JButton" name="btnOk"> <Component class="javax.swing.JButton" name="btnOk">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="OK"/> <Property name="text" type="java.lang.String" value="Close"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
@ -95,5 +107,13 @@
<Property name="text" type="java.lang.String" value="fireshoes, lunaskyrise, mnapoleon, jgod, LoneFox."/> <Property name="text" type="java.lang.String" value="fireshoes, lunaskyrise, mnapoleon, jgod, LoneFox."/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnWhatsNew">
<Properties>
<Property name="text" type="java.lang.String" value="What&apos;s new"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnWhatsNewActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,26 +1,18 @@
package mage.client.dialog; package mage.client.dialog;
import mage.client.MageFrame;
import mage.utils.MageVersion; import mage.utils.MageVersion;
/* import javax.swing.*;
* AboutDialog.java import java.awt.event.KeyEvent;
*
* Created on Mar 10, 2010, 8:19:41 AM
*/
/** /**
* * @author JayDi85
* @author BetaSteward_at_googlemail.com
*/ */
public class AboutDialog extends MageDialog { public class AboutDialog extends MageDialog {
/** Creates new form AboutDialog */
public AboutDialog() { public AboutDialog() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents(); initComponents();
this.modal = false; this.modal = false;
} }
@ -28,10 +20,28 @@ public class AboutDialog extends MageDialog {
public void showDialog(MageVersion version) { public void showDialog(MageVersion version) {
this.lblVersion.setText(version.toString()); this.lblVersion.setText(version.toString());
this.setLocation(100, 100); this.setLocation(100, 100);
// windows settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.makeWindowCentered();
// Close on "ESC"
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setVisible(true); this.setVisible(true);
} }
/** This method is called from within the constructor to private void onCancel() {
this.hideDialog();
}
/**
* This method is called from within the constructor to
* initialize the form. * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor. * always regenerated by the Form Editor.
@ -46,12 +56,17 @@ public class AboutDialog extends MageDialog {
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel();
btnWhatsNew = new javax.swing.JButton();
setMaximizable(true); setMaximizable(true);
setTitle("About XMage"); setTitle("About XMage");
btnOk.setText("OK"); btnOk.setText("Close");
btnOk.addActionListener(this::btnOkActionPerformed); btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
jLabel1.setText("XMage client"); jLabel1.setText("XMage client");
@ -59,53 +74,74 @@ public class AboutDialog extends MageDialog {
jLabel2.setText("Courtesy: BetaSteward@googlemail.com. Site: http://XMage.de/"); jLabel2.setText("Courtesy: BetaSteward@googlemail.com. Site: http://XMage.de/");
jLabel3.setText("Devs: BetaSteward, Noxx, Eugen.Rivniy, North, LevelX2, Jeff, Plopman, dustinconrad, emerald000,"); jLabel3.setText("Devs: BetaSteward, Noxx, Eugen.Rivniy, North, LevelX2, Jeff, Plopman, dustinconrad, emerald000.,");
jLabel4.setText("fireshoes, lunaskyrise, mnapoleon, jgod, LoneFox, drmDev, spjspj, TheElk801, L_J, JayDi85.");
jLabel4.setText("fireshoes, lunaskyrise, mnapoleon, jgod, LoneFox.");
btnWhatsNew.setText("What's new");
btnWhatsNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnWhatsNewActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jLabel1) .addComponent(btnWhatsNew, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblVersion)) .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnOk) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblVersion))
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1) .addComponent(jLabel1)
.addComponent(lblVersion)) .addComponent(lblVersion))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4) .addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
.addComponent(btnOk) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addContainerGap()) .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnWhatsNew, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
); );
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
this.removeDialog(); onCancel();
}//GEN-LAST:event_btnOkActionPerformed }//GEN-LAST:event_btnOkActionPerformed
private void btnWhatsNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWhatsNewActionPerformed
MageFrame.getInstance().showWhatsNewDialog(true);
}//GEN-LAST:event_btnWhatsNewActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnOk; private javax.swing.JButton btnOk;
private javax.swing.JButton btnWhatsNew;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel3;

View file

@ -51,9 +51,9 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="btnAdd" min="-2" max="-2" attributes="0"/> <Component id="btnOK" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Component id="ckbFullArtLands" min="-2" max="-2" attributes="0"/> <Component id="ckbFullArtLands" min="-2" max="-2" attributes="0"/>
@ -103,10 +103,12 @@
<Component id="panelSet" min="-2" pref="23" max="-2" attributes="0"/> <Component id="panelSet" min="-2" pref="23" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="0" 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"/> <Component id="lblForestIcon" alignment="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblForest" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnForest" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
@ -150,8 +152,8 @@
</Group> </Group>
<EmptySpace type="separate" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnOK" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -161,7 +163,7 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblLandSet"> <Component class="javax.swing.JLabel" name="lblLandSet">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Set:"/> <Property name="text" type="java.lang.String" value="From set:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblForest"> <Component class="javax.swing.JLabel" name="lblForest">
@ -304,20 +306,20 @@
</Component> </Component>
<Component class="javax.swing.JButton" name="btnAutoAdd"> <Component class="javax.swing.JButton" name="btnAutoAdd">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Suggest"/> <Property name="text" type="java.lang.String" value="Suggest lands"/>
<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."/> <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> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAutoAddActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAutoAddActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnAdd"> <Component class="javax.swing.JButton" name="btnOK">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Add"/> <Property name="text" type="java.lang.String" value="Add lands"/>
<Property name="toolTipText" type="java.lang.String" value="Add the selected number of basic lands to the deck."/> <Property name="toolTipText" type="java.lang.String" value="Add the selected number of basic lands to the deck."/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnCancel"> <Component class="javax.swing.JButton" name="btnCancel">
@ -366,7 +368,7 @@
</Container> </Container>
<Component class="javax.swing.JCheckBox" name="ckbFullArtLands"> <Component class="javax.swing.JCheckBox" name="ckbFullArtLands">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Only use full art lands"/> <Property name="text" type="java.lang.String" value="Only full art lands"/>
<Property name="toolTipText" type="java.lang.String" value="For example, lands from ZEN/UST/HOU"/> <Property name="toolTipText" type="java.lang.String" value="For example, lands from ZEN/UST/HOU"/>
</Properties> </Properties>
</Component> </Component>

View file

@ -1,23 +1,10 @@
package mage.client.dialog; package mage.client.dialog;
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.Mana;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.FrameStyle; import mage.cards.FrameStyle;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.cards.repository.CardCriteria; import mage.cards.repository.*;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.constants.Constants.DeckEditorMode; import mage.client.constants.Constants.DeckEditorMode;
import mage.client.util.gui.FastSearchUtil; import mage.client.util.gui.FastSearchUtil;
@ -26,8 +13,15 @@ import mage.util.RandomUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.card.arcane.ManaSymbols; import org.mage.card.arcane.ManaSymbols;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class AddLandDialog extends MageDialog { public class AddLandDialog extends MageDialog {
@ -38,9 +32,6 @@ public class AddLandDialog extends MageDialog {
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40; private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
/**
* Creates new form AddLandDialog
*/
public AddLandDialog() { public AddLandDialog() {
initComponents(); initComponents();
this.setModal(true); this.setModal(true);
@ -100,12 +91,6 @@ public class AddLandDialog extends MageDialog {
} }
// windows settings
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
spnDeckSize.setValue(DEFAULT_SEALED_DECK_CARD_NUMBER); spnDeckSize.setValue(DEFAULT_SEALED_DECK_CARD_NUMBER);
BufferedImage image = ManaSymbols.getSizedManaSymbol("G", 15); BufferedImage image = ManaSymbols.getSizedManaSymbol("G", 15);
if (image != null) { if (image != null) {
@ -128,6 +113,20 @@ public class AddLandDialog extends MageDialog {
lblSwampIcon.setIcon(new ImageIcon(image)); lblSwampIcon.setIcon(new ImageIcon(image));
} }
getRootPane().setDefaultButton(btnOK);
// windows settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.makeWindowCentered();
// Close on "ESC"
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setVisible(true); this.setVisible(true);
} }
@ -178,6 +177,27 @@ public class AddLandDialog extends MageDialog {
} }
} }
private void onCancel() {
this.removeDialog();
}
private void onOK() {
int nForest = ((Number) spnForest.getValue()).intValue();
int nIsland = ((Number) spnIsland.getValue()).intValue();
int nMountain = ((Number) spnMountain.getValue()).intValue();
int nPlains = ((Number) spnPlains.getValue()).intValue();
int nSwamp = ((Number) spnSwamp.getValue()).intValue();
boolean useFullArt = ckbFullArtLands.isSelected();
addLands("Forest", nForest, useFullArt);
addLands("Island", nIsland, useFullArt);
addLands("Mountain", nMountain, useFullArt);
addLands("Plains", nPlains, useFullArt);
addLands("Swamp", nSwamp, useFullArt);
this.removeDialog();
}
/** /**
* This method is called from within the constructor to initialize the form. * 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 * WARNING: Do NOT modify this code. The content of this method is always
@ -208,7 +228,7 @@ public class AddLandDialog extends MageDialog {
lblDeckSize = new javax.swing.JLabel(); lblDeckSize = new javax.swing.JLabel();
spnDeckSize = new javax.swing.JSpinner(); spnDeckSize = new javax.swing.JSpinner();
btnAutoAdd = new javax.swing.JButton(); btnAutoAdd = new javax.swing.JButton();
btnAdd = new javax.swing.JButton(); btnOK = new javax.swing.JButton();
btnCancel = new javax.swing.JButton(); btnCancel = new javax.swing.JButton();
panelSet = new javax.swing.JPanel(); panelSet = new javax.swing.JPanel();
cbLandSet = new javax.swing.JComboBox(); cbLandSet = new javax.swing.JComboBox();
@ -221,7 +241,7 @@ public class AddLandDialog extends MageDialog {
setTitle("Add Land"); setTitle("Add Land");
lblLandSet.setText("Set:"); lblLandSet.setText("From set:");
lblForest.setText("Forest:"); lblForest.setText("Forest:");
@ -268,7 +288,7 @@ public class AddLandDialog extends MageDialog {
spnDeckSize.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); spnDeckSize.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
btnAutoAdd.setText("Suggest"); btnAutoAdd.setText("Suggest lands");
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.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() { btnAutoAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -276,11 +296,11 @@ public class AddLandDialog extends MageDialog {
} }
}); });
btnAdd.setText("Add"); btnOK.setText("Add lands");
btnAdd.setToolTipText("Add the selected number of basic lands to the deck."); btnOK.setToolTipText("Add the selected number of basic lands to the deck.");
btnAdd.addActionListener(new java.awt.event.ActionListener() { btnOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddActionPerformed(evt); btnOKActionPerformed(evt);
} }
}); });
@ -293,7 +313,7 @@ public class AddLandDialog extends MageDialog {
panelSet.setLayout(new javax.swing.BoxLayout(panelSet, javax.swing.BoxLayout.LINE_AXIS)); 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" })); cbLandSet.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
cbLandSet.setMinimumSize(new java.awt.Dimension(20, 20)); cbLandSet.setMinimumSize(new java.awt.Dimension(20, 20));
panelSet.add(cbLandSet); panelSet.add(cbLandSet);
@ -308,132 +328,121 @@ public class AddLandDialog extends MageDialog {
}); });
panelSet.add(btnSetFastSearch); panelSet.add(btnSetFastSearch);
ckbFullArtLands.setText("Only use full art lands"); ckbFullArtLands.setText("Only full art lands");
ckbFullArtLands.setToolTipText("For example, lands from ZEN/UST/HOU"); ckbFullArtLands.setToolTipText("For example, lands from ZEN/UST/HOU");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 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.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)
.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() .addGroup(layout.createSequentialGroup()
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblForestIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addComponent(lblMountain)
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblForest, javax.swing.GroupLayout.Alignment.TRAILING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblLandSet, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblIslandIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblIsland, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup() .addComponent(lblPains, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblSwamp, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblDeckSize))
.addComponent(lblMountainIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(lblSwampIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnOK, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnDeckSize, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addContainerGap())
.addComponent(btnAutoAdd))) .addComponent(ckbFullArtLands)
.addGroup(layout.createSequentialGroup() .addComponent(panelSet, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, 50, 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)
.addGap(36, 36, 36)))) .addComponent(lblForestIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblIslandIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblMountainIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblSwampIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(spnDeckSize, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnAutoAdd)))
.addGroup(layout.createSequentialGroup()
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPlainsIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36))))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblLandSet) .addComponent(lblLandSet)
.addComponent(panelSet, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(panelSet, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblForest) .addComponent(lblForestIcon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblForestIcon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(lblForest)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblIsland) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblIsland)
.addComponent(lblIslandIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMountain) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblMountain)
.addComponent(lblMountainIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPains) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblPains)
.addComponent(lblPlainsIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblPlainsIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblSwamp) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblSwamp)
.addComponent(lblSwampIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 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))
.addComponent(ckbFullArtLands) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(2, 2, 2) .addComponent(ckbFullArtLands)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGap(2, 2, 2)
.addComponent(btnAutoAdd) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDeckSize) .addComponent(btnAutoAdd)
.addComponent(spnDeckSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblDeckSize)
.addGap(18, 18, 18) .addComponent(spnDeckSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGap(18, 18, 18)
.addComponent(btnAdd) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel)) .addComponent(btnOK, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
); );
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
this.removeDialog(); onCancel();
}//GEN-LAST:event_btnCancelActionPerformed }//GEN-LAST:event_btnCancelActionPerformed
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
int nForest = ((Number) spnForest.getValue()).intValue(); onOK();
int nIsland = ((Number) spnIsland.getValue()).intValue(); }//GEN-LAST:event_btnOKActionPerformed
int nMountain = ((Number) spnMountain.getValue()).intValue();
int nPlains = ((Number) spnPlains.getValue()).intValue();
int nSwamp = ((Number) spnSwamp.getValue()).intValue();
boolean useFullArt = ckbFullArtLands.isSelected();
addLands("Forest", nForest, useFullArt);
addLands("Island", nIsland, useFullArt);
addLands("Mountain", nMountain, useFullArt);
addLands("Plains", nPlains, useFullArt);
addLands("Swamp", nSwamp, useFullArt);
this.removeDialog();
}//GEN-LAST:event_btnAddActionPerformed
private void btnAutoAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAutoAddActionPerformed private void btnAutoAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAutoAddActionPerformed
autoAddLands(); autoAddLands();
@ -484,9 +493,9 @@ public class AddLandDialog extends MageDialog {
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAdd;
private javax.swing.JButton btnAutoAdd; private javax.swing.JButton btnAutoAdd;
private javax.swing.JButton btnCancel; private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOK;
private javax.swing.JButton btnSetFastSearch; private javax.swing.JButton btnSetFastSearch;
private javax.swing.JComboBox cbLandSet; private javax.swing.JComboBox cbLandSet;
private javax.swing.JCheckBox ckbFullArtLands; private javax.swing.JCheckBox ckbFullArtLands;

View file

@ -5,7 +5,7 @@
<Property name="iconifiable" type="boolean" value="true"/> <Property name="iconifiable" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="true"/> <Property name="resizable" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.3),&#xa; (int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.2))" type="code"/> <Connection code="new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.4),&#xd;&#xa; (int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.4))" type="code"/>
</Property> </Property>
</Properties> </Properties>
<SyntheticProperties> <SyntheticProperties>
@ -21,31 +21,20 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,0,0,0,1,112"/>
</AuxValues> </AuxValues>
<Layout> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="cards" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="cards" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents> <SubComponents>
<Component class="mage.client.cards.Cards" name="cards"> <Component class="mage.client.cards.Cards" name="cards">
<AuxValues> <AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CardInfoWindowDialog_cards"/> <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CardInfoWindowDialog_cards"/>
</AuxValues> </AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component> </Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,23 +1,5 @@
/*
* CardInfoWindowDialog.java
*
* Created on Feb 1, 2010, 3:00:35 PM
*/
package mage.client.dialog; package mage.client.dialog;
import java.awt.Dimension;
import java.awt.Point;
import java.beans.PropertyVetoException;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
@ -31,8 +13,17 @@ import mage.view.SimpleCardsView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.plugins.card.utils.impl.ImageManagerImpl; import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.swing.*;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import java.awt.*;
import java.beans.PropertyVetoException;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com, JayDi85
*/ */
public class CardInfoWindowDialog extends MageDialog { public class CardInfoWindowDialog extends MageDialog {
@ -151,6 +142,7 @@ public class CardInfoWindowDialog extends MageDialog {
return; return;
} }
} }
super.show(); super.show();
if (positioned) { // check if in frame rectangle if (positioned) { // check if in frame rectangle
showAndPositionWindow(); showAndPositionWindow();
@ -201,23 +193,10 @@ public class CardInfoWindowDialog extends MageDialog {
setIconifiable(true); setIconifiable(true);
setResizable(true); setResizable(true);
setPreferredSize(new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.3), setPreferredSize(new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.4),
(int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.2))); (int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.4)));
getContentPane().setLayout(new java.awt.BorderLayout());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().add(cards, java.awt.BorderLayout.CENTER);
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents

View file

@ -3,9 +3,6 @@
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties> <Properties>
<Property name="title" type="java.lang.String" value="Connect to server"/> <Property name="title" type="java.lang.String" value="Connect to server"/>
<Property name="normalBounds" type="java.awt.Rectangle" editor="org.netbeans.beaninfo.editors.RectangleEditor">
<Rectangle value="[100, 100, 410, 307]"/>
</Property>
</Properties> </Properties>
<SyntheticProperties> <SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
@ -26,30 +23,21 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0"> <Component id="lblUserName" alignment="0" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/> <Component id="lblServer" alignment="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Component id="lblFastConnect" alignment="0" max="32767" attributes="0"/>
<Component id="lblPort" alignment="1" min="-2" max="-2" attributes="0"/> <Component id="lblPassword" alignment="0" max="32767" attributes="0"/>
<Component id="lblServer" min="-2" max="-2" attributes="0"/> <Component id="lblFlag" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="lblFlag" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group> </Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="lblStatus" alignment="1" max="32767" attributes="0"/>
<Component id="chkForceUpdateDB" alignment="0" max="32767" attributes="0"/>
<Component id="chkAutoConnect" alignment="0" max="32767" attributes="0"/>
<Component id="txtUserName" alignment="0" max="32767" attributes="0"/>
<Component id="panelFlag" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="btnConnect" max="32767" attributes="0"/> <Component id="btnConnect" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -57,84 +45,77 @@
<Component id="btnRegister" max="32767" attributes="0"/> <Component id="btnRegister" max="32767" attributes="0"/>
<Component id="btnForgotPassword" max="32767" attributes="0"/> <Component id="btnForgotPassword" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" pref="77" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" pref="77" max="-2" attributes="0"/>
</Group> </Group>
<Component id="lblStatus" alignment="1" max="32767" attributes="0"/> <Component id="panelFast" alignment="0" max="32767" attributes="0"/>
<Component id="chkForceUpdateDB" alignment="0" max="32767" attributes="0"/> <Component id="panelServer" alignment="1" max="32767" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="jProxySettingsButton" min="-2" max="-2" attributes="0"/> <Component id="jProxySettingsButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnWhatsNew" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
<Component id="chkAutoConnect" alignment="0" max="32767" attributes="0"/> <Group type="102" alignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Component id="txtPassword" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <EmptySpace max="-2" attributes="0"/>
<Component id="panelFlag" alignment="0" max="32767" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="txtServer" alignment="0" max="32767" attributes="0"/>
<Component id="txtUserName" alignment="0" max="32767" attributes="0"/>
<Component id="txtPassword" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="txtPort" min="-2" pref="71" max="-2" attributes="0"/>
<EmptySpace pref="11" max="32767" attributes="0"/>
<Component id="lblFastConnect" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnFind1" min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnFind3" min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnFind2" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="btnFind" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="filler2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="lblServer" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="panelFast" max="32767" attributes="0"/>
<Component id="txtServer" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblFastConnect" max="32767" attributes="0"/>
<Component id="btnFind" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtPort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnFind1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnFind2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnFind3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFastConnect" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtUserName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblUserName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="panelServer" max="32767" attributes="0"/>
<Component id="lblServer" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtUserName" min="-2" max="-2" attributes="0"/>
<Component id="lblUserName" min="-2" pref="20" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtPassword" alignment="3" max="32767" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblPassword" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="filler2" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelFlag" min="-2" pref="20" max="-2" attributes="0"/> <Component id="panelFlag" min="-2" pref="20" max="-2" attributes="0"/>
<Component id="lblFlag" min="-2" pref="18" max="-2" attributes="0"/> <Component id="lblFlag" min="-2" pref="18" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="chkAutoConnect" min="-2" max="-2" attributes="0"/> <Component id="chkAutoConnect" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="chkForceUpdateDB" min="-2" max="-2" attributes="0"/> <Component id="chkForceUpdateDB" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="jProxySettingsButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="lblStatus" min="-2" pref="24" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="jProxySettingsButton" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnWhatsNew" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="lblStatus" min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="btnRegister" max="32767" attributes="0"/> <Component id="btnRegister" max="32767" attributes="0"/>
@ -152,49 +133,27 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblServer"> <Component class="javax.swing.JLabel" name="lblServer">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtServer"/> <ComponentRef name="txtServer"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Server:"/> <Property name="text" type="java.lang.String" value="Server name:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtServer">
</Component>
<Component class="javax.swing.JButton" name="btnFind">
<Properties>
<Property name="text" type="java.lang.String" value="Find..."/>
<Property name="toolTipText" type="java.lang.String" value="Shows the list of public servers"/>
<Property name="name" type="java.lang.String" value="findServerBtn" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="findPublicServerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblPort">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtPort"/>
</Property>
<Property name="text" type="java.lang.String" value="Port:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtPort">
<Events>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="keyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblUserName"> <Component class="javax.swing.JLabel" name="lblUserName">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtUserName"/> <ComponentRef name="txtUserName"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="User name:"/> <Property name="text" type="java.lang.String" value="Username:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtUserName"> <Component class="javax.swing.JTextField" name="txtUserName">
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblPassword"> <Component class="javax.swing.JLabel" name="lblPassword">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtPassword"/> <ComponentRef name="txtPassword"/>
</Property> </Property>
@ -205,10 +164,11 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblFlag"> <Component class="javax.swing.JLabel" name="lblFlag">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtUserName"/> <ComponentRef name="txtUserName"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="User flag:"/> <Property name="text" type="java.lang.String" value="User&apos;s flag:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkAutoConnect"> <Component class="javax.swing.JCheckBox" name="chkAutoConnect">
@ -289,86 +249,23 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnForgotPasswordActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnForgotPasswordActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnFind1">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/flags/de.png"/>
</Property>
<Property name="text" type="java.lang.String" value="X"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to xmage.de (Europe, most popular)"/>
<Property name="actionCommand" type="java.lang.String" value="connectXmageDe"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[42, 23]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[42, 23]"/>
</Property>
<Property name="name" type="java.lang.String" value="connectXmageDeBtn" noResource="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectXmageDe"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnFind2">
<Properties>
<Property name="text" type="java.lang.String" value="L"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to localhost (local server)"/>
<Property name="actionCommand" type="java.lang.String" value="connectLocalhost"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="name" type="java.lang.String" value="connectLocalhostBtn" noResource="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectLocalhost"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnFind3">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/flags/us.png"/>
</Property>
<Property name="text" type="java.lang.String" value="W"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to vaporservermtg.com (USA)"/>
<Property name="actionCommand" type="java.lang.String" value="connectXmageus"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="name" type="java.lang.String" value="connectXmageusBtn" noResource="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectXmageus"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblFastConnect"> <Component class="javax.swing.JLabel" name="lblFastConnect">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="btnFind1"/> <ComponentRef name="btnFindMain"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Fast connect to:"/> <Property name="text" type="java.lang.String" value="Connect to:"/>
<Property name="name" type="java.lang.String" value="" noResource="true"/> <Property name="name" type="java.lang.String" value="" noResource="true"/>
</Properties> </Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Fast connect to:"/>
</AccessibilityProperties>
</Component> </Component>
<Container class="javax.swing.JPanel" name="panelFlag"> <Container class="javax.swing.JPanel" name="panelFlag">
<Properties> <Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[189, 30]"/> <Dimension value="[50, 33]"/>
</Property> </Property>
</Properties> </Properties>
@ -420,5 +317,236 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="panelFast">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="btnFindMain" min="-2" pref="90" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="btnFindUs" min="-2" pref="90" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="btnFindBeta" min="-2" pref="90" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="btnFindLocal" min="-2" pref="90" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnFindOther" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnFindMain" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnFindLocal" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnFindUs" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnFindBeta" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnFindOther" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btnFindMain">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/flags/de.png"/>
</Property>
<Property name="text" type="java.lang.String" value="X"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to xmage.de (Europe, most popular, registration needs)"/>
<Property name="actionCommand" type="java.lang.String" value="connectXmageDe"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[42, 23]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[42, 23]"/>
</Property>
<Property name="name" type="java.lang.String" value="connectXmageDeBtn" noResource="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectXmageDe"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnFindLocal">
<Properties>
<Property name="text" type="java.lang.String" value="LOCAL, AI"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to localhost, AI enabled (run local server from launcher)"/>
<Property name="actionCommand" type="java.lang.String" value="connectLocalhost"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="name" type="java.lang.String" value="connectLocalhostBtn" noResource="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectLocalhost"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnFindBeta">
<Properties>
<Property name="text" type="java.lang.String" value="BETA, AI"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to BETA server, AI enabled (use any username without registration)"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnFindBetaconnectLocalhost"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnFindUs">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/flags/us.png"/>
</Property>
<Property name="text" type="java.lang.String" value="P"/>
<Property name="toolTipText" type="java.lang.String" value="Connect to mtg.powersofwar.com (USA, use any username without registration)"/>
<Property name="actionCommand" type="java.lang.String" value="connectXmageus"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="name" type="java.lang.String" value="connectXmageusBtn" noResource="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectXmageus"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnFindOther">
<Properties>
<Property name="text" type="java.lang.String" value="Other servers..."/>
<Property name="toolTipText" type="java.lang.String" value="Choose server from full servers list"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="name" type="java.lang.String" value="findServerBtn" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="findPublicServerActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelServer">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="txtServer" min="-2" pref="212" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPort" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPort" min="-2" pref="75" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCheckStatus" pref="205" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtServer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCheckStatus" alignment="3" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="txtServer">
</Component>
<Component class="javax.swing.JTextField" name="txtPort">
<Events>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="keyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblPort">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtPort"/>
</Property>
<Property name="text" type="java.lang.String" value="Port:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnCheckStatus">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/flags/world.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Check online status"/>
<Property name="toolTipText" type="java.lang.String" value="Go to servers online statuses page"/>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[2, 2, 2, 2]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[23, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCheckStatusActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.Box$Filler" name="filler2">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 50]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 50]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 50]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="btnWhatsNew">
<Properties>
<Property name="text" type="java.lang.String" value="Show what&apos;s new"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnWhatsNewActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="(use empty password for servers without registration)"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,45 +1,10 @@
/*
* ConnectDialog.java
*
* Created on 20-Jan-2010, 9:37:07 PM
*/
package mage.client.dialog; package mage.client.dialog;
import java.awt.Cursor; import mage.cards.repository.RepositoryUtil;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.Writer;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.client.MageFrame; import mage.client.MageFrame;
import static mage.client.dialog.PreferencesDialog.KEY_CONNECTION_URL_SERVER_LIST; import mage.client.SessionHandler;
import static mage.client.dialog.PreferencesDialog.KEY_CONNECT_AUTO_CONNECT;
import static mage.client.dialog.PreferencesDialog.KEY_CONNECT_FLAG;
import mage.client.preference.MagePreferences; import mage.client.preference.MagePreferences;
import mage.client.util.Config; import mage.client.util.Config;
import mage.client.util.gui.countryBox.CountryItemEditor; import mage.client.util.gui.countryBox.CountryItemEditor;
@ -48,6 +13,20 @@ import mage.remote.Connection;
import mage.utils.StreamUtils; import mage.utils.StreamUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.io.*;
import java.net.*;
import java.util.List;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static mage.client.dialog.PreferencesDialog.*;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
@ -107,8 +86,11 @@ public class ConnectDialog extends MageDialog {
MagePreferences.setServerAddress(serverAddress); MagePreferences.setServerAddress(serverAddress);
MagePreferences.setServerPort(Integer.parseInt(txtPort.getText().trim())); MagePreferences.setServerPort(Integer.parseInt(txtPort.getText().trim()));
MagePreferences.setUserName(serverAddress, txtUserName.getText().trim()); MagePreferences.setUserName(serverAddress, txtUserName.getText().trim());
MagePreferences.setPassword(serverAddress, txtPassword.getText().trim()); MagePreferences.setPassword(serverAddress, String.valueOf(txtPassword.getPassword()).trim());
MageFrame.getPreferences().put(KEY_CONNECT_AUTO_CONNECT, Boolean.toString(chkAutoConnect.isSelected())); MageFrame.getPreferences().put(KEY_CONNECT_AUTO_CONNECT, Boolean.toString(chkAutoConnect.isSelected()));
// last settings for reconnect
MagePreferences.saveLastServer();
} }
/** /**
@ -121,10 +103,6 @@ public class ConnectDialog extends MageDialog {
private void initComponents() { private void initComponents() {
lblServer = new javax.swing.JLabel(); lblServer = new javax.swing.JLabel();
txtServer = new javax.swing.JTextField();
btnFind = new javax.swing.JButton();
lblPort = new javax.swing.JLabel();
txtPort = new javax.swing.JTextField();
lblUserName = new javax.swing.JLabel(); lblUserName = new javax.swing.JLabel();
txtUserName = new javax.swing.JTextField(); txtUserName = new javax.swing.JTextField();
lblPassword = new javax.swing.JLabel(); lblPassword = new javax.swing.JLabel();
@ -138,47 +116,43 @@ public class ConnectDialog extends MageDialog {
lblStatus = new javax.swing.JLabel(); lblStatus = new javax.swing.JLabel();
btnRegister = new javax.swing.JButton(); btnRegister = new javax.swing.JButton();
btnForgotPassword = new javax.swing.JButton(); btnForgotPassword = new javax.swing.JButton();
btnFind1 = new javax.swing.JButton();
btnFind2 = new javax.swing.JButton();
btnFind3 = new javax.swing.JButton();
lblFastConnect = new javax.swing.JLabel(); lblFastConnect = new javax.swing.JLabel();
panelFlag = new javax.swing.JPanel(); panelFlag = new javax.swing.JPanel();
cbFlag = new mage.client.util.gui.countryBox.CountryComboBox(); cbFlag = new mage.client.util.gui.countryBox.CountryComboBox();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(4, 0), new java.awt.Dimension(5, 32767)); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(4, 0), new java.awt.Dimension(5, 32767));
btnFlagSearch = new javax.swing.JButton(); btnFlagSearch = new javax.swing.JButton();
panelFast = new javax.swing.JPanel();
btnFindMain = new javax.swing.JButton();
btnFindLocal = new javax.swing.JButton();
btnFindBeta = new javax.swing.JButton();
btnFindUs = new javax.swing.JButton();
btnFindOther = new javax.swing.JButton();
panelServer = new javax.swing.JPanel();
txtServer = new javax.swing.JTextField();
txtPort = new javax.swing.JTextField();
lblPort = new javax.swing.JLabel();
btnCheckStatus = new javax.swing.JButton();
filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 50), new java.awt.Dimension(0, 50), new java.awt.Dimension(32767, 50));
btnWhatsNew = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setTitle("Connect to server"); setTitle("Connect to server");
setNormalBounds(new java.awt.Rectangle(100, 100, 410, 307));
lblServer.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
lblServer.setLabelFor(txtServer); lblServer.setLabelFor(txtServer);
lblServer.setText("Server:"); lblServer.setText("Server name:");
btnFind.setText("Find...");
btnFind.setToolTipText("Shows the list of public servers");
btnFind.setName("findServerBtn"); // NOI18N
btnFind.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
findPublicServerActionPerformed(evt);
}
});
lblPort.setLabelFor(txtPort);
lblPort.setText("Port:");
txtPort.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
ConnectDialog.this.keyTyped(evt);
}
});
lblUserName.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
lblUserName.setLabelFor(txtUserName); lblUserName.setLabelFor(txtUserName);
lblUserName.setText("User name:"); lblUserName.setText("Username:");
lblPassword.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
lblPassword.setLabelFor(txtPassword); lblPassword.setLabelFor(txtPassword);
lblPassword.setText("Password:"); lblPassword.setText("Password:");
lblFlag.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
lblFlag.setLabelFor(txtUserName); lblFlag.setLabelFor(txtUserName);
lblFlag.setText("User flag:"); lblFlag.setText("User's flag:");
chkAutoConnect.setText("Automatically connect to this server next time"); chkAutoConnect.setText("Automatically connect to this server next time");
chkAutoConnect.setToolTipText("<HTML>If active this connect dialog will not be shown if you choose to connect.<br>\nInstead XMage tries to connect to the last server you were connected to."); chkAutoConnect.setToolTipText("<HTML>If active this connect dialog will not be shown if you choose to connect.<br>\nInstead XMage tries to connect to the last server you were connected to.");
@ -239,55 +213,12 @@ public class ConnectDialog extends MageDialog {
} }
}); });
btnFind1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flags/de.png"))); // NOI18N lblFastConnect.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
btnFind1.setText("X"); lblFastConnect.setLabelFor(btnFindMain);
btnFind1.setToolTipText("Connect to xmage.de (Europe, most popular)"); lblFastConnect.setText("Connect to:");
btnFind1.setActionCommand("connectXmageDe");
btnFind1.setAlignmentY(0.0F);
btnFind1.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFind1.setMaximumSize(new java.awt.Dimension(42, 23));
btnFind1.setMinimumSize(new java.awt.Dimension(42, 23));
btnFind1.setName("connectXmageDeBtn"); // NOI18N
btnFind1.setPreferredSize(new java.awt.Dimension(23, 23));
btnFind1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectXmageDe(evt);
}
});
btnFind2.setText("L");
btnFind2.setToolTipText("Connect to localhost (local server)");
btnFind2.setActionCommand("connectLocalhost");
btnFind2.setAlignmentY(0.0F);
btnFind2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnFind2.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFind2.setName("connectLocalhostBtn"); // NOI18N
btnFind2.setPreferredSize(new java.awt.Dimension(23, 23));
btnFind2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectLocalhost(evt);
}
});
btnFind3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flags/us.png"))); // NOI18N
btnFind3.setText("W");
btnFind3.setToolTipText("Connect to vaporservermtg.com (USA)");
btnFind3.setActionCommand("connectXmageus");
btnFind3.setAlignmentY(0.0F);
btnFind3.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFind3.setName("connectXmageusBtn"); // NOI18N
btnFind3.setPreferredSize(new java.awt.Dimension(23, 23));
btnFind3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectXmageus(evt);
}
});
lblFastConnect.setLabelFor(btnFind1);
lblFastConnect.setText("Fast connect to:");
lblFastConnect.setName(""); // NOI18N lblFastConnect.setName(""); // NOI18N
panelFlag.setPreferredSize(new java.awt.Dimension(189, 30)); panelFlag.setMinimumSize(new java.awt.Dimension(50, 33));
panelFlag.setLayout(new javax.swing.BoxLayout(panelFlag, javax.swing.BoxLayout.LINE_AXIS)); panelFlag.setLayout(new javax.swing.BoxLayout(panelFlag, javax.swing.BoxLayout.LINE_AXIS));
cbFlag.setEditable(true); cbFlag.setEditable(true);
@ -309,109 +240,250 @@ public class ConnectDialog extends MageDialog {
}); });
panelFlag.add(btnFlagSearch); panelFlag.add(btnFlagSearch);
btnFindMain.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flags/de.png"))); // NOI18N
btnFindMain.setText("X");
btnFindMain.setToolTipText("Connect to xmage.de (Europe, most popular, registration needs)");
btnFindMain.setActionCommand("connectXmageDe");
btnFindMain.setAlignmentY(0.0F);
btnFindMain.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFindMain.setMaximumSize(new java.awt.Dimension(42, 23));
btnFindMain.setMinimumSize(new java.awt.Dimension(42, 23));
btnFindMain.setName("connectXmageDeBtn"); // NOI18N
btnFindMain.setPreferredSize(new java.awt.Dimension(23, 23));
btnFindMain.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectXmageDe(evt);
}
});
btnFindLocal.setText("LOCAL, AI");
btnFindLocal.setToolTipText("Connect to localhost, AI enabled (run local server from launcher)");
btnFindLocal.setActionCommand("connectLocalhost");
btnFindLocal.setAlignmentY(0.0F);
btnFindLocal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnFindLocal.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFindLocal.setName("connectLocalhostBtn"); // NOI18N
btnFindLocal.setPreferredSize(new java.awt.Dimension(23, 23));
btnFindLocal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectLocalhost(evt);
}
});
btnFindBeta.setText("BETA, AI");
btnFindBeta.setToolTipText("Connect to BETA server, AI enabled (use any username without registration)");
btnFindBeta.setAlignmentY(0.0F);
btnFindBeta.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnFindBeta.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFindBeta.setPreferredSize(new java.awt.Dimension(23, 23));
btnFindBeta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFindBetaconnectLocalhost(evt);
}
});
btnFindUs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flags/us.png"))); // NOI18N
btnFindUs.setText("P");
btnFindUs.setToolTipText("Connect to mtg.powersofwar.com (USA, use any username without registration)");
btnFindUs.setActionCommand("connectXmageus");
btnFindUs.setAlignmentY(0.0F);
btnFindUs.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFindUs.setName("connectXmageusBtn"); // NOI18N
btnFindUs.setPreferredSize(new java.awt.Dimension(23, 23));
btnFindUs.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectXmageus(evt);
}
});
btnFindOther.setText("Other servers...");
btnFindOther.setToolTipText("Choose server from full servers list");
btnFindOther.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnFindOther.setName("findServerBtn"); // NOI18N
btnFindOther.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
findPublicServerActionPerformed(evt);
}
});
javax.swing.GroupLayout panelFastLayout = new javax.swing.GroupLayout(panelFast);
panelFast.setLayout(panelFastLayout);
panelFastLayout.setHorizontalGroup(
panelFastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelFastLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(btnFindMain, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFindUs, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFindBeta, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFindLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFindOther, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
panelFastLayout.setVerticalGroup(
panelFastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelFastLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(panelFastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnFindMain, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFindLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFindUs, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFindBeta, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFindOther, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, 0))
);
txtPort.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
ConnectDialog.this.keyTyped(evt);
}
});
lblPort.setLabelFor(txtPort);
lblPort.setText("Port:");
btnCheckStatus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flags/world.png"))); // NOI18N
btnCheckStatus.setText("Check online status");
btnCheckStatus.setToolTipText("Go to servers online statuses page");
btnCheckStatus.setAlignmentY(0.0F);
btnCheckStatus.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnCheckStatus.setPreferredSize(new java.awt.Dimension(23, 23));
btnCheckStatus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCheckStatusActionPerformed(evt);
}
});
javax.swing.GroupLayout panelServerLayout = new javax.swing.GroupLayout(panelServer);
panelServer.setLayout(panelServerLayout);
panelServerLayout.setHorizontalGroup(
panelServerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelServerLayout.createSequentialGroup()
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPort)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCheckStatus, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
panelServerLayout.setVerticalGroup(
panelServerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelServerLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(panelServerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPort)
.addComponent(btnCheckStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
btnWhatsNew.setText("Show what's new");
btnWhatsNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnWhatsNewActionPerformed(evt);
}
});
jLabel1.setText("(use empty password for servers without registration)");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29) .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lblPort) .addComponent(lblUserName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblServer))) .addComponent(lblServer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(lblFastConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap() .addComponent(lblPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblFlag))) .addComponent(lblFlag, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup() .addGap(18, 18, 18)
.addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblStatus, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblUserName) .addComponent(chkForceUpdateDB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblPassword, javax.swing.GroupLayout.Alignment.TRAILING)))) .addComponent(chkAutoConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0) .addComponent(txtUserName)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(panelFlag, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(btnConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnRegister, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnRegister, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnForgotPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(btnForgotPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblStatus, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelFast, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chkForceUpdateDB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelServer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jProxySettingsButton) .addComponent(jProxySettingsButton)
.addGap(0, 0, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkAutoConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnWhatsNew)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup()
.addComponent(panelFlag, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtPassword)
.addComponent(txtServer, javax.swing.GroupLayout.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtUserName, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1)))
.addComponent(txtPassword, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
.addComponent(lblFastConnect)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFind1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(filler2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addContainerGap())
.addComponent(btnFind3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFind2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, 0)
.addComponent(btnFind)))
.addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblServer) .addComponent(panelFast, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblFastConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(btnFind)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(panelServer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblServer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(lblPort) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFind1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnFind2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup()
.addComponent(btnFind3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblFastConnect)) .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lblUserName)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtPassword)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1))
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(lblPassword)) .addComponent(filler2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelFlag, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelFlag, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFlag, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblFlag, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkAutoConnect) .addComponent(chkAutoConnect)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkForceUpdateDB) .addComponent(chkForceUpdateDB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jProxySettingsButton) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jProxySettingsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnWhatsNew, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnRegister, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createSequentialGroup()
.addComponent(btnForgotPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(btnRegister, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(btnForgotPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(23, 23, 23)) .addComponent(btnConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(23, 23, 23))
); );
lblFastConnect.getAccessibleContext().setAccessibleName("Fast connect to:");
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -448,16 +520,15 @@ public class ConnectDialog extends MageDialog {
char[] input = new char[0]; char[] input = new char[0];
try { try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
connection = new Connection(); connection = new Connection();
connection.setHost(this.txtServer.getText().trim()); connection.setHost(this.txtServer.getText().trim());
connection.setPort(Integer.valueOf(this.txtPort.getText().trim())); connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
connection.setUsername(this.txtUserName.getText().trim()); connection.setUsername(this.txtUserName.getText().trim());
connection.setPassword(this.txtPassword.getText().trim()); connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected()); connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || RepositoryUtil.isDatabaseEmpty());
String allMAC = ""; String allMAC = "";
try { try {
allMAC = connection.getMAC(); allMAC = Connection.getMAC();
} catch (SocketException ex) { } catch (SocketException ex) {
} }
connection.setUserIdStr(System.getProperty("user.name") + ":" + System.getProperty("os.name") + ":" + MagePreferences.getUserNames() + ":" + allMAC); connection.setUserIdStr(System.getProperty("user.name") + ":" + System.getProperty("os.name") + ":" + MagePreferences.getUserNames() + ":" + allMAC);
@ -476,17 +547,25 @@ public class ConnectDialog extends MageDialog {
}//GEN-LAST:event_btnConnectActionPerformed }//GEN-LAST:event_btnConnectActionPerformed
private void setConnectButtonsState(boolean enable) {
btnConnect.setEnabled(enable);
btnRegister.setEnabled(enable);
btnForgotPassword.setEnabled(enable);
}
private class ConnectTask extends SwingWorker<Boolean, Void> { private class ConnectTask extends SwingWorker<Boolean, Void> {
private boolean result = false; private boolean result = false;
private String lastConnectError = "";
private static final int CONNECTION_TIMEOUT_MS = 2100; private static final int CONNECTION_TIMEOUT_MS = 2100;
@Override @Override
protected Boolean doInBackground() throws Exception { protected Boolean doInBackground() throws Exception {
lblStatus.setText("Connecting..."); lblStatus.setText("Connecting...");
btnConnect.setEnabled(false); setConnectButtonsState(false);
result = MageFrame.connect(connection); result = MageFrame.connect(connection);
lastConnectError = SessionHandler.getLastConnectError();
return result; return result;
} }
@ -494,26 +573,25 @@ public class ConnectDialog extends MageDialog {
protected void done() { protected void done() {
try { try {
get(CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS); get(CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
if (result) { if (result) {
lblStatus.setText(""); lblStatus.setText("");
connected(); connected();
MageFrame.getInstance().prepareAndShowTablesPane(); MageFrame.getInstance().prepareAndShowTablesPane();
} else { } else {
lblStatus.setText("Could not connect"); lblStatus.setText("Could not connect: " + lastConnectError);
} }
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
logger.fatal("Update Players Task error", ex); logger.fatal("Update Players Task error", ex);
} catch (ExecutionException ex) { } catch (ExecutionException ex) {
logger.fatal("Update Players Task error", ex); logger.fatal("Update Players Task error", ex);
} catch (CancellationException ex) { } catch (CancellationException ex) {
logger.info("Connect was canceled"); logger.info("Connect: canceled");
lblStatus.setText("Connect was canceled"); lblStatus.setText("Connect was canceled");
} catch (TimeoutException ex) { } catch (TimeoutException ex) {
logger.fatal("Connection timeout: ", ex); logger.fatal("Connection timeout: ", ex);
} finally { } finally {
MageFrame.stopConnecting(); MageFrame.stopConnecting();
btnConnect.setEnabled(true); setConnectButtonsState(true);
} }
} }
} }
@ -673,8 +751,7 @@ public class ConnectDialog extends MageDialog {
this.txtPort.setText("17171"); this.txtPort.setText("17171");
// Update userName and password according to the chosen server. // Update userName and password according to the chosen server.
this.txtUserName.setText(MagePreferences.getUserName(serverAddress)); this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress)); this.txtPassword.setText(MagePreferences.getPassword(serverAddress)); // TODO add your handling code here:
}//GEN-LAST:event_btnFind1findPublicServerActionPerformed }//GEN-LAST:event_btnFind1findPublicServerActionPerformed
private void connectLocalhost(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFind2findPublicServerActionPerformed private void connectLocalhost(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFind2findPublicServerActionPerformed
@ -688,7 +765,16 @@ public class ConnectDialog extends MageDialog {
}//GEN-LAST:event_btnFind2findPublicServerActionPerformed }//GEN-LAST:event_btnFind2findPublicServerActionPerformed
private void connectXmageus(java.awt.event.ActionEvent evt) { private void connectXmageus(java.awt.event.ActionEvent evt) {
String serverAddress = "vapormtgserver.com"; String serverAddress = "mtg.powersofwar.com";
this.txtServer.setText(serverAddress);
this.txtPort.setText("17171");
// Update userName and password according to the chosen server.
this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress));
}
private void connectBeta(java.awt.event.ActionEvent evt) {
String serverAddress = "xmage.today";
this.txtServer.setText(serverAddress); this.txtServer.setText(serverAddress);
this.txtPort.setText("17171"); this.txtPort.setText("17171");
// Update userName and password according to the chosen server. // Update userName and password according to the chosen server.
@ -700,6 +786,24 @@ public class ConnectDialog extends MageDialog {
doFastFlagSearch(); doFastFlagSearch();
}//GEN-LAST:event_btnFlagSearchActionPerformed }//GEN-LAST:event_btnFlagSearchActionPerformed
private void btnFindBetaconnectLocalhost(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFindBetaconnectLocalhost
connectBeta(evt);
}//GEN-LAST:event_btnFindBetaconnectLocalhost
private void btnCheckStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckStatusActionPerformed
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
try {
Desktop.getDesktop().browse(new URI("http://xmageservers.online/"));
} catch (Exception e) {
//
}
}
}//GEN-LAST:event_btnCheckStatusActionPerformed
private void btnWhatsNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWhatsNewActionPerformed
MageFrame.getInstance().showWhatsNewDialog(true);
}//GEN-LAST:event_btnWhatsNewActionPerformed
private void doFastFlagSearch() { private void doFastFlagSearch() {
Choice choice = new ChoiceImpl(false); Choice choice = new ChoiceImpl(false);
@ -745,18 +849,23 @@ public class ConnectDialog extends MageDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel; private javax.swing.JButton btnCancel;
private javax.swing.JButton btnCheckStatus;
private javax.swing.JButton btnConnect; private javax.swing.JButton btnConnect;
private javax.swing.JButton btnFind; private javax.swing.JButton btnFindBeta;
private javax.swing.JButton btnFind1; private javax.swing.JButton btnFindLocal;
private javax.swing.JButton btnFind2; private javax.swing.JButton btnFindMain;
private javax.swing.JButton btnFind3; private javax.swing.JButton btnFindOther;
private javax.swing.JButton btnFindUs;
private javax.swing.JButton btnFlagSearch; private javax.swing.JButton btnFlagSearch;
private javax.swing.JButton btnForgotPassword; private javax.swing.JButton btnForgotPassword;
private javax.swing.JButton btnRegister; private javax.swing.JButton btnRegister;
private javax.swing.JButton btnWhatsNew;
private mage.client.util.gui.countryBox.CountryComboBox cbFlag; private mage.client.util.gui.countryBox.CountryComboBox cbFlag;
private javax.swing.JCheckBox chkAutoConnect; private javax.swing.JCheckBox chkAutoConnect;
private javax.swing.JCheckBox chkForceUpdateDB; private javax.swing.JCheckBox chkForceUpdateDB;
private javax.swing.Box.Filler filler1; private javax.swing.Box.Filler filler1;
private javax.swing.Box.Filler filler2;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton jProxySettingsButton; private javax.swing.JButton jProxySettingsButton;
private javax.swing.JLabel lblFastConnect; private javax.swing.JLabel lblFastConnect;
private javax.swing.JLabel lblFlag; private javax.swing.JLabel lblFlag;
@ -765,7 +874,9 @@ public class ConnectDialog extends MageDialog {
private javax.swing.JLabel lblServer; private javax.swing.JLabel lblServer;
private javax.swing.JLabel lblStatus; private javax.swing.JLabel lblStatus;
private javax.swing.JLabel lblUserName; private javax.swing.JLabel lblUserName;
private javax.swing.JPanel panelFast;
private javax.swing.JPanel panelFlag; private javax.swing.JPanel panelFlag;
private javax.swing.JPanel panelServer;
private javax.swing.JPasswordField txtPassword; private javax.swing.JPasswordField txtPassword;
private javax.swing.JTextField txtPort; private javax.swing.JTextField txtPort;
private javax.swing.JTextField txtServer; private javax.swing.JTextField txtServer;

View file

@ -0,0 +1,560 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="title" type="java.lang.String" value="Downloading images"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[600, 400]"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,73,0,0,2,65"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelGlobal">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
<SubComponents>
<Component class="javax.swing.Box$Filler" name="fillerGlobal1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 5]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="labelGlobal">
<Properties>
<Property name="text" type="java.lang.String" value="Initializing image download..."/>
<Property name="alignmentX" type="float" value="0.5"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStop">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
<Property name="alignmentX" type="float" value="0.5"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[65, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStopActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.Box$Filler" name="fillerglobal2">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 5]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JTabbedPane" name="tabsList">
<Properties>
<Property name="tabLayoutPolicy" type="int" value="1"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="tabMain">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Standard download">
<Property name="tabTitle" type="java.lang.String" value="Standard download"/>
<Property name="tabIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/card_panel.png"/>
</Property>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelInfo">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
<SubComponents>
<Component class="javax.swing.Box$Filler" name="fillerInfo1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 5]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="labelInfo">
<Properties>
<Property name="text" type="java.lang.String" value="Missing stats: 12345 card images / 789 token images"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="7" right="0" top="0"/>
</Border>
</Property>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="fillerInfo2">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 5]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelSource">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[65536, 55]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[352, 55]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[593, 55]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="0"/>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelSourceLeft">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[430, 30]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="3"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="labelSource">
<Properties>
<Property name="text" type="java.lang.String" value="Images source to download:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboSource">
<Properties>
<Property name="maximumRowCount" type="int" value="15"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 25]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelSourceRight">
<Properties>
<Property name="alignmentX" type="float" value="0.0"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 30]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 100]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="3"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="labelLanguage">
<Properties>
<Property name="text" type="java.lang.String" value="Language:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboLanguage">
<Properties>
<Property name="maximumRowCount" type="int" value="15"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[90, 25]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelMode">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32869, 55]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[322, 55]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 55]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelModeInner">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[430, 43]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="0"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="labelMode">
<Properties>
<Property name="text" type="java.lang.String" value="Sets to download:"/>
<Property name="alignmentY" type="float" value="0.0"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelModeSelect">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="0"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="comboSets">
<Properties>
<Property name="maximumRowCount" type="int" value="15"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[373, 25]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.Box$Filler" name="fillerMode1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 0]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="buttonSearchSet">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/search_24.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Fast search your flag"/>
<Property name="alignmentX" type="float" value="1.0"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[25, 25]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSearchSetActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelRedownload">
<Properties>
<Property name="alignmentX" type="float" value="0.0"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 30]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 100]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="checkboxRedownload">
<Properties>
<Property name="text" type="java.lang.String" value="&lt;html&gt;Re-download selected images"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 5]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 5]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 3]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.Box$Filler" name="fillerMain1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 10]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 10]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 10]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.VerticalStrut"/>
</AuxValues>
</Component>
<Container class="javax.swing.JPanel" name="panelProgress">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32777, 30]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 30]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[564, 30]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="0"/>
</Layout>
<SubComponents>
<Component class="javax.swing.Box$Filler" name="fillerProgress1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 0]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JProgressBar" name="progress">
<Properties>
<Property name="value" type="int" value="75"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 25]"/>
</Property>
<Property name="string" type="java.lang.String" value="123 of 12313 (120 cards/546 tokens) image downloads finished! Please wait! [123 Mb]"/>
<Property name="stringPainted" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="fillerProgress2">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 0]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[5, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.Box$Filler" name="fillerMain2">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 32767]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.Glue"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="tabCustom">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Custom download">
<Property name="tabTitle" type="java.lang.String" value="Custom download"/>
<Property name="tabIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/buttons/list_panel.png"/>
</Property>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelCommands">
<Properties>
<Property name="alignmentX" type="float" value="0.0"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="4"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonOK">
<Properties>
<Property name="text" type="java.lang.String" value="Start download"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[120, 30]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="getRootPane().setDefaultButton(buttonOK);"/>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="DownloadImagesDialog_buttonOK"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 30]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -0,0 +1,470 @@
package mage.client.dialog;
import mage.client.MageFrame;
import mage.client.util.gui.FastSearchUtil;
import mage.client.util.gui.MageDialogState;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
/**
* @author JayDi85
*/
public class DownloadImagesDialog extends MageDialog {
public static final int RET_CANCEL = 0;
public static final int RET_OK = 1;
private Dimension sizeModeMessageOnly;
private Dimension sizeModeMessageAndControls;
private Map<Component, Boolean> actionsControlStates = new HashMap<>();
/**
* Creates new form DownloadImagesDialog
*/
public DownloadImagesDialog() {
initComponents();
this.setModal(true);
// fix for panelInfo (it's resets aligmentX after netbeans designer opened)
panelInfo.setAlignmentX(CENTER_ALIGNMENT);
// save default sizes
//
this.sizeModeMessageAndControls = new Dimension(580, 330); // dialog -> properties -> designer size
//
this.sizeModeMessageOnly = new Dimension(this.sizeModeMessageAndControls.getSize());
sizeModeMessageOnly.height = 25 * 4;
sizeModeMessageOnly.width = sizeModeMessageOnly.width / 2;
// Close the dialog when Esc is pressed
String cancelName = "cancel";
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
ActionMap actionMap = getRootPane().getActionMap();
actionMap.put(cancelName, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
doClose(RET_CANCEL);
}
});
}
public void setWindowSize(int width, int heigth) {
this.setSize(new Dimension(width, heigth));
}
public void showDialog() {
showDialog(null);
}
public void showDialog(MageDialogState mageDialogState) {
// window settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
if (mageDialogState != null) mageDialogState.setStateToDialog(this);
else this.makeWindowCentered();
showDownloadControls(false); // call to change window size
this.setVisible(true);
}
public void setGlobalInfo(String info) {
this.labelGlobal.setText(info);
}
public void setCurrentInfo(String info) {
this.labelInfo.setText(info);
}
public JComboBox getSourcesCombo() {
return this.comboSource;
}
public JComboBox getLaunguagesCombo() {
return this.comboLanguage;
}
public JComboBox getSetsCombo() {
return this.comboSets;
}
public JButton getStartButton() {
return this.buttonOK;
}
public JButton getCancelButton() {
return this.buttonCancel;
}
public JButton getStopButton() {
return this.buttonStop;
}
public JProgressBar getProgressBar() {
return this.progress;
}
public JCheckBox getRedownloadCheckbox() {
return this.checkboxRedownload;
}
public void showLanguagesSupport(boolean haveSupport) {
labelLanguage.setEnabled(haveSupport);
comboLanguage.setEnabled(haveSupport);
}
private void enableActionControl(boolean enable, Component comp) {
if (enable) {
// restore last enable state
comp.setEnabled(actionsControlStates.getOrDefault(comp, true));
} else {
// save enable state and disable it
actionsControlStates.putIfAbsent(comp, comp.isEnabled());
comp.setEnabled(false);
}
}
public void enableActionControls(boolean enable) {
// restrict user actions while downloading/processing (all buttons, comboboxes and edits)
enableActionControl(enable, tabsList);
enableActionControl(enable, comboSource);
enableActionControl(enable, comboSets);
enableActionControl(enable, buttonSearchSet);
enableActionControl(enable, comboLanguage);
enableActionControl(enable, checkboxRedownload);
}
private void setTabTitle(int tabIndex, String title, String iconResourceName) {
// tab caption with left sided icon
// https://stackoverflow.com/questions/1782224/jtabbedpane-icon-on-left-side-of-tabs
JLabel lbl = new JLabel(title);
Icon icon = new ImageIcon(getClass().getResource(iconResourceName));
lbl.setIcon(icon);
lbl.setIconTextGap(5);
lbl.setHorizontalTextPosition(SwingConstants.RIGHT);
tabsList.setTabComponentAt(tabIndex, lbl);
}
public void showDownloadControls(boolean needToShow) {
// 2 modes:
// - only message;
// - message + download controls and buttons
this.panelGlobal.setVisible(true);
this.buttonStop.setVisible(!needToShow); // stop button only for loading mode
this.tabsList.setVisible(needToShow);
this.panelCommands.setVisible(needToShow);
// auto-size form
if (needToShow) {
this.setWindowSize(this.sizeModeMessageAndControls.width, this.sizeModeMessageAndControls.height);
} else {
this.setWindowSize(this.sizeModeMessageOnly.width, this.sizeModeMessageOnly.height);
}
this.makeWindowCentered();
//this.setLocationRelativeTo(null); // center screen //FIX
// icons on tabs left side
setTabTitle(0, "Standard download", "/buttons/card_panel.png");
setTabTitle(1, "Custom download", "/buttons/list_panel.png");
// TODO: add manual mode as tab
this.tabsList.getTabComponentAt(1).setEnabled(false);
this.tabsList.setEnabledAt(1, false);
}
/**
* @return the return status of this dialog - one of RET_OK or RET_CANCEL
*/
public int getReturnStatus() {
return returnStatus;
}
/**
* 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
private void initComponents() {
panelGlobal = new javax.swing.JPanel();
fillerGlobal1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
labelGlobal = new javax.swing.JLabel();
buttonStop = new javax.swing.JButton();
fillerglobal2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
tabsList = new javax.swing.JTabbedPane();
tabMain = new javax.swing.JPanel();
panelInfo = new javax.swing.JPanel();
fillerInfo1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
labelInfo = new javax.swing.JLabel();
fillerInfo2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
panelSource = new javax.swing.JPanel();
panelSourceLeft = new javax.swing.JPanel();
labelSource = new javax.swing.JLabel();
comboSource = new javax.swing.JComboBox<>();
panelSourceRight = new javax.swing.JPanel();
labelLanguage = new javax.swing.JLabel();
comboLanguage = new javax.swing.JComboBox<>();
panelMode = new javax.swing.JPanel();
panelModeInner = new javax.swing.JPanel();
labelMode = new javax.swing.JLabel();
panelModeSelect = new javax.swing.JPanel();
comboSets = new javax.swing.JComboBox<>();
fillerMode1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
buttonSearchSet = new javax.swing.JButton();
panelRedownload = new javax.swing.JPanel();
checkboxRedownload = new javax.swing.JCheckBox();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 3), new java.awt.Dimension(32767, 5));
fillerMain1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(32767, 10));
panelProgress = new javax.swing.JPanel();
fillerProgress1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
progress = new javax.swing.JProgressBar();
fillerProgress2 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
fillerMain2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767));
tabCustom = new javax.swing.JPanel();
panelCommands = new javax.swing.JPanel();
buttonOK = new javax.swing.JButton();
buttonCancel = new javax.swing.JButton();
setTitle("Downloading images");
setPreferredSize(new java.awt.Dimension(600, 400));
getContentPane().setLayout(new java.awt.BorderLayout());
panelGlobal.setLayout(new javax.swing.BoxLayout(panelGlobal, javax.swing.BoxLayout.Y_AXIS));
panelGlobal.add(fillerGlobal1);
labelGlobal.setText("Initializing image download...");
labelGlobal.setAlignmentX(0.5F);
panelGlobal.add(labelGlobal);
buttonStop.setText("Cancel");
buttonStop.setAlignmentX(0.5F);
buttonStop.setPreferredSize(new java.awt.Dimension(65, 30));
buttonStop.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStopActionPerformed(evt);
}
});
panelGlobal.add(buttonStop);
panelGlobal.add(fillerglobal2);
getContentPane().add(panelGlobal, java.awt.BorderLayout.NORTH);
tabsList.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
tabMain.setLayout(new javax.swing.BoxLayout(tabMain, javax.swing.BoxLayout.Y_AXIS));
panelInfo.setLayout(new javax.swing.BoxLayout(panelInfo, javax.swing.BoxLayout.Y_AXIS));
panelInfo.add(fillerInfo1);
labelInfo.setText("Missing stats: 12345 card images / 789 token images");
labelInfo.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 7, 0, 0));
panelInfo.add(labelInfo);
panelInfo.add(fillerInfo2);
tabMain.add(panelInfo);
panelSource.setMaximumSize(new java.awt.Dimension(65536, 55));
panelSource.setMinimumSize(new java.awt.Dimension(352, 55));
panelSource.setPreferredSize(new java.awt.Dimension(593, 55));
panelSource.setLayout(new javax.swing.BoxLayout(panelSource, javax.swing.BoxLayout.X_AXIS));
panelSourceLeft.setMinimumSize(new java.awt.Dimension(430, 30));
panelSourceLeft.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
labelSource.setText("Images source to download:");
panelSourceLeft.add(labelSource);
comboSource.setMaximumRowCount(15);
comboSource.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
comboSource.setMinimumSize(new java.awt.Dimension(300, 20));
comboSource.setPreferredSize(new java.awt.Dimension(400, 25));
panelSourceLeft.add(comboSource);
panelSource.add(panelSourceLeft);
panelSourceRight.setAlignmentX(0.0F);
panelSourceRight.setMaximumSize(new java.awt.Dimension(130, 32767));
panelSourceRight.setMinimumSize(new java.awt.Dimension(130, 30));
panelSourceRight.setPreferredSize(new java.awt.Dimension(130, 100));
panelSourceRight.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
labelLanguage.setText("Language:");
panelSourceRight.add(labelLanguage);
comboLanguage.setMaximumRowCount(15);
comboLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
comboLanguage.setPreferredSize(new java.awt.Dimension(90, 25));
panelSourceRight.add(comboLanguage);
panelSource.add(panelSourceRight);
tabMain.add(panelSource);
panelMode.setMaximumSize(new java.awt.Dimension(32869, 55));
panelMode.setMinimumSize(new java.awt.Dimension(322, 55));
panelMode.setPreferredSize(new java.awt.Dimension(100, 55));
panelMode.setLayout(new javax.swing.BoxLayout(panelMode, javax.swing.BoxLayout.LINE_AXIS));
panelModeInner.setMinimumSize(new java.awt.Dimension(430, 43));
panelModeInner.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
labelMode.setText("Sets to download:");
labelMode.setAlignmentY(0.0F);
panelModeInner.add(labelMode);
panelModeSelect.setLayout(new javax.swing.BoxLayout(panelModeSelect, javax.swing.BoxLayout.X_AXIS));
comboSets.setMaximumRowCount(15);
comboSets.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
comboSets.setPreferredSize(new java.awt.Dimension(373, 25));
panelModeSelect.add(comboSets);
panelModeSelect.add(fillerMode1);
buttonSearchSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png"))); // NOI18N
buttonSearchSet.setToolTipText("Fast search your flag");
buttonSearchSet.setAlignmentX(1.0F);
buttonSearchSet.setPreferredSize(new java.awt.Dimension(25, 25));
buttonSearchSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSearchSetActionPerformed(evt);
}
});
panelModeSelect.add(buttonSearchSet);
panelModeInner.add(panelModeSelect);
panelMode.add(panelModeInner);
panelRedownload.setAlignmentX(0.0F);
panelRedownload.setMaximumSize(new java.awt.Dimension(130, 32767));
panelRedownload.setMinimumSize(new java.awt.Dimension(130, 30));
panelRedownload.setPreferredSize(new java.awt.Dimension(130, 100));
panelRedownload.setLayout(new java.awt.BorderLayout());
checkboxRedownload.setText("<html>Re-download selected images");
checkboxRedownload.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
panelRedownload.add(checkboxRedownload, java.awt.BorderLayout.CENTER);
panelRedownload.add(filler1, java.awt.BorderLayout.PAGE_END);
panelMode.add(panelRedownload);
tabMain.add(panelMode);
tabMain.add(fillerMain1);
panelProgress.setMaximumSize(new java.awt.Dimension(32777, 30));
panelProgress.setMinimumSize(new java.awt.Dimension(20, 30));
panelProgress.setPreferredSize(new java.awt.Dimension(564, 30));
panelProgress.setLayout(new javax.swing.BoxLayout(panelProgress, javax.swing.BoxLayout.X_AXIS));
panelProgress.add(fillerProgress1);
progress.setValue(75);
progress.setMaximumSize(new java.awt.Dimension(32767, 25));
progress.setString("123 of 12313 (120 cards/546 tokens) image downloads finished! Please wait! [123 Mb]");
progress.setStringPainted(true);
panelProgress.add(progress);
panelProgress.add(fillerProgress2);
tabMain.add(panelProgress);
tabMain.add(fillerMain2);
tabsList.addTab("Standard download", new javax.swing.ImageIcon(getClass().getResource("/buttons/card_panel.png")), tabMain); // NOI18N
tabCustom.setLayout(new javax.swing.BoxLayout(tabCustom, javax.swing.BoxLayout.Y_AXIS));
tabsList.addTab("Custom download", new javax.swing.ImageIcon(getClass().getResource("/buttons/list_panel.png")), tabCustom); // NOI18N
getContentPane().add(tabsList, java.awt.BorderLayout.CENTER);
panelCommands.setAlignmentX(0.0F);
panelCommands.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.TRAILING));
buttonOK.setText("Start download");
buttonOK.setPreferredSize(new java.awt.Dimension(120, 30));
panelCommands.add(buttonOK);
getRootPane().setDefaultButton(buttonOK);
buttonCancel.setText("Cancel");
buttonCancel.setPreferredSize(new java.awt.Dimension(80, 30));
panelCommands.add(buttonCancel);
getContentPane().add(panelCommands, java.awt.BorderLayout.SOUTH);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* Closes the dialog
*/
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
doClose(RET_CANCEL);
}//GEN-LAST:event_closeDialog
private void buttonSearchSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSearchSetActionPerformed
FastSearchUtil.showFastSearchForStringComboBox(comboSets, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE, 400, 500);
}//GEN-LAST:event_buttonSearchSetActionPerformed
private void buttonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_buttonStopActionPerformed
private void doClose(int retStatus) {
returnStatus = retStatus;
setVisible(false);
dispose();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonOK;
private javax.swing.JButton buttonSearchSet;
private javax.swing.JButton buttonStop;
private javax.swing.JCheckBox checkboxRedownload;
private javax.swing.JComboBox<String> comboLanguage;
private javax.swing.JComboBox<String> comboSets;
private javax.swing.JComboBox<String> comboSource;
private javax.swing.Box.Filler filler1;
private javax.swing.Box.Filler fillerGlobal1;
private javax.swing.Box.Filler fillerInfo1;
private javax.swing.Box.Filler fillerInfo2;
private javax.swing.Box.Filler fillerMain1;
private javax.swing.Box.Filler fillerMain2;
private javax.swing.Box.Filler fillerMode1;
private javax.swing.Box.Filler fillerProgress1;
private javax.swing.Box.Filler fillerProgress2;
private javax.swing.Box.Filler fillerglobal2;
private javax.swing.JLabel labelGlobal;
private javax.swing.JLabel labelInfo;
private javax.swing.JLabel labelLanguage;
private javax.swing.JLabel labelMode;
private javax.swing.JLabel labelSource;
private javax.swing.JPanel panelCommands;
private javax.swing.JPanel panelGlobal;
private javax.swing.JPanel panelInfo;
private javax.swing.JPanel panelMode;
private javax.swing.JPanel panelModeInner;
private javax.swing.JPanel panelModeSelect;
private javax.swing.JPanel panelProgress;
private javax.swing.JPanel panelRedownload;
private javax.swing.JPanel panelSource;
private javax.swing.JPanel panelSourceLeft;
private javax.swing.JPanel panelSourceRight;
private javax.swing.JProgressBar progress;
private javax.swing.JPanel tabCustom;
private javax.swing.JPanel tabMain;
private javax.swing.JTabbedPane tabsList;
// End of variables declaration//GEN-END:variables
private int returnStatus = RET_CANCEL;
}

View file

@ -1,7 +1,7 @@
package mage.client.dialog; package mage.client.dialog;
import mage.cards.decks.importer.DeckImporterUtil; import mage.cards.decks.importer.DeckImporter;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.SessionHandler; import mage.client.SessionHandler;
import mage.players.PlayerType; import mage.players.PlayerType;
@ -119,9 +119,9 @@ public class JoinTableDialog extends MageDialog {
try { try {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
if (isTournament) { if (isTournament) {
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText()); joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporter.importDeckFromFile(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
} else { } else {
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText()); joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporter.importDeckFromFile(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
} }
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -1,32 +1,20 @@
/*
* MageDialog.java
*
* Created on 15-Dec-2009, 10:28:27 PM
*/
package mage.client.dialog; package mage.client.dialog;
import java.awt.AWTEvent; import mage.client.MageFrame;
import java.awt.ActiveEvent; import mage.client.util.SettingsManager;
import java.awt.Component; import mage.client.util.gui.GuiDisplayUtil;
import java.awt.EventQueue; import org.apache.log4j.Logger;
import java.awt.KeyboardFocusManager;
import java.awt.MenuComponent; import javax.swing.*;
import java.awt.TrayIcon; import java.awt.*;
import java.awt.event.InvocationEvent; import java.awt.event.InvocationEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.*;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
/** /**
* * @author BetaSteward_at_googlemail.com, JayDi85
* @author BetaSteward_at_googlemail.com
*/ */
public class MageDialog extends javax.swing.JInternalFrame { public class MageDialog extends javax.swing.JInternalFrame {
@ -45,6 +33,34 @@ public class MageDialog extends javax.swing.JInternalFrame {
} }
public static boolean isModalDialogActivated() {
for (JInternalFrame frame : MageFrame.getDesktop().getAllFrames()) {
if (frame instanceof MageDialog) {
MageDialog md = (MageDialog) frame;
if (md.isVisible() && md.isModal()) {
return true;
}
}
}
return false;
}
public static void printFramesOrder(String name) {
///*
JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames();
System.out.println("--- " + name + " ---");
int order = 0;
for (JInternalFrame frame : frames) {
order++;
int zorder = -1;
if (frame.getParent() != null) {
zorder = frame.getParent().getComponentZOrder(frame);
}
System.out.println(order + ". " + frame.getClass() + " (" + frame.getTitle() + ") : layer = " + frame.getLayer() + ", zorder = " + zorder);
}
//*/
}
@Override @Override
public void show() { public void show() {
super.show(); super.show();
@ -57,17 +73,6 @@ public class MageDialog extends javax.swing.JInternalFrame {
// - JLayeredPane.MODAL_LAYER: all modal dialogs (user required actions - select cards in game, new game window, error windows) // - JLayeredPane.MODAL_LAYER: all modal dialogs (user required actions - select cards in game, new game window, error windows)
// - JLayeredPane.POPUP_LAYER: hints and other top level graphics // - JLayeredPane.POPUP_LAYER: hints and other top level graphics
// - JLayeredPane.DRAG_LAYER: top most layer for critical actions and user controls // - JLayeredPane.DRAG_LAYER: top most layer for critical actions and user controls
/*
JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames();
System.out.println("---");
for(JInternalFrame frame: frames){
int zorder = -1;
if (frame.getParent() != null){
frame.getParent().getComponentZOrder(frame);
}
System.out.println(frame.getClass() + " (" + frame.getTitle() + ") : layer = " + frame.getLayer() + ", zorder = " + zorder);
}
*/
if (modal) { if (modal) {
this.setClosable(false); this.setClosable(false);
@ -75,7 +80,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
this.toFront(); this.toFront();
if (modal){ if (modal) {
startModal(); startModal();
} }
} }
@ -83,9 +88,16 @@ public class MageDialog extends javax.swing.JInternalFrame {
@Override @Override
public void setVisible(boolean value) { public void setVisible(boolean value) {
super.setVisible(value); super.setVisible(value);
if (value) { if (value) {
this.toFront(); this.toFront();
try {
this.setSelected(true);
} catch (PropertyVetoException e) {
//
}
} }
if (modal) { if (modal) {
this.setClosable(false); this.setClosable(false);
if (value) { if (value) {
@ -97,6 +109,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
SwingUtilities.invokeAndWait(() -> stopModal()); SwingUtilities.invokeAndWait(() -> stopModal());
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
LOGGER.fatal("MageDialog error", ex); LOGGER.fatal("MageDialog error", ex);
Thread.currentThread().interrupt();
} catch (InvocationTargetException ex) { } catch (InvocationTargetException ex) {
LOGGER.fatal("MageDialog error", ex); LOGGER.fatal("MageDialog error", ex);
} }
@ -105,6 +118,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
} }
private synchronized void startModal() { private synchronized void startModal() {
// modal loop -- all mouse events must be ignored by other windows
try { try {
if (SwingUtilities.isEventDispatchThread()) { if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = getToolkit().getSystemEventQueue(); EventQueue theQueue = getToolkit().getSystemEventQueue();
@ -115,18 +129,47 @@ public class MageDialog extends javax.swing.JInternalFrame {
// https://github.com/magefree/mage/issues/584 - Let's hope this will fix the Linux window problem // https://github.com/magefree/mage/issues/584 - Let's hope this will fix the Linux window problem
if (event.getSource() != null && event.getSource() instanceof TrayIcon && !(event instanceof InvocationEvent)) { if (event.getSource() != null && event.getSource() instanceof TrayIcon && !(event instanceof InvocationEvent)) {
return; dispatch = false;
//return; // JayDi85: users can move mouse over try icon to disable modal mode (it's a bug but can be used in the future)
} }
// ignore mouse events outside from panel, only drag and move allowed -- as example:
// combobox's popup will be selectable outside
// cards and button hints will be works
Component popupComponent = null;
MouseEvent popupEvent = null;
if (event instanceof MouseEvent && event.getSource() instanceof Component) { if (event instanceof MouseEvent && event.getSource() instanceof Component) {
MouseEvent e = (MouseEvent) event; MouseEvent e = (MouseEvent) event;
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this); MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
dispatch = false; // disable all outer events (except some actions)
if (!this.contains(m.getPoint())) {
boolean allowedEvent = false;
// need any mouse move (for hints)
if (e.getID() == MouseEvent.MOUSE_DRAGGED || e.getID() == MouseEvent.MOUSE_MOVED) {
allowedEvent = true;
}
// need popup clicks and mouse wheel (for out of bound actions)
if (!allowedEvent) {
popupComponent = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); // show root component (popups creates at root)
if (popupComponent != null && (popupComponent.getClass().getName().contains("BasicComboPopup")
|| popupComponent.getClass().getName().contains("JMenuItem"))) {
popupEvent = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, popupComponent);
allowedEvent = true;
}
}
dispatch = allowedEvent;
} }
} }
if (dispatch) { if (dispatch) {
if (event instanceof ActiveEvent) { if (popupEvent != null) {
// process outer popup events, it's must be FIRST check
popupComponent.dispatchEvent(popupEvent);
} else if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch(); ((ActiveEvent) event).dispatch();
} else if (source instanceof Component) { } else if (source instanceof Component) {
((Component) source).dispatchEvent(event); ((Component) source).dispatchEvent(event);
@ -142,9 +185,10 @@ public class MageDialog extends javax.swing.JInternalFrame {
wait(); wait();
} }
} }
} catch (InterruptedException ignored) { } catch (InterruptedException e) {
LOGGER.fatal("MageDialog error", e);
Thread.currentThread().interrupt();
} }
} }
private synchronized void stopModal() { private synchronized void stopModal() {
@ -174,14 +218,21 @@ public class MageDialog extends javax.swing.JInternalFrame {
java.util.logging.Logger.getLogger(MageDialog.class.getName()).log(Level.SEVERE, "setClosed(false) failed", ex); java.util.logging.Logger.getLogger(MageDialog.class.getName()).log(Level.SEVERE, "setClosed(false) failed", ex);
} }
MageFrame.getDesktop().remove(this); MageFrame.getDesktop().remove(this);
}
public void makeWindowCentered() {
makeWindowCentered(this, this.getWidth(), this.getHeight());
}
public static void makeWindowCentered(Component component, int width, int height) {
Point centered = SettingsManager.instance.getComponentPosition(width, height);
component.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, component);
} }
/** /**
* Used to set a tooltip text on icon and titel bar * Used to set a tooltip text on icon and titel bar
* *
* used in {@link ExileZoneDialog} and {@link ShowCardsDialog}
*
* @param text * @param text
*/ */
public void setTitelBarToolTip(final String text) { public void setTitelBarToolTip(final String text) {
@ -209,12 +260,12 @@ public class MageDialog extends javax.swing.JInternalFrame {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 394, Short.MAX_VALUE) .addGap(0, 394, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 274, Short.MAX_VALUE) .addGap(0, 274, Short.MAX_VALUE)
); );
pack(); pack();

View file

@ -1,6 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents>
<Container class="javax.swing.JPopupMenu" name="popupSaveSettings">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuSaveSettings1">
<Properties>
<Property name="text" type="java.lang.String" value="Save to config 1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuSaveSettings1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuSaveSettings2">
<Properties>
<Property name="text" type="java.lang.String" value="Save to config 2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuSaveSettings2ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Container>
<Container class="javax.swing.JPopupMenu" name="popupLoadSettings">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettingsLast">
<Properties>
<Property name="text" type="java.lang.String" value="Load from last time"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettingsLastActionPerformed"/>
</Events>
</MenuItem>
<Component class="javax.swing.JPopupMenu$Separator" name="separator1">
</Component>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettings1">
<Properties>
<Property name="text" type="java.lang.String" value="Load from config 1"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettings1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettings2">
<Properties>
<Property name="text" type="java.lang.String" value="Load from config 2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettings2ActionPerformed"/>
</Events>
</MenuItem>
<Component class="javax.swing.JPopupMenu$Separator" name="separator2">
</Component>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettingsDefault">
<Properties>
<Property name="text" type="java.lang.String" value="Load default settings"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettingsDefaultActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Container>
</NonVisualComponents>
<Properties> <Properties>
<Property name="title" type="java.lang.String" value="New Table"/> <Property name="title" type="java.lang.String" value="New Table"/>
</Properties> </Properties>
@ -25,104 +98,123 @@
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblName" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="cbGameType" min="-2" pref="270" max="-2" attributes="1"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="chkRollbackTurnsAllowed" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="50" max="-2" attributes="0"/>
<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"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbTimeLimit" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTimeLimit" min="-2" pref="102" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPassword" min="-2" pref="125" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration1" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration2" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="cbDeckType" min="-2" pref="332" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblQuitRatio" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnQuitRatio" min="-2" pref="60" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblEdhPowerLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnEdhPowerLevel" min="-2" pref="60" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <Component id="lblSettings" min="-2" max="-2" attributes="0"/>
<Component id="btnOK" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="btnSettingsLoad" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="1"/>
<Component id="cbRange" min="-2" pref="117" max="-2" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="btnSettingsSave" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0"> <EmptySpace max="32767" attributes="0"/>
<Component id="lblAttack" min="-2" max="-2" attributes="0"/> <Component id="btnOK" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="116" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblSkillLevel" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="cbAttackOption" min="-2" pref="177" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbSkillLevel" min="-2" pref="148" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" alignment="0" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<Component id="jSeparator2" alignment="1" max="32767" attributes="0"/> <Component id="jSeparator2" alignment="1" max="32767" attributes="0"/>
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/> <Component id="player1Panel" alignment="0" pref="863" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" alignment="1" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" alignment="1" max="32767" attributes="0"/>
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/> <Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblName" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="txtName" min="-2" pref="178" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbTimeLimit" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTimeLimit" min="-2" pref="102" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPassword" min="-2" pref="109" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkSpectatorsAllowed" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="cbDeckType" max="32767" attributes="1"/>
<Component id="cbGameType" pref="270" max="32767" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="chkRollbackTurnsAllowed" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="chkRated" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblMinimumRating" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnMinimumRating" min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblQuitRatio" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnQuitRatio" min="-2" pref="60" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblEdhPowerLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnEdhPowerLevel" min="-2" pref="60" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</Group>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="1"/>
<Component id="cbRange" min="-2" pref="117" max="-2" attributes="1"/>
</Group>
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbAttackOption" alignment="0" min="-2" pref="177" max="-2" attributes="0"/>
<Component id="lblAttack" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbSkillLevel" alignment="0" min="-2" pref="102" max="-2" attributes="0"/>
<Component id="lblSkillLevel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" alignment="0" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblMullgian" min="-2" max="-2" attributes="0"/>
<Component id="cbMulligan" min="-2" pref="149" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="spnFreeMulligans" min="-2" pref="72" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkPlaneChase" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator3" pref="660" max="32767" attributes="0"/> <Component id="jSeparator3" pref="863" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -131,66 +223,80 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/> <EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtName" alignment="3" max="32767" attributes="0"/>
<Component id="btnPreviousConfiguration1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration2" alignment="3" min="-2" max="-2" attributes="0"/> </Group>
<Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbTimeLimit" alignment="3" max="32767" attributes="0"/>
<Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPassword" alignment="3" max="32767" attributes="0"/>
<Component id="chkSpectatorsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cbDeckType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblEdhPowerLevel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblEdhPowerLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnEdhPowerLevel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnEdhPowerLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblMinimumRating" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnMinimumRating" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkRated" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0"> <Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="chkRollbackTurnsAllowed" 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"/>
<Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<Group type="103" groupAlignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="cbRange" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/> <Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" max="-2" attributes="0"/> <Component id="spnNumPlayers" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<Component id="lblSkillLevel" alignment="0" min="-2" max="-2" attributes="0"/> <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="cbAttackOption" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> </Group>
<Component id="lblRange" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="102" alignment="1" attributes="0">
<Component id="lblAttack" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblSkillLevel" min="-2" max="-2" attributes="0"/>
</Group> <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group> <Component id="cbSkillLevel" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="lblMullgian" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="cbMulligan" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cbRange" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbAttackOption" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="chkPlaneChase" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbSkillLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
<Component id="jSeparator2" min="-2" max="-2" attributes="0"/> <Component id="jSeparator2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
@ -199,21 +305,24 @@
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/> <EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="105" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" pref="94" max="32767" attributes="0"/>
<EmptySpace pref="7" max="32767" attributes="0"/> <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/> <Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnOK" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnOK" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnSettingsLoad" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnSettingsSave" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="lblSettings" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="201" max="-2" attributes="0"/> <EmptySpace min="-2" pref="201" max="-2" attributes="0"/>
<Component id="jSeparator3" min="-2" max="-2" attributes="0"/> <Component id="jSeparator3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="167" max="32767" attributes="0"/> <EmptySpace pref="180" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
@ -233,17 +342,13 @@
<Component class="javax.swing.JLabel" name="lblPassword"> <Component class="javax.swing.JLabel" name="lblPassword">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtName"/> <ComponentRef name="txtPassword"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Password:"/> <Property name="text" type="java.lang.String" value="Password:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtPassword"> <Component class="javax.swing.JTextField" name="txtPassword">
</Component> </Component>
<Component class="javax.swing.JButton" name="btnPreviousConfiguration1">
</Component>
<Component class="javax.swing.JButton" name="btnPreviousConfiguration2">
</Component>
<Component class="javax.swing.JLabel" name="lbDeckType"> <Component class="javax.swing.JLabel" name="lbDeckType">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Deck Type:"/> <Property name="text" type="java.lang.String" value="Deck Type:"/>
@ -271,12 +376,15 @@
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkRollbackTurnsAllowed"> <Component class="javax.swing.JCheckBox" name="chkRollbackTurnsAllowed">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Allow rollbacks"/> <Property name="text" type="java.lang.String" value="Rollbacks"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Allow to rollback to the start of previous turns&lt;br&gt;&#xa;if all players agree.&#xa;"/> <Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Allow to rollback to the start of previous turns&lt;br&gt;&#xa;if all players agree.&#xa;"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblFreeMulligans"> <Component class="javax.swing.JLabel" name="lblFreeMulligans">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="spnFreeMulligans"/>
</Property>
<Property name="text" type="java.lang.String" value="Free Mulligans:"/> <Property name="text" type="java.lang.String" value="Free Mulligans:"/>
<Property name="toolTipText" type="java.lang.String" value="The number of mulligans a player can use without decreasing the number of drawn cards."/> <Property name="toolTipText" type="java.lang.String" value="The number of mulligans a player can use without decreasing the number of drawn cards."/>
</Properties> </Properties>
@ -289,11 +397,10 @@
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkPlaneChase"> <Component class="javax.swing.JCheckBox" name="chkPlaneChase">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Use PlaneChase"/> <Property name="text" type="java.lang.String" value="PlaneChase"/>
<Property name="toolTipText" type="java.lang.String" value="Use the PlaneChase variant for your game."/> <Property name="toolTipText" type="java.lang.String" value="Use the PlaneChase variant for your game."/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnFreeMulligans"> <Component class="javax.swing.JSpinner" name="spnFreeMulligans">
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblNumPlayers"> <Component class="javax.swing.JLabel" name="lblNumPlayers">
@ -301,7 +408,7 @@
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="spnNumPlayers"/> <ComponentRef name="spnNumPlayers"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Players"/> <Property name="text" type="java.lang.String" value="Players:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnNumPlayers"> <Component class="javax.swing.JSpinner" name="spnNumPlayers">
@ -314,7 +421,7 @@
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="cbRange"/> <ComponentRef name="cbRange"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Range of Influence"/> <Property name="text" type="java.lang.String" value="Range of Influence:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbRange"> <Component class="javax.swing.JComboBox" name="cbRange">
@ -330,7 +437,7 @@
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="cbAttackOption"/> <ComponentRef name="cbAttackOption"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Attack Option"/> <Property name="text" type="java.lang.String" value="Attack Option:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbAttackOption"> <Component class="javax.swing.JComboBox" name="cbAttackOption">
@ -346,7 +453,8 @@
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="cbAttackOption"/> <ComponentRef name="cbAttackOption"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Skill Level"/> <Property name="text" type="java.lang.String" value="Skill Level:"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbSkillLevel"> <Component class="javax.swing.JComboBox" name="cbSkillLevel">
@ -362,14 +470,11 @@
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="spnNumWins"/> <ComponentRef name="spnNumWins"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Wins"/> <Property name="text" type="java.lang.String" value="Wins:"/>
<Property name="toolTipText" type="java.lang.String" value="How many games has a player to win to win the match."/> <Property name="toolTipText" type="java.lang.String" value="How many games has a player to win to win the match."/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnNumWins"> <Component class="javax.swing.JSpinner" name="spnNumWins">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JSeparator" name="jSeparator2"> <Component class="javax.swing.JSeparator" name="jSeparator2">
</Component> </Component>
@ -404,7 +509,7 @@
</Component> </Component>
<Component class="javax.swing.JButton" name="btnOK"> <Component class="javax.swing.JButton" name="btnOK">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="OK"/> <Property name="text" type="java.lang.String" value="Create"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
@ -427,10 +532,76 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblEdhPowerLevel"> <Component class="javax.swing.JLabel" name="lblEdhPowerLevel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="EDH power level"/> <Property name="text" type="java.lang.String" value="EDH power level:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnEdhPowerLevel"> <Component class="javax.swing.JSpinner" name="spnEdhPowerLevel">
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbMulligan">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Selections the type of mulligan for games."/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="lblMullgian">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="cbMulligan"/>
</Property>
<Property name="text" type="java.lang.String" value="Mulligan type:"/>
<Property name="toolTipText" type="java.lang.String" value="What style of mulligan?"/>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Mullgian"/>
</AccessibilityProperties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="NewTableDialog_lblMullgian"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="lblMinimumRating">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="spnMinimumRating"/>
</Property>
<Property name="text" type="java.lang.String" value="Minimum rating:"/>
<Property name="toolTipText" type="java.lang.String" value="Players with rating less than this value can&apos;t join this table"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnMinimumRating">
</Component>
<Component class="javax.swing.JCheckBox" name="chkRated">
<Properties>
<Property name="text" type="java.lang.String" value="Rated game"/>
<Property name="toolTipText" type="java.lang.String" value="Indicates if matche will be rated"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnSettingsLoad">
<Properties>
<Property name="text" type="java.lang.String" value="Load..."/>
<Property name="toolTipText" type="java.lang.String" value="Load settings"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnSettingsLoadMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnSettingsSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save..."/>
<Property name="toolTipText" type="java.lang.String" value="Save settings"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnSettingsSaveMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblSettings">
<Properties>
<Property name="text" type="java.lang.String" value="Settings"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,13 +1,6 @@
package mage.client.dialog; package mage.client.dialog;
import java.io.FileNotFoundException; import mage.cards.decks.importer.DeckImporter;
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.MageFrame;
import mage.client.SessionHandler; import mage.client.SessionHandler;
import mage.client.components.MageComponents; import mage.client.components.MageComponents;
@ -20,13 +13,21 @@ import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence; import mage.constants.RangeOfInfluence;
import mage.constants.SkillLevel; import mage.constants.SkillLevel;
import mage.game.match.MatchOptions; import mage.game.match.MatchOptions;
import mage.game.mulligan.MulliganType;
import mage.players.PlayerType; import mage.players.PlayerType;
import mage.view.GameTypeView; import mage.view.GameTypeView;
import mage.view.TableView; import mage.view.TableView;
import org.apache.log4j.Logger; 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 * @author BetaSteward_at_googlemail.com, JayDi85
*/ */
public class NewTableDialog extends MageDialog { public class NewTableDialog extends MageDialog {
@ -51,6 +52,7 @@ public class NewTableDialog extends MageDialog {
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1)); this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1)); this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1));
this.spnQuitRatio.setModel(new SpinnerNumberModel(100, 0, 100, 5)); this.spnQuitRatio.setModel(new SpinnerNumberModel(100, 0, 100, 5));
this.spnMinimumRating.setModel(new SpinnerNumberModel(0, 0, 3000, 10));
this.spnEdhPowerLevel.setModel(new SpinnerNumberModel(100, 0, 100, 5)); this.spnEdhPowerLevel.setModel(new SpinnerNumberModel(100, 0, 100, 5));
MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK); MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
} }
@ -64,6 +66,16 @@ public class NewTableDialog extends MageDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
popupSaveSettings = new javax.swing.JPopupMenu();
menuSaveSettings1 = new javax.swing.JMenuItem();
menuSaveSettings2 = new javax.swing.JMenuItem();
popupLoadSettings = new javax.swing.JPopupMenu();
menuLoadSettingsLast = new javax.swing.JMenuItem();
separator1 = new javax.swing.JPopupMenu.Separator();
menuLoadSettings1 = new javax.swing.JMenuItem();
menuLoadSettings2 = new javax.swing.JMenuItem();
separator2 = new javax.swing.JPopupMenu.Separator();
menuLoadSettingsDefault = new javax.swing.JMenuItem();
lblName = new javax.swing.JLabel(); lblName = new javax.swing.JLabel();
txtName = new javax.swing.JTextField(); txtName = new javax.swing.JTextField();
lblPassword = new javax.swing.JLabel(); lblPassword = new javax.swing.JLabel();
@ -75,10 +87,9 @@ public class NewTableDialog extends MageDialog {
lblGameType = new javax.swing.JLabel(); lblGameType = new javax.swing.JLabel();
cbGameType = new javax.swing.JComboBox(); cbGameType = new javax.swing.JComboBox();
chkRollbackTurnsAllowed = new javax.swing.JCheckBox(); chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
lblFreeMulligans = new javax.swing.JLabel();
chkSpectatorsAllowed = new javax.swing.JCheckBox(); chkSpectatorsAllowed = new javax.swing.JCheckBox();
chkPlaneChase = new javax.swing.JCheckBox(); chkPlaneChase = new javax.swing.JCheckBox();
chkRated = new javax.swing.JCheckBox();
lblFreeMulligans = new javax.swing.JLabel();
spnFreeMulligans = new javax.swing.JSpinner(); spnFreeMulligans = new javax.swing.JSpinner();
lblNumPlayers = new javax.swing.JLabel(); lblNumPlayers = new javax.swing.JLabel();
spnNumPlayers = new javax.swing.JSpinner(); spnNumPlayers = new javax.swing.JSpinner();
@ -98,72 +109,136 @@ public class NewTableDialog extends MageDialog {
pnlOtherPlayers = new javax.swing.JPanel(); pnlOtherPlayers = new javax.swing.JPanel();
jSeparator1 = new javax.swing.JSeparator(); jSeparator1 = new javax.swing.JSeparator();
btnOK = new javax.swing.JButton(); btnOK = new javax.swing.JButton();
btnPreviousConfiguration1 = new javax.swing.JButton();
btnPreviousConfiguration2 = new javax.swing.JButton();
btnCancel = new javax.swing.JButton(); btnCancel = new javax.swing.JButton();
lblQuitRatio = new javax.swing.JLabel(); lblQuitRatio = new javax.swing.JLabel();
lblEdhPowerLevel = new javax.swing.JLabel();
spnQuitRatio = new javax.swing.JSpinner(); spnQuitRatio = new javax.swing.JSpinner();
lblEdhPowerLevel = new javax.swing.JLabel();
spnEdhPowerLevel = new javax.swing.JSpinner(); spnEdhPowerLevel = new javax.swing.JSpinner();
cbMulligan = new javax.swing.JComboBox<>();
lblMullgian = new javax.swing.JLabel();
lblMinimumRating = new javax.swing.JLabel();
spnMinimumRating = new javax.swing.JSpinner();
chkRated = new javax.swing.JCheckBox();
btnSettingsLoad = new javax.swing.JButton();
btnSettingsSave = new javax.swing.JButton();
lblSettings = new javax.swing.JLabel();
menuSaveSettings1.setText("Save to config 1");
menuSaveSettings1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuSaveSettings1ActionPerformed(evt);
}
});
popupSaveSettings.add(menuSaveSettings1);
menuSaveSettings2.setText("Save to config 2");
menuSaveSettings2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuSaveSettings2ActionPerformed(evt);
}
});
popupSaveSettings.add(menuSaveSettings2);
menuLoadSettingsLast.setText("Load from last time");
menuLoadSettingsLast.setToolTipText("");
menuLoadSettingsLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuLoadSettingsLastActionPerformed(evt);
}
});
popupLoadSettings.add(menuLoadSettingsLast);
popupLoadSettings.add(separator1);
menuLoadSettings1.setText("Load from config 1");
menuLoadSettings1.setToolTipText("");
menuLoadSettings1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuLoadSettings1ActionPerformed(evt);
}
});
popupLoadSettings.add(menuLoadSettings1);
menuLoadSettings2.setText("Load from config 2");
menuLoadSettings2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuLoadSettings2ActionPerformed(evt);
}
});
popupLoadSettings.add(menuLoadSettings2);
popupLoadSettings.add(separator2);
menuLoadSettingsDefault.setText("Load default settings");
menuLoadSettingsDefault.setToolTipText("");
menuLoadSettingsDefault.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
menuLoadSettingsDefaultActionPerformed(evt);
}
});
popupLoadSettings.add(menuLoadSettingsDefault);
setTitle("New Table"); setTitle("New Table");
lblName.setLabelFor(txtName); lblName.setLabelFor(txtName);
lblName.setText("Name:"); lblName.setText("Name:");
lblPassword.setLabelFor(txtName); lblPassword.setLabelFor(txtPassword);
lblPassword.setText("Password:"); lblPassword.setText("Password:");
lbDeckType.setText("Deck Type:"); lbDeckType.setText("Deck Type:");
lbTimeLimit.setText("Time Limit:"); lbTimeLimit.setText("Time Limit:");
lbTimeLimit.setToolTipText("The active time a player may use to finish the match. If their time runs out, the player looses the current game."); 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.");
lblGameType.setText("Game Type:"); lblGameType.setText("Game Type:");
cbGameType.addActionListener(evt -> cbGameTypeActionPerformed(evt)); cbGameType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbGameTypeActionPerformed(evt);
}
});
chkRollbackTurnsAllowed.setText("Allow rollbacks"); chkRollbackTurnsAllowed.setText("Rollbacks");
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n"); chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n");
chkSpectatorsAllowed.setText("Allow Spectators"); lblFreeMulligans.setLabelFor(spnFreeMulligans);
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.");
lblFreeMulligans.setText("Free Mulligans:"); lblFreeMulligans.setText("Free Mulligans:");
lblFreeMulligans.setToolTipText("The number of mulligans a player can use without decreasing the number of drawn cards."); lblFreeMulligans.setToolTipText("The number of mulligans a player can use without decreasing the number of drawn cards.");
lblNumPlayers.setLabelFor(spnNumPlayers); chkSpectatorsAllowed.setText("Spectators allowed");
lblNumPlayers.setText("Players"); chkSpectatorsAllowed.setToolTipText("Allow spectators to view your game.");
spnNumPlayers.addChangeListener(evt -> numPlayersChanged(evt)); chkPlaneChase.setText("PlaneChase");
chkPlaneChase.setToolTipText("Use the PlaneChase variant for your game.");
lblNumPlayers.setLabelFor(spnNumPlayers);
lblNumPlayers.setText("Players:");
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
numPlayersChanged(evt);
}
});
lblRange.setLabelFor(cbRange); lblRange.setLabelFor(cbRange);
lblRange.setText("Range of Influence"); lblRange.setText("Range of Influence:");
cbRange.setToolTipText("<HTML>An option for multiplayer games.\nA player's range of influence is the maximum distance from that player, measured in player seats,<br>\nthat the player can affect. Players within that many seats of the player are within that player's range<br>\nof influence. Objects controlled by players within a player's range of influence are also within that<br>\nplayer's range of influence. Range of influence covers spells, abilities, effects, damage dealing, attacking,<nr>\nmaking choices, and winning the game."); cbRange.setToolTipText("<HTML>An option for multiplayer games.\nA player's range of influence is the maximum distance from that player, measured in player seats,<br>\nthat the player can affect. Players within that many seats of the player are within that player's range<br>\nof influence. Objects controlled by players within a player's range of influence are also within that<br>\nplayer's range of influence. Range of influence covers spells, abilities, effects, damage dealing, attacking,<nr>\nmaking choices, and winning the game.");
lblAttack.setLabelFor(cbAttackOption); lblAttack.setLabelFor(cbAttackOption);
lblAttack.setText("Attack Option"); lblAttack.setText("Attack Option:");
cbAttackOption.setToolTipText("<HTML>An option for multiplayer games that defines<br>\nwhich opponents can be attacked from a player."); cbAttackOption.setToolTipText("<HTML>An option for multiplayer games that defines<br>\nwhich opponents can be attacked from a player.");
lblSkillLevel.setLabelFor(cbAttackOption); lblSkillLevel.setLabelFor(cbAttackOption);
lblSkillLevel.setText("Skill Level"); lblSkillLevel.setText("Skill Level:");
lblSkillLevel.setToolTipText("");
cbSkillLevel.setToolTipText("<HTML>This option can be used to make it easier to find matches<br>\nwith opponents of the appropriate skill level."); cbSkillLevel.setToolTipText("<HTML>This option can be used to make it easier to find matches<br>\nwith opponents of the appropriate skill level.");
lblNumWins.setLabelFor(spnNumWins); lblNumWins.setLabelFor(spnNumWins);
lblNumWins.setText("Wins"); lblNumWins.setText("Wins:");
lblNumWins.setToolTipText("How many games has a player to win to win the match."); lblNumWins.setToolTipText("How many games has a player to win to win the match.");
spnNumWins.addChangeListener(evt -> spnNumWinsnumPlayersChanged(evt));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel1.setText("Player 1 (You)"); jLabel1.setText("Player 1 (You)");
@ -172,24 +247,54 @@ public class NewTableDialog extends MageDialog {
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1)); pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1));
btnOK.setText("OK"); btnOK.setText("Create");
btnOK.addActionListener(evt -> btnOKActionPerformed(evt)); btnOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreviousConfiguration1.setText("M1"); btnOKActionPerformed(evt);
btnPreviousConfiguration1.setToolTipText("Load saved Match configuration #1"); }
btnPreviousConfiguration1.addActionListener(evt -> btnPreviousConfigurationActionPerformed(evt, 1)); });
btnPreviousConfiguration2.setText("M2");
btnPreviousConfiguration2.setToolTipText("Load saved Match configuration #2");
btnPreviousConfiguration2.addActionListener(evt -> btnPreviousConfigurationActionPerformed(evt, 2));
btnCancel.setText("Cancel"); btnCancel.setText("Cancel");
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt)); btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
lblQuitRatio.setText("Allowed quit %"); lblQuitRatio.setText("Allowed quit %");
lblEdhPowerLevel.setText("EDH power level");
spnQuitRatio.setToolTipText("Players with quit % more than this value can't join this table"); lblEdhPowerLevel.setText("EDH power level:");
spnEdhPowerLevel.setToolTipText("Players with decks with a higher power level can't join this table");
cbMulligan.setToolTipText("Selections the type of mulligan for games.");
lblMullgian.setLabelFor(cbMulligan);
lblMullgian.setText("Mulligan type:");
lblMullgian.setToolTipText("What style of mulligan?");
lblMinimumRating.setLabelFor(spnMinimumRating);
lblMinimumRating.setText("Minimum rating:");
lblMinimumRating.setToolTipText("Players with rating less than this value can't join this table");
chkRated.setText("Rated game");
chkRated.setToolTipText("Indicates if matche will be rated");
btnSettingsLoad.setText("Load...");
btnSettingsLoad.setToolTipText("Load settings");
btnSettingsLoad.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnSettingsLoadMouseClicked(evt);
}
});
btnSettingsSave.setText("Save...");
btnSettingsSave.setToolTipText("Save settings");
btnSettingsSave.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnSettingsSaveMouseClicked(evt);
}
});
lblSettings.setText("Settings");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
@ -198,144 +303,166 @@ public class NewTableDialog extends MageDialog {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblName)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(chkRollbackTurnsAllowed)
.addGap(13, 13, 13)
.addComponent(lblFreeMulligans)
.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)
.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)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPassword)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPreviousConfiguration1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPreviousConfiguration2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkRated)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEdhPowerLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addComponent(lblSettings)
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)) .addComponent(btnSettingsLoad)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnSettingsSave)
.addComponent(lblRange) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnOK, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblAttack)
.addGap(116, 116, 116)
.addComponent(lblSkillLevel))
.addGroup(layout.createSequentialGroup()
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator2) .addComponent(jSeparator2)
.addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 863, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)) .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblName)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPassword)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkSpectatorsAllowed))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(cbDeckType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cbGameType, 0, 270, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(chkRollbackTurnsAllowed)
.addGroup(layout.createSequentialGroup()
.addComponent(chkRated)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblMinimumRating)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnMinimumRating, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblEdhPowerLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblRange)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(8, 8, 8)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblAttack))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblSkillLevel))
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMullgian)
.addComponent(cbMulligan, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkPlaneChase))
.addComponent(lblFreeMulligans))))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE) .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 863, Short.MAX_VALUE)
.addContainerGap())) .addContainerGap()))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4) .addGap(3, 3, 3)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblName) .addComponent(txtName)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblName))
.addComponent(btnPreviousConfiguration1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnPreviousConfiguration2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbTimeLimit)
.addComponent(lblPassword) .addComponent(lbTimeLimit)
.addComponent(lbTimeLimit) .addComponent(lblPassword)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPassword)
.addComponent(chkSpectatorsAllowed)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType) .addComponent(lbDeckType)
.addComponent(lblQuitRatio) .addComponent(lblQuitRatio)
.addComponent(chkRated)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEdhPowerLevel) .addComponent(lblEdhPowerLevel)
.addComponent(chkRated) .addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblMinimumRating)
.addComponent(spnMinimumRating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chkRated))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.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(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblGameType)
.addComponent(lblFreeMulligans) .addComponent(chkRollbackTurnsAllowed))
.addComponent(chkRollbackTurnsAllowed) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkSpectatorsAllowed) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(chkPlaneChase)) .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblRange)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0)
.addComponent(lblGameType))) .addComponent(cbRange, 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.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblNumPlayers) .addComponent(lblNumPlayers)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblAttack)
.addComponent(lblSkillLevel) .addGap(0, 0, 0)
.addComponent(lblNumWins) .addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createSequentialGroup()
.addComponent(lblRange) .addComponent(lblSkillLevel)
.addComponent(lblAttack))) .addGap(0, 0, 0)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblNumWins)
.addGap(0, 0, 0)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblMullgian)
.addGap(0, 0, 0)
.addComponent(cbMulligan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblFreeMulligans)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chkPlaneChase))))
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1) .addComponent(jLabel1)
@ -344,21 +471,26 @@ public class NewTableDialog extends MageDialog {
.addGap(16, 16, 16) .addGap(16, 16, 16)
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) .addGap(9, 9, 9)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnOK)) .addComponent(btnOK, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)) .addComponent(btnSettingsLoad, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnSettingsSave, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblSettings))
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(201, 201, 201) .addGap(201, 201, 201)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(167, Short.MAX_VALUE))) .addContainerGap(180, Short.MAX_VALUE)))
); );
lblMullgian.getAccessibleContext().setAccessibleName("Mullgian");
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -369,39 +501,19 @@ public class NewTableDialog extends MageDialog {
}//GEN-LAST:event_btnCancelActionPerformed }//GEN-LAST:event_btnCancelActionPerformed
private void btnPreviousConfigurationActionPerformed(java.awt.event.ActionEvent evt, int i) {//GEN-FIRST:event_btnPreviousConfigurationActionPerformed private void btnPreviousConfigurationActionPerformed(java.awt.event.ActionEvent evt, int i) {//GEN-FIRST:event_btnPreviousConfigurationActionPerformed
currentSettingVersion = i;
setGameSettingsFromPrefs(currentSettingVersion);
}//GEN-LAST:event_btnPreviousConfigurationActionPerformed }//GEN-LAST:event_btnPreviousConfigurationActionPerformed
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName(), false, 2); MatchOptions options = getMatchOptions();
options.getPlayerTypes().add(PlayerType.HUMAN);
for (TablePlayerPanel player : players) {
options.getPlayerTypes().add(player.getPlayerType());
}
options.setDeckType((String) this.cbDeckType.getSelectedItem());
options.setLimited(false);
options.setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
options.setSkillLevel((SkillLevel) this.cbSkillLevel.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
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());
options.setQuitRatio((Integer) this.spnQuitRatio.getValue());
options.setEdhPowerLevel((Integer) this.spnEdhPowerLevel.getValue());
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
if (!checkMatchOptions(options)) { if (!checkMatchOptions(options)) {
return; return;
} }
saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile());
// save last used
onSaveSettings(0, options, this.player1Panel.getDeckFile());
// run
table = SessionHandler.createTable(roomId, options); table = SessionHandler.createTable(roomId, options);
if (table == null) { if (table == null) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
@ -413,7 +525,7 @@ public class NewTableDialog extends MageDialog {
table.getTableId(), table.getTableId(),
this.player1Panel.getPlayerName(), this.player1Panel.getPlayerName(),
PlayerType.HUMAN, 1, PlayerType.HUMAN, 1,
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()), DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile()),
this.txtPassword.getText())) { this.txtPassword.getText())) {
for (TablePlayerPanel player : players) { for (TablePlayerPanel player : players) {
if (player.getPlayerType() != PlayerType.HUMAN) { if (player.getPlayerType() != PlayerType.HUMAN) {
@ -449,9 +561,68 @@ public class NewTableDialog extends MageDialog {
createPlayers(numPlayers); createPlayers(numPlayers);
}//GEN-LAST:event_numPlayersChanged }//GEN-LAST:event_numPlayersChanged
private void spnNumWinsnumPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumWinsnumPlayersChanged private void btnSettingsSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSettingsSaveMouseClicked
// TODO add your handling code here: popupSaveSettings.show(evt.getComponent(), evt.getX(), evt.getY());
}//GEN-LAST:event_spnNumWinsnumPlayersChanged }//GEN-LAST:event_btnSettingsSaveMouseClicked
private void btnSettingsLoadMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSettingsLoadMouseClicked
popupLoadSettings.show(evt.getComponent(), evt.getX(), evt.getY());
}//GEN-LAST:event_btnSettingsLoadMouseClicked
private void menuSaveSettings2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSaveSettings2ActionPerformed
onSaveSettings(2);
}//GEN-LAST:event_menuSaveSettings2ActionPerformed
private void menuSaveSettings1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSaveSettings1ActionPerformed
onSaveSettings(1);
}//GEN-LAST:event_menuSaveSettings1ActionPerformed
private void menuLoadSettingsLastActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLoadSettingsLastActionPerformed
onLoadSettings(0);
}//GEN-LAST:event_menuLoadSettingsLastActionPerformed
private void menuLoadSettings1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLoadSettings1ActionPerformed
onLoadSettings(1);
}//GEN-LAST:event_menuLoadSettings1ActionPerformed
private void menuLoadSettings2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLoadSettings2ActionPerformed
onLoadSettings(2);
}//GEN-LAST:event_menuLoadSettings2ActionPerformed
private void menuLoadSettingsDefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLoadSettingsDefaultActionPerformed
onLoadSettings(-1);
}//GEN-LAST:event_menuLoadSettingsDefaultActionPerformed
private MatchOptions getMatchOptions() {
// current settings
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName(), false, 2);
options.getPlayerTypes().add(PlayerType.HUMAN);
for (TablePlayerPanel player : players) {
options.getPlayerTypes().add(player.getPlayerType());
}
options.setDeckType((String) this.cbDeckType.getSelectedItem());
options.setLimited(false);
options.setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
options.setSkillLevel((SkillLevel) this.cbSkillLevel.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
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());
options.setQuitRatio((Integer) this.spnQuitRatio.getValue());
options.setMinimumRating((Integer) this.spnMinimumRating.getValue());
options.setEdhPowerLevel((Integer) this.spnEdhPowerLevel.getValue());
options.setMullgianType((MulliganType) this.cbMulligan.getSelectedItem());
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
return options;
}
/** /**
* Checks about not valid game option combinations and shows an error * Checks about not valid game option combinations and shows an error
@ -460,10 +631,14 @@ public class NewTableDialog extends MageDialog {
* @return * @return
*/ */
private boolean checkMatchOptions(MatchOptions options) { private boolean checkMatchOptions(MatchOptions options) {
// deck => game
switch (options.getDeckType()) { switch (options.getDeckType()) {
case "Variant Magic - Commander": case "Variant Magic - Commander":
case "Variant Magic - Duel Commander": case "Variant Magic - Duel Commander":
case "Variant Magic - MTGO 1v1 Commander": case "Variant Magic - MTGO 1v1 Commander":
case "Variant Magic - Freeform Commander":
case "Variant Magic - Penny Dreadful Commander":
if (!options.getGameType().startsWith("Commander")) { if (!options.getGameType().startsWith("Commander")) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Commander needs also a Commander game type", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Commander needs also a Commander game type", "Error", JOptionPane.ERROR_MESSAGE);
return false; return false;
@ -489,12 +664,16 @@ public class NewTableDialog extends MageDialog {
} }
break; break;
} }
// game => deck
switch (options.getGameType()) { switch (options.getGameType()) {
case "Commander Two Player Duel": case "Commander Two Player Duel":
case "Commander Free For All": case "Commander Free For All":
if (!options.getDeckType().equals("Variant Magic - Commander") if (!options.getDeckType().equals("Variant Magic - Commander")
&& !options.getDeckType().equals("Variant Magic - Duel Commander") && !options.getDeckType().equals("Variant Magic - Duel Commander")
&& !options.getDeckType().equals("Variant Magic - MTGO 1v1 Commander")) { && !options.getDeckType().equals("Variant Magic - MTGO 1v1 Commander")
&& !options.getDeckType().equals("Variant Magic - Freeform Commander")
&& !options.getDeckType().equals("Variant Magic - Penny Dreadful Commander")) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Commander needs also a Commander game type", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Deck type Commander needs also a Commander game type", "Error", JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
@ -567,8 +746,7 @@ public class NewTableDialog extends MageDialog {
private void handleError(Exception ex) { private void handleError(Exception ex) {
logger.fatal("Error loading deck", ex); logger.fatal("Error loading deck", ex);
//JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE); MageFrame.getInstance().showErrorDialog("Error loading deck", ex.getMessage());
MageFrame.getInstance().showErrorDialog("Error loading deck.", ex.getMessage());
} }
public void showDialog(UUID roomId) { public void showDialog(UUID roomId) {
@ -583,6 +761,7 @@ public class NewTableDialog extends MageDialog {
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values())); cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values())); cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values()));
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values())); cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
cbMulligan.setModel(new DefaultComboBoxModel(MulliganType.values()));
// Update the existing player panels (neccessary if server was changes = new session) // Update the existing player panels (neccessary if server was changes = new session)
int i = 2; int i = 2;
for (TablePlayerPanel tablePlayerPanel : players) { for (TablePlayerPanel tablePlayerPanel : players) {
@ -592,8 +771,10 @@ public class NewTableDialog extends MageDialog {
setGameOptions(); setGameOptions();
this.setLocation(150, 100); this.setLocation(150, 100);
} }
currentSettingVersion = 0;
setGameSettingsFromPrefs(currentSettingVersion); // auto-load last settings
onLoadSettings(0);
this.setVisible(true); this.setVisible(true);
} }
@ -615,27 +796,24 @@ public class NewTableDialog extends MageDialog {
} }
} }
/** private void onLoadSettings(int version) {
* set the table settings from java prefs
*/
int currentSettingVersion = 0;
private void setGameSettingsFromPrefs(int version) {
currentSettingVersion = version;
String versionStr = ""; String versionStr = "";
switch (currentSettingVersion) { switch (version) {
case -1:
versionStr = "-1"; // default (empty)
break;
case 1: case 1:
versionStr = "1"; versionStr = "1";
btnPreviousConfiguration1.requestFocus();
break; break;
case 2: case 2:
versionStr = "2"; versionStr = "2";
btnPreviousConfiguration2.requestFocus();
break; break;
default: default:
btnPreviousConfiguration2.getParent().requestFocus(); versionStr = "";
break; break;
} }
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game")); txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, "")); txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, ""));
@ -671,6 +849,7 @@ public class NewTableDialog extends MageDialog {
this.chkPlaneChase.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, "No").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.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"))); this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
this.cbMulligan.setSelectedItem(MulliganType.valueByName(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_MULLIGAN_TYPE + versionStr, MulliganType.GAME_DEFAULT.toString())));
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, "1")); int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, "1"));
for (RangeOfInfluence roi : RangeOfInfluence.values()) { for (RangeOfInfluence roi : RangeOfInfluence.values()) {
@ -686,7 +865,7 @@ public class NewTableDialog extends MageDialog {
break; break;
} }
} }
String skillLevelDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL, "Casual"); String skillLevelDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, "Casual");
for (SkillLevel skillLevel : SkillLevel.values()) { for (SkillLevel skillLevel : SkillLevel.values()) {
if (skillLevel.toString().equals(skillLevelDefault)) { if (skillLevel.toString().equals(skillLevelDefault)) {
this.cbSkillLevel.setSelectedItem(skillLevel); this.cbSkillLevel.setSelectedItem(skillLevel);
@ -694,24 +873,31 @@ public class NewTableDialog extends MageDialog {
} }
} }
this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO, "100"))); this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, "100")));
this.spnEdhPowerLevel.setValue(0); this.spnMinimumRating.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_MINIMUM_RATING + versionStr, "0")));
this.spnEdhPowerLevel.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_EDH_POWER_LEVEL + versionStr, "0")));
} }
/** private void onSaveSettings(int version) {
* Save the settings to java prefs to reload it next time the dialog will be MatchOptions options = getMatchOptions();
* created onSaveSettings(version, options, this.player1Panel.getDeckFile());
* }
* @param options
* @param deckFile private void onSaveSettings(int version, MatchOptions options, String deckFile) {
*/
private void saveGameSettingsToPrefs(MatchOptions options, String deckFile) {
String versionStr = ""; String versionStr = "";
if (currentSettingVersion == 1) { switch (version) {
versionStr = "1"; case 1:
} else if (currentSettingVersion == 2) { versionStr = "1";
versionStr = "2"; break;
case 2:
versionStr = "2";
break;
default:
versionStr = "";
break;
} }
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, options.getName()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, options.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, options.getPassword()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, options.getPassword());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE + versionStr, options.getDeckType()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE + versionStr, options.getDeckType());
@ -721,6 +907,7 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, options.isRollbackTurnsAllowed() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, options.isRollbackTurnsAllowed() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, options.isRated() ? "Yes" : "No"); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, options.isRated() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(options.getFreeMulligans())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(options.getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_MULLIGAN_TYPE + versionStr, options.getMulliganType().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, deckFile); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, deckFile);
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS + versionStr, spnNumPlayers.getValue().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS + versionStr, spnNumPlayers.getValue().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange()));
@ -729,6 +916,9 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No"); 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_PLANECHASE + versionStr, options.isPlaneChase() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_MINIMUM_RATING + versionStr, Integer.toString(options.getMinimumRating()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_EDH_POWER_LEVEL + versionStr, Integer.toString(options.getEdhPowerLevel()));
StringBuilder playerTypesString = new StringBuilder(); StringBuilder playerTypesString = new StringBuilder();
for (Object player : players) { for (Object player : players) {
if (playerTypesString.length() > 0) { if (playerTypesString.length() > 0) {
@ -743,18 +933,19 @@ public class NewTableDialog extends MageDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel; private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOK; private javax.swing.JButton btnOK;
private javax.swing.JButton btnPreviousConfiguration1; private javax.swing.JButton btnSettingsLoad;
private javax.swing.JButton btnPreviousConfiguration2; private javax.swing.JButton btnSettingsSave;
private javax.swing.JComboBox cbAttackOption; private javax.swing.JComboBox cbAttackOption;
private javax.swing.JComboBox cbDeckType; private javax.swing.JComboBox cbDeckType;
private javax.swing.JComboBox cbGameType; private javax.swing.JComboBox cbGameType;
private javax.swing.JComboBox<String> cbMulligan;
private javax.swing.JComboBox cbRange; private javax.swing.JComboBox cbRange;
private javax.swing.JComboBox cbSkillLevel; private javax.swing.JComboBox cbSkillLevel;
private javax.swing.JComboBox cbTimeLimit; private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
private javax.swing.JCheckBox chkSpectatorsAllowed;
private javax.swing.JCheckBox chkPlaneChase; private javax.swing.JCheckBox chkPlaneChase;
private javax.swing.JCheckBox chkRated; private javax.swing.JCheckBox chkRated;
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
private javax.swing.JCheckBox chkSpectatorsAllowed;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator1;
@ -763,23 +954,37 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JLabel lbDeckType; private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lbTimeLimit; private javax.swing.JLabel lbTimeLimit;
private javax.swing.JLabel lblAttack; private javax.swing.JLabel lblAttack;
private javax.swing.JLabel lblEdhPowerLevel;
private javax.swing.JLabel lblFreeMulligans; private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblGameType; private javax.swing.JLabel lblGameType;
private javax.swing.JLabel lblMinimumRating;
private javax.swing.JLabel lblMullgian;
private javax.swing.JLabel lblName; private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNumPlayers; private javax.swing.JLabel lblNumPlayers;
private javax.swing.JLabel lblNumWins; private javax.swing.JLabel lblNumWins;
private javax.swing.JLabel lblPassword; private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblQuitRatio; private javax.swing.JLabel lblQuitRatio;
private javax.swing.JLabel lblEdhPowerLevel;
private javax.swing.JLabel lblRange; private javax.swing.JLabel lblRange;
private javax.swing.JLabel lblSettings;
private javax.swing.JLabel lblSkillLevel; private javax.swing.JLabel lblSkillLevel;
private javax.swing.JMenuItem menuLoadSettings1;
private javax.swing.JMenuItem menuLoadSettings2;
private javax.swing.JMenuItem menuLoadSettingsDefault;
private javax.swing.JMenuItem menuLoadSettingsLast;
private javax.swing.JMenuItem menuSaveSettings1;
private javax.swing.JMenuItem menuSaveSettings2;
private mage.client.table.NewPlayerPanel player1Panel; private mage.client.table.NewPlayerPanel player1Panel;
private javax.swing.JPanel pnlOtherPlayers; private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JPopupMenu popupLoadSettings;
private javax.swing.JPopupMenu popupSaveSettings;
private javax.swing.JPopupMenu.Separator separator1;
private javax.swing.JPopupMenu.Separator separator2;
private javax.swing.JSpinner spnEdhPowerLevel;
private javax.swing.JSpinner spnFreeMulligans; private javax.swing.JSpinner spnFreeMulligans;
private javax.swing.JSpinner spnMinimumRating;
private javax.swing.JSpinner spnNumPlayers; private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins; private javax.swing.JSpinner spnNumWins;
private javax.swing.JSpinner spnQuitRatio; private javax.swing.JSpinner spnQuitRatio;
private javax.swing.JSpinner spnEdhPowerLevel;
private javax.swing.JTextField txtName; private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPassword; private javax.swing.JTextField txtPassword;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -1,6 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents>
<Container class="javax.swing.JPopupMenu" name="popupSaveSettings">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuSaveSettings1">
<Properties>
<Property name="text" type="java.lang.String" value="Save to config 1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuSaveSettings1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuSaveSettings2">
<Properties>
<Property name="text" type="java.lang.String" value="Save to config 2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuSaveSettings2ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Container>
<Container class="javax.swing.JPopupMenu" name="popupLoadSettings">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettingsLast">
<Properties>
<Property name="text" type="java.lang.String" value="Load from last time"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettingsLastActionPerformed"/>
</Events>
</MenuItem>
<Component class="javax.swing.JPopupMenu$Separator" name="separator1">
</Component>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettings1">
<Properties>
<Property name="text" type="java.lang.String" value="Load from config 1"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettings1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettings2">
<Properties>
<Property name="text" type="java.lang.String" value="Load from config 2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettings2ActionPerformed"/>
</Events>
</MenuItem>
<Component class="javax.swing.JPopupMenu$Separator" name="separator2">
</Component>
<MenuItem class="javax.swing.JMenuItem" name="menuLoadSettingsDefault">
<Properties>
<Property name="text" type="java.lang.String" value="Load default settings"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuLoadSettingsDefaultActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Container>
</NonVisualComponents>
<Properties> <Properties>
<Property name="title" type="java.lang.String" value="New Tournament"/> <Property name="title" type="java.lang.String" value="New Tournament"/>
</Properties> </Properties>
@ -29,8 +102,16 @@
<Component id="pnlPacks" alignment="1" max="32767" attributes="0"/> <Component id="pnlPacks" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Component id="lblNbrPlayers" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="spnNumPlayers" min="-2" pref="46" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Component id="lblNbrSeats" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="spnNumSeats" min="-2" pref="46" max="-2" attributes="0"/> </Group> <Component id="lblNbrPlayers" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="46" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblNbrSeats" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumSeats" min="-2" pref="46" max="-2" attributes="0"/>
</Group>
<Component id="lblPacks" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="lblPacks" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblPlayer1" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="lblPlayer1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
@ -53,77 +134,96 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="chkRollbackTurnsAllowed" min="-2" max="-2" attributes="0"/> <Component id="chkRollbackTurnsAllowed" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" attributes="0"> <Component id="spnNumRounds" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="spnNumRounds" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbAllowSpectators" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbPlaneChase" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace min="-2" pref="95" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="lblSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSettingsLoad" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSettingsSave" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="btnOk" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" attributes="0">
<Component id="btnSavedConfiguration1" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0">
<Component id="lblDraftCube" max="-2" attributes="0"/>
<Component id="lblTournamentType" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" max="-2" attributes="0"/>
<Component id="lblGameType" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnSavedConfiguration2" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Component id="cbDraftCube" min="-2" pref="290" max="-2" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/> <Component id="cbDeckType" alignment="0" min="-2" pref="290" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/> <Component id="cbGameType" min="-2" pref="290" max="-2" attributes="1"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="cbTournamentType" min="-2" pref="290" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<Group type="103" alignment="1" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="chkRated" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblMinimumRating" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnMinimumRating" min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblMullgian" min="-2" max="-2" attributes="0"/>
<Component id="cbMulligan" min="-2" pref="151" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="lblFreeMulligans" max="32767" attributes="0"/>
<Component id="spnFreeMulligans" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbPlaneChase" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0"> <Component id="lblQuitRatio" min="-2" max="-2" attributes="0"/>
<Component id="lblDraftCube" max="-2" attributes="0"/>
<Component id="lblTournamentType" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" max="-2" attributes="0"/>
<Component id="lblGameType" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="spnQuitRatio" max="32767" attributes="0"/>
<Component id="cbDraftCube" min="-2" pref="290" max="-2" attributes="0"/>
<Component id="cbDeckType" alignment="0" min="-2" pref="290" max="-2" attributes="1"/>
<Component id="cbGameType" min="-2" pref="290" max="-2" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblQuitRatio" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnQuitRatio" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="cbTournamentType" min="-2" pref="290" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtName" min="-2" pref="224" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbTimeLimit" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTimeLimit" min="-2" pref="101" max="-2" attributes="1"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lbSkillLevel" min="-2" max="-2" attributes="0"/> <Component id="lbSkillLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cbSkillLevel" min="-2" pref="88" max="-2" attributes="1"/> <Component id="cbSkillLevel" min="-2" pref="88" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPassword" min="-2" pref="56" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="41" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtName" min="-2" pref="224" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbTimeLimit" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTimeLimit" min="-2" pref="101" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPassword" min="-2" pref="56" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbAllowSpectators" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/> <Component id="player1Panel" alignment="0" max="32767" attributes="0"/>
<Component id="pnlRandomPacks" alignment="1" max="32767" attributes="0"/> <Component id="pnlRandomPacks" alignment="1" max="32767" attributes="0"/>
@ -135,7 +235,7 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/> <EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
@ -143,22 +243,30 @@
<Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbSkillLevel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbAllowSpectators" alignment="3" max="32767" attributes="0"/>
<Component id="cbSkillLevel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" alignment="3" min="-2" max="-2" attributes="0"/> </Group>
<Component id="lblQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="spnQuitRatio" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="chkRated" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblMinimumRating" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnMinimumRating" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblTournamentType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbSkillLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbSkillLevel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
@ -166,42 +274,54 @@
<Component id="lblDraftCube" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblDraftCube" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="cbDeckType" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="102" attributes="0">
<Component id="lbDeckType" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
</Group> <Component id="cbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <Component id="lbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> </Group>
<Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblMullgian" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbMulligan" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbPlaneChase" alignment="3" max="32767" attributes="0"/>
</Group>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblPacks" min="-2" max="-2" attributes="0"/> <Component id="lblPacks" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="pnlPacks" min="-2" max="-2" attributes="0"/> <Component id="pnlPacks" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlRandomPacks" max="32767" attributes="0"/> <Component id="pnlRandomPacks" pref="10" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="103" alignment="1" groupAlignment="3" attributes="0"> <Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="cbAllowSpectators" alignment="3" max="32767" attributes="0"/>
<Component id="cbPlaneChase" alignment="3" max="32767" attributes="0"/>
<Component id="spnNumRounds" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnNumRounds" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumRounds" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblNumRounds" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="lblNbrPlayers" alignment="1" max="32767" attributes="0"/> <Component id="lblNbrPlayers" alignment="1" max="32767" attributes="0"/>
<Component id="spnNumPlayers" alignment="1" max="32767" attributes="1"/> <Component id="spnNumPlayers" alignment="1" pref="23" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" alignment="1" pref="0" max="32767" attributes="1"/> <Component id="pnlDraftOptions" alignment="1" pref="23" max="32767" attributes="1"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="lblNbrSeats" alignment="1" max="32767" attributes="0"/> <Component id="lblNbrSeats" alignment="1" max="32767" attributes="0"/>
<Component id="spnNumSeats" alignment="1" max="32767" attributes="1"/> <Component id="spnNumSeats" alignment="1" max="32767" attributes="1"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblPlayer1" min="-2" pref="25" max="-2" attributes="0"/> <Component id="lblPlayer1" min="-2" pref="25" max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
@ -210,17 +330,21 @@
<Component id="chkRollbackTurnsAllowed" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="chkRollbackTurnsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="player1Panel" min="-2" pref="62" max="-2" attributes="0"/> <Component id="player1Panel" min="-2" pref="62" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlPlayers" max="32767" attributes="0"/> <Component id="pnlPlayers" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="btnSavedConfiguration1" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="btnSavedConfiguration2" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnSettingsLoad" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnSettingsSave" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblSettings" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnOk" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -312,6 +436,9 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblFreeMulligans"> <Component class="javax.swing.JLabel" name="lblFreeMulligans">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="spnFreeMulligans"/>
</Property>
<Property name="text" type="java.lang.String" value="Free Mulligans:"/> <Property name="text" type="java.lang.String" value="Free Mulligans:"/>
</Properties> </Properties>
</Component> </Component>
@ -390,8 +517,16 @@
<Property name="rows" type="int" value="0"/> <Property name="rows" type="int" value="0"/>
</Layout> </Layout>
</Container> </Container>
<Component class="javax.swing.JLabel" name="lblNbrPlayers"> <Properties> <Property name="text" type="java.lang.String" value="Players:"/> </Properties> </Component> <Component class="javax.swing.JLabel" name="lblNbrPlayers">
<Component class="javax.swing.JLabel" name="lblNbrSeats"> <Properties> <Property name="text" type="java.lang.String" value="Seats:"/> </Properties> </Component> <Properties>
<Property name="text" type="java.lang.String" value="Players:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblNbrSeats">
<Properties>
<Property name="text" type="java.lang.String" value="Seats:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnNumPlayers"> <Component class="javax.swing.JSpinner" name="spnNumPlayers">
<Events> <Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumPlayersStateChanged"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumPlayersStateChanged"/>
@ -402,7 +537,7 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumSeatsStateChanged"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumSeatsStateChanged"/>
</Events> </Events>
</Component> </Component>
<Container class="javax.swing.JPanel" name="pnlDraftOptions"> <Container class="javax.swing.JPanel" name="pnlDraftOptions">
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
@ -459,11 +594,10 @@
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="cbPlaneChase"> <Component class="javax.swing.JCheckBox" name="cbPlaneChase">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Plane Chase"/> <Property name="text" type="java.lang.String" value="PlaneChase"/>
<Property name="toolTipText" type="java.lang.String" value="Use Plane Chase for the tournament."/> <Property name="toolTipText" type="java.lang.String" value="Use Plane Chase for the tournament."/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblPlayer1"> <Component class="javax.swing.JLabel" name="lblPlayer1">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
@ -479,7 +613,7 @@
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkRollbackTurnsAllowed"> <Component class="javax.swing.JCheckBox" name="chkRollbackTurnsAllowed">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Allow rollbacks"/> <Property name="text" type="java.lang.String" value="Rollbacks"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Allow to rollback to the start of previous turns&lt;br&gt; if all players agree. "/> <Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Allow to rollback to the start of previous turns&lt;br&gt; if all players agree. "/>
</Properties> </Properties>
</Component> </Component>
@ -505,7 +639,7 @@
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" alignment="0" pref="5" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
@ -527,25 +661,9 @@
</Container> </Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JButton" name="btnSavedConfiguration1"> <Component class="javax.swing.JButton" name="btnOk">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="C1"/> <Property name="text" type="java.lang.String" value="Create"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSavedConfigurationActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnSavedConfiguration2">
<Properties>
<Property name="text" type="java.lang.String" value="C2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSavedConfigurationActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnOk">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
@ -575,7 +693,7 @@
</Container> </Container>
<Component class="javax.swing.JLabel" name="lblQuitRatio"> <Component class="javax.swing.JLabel" name="lblQuitRatio">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Allow players with quit (%):"/> <Property name="text" type="java.lang.String" value="Allowed quit %"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnQuitRatio"> <Component class="javax.swing.JSpinner" name="spnQuitRatio">
@ -583,5 +701,65 @@
<Property name="toolTipText" type="java.lang.String" value=""/> <Property name="toolTipText" type="java.lang.String" value=""/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblMinimumRating">
<Properties>
<Property name="text" type="java.lang.String" value="Minimum rating:"/>
<Property name="toolTipText" type="java.lang.String" value="Players with rating less than this value can&apos;t join this table"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnMinimumRating">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnMinimumRatingnumPlayersChanged"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="chkRated">
<Properties>
<Property name="text" type="java.lang.String" value="Rated game"/>
<Property name="toolTipText" type="java.lang.String" value="Indicates if matches will be rated"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblMullgian">
<Properties>
<Property name="text" type="java.lang.String" value="Mulligan type:"/>
<Property name="toolTipText" type="java.lang.String" value="What style of mulligan?"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="NewTableDialog_lblMullgian"/>
</AuxValues>
</Component>
<Component class="javax.swing.JComboBox" name="cbMulligan">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Selections the type of mulligan for games."/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="btnSettingsSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save..."/>
<Property name="toolTipText" type="java.lang.String" value="Save settings"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnSettingsSaveMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnSettingsLoad">
<Properties>
<Property name="text" type="java.lang.String" value="Load..."/>
<Property name="toolTipText" type="java.lang.String" value="Load settings"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="btnSettingsLoadMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblSettings">
<Properties>
<Property name="text" type="java.lang.String" value="Settings"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,37 +1,17 @@
/*
* 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.dialog; package mage.client.dialog;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.DefaultListModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.KeyStroke;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import mage.choices.Choice; import mage.choices.Choice;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.MageDialogState; import mage.client.util.gui.MageDialogState;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
/** /**
*
* @author JayDi85 * @author JayDi85
* @author Salco * @author Salco
*/ */
@ -42,28 +22,29 @@ public class PickCheckBoxDialog extends MageDialog {
ArrayList<KeyValueItem> allItems = new ArrayList<>(); ArrayList<KeyValueItem> allItems = new ArrayList<>();
DefaultListModel<KeyValueItem> dataModel = new DefaultListModel(); DefaultListModel<KeyValueItem> dataModel = new DefaultListModel();
CheckBoxList.CheckBoxListModel m_dataModel; CheckBoxList.CheckBoxListModel m_dataModel;
CheckBoxList tList; CheckBoxList tList;
final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>"; final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>";
private void setFocus(CheckBoxList obj){ private void setFocus(CheckBoxList obj) {
if (!(obj instanceof java.awt.Component)) { if (!(obj instanceof java.awt.Component)) {
throw new IllegalArgumentException("Must be a java.awt.Component!"); throw new IllegalArgumentException("Must be a java.awt.Component!");
} }
this.scrollList.setViewportView((java.awt.Component)obj); this.scrollList.setViewportView(obj);
}
private javax.swing.JList get_a_Jlist_from_ScrollListView(){
return ((javax.swing.JList)this.scrollList.getViewport().getView());
} }
private void restoreData(Object dataFrom){ private javax.swing.JList get_a_Jlist_from_ScrollListView() {
return ((javax.swing.JList) this.scrollList.getViewport().getView());
}
private void restoreData(Object dataFrom) {
this.allItems.forEach((item) -> { this.allItems.forEach((item) -> {
((CheckBoxList.CheckBoxListModel)dataFrom).addElement(item.getObjectValue()); ((CheckBoxList.CheckBoxListModel) dataFrom).addElement(item.getObjectValue());
}); });
} }
public void showDialog(Choice choice) { public void showDialog(Choice choice) {
showDialog(choice, null, null, null); showDialog(choice, null, null, null);
} }
@ -75,47 +56,45 @@ public class PickCheckBoxDialog extends MageDialog {
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) { public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) {
showDialog(choice, objectId, mageDialogState, null); showDialog(choice, objectId, mageDialogState, null);
} }
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState, String startSelectionValue) { public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState, String startSelectionValue) {
this.choice = choice; this.choice = choice;
KeyValueItem tempKeyValue; KeyValueItem tempKeyValue;
int indexInTList; int indexInTList;
setLabelText(this.labelMessage, choice.getMessage()); setLabelText(this.labelMessage, choice.getMessage());
setLabelText(this.labelSubMessage, choice.getSubMessage()); setLabelText(this.labelSubMessage, choice.getSubMessage());
btCancel.setEnabled(!choice.isRequired()); btCancel.setEnabled(!choice.isRequired());
// 2 modes: string or key-values // 2 modes: string or key-values
// sore data in allItems for inremental filtering // sore data in allItems for inremental filtering
// http://logicbig.com/tutorials/core-java-tutorial/swing/list-filter/ // http://logicbig.com/tutorials/core-java-tutorial/swing/list-filter/
this.allItems.clear(); this.allItems.clear();
if (choice.isKeyChoice()){ if (choice.isKeyChoice()) {
for (Map.Entry<String, String> entry: choice.getKeyChoices().entrySet()) { for (Map.Entry<String, String> entry : choice.getKeyChoices().entrySet()) {
if(tList != null){ if (tList != null) {
indexInTList = m_dataModel.indexOf(entry.getKey()); indexInTList = m_dataModel.indexOf(entry.getKey());
tempKeyValue=new KeyValueItem(entry.getKey(), entry.getValue(),(CheckBoxList.CheckBoxListItem) this.tList.getModel().getElementAt(indexInTList)); tempKeyValue = new KeyValueItem(entry.getKey(), entry.getValue(), (CheckBoxList.CheckBoxListItem) this.tList.getModel().getElementAt(indexInTList));
} } else {
else{ tempKeyValue = new KeyValueItem(entry.getKey(), entry.getValue());
tempKeyValue=new KeyValueItem(entry.getKey(), entry.getValue());
} }
this.allItems.add(tempKeyValue); this.allItems.add(tempKeyValue);
} }
} else { } else {
for (String value: choice.getChoices()){ for (String value : choice.getChoices()) {
if(tList != null){ if (tList != null) {
indexInTList = m_dataModel.indexOf(value); indexInTList = m_dataModel.indexOf(value);
tempKeyValue=new KeyValueItem(value, value,(CheckBoxList.CheckBoxListItem) tList.getModel().getElementAt(indexInTList)); tempKeyValue = new KeyValueItem(value, value, (CheckBoxList.CheckBoxListItem) tList.getModel().getElementAt(indexInTList));
} } else {
else{ tempKeyValue = new KeyValueItem(value, value);
tempKeyValue=new KeyValueItem(value, value);
} }
this.allItems.add(tempKeyValue); this.allItems.add(tempKeyValue);
} }
} }
// sorting // sorting
if(choice.isSortEnabled()){ if (choice.isSortEnabled()) {
Collections.sort(this.allItems, new Comparator<KeyValueItem>() { Collections.sort(this.allItems, new Comparator<KeyValueItem>() {
@Override @Override
public int compare(KeyValueItem o1, KeyValueItem o2) { public int compare(KeyValueItem o1, KeyValueItem o2) {
@ -125,38 +104,37 @@ public class PickCheckBoxDialog extends MageDialog {
} }
}); });
} }
// search // search
if(choice.isSearchEnabled()) if (choice.isSearchEnabled()) {
{
panelSearch.setVisible(true); panelSearch.setVisible(true);
this.editSearch.setText(choice.getSearchText()); this.editSearch.setText(choice.getSearchText());
}else{ } else {
panelSearch.setVisible(false); panelSearch.setVisible(false);
this.editSearch.setText(""); this.editSearch.setText("");
} }
// listeners for inremental filtering // listeners for inremental filtering
editSearch.getDocument().addDocumentListener(new DocumentListener() { editSearch.getDocument().addDocumentListener(new DocumentListener() {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
choice.setSearchText(editSearch.getText()); choice.setSearchText(editSearch.getText());
loadData(); loadData();
} }
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
choice.setSearchText(editSearch.getText()); choice.setSearchText(editSearch.getText());
loadData(); loadData();
} }
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
choice.setSearchText(editSearch.getText()); choice.setSearchText(editSearch.getText());
loadData(); loadData();
} }
}); });
// listeners for select up and down without edit focus lost // listeners for select up and down without edit focus lost
editSearch.addKeyListener(new KeyListener() { editSearch.addKeyListener(new KeyListener() {
@Override @Override
@ -165,10 +143,10 @@ public class PickCheckBoxDialog extends MageDialog {
} }
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP){ if (e.getKeyCode() == KeyEvent.VK_UP) {
doPrevSelect(); doPrevSelect();
}else if(e.getKeyCode() == KeyEvent.VK_DOWN){ } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
doNextSelect(); doNextSelect();
} }
} }
@ -178,19 +156,19 @@ public class PickCheckBoxDialog extends MageDialog {
//System.out.println("released"); //System.out.println("released");
} }
}); });
// listeners double click choose // listeners double click choose
listChoices.addMouseListener(new MouseAdapter() { listChoices.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(e.getClickCount() == 2){ if (e.getClickCount() == 2) {
doChoose(); doChoose();
} }
} }
}); });
// listeners for ESC close // listeners for ESC close
if(!choice.isRequired()){ if (!choice.isRequired()) {
String cancelName = "cancel"; String cancelName = "cancel";
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
@ -201,107 +179,104 @@ public class PickCheckBoxDialog extends MageDialog {
} }
}); });
} }
// window settings // window settings
if (this.isModal()){ MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
}else{ } else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
} }
if (mageDialogState != null) { if (mageDialogState != null) mageDialogState.setStateToDialog(this);
mageDialogState.setStateToDialog(this); else this.makeWindowCentered();
} else {
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight());
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
}
// final load // final load
loadData(); loadData();
// start selection // start selection
if((startSelectionValue != null)){ if ((startSelectionValue != null)) {
javax.swing.JList currentlistChoices;// = new javax.swing.JList(); javax.swing.JList currentlistChoices;// = new javax.swing.JList();
currentlistChoices=this.get_a_Jlist_from_ScrollListView(); currentlistChoices = this.get_a_Jlist_from_ScrollListView();
/*currentlistChoices = this.listChoices;*/ /*currentlistChoices = this.listChoices;*/
int selectIndex = -1; int selectIndex = -1;
for(int i = 0; i < this.listChoices.getModel().getSize(); i++){ for (int i = 0; i < this.listChoices.getModel().getSize(); i++) {
//KeyValueItem listItem = (KeyValueItem)currentlistChoices.getModel().getElementAt(i); //KeyValueItem listItem = (KeyValueItem)currentlistChoices.getModel().getElementAt(i);
String elementOfList = currentlistChoices.getModel().getElementAt(i).toString(); String elementOfList = currentlistChoices.getModel().getElementAt(i).toString();
if (elementOfList.equals(startSelectionValue)){ if (elementOfList.equals(startSelectionValue)) {
selectIndex = i; selectIndex = i;
break; break;
} }
} }
if(selectIndex >= 0){ if (selectIndex >= 0) {
// currentlistChoices=this.get_a_Jlist_from_ScrollListView(); // currentlistChoices=this.get_a_Jlist_from_ScrollListView();
/*currentlistChoices = this.listChoices;*/ /*currentlistChoices = this.listChoices;*/
currentlistChoices.setSelectedIndex(selectIndex); currentlistChoices.setSelectedIndex(selectIndex);
currentlistChoices.ensureIndexIsVisible(selectIndex); currentlistChoices.ensureIndexIsVisible(selectIndex);
} }
} }
this.setVisible(true); this.setVisible(true);
} }
public void setWindowSize(int width, int heigth){ public void setWindowSize(int width, int heigth) {
this.setSize(new Dimension(width, heigth)); this.setSize(new Dimension(width, heigth));
} }
private void loadData(){ private void loadData() {
// load data to datamodel after filter or on startup // load data to datamodel after filter or on startup
String filter = choice.getSearchText(); String filter = choice.getSearchText();
if (filter == null){ filter = ""; } if (filter == null) {
filter = "";
}
filter = filter.toLowerCase(); filter = filter.toLowerCase();
this.dataModel.clear(); this.dataModel.clear();
this.m_dataModel.clear(); this.m_dataModel.clear();
for(KeyValueItem item: this.allItems){ for (KeyValueItem item : this.allItems) {
if(!choice.isSearchEnabled() || item.Value.toLowerCase().contains(filter)){ if (!choice.isSearchEnabled() || item.Value.toLowerCase().contains(filter)) {
this.dataModel.addElement(item); this.dataModel.addElement(item);
this.m_dataModel.addElement(item.getObjectValue()); this.m_dataModel.addElement(item.getObjectValue());
} }
} }
} }
private void setLabelText(JLabel label, String text){ private void setLabelText(JLabel label, String text) {
if ((text != null) && !text.equals("")){ if ((text != null) && !text.equals("")) {
label.setText(String.format(HTML_TEMPLATE, text)); label.setText(String.format(HTML_TEMPLATE, text));
label.setVisible(true); label.setVisible(true);
}else{ } else {
label.setText(""); label.setText("");
label.setVisible(false); label.setVisible(false);
}
}
private void doNextSelect(){
int newSel = this.listChoices.getSelectedIndex() + 1;
int maxSel = this.listChoices.getModel().getSize() - 1;
if(newSel <= maxSel){
this.listChoices.setSelectedIndex(newSel);
this.listChoices.ensureIndexIsVisible(newSel);
} }
} }
private void doPrevSelect(){ private void doNextSelect() {
int newSel = this.listChoices.getSelectedIndex() - 1; int newSel = this.listChoices.getSelectedIndex() + 1;
if(newSel >= 0){ int maxSel = this.listChoices.getModel().getSize() - 1;
if (newSel <= maxSel) {
this.listChoices.setSelectedIndex(newSel); this.listChoices.setSelectedIndex(newSel);
this.listChoices.ensureIndexIsVisible(newSel); this.listChoices.ensureIndexIsVisible(newSel);
} }
} }
private void doChoose(){ private void doPrevSelect() {
if((tList != null)||(setChoice())){ int newSel = this.listChoices.getSelectedIndex() - 1;
if (newSel >= 0) {
this.listChoices.setSelectedIndex(newSel);
this.listChoices.ensureIndexIsVisible(newSel);
}
}
private void doChoose() {
if ((tList != null) || (setChoice())) {
this.m_dataModel.clear(); this.m_dataModel.clear();
restoreData(this.m_dataModel); restoreData(this.m_dataModel);
this.hideDialog(); this.hideDialog();
} }
} }
private void doCancel(){ private void doCancel() {
this.listChoices.clearSelection(); this.listChoices.clearSelection();
this.choice.clearChoice(); this.choice.clearChoice();
hideDialog(); hideDialog();
@ -309,91 +284,93 @@ public class PickCheckBoxDialog extends MageDialog {
/** /**
* Creates new form PickChoiceDialog * Creates new form PickChoiceDialog
* @param list *
* @param list
*/ */
public PickCheckBoxDialog(CheckBoxList list) { public PickCheckBoxDialog(CheckBoxList list) {
initComponents(); initComponents();
tList=list; tList = list;
this.listChoices.setModel(dataModel); this.listChoices.setModel(dataModel);
this.setModal(true); this.setModal(true);
if(tList != null) if (tList != null) {
{
this.listChoices.setVisible(false); this.listChoices.setVisible(false);
m_dataModel= ( CheckBoxList.CheckBoxListModel )tList.getModel(); m_dataModel = (CheckBoxList.CheckBoxListModel) tList.getModel();
tList.setSelectionForeground(Color.BLUE); tList.setSelectionForeground(Color.BLUE);
if(this.tList instanceof javax.swing.JList){ if (this.tList instanceof javax.swing.JList) {
setFocus(tList); setFocus(tList);
} }
} }
} }
/** /**
* Creates new form PickChoiceDialog * Creates new form PickChoiceDialog
*/ */
public PickCheckBoxDialog() { public PickCheckBoxDialog() {
this(null); this(null);
} }
public boolean setChoice() { public boolean setChoice() {
KeyValueItem item = (KeyValueItem)this.listChoices.getSelectedValue(); KeyValueItem item = (KeyValueItem) this.listChoices.getSelectedValue();
// auto select one item (after incemental filtering) // auto select one item (after incemental filtering)
if((item == null) && (this.listChoices.getModel().getSize() == 1)){ if ((item == null) && (this.listChoices.getModel().getSize() == 1)) {
this.listChoices.setSelectedIndex(0); this.listChoices.setSelectedIndex(0);
item = (KeyValueItem)this.listChoices.getSelectedValue(); item = (KeyValueItem) this.listChoices.getSelectedValue();
} }
if(item != null){ if (item != null) {
if(choice.isKeyChoice()){ if (choice.isKeyChoice()) {
choice.setChoiceByKey(item.getKey()); choice.setChoiceByKey(item.getKey());
}else{ } else {
choice.setChoice(item.getKey()); choice.setChoice(item.getKey());
} }
return true; return true;
}else{ } else {
choice.clearChoice(); choice.clearChoice();
return false; return false;
} }
} }
class KeyValueItem class KeyValueItem {
{
private final String Key; private final String Key;
private final String Value; private final String Value;
private final CheckBoxList.CheckBoxListItem objectValue; private final CheckBoxList.CheckBoxListItem objectValue;
public KeyValueItem(String value) { public KeyValueItem(String value) {
this(value,null,null); this(value, null, null);
}
public KeyValueItem(String value, String label) {
this(value,label,null);
} }
public KeyValueItem(String value, String label,CheckBoxList.CheckBoxListItem object) {
public KeyValueItem(String value, String label) {
this(value, label, null);
}
public KeyValueItem(String value, String label, CheckBoxList.CheckBoxListItem object) {
this.Key = value; this.Key = value;
this.Value = label; this.Value = label;
this.objectValue = object; this.objectValue = object;
} }
public String getKey() { public String getKey() {
return this.Key; return this.Key;
} }
public String getValue() { public String getValue() {
return this.Value; return this.Value;
} }
public Object getObjectValue(){ public Object getObjectValue() {
return (CheckBoxList.CheckBoxListItem)this.objectValue; return this.objectValue;
} }
@Override @Override
public String toString() { public String toString() {
return this.Value; return this.Value;
} }
} }
/** /**
@ -428,20 +405,20 @@ public class PickCheckBoxDialog extends MageDialog {
javax.swing.GroupLayout panelHeaderLayout = new javax.swing.GroupLayout(panelHeader); javax.swing.GroupLayout panelHeaderLayout = new javax.swing.GroupLayout(panelHeader);
panelHeader.setLayout(panelHeaderLayout); panelHeader.setLayout(panelHeaderLayout);
panelHeaderLayout.setHorizontalGroup( panelHeaderLayout.setHorizontalGroup(
panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHeaderLayout.createSequentialGroup() .addGroup(panelHeaderLayout.createSequentialGroup()
.addGroup(panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(labelMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(labelSubMessage, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(labelSubMessage, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
panelHeaderLayout.setVerticalGroup( panelHeaderLayout.setVerticalGroup(
panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHeaderLayout.createSequentialGroup() .addGroup(panelHeaderLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(labelMessage) .addComponent(labelMessage)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelSubMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addComponent(labelSubMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE))
); );
labelSearch.setText("Search:"); labelSearch.setText("Search:");
@ -451,28 +428,34 @@ public class PickCheckBoxDialog extends MageDialog {
javax.swing.GroupLayout panelSearchLayout = new javax.swing.GroupLayout(panelSearch); javax.swing.GroupLayout panelSearchLayout = new javax.swing.GroupLayout(panelSearch);
panelSearch.setLayout(panelSearchLayout); panelSearch.setLayout(panelSearchLayout);
panelSearchLayout.setHorizontalGroup( panelSearchLayout.setHorizontalGroup(
panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelSearchLayout.createSequentialGroup() .addGroup(panelSearchLayout.createSequentialGroup()
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(labelSearch) .addComponent(labelSearch)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(editSearch) .addComponent(editSearch)
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
panelSearchLayout.setVerticalGroup( panelSearchLayout.setVerticalGroup(
panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelSearchLayout.createSequentialGroup() .addGroup(panelSearchLayout.createSequentialGroup()
.addGap(3, 3, 3) .addGap(3, 3, 3)
.addGroup(panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(labelSearch) .addComponent(labelSearch)
.addComponent(editSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(editSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)) .addGap(3, 3, 3))
); );
listChoices.setModel(new javax.swing.AbstractListModel() { listChoices.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "item1", "item2", "item3" }; String[] strings = {"item1", "item2", "item3"};
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; } public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
}); });
scrollList.setViewportView(listChoices); scrollList.setViewportView(listChoices);
@ -501,25 +484,25 @@ public class PickCheckBoxDialog extends MageDialog {
javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands); javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
panelCommands.setLayout(panelCommandsLayout); panelCommands.setLayout(panelCommandsLayout);
panelCommandsLayout.setHorizontalGroup( panelCommandsLayout.setHorizontalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup() .addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btClear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btClear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btOK) .addComponent(btOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
panelCommandsLayout.setVerticalGroup( panelCommandsLayout.setVerticalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup() .addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btCancel) .addComponent(btCancel)
.addComponent(btOK) .addComponent(btOK)
.addComponent(btClear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btClear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap()) .addContainerGap())
); );
getRootPane().setDefaultButton(btOK); getRootPane().setDefaultButton(btOK);
@ -528,28 +511,28 @@ public class PickCheckBoxDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(scrollList, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(scrollList, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panelCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelSearch, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(panelSearch, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(panelHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scrollList, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE) .addComponent(scrollList, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addContainerGap())
); );
pack(); pack();

View file

@ -1,36 +1,17 @@
/*
* 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.dialog; package mage.client.dialog;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.DefaultListModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.KeyStroke;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import mage.choices.Choice; import mage.choices.Choice;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.MageDialogState; import mage.client.util.gui.MageDialogState;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
/** /**
*
* @author JayDi85 * @author JayDi85
*/ */
@ -39,7 +20,7 @@ public class PickChoiceDialog extends MageDialog {
Choice choice; Choice choice;
ArrayList<KeyValueItem> allItems = new ArrayList<>(); ArrayList<KeyValueItem> allItems = new ArrayList<>();
DefaultListModel<KeyValueItem> dataModel = new DefaultListModel(); DefaultListModel<KeyValueItem> dataModel = new DefaultListModel();
final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>"; final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>";
public void showDialog(Choice choice) { public void showDialog(Choice choice) {
@ -53,31 +34,31 @@ public class PickChoiceDialog extends MageDialog {
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) { public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState) {
showDialog(choice, objectId, mageDialogState, null); showDialog(choice, objectId, mageDialogState, null);
} }
public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState, String startSelectionValue) { public void showDialog(Choice choice, UUID objectId, MageDialogState mageDialogState, String startSelectionValue) {
this.choice = choice; this.choice = choice;
setLabelText(this.labelMessage, choice.getMessage()); setLabelText(this.labelMessage, choice.getMessage());
setLabelText(this.labelSubMessage, choice.getSubMessage()); setLabelText(this.labelSubMessage, choice.getSubMessage());
btCancel.setEnabled(!choice.isRequired()); btCancel.setEnabled(!choice.isRequired());
// 2 modes: string or key-values // 2 modes: string or key-values
// sore data in allItems for inremental filtering // sore data in allItems for inremental filtering
// http://logicbig.com/tutorials/core-java-tutorial/swing/list-filter/ // http://logicbig.com/tutorials/core-java-tutorial/swing/list-filter/
this.allItems.clear(); this.allItems.clear();
if (choice.isKeyChoice()){ if (choice.isKeyChoice()) {
for (Map.Entry<String, String> entry: choice.getKeyChoices().entrySet()) { for (Map.Entry<String, String> entry : choice.getKeyChoices().entrySet()) {
this.allItems.add(new KeyValueItem(entry.getKey(), entry.getValue())); this.allItems.add(new KeyValueItem(entry.getKey(), entry.getValue()));
} }
} else { } else {
for (String value: choice.getChoices()){ for (String value : choice.getChoices()) {
this.allItems.add(new KeyValueItem(value, value)); this.allItems.add(new KeyValueItem(value, value));
} }
} }
// sorting // sorting
if(choice.isSortEnabled()){ if (choice.isSortEnabled()) {
Collections.sort(this.allItems, new Comparator<KeyValueItem>() { Collections.sort(this.allItems, new Comparator<KeyValueItem>() {
@Override @Override
public int compare(KeyValueItem o1, KeyValueItem o2) { public int compare(KeyValueItem o1, KeyValueItem o2) {
@ -87,38 +68,37 @@ public class PickChoiceDialog extends MageDialog {
} }
}); });
} }
// search // search
if(choice.isSearchEnabled()) if (choice.isSearchEnabled()) {
{
panelSearch.setVisible(true); panelSearch.setVisible(true);
this.editSearch.setText(choice.getSearchText()); this.editSearch.setText(choice.getSearchText());
}else{ } else {
panelSearch.setVisible(false); panelSearch.setVisible(false);
this.editSearch.setText(""); this.editSearch.setText("");
} }
// listeners for inremental filtering // listeners for inremental filtering
editSearch.getDocument().addDocumentListener(new DocumentListener() { editSearch.getDocument().addDocumentListener(new DocumentListener() {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
choice.setSearchText(editSearch.getText()); choice.setSearchText(editSearch.getText());
loadData(); loadData();
} }
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
choice.setSearchText(editSearch.getText()); choice.setSearchText(editSearch.getText());
loadData(); loadData();
} }
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
choice.setSearchText(editSearch.getText()); choice.setSearchText(editSearch.getText());
loadData(); loadData();
} }
}); });
// listeners for select up and down without edit focus lost // listeners for select up and down without edit focus lost
editSearch.addKeyListener(new KeyListener() { editSearch.addKeyListener(new KeyListener() {
@Override @Override
@ -127,10 +107,10 @@ public class PickChoiceDialog extends MageDialog {
} }
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP){ if (e.getKeyCode() == KeyEvent.VK_UP) {
doPrevSelect(); doPrevSelect();
}else if(e.getKeyCode() == KeyEvent.VK_DOWN){ } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
doNextSelect(); doNextSelect();
} }
} }
@ -140,19 +120,19 @@ public class PickChoiceDialog extends MageDialog {
//System.out.println("released"); //System.out.println("released");
} }
}); });
// listeners double click choose // listeners double click choose
listChoices.addMouseListener(new MouseAdapter() { listChoices.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(e.getClickCount() == 2){ if (e.getClickCount() == 2) {
doChoose(); doChoose();
} }
} }
}); });
// listeners for ESC close // listeners for ESC close
if(!choice.isRequired()){ if (!choice.isRequired()) {
String cancelName = "cancel"; String cancelName = "cancel";
InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
@ -163,37 +143,32 @@ public class PickChoiceDialog extends MageDialog {
} }
}); });
} }
// window settings // window settings
if (this.isModal()){ MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
}else{ } else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
} }
if (mageDialogState != null) { if (mageDialogState != null) mageDialogState.setStateToDialog(this);
mageDialogState.setStateToDialog(this); else this.makeWindowCentered();
} else {
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight());
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
}
// final load // final load
loadData(); loadData();
// start selection // start selection
if((startSelectionValue != null)){ if ((startSelectionValue != null)) {
int selectIndex = -1; int selectIndex = -1;
for(int i = 0; i < this.listChoices.getModel().getSize(); i++){ for (int i = 0; i < this.listChoices.getModel().getSize(); i++) {
KeyValueItem listItem = (KeyValueItem)this.listChoices.getModel().getElementAt(i); KeyValueItem listItem = (KeyValueItem) this.listChoices.getModel().getElementAt(i);
if (listItem.Key.equals(startSelectionValue)){ if (listItem.Key.equals(startSelectionValue)) {
selectIndex = i; selectIndex = i;
break; break;
} }
} }
if(selectIndex >= 0){ if (selectIndex >= 0) {
this.listChoices.setSelectedIndex(selectIndex); this.listChoices.setSelectedIndex(selectIndex);
this.listChoices.ensureIndexIsVisible(selectIndex); this.listChoices.ensureIndexIsVisible(selectIndex);
} }
@ -201,59 +176,61 @@ public class PickChoiceDialog extends MageDialog {
this.setVisible(true); this.setVisible(true);
} }
public void setWindowSize(int width, int heigth){ public void setWindowSize(int width, int height) {
this.setSize(new Dimension(width, heigth)); this.setSize(new Dimension(width, height));
} }
private void loadData(){ private void loadData() {
// load data to datamodel after filter or on startup // load data to datamodel after filter or on startup
String filter = choice.getSearchText(); String filter = choice.getSearchText();
if (filter == null){ filter = ""; } if (filter == null) {
filter = "";
}
filter = filter.toLowerCase(Locale.ENGLISH); filter = filter.toLowerCase(Locale.ENGLISH);
this.dataModel.clear(); this.dataModel.clear();
for(KeyValueItem item: this.allItems){ for (KeyValueItem item : this.allItems) {
if(!choice.isSearchEnabled() || item.Value.toLowerCase(Locale.ENGLISH).contains(filter)){ if (!choice.isSearchEnabled() || item.Value.toLowerCase(Locale.ENGLISH).contains(filter)) {
this.dataModel.addElement(item); this.dataModel.addElement(item);
} }
} }
} }
private void setLabelText(JLabel label, String text){ private void setLabelText(JLabel label, String text) {
if ((text != null) && !text.equals("")){ if ((text != null) && !text.equals("")) {
label.setText(String.format(HTML_TEMPLATE, text)); label.setText(String.format(HTML_TEMPLATE, text));
label.setVisible(true); label.setVisible(true);
}else{ } else {
label.setText(""); label.setText("");
label.setVisible(false); label.setVisible(false);
}
}
private void doNextSelect(){
int newSel = this.listChoices.getSelectedIndex() + 1;
int maxSel = this.listChoices.getModel().getSize() - 1;
if(newSel <= maxSel){
this.listChoices.setSelectedIndex(newSel);
this.listChoices.ensureIndexIsVisible(newSel);
} }
} }
private void doPrevSelect(){ private void doNextSelect() {
int newSel = this.listChoices.getSelectedIndex() - 1; int newSel = this.listChoices.getSelectedIndex() + 1;
if(newSel >= 0){ int maxSel = this.listChoices.getModel().getSize() - 1;
if (newSel <= maxSel) {
this.listChoices.setSelectedIndex(newSel); this.listChoices.setSelectedIndex(newSel);
this.listChoices.ensureIndexIsVisible(newSel); this.listChoices.ensureIndexIsVisible(newSel);
} }
} }
private void doChoose(){ private void doPrevSelect() {
if(setChoice()){ int newSel = this.listChoices.getSelectedIndex() - 1;
if (newSel >= 0) {
this.listChoices.setSelectedIndex(newSel);
this.listChoices.ensureIndexIsVisible(newSel);
}
}
private void doChoose() {
if (setChoice()) {
this.hideDialog(); this.hideDialog();
} }
} }
private void doCancel(){ private void doCancel() {
this.listChoices.clearSelection(); this.listChoices.clearSelection();
this.choice.clearChoice(); this.choice.clearChoice();
hideDialog(); hideDialog();
@ -267,34 +244,33 @@ public class PickChoiceDialog extends MageDialog {
this.listChoices.setModel(dataModel); this.listChoices.setModel(dataModel);
this.setModal(true); this.setModal(true);
} }
public boolean setChoice() { public boolean setChoice() {
KeyValueItem item = (KeyValueItem)this.listChoices.getSelectedValue(); KeyValueItem item = (KeyValueItem) this.listChoices.getSelectedValue();
// auto select one item (after incemental filtering) // auto select one item (after incemental filtering)
if((item == null) && (this.listChoices.getModel().getSize() == 1)){ if ((item == null) && (this.listChoices.getModel().getSize() == 1)) {
this.listChoices.setSelectedIndex(0); this.listChoices.setSelectedIndex(0);
item = (KeyValueItem)this.listChoices.getSelectedValue(); item = (KeyValueItem) this.listChoices.getSelectedValue();
} }
if(item != null){ if (item != null) {
if(choice.isKeyChoice()){ if (choice.isKeyChoice()) {
choice.setChoiceByKey(item.getKey()); choice.setChoiceByKey(item.getKey());
}else{ } else {
choice.setChoice(item.getKey()); choice.setChoice(item.getKey());
} }
return true; return true;
}else{ } else {
choice.clearChoice(); choice.clearChoice();
return false; return false;
} }
} }
class KeyValueItem class KeyValueItem {
{
private final String Key; private final String Key;
private final String Value; private final String Value;
public KeyValueItem(String value, String label) { public KeyValueItem(String value, String label) {
this.Key = value; this.Key = value;
this.Value = label; this.Value = label;
@ -311,7 +287,7 @@ public class PickChoiceDialog extends MageDialog {
@Override @Override
public String toString() { public String toString() {
return this.Value; return this.Value;
} }
} }
/** /**
@ -345,20 +321,20 @@ public class PickChoiceDialog extends MageDialog {
javax.swing.GroupLayout panelHeaderLayout = new javax.swing.GroupLayout(panelHeader); javax.swing.GroupLayout panelHeaderLayout = new javax.swing.GroupLayout(panelHeader);
panelHeader.setLayout(panelHeaderLayout); panelHeader.setLayout(panelHeaderLayout);
panelHeaderLayout.setHorizontalGroup( panelHeaderLayout.setHorizontalGroup(
panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHeaderLayout.createSequentialGroup() .addGroup(panelHeaderLayout.createSequentialGroup()
.addGroup(panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE) .addComponent(labelMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
.addComponent(labelSubMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)) .addComponent(labelSubMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE))
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
panelHeaderLayout.setVerticalGroup( panelHeaderLayout.setVerticalGroup(
panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHeaderLayout.createSequentialGroup() .addGroup(panelHeaderLayout.createSequentialGroup()
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(labelMessage) .addComponent(labelMessage)
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(labelSubMessage)) .addComponent(labelSubMessage))
); );
labelSearch.setText("Search:"); labelSearch.setText("Search:");
@ -368,28 +344,34 @@ public class PickChoiceDialog extends MageDialog {
javax.swing.GroupLayout panelSearchLayout = new javax.swing.GroupLayout(panelSearch); javax.swing.GroupLayout panelSearchLayout = new javax.swing.GroupLayout(panelSearch);
panelSearch.setLayout(panelSearchLayout); panelSearch.setLayout(panelSearchLayout);
panelSearchLayout.setHorizontalGroup( panelSearchLayout.setHorizontalGroup(
panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelSearchLayout.createSequentialGroup() .addGroup(panelSearchLayout.createSequentialGroup()
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(labelSearch) .addComponent(labelSearch)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(editSearch) .addComponent(editSearch)
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
panelSearchLayout.setVerticalGroup( panelSearchLayout.setVerticalGroup(
panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelSearchLayout.createSequentialGroup() .addGroup(panelSearchLayout.createSequentialGroup()
.addGap(3, 3, 3) .addGap(3, 3, 3)
.addGroup(panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(panelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(labelSearch) .addComponent(labelSearch)
.addComponent(editSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(editSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)) .addGap(3, 3, 3))
); );
listChoices.setModel(new javax.swing.AbstractListModel() { listChoices.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "item1", "item2", "item3" }; String[] strings = {"item1", "item2", "item3"};
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; } public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
}); });
scrollList.setViewportView(listChoices); scrollList.setViewportView(listChoices);
@ -410,25 +392,25 @@ public class PickChoiceDialog extends MageDialog {
javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands); javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
panelCommands.setLayout(panelCommandsLayout); panelCommands.setLayout(panelCommandsLayout);
panelCommandsLayout.setHorizontalGroup( panelCommandsLayout.setHorizontalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup() .addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btOK) .addComponent(btOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addContainerGap())
); );
panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btCancel, btOK}); panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, btCancel, btOK);
panelCommandsLayout.setVerticalGroup( panelCommandsLayout.setVerticalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup() .addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btCancel) .addComponent(btCancel)
.addComponent(btOK)) .addComponent(btOK))
.addContainerGap()) .addContainerGap())
); );
getRootPane().setDefaultButton(btOK); getRootPane().setDefaultButton(btOK);
@ -436,28 +418,28 @@ public class PickChoiceDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(scrollList, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(scrollList, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panelCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelCommands, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelSearch, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(panelSearch, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(panelHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scrollList, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE) .addComponent(scrollList, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addContainerGap())
); );
pack(); pack();

View file

@ -1,31 +1,21 @@
/*
* PickNumberDialog.java
*
* Created on Feb 25, 2010, 12:03:39 PM
*/
package mage.client.dialog; package mage.client.dialog;
import java.awt.Point; import mage.client.MageFrame;
import javax.swing.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import javax.swing.*;
import mage.client.MageFrame;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class PickNumberDialog extends MageDialog { public class PickNumberDialog extends MageDialog {
private boolean cancel; private boolean cancel;
/** Creates new form PickNumberDialog */ /**
* Creates new form PickNumberDialog
*/
public PickNumberDialog() { public PickNumberDialog() {
initComponents(); initComponents();
this.setModal(true); this.setModal(true);
@ -40,16 +30,18 @@ public class PickNumberDialog extends MageDialog {
this.pack(); this.pack();
// window settings // window settings
if (this.isModal()){ MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
}else{ } else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
} }
this.getRootPane().setDefaultButton(this.btnOk); // restore default button after root panel change (no need actually) 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) // enable spinner's enter key like text (one enter press instead two)
// https://stackoverflow.com/questions/3873870/java-keylistener-not-firing-on-jspinner // https://stackoverflow.com/questions/3873870/java-keylistener-not-firing-on-jspinner
((JSpinner.DefaultEditor)this.spnAmount.getEditor()).getTextField().addKeyListener(new KeyListener(){ ((JSpinner.DefaultEditor) this.spnAmount.getEditor()).getTextField().addKeyListener(new KeyListener() {
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
@ -68,23 +60,22 @@ public class PickNumberDialog extends MageDialog {
}); });
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight()); this.makeWindowCentered();
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) // TODO: need to fix focus restore on second popup (it's not focues, test on Manamorphose)
this.setVisible(true); this.setVisible(true);
} }
public int getAmount() { public int getAmount() {
return ((Number)spnAmount.getValue()).intValue(); return ((Number) spnAmount.getValue()).intValue();
} }
public boolean isCancel() { public boolean isCancel() {
return cancel; return cancel;
} }
/** This method is called from within the constructor to /**
* This method is called from within the constructor to
* initialize the form. * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor. * always regenerated by the Form Editor.
@ -105,7 +96,7 @@ public class PickNumberDialog extends MageDialog {
lblMessage.setEditable(false); lblMessage.setEditable(false);
lblMessage.setText("long text long text long text long text long text long text long text long text"); lblMessage.setText("long text long text long text long text long text long text long text long text");
lblMessage.setCursor(null ); lblMessage.setCursor(null);
lblMessage.setFocusable(false); lblMessage.setFocusable(false);
lblMessage.setOpaque(false); lblMessage.setOpaque(false);
jScrollPane1.setViewportView(lblMessage); jScrollPane1.setViewportView(lblMessage);
@ -129,22 +120,22 @@ public class PickNumberDialog extends MageDialog {
javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands); javax.swing.GroupLayout panelCommandsLayout = new javax.swing.GroupLayout(panelCommands);
panelCommands.setLayout(panelCommandsLayout); panelCommands.setLayout(panelCommandsLayout);
panelCommandsLayout.setHorizontalGroup( panelCommandsLayout.setHorizontalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup() .addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnOk) .addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel) .addComponent(btnCancel)
.addContainerGap()) .addContainerGap())
); );
panelCommandsLayout.setVerticalGroup( panelCommandsLayout.setVerticalGroup(
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCommandsLayout.createSequentialGroup() .addGroup(panelCommandsLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnOk) .addComponent(btnOk)
.addComponent(btnCancel)) .addComponent(btnCancel))
.addContainerGap()) .addContainerGap())
); );
getRootPane().setDefaultButton(btnOk); getRootPane().setDefaultButton(btnOk);
@ -152,27 +143,27 @@ public class PickNumberDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE) .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) .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.createSequentialGroup()
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))) .addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addContainerGap())
); );
pack(); pack();

View file

@ -1,23 +1,16 @@
package mage.client.dialog; package mage.client.dialog;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Point;
import java.util.UUID;
import javax.swing.JButton;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.cards.CardArea; import mage.client.cards.CardArea;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.view.CardsView; import mage.view.CardsView;
import org.mage.card.arcane.CardPanel; import org.mage.card.arcane.CardPanel;
import javax.swing.*;
import java.awt.*;
import java.util.UUID;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class PickPileDialog extends MageDialog { public class PickPileDialog extends MageDialog {
@ -76,25 +69,20 @@ public class PickPileDialog extends MageDialog {
this.pile1.loadCardsNarrow(pile1, bigCard, gameId); this.pile1.loadCardsNarrow(pile1, bigCard, gameId);
this.pile2.loadCardsNarrow(pile2, bigCard, gameId); this.pile2.loadCardsNarrow(pile2, bigCard, gameId);
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) { this.setModal(true);
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
}
pack(); pack();
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight()); // windows settings
this.setLocation(centered.x, centered.y); MageFrame.getDesktop().remove(this);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this); if (this.isModal()) {
this.revalidate();
this.repaint();
this.setModal(true);
// window settings
if (this.isModal()){
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
}else{ } else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
} }
this.makeWindowCentered();
this.revalidate(); // TODO: remove?
this.repaint(); // TODO: remove?
this.setVisible(true); this.setVisible(true);
} }

View file

@ -236,7 +236,7 @@
<Property name="toolTipText" type="java.lang.String" value="Write the card&apos;s name on the card to make the card name more recognizable."/> <Property name="toolTipText" type="java.lang.String" value="Write the card&apos;s name on the card to make the card name more recognizable."/>
<Property name="actionCommand" type="java.lang.String" value=""/> <Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Standardcursor"/> <Color id="Default Cursor"/>
</Property> </Property>
</Properties> </Properties>
<Events> <Events>
@ -267,7 +267,7 @@
<Property name="selected" type="boolean" value="true"/> <Property name="selected" type="boolean" value="true"/>
<Property name="toolTipText" type="java.lang.String" value="Show the path Xmage is expecting for this card&apos;s image (only displays if missing)"/> <Property name="toolTipText" type="java.lang.String" value="Show the path Xmage is expecting for this card&apos;s image (only displays if missing)"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Standardcursor"/> <Color id="Default Cursor"/>
</Property> </Property>
<Property name="label" type="java.lang.String" value="Display image path for missing images"/> <Property name="label" type="java.lang.String" value="Display image path for missing images"/>
</Properties> </Properties>
@ -4071,7 +4071,7 @@
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="phases_stopSettings" min="-2" max="-2" attributes="0"/> <Component id="phases_stopSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="170" max="32767" attributes="0"/> <EmptySpace pref="160" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -4079,7 +4079,7 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="jLabelHeadLine"> <Component class="javax.swing.JLabel" name="jLabelHeadLine">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Choose phases your game will stop on if not skipped by a skip action (e.g. F6):"/> <Property name="text" type="java.lang.String" value="Default stop steps if not skip buttons activated (e.g. F6):"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabelYourTurn"> <Component class="javax.swing.JLabel" name="jLabelYourTurn">
@ -4112,7 +4112,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabelMain1"> <Component class="javax.swing.JLabel" name="jLabelMain1">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Main:"/> <Property name="text" type="java.lang.String" value="Main 1:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="checkBoxMainYou"> <Component class="javax.swing.JCheckBox" name="checkBoxMainYou">
@ -4159,7 +4159,7 @@
<Properties> <Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Stop settings"> <TitledBorder title="SKIP settings">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/> <EtchetBorder/>
</Border> </Border>
@ -4170,34 +4170,58 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/> <Property name="columns" type="int" value="1"/>
<Property name="rows" type="int" value="7"/> <Property name="rows" type="int" value="9"/>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JCheckBox" name="cbStopAttack"> <Component class="javax.swing.JCheckBox" name="cbStopAttack">
<Properties> <Properties>
<Property name="selected" type="boolean" value="true"/> <Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Stop on declare attackers step if you skip steps (F4/F5/F7) and attackers are available"/> <Property name="text" type="java.lang.String" value="STOP skips on declare attackers if attackers are available"/>
<Property name="toolTipText" type="java.lang.String" value="If you use F4, F5 or F7 to skip steps, you stop on declare attackers step if attackers are available. If this option is not activated, you also skip the declare attackers step with this actions. F9 does always skip the declare attackers step."/> <Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/> <Property name="actionCommand" type="java.lang.String" value=""/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopAttackActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopAttackActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="cbStopBlock"> <Component class="javax.swing.JCheckBox" name="cbStopBlockWithAny">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Stop on your declare blockers step also if no blockers available"/> <Property name="selected" type="boolean" value="true"/>
<Property name="toolTipText" type="java.lang.String" value="Also if you have no blockers to declare, the game stops at the declare blockers step."/> <Property name="text" type="java.lang.String" value="STOP skips on declare blockers if ANY blockers are available"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/> <Property name="actionCommand" type="java.lang.String" value=""/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopBlockActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopBlockWithAnyActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbStopBlockWithZero">
<Properties>
<Property name="text" type="java.lang.String" value="STOP skips on declare blockers if ZERO blockers are available"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopBlockWithZeroActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbStopOnNewStackObjects">
<Properties>
<Property name="text" type="java.lang.String" value="Skip to STACK resolved (F10): stop on new objects added (on) or stop until empty (off)"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 25]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStopOnNewStackObjectsActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="cbStopOnAllMain"> <Component class="javax.swing.JCheckBox" name="cbStopOnAllMain">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Skip with F7 to next main phase (if not activated skip always to your next main phase)"/> <Property name="text" type="java.lang.String" value="Skip to MAIN step (F7): stop on any main steps (on) or stop on your main step (off)"/>
<Property name="toolTipText" type="java.lang.String" value="If activated F7 skips to next main phases (regardless of the active players)."/> <Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/> <Property name="actionCommand" type="java.lang.String" value=""/>
</Properties> </Properties>
<Events> <Events>
@ -4206,8 +4230,8 @@
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="cbStopOnAllEnd"> <Component class="javax.swing.JCheckBox" name="cbStopOnAllEnd">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Skip with F5 to next end step (if not activated only to end steps of opponents)"/> <Property name="text" type="java.lang.String" value="Skip to END step (F5): stop on any end steps (on) or stop on opponents end step (off)"/>
<Property name="toolTipText" type="java.lang.String" value="If activated - F5 skips to the next end step (regardless of the current player)"/> <Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="actionCommand" type="java.lang.String" value=""/> <Property name="actionCommand" type="java.lang.String" value=""/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 25]"/> <Dimension value="[300, 25]"/>
@ -4302,7 +4326,7 @@
<Properties> <Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Card images:"> <TitledBorder title="Card images">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/> <EtchetBorder/>
</Border> </Border>
@ -4351,7 +4375,7 @@
</Group> </Group>
<Component id="cbUseDefaultImageFolder" min="-2" max="-2" attributes="0"/> <Component id="cbUseDefaultImageFolder" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="0" pref="308" max="32767" attributes="0"/> <EmptySpace min="0" pref="391" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -4425,6 +4449,7 @@
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbPreferedImageLanguage"> <Component class="javax.swing.JComboBox" name="cbPreferedImageLanguage">
<Properties> <Properties>
<Property name="maximumRowCount" type="int" value="20"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4"> <StringArray count="4">
<StringItem index="0" value="Item 1"/> <StringItem index="0" value="Item 1"/>
@ -4451,6 +4476,7 @@
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbNumberOfDownloadThreads"> <Component class="javax.swing.JComboBox" name="cbNumberOfDownloadThreads">
<Properties> <Properties>
<Property name="maximumRowCount" type="int" value="20"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4"> <StringArray count="4">
<StringItem index="0" value="Item 1"/> <StringItem index="0" value="Item 1"/>
@ -4467,7 +4493,7 @@
<Properties> <Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Background images setting:"> <TitledBorder title="Background images">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/> <EtchetBorder/>
</Border> </Border>
@ -4608,7 +4634,7 @@
<Properties> <Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Card rendering:"> <TitledBorder title="Card styles (restart xmage to apply new settings)">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/> <EtchetBorder/>
</Border> </Border>
@ -4646,7 +4672,7 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JCheckBox" name="cbCardRenderImageFallback"> <Component class="javax.swing.JCheckBox" name="cbCardRenderImageFallback">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Fall back to plain image based rendering"/> <Property name="text" type="java.lang.String" value="Render mode: MTGO style (off) or IMAGE style (on)"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbCardRenderImageFallbackActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbCardRenderImageFallbackActionPerformed"/>
@ -5776,7 +5802,7 @@
<Component id="jLabel17" min="-2" max="-2" attributes="0"/> <Component id="jLabel17" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace pref="201" max="32767" attributes="0"/> <EmptySpace pref="251" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -6009,11 +6035,8 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0"> <Component id="bttnResetControls" max="32767" attributes="0"/>
<Component id="bttnResetControls" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="labelCancel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="labelCancel" alignment="0" min="-2" max="-2" attributes="0"/>
@ -6026,24 +6049,26 @@
<Component id="labelSkipStep" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="labelSkipStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelConfirm" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="labelConfirm" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="labelToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelSwitchChat" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="keyConfirm" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyConfirm" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyCancelSkip" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyCancelSkip" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyNextTurn" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyNextTurn" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keySkipStack" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keySkipStack" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyYourTurn" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyYourTurn" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyMainStep" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyMainStep" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyPriorEnd" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyPriorEnd" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keySkipStep" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keySkipStep" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyEndStep" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyEndStep" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keyToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="keyToggleRecordMacro" alignment="0" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="keySwitchChat" min="-2" pref="100" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="478" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="481" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -6052,9 +6077,8 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="controlsDescriptionLabel" alignment="0" max="32767" attributes="0"/> <Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="labelConfirm" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="labelConfirm" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="keyConfirm" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="keyConfirm" alignment="3" min="-2" max="-2" attributes="0"/>
@ -6104,10 +6128,16 @@
<Component id="labelToggleRecordMacro" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="labelToggleRecordMacro" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="keyToggleRecordMacro" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="keyToggleRecordMacro" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="labelSwitchChat" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="keySwitchChat" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="bttnResetControls" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="controlsDescriptionLabel" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="bttnResetControls" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -6116,37 +6146,37 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="labelNextTurn"> <Component class="javax.swing.JLabel" name="labelNextTurn">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Next Turn"/> <Property name="text" type="java.lang.String" value="Next Turn:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelEndStep"> <Component class="javax.swing.JLabel" name="labelEndStep">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="End Step"/> <Property name="text" type="java.lang.String" value="End Step:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelMainStep"> <Component class="javax.swing.JLabel" name="labelMainStep">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Main Step"/> <Property name="text" type="java.lang.String" value="Main Step:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelYourTurn"> <Component class="javax.swing.JLabel" name="labelYourTurn">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Your Turn"/> <Property name="text" type="java.lang.String" value="Your Turn:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lebelSkip"> <Component class="javax.swing.JLabel" name="lebelSkip">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Skip Stack"/> <Property name="text" type="java.lang.String" value="Skip Stack:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelPriorEnd"> <Component class="javax.swing.JLabel" name="labelPriorEnd">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Prior End"/> <Property name="text" type="java.lang.String" value="Prior End:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelCancel"> <Component class="javax.swing.JLabel" name="labelCancel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Cancel Skip"/> <Property name="text" type="java.lang.String" value="Cancel Skip:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="mage.client.components.KeyBindButton" name="keyCancelSkip"> <Component class="mage.client.components.KeyBindButton" name="keyCancelSkip">
@ -6215,7 +6245,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelSkipStep"> <Component class="javax.swing.JLabel" name="labelSkipStep">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Skip Step"/> <Property name="text" type="java.lang.String" value="Skip Step:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="mage.client.components.KeyBindButton" name="keyConfirm"> <Component class="mage.client.components.KeyBindButton" name="keyConfirm">
@ -6228,12 +6258,12 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelConfirm"> <Component class="javax.swing.JLabel" name="labelConfirm">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Confirm"/> <Property name="text" type="java.lang.String" value="Confirm:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="controlsDescriptionLabel"> <Component class="javax.swing.JLabel" name="controlsDescriptionLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="&lt;html&gt;Click on a button and press a key to change a keybind.&lt;br&gt;Space and ESC are not available, and will set the keybind to nothing.&lt;br&gt;If you are currently playing a game, the changes will not take effect until you start a new game."/> <Property name="text" type="java.lang.String" value="&lt;html&gt;Click on a button and press a KEY or a combination of CTRL/ALT/SHIF + KEY to change a keybind.&#xa;&lt;br&gt;&#xa;Press SPACE to clear binging.&#xa;&lt;br&gt;&#xa;Press ESC to cancel binding.&#xa;&lt;br&gt;&#xa;New changes will be applied after new game start."/>
<Property name="verticalAlignment" type="int" value="1"/> <Property name="verticalAlignment" type="int" value="1"/>
</Properties> </Properties>
</Component> </Component>
@ -6247,7 +6277,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelToggleRecordMacro"> <Component class="javax.swing.JLabel" name="labelToggleRecordMacro">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Toggle Record Macro"/> <Property name="text" type="java.lang.String" value="Record Macro (unsupported):"/>
</Properties> </Properties>
</Component> </Component>
<Component class="mage.client.components.KeyBindButton" name="keyToggleRecordMacro"> <Component class="mage.client.components.KeyBindButton" name="keyToggleRecordMacro">
@ -6258,6 +6288,19 @@
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new KeyBindButton(this, KEY_CONTROL_TOGGLE_MACRO)"/> <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new KeyBindButton(this, KEY_CONTROL_TOGGLE_MACRO)"/>
</AuxValues> </AuxValues>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelSwitchChat">
<Properties>
<Property name="text" type="java.lang.String" value="Go in/out to chat:"/>
</Properties>
</Component>
<Component class="mage.client.components.KeyBindButton" name="keySwitchChat">
<Properties>
<Property name="text" type="java.lang.String" value="keyBindButton1"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new KeyBindButton(this, KEY_CONTROL_SWITCH_CHAT)"/>
</AuxValues>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
</SubComponents> </SubComponents>

View file

@ -25,7 +25,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
private boolean isRandomDraft; private boolean isRandomDraft;
private boolean isRichManDraft; private boolean isRichManDraft;
private String title = ""; private String title = "";
public final static String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided."); public static final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
public RandomPacksSelectorDialog(boolean isRandomDraft, boolean isRichManDraft) { public RandomPacksSelectorDialog(boolean isRandomDraft, boolean isRichManDraft) {
initComponents(); initComponents();

View file

@ -1,16 +1,18 @@
package mage.client.dialog; package mage.client.dialog;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.SwingWorker;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.SessionHandler; import mage.client.SessionHandler;
import mage.client.preference.MagePreferences; import mage.client.preference.MagePreferences;
import mage.remote.Connection; import mage.remote.Connection;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*;
import java.util.Arrays;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class RegisterUserDialog extends MageDialog { public class RegisterUserDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(ConnectDialog.class); private static final Logger logger = Logger.getLogger(ConnectDialog.class);
@ -106,73 +108,73 @@ public class RegisterUserDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPasswordConfirmationReasoning)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addContainerGap()
.addComponent(lblServer) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lblUserName) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPort) .addComponent(lblPasswordConfirmationReasoning)
.addComponent(lblPassword) .addGroup(layout.createSequentialGroup()
.addComponent(lblPasswordConfirmation) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblEmail)) .addComponent(lblServer)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblUserName)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblPort)
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblPassword)
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblPasswordConfirmation)
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblEmail))
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEmailReasoning) .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup() .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnRegister) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnCancel))) .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(lblEmailReasoning)
.addContainerGap(22, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup()
.addComponent(btnRegister)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)))
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(22, Short.MAX_VALUE))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(9, 9, 9) .addGap(9, 9, 9)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblServer) .addComponent(lblServer)
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPort) .addComponent(lblPort)
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblUserName) .addComponent(lblUserName)
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPassword) .addComponent(lblPassword)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPasswordConfirmation)) .addComponent(lblPasswordConfirmation))
.addComponent(lblPasswordConfirmationReasoning) .addComponent(lblPasswordConfirmationReasoning)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblEmail) .addComponent(lblEmail)
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblEmailReasoning) .addComponent(lblEmailReasoning)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel) .addComponent(btnCancel)
.addComponent(btnRegister)) .addComponent(btnRegister))
.addContainerGap()) .addContainerGap())
); );
pack(); pack();
@ -187,7 +189,7 @@ public class RegisterUserDialog extends MageDialog {
}//GEN-LAST:event_btnCancelActionPerformed }//GEN-LAST:event_btnCancelActionPerformed
private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed
if (!this.txtPassword.getText().equals(this.txtPasswordConfirmation.getText())) { if (!Arrays.equals(this.txtPassword.getPassword(), this.txtPasswordConfirmation.getPassword())) {
MageFrame.getInstance().showError("Passwords don't match."); MageFrame.getInstance().showError("Passwords don't match.");
return; return;
} }
@ -195,7 +197,7 @@ public class RegisterUserDialog extends MageDialog {
connection.setHost(this.txtServer.getText().trim()); connection.setHost(this.txtServer.getText().trim());
connection.setPort(Integer.valueOf(this.txtPort.getText().trim())); connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
connection.setUsername(this.txtUserName.getText().trim()); connection.setUsername(this.txtUserName.getText().trim());
connection.setPassword(this.txtPassword.getText().trim()); connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
connection.setEmail(this.txtEmail.getText().trim()); connection.setEmail(this.txtEmail.getText().trim());
PreferencesDialog.setProxyInformation(connection); PreferencesDialog.setProxyInformation(connection);
task = new ConnectTask(); task = new ConnectTask();

View file

@ -1,16 +1,18 @@
package mage.client.dialog; package mage.client.dialog;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.SwingWorker;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.SessionHandler; import mage.client.SessionHandler;
import mage.client.preference.MagePreferences; import mage.client.preference.MagePreferences;
import mage.remote.Connection; import mage.remote.Connection;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*;
import java.util.Arrays;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class ResetPasswordDialog extends MageDialog { public class ResetPasswordDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(ResetPasswordDialog.class); private static final Logger logger = Logger.getLogger(ResetPasswordDialog.class);
@ -97,51 +99,51 @@ public class ResetPasswordDialog extends MageDialog {
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout); jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel6) .addComponent(jLabel6)
.addGap(0, 0, Short.MAX_VALUE)) .addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(lblAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblPassword, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblPasswordConfirmation, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(lblPasswordConfirmation, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtAuthToken) .addComponent(txtAuthToken)
.addComponent(txtPassword) .addComponent(txtPassword)
.addComponent(txtPasswordConfirmation))) .addComponent(txtPasswordConfirmation)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(0, 204, Short.MAX_VALUE) .addGap(0, 204, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPasswordConfirmationReasoning, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(lblPasswordConfirmationReasoning, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnSubmitNewPassword, javax.swing.GroupLayout.Alignment.TRAILING)))) .addComponent(btnSubmitNewPassword, javax.swing.GroupLayout.Alignment.TRAILING))))
.addContainerGap()) .addContainerGap())
); );
jPanel2Layout.setVerticalGroup( jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel6) .addComponent(jLabel6)
.addGap(24, 24, 24) .addGap(24, 24, 24)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblAuthToken) .addComponent(lblAuthToken)
.addComponent(txtAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPassword) .addComponent(lblPassword)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPasswordConfirmation) .addComponent(lblPasswordConfirmation)
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPasswordConfirmationReasoning) .addComponent(lblPasswordConfirmationReasoning)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnSubmitNewPassword) .addComponent(btnSubmitNewPassword)
.addContainerGap(9, Short.MAX_VALUE)) .addContainerGap(9, Short.MAX_VALUE))
); );
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
@ -158,33 +160,33 @@ public class ResetPasswordDialog extends MageDialog {
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5) .addComponent(jLabel5)
.addGap(0, 0, Short.MAX_VALUE)) .addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lblEmail) .addComponent(lblEmail)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtEmail)) .addComponent(txtEmail))
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnGetAuthToken))) .addComponent(btnGetAuthToken)))
.addContainerGap()) .addContainerGap())
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5) .addComponent(jLabel5)
.addGap(24, 24, 24) .addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblEmail) .addComponent(lblEmail)
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtEmail, 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) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnGetAuthToken) .addComponent(btnGetAuthToken)
.addContainerGap()) .addContainerGap())
); );
btnCancel.setText("Cancel"); btnCancel.setText("Cancel");
@ -199,46 +201,46 @@ public class ResetPasswordDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnCancel)) .addComponent(btnCancel))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblServer) .addComponent(lblServer)
.addComponent(lblPort)) .addComponent(lblPort))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtServer) .addComponent(txtServer)
.addComponent(txtPort)))) .addComponent(txtPort))))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblServer) .addComponent(lblServer)
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPort)) .addComponent(lblPort))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel) .addComponent(btnCancel)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
pack(); pack();
@ -269,11 +271,11 @@ public class ResetPasswordDialog extends MageDialog {
MageFrame.getInstance().showError("Please enter an auth token."); MageFrame.getInstance().showError("Please enter an auth token.");
return; return;
} }
if (this.txtPassword.getText().isEmpty()) { if (String.valueOf(this.txtPassword.getPassword()).trim().isEmpty()) {
MageFrame.getInstance().showError("Please enter a new password."); MageFrame.getInstance().showError("Please enter a new password.");
return; return;
} }
if (!this.txtPassword.getText().equals(this.txtPasswordConfirmation.getText())) { if (!Arrays.equals(this.txtPassword.getPassword(), this.txtPasswordConfirmation.getPassword())) {
MageFrame.getInstance().showError("Passwords don't match."); MageFrame.getInstance().showError("Passwords don't match.");
return; return;
} }
@ -284,7 +286,7 @@ public class ResetPasswordDialog extends MageDialog {
PreferencesDialog.setProxyInformation(connection); PreferencesDialog.setProxyInformation(connection);
connection.setEmail(this.txtEmail.getText().trim()); connection.setEmail(this.txtEmail.getText().trim());
connection.setAuthToken(this.txtAuthToken.getText().trim()); connection.setAuthToken(this.txtAuthToken.getText().trim());
connection.setPassword(this.txtPassword.getText().trim()); connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
resetPasswordTask = new ResetPasswordTask(); resetPasswordTask = new ResetPasswordTask();
resetPasswordTask.execute(); resetPasswordTask.execute();

View file

@ -1,138 +1,137 @@
/* /*
* ShowCardsDialog.java * ShowCardsDialog.java
* *
* Created on 3-Feb-2010, 8:59:11 PM * Created on 3-Feb-2010, 8:59:11 PM
*/ */
package mage.client.dialog; package mage.client.dialog;
import java.awt.Component; import mage.client.MageFrame;
import java.awt.Point; import mage.client.cards.BigCard;
import java.io.Serializable; import mage.client.cards.CardArea;
import java.util.Map; import mage.client.util.Event;
import java.util.UUID; import mage.client.util.Listener;
import javax.swing.JLayeredPane; import mage.client.util.SettingsManager;
import javax.swing.JPopupMenu; import mage.client.util.gui.GuiDisplayUtil;
import javax.swing.SwingUtilities; import mage.game.events.PlayerQueryEvent.QueryType;
import mage.client.MageFrame; import mage.view.CardsView;
import mage.client.cards.BigCard; import org.mage.card.arcane.CardPanel;
import mage.client.cards.CardArea;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.game.events.PlayerQueryEvent.QueryType;
import mage.view.CardsView;
import org.mage.card.arcane.CardPanel;
/** import javax.swing.*;
* @author BetaSteward_at_googlemail.com import java.awt.*;
*/ import java.io.Serializable;
public class ShowCardsDialog extends MageDialog { import java.util.Map;
import java.util.UUID;
// remember if this dialog was already auto positioned, so don't do it after the first time /**
private boolean positioned; * @author BetaSteward_at_googlemail.com
*/
public class ShowCardsDialog extends MageDialog {
/** // remember if this dialog was already auto positioned, so don't do it after the first time
* Creates new form ShowCardsDialog private boolean positioned;
*/
public ShowCardsDialog() {
this.positioned = false;
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); /**
initComponents(); * Creates new form ShowCardsDialog
*/
public ShowCardsDialog() {
this.positioned = false;
this.setModal(false); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
} this.setModal(false);
public void cleanUp() { }
cardArea.cleanUp();
for (Component comp : cardArea.getComponents()) {
if (comp instanceof CardPanel) {
((CardPanel) comp).cleanUp();
cardArea.remove(comp);
}
}
}
@Override public void cleanUp() {
public void changeGUISize() { cardArea.cleanUp();
setGUISize(); for (Component comp : cardArea.getComponents()) {
cardArea.changeGUISize(); if (comp instanceof CardPanel) {
} ((CardPanel) comp).cleanUp();
cardArea.remove(comp);
}
}
}
private void setGUISize() { @Override
public void changeGUISize() {
setGUISize();
cardArea.changeGUISize();
}
} private void setGUISize() {
public void loadCards(String name, CardsView showCards, BigCard bigCard, }
UUID gameId, boolean modal, Map<String, Serializable> options,
JPopupMenu popupMenu, Listener<Event> eventListener) {
this.title = name;
this.setTitelBarToolTip(name);
cardArea.clearCardEventListeners();
cardArea.loadCards(showCards, bigCard, gameId);
if (options != null) {
if (options.containsKey("chosen")) {
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosen");
cardArea.selectCards(chosenCards);
}
if (options.containsKey("choosable")) {
java.util.List<UUID> choosableCards = (java.util.List<UUID>) options.get("choosable");
cardArea.markCards(choosableCards);
}
if (options.containsKey("queryType") && options.get("queryType") == QueryType.PICK_ABILITY) {
cardArea.setPopupMenu(popupMenu);
}
}
if (popupMenu != null) {
this.cardArea.setPopupMenu(popupMenu);
}
if (eventListener != null) {
this.cardArea.addCardEventListener(eventListener);
}
pack(); public void loadCards(String name, CardsView showCards, BigCard bigCard,
UUID gameId, boolean modal, Map<String, Serializable> options,
JPopupMenu popupMenu, Listener<Event> eventListener) {
this.title = name;
this.setTitelBarToolTip(name);
cardArea.clearCardEventListeners();
cardArea.loadCards(showCards, bigCard, gameId);
if (options != null) {
if (options.containsKey("chosen")) {
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosen");
cardArea.selectCards(chosenCards);
}
if (options.containsKey("choosable")) {
java.util.List<UUID> choosableCards = (java.util.List<UUID>) options.get("choosable");
cardArea.markCards(choosableCards);
}
if (options.containsKey("queryType") && options.get("queryType") == QueryType.PICK_ABILITY) {
cardArea.setPopupMenu(popupMenu);
}
}
if (popupMenu != null) {
this.cardArea.setPopupMenu(popupMenu);
}
if (eventListener != null) {
this.cardArea.addCardEventListener(eventListener);
}
this.revalidate(); pack();
this.repaint();
this.setModal(modal);
// window settings this.revalidate();
if (this.isModal()){ this.repaint();
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER); this.setModal(modal);
}else{
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
SwingUtilities.invokeLater(() -> { // window settings
if (!positioned) { MageFrame.getDesktop().remove(this);
int width = ShowCardsDialog.this.getWidth(); if (this.isModal()) {
int height = ShowCardsDialog.this.getHeight(); MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
if (width > 0 && height > 0) { } else {
Point centered = SettingsManager.instance.getComponentPosition(width, height); MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
ShowCardsDialog.this.setLocation(centered.x, centered.y); }
positioned = true;
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
}
}
ShowCardsDialog.this.setVisible(true);
});
}
private void initComponents() { SwingUtilities.invokeLater(() -> {
if (!positioned) {
int width = ShowCardsDialog.this.getWidth();
int height = ShowCardsDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.instance.getComponentPosition(width, height);
ShowCardsDialog.this.setLocation(centered.x, centered.y);
positioned = true;
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
}
}
ShowCardsDialog.this.setVisible(true);
});
}
cardArea = new CardArea(); private void initComponents() {
setClosable(true); cardArea = new CardArea();
setResizable(true);
getContentPane().setLayout(new java.awt.BorderLayout());
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
setGUISize();
pack();
}
private CardArea cardArea; setClosable(true);
} setResizable(true);
getContentPane().setLayout(new java.awt.BorderLayout());
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
setGUISize();
pack();
}
private CardArea cardArea;
}

View file

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</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"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="buttonShowConstModal123" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonShowConstModal321" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="buttonShowDynModal123" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonShowDynModal321" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="buttonShowConstNonModal123" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonShowConstNonModal321" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="buttonShowDynNonModal123" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonShowDynNonModal321" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="buttonPrintFramesList" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="44" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonShowConstModal123" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonShowConstModal321" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonShowDynModal123" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonShowDynModal321" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonShowConstNonModal123" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonShowConstNonModal321" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonShowDynNonModal123" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonShowDynNonModal321" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonPrintFramesList" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="129" max="32767" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Test modal dialog system:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonShowConstModal123">
<Properties>
<Property name="text" type="java.lang.String" value="const modal 123"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstModal123ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonShowConstModal321">
<Properties>
<Property name="text" type="java.lang.String" value="const modal 321"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstModal321ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonShowDynModal123">
<Properties>
<Property name="text" type="java.lang.String" value="dyn modal 123"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynModal123ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonShowDynModal321">
<Properties>
<Property name="text" type="java.lang.String" value="dyn modal 321"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynModal321ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Test mon modal dialog system:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonShowConstNonModal123">
<Properties>
<Property name="text" type="java.lang.String" value="const non modal 123"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstNonModal123ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonShowConstNonModal321">
<Properties>
<Property name="text" type="java.lang.String" value="const non modal 321"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowConstNonModal321ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonShowDynNonModal321">
<Properties>
<Property name="text" type="java.lang.String" value="dyn non modal 321"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynNonModal321ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonShowDynNonModal123">
<Properties>
<Property name="text" type="java.lang.String" value="dyn non modal 123"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonShowDynNonModal123ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonPrintFramesList">
<Properties>
<Property name="text" type="java.lang.String" value="print frames list"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPrintFramesListActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View file

@ -0,0 +1,345 @@
package mage.client.dialog;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.event.KeyEvent;
/**
* @author JayDi85
*/
public class TestModalDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(TestModalDialog.class);
private final TestModalSampleDialog constModalDialog1;
private final TestModalSampleDialog constModalDialog2;
private final TestModalSampleDialog constModalDialog3;
private final TestModalSampleDialog constNonModalDialog1;
private final TestModalSampleDialog constNonModalDialog2;
private final TestModalSampleDialog constNonModalDialog3;
public TestModalDialog() {
initComponents();
constModalDialog1 = new TestModalSampleDialog("const modal dialog 1", true, true, -50, -50);
constModalDialog2 = new TestModalSampleDialog("const modal dialog 2", true, true, -100, -100);
constModalDialog3 = new TestModalSampleDialog("const modal dialog 3", true, true, -150, -150);
constNonModalDialog1 = new TestModalSampleDialog("const non modal dialog 1", false, true, -50, -50);
constNonModalDialog2 = new TestModalSampleDialog("const non modal dialog 2", false, true, -100, -100);
constNonModalDialog3 = new TestModalSampleDialog("const non modal dialog 3", false, true, -150, -150);
}
public void showDialog() {
this.setModal(false);
getRootPane().setDefaultButton(buttonCancel);
// windows settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.makeWindowCentered();
// Close on "ESC"
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setVisible(true);
}
private void onCancel() {
this.removeDialog();
}
private void showLater(TestModalSampleDialog dialog) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
logger.info(dialog.getTitle());
dialog.showDialog();
}
});
}
private void showConstModalDialogs(boolean isReverse) {
if (isReverse) {
showLater(constModalDialog3);
showLater(constModalDialog2);
showLater(constModalDialog1);
} else {
showLater(constModalDialog1);
showLater(constModalDialog2);
showLater(constModalDialog3);
}
}
private void showConstNonModalDialogs(boolean isReverse) {
if (isReverse) {
showLater(constNonModalDialog3);
showLater(constNonModalDialog2);
showLater(constNonModalDialog1);
} else {
showLater(constNonModalDialog1);
showLater(constNonModalDialog2);
showLater(constNonModalDialog3);
}
}
private void showDynModalDialogs(boolean isReverse) {
TestModalSampleDialog dynDialog1 = new TestModalSampleDialog("dyn modal dialog 1", true, false, -50, -50);
TestModalSampleDialog dynDialog2 = new TestModalSampleDialog("dyn modal dialog 2", true, false, -100, -100);
TestModalSampleDialog dynDialog3 = new TestModalSampleDialog("dyn modal dialog 3", true, false, -150, -150);
if (isReverse) {
showLater(dynDialog3);
showLater(dynDialog2);
showLater(dynDialog1);
} else {
showLater(dynDialog1);
showLater(dynDialog2);
showLater(dynDialog3);
}
}
private void showDynNonModalDialogs(boolean isReverse) {
TestModalSampleDialog dynDialog1 = new TestModalSampleDialog("dyn non modal dialog 1", false, false, -50, -50);
TestModalSampleDialog dynDialog2 = new TestModalSampleDialog("dyn non modal dialog 2", false, false, -100, -100);
TestModalSampleDialog dynDialog3 = new TestModalSampleDialog("dyn non modal dialog 3", false, false, -150, -150);
if (isReverse) {
showLater(dynDialog3);
showLater(dynDialog2);
showLater(dynDialog1);
} else {
showLater(dynDialog1);
showLater(dynDialog2);
showLater(dynDialog3);
}
}
/**
* 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
private void initComponents() {
buttonCancel = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
buttonShowConstModal123 = new javax.swing.JButton();
buttonShowConstModal321 = new javax.swing.JButton();
buttonShowDynModal123 = new javax.swing.JButton();
buttonShowDynModal321 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
buttonShowConstNonModal123 = new javax.swing.JButton();
buttonShowConstNonModal321 = new javax.swing.JButton();
buttonShowDynNonModal321 = new javax.swing.JButton();
buttonShowDynNonModal123 = new javax.swing.JButton();
buttonPrintFramesList = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
buttonCancel.setText("Close");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
jLabel1.setText("Test modal dialog system:");
buttonShowConstModal123.setText("const modal 123");
buttonShowConstModal123.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowConstModal123ActionPerformed(evt);
}
});
buttonShowConstModal321.setText("const modal 321");
buttonShowConstModal321.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowConstModal321ActionPerformed(evt);
}
});
buttonShowDynModal123.setText("dyn modal 123");
buttonShowDynModal123.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowDynModal123ActionPerformed(evt);
}
});
buttonShowDynModal321.setText("dyn modal 321");
buttonShowDynModal321.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowDynModal321ActionPerformed(evt);
}
});
jLabel2.setText("Test mon modal dialog system:");
buttonShowConstNonModal123.setText("const non modal 123");
buttonShowConstNonModal123.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowConstNonModal123ActionPerformed(evt);
}
});
buttonShowConstNonModal321.setText("const non modal 321");
buttonShowConstNonModal321.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowConstNonModal321ActionPerformed(evt);
}
});
buttonShowDynNonModal321.setText("dyn non modal 321");
buttonShowDynNonModal321.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowDynNonModal321ActionPerformed(evt);
}
});
buttonShowDynNonModal123.setText("dyn non modal 123");
buttonShowDynNonModal123.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonShowDynNonModal123ActionPerformed(evt);
}
});
buttonPrintFramesList.setText("print frames list");
buttonPrintFramesList.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPrintFramesListActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(buttonShowConstModal123)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonShowConstModal321))
.addGroup(layout.createSequentialGroup()
.addComponent(buttonShowDynModal123)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonShowDynModal321))
.addComponent(jLabel2)
.addGroup(layout.createSequentialGroup()
.addComponent(buttonShowConstNonModal123)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonShowConstNonModal321))
.addGroup(layout.createSequentialGroup()
.addComponent(buttonShowDynNonModal123)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonShowDynNonModal321))
.addComponent(buttonPrintFramesList))
.addGap(0, 44, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonShowConstModal123)
.addComponent(buttonShowConstModal321))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonShowDynModal123)
.addComponent(buttonShowDynModal321))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonShowConstNonModal123)
.addComponent(buttonShowConstNonModal321))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonShowDynNonModal123)
.addComponent(buttonShowDynNonModal321))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonPrintFramesList)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
onCancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonShowConstModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstModal123ActionPerformed
showConstModalDialogs(false);
}//GEN-LAST:event_buttonShowConstModal123ActionPerformed
private void buttonShowConstModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstModal321ActionPerformed
showConstModalDialogs(true);
}//GEN-LAST:event_buttonShowConstModal321ActionPerformed
private void buttonShowDynModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynModal123ActionPerformed
showDynModalDialogs(false);
}//GEN-LAST:event_buttonShowDynModal123ActionPerformed
private void buttonShowDynModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynModal321ActionPerformed
showDynModalDialogs(true);
}//GEN-LAST:event_buttonShowDynModal321ActionPerformed
private void buttonShowConstNonModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstNonModal123ActionPerformed
showConstNonModalDialogs(false);
}//GEN-LAST:event_buttonShowConstNonModal123ActionPerformed
private void buttonShowConstNonModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowConstNonModal321ActionPerformed
showConstNonModalDialogs(true);
}//GEN-LAST:event_buttonShowConstNonModal321ActionPerformed
private void buttonShowDynNonModal321ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynNonModal321ActionPerformed
showDynNonModalDialogs(true);
}//GEN-LAST:event_buttonShowDynNonModal321ActionPerformed
private void buttonShowDynNonModal123ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonShowDynNonModal123ActionPerformed
showDynNonModalDialogs(false);
}//GEN-LAST:event_buttonShowDynNonModal123ActionPerformed
private void buttonPrintFramesListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPrintFramesListActionPerformed
MageDialog.printFramesOrder("print");
}//GEN-LAST:event_buttonPrintFramesListActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonPrintFramesList;
private javax.swing.JButton buttonShowConstModal123;
private javax.swing.JButton buttonShowConstModal321;
private javax.swing.JButton buttonShowConstNonModal123;
private javax.swing.JButton buttonShowConstNonModal321;
private javax.swing.JButton buttonShowDynModal123;
private javax.swing.JButton buttonShowDynModal321;
private javax.swing.JButton buttonShowDynNonModal123;
private javax.swing.JButton buttonShowDynNonModal321;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
// End of variables declaration//GEN-END:variables
}

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</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"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="290" max="32767" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelInfo" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelInfo" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="234" max="32767" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="labelInfo">
<Properties>
<Property name="text" type="java.lang.String" value="Sample dialog"/>
</Properties>
</Component>
</SubComponents>
</Form>

View file

@ -0,0 +1,119 @@
package mage.client.dialog;
import mage.client.MageFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
/**
* @author JayDi85
*/
public class TestModalSampleDialog extends MageDialog {
private final boolean useModal;
private final boolean useHideDialog;
private final int offsetX;
private final int offsetY;
public TestModalSampleDialog(String name, boolean useModal, boolean useHideDialog, int offsetX, int offsetY) {
initComponents();
this.useModal = useModal;
this.useHideDialog = useHideDialog;
this.offsetX = offsetX;
this.offsetY = offsetY;
labelInfo.setText(name);
this.setTitle(name);
}
public void showDialog() {
this.setModal(useModal);
getRootPane().setDefaultButton(buttonCancel);
// windows settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
this.makeWindowCentered();
Point p = this.getLocation();
p.x = p.x + offsetX;
p.y = p.y + offsetY;
this.setLocation(p);
// Close on "ESC"
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
this.setVisible(true);
}
private void onCancel() {
if (useHideDialog) {
this.hideDialog();
} else {
this.removeDialog();
}
}
/**
* 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
private void initComponents() {
buttonCancel = new javax.swing.JButton();
labelInfo = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
buttonCancel.setText("Close");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
labelInfo.setText("Sample dialog");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(290, Short.MAX_VALUE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(labelInfo)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(labelInfo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 234, Short.MAX_VALUE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
onCancel();
}//GEN-LAST:event_buttonCancelActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JLabel labelInfo;
// End of variables declaration//GEN-END:variables
}

View file

@ -1,22 +1,15 @@
/*
* ErrorDialog.java
*
* Created on Dec 23, 2009, 11:01:32 AM
*/
package mage.client.dialog; package mage.client.dialog;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.constants.PlayerAction; import mage.constants.PlayerAction;
import mage.view.UserRequestMessage; import mage.view.UserRequestMessage;
import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.*;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class UserRequestDialog extends MageDialog { public class UserRequestDialog extends MageDialog {
@ -34,7 +27,7 @@ public class UserRequestDialog extends MageDialog {
private void setGUISize() { private void setGUISize() {
Font font = GUISizeHelper.gameRequestsFont; Font font = GUISizeHelper.gameRequestsFont;
lblText.setFont(font); lblText.setFont(font);
lblText.setMaximumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5)); lblText.setMaximumSize(new Dimension(300 + font.getSize() * 15, 200 + font.getSize() * 5));
lblText.setMinimumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5)); lblText.setMinimumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
lblText.setPreferredSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5)); lblText.setPreferredSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
btn1.setFont(font); btn1.setFont(font);
@ -58,7 +51,7 @@ public class UserRequestDialog extends MageDialog {
public void showDialog(UserRequestMessage userRequestMessage) { public void showDialog(UserRequestMessage userRequestMessage) {
this.userRequestMessage = userRequestMessage; this.userRequestMessage = userRequestMessage;
this.setTitle(userRequestMessage.getTitel()); this.setTitle(userRequestMessage.getTitle());
String text = "<html><p style=\"text-align:center; margin-left:10px; margin-right:10px\">" + userRequestMessage.getMessage() + "</p></html>"; String text = "<html><p style=\"text-align:center; margin-left:10px; margin-right:10px\">" + userRequestMessage.getMessage() + "</p></html>";
this.lblText.setText(text); this.lblText.setText(text);
if (userRequestMessage.getButton1Text() != null) { if (userRequestMessage.getButton1Text() != null) {
@ -128,30 +121,30 @@ public class UserRequestDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(btn3, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) .addComponent(btn3, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn2, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) .addComponent(btn2, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn1, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))) .addComponent(btn1, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btn1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btn2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btn3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(btn3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(12, 12, 12)) .addGap(12, 12, 12))
); );
pack(); pack();

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelData" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="buttonRefresh" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="panelData" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonCancel" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="buttonRefresh" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonRefresh">
<Properties>
<Property name="text" type="java.lang.String" value="Refresh"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonRefreshActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="panelData">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Container>
</SubComponents>
</Form>

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