Merge remote-tracking branch 'origin/master' into decouple-client

Conflicts:
	Mage/src/mage/cards/repository/CardRepository.java
This commit is contained in:
North 2013-06-30 11:26:40 +03:00
commit 1fccbd6b87
339 changed files with 17278 additions and 1002 deletions

View file

@ -26,8 +26,11 @@ public class HoverButton extends JPanel implements MouseListener {
private int textOffsetY = 0;
private int textOffsetButtonY = 2;
private int textOffsetX = -1;
private int topTextOffsetX = -1;
private Dimension overlayImageSize;
private String topText;
private boolean isHovered = false;
private boolean isSelected = false;
private boolean drawSet = false;
@ -36,6 +39,7 @@ public class HoverButton extends JPanel implements MouseListener {
private Command observer = null;
private Command onHover = null;
private Color textColor = Color.white;
private Color textBGColor = Color.black;
static final Font textFont = new Font("Arial", Font.PLAIN, 12);
static final Font textFontMini = new Font("Arial", Font.PLAIN, 11);
@ -100,6 +104,18 @@ public class HoverButton extends JPanel implements MouseListener {
} else {
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
}
if (topText != null) {
if (useMiniFont) {
g2d.setFont(textFontMini);
} else {
g2d.setFont(textFont);
}
topTextOffsetX = calculateOffsetForTop(g2d, topText);
g2d.setColor(textBGColor);
g2d.drawString(topText, topTextOffsetX+1, 13);
g2d.setColor(textColor);
g2d.drawString(topText, topTextOffsetX, 12);
}
if (overlayImage != null) {
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
} else if (set != null) {
@ -136,6 +152,15 @@ public class HoverButton extends JPanel implements MouseListener {
return textOffsetX;
}
private int calculateOffsetForTop(Graphics2D g2d, String text) {
if (topTextOffsetX == -1) { // calculate once
FontRenderContext frc = g2d.getFontRenderContext();
int textWidth = (int) textFont.getStringBounds(text, frc).getWidth();
topTextOffsetX = (imageSize.width - textWidth) / 2;
}
return topTextOffsetX;
}
public void setTextColor(Color textColor) {
this.textColor = textColor;
}
@ -242,4 +267,8 @@ public class HoverButton extends JPanel implements MouseListener {
observer.execute();
}
}
public void setTopText(String topText) {
this.topText = topText;
}
}

View file

@ -102,12 +102,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(Integer.toString(timeout));
setTimeout(timeout);
}
else {
if (updateDeckTask != null)
updateDeckTask.cancel(true);
setTimeout("0");
setTimeout(0);
countdown.stop();
hideDeckEditor();
}
@ -136,7 +136,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
this.deckArea.showSideboard(false);
countdown.stop();
this.timeout = time;
setTimeout(Integer.toString(timeout));
setTimeout(timeout);
if (timeout != 0) {
countdown.start();
if (updateDeckTask == null || updateDeckTask.isDone()) {
@ -308,7 +308,20 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
}
private void setTimeout(String text) {
private void setTimeout(int s){
int minute = s/60;
int second = s - (minute*60);
String text;
if(minute < 10){
text = "0" + Integer.toString(minute) + ":";
}else{
text = Integer.toString(minute) + ":";
}
if(second < 10){
text = text + "0" + Integer.toString(second);
}else{
text = text + Integer.toString(second);
}
this.txtTimeRemaining.setText(text);
}

View file

@ -25,41 +25,49 @@
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lbDeckType" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
<Component id="lbDeckType" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="cbGameType" min="-2" pref="398" max="-2" attributes="1"/>
<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="50" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="9" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="cbDeckType" alignment="0" max="32767" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<Component id="cbGameType" min="-2" pref="398" max="-2" attributes="1"/>
<Component id="txtName" min="-2" pref="546" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="cbDeckType" max="32767" attributes="1"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lbTimeLimit" min="-2" 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" pref="50" max="32767" attributes="0"/>
<Component id="cbTimeLimit" min="-2" pref="126" max="-2" attributes="1"/>
</Group>
<Component id="txtName" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="0" pref="29" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="btnOK" min="-2" max="-2" attributes="0"/>
@ -88,6 +96,7 @@
</Group>
</Group>
<Component id="jSeparator2" alignment="1" max="32767" attributes="0"/>
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" alignment="1" max="32767" attributes="0"/>
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
</Group>
@ -98,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="625" max="32767" attributes="0"/>
<Component id="jSeparator3" pref="633" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -107,17 +116,19 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lbDeckType" min="-2" max="-2" attributes="0"/>
<Component id="cbDeckType" min="-2" max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<Component id="txtName" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
@ -157,10 +168,12 @@
<Component id="jSeparator2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="player1Panel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="205" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" pref="181" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -174,7 +187,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="248" max="32767" attributes="0"/>
<EmptySpace pref="252" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@ -198,6 +211,14 @@
</Component>
<Component class="javax.swing.JComboBox" name="cbDeckType">
</Component>
<Component class="javax.swing.JLabel" name="lbTimeLimit">
<Properties>
<Property name="text" type="java.lang.String" value="Time Limit:"/>
<Property name="toolTipText" type="java.lang.String" value="The activie time a player may use to finish the match. If the time runs out, the player looses the current game."/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbTimeLimit">
</Component>
<Component class="javax.swing.JLabel" name="lblGameType">
<Properties>
<Property name="text" type="java.lang.String" value="Game Type:"/>
@ -211,6 +232,7 @@
<Component class="javax.swing.JLabel" name="lblFreeMulligans">
<Properties>
<Property name="text" type="java.lang.String" value="Free Mulligans:"/>
<Property name="toolTipText" type="java.lang.String" value="The number of mulligans a player can use without decreasing the number of drawn cards."/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnFreeMulligans">
@ -264,6 +286,7 @@
<ComponentRef name="spnNumWins"/>
</Property>
<Property name="text" type="java.lang.String" value="Wins"/>
<Property name="toolTipText" type="java.lang.String" value="How many games has a player to win to win the match."/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnNumWins">
@ -281,6 +304,8 @@
<Property name="text" type="java.lang.String" value="Player 1 (You)"/>
</Properties>
</Component>
<Component class="mage.client.table.NewPlayerPanel" name="player1Panel">
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator3">
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">

View file

@ -27,21 +27,23 @@
*/
package mage.client.dialog;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.*;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.components.MageComponents;
import mage.client.table.*;
import mage.client.table.TablePlayerPanel;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.game.match.MatchOptions;
import mage.remote.Session;
import mage.view.GameTypeView;
@ -85,6 +87,8 @@ public class NewTableDialog extends MageDialog {
txtName = new javax.swing.JTextField();
lbDeckType = new javax.swing.JLabel();
cbDeckType = new javax.swing.JComboBox();
lbTimeLimit = new javax.swing.JLabel();
cbTimeLimit = new javax.swing.JComboBox();
lblGameType = new javax.swing.JLabel();
cbGameType = new javax.swing.JComboBox();
lblFreeMulligans = new javax.swing.JLabel();
@ -114,6 +118,9 @@ public class NewTableDialog extends MageDialog {
lbDeckType.setText("Deck Type:");
lbTimeLimit.setText("Time Limit:");
lbTimeLimit.setToolTipText("The activie time a player may use to finish the match. If the time runs out, the player looses the current game.");
lblGameType.setText("Game Type:");
cbGameType.addActionListener(new java.awt.event.ActionListener() {
@ -123,6 +130,7 @@ public class NewTableDialog extends MageDialog {
});
lblFreeMulligans.setText("Free Mulligans:");
lblFreeMulligans.setToolTipText("The number of mulligans a player can use without decreasing the number of drawn cards.");
lblNumPlayers.setLabelFor(spnNumPlayers);
lblNumPlayers.setText("Players");
@ -141,6 +149,7 @@ public class NewTableDialog extends MageDialog {
lblNumWins.setLabelFor(spnNumWins);
lblNumWins.setText("Wins");
lblNumWins.setToolTipText("How many games has a player to win to win the match.");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
@ -177,33 +186,39 @@ public class NewTableDialog extends MageDialog {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lbDeckType)
.addComponent(lblGameType)
.addComponent(lblName))
.addComponent(lblName)))
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(lbDeckType)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 398, 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, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 9, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(cbDeckType, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(cbDeckType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE))
.addComponent(txtName))))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOK)
@ -233,27 +248,30 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 625, Short.MAX_VALUE)
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 633, Short.MAX_VALUE)
.addContainerGap()))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblName)
.addComponent(txtName, 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.TRAILING)
.addComponent(lbDeckType)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType)
.addComponent(lbTimeLimit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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))
.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)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
@ -282,7 +300,7 @@ public class NewTableDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -294,7 +312,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(240, Short.MAX_VALUE)))
.addContainerGap(252, Short.MAX_VALUE)))
);
pack();
@ -315,6 +333,7 @@ public class NewTableDialog extends MageDialog {
}
options.setDeckType((String) this.cbDeckType.getSelectedItem());
options.setLimited(false);
options.setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
options.setWinsNeeded((Integer)this.spnNumWins.getValue());
@ -422,6 +441,7 @@ public class NewTableDialog extends MageDialog {
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
selectLimitedByDefault();
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values()));
@ -464,13 +484,19 @@ public class NewTableDialog extends MageDialog {
break;
}
}
int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT, "1500"));
for (MatchTimeLimit mtl :MatchTimeLimit.values()) {
if (mtl.getTimeLimit() == timeLimit) {
this.cbTimeLimit.setSelectedItem(mtl);
break;
}
}
cbDeckType.setSelectedItem(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE, "Limited"));
String deckFile = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, null);
if (deckFile != null) {
this.player1Panel.setDeckFile(deckFile);
}
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, "2")));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, "0")));
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, "1"));
for (RangeOfInfluence roi :RangeOfInfluence.values()) {
@ -497,9 +523,9 @@ public class NewTableDialog extends MageDialog {
private void saveGameSettingsToPrefs(MatchOptions options, String deckFile) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NAME, options.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE, options.getDeckType());
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_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()));
@ -513,12 +539,14 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JComboBox cbDeckType;
private javax.swing.JComboBox cbGameType;
private javax.swing.JComboBox cbRange;
private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lbTimeLimit;
private javax.swing.JLabel lblAttack;
private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblGameType;
@ -534,4 +562,4 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JTextField txtName;
// End of variables declaration//GEN-END:variables
}
}

View file

@ -27,54 +27,57 @@
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtName" max="32767" attributes="0"/>
<Component id="cbTournamentType" pref="330" max="32767" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="lblConstructionTime" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spnConstructTime" pref="48" max="32767" attributes="0"/>
<Component id="spnNumWins" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="45" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="45" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" 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="233" 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" pref="115" max="32767" attributes="1"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTournamentType" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lblConstructionTime" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnConstructTime" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="40" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="spnNumWins" min="-2" pref="41" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -85,39 +88,30 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spnNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="pnlPacks" pref="65" max="32767" attributes="0"/>
<Component id="pnlPacks" pref="62" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumPlayers" alignment="0" pref="28" max="32767" attributes="1"/>
<Component id="spnNumPlayers" alignment="0" pref="25" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
@ -140,6 +134,13 @@
</Component>
<Component class="javax.swing.JTextField" name="txtName">
</Component>
<Component class="javax.swing.JLabel" name="lbTimeLimit">
<Properties>
<Property name="text" type="java.lang.String" value="Time Limit:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbTimeLimit">
</Component>
<Component class="javax.swing.JLabel" name="lblConstructionTime">
<Properties>
<Property name="text" type="java.lang.String" value="Construction Time (Minutes):"/>
@ -233,7 +234,7 @@
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" pref="638" max="32767" attributes="0"/>
<Component id="txtPlayer1Name" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>

View file

@ -41,12 +41,13 @@ import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.cards.ExpansionSet;
import mage.cards.Sets;
import mage.client.MageFrame;
import mage.client.table.TournamentPlayerPanel;
import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
@ -86,6 +87,7 @@ public class NewTournamentDialog extends MageDialog {
session = MageFrame.getSession();
this.txtPlayer1Name.setText(session.getUserName());
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
this.setModal(true);
setTournamentOptions();
@ -104,6 +106,8 @@ public class NewTournamentDialog extends MageDialog {
lblName = new javax.swing.JLabel();
txtName = new javax.swing.JTextField();
lbTimeLimit = new javax.swing.JLabel();
cbTimeLimit = new javax.swing.JComboBox();
lblConstructionTime = new javax.swing.JLabel();
spnConstructTime = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel();
@ -131,6 +135,8 @@ public class NewTournamentDialog extends MageDialog {
lblName.setText("Name:");
lbTimeLimit.setText("Time Limit:");
lblConstructionTime.setText("Construction Time (Minutes):");
jLabel1.setText("Tournament Type:");
@ -198,7 +204,7 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 638, Short.MAX_VALUE)))
.addComponent(txtPlayer1Name)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
@ -247,76 +253,76 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblName)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtName)
.addComponent(cbTournamentType, 0, 330, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblNumWins))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spnConstructTime, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
.addComponent(spnNumWins)))
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING))
.addGap(0, 0, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, 0, 115, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTournamentType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblConstructionTime)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addContainerGap())
);
layout.setVerticalGroup(
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.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(cbTournamentType, 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.BASELINE)
.addComponent(lblConstructionTime)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans))))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName)
.addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -351,12 +357,13 @@ public class NewTournamentDialog extends MageDialog {
if (tournamentType.isLimited()) {
if (tOptions.getLimitedOptions() == null) {
tOptions.setLimitedOptions(new LimitedOptions());
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue());
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
}
for (JComboBox pack: packs) {
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionSet) pack.getSelectedItem()).getCode());
}
}
tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
tOptions.getMatchOptions().setDeckType("Limited");
tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
@ -512,6 +519,7 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk;
private javax.swing.JComboBox cbDraftTiming;
private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JComboBox cbTournamentType;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
@ -520,6 +528,7 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lbTimeLimit;
private javax.swing.JLabel lblConstructionTime;
private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblName;

View file

@ -92,6 +92,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
// default setting for new table dialog
public static final String KEY_NEW_TABLE_NAME = "newTableName";
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_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans";
@ -154,24 +155,18 @@ public class PreferencesDialog extends javax.swing.JDialog {
private final JFileChooser fc_i = new JFileChooser();
{
fc_i.setAcceptAllFileFilterUsed(false);
fc_i.addChoosableFileFilter(new ImageFileFilter(".jpg"));
fc_i.addChoosableFileFilter(new ImageFileFilter(".jpeg"));
fc_i.addChoosableFileFilter(new ImageFileFilter(".png"));
fc_i.addChoosableFileFilter(new ImageFileFilter(".bmp"));
fc_i.addChoosableFileFilter(new ImageFileFilter());
}
private static class ImageFileFilter extends FileFilter{
String extend;
public ImageFileFilter(String extend){
this.extend = extend;
}
@Override
public boolean accept(File f) {
String filename = f.getName();
if(f.isDirectory()) return true;
if(filename != null){
if(filename.endsWith(extend)){
if(filename.endsWith(".jpg") || filename.endsWith(".jpeg") ||
filename.endsWith(".png") || filename.endsWith(".bmp")){
return true;
}
}
@ -180,13 +175,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
@Override
public String getDescription() {
if(extend.equals(".png") || extend.equals(".bmp"))
return "Image File(*.png, *.bmp)";
if(extend.equals(".jpg") || extend.equals(".jpg"))
return "JEGP file(*.jpg,*.jepg)";
return "";
}
return "*.png | *.bmp |*.jpg | *.jpeg";
}
}

View file

@ -49,6 +49,7 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import mage.client.util.AudioManager;
/**
*
@ -392,6 +393,7 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
if (count > 0) {
if (current > count) {
MageTray.getInstance().displayMessage("New player joined your game.");
AudioManager.playPlayerJoinedTable();
} else {
MageTray.getInstance().displayMessage("A player left your game.");
}

View file

@ -78,10 +78,10 @@ public class DraftPanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(Integer.toString(timeout));
setTimeout(timeout);
}
else {
setTimeout("0");
setTimeout(0);
countdown.stop();
}
}
@ -119,7 +119,6 @@ public class DraftPanel extends javax.swing.JPanel {
SimpleCardView source = (SimpleCardView) event.getSource();
DraftPickView view = session.sendCardPick(draftId, source.getId());
if (view != null) {
//draftBooster.loadBooster(view.getBooster(), bigCard);
draftBooster.loadBooster(emptyView, bigCard);
draftPicks.loadCards(CardsViewUtil.convertSimple(view.getPicks()), bigCard, null);
Plugins.getInstance().getActionCallback().hidePopup();
@ -132,13 +131,26 @@ public class DraftPanel extends javax.swing.JPanel {
setMessage("Pick a card");
countdown.stop();
this.timeout = draftPickView.getTimeout();
setTimeout(Integer.toString(timeout));
setTimeout(timeout);
if (timeout != 0) {
countdown.start();
}
}
private void setTimeout(String text) {
private void setTimeout(int s){
int minute = s/60;
int second = s - (minute*60);
String text;
if(minute < 10){
text = "0" + Integer.toString(minute) + ":";
}else{
text = Integer.toString(minute) + ":";
}
if(second < 10){
text = text + "0" + Integer.toString(second);
}else{
text = text + Integer.toString(second);
}
this.txtTimeRemaining.setText(text);
}

View file

@ -353,7 +353,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
}
PlayerView player = game.getPlayers().get(playerSeat);
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true);
PlayAreaPanel sessionPlayer = new PlayAreaPanel(player, bigCard, gameId, true, game.getPriorityTime());
players.put(player.getPlayerId(), sessionPlayer);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
@ -385,7 +385,7 @@ public final class GamePanel extends javax.swing.JPanel {
col = numColumns - 1;
}
player = game.getPlayers().get(playerNum);
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false);
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, false, game.getPriorityTime());
players.put(player.getPlayerId(), playerPanel);
c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;

View file

@ -64,9 +64,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
addPopupMenu();
}
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime) {
this();
init(player, bigCard, gameId);
init(player, bigCard, gameId, priorityTime);
update(player);
}
@ -99,8 +99,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
});
}
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
public final void init(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime) {
this.playerPanel.init(gameId, player.getPlayerId(), bigCard, priorityTime);
this.battlefieldPanel.init(gameId, bigCard);
this.gameId = gameId;
if (MageFrame.getSession().isTestMode()) {

View file

@ -34,6 +34,7 @@
package mage.client.game;
import mage.MageException;
import mage.cards.MageCard;
import mage.cards.action.ActionCallback;
import mage.cards.decks.importer.DckDeckImporter;
@ -52,6 +53,7 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import mage.components.ImagePanel;
import mage.remote.Session;
import mage.utils.timer.PriorityTimer;
import mage.view.CardView;
import mage.view.ManaPoolView;
import mage.view.PlayerView;
@ -101,19 +103,43 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private int avatarId = -1;
private PriorityTimer timer;
/** Creates new form PlayerPanel */
public PlayerPanelExt() {
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
initComponents();
}
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
public void init(UUID gameId, UUID playerId, BigCard bigCard, int priorityTime) {
this.gameId = gameId;
this.playerId = playerId;
this.bigCard = bigCard;
session = MageFrame.getSession();
cheat.setVisible(session.isTestMode());
cheat.setFocusable(false);
if (priorityTime > 0) {
long delay = 1000L;
timer = new PriorityTimer(priorityTime, delay, new mage.interfaces.Action() {
@Override
public void execute() throws MageException {
// do nothing
}
});
final PriorityTimer pt = timer;
timer.setTaskOnTick(new mage.interfaces.Action() {
@Override
public void execute() throws MageException {
int priorityTimeValue = pt.getCount();
String text = getPriorityTimeLeftString(priorityTimeValue);
PlayerPanelExt.this.avatar.setTopText(text);
PlayerPanelExt.this.avatar.repaint();
}
});
timer.init();
}
}
public void update(PlayerView player) {
@ -182,6 +208,19 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
}
this.avatar.setText(player.getName());
if (this.timer != null) {
if (player.getPriorityTimeLeft() != Integer.MAX_VALUE) {
String priorityTimeValue = getPriorityTimeLeftString(player);
this.timer.setCount(player.getPriorityTimeLeft());
this.avatar.setTopText(priorityTimeValue);
}
if (player.hasPriority()) {
this.timer.resume();
} else {
this.timer.pause();
}
}
this.btnPlayer.setText(player.getName());
if (player.isActive()) {
this.avatar.setBorder(greenBorder);
@ -193,6 +232,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
this.avatar.setBorder(emptyBorder);
this.btnPlayer.setBorder(emptyBorder);
}
synchronized (this) {
if (player.getTopCard() != null) {
@ -216,6 +256,18 @@ public class PlayerPanelExt extends javax.swing.JPanel {
update(player.getManaPool());
}
private String getPriorityTimeLeftString(PlayerView player) {
int priorityTimeLeft = player.getPriorityTimeLeft();
return getPriorityTimeLeftString(priorityTimeLeft);
}
private String getPriorityTimeLeftString(int priorityTimeLeft) {
int h = priorityTimeLeft / 3600;
int m = (priorityTimeLeft % 3600) / 60;
int s = priorityTimeLeft % 60;
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
}
protected void update(ManaPoolView pool) {
manaLabels.get("B").setText(Integer.toString(pool.getBlack()));
manaLabels.get("R").setText(Integer.toString(pool.getRed()));

View file

@ -19,11 +19,7 @@
<Component id="jPanel1" alignment="1" max="32767" attributes="0"/>
<Component id="jSplitPane1" alignment="0" pref="848" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jPanel2" pref="809" max="32767" attributes="0"/>
<EmptySpace pref="99" max="32767" attributes="0"/>
</Group>
<Component id="jPanel2" alignment="1" pref="908" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -128,13 +124,12 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jButton1" min="-2" pref="65" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" max="32767" attributes="0"/>
<Component id="jLabel2" pref="701" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="440" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View file

@ -422,7 +422,7 @@ public class TablesPanel extends javax.swing.JPanel {
jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jPanel2.setPreferredSize(new java.awt.Dimension(664, 39));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel1.setText("Message of the Day:");
jLabel1.setAlignmentY(0.3F);
@ -443,13 +443,12 @@ public class TablesPanel extends javax.swing.JPanel {
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, 449, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(440, 440, 440))
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 701, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -486,7 +485,7 @@ public class TablesPanel extends javax.swing.JPanel {
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
.addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 803, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -502,21 +501,18 @@ public class TablesPanel extends javax.swing.JPanel {
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 848, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE)
.addContainerGap(69, Short.MAX_VALUE)))
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 908, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 501, Short.MAX_VALUE)
.addComponent(jSplitPane1)
.addGap(0, 0, 0)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 576, Short.MAX_VALUE))
.addGap(0, 580, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents

View file

@ -1,6 +1,11 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[908, 580]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -16,59 +21,233 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jScrollPane1" pref="573" max="32767" attributes="2"/>
<Component id="jScrollPane2" alignment="1" pref="573" max="32767" attributes="2"/>
</Group>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="chatPanel1" min="-2" pref="215" max="-2" attributes="0"/>
</Group>
<Component id="actionPanel" alignment="0" max="32767" attributes="0"/>
<Component id="jSplitPane2" alignment="1" pref="908" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jScrollPane1" min="-2" pref="262" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jScrollPane2" pref="260" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="actionPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSplitPane2" pref="489" max="32767" attributes="0"/>
</Group>
<Component id="chatPanel1" alignment="0" pref="522" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="mage.client.chat.ChatPanel" name="chatPanel1">
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Container class="javax.swing.JPanel" name="actionPanel">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<Component id="lblType" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtName" pref="260" max="32767" attributes="0"/>
<Component id="txtType" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lablEndTime" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="txtEndTime" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblStartTime" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtStartTime" min="-2" pref="140" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="btnCloseWindow" min="-2" pref="129" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblName" alignment="3" min="-2" pref="23" max="-2" attributes="0"/>
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblStartTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtStartTime" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lablEndTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtEndTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCloseWindow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="14" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTable" name="tablePlayers">
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="this.playersModel" type="code"/>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtName">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="text" type="java.lang.String" value="tournament name"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[50, 22]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblType">
<Properties>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="text" type="java.lang.String" value="Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtType">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="text" type="java.lang.String" value="tournament type"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblStartTime">
<Properties>
<Property name="text" type="java.lang.String" value="Start time:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtStartTime">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="jTextField1"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lablEndTime">
<Properties>
<Property name="text" type="java.lang.String" value="End time:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtEndTime">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="jTextField2"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnCloseWindow">
<Properties>
<Property name="text" type="java.lang.String" value="Close Window"/>
<Property name="horizontalAlignment" type="int" value="4"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCloseWindowActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Container class="javax.swing.JSplitPane" name="jSplitPane2">
<Properties>
<Property name="resizeWeight" type="double" value="1.0"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="tableMatches">
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="matchesModel" type="code"/>
</Property>
<Property name="dividerLocation" type="int" value="230"/>
<Property name="orientation" type="int" value="0"/>
<Property name="resizeWeight" type="double" value="0.5"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Properties>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Standardcursor"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 100]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="top"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="tablePlayers">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="this.playersModel" type="code"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[400, 100]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="bottom"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="tableMatches">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="matchesModel" type="code"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="mage.client.chat.ChatPanel" name="chatPanel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>

View file

@ -36,14 +36,17 @@ package mage.client.tournament;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javafx.scene.layout.Pane;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import mage.client.MageFrame;
import mage.client.MagePane;
import mage.client.chat.ChatPanel;
import mage.client.util.ButtonColumn;
import mage.remote.Session;
@ -66,6 +69,8 @@ public class TournamentPanel extends javax.swing.JPanel {
private TournamentPlayersTableModel playersModel;
private TournamentMatchesTableModel matchesModel;
private UpdateTournamentTask updateTask;
private boolean titleSet = false;
private DateFormat df;
/** Creates new form TournamentPanel */
public TournamentPanel() {
@ -74,6 +79,8 @@ public class TournamentPanel extends javax.swing.JPanel {
initComponents();
df = DateFormat.getDateTimeInstance();
tablePlayers.createDefaultColumnsFromModel();
tableMatches.createDefaultColumnsFromModel();
@ -95,6 +102,7 @@ public class TournamentPanel extends javax.swing.JPanel {
}
};
// replay button, don't delete this
ButtonColumn buttonColumn = new ButtonColumn(tableMatches, action, 6);
}
@ -128,6 +136,31 @@ public class TournamentPanel extends javax.swing.JPanel {
}
public void update(TournamentView tournament) {
if (!titleSet) {
Component c = this.getParent();
while (c != null && !(c instanceof TournamentPane)) {
c = c.getParent();
}
if (c != null) {
((TournamentPane)c).setTitle("Tournament [" + tournament.getTournamentName() +"]");
}
titleSet = true;
}
txtName.setText(tournament.getTournamentName());
txtType.setText(tournament.getTournamentType());
txtStartTime.setText(df.format(tournament.getStartTime()));
if (tournament.getEndTime() != null) {
txtEndTime.setText(df.format(tournament.getEndTime()));
btnCloseWindow.setVisible(true);
} else {
txtEndTime.setText("running...");
btnCloseWindow.setVisible(false);
}
playersModel.loadData(tournament);
matchesModel.loadData(tournament);
this.tablePlayers.repaint();
@ -144,8 +177,9 @@ public class TournamentPanel extends javax.swing.JPanel {
}
public void stopTasks() {
if (updateTask != null)
if (updateTask != null) {
updateTask.cancel(true);
}
}
/** This method is called from within the constructor to
@ -157,46 +191,175 @@ public class TournamentPanel extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
chatPanel1 = new mage.client.chat.ChatPanel();
actionPanel = new javax.swing.JPanel();
lblName = new javax.swing.JLabel();
txtName = new javax.swing.JTextField();
lblType = new javax.swing.JLabel();
txtType = new javax.swing.JTextField();
lblStartTime = new javax.swing.JLabel();
txtStartTime = new javax.swing.JTextField();
lablEndTime = new javax.swing.JLabel();
txtEndTime = new javax.swing.JTextField();
btnCloseWindow = new javax.swing.JButton();
jSplitPane2 = new javax.swing.JSplitPane();
jSplitPane1 = new javax.swing.JSplitPane();
jScrollPane1 = new javax.swing.JScrollPane();
tablePlayers = new javax.swing.JTable();
jScrollPane2 = new javax.swing.JScrollPane();
tableMatches = new javax.swing.JTable();
chatPanel1 = new mage.client.chat.ChatPanel();
setPreferredSize(new java.awt.Dimension(908, 580));
lblName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lblName.setText("Name:");
txtName.setEditable(false);
txtName.setHorizontalAlignment(javax.swing.JTextField.LEFT);
txtName.setText("tournament name");
txtName.setFocusable(false);
txtName.setMaximumSize(new java.awt.Dimension(50, 22));
lblType.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lblType.setText("Type:");
txtType.setEditable(false);
txtType.setHorizontalAlignment(javax.swing.JTextField.LEFT);
txtType.setText("tournament type");
txtType.setFocusable(false);
lblStartTime.setText("Start time:");
txtStartTime.setEditable(false);
txtStartTime.setHorizontalAlignment(javax.swing.JTextField.CENTER);
txtStartTime.setText("jTextField1");
txtStartTime.setFocusable(false);
lablEndTime.setText("End time:");
txtEndTime.setEditable(false);
txtEndTime.setHorizontalAlignment(javax.swing.JTextField.CENTER);
txtEndTime.setText("jTextField2");
txtEndTime.setFocusable(false);
btnCloseWindow.setText("Close Window");
btnCloseWindow.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
btnCloseWindow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCloseWindowActionPerformed(evt);
}
});
javax.swing.GroupLayout actionPanelLayout = new javax.swing.GroupLayout(actionPanel);
actionPanel.setLayout(actionPanelLayout);
actionPanelLayout.setHorizontalGroup(
actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(actionPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblName)
.addComponent(lblType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
.addComponent(txtType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(actionPanelLayout.createSequentialGroup()
.addComponent(lablEndTime)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtEndTime))
.addGroup(actionPanelLayout.createSequentialGroup()
.addComponent(lblStartTime)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCloseWindow, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
actionPanelLayout.setVerticalGroup(
actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(actionPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblName, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblStartTime)
.addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblType)
.addComponent(txtType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lablEndTime)
.addComponent(txtEndTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnCloseWindow))
.addGap(0, 14, Short.MAX_VALUE))
);
jSplitPane2.setResizeWeight(1.0);
jSplitPane2.setToolTipText("");
jSplitPane1.setDividerLocation(230);
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane1.setResizeWeight(0.5);
jScrollPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 100));
tablePlayers.setModel(this.playersModel);
jScrollPane1.setViewportView(tablePlayers);
jSplitPane1.setTopComponent(jScrollPane1);
jScrollPane2.setPreferredSize(new java.awt.Dimension(400, 100));
tableMatches.setModel(matchesModel);
jScrollPane2.setViewportView(tableMatches);
jSplitPane1.setBottomComponent(jScrollPane2);
jSplitPane2.setLeftComponent(jSplitPane1);
jSplitPane2.setRightComponent(chatPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE))
.addGap(0, 0, 0)
.addComponent(chatPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(actionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSplitPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 908, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE))
.addComponent(chatPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(actionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void btnCloseWindowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseWindowActionPerformed
hideTournament();
}//GEN-LAST:event_btnCloseWindowActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel actionPanel;
private javax.swing.JButton btnCloseWindow;
private mage.client.chat.ChatPanel chatPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JSplitPane jSplitPane2;
private javax.swing.JLabel lablEndTime;
private javax.swing.JLabel lblName;
private javax.swing.JLabel lblStartTime;
private javax.swing.JLabel lblType;
private javax.swing.JTable tableMatches;
private javax.swing.JTable tablePlayers;
private javax.swing.JTextField txtEndTime;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtStartTime;
private javax.swing.JTextField txtType;
// End of variables declaration//GEN-END:variables
}
@ -237,8 +400,9 @@ class TournamentPlayersTableModel extends AbstractTableModel {
public String getColumnName(int columnIndex) {
String colName = "";
if (columnIndex <= getColumnCount())
if (columnIndex <= getColumnCount()) {
colName = columnNames[columnIndex];
}
return colName;
}
@ -308,8 +472,9 @@ class TournamentMatchesTableModel extends AbstractTableModel {
public String getColumnName(int columnIndex) {
String colName = "";
if (columnIndex <= getColumnCount())
if (columnIndex <= getColumnCount()) {
colName = columnNames[columnIndex];
}
return colName;
}
@ -321,8 +486,9 @@ class TournamentMatchesTableModel extends AbstractTableModel {
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
if (columnIndex != 6)
if (columnIndex != 6) {
return false;
}
return true;
}

View file

@ -1,12 +1,15 @@
package mage.client.util;
import java.io.File;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import org.apache.log4j.Logger;
import javax.sound.sampled.*;
import java.io.File;
/**
* Manager class for playing audio files.
*
@ -42,6 +45,8 @@ public class AudioManager {
audioManager.addArtifactClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAddArtifact.wav");
audioManager.updateStackClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnStackNew.wav");
audioManager.onHover = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnHover.wav");
audioManager.playerJoinedTable = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerJoinedTable.wav");
}
return audioManager;
}
@ -114,6 +119,10 @@ public class AudioManager {
checkAndPlayClip(getManager().onHover);
}
public static void playPlayerJoinedTable() {
checkAndPlayClip(getManager().playerJoinedTable);
}
private static void checkAndPlayClip(Clip clip) {
try {
if (clip != null) {
@ -175,4 +184,6 @@ public class AudioManager {
private Clip addArtifactClip = null;
private Clip updateStackClip = null;
private Clip onHover = null;
private Clip playerJoinedTable = null;
}

View file

@ -65,6 +65,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
public final ScaledImagePanel imagePanel;
public ImagePanel overlayPanel;
public JPanel buttonPanel;
public JPanel iconPanel;
private GlowText titleText;
private GlowText ptText;
@ -94,6 +95,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private boolean transformed;
private boolean animationInProgress = false;
private JButton dayNightButton;
private JButton tokenButton;
private boolean displayTitleAnyway;
@ -142,6 +144,23 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}
});
// token icon
iconPanel = new JPanel();
iconPanel.setLayout(null);
iconPanel.setOpaque(false);
add(iconPanel);
tokenButton = new JButton("");
tokenButton.setLocation(2, 2);
tokenButton.setSize(25, 25);
iconPanel.setVisible(this.gameCard.isToken());
BufferedImage tokenIconImage = ImageManagerImpl.getInstance().getTokenIconImage();
tokenButton.setIcon(new ImageIcon(tokenIconImage));
iconPanel.add(tokenButton);
setBackground(Color.black);
setOpaque(false);
@ -411,6 +430,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
buttonPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
buttonPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
iconPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
iconPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
int fontHeight = Math.round(cardHeight * (27f / 680));
boolean showText = (!isAnimationPanel && fontHeight < 12);
titleText.setVisible(showText);

View file

@ -154,12 +154,15 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
} else if (CardUtil.isPlaneswalker(card)) {
pt = card.getLoyalty().toString();
}
if (pt.length() > 0) {
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%' valign='bottom'><tr><td>");
buffer.append("<b>");
buffer.append(pt);
buffer.append("</b>");
buffer.append("</td></tr></table>");
if (pt.length() > 0 || card.isToken()) {
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%' valign='bottom'><tr><td><b>");
buffer.append(pt).append("</b></td>");
if (card.isToken()) {
buffer.append("<td align='right'>Token</td>");
}
buffer.append("</tr></table>");
}
StringBuilder rule = new StringBuilder("<br/>");

View file

@ -11,6 +11,8 @@ public interface ImageManager {
Image getSicknessImage();
Image getDayImage();
Image getNightImage();
Image getTokenIconImage();
Image getDlgAcceptButtonImage();
Image getDlgActiveAcceptButtonImage();

View file

@ -97,6 +97,15 @@ public class ImageManagerImpl implements ImageManager {
return imageNight;
}
@Override
public BufferedImage getTokenIconImage() {
if (imageTokenIcon == null) {
Image image = getImageFromResourceTransparent("/card/token.png", Color.WHITE, new Rectangle(20, 20));
imageTokenIcon = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
}
return imageTokenIcon;
}
@Override
public Image getDlgCancelButtonImage() {
if (imageDlgCancelButton == null) {
@ -216,6 +225,8 @@ public class ImageManagerImpl implements ImageManager {
private static BufferedImage imageDay;
private static BufferedImage imageNight;
private static BufferedImage imageTokenIcon;
private static BufferedImage imageDlgAcceptButton;
private static BufferedImage imageDlgActiveAcceptButton;
private static BufferedImage imageDlgCancelButton;

View file

@ -78,25 +78,12 @@ public class ThemePluginImpl implements ThemePlugin {
background = loadbuffer_default();
}
/*
if(loadimages()){
int it = (int)Math.abs(Math.random()*(flist.getItemCount()));
filename = BackgroundDir + flist.getItem(it);
background = ImageIO.read(new File(filename));
}else{
filename = "/dragon.png";
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null)
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
background = ImageIO.read(is);
if (background == null) {
background = loadbuffer_default();
}
if (background == null){
throw new FileNotFoundException("Couldn't find in resources.");
}
*/
if (background == null) {
throw new FileNotFoundException("Couldn't find background file in resources.");
}
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
@ -143,9 +130,13 @@ public class ThemePluginImpl implements ThemePlugin {
BufferedImage res;
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
KEY_BATTLEFIELD_IMAGE, "");
if(path != null){
res = ImageIO.read(new File(path));
return res;
if(path != null && !path.equals("")){
try{
res = ImageIO.read(new File(path));
return res;
}catch(Exception e){
res = null;
}
}
return null;
}
@ -176,23 +167,28 @@ public class ThemePluginImpl implements ThemePlugin {
if (is == null)
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
background = ImageIO.read(is);
}else if(PreferencesDialog.getCachedValue(PreferencesDialog.
KEY_BACKGROUND_IMAGE, "") != null){
}else{
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
KEY_BATTLEFIELD_IMAGE, "");
if(path != null){
background = ImageIO.read(new File(path));
}else{
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null)
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
background = ImageIO.read(is);
}
KEY_BACKGROUND_IMAGE, "");
if(path != null && !path.equals("")){
try{
File f = new File(path);
if(f != null)
background = ImageIO.read(f);
}catch(Exception e){
background = null;
}
}
}
if (background == null)
if (background == null){
InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null)
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
} catch (Exception e) {
background = ImageIO.read(is);
}
if(background == null) throw new
FileNotFoundException("Couldn't find " + filename + " in resources.");
}catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}