mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
latest
This commit is contained in:
parent
ee760de985
commit
1e292afb69
11 changed files with 69 additions and 65 deletions
|
|
@ -25,8 +25,8 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="desktopPane" alignment="0" pref="1066" max="32767" attributes="0"/>
|
||||
<Component id="mageToolbar" alignment="0" pref="1066" max="32767" attributes="0"/>
|
||||
<Component id="desktopPane" alignment="0" pref="1144" max="32767" attributes="0"/>
|
||||
<Component id="mageToolbar" alignment="0" pref="1144" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="mageToolbar" min="-2" pref="25" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="desktopPane" pref="840" max="32767" attributes="0"/>
|
||||
<Component id="desktopPane" pref="880" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
@ -182,7 +182,7 @@
|
|||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblStatus">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Not connected"/>
|
||||
<Property name="text" type="java.lang.String" value="Not connected "/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_AddingCodePre" type="java.lang.String" value="mageToolbar.add(Box.createHorizontalGlue());"/>
|
||||
|
|
|
|||
|
|
@ -117,11 +117,11 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
this.gamePane.watchGame(gameId);
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
public void replayGame() {
|
||||
this.tablesPane.hideTables();
|
||||
this.tablesPane.setVisible(false);
|
||||
this.gamePane.setVisible(true);
|
||||
this.gamePane.replayGame(gameId);
|
||||
this.gamePane.replayGame();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
|
@ -242,7 +242,7 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
});
|
||||
mageToolbar.add(btnExit);
|
||||
|
||||
lblStatus.setText("Not connected");
|
||||
lblStatus.setText("Not connected ");
|
||||
mageToolbar.add(Box.createHorizontalGlue());
|
||||
mageToolbar.add(lblStatus);
|
||||
|
||||
|
|
@ -250,15 +250,15 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1066, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1066, Short.MAX_VALUE)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1144, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1144, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 840, Short.MAX_VALUE))
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
|
|
|
|||
|
|
@ -166,14 +166,14 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou
|
|||
|
||||
protected String getText(String cardType) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(card.getName()).append("\n");
|
||||
sb.append(card.getName());
|
||||
if (card.getManaCost().size() > 0) {
|
||||
sb.append(card.getManaCost()).append("\n");
|
||||
sb.append("\n").append(card.getManaCost());
|
||||
}
|
||||
sb.append(cardType).append("\n");
|
||||
sb.append(card.getColor().toString()).append("\n");
|
||||
sb.append("\n").append(cardType);
|
||||
sb.append("\n").append(card.getColor().toString());
|
||||
for (String rule: getRules()) {
|
||||
sb.append(rule).append("\n");
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append(card.getPower()).append("/").append(card.getToughness());
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
txtConversation.setCaretPosition(txtConversation.getText().length() - 1);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.txtConversation.selectAll();
|
||||
this.txtConversation.replaceSelection("");
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="player2Panel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="22" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="26" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnOK" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
|
|
|||
|
|
@ -64,13 +64,6 @@ public class NewTableDialog extends MageDialog {
|
|||
public NewTableDialog() {
|
||||
initComponents();
|
||||
this.player2Panel.setVisible(false);
|
||||
//for testing only
|
||||
// this.player1Panel.setPlayerName("human");
|
||||
// this.player2Panel.setPlayerName("computer");
|
||||
// //this.cbPlayer2Type.setSelectedItem(PlayerType.COMPUTER);
|
||||
// this.player2Panel.setVisible(true);
|
||||
// this.player1Panel.setDeckFile("test.dck");
|
||||
// this.player2Panel.setDeckFile("test.dck");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -206,31 +199,20 @@ public class NewTableDialog extends MageDialog {
|
|||
List<String> playerTypes = new ArrayList<String>();
|
||||
playerTypes.add("Human");
|
||||
playerTypes.add((String) this.cbPlayer2Type.getSelectedItem());
|
||||
table = session.createTable(
|
||||
roomId,
|
||||
(String)this.cbGameType.getSelectedItem(),
|
||||
(String)this.cbDeckType.getSelectedItem(),
|
||||
playerTypes
|
||||
);
|
||||
if (session.joinTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
0,
|
||||
this.player1Panel.getPlayerName(),
|
||||
DeckCardLists.load(this.player1Panel.getDeckFile())
|
||||
)) {
|
||||
table = session.createTable(roomId, (String)this.cbGameType.getSelectedItem(), (String)this.cbDeckType.getSelectedItem(), playerTypes);
|
||||
if (session.joinTable(roomId, table.getTableId(), 0, this.player1Panel.getPlayerName(), DeckCardLists.load(this.player1Panel.getDeckFile()))) {
|
||||
if (!this.cbPlayer2Type.getSelectedItem().equals("Human")) {
|
||||
if (session.joinTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
1,
|
||||
this.player2Panel.getPlayerName(),
|
||||
DeckCardLists.load(this.player2Panel.getDeckFile())
|
||||
)) {
|
||||
if (session.joinTable(roomId, table.getTableId(), 1, this.player2Panel.getPlayerName(), DeckCardLists.load(this.player2Panel.getDeckFile()))) {
|
||||
this.setVisible(false);
|
||||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
else {
|
||||
this.setVisible(false);
|
||||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ public class GamePane extends MagePane {
|
|||
gamePanel.watchGame(gameId);
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
gamePanel.replayGame(gameId);
|
||||
public void replayGame() {
|
||||
gamePanel.replayGame();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
|
|
|||
|
|
@ -36,9 +36,14 @@
|
|||
<SubComponents>
|
||||
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
|
||||
<Properties>
|
||||
<Property name="dividerLocation" type="int" value="1000"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
<Property name="dividerSize" type="int" value="3"/>
|
||||
<Property name="resizeWeight" type="double" value="1.0"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[26, 48]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||
|
|
@ -58,7 +63,7 @@
|
|||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="pnlHand" max="32767" attributes="0"/>
|
||||
<Component id="pnlBattlefield" alignment="0" pref="739" max="32767" attributes="0"/>
|
||||
<Component id="pnlBattlefield" alignment="0" pref="665" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
|
|
@ -66,7 +71,7 @@
|
|||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="pnlBattlefield" pref="632" max="32767" attributes="0"/>
|
||||
<Component id="pnlBattlefield" pref="634" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="pnlHand" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
|
@ -158,7 +163,7 @@
|
|||
<Component id="stack" min="-2" pref="209" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace pref="8" max="32767" attributes="0"/>
|
||||
<Component id="pnlReplay" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
|
|
@ -394,7 +399,7 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="hand" alignment="1" pref="735" max="32767" attributes="0"/>
|
||||
<Component id="hand" alignment="1" pref="661" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
|
@ -418,6 +423,11 @@
|
|||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="mage.client.chat.ChatPanel" name="chatPanel">
|
||||
<Properties>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 48]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||
<JSplitPaneConstraints position="right"/>
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.pnlReplay.setVisible(false);
|
||||
this.btnStopWatching.setVisible(false);
|
||||
this.setVisible(true);
|
||||
this.chatPanel.clear();
|
||||
this.chatPanel.connect(session.getGameChatId(gameId));
|
||||
if (!session.joinGame(gameId))
|
||||
hideGame();
|
||||
|
|
@ -102,22 +103,25 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.feedbackPanel.clear();
|
||||
this.btnConcede.setVisible(false);
|
||||
this.btnStopWatching.setVisible(true);
|
||||
this.btnCheat.setVisible(false);
|
||||
this.pnlReplay.setVisible(false);
|
||||
this.setVisible(true);
|
||||
this.chatPanel.clear();
|
||||
this.chatPanel.connect(session.getGameChatId(gameId));
|
||||
if (!session.watchGame(gameId))
|
||||
hideGame();
|
||||
}
|
||||
|
||||
public synchronized void replayGame(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
public synchronized void replayGame() {
|
||||
session = MageFrame.getSession();
|
||||
session.setGame(this);
|
||||
this.feedbackPanel.clear();
|
||||
this.btnConcede.setVisible(false);
|
||||
this.btnStopWatching.setVisible(false);
|
||||
this.btnCheat.setVisible(false);
|
||||
this.pnlReplay.setVisible(true);
|
||||
this.setVisible(true);
|
||||
this.chatPanel.clear();
|
||||
if (!session.replayGame())
|
||||
hideGame();
|
||||
}
|
||||
|
|
@ -132,6 +136,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
public synchronized void init(GameView game) {
|
||||
combat.init(gameId, bigCard);
|
||||
combat.setLocation(300, 200);
|
||||
MageFrame.getDesktop().add(combat, JLayeredPane.PALETTE_LAYER);
|
||||
this.players.clear();
|
||||
this.pnlBattlefield.removeAll();
|
||||
|
|
@ -169,7 +174,6 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
if (game.getCombat().size() > 0) {
|
||||
combat.showDialog(game.getCombat());
|
||||
combat.setLocation(300, 200);
|
||||
}
|
||||
else {
|
||||
combat.hideDialog();
|
||||
|
|
@ -230,7 +234,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void pickAbility(AbilityPickerView choices) {
|
||||
this.abilityPicker.show(choices, MouseInfo.getPointerInfo().getLocation());
|
||||
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
|
||||
}
|
||||
|
||||
public void revealCards(String name, CardsView cards) {
|
||||
|
|
@ -297,9 +301,10 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
pnlBattlefield = new javax.swing.JPanel();
|
||||
chatPanel = new mage.client.chat.ChatPanel();
|
||||
|
||||
jSplitPane1.setDividerLocation(1000);
|
||||
jSplitPane1.setBorder(null);
|
||||
jSplitPane1.setDividerSize(3);
|
||||
jSplitPane1.setResizeWeight(1.0);
|
||||
jSplitPane1.setMinimumSize(new java.awt.Dimension(26, 48));
|
||||
|
||||
pnlGameInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
|
||||
|
|
@ -467,7 +472,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
.addComponent(stack, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(bigCard, 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)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
|
||||
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlGameInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
|
|
@ -482,7 +487,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
pnlHand.setLayout(pnlHandLayout);
|
||||
pnlHandLayout.setHorizontalGroup(
|
||||
pnlHandLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(hand, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 735, Short.MAX_VALUE)
|
||||
.addComponent(hand, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 661, Short.MAX_VALUE)
|
||||
);
|
||||
pnlHandLayout.setVerticalGroup(
|
||||
pnlHandLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
|
@ -500,18 +505,20 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
.addGap(0, 0, 0)
|
||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(pnlHand, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 739, Short.MAX_VALUE)))
|
||||
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE)))
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE)
|
||||
.addComponent(pnlBattlefield, javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(pnlHand, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(pnlGameInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jSplitPane1.setLeftComponent(jPanel3);
|
||||
|
||||
chatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
|
||||
jSplitPane1.setRightComponent(chatPanel);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class Client implements CallbackClient {
|
|||
gameStarted(data[0], data[1]);
|
||||
}
|
||||
else if (callback.getMethod().equals("replayGame")) {
|
||||
replayGame((UUID) callback.getData());
|
||||
replayGame();
|
||||
}
|
||||
else if (callback.getMethod().equals("watchGame")) {
|
||||
watchGame((UUID) callback.getData());
|
||||
|
|
@ -158,9 +158,9 @@ public class Client implements CallbackClient {
|
|||
logger.info("Watching game " + gameId);
|
||||
}
|
||||
|
||||
protected void replayGame(UUID gameId) {
|
||||
frame.replayGame(gameId);
|
||||
logger.info("Replaying game " + gameId);
|
||||
protected void replayGame() {
|
||||
frame.replayGame();
|
||||
logger.info("Replaying game");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class Session {
|
|||
gameTypes = server.getGameTypes();
|
||||
deckTypes = server.getDeckTypes();
|
||||
logger.info("Connected to RMI server at " + serverName + ":" + port);
|
||||
frame.setStatusText("Connected to " + serverName + ":" + port);
|
||||
frame.setStatusText("Connected to " + serverName + ":" + port + " ");
|
||||
frame.enableButtons();
|
||||
} catch (MageException ex) {
|
||||
Logger.getLogger(Session.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
|
@ -115,7 +115,7 @@ public class Session {
|
|||
} catch (MageException ex) {
|
||||
logger.log(Level.SEVERE, "Error disconnecting ...", ex);
|
||||
}
|
||||
frame.setStatusText("Not connected");
|
||||
frame.setStatusText("Not connected ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue