Added possibility to show tournament panel and watch tournament games (if allowed at tournament start) for spectators .

This commit is contained in:
LevelX2 2013-07-16 17:39:02 +02:00
parent 001f8ec1e6
commit 9838dea551
24 changed files with 520 additions and 311 deletions

View file

@ -594,6 +594,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void showTournament(UUID tournamentId) {
try {
for(Component component :desktopPane.getComponents()) {
if (component instanceof TournamentPane &&
((TournamentPane) component).getTournamentId().equals(tournamentId)) {
setActive((TournamentPane) component);
return;
}
}
TournamentPane tournamentPane = new TournamentPane();
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
tournamentPane.setMaximum(true);

View file

@ -24,7 +24,17 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" 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"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="cbAllowSpectators" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
</Group>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
@ -33,49 +43,46 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<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="102" 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"/>
<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="205" 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" 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" min="-2" pref="295" max="-2" attributes="0"/>
</Group>
</Group>
<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 type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="lblConstructionTime" min="-2" pref="141" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="spnConstructTime" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="41" max="-2" attributes="0"/>
<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>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -106,19 +113,34 @@
<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="66" max="32767" attributes="0"/>
<Component id="pnlPacks" pref="67" 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="29" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="21" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="spnNumPlayers" pref="23" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
</Group>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="cbAllowSpectators" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
@ -201,6 +223,55 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumPlayersStateChanged"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="pnlDraftOptions">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbDraftTiming" min="-2" pref="107" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="cbDraftTiming" alignment="0" max="32767" attributes="1"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="Timing:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbDraftTiming">
<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>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="cbAllowSpectators">
<Properties>
<Property name="text" type="java.lang.String" value="Allow spectators"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnOk">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
@ -223,20 +294,15 @@
<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="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="483" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" max="32767" attributes="0"/>
</Group>
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -291,48 +357,5 @@
<Property name="text" type="java.lang.String" value="Packs"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="pnlDraftOptions">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbDraftTiming" min="-2" pref="107" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="cbDraftTiming" alignment="3" max="32767" attributes="1"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="Timing:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbDraftTiming">
<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>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -91,6 +91,7 @@ public class NewTournamentDialog extends MageDialog {
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
cbAllowSpectators.setSelected(true);
this.setModal(true);
setTournamentOptions();
this.setLocation(150, 100);
@ -121,6 +122,10 @@ public class NewTournamentDialog extends MageDialog {
pnlPacks = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
spnNumPlayers = new javax.swing.JSpinner();
pnlDraftOptions = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
cbDraftTiming = new javax.swing.JComboBox();
cbAllowSpectators = new javax.swing.JCheckBox();
btnOk = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
@ -129,9 +134,6 @@ public class NewTournamentDialog extends MageDialog {
txtPlayer1Name = new javax.swing.JTextField();
pnlOtherPlayers = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
pnlDraftOptions = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
cbDraftTiming = new javax.swing.JComboBox();
setTitle("New Tournament");
@ -170,6 +172,31 @@ public class NewTournamentDialog extends MageDialog {
}
});
jLabel6.setText("Timing:");
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions);
pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
pnlDraftOptionsLayout.setHorizontalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pnlDraftOptionsLayout.setVerticalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addComponent(jLabel6)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(cbDraftTiming)
);
cbAllowSpectators.setText("Allow spectators");
btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -198,16 +225,13 @@ public class NewTournamentDialog extends MageDialog {
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 483, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name)))
.addContainerGap())
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name))
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -224,79 +248,61 @@ public class NewTournamentDialog extends MageDialog {
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel5.setText("Packs");
jLabel6.setText("Timing:");
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions);
pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
pnlDraftOptionsLayout.setHorizontalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pnlDraftOptionsLayout.setVerticalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDraftTiming)
.addComponent(jLabel6))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.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(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(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)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cbAllowSpectators)
.addGap(9, 9, 9))
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 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.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))))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(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, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblConstructionTime, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.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))))
.addComponent(jLabel5))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
@ -321,18 +327,27 @@ public class NewTournamentDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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)
.addComponent(jPanel1, 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(btnOk)
.addComponent(btnCancel)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(14, 14, 14)))
.addComponent(jPanel1, 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(btnOk)
.addComponent(btnCancel)))
.addGroup(layout.createSequentialGroup()
.addComponent(cbAllowSpectators)
.addGap(0, 0, Short.MAX_VALUE))))
);
pack();
@ -347,6 +362,7 @@ public class NewTournamentDialog extends MageDialog {
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText());
tOptions.setTournamentType(tournamentType.getName());
tOptions.getPlayerTypes().add("Human");
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
for (TournamentPlayerPanel player: players) {
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
}
@ -364,7 +380,7 @@ public class NewTournamentDialog extends MageDialog {
for (JComboBox pack: packs) {
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
}
}
}
tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
tOptions.getMatchOptions().setDeckType("Limited");
tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
@ -520,6 +536,7 @@ public class NewTournamentDialog extends MageDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk;
private javax.swing.JCheckBox cbAllowSpectators;
private javax.swing.JComboBox cbDraftTiming;
private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JComboBox cbTournamentType;

View file

@ -28,6 +28,9 @@
package mage.client.remote;
import java.util.UUID;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import mage.Constants;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
@ -42,11 +45,16 @@ import mage.client.util.object.SaveObjectUtil;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.utils.CompressUtil;
import mage.view.*;
import mage.view.AbilityPickerView;
import mage.view.ChatMessage;
import mage.view.DeckView;
import mage.view.DraftClientMessage;
import mage.view.DraftView;
import mage.view.GameClientMessage;
import mage.view.GameView;
import mage.view.TableClientMessage;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.util.UUID;
/**
*
@ -93,12 +101,15 @@ public class CallbackClientImpl implements CallbackClient {
else if (callback.getMethod().equals("replayGame")) {
replayGame(callback.getObjectId());
}
else if (callback.getMethod().equals("showTournament")) {
showTournament((UUID) callback.getObjectId());
}
else if (callback.getMethod().equals("watchGame")) {
watchGame((UUID) callback.getObjectId());
}
else if (callback.getMethod().equals("chatMessage")) {
ChatMessage message = (ChatMessage) callback.getData();
ChatPanel panel = frame.getChat(callback.getObjectId());
ChatPanel panel = MageFrame.getChat(callback.getObjectId());
if (panel != null) {
if (message.getMessage().equals(Constants.MSG_TIP_HOT_KEYS_CODE) && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage("[Tips] ", "You may use hot keys to play faster: " + "" +
@ -128,29 +139,31 @@ public class CallbackClientImpl implements CallbackClient {
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
}
else if (callback.getMethod().equals("replayInit")) {
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
}
else if (callback.getMethod().equals("replayDone")) {
GamePanel panel = frame.getGame(callback.getObjectId());
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData());
}
}
else if (callback.getMethod().equals("replayUpdate")) {
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
}
else if (callback.getMethod().equals("gameInit")) {
GamePanel panel = frame.getGame(callback.getObjectId());
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
}
else if (callback.getMethod().equals("gameOver")) {
GamePanel panel = frame.getGame(callback.getObjectId());
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData());
}
@ -160,69 +173,80 @@ public class CallbackClientImpl implements CallbackClient {
}
else if (callback.getMethod().equals("gameAsk")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.ask(message.getMessage(), message.getGameView());
}
}
else if (callback.getMethod().equals("gameTarget")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
}
}
else if (callback.getMethod().equals("gameSelect")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.select(message.getMessage(), message.getGameView());
}
}
else if (callback.getMethod().equals("gameChooseAbility")) {
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickAbility((AbilityPickerView) callback.getData());
}
}
else if (callback.getMethod().equals("gameChoosePile")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
}
}
else if (callback.getMethod().equals("gameChoose")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.getChoice(message.getMessage(), message.getStrings());
}
}
else if (callback.getMethod().equals("gamePlayMana")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playMana(message.getMessage(), message.getGameView());
}
}
else if (callback.getMethod().equals("gamePlayXMana")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playXMana(message.getMessage(), message.getGameView());
}
}
else if (callback.getMethod().equals("gameSelectAmount")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
}
}
else if (callback.getMethod().equals("gameUpdate")) {
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
}
else if (callback.getMethod().equals("gameInform")) {
if (callback.getMessageId() > messageId) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.inform(message.getMessage(), message.getGameView());
}
}
else {
logger.warn("message out of sequence - ignoring");
@ -230,7 +254,7 @@ public class CallbackClientImpl implements CallbackClient {
}
else if (callback.getMethod().equals("gameInformPersonal")) {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = frame.getGame(callback.getObjectId());
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
JOptionPane.showMessageDialog(panel, message.getMessage(), "Game message",
JOptionPane.INFORMATION_MESSAGE);
@ -240,10 +264,12 @@ public class CallbackClientImpl implements CallbackClient {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
if (message.getFlag())
if (message.getFlag()) {
construct(deck, message.getTableId(), message.getTime());
else
}
else {
sideboard(deck, message.getTableId(), message.getTime());
}
}
else if (callback.getMethod().equals("construct")) {
TableClientMessage message = (TableClientMessage) callback.getData();
@ -252,20 +278,23 @@ public class CallbackClientImpl implements CallbackClient {
construct(deck, message.getTableId(), message.getTime());
}
else if (callback.getMethod().equals("draftOver")) {
DraftPanel panel = frame.getDraft(callback.getObjectId());
if (panel != null)
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.hideDraft();
}
}
else if (callback.getMethod().equals("draftPick")) {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = frame.getDraft(callback.getObjectId());
if (panel != null)
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
}
}
else if (callback.getMethod().equals("draftUpdate")) {
DraftPanel panel = frame.getDraft(callback.getObjectId());
if (panel != null)
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.updateDraft((DraftView) callback.getData());
}
}
else if (callback.getMethod().equals("draftInform")) {
if (callback.getMessageId() > messageId) {
@ -277,9 +306,10 @@ public class CallbackClientImpl implements CallbackClient {
}
else if (callback.getMethod().equals("draftInit")) {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = frame.getDraft(callback.getObjectId());
if (panel != null)
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
}
}
else if (callback.getMethod().equals("tournamentInit")) {
@ -340,6 +370,21 @@ public class CallbackClientImpl implements CallbackClient {
}
}
/**
* Shows the tournament info panel for a tournament
*
* @param tournamentId
*/
protected void showTournament(UUID tournamentId) {
try {
frame.showTournament(tournamentId);
logger.info("Showing tournament " + tournamentId);
}
catch (Exception ex) {
handleException(ex);
}
}
protected void watchGame(UUID gameId) {
try {
frame.watchGame(gameId);
@ -349,7 +394,6 @@ public class CallbackClientImpl implements CallbackClient {
handleException(ex);
}
}
protected void replayGame(UUID gameId) {
try {
frame.replayGame(gameId);

View file

@ -59,6 +59,7 @@ import mage.client.dialog.TableWaitingDialog;
import mage.client.util.ButtonColumn;
import mage.client.util.gui.GuiDisplayUtil;
import mage.constants.MatchTimeLimit;
import static mage.constants.TableState.DUELING;
import mage.game.match.MatchOptions;
import mage.remote.MageRemoteException;
import mage.remote.Session;
@ -123,11 +124,11 @@ public class TablesPanel extends javax.swing.JPanel {
int modelRow = Integer.valueOf( e.getActionCommand() );
UUID tableId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3);
UUID gameId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
String state = (String)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
String action = (String)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1);
String owner = (String)tableModel.getValueAt(modelRow, 1);
if (state.equals("Join")) {
if (action.equals("Join")) {
if (owner.equals(session.getUserName())) {
try {
JDesktopPane desktopPane = (JDesktopPane)MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
@ -158,16 +159,21 @@ public class TablesPanel extends javax.swing.JPanel {
logger.info("Joining table " + tableId);
joinTableDialog.showDialog(roomId, tableId);
}
} else if (state.equals("Remove")) {
} else if (action.equals("Remove")) {
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to remove table?", "Removing table", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
session.removeTable(roomId, tableId);
}
} else if (state.equals("Watch")) {
if (!isTournament) {
logger.info("Watching table " + tableId);
} else if (action.equals("Show")) {
if (isTournament) {
logger.info("Showing tournament table " + tableId);
session.watchTable(roomId, tableId);
}
} else if (state.equals("Replay")) {
} else if (action.equals("Watch")) {
if (!isTournament) {
logger.info("Watching table " + tableId);
session.watchTable(roomId, tableId);
}
} else if (action.equals("Replay")) {
logger.info("Replaying game " + gameId);
// no replay because of memory leaks
// session.replayGame(gameId);
@ -181,13 +187,17 @@ public class TablesPanel extends javax.swing.JPanel {
public void actionPerformed(ActionEvent e)
{
int modelRow = Integer.valueOf( e.getActionCommand() );
List<UUID> games = (List<UUID>)matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN);
if (games.size() == 1) {
session.replayGame(games.get(0));
}
else {
gameChooser.show(games, MageFrame.getDesktop().getMousePosition());
if (matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN) instanceof List) {
List<UUID> games = (List<UUID>)matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN);
if (games.size() == 1) {
session.replayGame(games.get(0));
}
else {
gameChooser.show(games, MageFrame.getDesktop().getMousePosition());
}
}
// MageFrame.getDesktop().showTournament(tournamentId);
}
};
@ -655,29 +665,27 @@ class TableTableModel extends AbstractTableModel {
return timeFormatter.format(tables[arg0].getCreateTime());
case 9:
switch (tables[arg0].getTableState()) {
case WAITING:
String owner = tables[arg0].getControllerName();
if (session != null && owner.equals(session.getUserName())) {
return "Remove";
}
return "Join";
case DUELING:
owner = tables[arg0].getControllerName();
if (session != null && owner.equals(session.getUserName())) {
return "Remove";
}
case CONSTRUCTING:
if (tables[arg0].isTournament()) {
return "None";
return "Show";
}
case DUELING:
if (tables[arg0].isTournament()) {
return "Show";
} else {
owner = tables[arg0].getControllerName();
if (session != null && owner.equals(session.getUserName())) {
return "Remove";
}
return "Watch";
}
case FINISHED:
owner = tables[arg0].getControllerName();
if (session != null && owner.equals(session.getUserName())) {
return "Remove";
}
return "None";
}
default:
return "";
}

View file

@ -58,6 +58,13 @@ public class TournamentPane extends MagePane {
tournamentPanel.hideTournament();
}
public UUID getTournamentId() {
if (this.tournamentPanel == null) {
return null;
}
return tournamentPanel.getTournamentId();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is

View file

@ -155,7 +155,7 @@
<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"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCloseWindowActionPerformed"/>

View file

@ -63,11 +63,11 @@ public class TournamentPanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(TournamentPanel.class);
private UUID tournamentId;
private boolean firstInitDone = false;
private Session session;
private TournamentPlayersTableModel playersModel;
private TournamentMatchesTableModel matchesModel;
private UpdateTournamentTask updateTask;
private boolean titleSet = false;
private DateFormat df;
/** Creates new form TournamentPanel */
@ -92,10 +92,15 @@ public class TournamentPanel extends javax.swing.JPanel {
int modelRow = Integer.valueOf( e.getActionCommand() );
UUID gameId = UUID.fromString((String)tableMatches.getValueAt(modelRow, 3));
String state = (String)tableMatches.getValueAt(modelRow, 4);
if (state.equals("Finished")) {
logger.info("Replaying game " + gameId);
session.replayGame(gameId);
String actionText = (String)tableMatches.getValueAt(modelRow, 6);
UUID tableId = UUID.fromString((String)matchesModel.getValueAt(modelRow, 7));
// if (state.equals("Finished") && action.equals("Replay")) {
// logger.info("Replaying game " + gameId);
// session.replayGame(gameId);
// }
if (state.equals("Dueling") && actionText.equals("Watch")) {
logger.info("Watching game " + gameId);
session.watchTournamentTable(tableId);
}
}
};
@ -121,6 +126,10 @@ public class TournamentPanel extends javax.swing.JPanel {
}
}
public UUID getTournamentId() {
return tournamentId;
}
public void hideTournament() {
stopTasks();
this.chatPanel1.disconnect();
@ -135,7 +144,7 @@ public class TournamentPanel extends javax.swing.JPanel {
public void update(TournamentView tournament) {
if (!titleSet) {
if (!firstInitDone) {
Component c = this.getParent();
while (c != null && !(c instanceof TournamentPane)) {
c = c.getParent();
@ -143,20 +152,17 @@ public class TournamentPanel extends javax.swing.JPanel {
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()));
txtEndTime.setText("running...");
firstInitDone = true;
}
txtName.setText(tournament.getTournamentName());
txtType.setText(tournament.getTournamentType());
txtStartTime.setText(df.format(tournament.getStartTime()));
if (tournament.getEndTime() != null) {
if (txtEndTime.getText().equals("running...") && tournament.getEndTime() != null) {
txtEndTime.setText(df.format(tournament.getEndTime()));
btnCloseWindow.setVisible(true);
} else {
txtEndTime.setText("running...");
btnCloseWindow.setVisible(false);
}
playersModel.loadData(tournament);
@ -241,7 +247,7 @@ public class TournamentPanel extends javax.swing.JPanel {
txtEndTime.setFocusable(false);
btnCloseWindow.setText("Close Window");
btnCloseWindow.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
btnCloseWindow.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnCloseWindow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCloseWindowActionPerformed(evt);
@ -331,7 +337,7 @@ public class TournamentPanel extends javax.swing.JPanel {
.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))
.addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 494, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@ -422,9 +428,11 @@ class TournamentPlayersTableModel extends AbstractTableModel {
class TournamentMatchesTableModel extends AbstractTableModel {
private String[] columnNames = new String[]{"Round Number", "Players", "Match Id", "Game Id", "State", "Result", "Action"};
private TournamentGameView[] games = new TournamentGameView[0];
private boolean watchingAllowed;
public void loadData(TournamentView tournament) {
List<TournamentGameView> views = new ArrayList<TournamentGameView>();
watchingAllowed = tournament.isWatchingAllowed();
for (RoundView round: tournament.getRounds()) {
for (TournamentGameView game: round.getGames()) {
views.add(game);
@ -460,10 +468,15 @@ class TournamentMatchesTableModel extends AbstractTableModel {
case 5:
return games[arg0].getResult();
case 6:
if (games[arg0].getState().equals("Finished")) {
return "Replay";
// if (games[arg0].getState().equals("Finished")) {
// return "Replay";
// }
if (watchingAllowed && games[arg0].getState().equals("Dueling")) {
return "Watch";
}
return "";
case 7:
return games[arg0].getTableId().toString();
}
return "";
}