mirror of
https://github.com/correl/mage.git
synced 2024-11-22 03:00:11 +00:00
...
This commit is contained in:
parent
de6a672d24
commit
14de10fd72
23 changed files with 498 additions and 501 deletions
25
Mage.Client/release/license.txt
Normal file
25
Mage.Client/release/license.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those of the
|
||||
authors and should not be interpreted as representing official policies, either expressed
|
||||
or implied, of BetaSteward_at_googlemail.com.
|
|
@ -8,6 +8,7 @@ You will need to have the Java Runtime Environment Version 6 Update 10 or greate
|
|||
You can download this from: http://java.com/
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
Installing and running MAGE
|
||||
|
||||
You will need to download both the client and the server applications. These can be
|
||||
obtained from http://code.google.com/p/magic--another-game-engine/downloads/list.
|
||||
|
@ -23,17 +24,34 @@ To launch the client run the startClient.bat command. Click on the connect butt
|
|||
the toolbar and enter the server name/IP address and port. Then click on the tables
|
||||
button. This will bring up a list of active and completed games. Click on join to
|
||||
join an existing game that hasn't started yet or you can create a new table by
|
||||
clicking the new button.
|
||||
clicking the New button.
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
Playing a game
|
||||
|
||||
The client useage should be fairly self evident. Click on cards in your hand to
|
||||
Playing a game should be fairly self evident. Your hand is displayed at the bottom
|
||||
of the screen. The battlefield is the central area. Click on cards in your hand to
|
||||
play them. Click on cards in the battlefield to activate abilities. A popup menu
|
||||
will be presented if you have more than one choice. To pass priority for the turn
|
||||
hold down the ctrl key while clicking done. You will still receive priority if
|
||||
your opponent casts a spell or activates an ability.
|
||||
your opponent casts a spell or activates an ability. Target cards by clicking on
|
||||
them. To target a player click on the player name. You can see the cards in any
|
||||
graveyard by clicking on the graveyard count.
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
Deck editor
|
||||
|
||||
A simple deck editor is available by clicking on the Deck Editor button on the
|
||||
toolbar. All the available cards are displayed in the top section. Your deck
|
||||
and sideboard are displayed at the bottom. To add a card to your deck double
|
||||
click on the card in the top section. To remove it from your deck double click
|
||||
on the card in the deck area. The sideboard section is not ready yet (don't
|
||||
worry it's coming soon).
|
||||
|
||||
You can save or load a deck using the Save or Load buttons.
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
Notes
|
||||
|
||||
MAGE is still very much in the testing phase so there can be lots of bugs and/or
|
||||
missing functionality. Please be patient. If you notice anything or want to
|
||||
|
|
|
@ -48,6 +48,7 @@ import mage.cards.decks.Deck;
|
|||
import mage.client.dialog.AboutDialog;
|
||||
import mage.client.dialog.ConnectDialog;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.EDTExceptionHandler;
|
||||
import mage.util.Logging;
|
||||
|
||||
/**
|
||||
|
@ -75,6 +76,7 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
/** Creates new form MageFrame */
|
||||
public MageFrame() {
|
||||
|
||||
EDTExceptionHandler.registerExceptionHandler();
|
||||
addWindowListener(new WindowAdapter()
|
||||
{
|
||||
@Override
|
||||
|
@ -100,7 +102,6 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
}
|
||||
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
logger.info("showing game");
|
||||
this.tablesPane.hideTables();
|
||||
this.tablesPane.setVisible(false);
|
||||
this.gamePane.setVisible(true);
|
||||
|
|
|
@ -166,24 +166,17 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou
|
|||
|
||||
private String getText(String cardType) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(card.getName());
|
||||
sb.append("\n");
|
||||
sb.append(card.getName()).append("\n");
|
||||
if (card.getManaCost().size() > 0) {
|
||||
sb.append(card.getManaCost());
|
||||
sb.append("\n");
|
||||
sb.append(card.getManaCost()).append("\n");
|
||||
}
|
||||
sb.append(cardType);
|
||||
sb.append("\n");
|
||||
sb.append(card.getColor().toString());
|
||||
sb.append("\n");
|
||||
sb.append(cardType).append("\n");
|
||||
sb.append(card.getColor().toString()).append("\n");
|
||||
for (String rule: card.getRules()) {
|
||||
sb.append(rule);
|
||||
sb.append("\n");
|
||||
sb.append(rule).append("\n");
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append(card.getPower());
|
||||
sb.append("/");
|
||||
sb.append(card.getToughness());
|
||||
sb.append(card.getPower()).append("/").append(card.getToughness());
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append(card.getLoyalty());
|
||||
|
@ -209,20 +202,17 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou
|
|||
StringBuilder sbType = new StringBuilder();
|
||||
|
||||
for (String superType: card.getSuperTypes()) {
|
||||
sbType.append(superType);
|
||||
sbType.append(" ");
|
||||
sbType.append(superType).append(" ");
|
||||
}
|
||||
|
||||
for (mage.Constants.CardType cardType: card.getCardTypes()) {
|
||||
sbType.append(cardType.toString());
|
||||
sbType.append(" ");
|
||||
sbType.append(cardType.toString()).append(" ");
|
||||
}
|
||||
|
||||
if (card.getSubTypes().size() > 0) {
|
||||
sbType.append("- ");
|
||||
for (String subType: card.getSubTypes()) {
|
||||
sbType.append(subType);
|
||||
sbType.append(" ");
|
||||
sbType.append(subType).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,60 +26,60 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.chat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JTextArea;
|
||||
import mage.interfaces.ChatClient;
|
||||
import mage.util.Logging;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChatClientImpl implements ChatClient, Serializable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(ChatClientImpl.class.getName());
|
||||
|
||||
private JTextArea textArea;
|
||||
private String userName;
|
||||
private UUID clientId;
|
||||
|
||||
public ChatClientImpl(String userName, JTextArea textArea) {
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.textArea = textArea;
|
||||
try {
|
||||
this.userName = userName;
|
||||
UnicastRemoteObject.exportObject(this, 0);
|
||||
} catch (RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveMessage(String message) throws RemoteException {
|
||||
this.textArea.append(message + "\n");
|
||||
textArea.setCaretPosition(textArea.getText().length() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() throws RemoteException {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() throws RemoteException {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public UUID getIdLocal() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
}
|
||||
//package mage.client.chat;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.rmi.RemoteException;
|
||||
//import java.rmi.server.UnicastRemoteObject;
|
||||
//import java.util.UUID;
|
||||
//import java.util.logging.Level;
|
||||
//import java.util.logging.Logger;
|
||||
//import javax.swing.JTextArea;
|
||||
//import mage.interfaces.ChatClient;
|
||||
//import mage.util.Logging;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author BetaSteward_at_googlemail.com
|
||||
// */
|
||||
//public class ChatClientImpl implements ChatClient, Serializable {
|
||||
//
|
||||
// private final static Logger logger = Logging.getLogger(ChatClientImpl.class.getName());
|
||||
//
|
||||
// private JTextArea textArea;
|
||||
// private String userName;
|
||||
// private UUID clientId;
|
||||
//
|
||||
// public ChatClientImpl(String userName, JTextArea textArea) {
|
||||
// this.clientId = UUID.randomUUID();
|
||||
// this.textArea = textArea;
|
||||
// try {
|
||||
// this.userName = userName;
|
||||
// UnicastRemoteObject.exportObject(this, 0);
|
||||
// } catch (RemoteException ex) {
|
||||
// logger.log(Level.SEVERE, null, ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void receiveMessage(String message) throws RemoteException {
|
||||
// this.textArea.append(message + "\n");
|
||||
// textArea.setCaretPosition(textArea.getText().length() - 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getName() throws RemoteException {
|
||||
// return userName;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public UUID getId() throws RemoteException {
|
||||
// return clientId;
|
||||
// }
|
||||
//
|
||||
// public UUID getIdLocal() {
|
||||
// return clientId;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -16,16 +16,16 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="179" max="32767" attributes="0"/>
|
||||
<Component id="txtMessage" alignment="1" pref="179" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="0" pref="179" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" pref="305" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="1"/>
|
||||
<Component id="txtMessage" min="-2" pref="20" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jScrollPane1" pref="300" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="txtMessage" min="-2" pref="25" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
|
@ -39,7 +39,6 @@ import java.util.UUID;
|
|||
import java.util.logging.Logger;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.remote.Session;
|
||||
import mage.interfaces.ChatClient;
|
||||
import mage.util.Logging;
|
||||
/**
|
||||
*
|
||||
|
@ -51,7 +50,6 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
|
||||
private UUID chatId;
|
||||
private UUID clientId;
|
||||
private ChatClient client;
|
||||
private Session session;
|
||||
|
||||
|
||||
|
@ -63,16 +61,18 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
public void connect(UUID chatId) {
|
||||
session = MageFrame.getSession();
|
||||
this.chatId = chatId;
|
||||
client = new ChatClientImpl(session.getUserName(), this.txtConversation);
|
||||
clientId = ((ChatClientImpl)client).getIdLocal();
|
||||
session.joinChat(chatId, client);
|
||||
session.joinChat(chatId, this);
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (session.isConnected())
|
||||
session.leaveChat(chatId, clientId);
|
||||
session.leaveChat(chatId);
|
||||
}
|
||||
|
||||
public void receiveMessage(String message) {
|
||||
this.txtConversation.append(message + "\n");
|
||||
txtConversation.setCaretPosition(txtConversation.getText().length() - 1);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -105,15 +105,15 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
|
||||
.addComponent(txtMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(txtMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(txtMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import mage.Constants.Zone;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
|
@ -91,7 +92,13 @@ public class CardSelector extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private void filterCards() {
|
||||
this.cardsList1.loadCards(new CardsView(cards.getCards(filter)), bigCard, null);
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
this.cardsList1.loadCards(new CardsView(cards.getCards(filter)), bigCard, null);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
public CardsList getCardsList() {
|
||||
|
|
|
@ -34,9 +34,8 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
@ -95,15 +94,20 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void refreshDeck() {
|
||||
this.txtDeckName.setText(deck.getName());
|
||||
deckArea.getDeckList().loadCards(new CardsView(deck.getCards()), bigCard, null);
|
||||
deckArea.getSideboardList().loadCards(new CardsView(deck.getSideboard()), bigCard, null);
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
this.txtDeckName.setText(deck.getName());
|
||||
deckArea.getDeckList().loadCards(new CardsView(deck.getCards()), bigCard, null);
|
||||
deckArea.getSideboardList().loadCards(new CardsView(deck.getSideboard()), bigCard, null);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
private Card createCard(Class clazz) {
|
||||
|
@ -236,10 +240,14 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
deck = Deck.load(DeckCardLists.load(file.getPath()));
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(DeckEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
refreshDeck();
|
||||
}
|
||||
fcSelectDeck.setSelectedFile(null);
|
||||
|
@ -251,10 +259,14 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
deck.getDeckCardLists().save(file.getPath());
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(DeckEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnSaveActionPerformed
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
|
@ -23,7 +20,7 @@
|
|||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace pref="154" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="159" max="32767" attributes="0"/>
|
||||
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -32,17 +29,17 @@
|
|||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblVersion" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="104" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="109" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="23" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="70" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="75" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -58,7 +55,7 @@
|
|||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="15" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="19" max="32767" attributes="0"/>
|
||||
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -86,7 +83,7 @@
|
|||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Courtesy: ForgottenBeta@gmail.com"/>
|
||||
<Property name="text" type="java.lang.String" value="Courtesy: BetaSteward@googlemail.com"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
|
|
|
@ -66,8 +66,6 @@ public class AboutDialog extends MageDialog {
|
|||
jLabel2 = new javax.swing.JLabel();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
btnOk.setText("OK");
|
||||
btnOk.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
@ -79,7 +77,7 @@ public class AboutDialog extends MageDialog {
|
|||
|
||||
lblVersion.setText("version");
|
||||
|
||||
jLabel2.setText("Courtesy: ForgottenBeta@gmail.com");
|
||||
jLabel2.setText("Courtesy: BetaSteward@googlemail.com");
|
||||
|
||||
jLabel3.setText("Thanks: KLo, Cosmo & Fritz");
|
||||
|
||||
|
@ -88,7 +86,7 @@ public class AboutDialog extends MageDialog {
|
|||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(154, Short.MAX_VALUE)
|
||||
.addContainerGap(159, Short.MAX_VALUE)
|
||||
.addComponent(btnOk)
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
|
@ -96,15 +94,15 @@ public class AboutDialog extends MageDialog {
|
|||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblVersion)
|
||||
.addContainerGap(104, Short.MAX_VALUE))
|
||||
.addContainerGap(109, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2)
|
||||
.addContainerGap(23, Short.MAX_VALUE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel3)
|
||||
.addContainerGap(70, Short.MAX_VALUE))
|
||||
.addContainerGap(75, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
@ -117,7 +115,7 @@ public class AboutDialog extends MageDialog {
|
|||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel3)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
|
||||
.addComponent(btnOk)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<Component id="txtUserName" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblUserName" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="39" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="43" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnConnect" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
@ -101,9 +101,6 @@
|
|||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtUserName">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="me"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblUserName">
|
||||
<Properties>
|
||||
|
|
|
@ -34,10 +34,12 @@
|
|||
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JOptionPane;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Config;
|
||||
|
@ -51,16 +53,19 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
private final static Logger logger = Logging.getLogger(ConnectDialog.class.getName());
|
||||
private Session session;
|
||||
private Preferences prefs;
|
||||
|
||||
/** Creates new form ConnectDialog */
|
||||
public ConnectDialog(Session session) {
|
||||
this.session = session;
|
||||
prefs = Preferences.userNodeForPackage(this.getClass());
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
this.txtServer.setText(Config.serverName);
|
||||
this.txtPort.setText(Integer.toString(Config.port));
|
||||
this.txtServer.setText(prefs.get("serverAddress", Config.serverName));
|
||||
this.txtPort.setText(prefs.get("serverPort", Integer.toString(Config.port)));
|
||||
this.txtUserName.setText(prefs.get("userName", ""));
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
@ -95,8 +100,6 @@ public class ConnectDialog extends MageDialog {
|
|||
}
|
||||
});
|
||||
|
||||
txtUserName.setText("me");
|
||||
|
||||
lblUserName.setLabelFor(txtUserName);
|
||||
lblUserName.setText("User Name:");
|
||||
|
||||
|
@ -154,7 +157,7 @@ public class ConnectDialog extends MageDialog {
|
|||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblUserName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCancel)
|
||||
.addComponent(btnConnect))
|
||||
|
@ -171,15 +174,41 @@ public class ConnectDialog extends MageDialog {
|
|||
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||
|
||||
try {
|
||||
if (txtUserName.getText().isEmpty()) {
|
||||
JOptionPane.showMessageDialog(rootPane, "Please provide a user name");
|
||||
return;
|
||||
}
|
||||
if (txtServer.getText().isEmpty()) {
|
||||
JOptionPane.showMessageDialog(rootPane, "Please provide a server address");
|
||||
return;
|
||||
}
|
||||
if (txtPort.getText().isEmpty()) {
|
||||
JOptionPane.showMessageDialog(rootPane, "Please provide a port number");
|
||||
return;
|
||||
}
|
||||
if (Integer.valueOf(txtPort.getText()) < 1 || Integer.valueOf(txtPort.getText()) > 65535 ) {
|
||||
JOptionPane.showMessageDialog(rootPane, "Invalid port number");
|
||||
txtPort.setText(prefs.get("serverPort", Integer.toString(Config.port)));
|
||||
return;
|
||||
}
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
session.connect(txtUserName.getText(), txtServer.getText(), Integer.valueOf(txtPort.getText()));
|
||||
prefs.put("serverAddress", txtServer.getText());
|
||||
prefs.put("serverPort", txtPort.getText());
|
||||
prefs.put("userName", txtUserName.getText());
|
||||
this.setVisible(false);
|
||||
} catch (RemoteException ex) {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
logger.log(Level.SEVERE, "Unable to connect to server", ex);
|
||||
JOptionPane.showMessageDialog(rootPane, "Unable to connect to server");
|
||||
} catch (NotBoundException ex) {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
logger.log(Level.SEVERE, "Unable to connect to server", ex);
|
||||
JOptionPane.showMessageDialog(rootPane, "Unable to connect to server");
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}//GEN-LAST:event_btnConnectActionPerformed
|
||||
|
||||
private void keyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_keyTyped
|
||||
|
|
|
@ -122,7 +122,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
} else if (source instanceof MenuComponent) {
|
||||
((MenuComponent) source).dispatchEvent(event);
|
||||
} else {
|
||||
logger.info("Unable to dispatch: " + event);
|
||||
logger.warning("Unable to dispatch: " + event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ import java.util.UUID;
|
|||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.remote.Session;
|
||||
import mage.view.AbilityPickerView;
|
||||
|
||||
|
@ -42,12 +45,13 @@ import mage.view.AbilityPickerView;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class AbilityPicker extends JPopupMenu {
|
||||
public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||
|
||||
private Session session;
|
||||
private UUID gameId;
|
||||
|
||||
public AbilityPicker() {
|
||||
this.addPopupMenuListener(this);
|
||||
}
|
||||
|
||||
public void init(Session session, UUID gameId) {
|
||||
|
@ -60,8 +64,19 @@ public class AbilityPicker extends JPopupMenu {
|
|||
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
this.setLocation(p);
|
||||
this.setVisible(true);
|
||||
// this.setLocation(p);
|
||||
this.show(MageFrame.getDesktop(), p.x, p.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { }
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { }
|
||||
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
|
||||
private class AbilityPickerAction extends AbstractAction {
|
||||
|
|
|
@ -145,7 +145,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
} else if (source instanceof MenuComponent) {
|
||||
((MenuComponent) source).dispatchEvent(event);
|
||||
} else {
|
||||
logger.info("Unable to dispatch: " + event);
|
||||
logger.warning("Unable to dispatch: " + event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,11 +51,7 @@ import mage.client.dialog.PickChoiceDialog;
|
|||
import mage.client.dialog.PickNumberDialog;
|
||||
import mage.client.dialog.ShowCardsDialog;
|
||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||
import mage.client.remote.GameClientImpl;
|
||||
import mage.client.remote.GameReplayClientImpl;
|
||||
import mage.client.remote.Session;
|
||||
import mage.interfaces.GameClient;
|
||||
import mage.interfaces.GameReplayClient;
|
||||
import mage.util.Logging;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.CardsView;
|
||||
|
@ -74,8 +70,6 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
private Map<UUID, PlayAreaPanel> players = new HashMap<UUID, PlayAreaPanel>();
|
||||
private Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
|
||||
private UUID gameId;
|
||||
private GameClient gameClient;
|
||||
private GameReplayClient replayClient;
|
||||
private Session session;
|
||||
private CombatDialog combat = new CombatDialog();
|
||||
|
||||
|
@ -87,7 +81,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
public void showGame(UUID gameId, UUID playerId) {
|
||||
this.gameId = gameId;
|
||||
session = MageFrame.getSession();
|
||||
gameClient = new GameClientImpl(this);
|
||||
session.setGame(this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
this.abilityPicker.init(session, gameId);
|
||||
|
@ -96,13 +90,14 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.btnStopWatching.setVisible(false);
|
||||
this.setVisible(true);
|
||||
this.chatPanel.connect(session.getGameChatId(gameId));
|
||||
if (!session.joinGame(gameId, gameClient))
|
||||
if (!session.joinGame(gameId))
|
||||
hideGame();
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
gameClient = new GameClientImpl(this);
|
||||
session = MageFrame.getSession();
|
||||
session.setGame(this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
this.btnConcede.setVisible(false);
|
||||
|
@ -110,19 +105,20 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.pnlReplay.setVisible(false);
|
||||
this.setVisible(true);
|
||||
this.chatPanel.connect(session.getGameChatId(gameId));
|
||||
if (!session.watchGame(gameId, gameClient))
|
||||
if (!session.watchGame(gameId))
|
||||
hideGame();
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
replayClient = new GameReplayClientImpl(this);
|
||||
session = MageFrame.getSession();
|
||||
session.setGame(this);
|
||||
this.feedbackPanel.clear();
|
||||
this.btnConcede.setVisible(false);
|
||||
this.btnStopWatching.setVisible(false);
|
||||
this.pnlReplay.setVisible(true);
|
||||
this.setVisible(true);
|
||||
if (!session.replayGame(gameId, replayClient))
|
||||
if (!session.replayGame())
|
||||
hideGame();
|
||||
}
|
||||
|
||||
|
@ -537,7 +533,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
private void btnStopWatchingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopWatchingActionPerformed
|
||||
if (modalQuestion("Are you sure you want to stop watching?", "Stop watching") == JOptionPane.YES_OPTION) {
|
||||
session.stopWatching(gameId, ((GameClientImpl)gameClient).getIdLocal());
|
||||
session.stopWatching(gameId);
|
||||
}
|
||||
}//GEN-LAST:event_btnStopWatchingActionPerformed
|
||||
|
||||
|
|
166
Mage.Client/src/mage/client/remote/Client.java
Normal file
166
Mage.Client/src/mage/client/remote/Client.java
Normal file
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.remote;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import mage.client.MageFrame;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.util.Logging;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Client implements CallbackClient {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(Client.class.getName());
|
||||
|
||||
private UUID clientId;
|
||||
private String userName;
|
||||
private MageFrame frame;
|
||||
private Session session;
|
||||
|
||||
public Client(Session session, MageFrame frame, String userName) {
|
||||
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.userName = userName;
|
||||
this.frame = frame;
|
||||
this.session = session;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCallback(ClientCallback callback) {
|
||||
if (callback.getMethod().equals("startGame")) {
|
||||
UUID[] data = (UUID[]) callback.getData();
|
||||
gameStarted(data[0], data[1]);
|
||||
}
|
||||
else if (callback.getMethod().equals("replayGame")) {
|
||||
replayGame((UUID) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("watchGame")) {
|
||||
watchGame((UUID) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("chatMessage")) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
session.getChats().get(message.getChatId()).receiveMessage(message.getMessage());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayInit")) {
|
||||
session.getGame().init((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayDone")) {
|
||||
session.getGame().modalMessage((String) callback.getData());
|
||||
session.getGame().hideGame();
|
||||
}
|
||||
else if (callback.getMethod().equals("replayUpdate")) {
|
||||
session.getGame().updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInit")) {
|
||||
session.getGame().init((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameUpdate")) {
|
||||
session.getGame().updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInform")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().inform(message.getMessage(), null, message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameOver")) {
|
||||
session.getGame().modalMessage((String) callback.getData());
|
||||
session.getGame().hideGame();
|
||||
}
|
||||
else if (callback.getMethod().equals("gameAsk")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().updateGame(message.getGameView());
|
||||
session.getGame().ask(message.getMessage());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameTarget")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
if (message.isFlag()) {
|
||||
session.getGame().inform(message.getMessage(), message.getCardsView(), message.getGameView());
|
||||
} else {
|
||||
session.getGame().cancel(message.getMessage(), message.getCardsView(), message.getGameView());
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelect")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().select(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChooseAbility")) {
|
||||
session.getGame().pickAbility((AbilityPickerView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChoose")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().getChoice(message.getMessage(), message.getStrings());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().playMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayXMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().playXMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelectAmount")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().getAmount(message.getMin(), message.getMax());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameReveal")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
session.getGame().revealCards(message.getMessage(), message.getCardsView());
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getId() throws RemoteException {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
protected void gameStarted(UUID gameId, UUID playerId) {
|
||||
frame.showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
}
|
||||
|
||||
protected void watchGame(UUID gameId) {
|
||||
frame.watchGame(gameId);
|
||||
logger.info("Watching game " + gameId);
|
||||
}
|
||||
|
||||
protected void replayGame(UUID gameId) {
|
||||
frame.replayGame(gameId);
|
||||
logger.info("Replaying game " + gameId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.remote;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.client.MageFrame;
|
||||
import mage.interfaces.Client;
|
||||
import mage.util.Logging;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ClientImpl implements Client, Serializable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(ClientImpl.class.getName());
|
||||
|
||||
private UUID clientId;
|
||||
private String userName;
|
||||
private MageFrame frame;
|
||||
|
||||
public ClientImpl(MageFrame frame, String userName) {
|
||||
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.userName = userName;
|
||||
this.frame = frame;
|
||||
try {
|
||||
UnicastRemoteObject.exportObject(this, 0);
|
||||
} catch (RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() throws RemoteException {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getPlayerId() throws RemoteException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gameStarted(UUID gameId, UUID playerId) throws RemoteException {
|
||||
frame.showGame(gameId, playerId);
|
||||
logger.info("Game client started for player " + playerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserName() throws RemoteException {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watchGame(UUID gameId) throws RemoteException {
|
||||
frame.watchGame(gameId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replayGame(UUID gameId) throws RemoteException {
|
||||
frame.replayGame(gameId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.remote;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.interfaces.GameClient;
|
||||
import mage.interfaces.MageException;
|
||||
import mage.util.Logging;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.GameView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GameClientImpl implements GameClient {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(GameClientImpl.class.getName());
|
||||
|
||||
private UUID gameClientId;
|
||||
private GamePanel gamePanel;
|
||||
|
||||
public GameClientImpl(GamePanel gamePanel) {
|
||||
gameClientId = UUID.randomUUID();
|
||||
this.gamePanel = gamePanel;
|
||||
try {
|
||||
UnicastRemoteObject.exportObject(this, 0);
|
||||
} catch (RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized UUID getId() throws RemoteException {
|
||||
return gameClientId;
|
||||
}
|
||||
|
||||
public UUID getIdLocal() {
|
||||
return gameClientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void update(GameView gameView) throws RemoteException {
|
||||
logger.info("Received update event for game");
|
||||
gamePanel.updateGame(gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init(GameView gameView) throws RemoteException {
|
||||
gamePanel.init(gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void ask(String question, GameView gameView) throws RemoteException {
|
||||
gamePanel.updateGame(gameView);
|
||||
gamePanel.ask(question);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void inform(String message, GameView gameView) throws RemoteException {
|
||||
gamePanel.inform(message, null, gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void target(String message, CardsView cardView, boolean required, GameView gameView) throws RemoteException {
|
||||
if (required) {
|
||||
gamePanel.inform(message, cardView, gameView);
|
||||
} else {
|
||||
gamePanel.cancel(message, cardView, gameView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void gameOver(String message) throws RemoteException {
|
||||
gamePanel.modalMessage(message);
|
||||
gamePanel.hideGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void select(String message, GameView gameView) throws RemoteException {
|
||||
gamePanel.select(message, gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void playMana(String message, GameView gameView) throws RemoteException {
|
||||
gamePanel.playMana(message, gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void playXMana(String message, GameView gameView) throws RemoteException {
|
||||
gamePanel.playXMana(message, gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void chooseAbility(AbilityPickerView abilities) throws RemoteException {
|
||||
gamePanel.pickAbility(abilities);
|
||||
}
|
||||
|
||||
public void handleException(Exception ex) throws MageException {
|
||||
logger.log(Level.SEVERE, "", ex);
|
||||
throw new MageException("Server error");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void revealCards(String name, CardsView cards) throws RemoteException {
|
||||
gamePanel.revealCards(name, cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void getAmount(int min, int max) throws RemoteException {
|
||||
gamePanel.getAmount(min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void choose(String message, String[] choices) throws RemoteException {
|
||||
gamePanel.getChoice(message, choices);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.remote;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.interfaces.GameReplayClient;
|
||||
import mage.util.Logging;
|
||||
import mage.view.GameView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GameReplayClientImpl implements GameReplayClient {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(GameClientImpl.class.getName());
|
||||
|
||||
private UUID replayClientId;
|
||||
private GamePanel gamePanel;
|
||||
|
||||
public GameReplayClientImpl(GamePanel gamePanel) {
|
||||
replayClientId = UUID.randomUUID();
|
||||
this.gamePanel = gamePanel;
|
||||
try {
|
||||
UnicastRemoteObject.exportObject(this, 0);
|
||||
} catch (RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() throws RemoteException {
|
||||
return replayClientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void update(GameView game) throws RemoteException {
|
||||
gamePanel.updateGame(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init(GameView gameView) throws RemoteException {
|
||||
gamePanel.init(gameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void gameOver(String message) throws RemoteException {
|
||||
gamePanel.modalMessage(message);
|
||||
gamePanel.hideGame();
|
||||
}
|
||||
|
||||
public synchronized void message(String message) throws RemoteException {
|
||||
gamePanel.replayMessage(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,9 @@ import java.rmi.RemoteException;
|
|||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -41,13 +43,12 @@ import javax.swing.JOptionPane;
|
|||
import mage.Constants;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.client.util.Config;
|
||||
import mage.interfaces.ChatClient;
|
||||
import mage.interfaces.Client;
|
||||
import mage.interfaces.GameClient;
|
||||
import mage.interfaces.GameReplayClient;
|
||||
import mage.interfaces.MageException;
|
||||
import mage.interfaces.Server;
|
||||
import mage.interfaces.callback.CallbackClientDaemon;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TableView;
|
||||
|
||||
|
@ -66,6 +67,9 @@ public class Session {
|
|||
private MageFrame frame;
|
||||
private String[] playerTypes;
|
||||
private String[] gameTypes;
|
||||
private Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
|
||||
private GamePanel game;
|
||||
private CallbackClientDaemon callbackDaemon;
|
||||
|
||||
public Session(MageFrame frame) {
|
||||
this.frame = frame;
|
||||
|
@ -75,13 +79,14 @@ public class Session {
|
|||
if (isConnected()) {
|
||||
disconnect();
|
||||
}
|
||||
this.userName = userName;
|
||||
this.client = new ClientImpl(frame, userName);
|
||||
System.setSecurityManager(null);
|
||||
Registry reg = LocateRegistry.getRegistry(serverName, port);
|
||||
this.server = (Server) reg.lookup(Config.remoteServer);
|
||||
this.userName = userName;
|
||||
try {
|
||||
sessionId = server.registerClient(client);
|
||||
this.client = new Client(this, frame, userName);
|
||||
sessionId = server.registerClient(userName, client.getId());
|
||||
callbackDaemon = new CallbackClientDaemon(sessionId, client, server);
|
||||
playerTypes = server.getPlayerTypes();
|
||||
gameTypes = server.getGameTypes();
|
||||
logger.info("Connected to RMI server at " + serverName + ":" + port);
|
||||
|
@ -95,6 +100,10 @@ public class Session {
|
|||
|
||||
if (isConnected()) {
|
||||
try {
|
||||
for (UUID chatId: chats.keySet()) {
|
||||
server.leaveChat(chatId, sessionId);
|
||||
}
|
||||
//TODO: stop daemon
|
||||
server.deregisterClient(sessionId);
|
||||
server = null;
|
||||
logger.info("Disconnected ... ");
|
||||
|
@ -118,6 +127,18 @@ public class Session {
|
|||
return gameTypes;
|
||||
}
|
||||
|
||||
public Map<UUID, ChatPanel> getChats() {
|
||||
return chats;
|
||||
}
|
||||
|
||||
public GamePanel getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
public void setGame(GamePanel gamePanel) {
|
||||
game = gamePanel;
|
||||
}
|
||||
|
||||
public UUID getMainRoomId() {
|
||||
try {
|
||||
return server.getMainRoomId();
|
||||
|
@ -268,9 +289,10 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean joinChat(UUID chatId, ChatClient client) {
|
||||
public boolean joinChat(UUID chatId, ChatPanel chat) {
|
||||
try {
|
||||
server.joinChat(chatId, client);
|
||||
server.joinChat(chatId, sessionId, userName);
|
||||
chats.put(chatId, chat);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
|
@ -280,9 +302,10 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean leaveChat(UUID chatId, UUID clientId) {
|
||||
public boolean leaveChat(UUID chatId) {
|
||||
try {
|
||||
server.leaveChat(chatId, clientId);
|
||||
server.leaveChat(chatId, sessionId);
|
||||
chats.remove(chatId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
|
@ -304,9 +327,9 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean joinGame(UUID gameId, GameClient gameClient) {
|
||||
public boolean joinGame(UUID gameId) {
|
||||
try {
|
||||
server.joinGame(gameId, sessionId, gameClient);
|
||||
server.joinGame(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
|
@ -316,9 +339,9 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean watchGame(UUID gameId, GameClient gameClient) {
|
||||
public boolean watchGame(UUID gameId) {
|
||||
try {
|
||||
server.watchGame(gameId, sessionId, gameClient);
|
||||
server.watchGame(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
|
@ -328,9 +351,9 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean replayGame(UUID gameId, GameReplayClient replayClient) {
|
||||
public boolean replayGame() {
|
||||
try {
|
||||
server.replayGame(gameId, sessionId, replayClient);
|
||||
server.replayGame(sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
|
@ -410,9 +433,9 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean stopWatching(UUID gameId, UUID gameClientId) {
|
||||
public boolean stopWatching(UUID gameId) {
|
||||
try {
|
||||
server.stopWatching(gameId, gameClientId);
|
||||
server.stopWatching(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
|
|
58
Mage.Client/src/mage/client/util/EDTExceptionHandler.java
Normal file
58
Mage.Client/src/mage/client/util/EDTExceptionHandler.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import mage.util.Logging;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class EDTExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(EDTExceptionHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
handle(e);
|
||||
}
|
||||
|
||||
public void handle(Throwable throwable) {
|
||||
try {
|
||||
logger.severe(throwable.getMessage());
|
||||
} catch (Throwable t) {}
|
||||
}
|
||||
|
||||
public static void registerExceptionHandler() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new EDTExceptionHandler());
|
||||
System.setProperty("sun.awt.exception.handler", EDTExceptionHandler.class.getName());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue