Merge branch 'master' into Network_Upgrade

Conflicts:
	Mage.Client/src/main/java/mage/client/MageFrame.java
	Mage.Client/src/main/java/mage/client/chat/ChatPanel.java
	Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java
	Mage.Client/src/main/java/mage/client/dialog/UserRequestDialog.java
	Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java
	Mage.Client/src/main/java/mage/client/table/TablesPanel.java
	Mage.Common/src/mage/remote/SessionImpl.java
	Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java
This commit is contained in:
betasteward 2015-06-12 08:56:26 -04:00
commit 38da157f8c
807 changed files with 13691 additions and 4039 deletions

5
.gitignore vendored
View file

@ -50,7 +50,8 @@ Mage.Updater/target
mage.updater.client/target
releases
Utils/author.txt
Utils/author.txt
.DS_Store
.metadata
.project
.settings
@ -88,4 +89,4 @@ Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target
*.netbeans_automatic_build
*.txt
Mage.Client/serverlist.txt
/Mage.Network/target/
/Mage.Network/target/

View file

@ -0,0 +1,97 @@
1 [MMQ:316] Dust Bowl
1 [MBS:43] Go for the Throat
1 [ALL:42] Force of Will
1 [ZEN:220] Misty Rainforest
1 [10E:361] Treetop Village
1 [10E:362] Underground River
1 [ROE:115] Inquisition of Kozilek
1 [STH:137] Volrath's Stronghold
1 [PLC:85] Damnation
1 [FUT:173] Tolaria West
1 [ISD:78] Snapcaster Mage
1 [ZEN:67] Spell Pierce
1 [ZEN:229] Verdant Catacombs
1 [M11:70] Preordain
1 [C13:177] Baleful Strix
1 [ZEN:223] Scalding Tarn
1 [MBS:138] Sword of Feast and Famine
1 [NPH:57] Dismember
1 [TMP:58] Dismiss
1 [INV:57] Fact or Fiction
1 [DGM:93] Putrefy
1 [ONS:320] Lonely Sandbar
1 [GTC:240] Breeding Pool
1 [DTK:262] Forest
1 [ISD:105] Liliana of the Veil
1 [TMP:340] Wasteland
1 [JUD:46] Mental Note
1 [ULG:36] Miscalculation
2 [CSP:152] Snow-Covered Island
1 [RAV:63] Remand
1 [LRW:56] Cryptic Command
1 [3ED:283] Bayou
1 [5ED:191] Sylvan Library
1 [CMD:269] Command Tower
1 [EXO:35] Forbid
1 [DDO:36] AEtherize
1 [KTK:36] Dig Through Time
1 [RTR:141] Abrupt Decay
1 [SHM:280] Sunken Ruins
1 [DIS:33] Spell Snare
1 [ARB:92] Maelstrom Pulse
1 [KTK:81] Murderous Cut
1 [TSP:48] Ancestral Vision
1 [TMP:22] Diabolic Edict
1 [10E:319] Crucible of Worlds
1 [M12:63] Mana Leak
1 [FUT:52] Logic Knot
1 [CHK:268] Sensei's Divining Top
1 [THS:225] Temple of Deceit
1 [ODY:317] Cephalid Coliseum
1 [WWK:145] Tectonic Edge
1 [EVE:41] Raven's Crime
1 [C13:96] Toxic Deluge
1 [9ED:152] Phyrexian Arena
1 [KTK:248] Windswept Heath
1 [KTK:204] Sultai Charm
1 [KTK:249] Wooded Foothills
1 [M13:223] Drowned Catacomb
1 [RAV:172] Life from the Loam
1 [THS:107] Thoughtseize
1 [MMQ:61] Brainstorm
1 [M15:244] Llanowar Wastes
1 [ISD:55] Forbidden Alchemy
1 [APC:114] Pernicious Deed
1 [RTR:243] Overgrown Tomb
1 [7ED:76] Force Spike
1 [TMP:70] Intuition
1 [3ED:305] Underground Sea
1 [M15:248] Urborg, Tomb of Yawgmoth
1 [AVR:226] Cavern of Souls
1 [ISD:241] Hinterland Harbor
1 [DKA:52] Thought Scour
1 [3ED:303] Tropical Island
1 [3ED:13] Demonic Tutor
1 [ISD:249] Woodland Cemetery
1 [M12:73] Ponder
1 [DTK:65] Negate
1 [RAV:82] Darkblast
1 [WWK:134] Creeping Tar Pit
1 [GTC:249] Watery Grave
1 [WWK:132] Bojuka Bog
1 [KTK:239] Polluted Delta
1 [KTK:233] Flooded Strand
1 [KTK:59] Treasure Cruise
1 [TSP:202] Krosan Grip
1 [7ED:67] Counterspell
1 [MIR:80] Mystical Tutor
1 [MOR:55] Vendilion Clique
1 [TSP:69] Mystical Teachings
1 [KTK:230] Bloodstained Mire
1 [ZEN:219] Marsh Flats
1 [DTK:256] Swamp
1 [THS:90] Hero's Downfall
3 [DTK:253] Island
1 [WWK:31] Jace, the Mind Sculptor
1 [DTK:98] Duress
SB: 1 [FRF:87] Tasigur, the Golden Fang

View file

@ -93,6 +93,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import static mage.client.dialog.PreferencesDialog.KEY_CONNECT_FLAG;
import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository;
import mage.client.util.audio.AudioManager;
@ -800,10 +801,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
ProxyType proxyType = ProxyType.valueByText(prefs.get("proxyType", "None"));
String proxyUsername = prefs.get("proxyUsername", "");
String proxyPassword = prefs.get("proxyPassword", "");
int avatarId = PreferencesDialog.getSelectedAvatar();
boolean showAbilityPickerForced = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true");
try {
setCursor(new Cursor(Cursor.WAIT_CURSOR));
Connection connection = new Connection();
@ -815,10 +812,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
connection.setProxyPort(proxyPort);
connection.setProxyUsername(proxyUsername);
connection.setProxyPassword(proxyPassword);
connection.setAvatarId(avatarId);
connection.setShowAbilityPickerForced(showAbilityPickerForced);
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
setUserPrefsToConnection(connection);
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
if (connect(connection)) {
return true;
@ -831,6 +827,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
return false;
}
public void setUserPrefsToConnection(Connection connection) {
int avatarId = PreferencesDialog.getSelectedAvatar();
connection.setAvatarId(avatarId);
boolean showAbilityPickerForced = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true");
connection.setShowAbilityPickerForced(showAbilityPickerForced);
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
connection.setConfirmEmptyManaPool(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"));
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
connection.setFlagName(MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world.png"));
}
/**
* This method is called from within the constructor to
* initialize the form.

View file

@ -37,14 +37,24 @@ import java.awt.Color;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTextField;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_WIDTH;
import mage.client.util.MageTableRowSorter;
import mage.client.util.gui.TableUtil;
import mage.client.util.audio.AudioManager;
import mage.remote.MageRemoteException;
import mage.view.ChatMessage;
@ -53,6 +63,7 @@ import mage.view.ChatMessage.MessageColor;
import mage.view.ChatMessage.MessageType;
import mage.view.RoomUsersView;
import mage.view.UsersView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.ManaSymbols;
import org.mage.network.Client;
@ -61,7 +72,9 @@ import org.mage.network.Client;
* @author BetaSteward_at_googlemail.com, nantuko
*/
public class ChatPanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(ChatPanel.class);
private UUID chatId;
private Client client;
private final List<String> players = new ArrayList<>();
@ -120,6 +133,8 @@ public class ChatPanel extends javax.swing.JPanel {
*/
private ChatType chatType = ChatType.DEFAULT;
private static final int[] defaultColumnsWidth = {20, 100, 100, 80};
public enum ChatType {
DEFAULT, GAME, TABLES, TOURNAMENT
@ -147,6 +162,9 @@ public class ChatPanel extends javax.swing.JPanel {
jTablePlayers.setBackground(new Color(0, 0, 0, ALPHA));
jTablePlayers.setForeground(Color.white);
jTablePlayers.setRowSorter(new MageTableRowSorter(tableModel));
TableUtil.setColumnWidthAndOrder(jTablePlayers, defaultColumnsWidth, KEY_USERS_COLUMNS_WIDTH, KEY_USERS_COLUMNS_ORDER);
if (jScrollPaneTxt != null) {
jScrollPaneTxt.setBackground(new Color(0, 0, 0, ALPHA));
jScrollPaneTxt.getViewport().setBackground(new Color(0, 0, 0, ALPHA));
@ -160,6 +178,10 @@ public class ChatPanel extends javax.swing.JPanel {
}
}
public void cleanUp() {
TableUtil.saveColumnWidthAndOrderToPrefs(jTablePlayers, KEY_USERS_COLUMNS_WIDTH, KEY_USERS_COLUMNS_ORDER);
}
public ChatType getChatType() {
return chatType;
}
@ -367,16 +389,20 @@ public class ChatPanel extends javax.swing.JPanel {
class TableModel extends AbstractTableModel {
private final String[] columnNames = new String[]{"Players", "Info", "Games", "Connection"};
private final String[] columnNames = new String[]{" ","Players", "Info", "Games", "Connection"};
private UsersView[] players = new UsersView[0];
private Map<String, ImageIcon> flagIconCache = new HashMap<>();
public void loadData(RoomUsersView roomUserInfo) throws MageRemoteException {
// RoomUsersView roomUserInfo = roomUserInfoList.iterator().next();
this.players = roomUserInfo.getUsersView().toArray(new UsersView[0]);
JTableHeader th = jTablePlayers.getTableHeader();
TableColumnModel tcm = th.getColumnModel();
tcm.getColumn(0).setHeaderValue("Players (" + this.players.length + ")");
tcm.getColumn(2).setHeaderValue(
tcm.getColumn(1).setHeaderValue("Players (" + this.players.length + ")");
tcm.getColumn(3).setHeaderValue(
"Games " + roomUserInfo.getNumberActiveGames() +
(roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads():" (") +
" limit: " + roomUserInfo.getNumberMaxGames() + ")");
@ -398,12 +424,14 @@ public class ChatPanel extends javax.swing.JPanel {
public Object getValueAt(int arg0, int arg1) {
switch (arg1) {
case 0:
return players[arg0].getUserName();
return getCountryFlagIcon(players[arg0].getFlagName());
case 1:
return players[arg0].getInfoState();
return players[arg0].getUserName();
case 2:
return players[arg0].getInfoGames();
return players[arg0].getInfoState();
case 3:
return players[arg0].getInfoGames();
case 4:
return players[arg0].getInfoPing();
}
return "";
@ -422,13 +450,32 @@ public class ChatPanel extends javax.swing.JPanel {
@Override
public Class getColumnClass(int columnIndex) {
return String.class;
switch (columnIndex) {
case 0:
return Icon.class;
default:
return String.class;
}
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
private ImageIcon getCountryFlagIcon(String countryCode) {
ImageIcon flagIcon = flagIconCache.get(countryCode);
if (flagIcon == null) {
flagIcon = new javax.swing.ImageIcon(getClass().getResource("/flags/" + countryCode +".png"));
if (flagIcon.getImage() == null) {
logger.warn("Country flag resource not found: " + countryCode);
} else {
flagIconCache.put(countryCode, flagIcon);
}
}
return flagIcon;
}
}
public void clear() {

View file

@ -187,6 +187,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
break;
case FREE_BUILDING:
this.btnSubmit.setVisible(false);
this.btnAddLand.setVisible(true);
this.cardSelector.loadCards(this.bigCard);
//this.cardTableSelector.loadCards(this.bigCard);
this.btnExit.setVisible(true);
@ -797,7 +798,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLandActionPerformed
AddLandDialog addLand = new AddLandDialog();
addLand.showDialog(deck);
addLand.showDialog(deck, mode);
refreshDeck();
}//GEN-LAST:event_btnAddLandActionPerformed

View file

@ -29,9 +29,9 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
@ -39,34 +39,43 @@
<Component id="lblIsland" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblMountain" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblForest" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblLandSet" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spnMountain" pref="85" max="32767" attributes="0"/>
<Component id="spnIsland" max="32767" attributes="0"/>
<Component id="spnForest" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spnMountain" pref="85" max="32767" attributes="0"/>
<Component id="spnIsland" max="32767" attributes="0"/>
<Component id="spnForest" max="32767" attributes="0"/>
</Group>
<Component id="cbLandSet" min="-2" pref="207" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblPains" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
<Component id="spnPlains" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblSwamp" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
<Component id="spnSwamp" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lblSwamp" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
<Component id="spnSwamp" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblPains" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
<Component id="spnPlains" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="122" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="114" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="btnAutoAdd" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="btnAdd" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="40" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@ -75,6 +84,11 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbLandSet" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLandSet" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblForest" alignment="3" min="-2" max="-2" attributes="0"/>
@ -100,7 +114,7 @@
<Component id="lblSwamp" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnSwamp" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="38" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
@ -112,6 +126,23 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblLandSet">
<Properties>
<Property name="text" type="java.lang.String" value="Set"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbLandSet">
<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>
</Component>
<Component class="javax.swing.JLabel" name="lblForest">
<Properties>
<Property name="text" type="java.lang.String" value="Forest"/>
@ -124,6 +155,11 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblIsland">
<Properties>
<Property name="text" type="java.lang.String" value="Island"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnIsland">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
@ -131,9 +167,16 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblIsland">
<Component class="javax.swing.JLabel" name="lblMountain">
<Properties>
<Property name="text" type="java.lang.String" value="Island"/>
<Property name="text" type="java.lang.String" value="Mountain"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnMountain">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblPains">
@ -148,16 +191,9 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnMountain">
<Component class="javax.swing.JLabel" name="lblSwamp">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblMountain">
<Properties>
<Property name="text" type="java.lang.String" value="Mountain"/>
<Property name="text" type="java.lang.String" value="Swamp"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnSwamp">
@ -167,11 +203,6 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblSwamp">
<Properties>
<Property name="text" type="java.lang.String" value="Swamp"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnAdd">
<Properties>
<Property name="text" type="java.lang.String" value="Add"/>

View file

@ -31,6 +31,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLayeredPane;
import mage.Mana;
import mage.cards.Card;
@ -41,6 +44,7 @@ import mage.cards.repository.CardRepository;
import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame;
import mage.client.constants.Constants.DeckEditorMode;
import mage.constants.Rarity;
/**
@ -60,45 +64,49 @@ public class AddLandDialog extends MageDialog {
this.setModal(true);
}
public void showDialog(Deck deck) {
public void showDialog(Deck deck, DeckEditorMode mode) {
this.deck = deck;
// decide from which sets basic lands are taken from
for (String setCode :deck.getExpansionSetCodes()) {
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
if (expansionInfo != null && expansionInfo.hasBasicLands()) {
this.setCodesland.add(expansionInfo.getCode());
}
}
// if sets have no basic land, take land from block
if (this.setCodesland.isEmpty()) {
SortedSet<String> landSets = new TreeSet<>();
if (!mode.equals(DeckEditorMode.FREE_BUILDING)) {
// decide from which sets basic lands are taken from
for (String setCode :deck.getExpansionSetCodes()) {
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
if (expansionInfo != null) {
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
for (ExpansionInfo blockSet: blockSets) {
if (blockSet.hasBasicLands()) {
this.setCodesland.add(blockSet.getCode());
if (expansionInfo != null && expansionInfo.hasBasicLands()) {
this.setCodesland.add(expansionInfo.getCode());
landSets.add(expansionInfo.getName());
}
}
// if sets have no basic land, take land from block
if (this.setCodesland.isEmpty()) {
for (String setCode :deck.getExpansionSetCodes()) {
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
if (expansionInfo != null) {
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
for (ExpansionInfo blockSet: blockSets) {
if (blockSet.hasBasicLands()) {
this.setCodesland.add(blockSet.getCode());
landSets.add(blockSet.getName());
}
}
}
}
}
}
// if still no set with lands found, take one by random
}
// if still no set with lands found, add list of all available
if (this.setCodesland.isEmpty()) {
// if sets have no basic lands and also it has no parent or parent has no lands get last set with lands
// select a set with basic lands by random
Random generator = new Random();
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
if (basicLandSets.size() > 0) {
this.setCodesland.add(basicLandSets.get(generator.nextInt(basicLandSets.size())).getCode());
for (ExpansionInfo expansionInfo: basicLandSets) {
landSets.add(expansionInfo.getName());
}
}
if (this.setCodesland.isEmpty()) {
}
if (landSets.isEmpty()) {
throw new IllegalArgumentException("No set with basic land was found");
}
if(landSets.size() > 1) {
landSets.add("<Random lands>");
}
cbLandSet.setModel(new DefaultComboBoxModel(landSets.toArray()));
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
this.setVisible(true);
@ -106,14 +114,22 @@ public class AddLandDialog extends MageDialog {
private void addLands(String landName, int number) {
Random random = new Random();
String landSetName = (String) cbLandSet.getSelectedItem();
CardCriteria criteria = new CardCriteria();
if (!setCodesland.isEmpty()) {
if (landSetName.equals("<Random lands>")) {
criteria.setCodes(setCodesland.toArray(new String[setCodesland.size()]));
}
} else {
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByName(landSetName);
if (expansionInfo == null) {
throw new IllegalArgumentException("Code of Set " + landSetName + " not found");
}
criteria.setCodes(expansionInfo.getCode());
}
criteria.rarities(Rarity.LAND).name(landName);
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
if (cards.isEmpty()) {
return;
throw new IllegalArgumentException("No basic lands found in Set: " + landSetName);
}
for (int i = 0; i < number; i++) {
@ -132,16 +148,18 @@ public class AddLandDialog extends MageDialog {
private void initComponents() {
jButton2 = new javax.swing.JButton();
lblLandSet = new javax.swing.JLabel();
cbLandSet = new javax.swing.JComboBox();
lblForest = new javax.swing.JLabel();
spnForest = new javax.swing.JSpinner();
spnIsland = new javax.swing.JSpinner();
lblIsland = new javax.swing.JLabel();
spnIsland = new javax.swing.JSpinner();
lblMountain = new javax.swing.JLabel();
spnMountain = new javax.swing.JSpinner();
lblPains = new javax.swing.JLabel();
spnPlains = new javax.swing.JSpinner();
spnMountain = new javax.swing.JSpinner();
lblMountain = new javax.swing.JLabel();
spnSwamp = new javax.swing.JSpinner();
lblSwamp = new javax.swing.JLabel();
spnSwamp = new javax.swing.JSpinner();
btnAdd = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
btnAutoAdd = new javax.swing.JButton();
@ -150,26 +168,30 @@ public class AddLandDialog extends MageDialog {
setTitle("Add Land");
lblLandSet.setText("Set");
cbLandSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
lblForest.setText("Forest");
spnForest.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblIsland.setText("Island");
spnIsland.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblIsland.setText("Island");
lblMountain.setText("Mountain");
spnMountain.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblPains.setText("Plains");
spnPlains.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnMountain.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblMountain.setText("Mountain");
lblSwamp.setText("Swamp");
spnSwamp.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblSwamp.setText("Swamp");
btnAdd.setText("Add");
btnAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -197,40 +219,50 @@ public class AddLandDialog extends MageDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblIsland)
.addComponent(lblMountain)
.addComponent(lblForest))
.addComponent(lblForest)
.addComponent(lblLandSet))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spnMountain, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addComponent(spnIsland)
.addComponent(spnForest)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblPains)
.addGap(21, 21, 21)
.addComponent(spnPlains))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblSwamp)
.addGap(14, 14, 14)
.addComponent(spnSwamp)))
.addGap(114, 114, 114))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spnMountain, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addComponent(spnIsland)
.addComponent(spnForest))
.addComponent(cbLandSet, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblSwamp)
.addGap(14, 14, 14)
.addComponent(spnSwamp))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblPains)
.addGap(21, 21, 21)
.addComponent(spnPlains)))
.addGap(122, 122, 122)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addComponent(btnCancel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnAutoAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnAdd)
.addGap(0, 40, Short.MAX_VALUE))))
.addGap(0, 0, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbLandSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblLandSet))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblForest)
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@ -250,7 +282,7 @@ public class AddLandDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblSwamp)
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnAdd)
.addComponent(btnCancel)
@ -322,9 +354,11 @@ public class AddLandDialog extends MageDialog {
private javax.swing.JButton btnAdd;
private javax.swing.JButton btnAutoAdd;
private javax.swing.JButton btnCancel;
private javax.swing.JComboBox cbLandSet;
private javax.swing.JButton jButton2;
private javax.swing.JLabel lblForest;
private javax.swing.JLabel lblIsland;
private javax.swing.JLabel lblLandSet;
private javax.swing.JLabel lblMountain;
private javax.swing.JLabel lblPains;
private javax.swing.JLabel lblSwamp;

View file

@ -35,20 +35,19 @@
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblPort" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblServer" min="-2" max="-2" attributes="0"/>
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblPort" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblServer" min="-2" max="-2" attributes="0"/>
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblFlag" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblStatus" alignment="1" max="32767" attributes="0"/>
<Component id="chkForceUpdateDB" max="32767" attributes="0"/>
<Component id="chkAutoConnect" pref="362" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jProxySettingsButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="164" pref="237" max="32767" attributes="0"/>
</Group>
<Component id="jProxySettingsButton" min="-2" max="-2" attributes="0"/>
<Component id="cbFlag" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="txtServer" pref="286" max="32767" attributes="0"/>
@ -57,8 +56,9 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnFind" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="chkForceUpdateDB" alignment="0" max="32767" attributes="0"/>
<Component id="chkAutoConnect" alignment="0" pref="358" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@ -86,12 +86,17 @@
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="lblFlag" max="32767" attributes="0"/>
<Component id="cbFlag" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<Component id="chkAutoConnect" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkForceUpdateDB" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jProxySettingsButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="20" max="32767" attributes="0"/>
<EmptySpace pref="50" max="32767" attributes="0"/>
<Component id="lblStatus" min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -142,11 +147,24 @@
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtUserName"/>
</Property>
<Property name="text" type="java.lang.String" value="User Name:"/>
<Property name="text" type="java.lang.String" value="User name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtUserName">
</Component>
<Component class="javax.swing.JLabel" name="lblFlag">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtUserName"/>
</Property>
<Property name="text" type="java.lang.String" value="User flag:"/>
</Properties>
</Component>
<Component class="mage.client.util.gui.countryBox.CountryComboBox" name="cbFlag">
<Properties>
<Property name="editable" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="chkAutoConnect">
<Properties>
<Property name="text" type="java.lang.String" value="Automatically connect to this server next time"/>

View file

@ -37,7 +37,6 @@ package mage.client.dialog;
import mage.client.MageFrame;
import mage.client.util.Config;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import org.apache.log4j.Logger;
import javax.swing.*;
@ -64,6 +63,10 @@ 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.KEY_CONNECT_AUTO_CONNECT;
import static mage.client.dialog.PreferencesDialog.KEY_CONNECT_FLAG;
import mage.client.util.gui.countryBox.CountryItemEditor;
import mage.remote.Connection.ProxyType;
/**
* @author BetaSteward_at_googlemail.com
@ -96,9 +99,19 @@ public class ConnectDialog extends MageDialog {
this.txtServer.setText(MageFrame.getPreferences().get("serverAddress", Config.serverName));
this.txtPort.setText(MageFrame.getPreferences().get("serverPort", Integer.toString(Config.port)));
this.txtUserName.setText(MageFrame.getPreferences().get("userName", ""));
this.chkAutoConnect.setSelected(Boolean.parseBoolean(MageFrame.getPreferences().get("autoConnect", "false")));
this.chkAutoConnect.setSelected(Boolean.parseBoolean(MageFrame.getPreferences().get(KEY_CONNECT_AUTO_CONNECT, "false")));
this.chkForceUpdateDB.setSelected(false); // has always to be set manually to force comparison
this.lblStatus.setText("");
String selectedFlag = MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world");
// set the selected country/flag
for (int i = 0; i < cbFlag.getItemCount(); i++) {
String[] name = (String[])cbFlag.getItemAt(i);
if (name[1].equals(selectedFlag)) {
cbFlag.setSelectedIndex(i);
break;
}
}
this.setModal(true);
this.setLocation(50, 50);
this.setVisible(true);
@ -108,7 +121,7 @@ public class ConnectDialog extends MageDialog {
MageFrame.getPreferences().put("serverAddress", txtServer.getText().trim());
MageFrame.getPreferences().put("serverPort", txtPort.getText().trim());
MageFrame.getPreferences().put("userName", txtUserName.getText().trim());
MageFrame.getPreferences().put("autoConnect", Boolean.toString(chkAutoConnect.isSelected()));
MageFrame.getPreferences().put(KEY_CONNECT_AUTO_CONNECT, Boolean.toString(chkAutoConnect.isSelected()));
}
/**
@ -128,6 +141,8 @@ public class ConnectDialog extends MageDialog {
txtPort = new javax.swing.JTextField();
lblUserName = new javax.swing.JLabel();
txtUserName = new javax.swing.JTextField();
lblFlag = new javax.swing.JLabel();
cbFlag = new mage.client.util.gui.countryBox.CountryComboBox();
chkAutoConnect = new javax.swing.JCheckBox();
chkForceUpdateDB = new javax.swing.JCheckBox();
jProxySettingsButton = new javax.swing.JButton();
@ -160,7 +175,12 @@ public class ConnectDialog extends MageDialog {
});
lblUserName.setLabelFor(txtUserName);
lblUserName.setText("User Name:");
lblUserName.setText("User name:");
lblFlag.setLabelFor(txtUserName);
lblFlag.setText("User flag:");
cbFlag.setEditable(true);
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.");
@ -212,26 +232,26 @@ public class ConnectDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPort)
.addComponent(lblServer)
.addComponent(lblUserName))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPort)
.addComponent(lblServer)
.addComponent(lblUserName))
.addComponent(lblFlag, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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(chkForceUpdateDB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chkAutoConnect, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jProxySettingsButton)
.addGap(164, 237, Short.MAX_VALUE))
.addComponent(jProxySettingsButton)
.addComponent(cbFlag, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtServer, javax.swing.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE)
.addComponent(txtPort, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtUserName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFind)
.addGap(0, 0, Short.MAX_VALUE)))))
.addComponent(btnFind))
.addComponent(chkForceUpdateDB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(chkAutoConnect, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
@ -251,12 +271,16 @@ public class ConnectDialog extends MageDialog {
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblUserName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lblFlag, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cbFlag, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(5, 5, 5)
.addComponent(chkAutoConnect)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkForceUpdateDB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jProxySettingsButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@ -270,6 +294,7 @@ public class ConnectDialog extends MageDialog {
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
MageFrame.getPreferences().put("autoConnect", Boolean.toString(chkAutoConnect.isSelected()));
MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor)cbFlag.getEditor()).getImageItem());
if (task != null && !task.isDone()) {
task.cancel(true);
} else {
@ -305,7 +330,7 @@ public class ConnectDialog extends MageDialog {
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
connection.setUsername(this.txtUserName.getText().trim());
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected());
MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor)cbFlag.getEditor()).getImageItem());
ProxyType configProxyType = Connection.ProxyType.valueByText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_TYPE, "None"));
@ -330,12 +355,8 @@ public class ConnectDialog extends MageDialog {
}
// pref settings
int avatarId = PreferencesDialog.getSelectedAvatar();
connection.setAvatarId(avatarId);
boolean showAbilityPickerForced = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true");
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
connection.setShowAbilityPickerForced(showAbilityPickerForced);
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
MageFrame.getInstance().setUserPrefsToConnection(connection);
logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort());
task = new ConnectTask();
task.execute();
@ -525,9 +546,11 @@ public class ConnectDialog extends MageDialog {
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnConnect;
private javax.swing.JButton btnFind;
private mage.client.util.gui.countryBox.CountryComboBox cbFlag;
private javax.swing.JCheckBox chkAutoConnect;
private javax.swing.JCheckBox chkForceUpdateDB;
private javax.swing.JButton jProxySettingsButton;
private javax.swing.JLabel lblFlag;
private javax.swing.JLabel lblPort;
private javax.swing.JLabel lblServer;
private javax.swing.JLabel lblStatus;

View file

@ -52,7 +52,7 @@ public class JoinTableDialog extends MageDialog {
public JoinTableDialog() {
initComponents();
newPlayerPanel.showLevel(false);
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, ""));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, ""));
}
public void showDialog(UUID roomId, UUID tableId, boolean isTournament, boolean isLimited) {
@ -149,7 +149,7 @@ public class JoinTableDialog extends MageDialog {
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
Client client = MageFrame.getClient();
try {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, txtPassword.getText());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
if (isTournament) {
joined = client.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
} else {

View file

@ -32,20 +32,22 @@
<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" alignment="0" attributes="0">
<Component id="cbGameType" min="-2" pref="398" max="-2" attributes="1"/>
<Group type="103" groupAlignment="0" max="-2" 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 pref="13" max="32767" attributes="0"/>
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="txtName" alignment="0" max="32767" attributes="0"/>
<Component id="cbDeckType" alignment="0" pref="338" max="32767" attributes="1"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtName" max="32767" attributes="0"/>
<Component id="cbDeckType" pref="332" max="32767" attributes="1"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lbTimeLimit" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="1" min="-2" max="-2" attributes="0"/>
@ -89,10 +91,10 @@
<Component id="cbSkillLevel" min="-2" pref="148" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" 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>
<Component id="jSeparator2" alignment="1" max="32767" attributes="0"/>
@ -105,7 +107,7 @@
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator3" pref="606" max="32767" attributes="0"/>
<Component id="jSeparator3" pref="586" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -133,6 +135,7 @@
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="spnFreeMulligans" 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"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
@ -147,11 +150,13 @@
<Component id="spnNumPlayers" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblRange" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblAttack" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblSkillLevel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblRange" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblAttack" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -171,8 +176,8 @@
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="113" max="32767" attributes="0"/>
<EmptySpace pref="13" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" pref="105" max="32767" attributes="0"/>
<EmptySpace pref="7" max="32767" attributes="0"/>
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -185,7 +190,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="201" max="-2" attributes="0"/>
<Component id="jSeparator3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="178" max="32767" attributes="0"/>
<EmptySpace pref="167" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@ -237,6 +242,12 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameTypeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="chkRollbackTurnsAllowed">
<Properties>
<Property name="text" type="java.lang.String" value="Allow 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;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblFreeMulligans">
<Properties>
<Property name="text" type="java.lang.String" value="Free Mulligans:"/>

View file

@ -102,6 +102,7 @@ public class NewTableDialog extends MageDialog {
cbTimeLimit = new javax.swing.JComboBox();
lblGameType = new javax.swing.JLabel();
cbGameType = new javax.swing.JComboBox();
chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
lblFreeMulligans = new javax.swing.JLabel();
spnFreeMulligans = new javax.swing.JSpinner();
lblNumPlayers = new javax.swing.JLabel();
@ -145,6 +146,9 @@ public class NewTableDialog extends MageDialog {
}
});
chkRollbackTurnsAllowed.setText("Allow rollbacks");
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n");
lblFreeMulligans.setText("Free Mulligans:");
lblFreeMulligans.setToolTipText("The number of mulligans a player can use without decreasing the number of drawn cards.");
@ -217,18 +221,20 @@ public class NewTableDialog extends MageDialog {
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(chkRollbackTurnsAllowed)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtName, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbDeckType, javax.swing.GroupLayout.Alignment.LEADING, 0, 338, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtName)
.addComponent(cbDeckType, 0, 332, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbTimeLimit, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPassword, javax.swing.GroupLayout.Alignment.TRAILING))
@ -261,10 +267,10 @@ public class NewTableDialog extends MageDialog {
.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)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)))
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator2)
.addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, 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)
@ -273,7 +279,7 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
.addContainerGap()))
);
layout.setVerticalGroup(
@ -295,7 +301,8 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans))
.addComponent(lblFreeMulligans)
.addComponent(chkRollbackTurnsAllowed))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType)))
@ -306,11 +313,12 @@ public class NewTableDialog extends MageDialog {
.addGap(0, 0, 0)
.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.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblRange)
.addComponent(lblAttack)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblSkillLevel)
.addComponent(lblNumWins))
.addComponent(lblNumWins)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblRange)
.addComponent(lblAttack)))
.addGap(0, 0, 0)
.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)
@ -326,8 +334,8 @@ public class NewTableDialog extends MageDialog {
.addGap(16, 16, 16)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@ -338,7 +346,7 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createSequentialGroup()
.addGap(201, 201, 201)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(178, Short.MAX_VALUE)))
.addContainerGap(167, Short.MAX_VALUE)))
);
pack();
@ -364,6 +372,7 @@ public class NewTableDialog extends MageDialog {
options.setSkillLevel((SkillLevel) this.cbSkillLevel.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
options.setWinsNeeded((Integer)this.spnNumWins.getValue());
options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected());
options.setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
options.setPassword(this.txtPassword.getText());
if (!checkMatchOptions(options)) {
@ -598,6 +607,9 @@ public class NewTableDialog extends MageDialog {
this.player1Panel.setDeckFile(deckFile);
}
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, "2")));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED, "Yes").equals("Yes"));
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, "1"));
for (RangeOfInfluence roi :RangeOfInfluence.values()) {
if (roi.getRange() == range) {
@ -634,6 +646,8 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT, Integer.toString(options.getPriorityTime()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, options.getGameType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, Integer.toString(options.getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED, options.isRollbackTurnsAllowed() ? "Yes": "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, Integer.toString(options.getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, spnNumPlayers.getValue().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, Integer.toString(options.getRange().getRange()));
@ -660,6 +674,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JComboBox cbRange;
private javax.swing.JComboBox cbSkillLevel;
private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JSeparator jSeparator1;

View file

@ -51,7 +51,11 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnConstructTime" min="-2" pref="50" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="spnConstructTime" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkRollbackTurnsAllowed" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="spnNumRounds" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -67,52 +71,49 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" 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"/>
<Group type="103" groupAlignment="0" 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">
<Component id="cbTournamentType" min="-2" pref="290" max="-2" attributes="0"/>
<EmptySpace max="-2" 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"/>
<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>
<Group type="103" alignment="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" 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>
<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="124" 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="89" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbSkillLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbSkillLevel" min="-2" pref="112" 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"/>
<Group type="103" groupAlignment="0" 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">
<Component id="cbTournamentType" min="-2" pref="290" max="-2" attributes="0"/>
<EmptySpace max="-2" 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"/>
<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>
</Group>
<EmptySpace min="0" pref="0" max="-2" 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="124" 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"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<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>
</Group>
</Group>
@ -183,10 +184,11 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkRollbackTurnsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="player1Panel" pref="62" max="32767" attributes="0"/>
<Component id="player1Panel" pref="64" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlPlayers" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -440,6 +442,12 @@
<Property name="text" type="java.lang.String" value="Construction Time (Minutes):"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="chkRollbackTurnsAllowed">
<Properties>
<Property name="text" type="java.lang.String" value="Allow 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. "/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnConstructTime">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="The time players have to build their deck."/>
@ -462,7 +470,7 @@
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlOtherPlayers" alignment="0" pref="5" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" alignment="0" pref="7" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>

View file

@ -164,6 +164,7 @@ public class NewTournamentDialog extends MageDialog {
cbAllowSpectators = new javax.swing.JCheckBox();
lblPlayer1 = new javax.swing.JLabel();
lblConstructionTime = new javax.swing.JLabel();
chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
spnConstructTime = new javax.swing.JSpinner();
player1Panel = new mage.client.table.NewPlayerPanel();
pnlPlayers = new javax.swing.JPanel();
@ -297,6 +298,9 @@ public class NewTournamentDialog extends MageDialog {
lblConstructionTime.setText("Construction Time (Minutes):");
chkRollbackTurnsAllowed.setText("Allow rollbacks");
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br> if all players agree. ");
spnConstructTime.setToolTipText("The time players have to build their deck.");
player1Panel.setPreferredSize(new java.awt.Dimension(400, 44));
@ -312,7 +316,7 @@ public class NewTournamentDialog extends MageDialog {
);
pnlPlayersLayout.setVerticalGroup(
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 5, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 7, Short.MAX_VALUE)
);
btnOk.setText("OK");
@ -357,7 +361,10 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkRollbackTurnsAllowed))
.addGroup(layout.createSequentialGroup()
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -369,46 +376,44 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblDraftCube)
.addComponent(lblTournamentType)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 124, 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, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbSkillLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 112, 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, 56, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, 0))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblDraftCube)
.addComponent(lblTournamentType)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 124, 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, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbSkillLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, 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, 56, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
@ -464,9 +469,10 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(lblPlayer1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime)))
.addComponent(lblConstructionTime)
.addComponent(chkRollbackTurnsAllowed)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -535,6 +541,7 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
tOptions.getMatchOptions().setRollbackTurnsAllowed(this.chkRollbackTurnsAllowed.isSelected());
saveTournamentSettingsToPrefs(tOptions);
table = client.createTournamentTable(roomId, tOptions);
@ -834,6 +841,7 @@ public class NewTournamentDialog extends MageDialog {
}
}
this.cbAllowSpectators.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, "Yes").equals("Yes"));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, "Yes").equals("Yes"));
}
private void loadBoosterPacks(String packString) {
@ -896,6 +904,7 @@ public class NewTournamentDialog extends MageDialog {
}
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, (tOptions.isWatchingAllowed()?"Yes":"No"));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, (tOptions.getMatchOptions().isRollbackTurnsAllowed()?"Yes":"No"));
}
@ -915,6 +924,7 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JComboBox cbSkillLevel;
private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JComboBox cbTournamentType;
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lbSkillLevel;

View file

@ -85,7 +85,7 @@
<Component id="main_game" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_gamelog" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="63" max="32767" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -203,16 +203,17 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="cbAllowRequestToShowHandCards" min="-2" pref="546" max="-2" attributes="0"/>
<EmptySpace pref="14" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="showPlayerNamesPermanently" alignment="0" max="32767" attributes="0"/>
<Component id="nonLandPermanentsInOnePile" alignment="0" max="32767" attributes="0"/>
<Component id="showAbilityPickerForced" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="cbShowStormCounter" alignment="0" min="-2" pref="546" max="-2" attributes="0"/>
<Component id="cbConfirmEmptyManaPool" alignment="0" min="-2" pref="546" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
@ -232,6 +233,8 @@
<Component id="cbAllowRequestToShowHandCards" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbShowStormCounter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbConfirmEmptyManaPool" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -293,6 +296,17 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbShowStormCounterActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbConfirmEmptyManaPool">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Confirm if you want to pass a phase/step but there is still mana in your mana pool"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;html&gt;If activated you get a confirm message if you pass priority while stack is empty&lt;br&gt;&#xa; and you still have mana in your mana pool."/>
<Property name="horizontalAlignment" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbConfirmEmptyManaPoolActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="main_gamelog">
@ -1128,7 +1142,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="598" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="590" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">

View file

@ -85,6 +85,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_SHOW_ABILITY_PICKER_FORCED = "showAbilityPicker";
public static final String KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS = "gameAllowRequestShowHandCards";
public static final String KEY_GAME_SHOW_STORM_COUNTER = "gameShowStormCounter";
public static final String KEY_GAME_CONFIRM_EMPTY_MANA_POOL = "gameConfirmEmptyManaPool";
public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave";
@ -132,6 +133,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_STOP_ALL_MAIN_PHASES = "stopOnAllMainPhases";
public static final String KEY_STOP_ALL_END_PHASES = "stopOnAllEndPhases";
// mana auto payment
public static final String KEY_GAME_MANA_AUTOPAYMENT = "gameManaAutopayment";
public static final String KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE = "gameManaAutopaymentOnlyOne";
// Size of frame to check if divider locations should be used
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
@ -145,6 +150,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_TABLES_DIVIDER_LOCATION_2 = "tablePanelDividerLocation2";
public static final String KEY_TABLES_DIVIDER_LOCATION_3 = "tablePanelDividerLocation3";
// user list
public static final String KEY_USERS_COLUMNS_WIDTH = "userPanelColumnWidth";
public static final String KEY_USERS_COLUMNS_ORDER = "userPanelColumnSort";
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_0 = "gamepanelDividerLocation0";
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_1 = "gamepanelDividerLocation1";
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_2 = "gamepanelDividerLocation2";
@ -155,10 +164,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
// pref setting for new table dialog
public static final String KEY_NEW_TABLE_NAME = "newTableName";
public static final String KEY_NEW_TABLE_PASSWORD = "newTablePassword";
public static final String KEY_NEW_TABLE_PASSWORD_JOIN = "newTablePasswordJoin";
public static final String KEY_NEW_TABLE_DECK_TYPE = "newTableDeckType";
public static final String KEY_NEW_TABLE_TIME_LIMIT = "newTableTimeLimit";
public static final String KEY_NEW_TABLE_GAME_TYPE = "newTableGameType";
public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins";
public static final String KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED = "newTableRollbackTurnsAllowed";
public static final String KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans";
public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile";
public static final String KEY_NEW_TABLE_RANGE = "newTableRange";
@ -181,6 +192,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TOURNAMENT_PLAYERS_DRAFT = "newTournamentPlayersDraft";
public static final String KEY_NEW_TOURNAMENT_DRAFT_TIMING = "newTournamentDraftTiming";
public static final String KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS = "newTournamentAllowSpectators";
public static final String KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS = "newTournamentAllowRollbacks";
public static final String KEY_NEW_TOURNAMENT_DECK_FILE = "newTournamentDeckFile";
// pref setting for deck generator
@ -219,6 +231,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_CONNECTION_URL_SERVER_LIST = "connectionURLServerList";
public static final String KEY_AVATAR = "selectedId";
public static final String KEY_CONNECT_AUTO_CONNECT = "autoConnect";
public static final String KEY_CONNECT_FLAG = "connectFlag";
private static final Map<String, String> cache = new HashMap<>();
@ -329,6 +345,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
showAbilityPickerForced = new javax.swing.JCheckBox();
cbAllowRequestToShowHandCards = new javax.swing.JCheckBox();
cbShowStormCounter = new javax.swing.JCheckBox();
cbConfirmEmptyManaPool = new javax.swing.JCheckBox();
main_gamelog = new javax.swing.JPanel();
cbGameLogAutoSave = new javax.swing.JCheckBox();
tabPhases = new javax.swing.JPanel();
@ -543,6 +560,16 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
cbConfirmEmptyManaPool.setSelected(true);
cbConfirmEmptyManaPool.setText("Confirm if you want to pass a phase/step but there is still mana in your mana pool");
cbConfirmEmptyManaPool.setToolTipText("<html>If activated you get a confirm message if you pass priority while stack is empty<br>\n and you still have mana in your mana pool.");
cbConfirmEmptyManaPool.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbConfirmEmptyManaPool.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbConfirmEmptyManaPoolActionPerformed(evt);
}
});
javax.swing.GroupLayout main_gameLayout = new javax.swing.GroupLayout(main_game);
main_game.setLayout(main_gameLayout);
main_gameLayout.setHorizontalGroup(
@ -552,14 +579,15 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createSequentialGroup()
.addComponent(cbAllowRequestToShowHandCards, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(14, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(main_gameLayout.createSequentialGroup()
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(showPlayerNamesPermanently, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(nonLandPermanentsInOnePile, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(showAbilityPickerForced, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(cbShowStormCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cbShowStormCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbConfirmEmptyManaPool, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))))
);
main_gameLayout.setVerticalGroup(
@ -573,7 +601,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAllowRequestToShowHandCards)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbShowStormCounter))
.addComponent(cbShowStormCounter)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbConfirmEmptyManaPool))
);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
@ -624,7 +654,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addComponent(main_game, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(main_gamelog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(63, Short.MAX_VALUE))
.addContainerGap(40, Short.MAX_VALUE))
);
main_card.getAccessibleContext().setAccessibleName("Game panel");
@ -1377,7 +1407,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabAvatars.setLayout(tabAvatarsLayout);
tabAvatarsLayout.setHorizontalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
);
tabAvatarsLayout.setVerticalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1596,7 +1626,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addComponent(tabsPanel)
.addComponent(tabsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1624,6 +1654,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbShowStormCounter, KEY_GAME_SHOW_STORM_COUNTER, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbConfirmEmptyManaPool, KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
// Phases
@ -1690,7 +1721,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
getSelectedAvatar(),
dialog.showAbilityPickerForced.isSelected(),
dialog.cbAllowRequestToShowHandCards.isSelected(),
getUserSkipPrioritySteps());
dialog.cbConfirmEmptyManaPool.isSelected(),
getUserSkipPrioritySteps(),
MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world.png"));
prefs.flush();
} catch (BackingStoreException ex) {
@ -1941,6 +1974,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_cbShowStormCounterActionPerformed
private void cbConfirmEmptyManaPoolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbConfirmEmptyManaPoolActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbConfirmEmptyManaPoolActionPerformed
private void showProxySettings() {
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
this.pnlProxy.setVisible(true);
@ -2017,6 +2054,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true");
load(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true");
load(prefs, dialog.cbShowStormCounter, KEY_GAME_SHOW_STORM_COUNTER, "true");
load(prefs, dialog.cbConfirmEmptyManaPool, KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true");
load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
@ -2361,7 +2399,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
id,
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),
getUserSkipPrioritySteps());
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
getUserSkipPrioritySteps(),
MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world.png")
);
}
}
});
@ -2375,6 +2416,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JButton btnBrowseImageLocation;
private javax.swing.JCheckBox cbAllowRequestToShowHandCards;
private javax.swing.JCheckBox cbCheckForNewImages;
private javax.swing.JCheckBox cbConfirmEmptyManaPool;
private javax.swing.JCheckBox cbEnableBattlefieldBGM;
private javax.swing.JCheckBox cbEnableDraftSounds;
private javax.swing.JCheckBox cbEnableGameSounds;

View file

@ -178,12 +178,8 @@ public class UserRequestDialog extends MageDialog {
private void sendUserReplay(PlayerAction playerAction) {
Client client = MageFrame.getClient();
switch(playerAction) {
case ADD_PERMISSION_TO_SEE_HAND_CARDS:
client.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
break;
default:
// not supported action
if (session != null && playerAction != null) {
session.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
}
}

View file

@ -90,6 +90,8 @@ import mage.client.dialog.PickChoiceDialog;
import mage.client.dialog.PickNumberDialog;
import mage.client.dialog.PickPileDialog;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE;
import mage.client.dialog.ShowCardsDialog;
import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.adapters.MageActionCallback;
@ -383,7 +385,8 @@ public final class GamePanel extends javax.swing.JPanel {
this.gameChatPanel.connect(client.getGameChatId(gameId));
if (!client.joinGame(gameId)) {
removeGame();
} else {
} else {
// play start sound
AudioManager.playYourGameStarted();
}
}
@ -457,6 +460,11 @@ public final class GamePanel extends javax.swing.JPanel {
public synchronized void init(GameView game) {
addPlayers(game);
// default menu states
setMenuStates(
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"));
updateGame(game);
}
@ -479,7 +487,8 @@ public final class GamePanel extends javax.swing.JPanel {
}
}
PlayerView player = game.getPlayers().get(playerSeat);
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true, game.getPriorityTime(), game.isPlayer(), this);
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
new PlayAreaPanelOptions(game.isPlayer(), true, game.isRollbackTurnsAllowed()));
players.put(player.getPlayerId(), sessionPlayer);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
@ -511,7 +520,8 @@ public final class GamePanel extends javax.swing.JPanel {
col = numColumns - 1;
}
player = game.getPlayers().get(playerNum);
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false, game.getPriorityTime(), game.isPlayer(), this);
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
new PlayAreaPanelOptions(game.isPlayer(), false, game.isRollbackTurnsAllowed()));
players.put(player.getPlayerId(), playerPanel);
c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
@ -728,10 +738,11 @@ public final class GamePanel extends javax.swing.JPanel {
/**
* Set the same state for menu selections to all player areas.
* @param manaPoolAutomatic
* @param manaPoolAutomaticRestricted
*/
public void setMenuStates(boolean manaPoolAutomatic) {
public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
for(PlayAreaPanel playAreaPanel: players.values()) {
playAreaPanel.setMenuStates(manaPoolAutomatic);
playAreaPanel.setMenuStates(manaPoolAutomatic, manaPoolAutomaticRestricted);
}
}
@ -802,7 +813,7 @@ public final class GamePanel extends javax.swing.JPanel {
ShowCardsDialog newReveal = new ShowCardsDialog();
revealed.put(reveal.getName(), newReveal);
}
revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), CardsViewUtil.convertSimple(reveal.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false);
revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), reveal.getCards(), bigCard, Config.dimensions, gameId, false);
}
}
@ -815,7 +826,7 @@ public final class GamePanel extends javax.swing.JPanel {
ShowCardsDialog newLookedAt = new ShowCardsDialog();
lookedAt.put(looked.getName(), newLookedAt);
}
lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), CardsViewUtil.convertSimple(looked.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false);
lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), looked.getCards(), bigCard, Config.dimensions, gameId, false);
}
}

View file

@ -221,12 +221,18 @@ public class HelperPanel extends JPanel {
public void setMessage(String message) {
if (message.startsWith("Use alternative cost")) {
textArea.setText("Use alternative cost?");
} else if (message.length() > 40 && message.contains("Use ")) {
textArea.setText("Use ability?");
} else {
textArea.setText(message);
}
message = "Use alternative cost?";
} else if (message.contains("Use ")) {
if (message.length() < this.getWidth() / 10) {
message = getSmallText(message);
} else {
message = "Use ability?" + getSmallText(message.substring(this.getWidth() / 10));
}
}
textArea.setText(message);
}
protected String getSmallText(String text) {
return "<div style='font-size:11pt'>" + text + "</div>";
}
@Override

View file

@ -42,6 +42,7 @@ import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
@ -53,6 +54,8 @@ import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE;
import mage.constants.PlayerAction;
import mage.view.PlayerView;
@ -68,9 +71,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
private boolean smallMode = false;
private boolean playingMode = true;
private final GamePanel gamePanel;
private final boolean playerItself;
private JCheckBoxMenuItem manaPoolMenuItem;
private final PlayAreaPanelOptions options;
private JCheckBoxMenuItem manaPoolMenuItem1;
private JCheckBoxMenuItem manaPoolMenuItem2;
private JCheckBoxMenuItem allowViewHandCardsMenuItem;
public static final int PANEL_HEIGHT = 242;
@ -80,25 +84,24 @@ public class PlayAreaPanel extends javax.swing.JPanel {
* @param player
* @param bigCard
* @param gameId
* @param isPlayer true if the client is a player / false if the client is a watcher
* @param playerItself true if it's the area of the player itself
* @param priorityTime
* @param gamePanel */
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean playerItself, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
//this(isPlayer);
this.playerItself = playerItself;
* @param gamePanel
* @param options
*/
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime, GamePanel gamePanel, PlayAreaPanelOptions options) {
this.gamePanel = gamePanel;
this.options = options;
initComponents();
setOpaque(false);
battlefieldPanel.setOpaque(false);
popupMenu = new JPopupMenu();
if (isPlayer) {
if (options.isPlayer) {
addPopupMenuPlayer(player.getUserData().allowRequestShowHandCards());
} else {
addPopupMenuWatcher();
}
this.add(popupMenu);
this.gamePanel = gamePanel;
init(player, bigCard, gameId, priorityTime);
update(player);
}
@ -138,98 +141,135 @@ public class PlayAreaPanel extends javax.swing.JPanel {
JMenuItem menuItem;
menuItem = new JMenuItem("F2 - Confirm");
popupMenu.add(menuItem);
// Confirm (F2)
menuItem.addActionListener(new ActionListener() {
ActionListener skipListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (gamePanel.getFeedbackPanel() != null) {
gamePanel.getFeedbackPanel().pressOKYesOrDone();
switch (e.getActionCommand()) {
case "F2": {
if (gamePanel.getFeedbackPanel() != null) {
gamePanel.getFeedbackPanel().pressOKYesOrDone();
}
break;
}
case "F3": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
break;
}
case "F4": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
break;
}
case "F5": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
break;
}
case "F7": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
break;
}
case "F9": {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
break;
}
}
}
});
menuItem = new JMenuItem("F3 - Cancel previous F4/F9 skip action");
};
menuItem = new JMenuItem("<html><b>F2</b> - Confirm current request");
menuItem.setActionCommand("F2");
menuItem.setMnemonic(KeyEvent.VK_O);
popupMenu.add(menuItem);
menuItem.addActionListener(skipListener);
// Cancel (F3)
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
}
});
menuItem = new JMenuItem("<html><b>F3</b> - Cancel active skip action");
menuItem.setActionCommand("F3");
menuItem.setMnemonic(KeyEvent.VK_N);
popupMenu.add(menuItem);
menuItem.addActionListener(skipListener);
JMenu skipMenu = new JMenu("Skip");
skipMenu.setMnemonic(KeyEvent.VK_S);
popupMenu.add(skipMenu);
String tooltipText = "<html>This skip actions stops if something goes to <br><b>stack</b> and if <b>attackers</b> or <b>blocker</b> have to be <b>declared</b>.";
menuItem = new JMenuItem("<html><b>F4</b> - Phases until next turn");
menuItem.setActionCommand("F4");
menuItem.setToolTipText(tooltipText);
menuItem.setMnemonic(KeyEvent.VK_T);
skipMenu.add(menuItem);
menuItem.addActionListener(skipListener);
menuItem = new JMenuItem("<html><b>F5</b> - Phases until next end step");
menuItem.setActionCommand("F5");
menuItem.setToolTipText(tooltipText);
menuItem.setMnemonic(KeyEvent.VK_E);
skipMenu.add(menuItem);
menuItem.addActionListener(skipListener);
menuItem = new JMenuItem("<html><b>F7</b> - Phases until begin of next main phase");
menuItem.setToolTipText(tooltipText);
menuItem.setActionCommand("F7");
menuItem.setMnemonic(KeyEvent.VK_M);
skipMenu.add(menuItem);
menuItem.addActionListener(skipListener);
menuItem = new JMenuItem("<html><b>F9</b> - Everything until your own next turn");
menuItem.setActionCommand("F9");
menuItem.setToolTipText(tooltipText);
menuItem.setMnemonic(KeyEvent.VK_N);
skipMenu.add(menuItem);
menuItem.addActionListener(skipListener);
popupMenu.addSeparator();
menuItem = new JMenuItem("F4 - Skip phases until next turn (stop on stack/attack/block)");
popupMenu.add(menuItem);
// Skip to next turn (F4)
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
}
});
menuItem = new JMenuItem("F5 - Skip phases until next end step (stop on stack/attack/block)");
popupMenu.add(menuItem);
// Skip to next end step of turn (F5)
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
}
});
menuItem = new JMenuItem("F7 - Skip phases until begin of next main phase (stop on stack/attack/block)");
popupMenu.add(menuItem);
// Skip to next main phase (F7)
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
}
});
menuItem = new JMenuItem("F9 - Skip everything until own next turn (stop on attack/block)");
popupMenu.add(menuItem);
// Skip to next own turn (F9)
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getClient().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
}
});
popupMenu.addSeparator();
manaPoolMenuItem = new JCheckBoxMenuItem("Use mana from pool automatically", true);
manaPoolMenuItem.setMnemonic(KeyEvent.VK_M);
manaPoolMenuItem.setToolTipText("If not active, you have to click the type of mana you want to pay in the player panel.");
popupMenu.add(manaPoolMenuItem);
JMenu manaPoolMenu = new JMenu("Mana payment");
manaPoolMenu.setMnemonic(KeyEvent.VK_M);
popupMenu.add(manaPoolMenu);
manaPoolMenuItem1 = new JCheckBoxMenuItem("Automatically", true);
manaPoolMenuItem1.setMnemonic(KeyEvent.VK_A);
manaPoolMenuItem1.setToolTipText("<html>If not active, produced mana goes only to the mana pool<br>"
+ "and you have to click the type of mana you want to use <br>"
+ "in the player mana pool panel for payment.");
manaPoolMenu.add(manaPoolMenuItem1);
// Auto pay mana from mana pool
manaPoolMenuItem.addActionListener(new ActionListener() {
manaPoolMenuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
gamePanel.setMenuStates(manaPoolAutomatic);
gamePanel.getClient().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true": "false");
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState());
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
}
});
manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
manaPoolMenuItem2.setMnemonic(KeyEvent.VK_N);
manaPoolMenuItem2.setToolTipText("<html>Mana that is already in the mana pool as you start casting a spell or activating an ability<br>"
+ " needs to be payed manually. So you use the mana in the pool only by clicking on the related<br>"
+ " mana symbols of mana pool area.");
manaPoolMenu.add(manaPoolMenuItem2);
// Auto pay mana from mana pool
manaPoolMenuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem)e.getSource()).getState();
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true": "false");
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted);
gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON: PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
}
});
JMenu automaticConfirmsMenu = new JMenu("Automatic confirms");
automaticConfirmsMenu.setMnemonic(KeyEvent.VK_U);
popupMenu.add(automaticConfirmsMenu);
menuItem = new JMenuItem("Replacement effects - reset auto select");
menuItem.setMnemonic(KeyEvent.VK_R);
menuItem.setToolTipText("Reset all effects that were added to the list of auto select replacement effects this game.");
popupMenu.add(menuItem);
automaticConfirmsMenu.add(menuItem);
// Reset the replacement effcts that were auto selected for the game
menuItem.addActionListener(new ActionListener() {
@Override
@ -238,11 +278,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
});
popupMenu.addSeparator();
if (!playerItself) {
menuItem = new JMenuItem("Request permission to see hand cards");
popupMenu.add(menuItem);
JMenu handCardsMenu = new JMenu("Cards on hand");
handCardsMenu.setMnemonic(KeyEvent.VK_H);
popupMenu.add(handCardsMenu);
if (!options.playerItself) {
menuItem = new JMenuItem("Request permission to see the hand cards");
menuItem.setMnemonic(KeyEvent.VK_P);
handCardsMenu.add(menuItem);
// Request to see hand cards
menuItem.addActionListener(new ActionListener() {
@ -252,10 +295,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
});
} else {
allowViewHandCardsMenuItem = new JCheckBoxMenuItem("Allow requests to show your hand cards", allowRequestToShowHandCards);
allowViewHandCardsMenuItem = new JCheckBoxMenuItem("Allow requests to show from other users", allowRequestToShowHandCards);
allowViewHandCardsMenuItem.setMnemonic(KeyEvent.VK_A);
allowViewHandCardsMenuItem.setToolTipText("If activated watchers or other players can request to see your hand cards. If you grant this to a user, it's valid for the complete match.");
popupMenu.add(allowViewHandCardsMenuItem);
handCardsMenu.add(allowViewHandCardsMenuItem);
// Requests allowed
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
@ -268,9 +311,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
});
menuItem = new JMenuItem("Revoke all permission(s) to see your hand cards");
menuItem.setMnemonic(KeyEvent.VK_P);
menuItem.setMnemonic(KeyEvent.VK_R);
menuItem.setToolTipText("Revoke already granted permission for all spectators to see your hand cards.");
popupMenu.add(menuItem);
handCardsMenu.add(menuItem);
// revoke permissions to see hand cards
menuItem.addActionListener(new ActionListener() {
@ -280,37 +323,90 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
});
}
popupMenu.addSeparator();
if (options.rollbackTurnsAllowed) {
ActionListener rollBackActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int turnsToRollBack = Integer.parseInt(e.getActionCommand());
gamePanel.getSession().sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
}
};
JMenu rollbackMainItem = new JMenu("Roll back");
rollbackMainItem.setMnemonic(KeyEvent.VK_R);
rollbackMainItem.setToolTipText("The game will be rolled back to the start of the requested turn if all players agree.");
popupMenu.add(rollbackMainItem);
menuItem = new JMenuItem("To the start of the current turn");
menuItem.setMnemonic(KeyEvent.VK_C);
menuItem.setActionCommand("0");
menuItem.addActionListener(rollBackActionListener);
rollbackMainItem.add(menuItem);
menuItem = new JMenuItem("To the start of the previous turn");
menuItem.setMnemonic(KeyEvent.VK_P);
menuItem.setActionCommand("1");
menuItem.addActionListener(rollBackActionListener);
rollbackMainItem.add(menuItem);
menuItem = new JMenuItem("Concede game");
popupMenu.add(menuItem);
menuItem = new JMenuItem("The current turn and the 2 turns before");
menuItem.setMnemonic(KeyEvent.VK_2);
menuItem.setActionCommand("2");
menuItem.addActionListener(rollBackActionListener);
rollbackMainItem.add(menuItem);
// Concede
menuItem.addActionListener(new ActionListener() {
menuItem = new JMenuItem("The current turn and the 3 turns before");
menuItem.setMnemonic(KeyEvent.VK_3);
menuItem.setActionCommand("3");
menuItem.addActionListener(rollBackActionListener);
rollbackMainItem.add(menuItem);
}
JMenu concedeMenu = new JMenu("Concede");
concedeMenu.setMnemonic(KeyEvent.VK_C);
popupMenu.add(concedeMenu);
ActionListener concedeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getClient().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
switch (e.getActionCommand()) {
case "Game": {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
}
break;
}
case "Match": {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().quitMatch(gameId);
}
break;
}
}
}
});
popupMenu.addSeparator();
menuItem = new JMenuItem("Concede complete match");
popupMenu.add(menuItem);
// Quit match
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getClient().quitMatch(gameId);
}
}
});
};
// Concede Game
menuItem = new JMenuItem("Game");
menuItem.setMnemonic(KeyEvent.VK_G);
menuItem.setActionCommand("Game");
menuItem.setToolTipText("Concedes only the current game and after that the next game of the match is started if there is another game needed.");
concedeMenu.add(menuItem);
menuItem.addActionListener(concedeListener);
// Concede Match
menuItem = new JMenuItem("Match");
menuItem.setMnemonic(KeyEvent.VK_M);
menuItem.setActionCommand("Match");
menuItem.setToolTipText("Concedes the complete match. So if you're in a tournament you finish the current tournament round.");
concedeMenu.add(menuItem);
menuItem.addActionListener(concedeListener);
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent Me) {
@ -472,8 +568,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
this.playingMode = playingMode;
}
public void setMenuStates(boolean manaPoolAutomatic) {
manaPoolMenuItem.setSelected(manaPoolAutomatic);
public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
manaPoolMenuItem1.setSelected(manaPoolAutomatic);
manaPoolMenuItem2.setSelected(manaPoolAutomaticRestricted);
}
private mage.client.game.BattlefieldPanel battlefieldPanel;

View file

@ -0,0 +1,58 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.game;
/**
* Defines some options for the PlayAreaPanel
*
* @author LevelX2
*/
public class PlayAreaPanelOptions {
public PlayAreaPanelOptions(boolean isPlayer, boolean playerItself, boolean rollbackTurnsAllowed) {
this.isPlayer = isPlayer;
this.playerItself = playerItself;
this.rollbackTurnsAllowed = rollbackTurnsAllowed;
}
/**
* true if the client is a player / false if the client is a watcher
*/
public boolean isPlayer = false;
/**
* true if the player is the client player itself, false if the player is another player playing with the clinet player
*/
public boolean playerItself = false;
/**
* true if the player can roll back turns if all players agree
*/
public boolean rollbackTurnsAllowed = false;
}

View file

@ -64,12 +64,10 @@ import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.JToggleButton;
import javax.swing.RowFilter;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
@ -78,10 +76,13 @@ import mage.client.dialog.JoinTableDialog;
import mage.client.dialog.NewTableDialog;
import mage.client.dialog.NewTournamentDialog;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
import mage.client.dialog.TableWaitingDialog;
import mage.client.util.ButtonColumn;
import mage.client.util.MageTableRowSorter;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.TableUtil;
import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
@ -94,7 +95,6 @@ import mage.view.RoomUsersView;
import mage.view.RoomView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.Util;
import org.mage.network.Client;
/**
@ -122,9 +122,11 @@ public class TablesPanel extends javax.swing.JPanel {
JToggleButton[] filterButtons;
private static final int[] defaultColumnsWidth = {35, 150, 120, 180, 80, 120, 80, 60, 60};
/** Creates new form TablesPanel */
public TablesPanel() {
tableModel = new TableTableModel();
matchesModel = new MatchesTableModel();
gameChooser = new GameChooser();
@ -137,7 +139,8 @@ public class TablesPanel extends javax.swing.JPanel {
activeTablesSorter = new MageTableRowSorter(tableModel);
tableTables.setRowSorter(activeTablesSorter);
TableTableModel.setColumnWidthAndOrder(tableTables);
TableUtil.setColumnWidthAndOrder(tableTables, defaultColumnsWidth,
PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, PreferencesDialog.KEY_TABLES_COLUMNS_ORDER);
tableCompleted.setRowSorter(new MageTableRowSorter(matchesModel));
@ -148,7 +151,8 @@ public class TablesPanel extends javax.swing.JPanel {
filterButtons = new JToggleButton[]
{btnStateWaiting, btnStateActive, btnStateFinished,
btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited,
btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther};
btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther,
btnSkillBeginner, btnSkillCasual, btnSkillSerious };
JComponent[] components = new JComponent[] {chatPanel, jSplitPane1, jScrollPane1, jScrollPane2, topPanel, jPanel3};
for (JComponent component : components) {
@ -277,6 +281,7 @@ public class TablesPanel extends javax.swing.JPanel {
public void cleanUp() {
saveSettings();
chatPanel.cleanUp();
}
private void saveDividerLocations() {
@ -312,23 +317,7 @@ public class TablesPanel extends javax.swing.JPanel {
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_FILTER_SETTINGS, formatSettings.toString());
// Column width
StringBuilder columnWidthSettings = new StringBuilder();
StringBuilder columnOrderSettings = new StringBuilder();
boolean firstValue = true;
for (int i = 0; i < tableTables.getColumnModel().getColumnCount(); i++) {
TableColumn column = tableTables.getColumnModel().getColumn(tableTables.convertColumnIndexToView(i));
if (!firstValue) {
columnWidthSettings.append(",");
columnOrderSettings.append(",");
} else {
firstValue = false;
}
columnWidthSettings.append(column.getWidth());
columnOrderSettings.append(tableTables.convertColumnIndexToModel(i));
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, columnWidthSettings.toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_COLUMNS_ORDER, columnOrderSettings.toString());
TableUtil.saveColumnWidthAndOrderToPrefs(tableTables, KEY_TABLES_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_ORDER);
}
private void restoreDividerLocations() {
@ -1158,6 +1147,7 @@ public class TablesPanel extends javax.swing.JPanel {
options.setWinsNeeded(1);
options.setMatchTimeLimit(MatchTimeLimit.NONE);
options.setFreeMulligans(2);
options.setSkillLevel(SkillLevel.CASUAL);
table = client.createTable(roomId, options);
client.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
@ -1263,8 +1253,7 @@ class TableTableModel extends AbstractTableModel {
public static final int ACTION_COLUMN = 8; // column the action is located (starting with 0)
private final String[] columnNames = new String[]{"M/T","Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Skill Level", "Action"};
private static final int[] defaultColumnsWidth = {35, 150, 120, 180, 80, 120, 80, 60, 60};
private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");;
@ -1273,32 +1262,7 @@ class TableTableModel extends AbstractTableModel {
public void loadData(Collection<TableView> tables) throws MageRemoteException {
this.tables = tables.toArray(new TableView[0]);
this.fireTableDataChanged();
}
static public void setColumnWidthAndOrder(JTable table) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// set the column width from saved value or defaults
int[] widths = Util.getIntArrayFromString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, null));
int i = 0;
for (int width : defaultColumnsWidth) {
if (widths != null && widths.length > i) {
width = widths[i];
}
TableColumn column = table.getColumnModel().getColumn(i++);
column.setWidth(width);
column.setPreferredWidth(width);
}
// set the column order
int[] order = Util.getIntArrayFromString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_ORDER, null));
if (order != null && order.length == table.getColumnCount()) {
for (int j = 0; j < table.getColumnCount(); j++) {
table.moveColumn(table.convertColumnIndexToView(order[j]), j);
}
}
}
}
@Override
public int getRowCount() {

View file

@ -78,7 +78,7 @@ public class ColorsChooser extends JComboBox implements ListCellRenderer {
}
private void drawOn(JPanel panel, String value) {
List<Image> images = new ArrayList<Image>();
List<Image> images = new ArrayList<>();
value = value.toUpperCase();
for (int i = 0; i < value.length(); i++) {
char symbol = value.charAt(i);

View file

@ -13,7 +13,6 @@ import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import mage.client.dialog.MageDialog;
import mage.constants.Rarity;
public class GuiDisplayUtil {

View file

@ -0,0 +1,87 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.client.util.gui;
import javax.swing.JTable;
import javax.swing.table.TableColumn;
import mage.client.dialog.PreferencesDialog;
import org.mage.card.arcane.Util;
/**
*
* @author LevelX2
*/
public class TableUtil {
/**
*
* @param table
* @param defaultColumnsWidth
* @param widthPrefKey
* @param orderPrefKey
*/
static public void setColumnWidthAndOrder(JTable table, int[] defaultColumnsWidth, String widthPrefKey, String orderPrefKey) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// set the column width from saved value or defaults
int[] widths = getIntArrayFromString(PreferencesDialog.getCachedValue(widthPrefKey, null));
int i = 0;
for (int width : defaultColumnsWidth) {
if (widths != null && widths.length > i) {
width = widths[i];
}
TableColumn column = table.getColumnModel().getColumn(i++);
column.setWidth(width);
column.setPreferredWidth(width);
}
// set the column order
int[] order = getIntArrayFromString(PreferencesDialog.getCachedValue(orderPrefKey, null));
if (order != null && order.length == table.getColumnCount()) {
for (int j = 0; j < table.getColumnCount(); j++) {
table.moveColumn(table.convertColumnIndexToView(order[j]), j);
}
}
}
static public void saveColumnWidthAndOrderToPrefs(JTable table, String widthPrefKey, String orderPrefKey) {
// Column width
StringBuilder columnWidthSettings = new StringBuilder();
StringBuilder columnOrderSettings = new StringBuilder();
boolean firstValue = true;
for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
TableColumn column = table.getColumnModel().getColumn(table.convertColumnIndexToView(i));
if (!firstValue) {
columnWidthSettings.append(",");
columnOrderSettings.append(",");
} else {
firstValue = false;
}
columnWidthSettings.append(column.getWidth());
columnOrderSettings.append(table.convertColumnIndexToModel(i));
}
PreferencesDialog.saveValue(widthPrefKey, columnWidthSettings.toString());
PreferencesDialog.saveValue(orderPrefKey, columnOrderSettings.toString());
}
public static int[] getIntArrayFromString(String stringData) {
int[] intArray = null;
if (stringData != null && !stringData.isEmpty()) {
String[] items = stringData.split(",");
int lengthW = items.length;
intArray = new int[lengthW];
for (int i = 0; i < lengthW; i++) {
try {
intArray[i] = Integer.parseInt(items[i]);
} catch (NumberFormatException nfe) {}
}
}
return intArray;
}
}

View file

@ -0,0 +1,320 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.util.gui.countryBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
/**
* A custom combo box with its own renderer and editor.
* @author wwww.codejava.net
*
*/
public class CountryComboBox extends JComboBox {
private final DefaultComboBoxModel model;
public static String[][] countryList = {
{"Afghanistan", "af"},
{"Åland Islands", "ax"},
{"Albania", "al"},
{"Algeria", "dz"},
{"American Samoa", "as"},
{"Andorra", "ad"},
{"Angola", "an"},
{"Anguilla", "ai"},
{"Antarctica", "ao"},
{"Antigua and Barbuda", "ag"},
{"Argentina", "ar"},
{"Armenia", "am"},
{"Aruba", "aw"},
{"Australia", "au"},
{"Austria", "at"},
{"Azerbaijan", "az"},
{"Bahamas", "bs"},
{"Bahrain", "bh"},
{"Bangladesh", "bd"},
{"Barbados", "bb"},
{"Belarus", "by"},
{"Belgium", "be"},
{"Belize", "bz"},
{"Benin", "bj"},
{"Bermuda", "bm"},
{"Bhutan", "bt"},
{"Bolivia, Plurinational State of", "bo"},
{"Bosnia and Herzegovina", "ba"},
{"Botswana", "bw"},
{"Bouvet Island", "bv"},
{"Brazil", "br"},
{"British Indian Ocean Territory", "io"},
{"Brunei Darussalam", "bn"},
{"Bulgaria", "bg"},
{"Burkina Faso", "bf"},
{"Burundi", "bi"},
{"Cabo Verde", "cv"},
{"Cambodia", "kh"},
{"Cameroon", "cm"},
{"Canada", "ca"},
{"Catalonia", "catalonia"},
{"Cayman Islands", "ky"},
{"Central African Republic", "cf"},
{"Chad", "td"},
{"Chile", "cl"},
{"China", "cn"},
{"Christmas Island", "cx"},
{"Cocos (Keeling) Islands", "cc"},
{"Colombia", "co"},
{"Comoros", "km"},
{"Congo", "cg"},
{"Congo, the Democratic Republic of the", "cd"},
{"Cook Islands", "ck"},
{"Costa Rica", "cr"},
{"Côte d'Ivoire", "ci"},
{"Croatia", "hr"},
{"Cuba", "cu"},
{"Cyprus", "cy"},
{"Czech Republic", "cz"},
{"Denmark", "dk"},
{"Djibouti", "dj"},
{"Dominica", "dm"},
{"Dominican Republic", "do"},
{"Ecuador", "ec"},
{"Egypt", "eg"},
{"El Salvador", "sv"},
{"England", "england"},
{"Equatorial Guinea", "gq"},
{"Eritrea", "er"},
{"Estonia", "ee"},
{"Ethiopia", "et"},
{"European Union", "europeanunion"},
{"Falkland Islands (Malvinas)", "fk"},
{"Faroe Islands", "fo"},
{"Fiji", "fj"},
{"Finland", "fi"},
{"France", "fr"},
{"French Guiana", "gf"},
{"French Polynesia", "pf"},
{"French Southern Territories", "tf"},
{"Gabon", "ga"},
{"Gambia", "gm"},
{"Georgia", "ge"},
{"Germany", "de"},
{"Ghana", "gh"},
{"Gibraltar", "gi"},
{"Greece", "gr"},
{"Greenland", "gl"},
{"Grenada", "gd"},
{"Guadeloupe", "gp"},
{"Guam", "gu"},
{"Guatemala", "gt"},
{"Guinea", "gn"},
{"Guinea-Bissau", "gw"},
{"Guyana", "gy"},
{"Haiti", "ht"},
{"Heard Island and McDonald Islands", "hm"},
{"Holy See", "va"},
{"Honduras", "hn"},
{"Hong Kong", "hk"},
{"Hungary", "hu"},
{"Iceland", "is"},
{"India", "in"},
{"Indonesia", "id"},
{"Iran, Islamic Republic of", "ir"},
{"Iraq", "iq"},
{"Ireland", "ie"},
{"Israel", "il"},
{"Italy", "it"},
{"Jamaica", "jm"},
{"Japan", "jp"},
{"Jordan", "jo"},
{"Kazakhstan", "kz"},
{"Kenya", "ke"},
{"Kiribati", "ki"},
{"Korea, Democratic People's Republic of", "kp"},
{"Korea, Republic of", "kr"},
{"Kuwait", "kw"},
{"Kyrgyzstan", "kg"},
{"Lao People's Democratic Republic", "la"},
{"Latvia", "lv"},
{"Lebanon", "lb"},
{"Lesotho", "ls"},
{"Liberia", "lr"},
{"Libya", "ly"},
{"Liechtenstein", "li"},
{"Lithuania", "lt"},
{"Luxembourg", "lu"},
{"Macao", "mo"},
{"Macedonia, the former Yugoslav Republic of", "mk"},
{"Madagascar", "mg"},
{"Malawi", "mw"},
{"Malaysia", "my"},
{"Maldives", "mv"},
{"Mali", "ml"},
{"Malta", "mt"},
{"Marshall Islands", "mh"},
{"Martinique", "mq"},
{"Mauritania", "mr"},
{"Mauritius", "mu"},
{"Mayotte", "yt"},
{"Mexico", "mx"},
{"Micronesia, Federated States of", "fm"},
{"Moldova, Republic of", "md"},
{"Monaco", "mc"},
{"Mongolia", "mn"},
{"Montenegro", "me"},
{"Montserrat", "ms"},
{"Morocco", "ma"},
{"Mozambique", "mz"},
{"Myanmar", "mm"},
{"Namibia", "na"},
{"Nauru", "nr"},
{"Nepal", "np"},
{"Netherlands", "nl"},
{"New Caledonia", "nc"},
{"New Zealand", "nz"},
{"Nicaragua", "ni"},
{"Niger", "ne"},
{"Nigeria", "ng"},
{"Niue", "nu"},
{"Norfolk Island", "nf"},
{"Northern Mariana Islands", "mp"},
{"Norway", "no"},
{"Oman", "om"},
{"Pakistan", "pk"},
{"Palau", "pw"},
{"Palestine, State of", "ps"},
{"Panama", "pa"},
{"Papua New Guinea", "pg"},
{"Paraguay", "py"},
{"Peru", "pe"},
{"Philippines", "ph"},
{"Pitcairn", "pn"},
{"Poland", "pl"},
{"Portugal", "pt"},
{"Puerto Rico", "pr"},
{"Qatar", "qa"},
{"Réunion", "re"},
{"Romania", "ro"},
{"Russian Federation", "ru"},
{"Rwanda", "rw"},
{"Saint Helena, Ascension and Tristan da Cunha", "sh"},
{"Saint Kitts and Nevis", "kn"},
{"Saint Lucia", "lc"},
{"Saint Pierre and Miquelon", "pm"},
{"Saint Vincent and the Grenadines", "vc"},
{"Samoa", "ws"},
{"San Marino", "sm"},
{"Sao Tome and Principe", "st"},
{"Saudi Arabia", "sa"},
{"Scotland", "scotland"},
{"Senegal", "sn"},
{"Serbia", "rs"},
{"Seychelles", "sc"},
{"Sierra Leone", "sl"},
{"Singapore", "sg"},
{"Slovakia", "sk"},
{"Slovenia", "si"},
{"Solomon Islands", "sb"},
{"Somalia", "so"},
{"South Africa", "za"},
{"South Georgia and the South Sandwich Islands", "gs"},
{"Spain", "es"},
{"Sri Lanka", "lk"},
{"Sudan", "sd"},
{"Suriname", "sr"},
{"Svalbard and Jan Mayen", "sj"},
{"Swaziland", "sz"},
{"Sweden", "se"},
{"Switzerland", "ch"},
{"Syrian Arab Republic", "sy"},
{"Taiwan, Province of China", "tw"},
{"Tajikistan", "tj"},
{"Tanzania, United Republic of", "tz"},
{"Thailand", "th"},
{"Timor-Leste", "tl"},
{"Togo", "tg"},
{"Tokelau", "tk"},
{"Tonga", "to"},
{"Trinidad and Tobago", "tt"},
{"Tunisia", "tn"},
{"Turkey", "tr"},
{"Turkmenistan", "tm"},
{"Turks and Caicos Islands", "tc"},
{"Tuvalu", "tv"},
{"Uganda", "ug"},
{"Ukraine", "ua"},
{"United Arab Emirates", "ae"},
{"United Kingdom of Great Britain and Northern Ireland", "gb"},
{"United States Minor Outlying Islands", "um"},
{"United States of America", "us"},
{"Uruguay", "uy"},
{"Uzbekistan", "uz"},
{"Vanuatu", "vu"},
{"Venezuela, Bolivarian Republic of", "ve"},
{"Viet Nam", "vn"},
{"Virgin Islands, British", "vg"},
{"Virgin Islands, U.S.", "vi"},
{"Wales", "wales"},
{"Wallis and Futuna", "wf"},
{"World", "world"},
{"Western Sahara", "eh"},
{"Yemen", "ye"},
{"Zambia", "zm"},
{"Zimbabwe", "zw"},
};
@SuppressWarnings("unchecked")
public CountryComboBox() {
model = new DefaultComboBoxModel();
setModel(model);
setRenderer(new CountryItemRenderer());
setEditor(new CountryItemEditor());
addItems(countryList);
}
/**
* Add an array items to this combo box.
* Each item is an array of two String elements:
* - first element is country name.
* - second element is path of an image file for country flag.
* @param items
*/
@SuppressWarnings("unchecked")
public void addItems(String[][] items) {
for (String[] anItem : items) {
model.addElement(anItem);
}
}
@Override
public Object getSelectedItem() {
return super.getSelectedItem(); //To change body of generated methods, choose Tools | Templates.
}
}

View file

@ -0,0 +1,95 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.util.gui.countryBox;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicComboBoxEditor;
/**
* Editor for JComboBox
* @author wwww.codejava.net
*
*/
public class CountryItemEditor extends BasicComboBoxEditor {
private final JPanel panel = new JPanel();
private final JLabel labelItem = new JLabel();
private String selectedValue;
private String selectedImage;
public CountryItemEditor() {
panel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1.0;
// constraints.insets = new Insets(2, 5, 2, 2);
constraints.insets = new Insets(0, 5, 0, 0);
labelItem.setOpaque(false);
labelItem.setHorizontalAlignment(JLabel.LEFT);
labelItem.setForeground(Color.WHITE);
panel.add(labelItem, constraints);
// panel.setBackground(Color.WHITE);
panel.setBackground(new Color(0, 100,190, 255));
selectedValue = null;
}
@Override
public Component getEditorComponent() {
return this.panel;
}
@Override
public Object getItem() {
return this.selectedValue;
}
public String getImageItem() {
return this.selectedImage;
}
@Override
public void setItem(Object item) {
if (item == null || !(item instanceof String[])) {
return;
}
String[] countryItem = (String[]) item;
selectedValue = countryItem[0];
selectedImage = countryItem[1];
labelItem.setText(selectedValue);
labelItem.setIcon(new ImageIcon(getClass().getResource("/flags/"+ countryItem[1] + ".png")));
}
}

View file

@ -0,0 +1,87 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.util.gui.countryBox;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
* Customer renderer for JComboBox
* @author www.codejava.net
*
*/
public class CountryItemRenderer extends JPanel implements ListCellRenderer {
private final JLabel labelItem = new JLabel();
public CountryItemRenderer() {
setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1.0;
constraints.insets = new Insets(0, 0, 0, 0);
labelItem.setOpaque(true);
labelItem.setHorizontalAlignment(JLabel.LEFT);
add(labelItem, constraints);
setBackground(Color.LIGHT_GRAY);
}
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
String[] countryItem = (String[]) value;
// set country name
labelItem.setText(countryItem[0]);
// set country flag
labelItem.setIcon(new ImageIcon(countryItem[1]));
if (isSelected) {
labelItem.setBackground(Color.BLUE);
labelItem.setForeground(Color.YELLOW);
} else {
labelItem.setForeground(Color.BLACK);
labelItem.setBackground(Color.LIGHT_GRAY);
}
return this;
}
}

View file

@ -0,0 +1,77 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.util.gui.countryBox;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.plaf.basic.BasicComboBoxEditor;
/**
*
* @author LevelX2
*/
public class MyComboBoxEditor extends BasicComboBoxEditor {
private final JLabel label;
private final JPanel panel;
private Object selectedItem;
public MyComboBoxEditor() {
label = new JLabel();
panel = new JPanel();
label.setOpaque(false);
label.setFont(new Font("Arial", Font.BOLD, 14));
label.setForeground(Color.BLACK);
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));
panel.add(label);
panel.setBackground(Color.BLUE);
}
@Override
public Component getEditorComponent() {
return this.panel;
}
@Override
public Object getItem() {
return "[" + this.selectedItem.toString() + "]";
}
@Override
public void setItem(Object item) {
this.selectedItem = item;
label.setText(item.toString());
}
}

View file

@ -0,0 +1,57 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.util.gui.countryBox;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
/**
*
* @author LevelX2
*/
public class MyComboBoxRenderer extends JLabel implements ListCellRenderer {
public MyComboBoxRenderer() {
setOpaque(true);
setFont(new Font("Arial", Font.BOLD /*| Font.ITALIC*/, 14));
setBackground(Color.BLUE);
setForeground(Color.YELLOW);
}
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
setText(value.toString());
return this;
}
}

View file

@ -89,19 +89,5 @@ public class Util {
throw new RuntimeException("Error invoking runnable in UI thread.", ex);
}
}
public static int[] getIntArrayFromString(String stringData) {
int[] intArray = null;
if (stringData != null && !stringData.isEmpty()) {
String[] items = stringData.split(",");
int lengthW = items.length;
intArray = new int[lengthW];
for (int i = 0; i < lengthW; i++) {
try {
intArray[i] = Integer.parseInt(items[i]);
} catch (NumberFormatException nfe) {}
}
}
return intArray;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

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