This commit is contained in:
BetaSteward 2010-06-29 01:15:15 +00:00
parent 1f53bb1995
commit 4d5c30d06c
6 changed files with 137 additions and 106 deletions

View file

@ -61,8 +61,8 @@ public class CardDimensions {
textYOffset = (int)(TEXT_MAX_YOFFSET * scaleFactor); textYOffset = (int)(TEXT_MAX_YOFFSET * scaleFactor);
textWidth = (int)(TEXT_MAX_WIDTH * scaleFactor); textWidth = (int)(TEXT_MAX_WIDTH * scaleFactor);
textHeight = (int)(TEXT_MAX_HEIGHT * scaleFactor); textHeight = (int)(TEXT_MAX_HEIGHT * scaleFactor);
powBoxTextTop = (int)(POWBOX_MAX_TOP * scaleFactor); powBoxTextTop = (int)(POWBOX_TEXT_MAX_TOP * scaleFactor);
powBoxTextLeft = (int)(POWBOX_MAX_LEFT * scaleFactor); powBoxTextLeft = (int)(POWBOX_TEXT_MAX_LEFT * scaleFactor);
nameFontSize = Math.max(9, (int)(NAME_FONT_MAX_SIZE * scaleFactor)); nameFontSize = Math.max(9, (int)(NAME_FONT_MAX_SIZE * scaleFactor));
} }

View file

@ -19,17 +19,24 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace pref="13" max="32767" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/> <Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="61" max="-2" attributes="0"/> <EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
<Component id="spnAmount" min="-2" pref="48" max="-2" attributes="0"/> <Component id="spnAmount" min="-2" pref="52" max="-2" attributes="0"/>
<EmptySpace pref="51" max="32767" attributes="0"/> </Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lblMessage" pref="121" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -37,8 +44,10 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblMessage" pref="30" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="spnAmount" min="-2" max="-2" attributes="0"/> <Component id="spnAmount" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
@ -72,5 +81,10 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblMessage">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -50,8 +50,9 @@ public class PickNumberDialog extends MageDialog {
this.setModal(true); this.setModal(true);
} }
public void showDialog(int min, int max) { public void showDialog(int min, int max, String message) {
this.spnAmount.setModel(new SpinnerNumberModel(min, min, max, 1)); this.spnAmount.setModel(new SpinnerNumberModel(min, min, max, 1));
this.lblMessage.setText(message);
this.btnCancel.setVisible(false); this.btnCancel.setVisible(false);
this.setVisible(true); this.setVisible(true);
} }
@ -76,8 +77,7 @@ public class PickNumberDialog extends MageDialog {
spnAmount = new javax.swing.JSpinner(); spnAmount = new javax.swing.JSpinner();
btnCancel = new javax.swing.JButton(); btnCancel = new javax.swing.JButton();
btnOk = new javax.swing.JButton(); btnOk = new javax.swing.JButton();
lblMessage = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
spnAmount.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), null, null, Integer.valueOf(1))); spnAmount.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), null, null, Integer.valueOf(1)));
@ -95,27 +95,35 @@ public class PickNumberDialog extends MageDialog {
} }
}); });
lblMessage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(13, Short.MAX_VALUE)
.addComponent(btnOk) .addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel) .addComponent(btnCancel))
.addContainerGap())
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(61, 61, 61) .addGap(44, 44, 44)
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(51, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)))
.addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel) .addComponent(btnCancel)
.addComponent(btnOk)) .addComponent(btnOk))
@ -138,6 +146,7 @@ public class PickNumberDialog extends MageDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel; private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk; private javax.swing.JButton btnOk;
private javax.swing.JLabel lblMessage;
private javax.swing.JSpinner spnAmount; private javax.swing.JSpinner spnAmount;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -47,7 +47,6 @@ import mage.client.cards.CardDimensions;
import mage.client.util.Config; import mage.client.util.Config;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CardsView; import mage.view.CardsView;
import static mage.client.util.Constants.*;
/** /**
* *

View file

@ -74,6 +74,7 @@ public class GamePanel extends javax.swing.JPanel {
private UUID playerId; private UUID playerId;
private Session session; private Session session;
private CombatDialog combat = new CombatDialog(); private CombatDialog combat = new CombatDialog();
private PickNumberDialog pickNumber = new PickNumberDialog();
/** Creates new form GamePanel */ /** Creates new form GamePanel */
public GamePanel() { public GamePanel() {
@ -144,6 +145,7 @@ public class GamePanel extends javax.swing.JPanel {
combat.init(gameId, bigCard); combat.init(gameId, bigCard);
MageFrame.getDesktop().add(combat, JLayeredPane.POPUP_LAYER); MageFrame.getDesktop().add(combat, JLayeredPane.POPUP_LAYER);
combat.setLocation(500, 300); combat.setLocation(500, 300);
MageFrame.getDesktop().add(pickNumber, JLayeredPane.POPUP_LAYER);
this.players.clear(); this.players.clear();
this.pnlBattlefield.removeAll(); this.pnlBattlefield.removeAll();
//arrange players in a circle with the session player at the bottom left //arrange players in a circle with the session player at the bottom left
@ -306,9 +308,8 @@ public class GamePanel extends javax.swing.JPanel {
showCards.loadCards(title, cards, bigCard, Config.dimensions, gameId); showCards.loadCards(title, cards, bigCard, Config.dimensions, gameId);
} }
public void getAmount(int min, int max) { public void getAmount(int min, int max, String message) {
PickNumberDialog pickNumber = new PickNumberDialog(); pickNumber.showDialog(min, max, message);
pickNumber.showDialog(min, max);
if (pickNumber.isCancel()) if (pickNumber.isCancel())
session.sendPlayerBoolean(gameId, false); session.sendPlayerBoolean(gameId, false);
else else

View file

@ -52,6 +52,7 @@ public class Client implements CallbackClient {
private String userName; private String userName;
private MageFrame frame; private MageFrame frame;
private Session session; private Session session;
private int messageId = 0;
public Client(Session session, MageFrame frame, String userName) { public Client(Session session, MageFrame frame, String userName) {
@ -63,7 +64,10 @@ public class Client implements CallbackClient {
} }
@Override @Override
public void processCallback(ClientCallback callback) { public synchronized void processCallback(ClientCallback callback) {
if (callback.getMessageId() > messageId) {
messageId = callback.getMessageId();
logger.info(callback.getMessageId() + " - " + callback.getMethod());
if (callback.getMethod().equals("startGame")) { if (callback.getMethod().equals("startGame")) {
UUID[] data = (UUID[]) callback.getData(); UUID[] data = (UUID[]) callback.getData();
gameStarted(data[0], data[1]); gameStarted(data[0], data[1]);
@ -136,13 +140,17 @@ public class Client implements CallbackClient {
} }
else if (callback.getMethod().equals("gameSelectAmount")) { else if (callback.getMethod().equals("gameSelectAmount")) {
GameClientMessage message = (GameClientMessage) callback.getData(); GameClientMessage message = (GameClientMessage) callback.getData();
session.getGame().getAmount(message.getMin(), message.getMax()); session.getGame().getAmount(message.getMin(), message.getMax(), message.getMessage());
} }
else if (callback.getMethod().equals("gameReveal")) { else if (callback.getMethod().equals("gameReveal")) {
GameClientMessage message = (GameClientMessage) callback.getData(); GameClientMessage message = (GameClientMessage) callback.getData();
session.getGame().revealCards(message.getMessage(), message.getCardsView()); session.getGame().revealCards(message.getMessage(), message.getCardsView());
} }
} }
else {
logger.warning("message out of sequence - ignoring");
}
}
public UUID getId() throws RemoteException { public UUID getId() throws RemoteException {
return clientId; return clientId;