mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
added Windows button to toolbar
This commit is contained in:
parent
6e7576abe7
commit
812d1bc9c3
12 changed files with 152 additions and 115 deletions
|
|
@ -55,11 +55,16 @@ import javax.imageio.ImageIO;
|
|||
import javax.swing.*;
|
||||
import javax.swing.JToolBar.Separator;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
|
@ -67,6 +72,8 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import mage.client.draft.DraftPane;
|
||||
|
||||
/**
|
||||
|
|
@ -104,7 +111,7 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
*/
|
||||
public MageFrame() {
|
||||
|
||||
setTitle("Mage, version 0.5.1");
|
||||
setTitle("Mage, version 0.6");
|
||||
|
||||
EDTExceptionHandler.registerExceptionHandler();
|
||||
addWindowListener(new WindowAdapter() {
|
||||
|
|
@ -148,7 +155,7 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
addTooltipContainer();
|
||||
addTooltipContainer();
|
||||
setBackground();
|
||||
addMageLabel();
|
||||
setAppIcon();
|
||||
|
|
@ -175,6 +182,9 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
}
|
||||
});
|
||||
|
||||
mageToolbar.add(new javax.swing.JToolBar.Separator());
|
||||
mageToolbar.add(createWindowsButton());
|
||||
|
||||
//TODO: move to plugin impl
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
Separator separator = new javax.swing.JToolBar.Separator();
|
||||
|
|
@ -303,6 +313,63 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
}
|
||||
}
|
||||
|
||||
private AbstractButton createWindowsButton() {
|
||||
final JToggleButton windowButton = new JToggleButton("Windows");
|
||||
windowButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
createAndShowMenu((JComponent) e.getSource(), windowButton);
|
||||
}
|
||||
}
|
||||
});
|
||||
windowButton.setFocusable(false);
|
||||
windowButton.setHorizontalTextPosition(SwingConstants.LEADING);
|
||||
return windowButton;
|
||||
}
|
||||
|
||||
private void createAndShowMenu(final JComponent component, final AbstractButton windowButton) {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
MagePaneMenuItem menuItem;
|
||||
|
||||
for (int i = 0; i < windows.length; i++) {
|
||||
JInternalFrame window = windows[i];
|
||||
if (window.isVisible()) {
|
||||
menuItem = new MagePaneMenuItem(window);
|
||||
menuItem.setState(i == 0);
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
JInternalFrame frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
|
||||
frame.toFront();
|
||||
frame.setVisible(true);
|
||||
//frame.moveToFront();
|
||||
try {
|
||||
frame.setSelected(true);
|
||||
} catch (PropertyVetoException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
menuItem.setIcon(window.getFrameIcon());
|
||||
menu.add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
menu.addPopupMenuListener(new PopupMenuListener() {
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { }
|
||||
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
windowButton.setSelected(false);
|
||||
}
|
||||
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
windowButton.setSelected(false);
|
||||
}
|
||||
});
|
||||
|
||||
menu.show(component, 0, component.getHeight());
|
||||
}
|
||||
|
||||
private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
HashSet<Card> cards = new HashSet<Card>(CardsStorage.getAllCards());
|
||||
List<Card> notImplemented = CardsStorage.getNotImplementedCards();
|
||||
|
|
@ -317,38 +384,30 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
}
|
||||
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
this.tablesPane.hideTables();
|
||||
this.tablesPane.setVisible(false);
|
||||
this.draftPane.setVisible(false);
|
||||
this.gamePane.setVisible(true);
|
||||
this.gamePane.toFront();
|
||||
this.gamePane.showGame(gameId, playerId);
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
this.tablesPane.hideTables();
|
||||
this.tablesPane.setVisible(false);
|
||||
this.draftPane.setVisible(false);
|
||||
this.gamePane.setVisible(true);
|
||||
this.gamePane.toFront();
|
||||
this.gamePane.watchGame(gameId);
|
||||
}
|
||||
|
||||
public void replayGame() {
|
||||
this.tablesPane.hideTables();
|
||||
this.tablesPane.setVisible(false);
|
||||
this.draftPane.setVisible(false);
|
||||
this.gamePane.setVisible(true);
|
||||
this.gamePane.toFront();
|
||||
this.gamePane.replayGame();
|
||||
}
|
||||
|
||||
public void showDraft(UUID draftId) {
|
||||
this.tablesPane.hideTables();
|
||||
this.tablesPane.setVisible(false);
|
||||
this.gamePane.setVisible(false);
|
||||
this.draftPane.setVisible(true);
|
||||
this.draftPane.toFront();
|
||||
this.draftPane.showDraft(draftId);
|
||||
}
|
||||
|
||||
public static boolean connect(String userName, String serverName, int port) {
|
||||
public static boolean connect(String userName, String serverName, int port) {
|
||||
return session.connect(userName, serverName, port);
|
||||
}
|
||||
|
||||
|
|
@ -551,17 +610,10 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed
|
||||
this.gamePane.setVisible(false);
|
||||
this.tablesPane.setVisible(false);
|
||||
this.draftPane.setVisible(false);
|
||||
this.collectionViewerPane.setVisible(false);
|
||||
showDeckEditor(DeckEditorMode.Constructed, null, null);
|
||||
}//GEN-LAST:event_btnDeckEditorActionPerformed
|
||||
|
||||
private void btnCollectionViewerActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
this.gamePane.setVisible(false);
|
||||
this.tablesPane.setVisible(false);
|
||||
this.deckEditorPane.setVisible(false);
|
||||
showCollectionViewer();
|
||||
}
|
||||
|
||||
|
|
@ -570,9 +622,6 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
}
|
||||
|
||||
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
||||
this.gamePane.setVisible(false);
|
||||
this.deckEditorPane.setVisible(false);
|
||||
this.collectionViewerPane.setVisible(false);
|
||||
this.tablesPane.setVisible(true);
|
||||
this.tablesPane.showTables();
|
||||
}//GEN-LAST:event_btnGamesActionPerformed
|
||||
|
|
@ -616,20 +665,17 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
btnConnect.setText("Connect");
|
||||
btnGames.setEnabled(false);
|
||||
btnDeckEditor.setEnabled(true);
|
||||
this.tablesPane.setVisible(false);
|
||||
this.gamePane.setVisible(false);
|
||||
this.deckEditorPane.setVisible(false);
|
||||
this.draftPane.setVisible(false);
|
||||
this.collectionViewerPane.setVisible(false);
|
||||
}
|
||||
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) {
|
||||
this.deckEditorPane.setVisible(true);
|
||||
this.deckEditorPane.toFront();
|
||||
this.deckEditorPane.show(mode, deck, tableId);
|
||||
}
|
||||
|
||||
public void showCollectionViewer() {
|
||||
this.collectionViewerPane.setVisible(true);
|
||||
this.collectionViewerPane.toFront();
|
||||
}
|
||||
|
||||
public static CombatDialog getCombatDialog() {
|
||||
|
|
@ -704,3 +750,16 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
this.lblStatus.setText(status);
|
||||
}
|
||||
}
|
||||
|
||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||
private JInternalFrame frame;
|
||||
|
||||
public MagePaneMenuItem(JInternalFrame frame) {
|
||||
super(frame.getTitle());
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
public JInternalFrame getFrame() {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,10 @@ public class DeckEditorPane extends MagePane {
|
|||
}
|
||||
|
||||
public void show(DeckEditorMode mode, Deck deck, UUID tableId) {
|
||||
if (deck != null)
|
||||
this.setTitle("Deck Editor - " + deck.getName());
|
||||
else
|
||||
this.setTitle("Deck Editor");
|
||||
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId);
|
||||
this.repaint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import java.util.ArrayList;
|
|||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.client.MagePane;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.constants.Constants.DeckEditorMode;
|
||||
import mage.client.dialog.AddLandDialog;
|
||||
|
|
@ -409,7 +410,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}//GEN-LAST:event_btnNewActionPerformed
|
||||
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
||||
this.setVisible(false);
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof DeckEditorPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}//GEN-LAST:event_btnExitActionPerformed
|
||||
|
||||
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public class CollectionViewerPane extends MagePane {
|
|||
|
||||
public CollectionViewerPane() {
|
||||
boolean initialized = false;
|
||||
this.setTitle("Collection Viewier");
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,11 @@ public class CollectionViewerPanel extends JPanel {
|
|||
jPanel1 = new javax.swing.JPanel();
|
||||
jPanel1.setOpaque(false);
|
||||
bigCard = new BigCard();
|
||||
BoxLayout boxlayout = new BoxLayout(jPanel1, BoxLayout.X_AXIS);
|
||||
BoxLayout boxlayout = new BoxLayout(jPanel1, BoxLayout.Y_AXIS);
|
||||
jPanel1.setLayout(boxlayout);
|
||||
btnExit = new javax.swing.JButton();
|
||||
jPanel1.add(btnExit);
|
||||
jPanel1.add(Box.createVerticalGlue());
|
||||
bigCard.setAlignmentY(Component.BOTTOM_ALIGNMENT);
|
||||
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
jPanel1.add(bigCard);
|
||||
|
|
@ -71,8 +74,25 @@ public class CollectionViewerPanel extends JPanel {
|
|||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
btnExit.setText("Exit");
|
||||
btnExit.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnExitActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof CollectionViewerPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}
|
||||
|
||||
private class MageBookContainer extends JPanel {
|
||||
public MageBookContainer() {
|
||||
super();
|
||||
|
|
@ -99,5 +119,6 @@ public class CollectionViewerPanel extends JPanel {
|
|||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private mage.client.cards.BigCard bigCard;
|
||||
private javax.swing.JButton btnExit;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="394" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="0" pref="868" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="282" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="0" pref="582" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public class DraftPane extends MagePane {
|
|||
}
|
||||
|
||||
public void showDraft(UUID draftId) {
|
||||
this.setTitle("Draft - " + draftId);
|
||||
this.draftPanel1.showDraft(draftId);
|
||||
}
|
||||
|
||||
|
|
@ -70,11 +71,11 @@ public class DraftPane extends MagePane {
|
|||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 868, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 582, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
|
|
|
|||
|
|
@ -153,9 +153,6 @@
|
|||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtPack1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtPack2">
|
||||
<Properties>
|
||||
|
|
@ -168,18 +165,12 @@
|
|||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtPack3ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtCardNo">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtCardNoActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkPack1">
|
||||
</Component>
|
||||
|
|
@ -200,9 +191,6 @@
|
|||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtTimeRemainingActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
package mage.client.draft;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.UUID;
|
||||
|
|
@ -120,7 +121,12 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void hideDraft() {
|
||||
this.setVisible(false);
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof DraftPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
|
@ -162,40 +168,20 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
|
||||
txtPack1.setEditable(false);
|
||||
txtPack1.setEnabled(false);
|
||||
txtPack1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
txtPack1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
txtPack2.setEditable(false);
|
||||
txtPack2.setEnabled(false);
|
||||
|
||||
txtPack3.setEditable(false);
|
||||
txtPack3.setEnabled(false);
|
||||
txtPack3.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
txtPack3ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
txtCardNo.setEditable(false);
|
||||
txtCardNo.setEnabled(false);
|
||||
txtCardNo.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
txtCardNoActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
txtTimeRemaining.setEditable(false);
|
||||
txtTimeRemaining.setForeground(java.awt.Color.red);
|
||||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
||||
txtTimeRemaining.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
txtTimeRemainingActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
|
|
@ -293,22 +279,6 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void txtPack1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPack1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_txtPack1ActionPerformed
|
||||
|
||||
private void txtPack3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPack3ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_txtPack3ActionPerformed
|
||||
|
||||
private void txtCardNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCardNoActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_txtCardNoActionPerformed
|
||||
|
||||
private void txtTimeRemainingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTimeRemainingActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_txtTimeRemainingActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private mage.client.cards.BigCard bigCard;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class GamePane extends MagePane {
|
|||
}
|
||||
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
this.setTitle("Game " + gameId);
|
||||
gamePanel.showGame(gameId, playerId);
|
||||
this.toFront();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public class TablesPane extends MagePane {
|
|||
public void showTables() {
|
||||
UUID roomId = MageFrame.getSession().getMainRoomId();
|
||||
if (roomId != null) {
|
||||
this.setTitle("Tables");
|
||||
tablesPanel.showTables(roomId);
|
||||
this.repaint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@
|
|||
package mage.client.table;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Observable;
|
||||
|
|
@ -64,6 +66,7 @@ import mage.client.remote.Session;
|
|||
import mage.client.util.ButtonColumn;
|
||||
import mage.game.draft.DraftOptions;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.sets.Sets;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TableView;
|
||||
|
|
@ -143,7 +146,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
@Override
|
||||
public void update(Observable arg0, Object arg1) {
|
||||
try {
|
||||
tableModel.loadData(roomId);
|
||||
tableModel.loadData(MageFrame.getSession().getTables(roomId));
|
||||
this.tableTables.repaint();
|
||||
} catch (MageRemoteException ex) {
|
||||
hideTables();
|
||||
|
|
@ -171,7 +174,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
}
|
||||
UUID chatRoomId = session.getRoomChatId(roomId);
|
||||
if (chatRoomId != null) {
|
||||
this.chatPanel.connect(session.getRoomChatId(roomId));
|
||||
this.chatPanel.connect(chatRoomId);
|
||||
tablesWatchdog.addObserver(this);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
|
|
@ -189,7 +192,13 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
}
|
||||
tablesWatchdog.deleteObservers();
|
||||
this.chatPanel.disconnect();
|
||||
this.setVisible(false);
|
||||
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof TablesPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
|
@ -320,31 +329,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
}//GEN-LAST:event_btnQuickStartActionPerformed
|
||||
|
||||
private void btnNewDraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewDraftActionPerformed
|
||||
DraftOptions options = new DraftOptions("testDraft");
|
||||
options.setDraftType("8 Player Booster");
|
||||
options.setTiming(DraftOptions.TimingOption.REGULAR);
|
||||
options.getPlayerTypes().add("Human");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getPlayerTypes().add("Computer - default");
|
||||
options.getSets().add(Sets.findSet("M11"));
|
||||
options.getSets().add(Sets.findSet("M11"));
|
||||
options.getSets().add(Sets.findSet("M11"));
|
||||
TableView table = session.createDraftTable(roomId, options);
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Human");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 1");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 2");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 3");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 4");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 5");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 6");
|
||||
session.joinDraftTable(roomId, table.getTableId(), "Computer 7");
|
||||
hideTables();
|
||||
session.startDraft(roomId, table.getTableId());
|
||||
|
||||
}//GEN-LAST:event_btnNewDraftActionPerformed
|
||||
|
||||
private void handleError(Exception ex) {
|
||||
|
|
@ -371,8 +356,8 @@ class TableTableModel extends AbstractTableModel {
|
|||
private TableView[] tables = new TableView[0];
|
||||
|
||||
|
||||
public void loadData(UUID roomId) throws MageRemoteException {
|
||||
tables = MageFrame.getSession().getTables(roomId).toArray(new TableView[0]);
|
||||
public void loadData(Collection<TableView> tables) throws MageRemoteException {
|
||||
this.tables = tables.toArray(new TableView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue