* Added possibility to allow other players to see hand cards of player.

This commit is contained in:
LevelX2 2014-11-24 23:03:21 +01:00
parent d0e1107a3e
commit 7e145d2cfd
33 changed files with 1093 additions and 190 deletions

View file

@ -92,6 +92,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import mage.view.UserRequestMessage;
import net.java.truevfs.access.TArchiveDetector;
import net.java.truevfs.access.TConfig;
import net.java.truevfs.kernel.spec.FsAccessOption;
@ -1059,6 +1060,24 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
public void showUserRequestDialog(final UserRequestMessage userRequestMessage) {
final UserRequestDialog userRequestDialog = new UserRequestDialog();
userRequestDialog.setLocation(100, 100);
desktopPane.add(userRequestDialog, JLayeredPane.MODAL_LAYER);
// ui.addComponent(MageComponents.DESKTOP_PANE, userRequestDialog);
if (SwingUtilities.isEventDispatchThread()) {
userRequestDialog.showDialog(userRequestMessage);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
userRequestDialog.showDialog(userRequestMessage);
}
});
}
}
public void showErrorDialog(final String title, final String message) {
if (SwingUtilities.isEventDispatchThread()) {
errorDialog.showDialog(title, message);

View file

@ -24,7 +24,6 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
@ -32,6 +31,7 @@
<Component id="exitButton" min="-2" pref="55" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -80,12 +80,12 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="main_card" min="-2" pref="99" max="-2" attributes="0"/>
<Component id="main_card" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_game" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_gamelog" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="145" max="32767" attributes="0"/>
<EmptySpace pref="120" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -107,7 +107,39 @@
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Game panel"/>
</AccessibilityProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="displayBigCardsInHand" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="showToolTipsInAnyZone" min="-2" max="-2" attributes="0"/>
<Component id="showCardName" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="displayBigCardsInHand" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="showToolTipsInAnyZone" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="showCardName" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="displayBigCardsInHand">
<Properties>
@ -119,11 +151,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="displayBigCardsInHandActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="showToolTipsInAnyZone">
<Properties>
@ -138,11 +165,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showToolTipsInAnyZoneActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="showCardName">
<Properties>
@ -157,11 +179,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showCardNameActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
@ -178,7 +195,42 @@
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="cbAllowRequestToShowHandCards" min="-2" pref="546" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="showPlayerNamesPermanently" alignment="0" max="32767" attributes="0"/>
<Component id="nonLandPermanentsInOnePile" alignment="0" max="32767" attributes="0"/>
<Component id="showAbilityPickerForced" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="nonLandPermanentsInOnePile" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="showPlayerNamesPermanently" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="showAbilityPickerForced" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbAllowRequestToShowHandCards" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="nonLandPermanentsInOnePile">
<Properties>
@ -191,11 +243,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="nonLandPermanentsInOnePileActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="showPlayerNamesPermanently">
<Properties>
@ -207,11 +254,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showPlayerNamesPermanentlyActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="showAbilityPickerForced">
<Properties>
@ -223,11 +265,17 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showAbilityPickerForcedActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="cbAllowRequestToShowHandCards">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Allow requests from players and spectators to show your hand cards"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;html&gt;This is the default setting used for your matches. If activated other players or spectators&lt;br&gt;&#xa;of your match can send a request so you can allow them to see your hand cards."/>
<Property name="horizontalAlignment" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbAllowRequestToShowHandCardsActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
@ -244,7 +292,22 @@
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="cbGameLogAutoSave" min="-2" pref="528" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbGameLogAutoSave" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="cbGameLogAutoSave">
<Properties>
@ -255,11 +318,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameLogAutoSaveActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
@ -1054,7 +1112,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="582" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="598" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">

View file

@ -83,6 +83,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_PERMANENTS_IN_ONE_PILE = "nonLandPermanentsInOnePile";
public static final String KEY_SHOW_PLAYER_NAMES_PERMANENTLY = "showPlayerNamesPermanently";
public static final String KEY_SHOW_ABILITY_PICKER_FORCED = "showAbilityPicker";
public static final String KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS = "gameAllowRequestShowHandCards";
public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave";
public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault";
@ -318,6 +319,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
nonLandPermanentsInOnePile = new javax.swing.JCheckBox();
showPlayerNamesPermanently = new javax.swing.JCheckBox();
showAbilityPickerForced = new javax.swing.JCheckBox();
cbAllowRequestToShowHandCards = new javax.swing.JCheckBox();
main_gamelog = new javax.swing.JPanel();
cbGameLogAutoSave = new javax.swing.JCheckBox();
tabPhases = new javax.swing.JPanel();
@ -423,7 +425,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
setTitle("Preferences");
main_card.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card"));
main_card.setLayout(new java.awt.BorderLayout());
displayBigCardsInHand.setText("Use big images (for high resolution screens)");
displayBigCardsInHand.setToolTipText("Changes the size of the cards shown in hand. Switch this option off if you have a small screen size.");
@ -434,7 +435,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
displayBigCardsInHandActionPerformed(evt);
}
});
main_card.add(displayBigCardsInHand, java.awt.BorderLayout.PAGE_START);
showToolTipsInAnyZone.setSelected(true);
showToolTipsInAnyZone.setText("Show card tooltips while hoovering with the mouse pointer over a card");
@ -446,7 +446,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
showToolTipsInAnyZoneActionPerformed(evt);
}
});
main_card.add(showToolTipsInAnyZone, java.awt.BorderLayout.CENTER);
showCardName.setSelected(true);
showCardName.setText("Show card name on card panel");
@ -458,10 +457,34 @@ public class PreferencesDialog extends javax.swing.JDialog {
showCardNameActionPerformed(evt);
}
});
main_card.add(showCardName, java.awt.BorderLayout.PAGE_END);
javax.swing.GroupLayout main_cardLayout = new javax.swing.GroupLayout(main_card);
main_card.setLayout(main_cardLayout);
main_cardLayout.setHorizontalGroup(
main_cardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_cardLayout.createSequentialGroup()
.addContainerGap()
.addGroup(main_cardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_cardLayout.createSequentialGroup()
.addComponent(displayBigCardsInHand, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(main_cardLayout.createSequentialGroup()
.addGroup(main_cardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(showToolTipsInAnyZone)
.addComponent(showCardName))
.addGap(0, 0, Short.MAX_VALUE))))
);
main_cardLayout.setVerticalGroup(
main_cardLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_cardLayout.createSequentialGroup()
.addComponent(displayBigCardsInHand)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showToolTipsInAnyZone)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showCardName))
);
main_game.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Game"));
main_game.setLayout(new java.awt.BorderLayout());
nonLandPermanentsInOnePile.setSelected(true);
nonLandPermanentsInOnePile.setLabel("Put non-land permanents in one pile");
@ -470,8 +493,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
nonLandPermanentsInOnePileActionPerformed(evt);
}
});
main_game.add(nonLandPermanentsInOnePile, java.awt.BorderLayout.PAGE_START);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
showPlayerNamesPermanently.setSelected(true);
showPlayerNamesPermanently.setText("Show player names on avatar permanently");
@ -482,7 +503,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
showPlayerNamesPermanentlyActionPerformed(evt);
}
});
main_game.add(showPlayerNamesPermanently, java.awt.BorderLayout.LINE_START);
showAbilityPickerForced.setSelected(true);
showAbilityPickerForced.setText("Show ability picker for abilities or spells without costs");
@ -493,10 +513,49 @@ public class PreferencesDialog extends javax.swing.JDialog {
showAbilityPickerForcedActionPerformed(evt);
}
});
main_game.add(showAbilityPickerForced, java.awt.BorderLayout.PAGE_END);
cbAllowRequestToShowHandCards.setSelected(true);
cbAllowRequestToShowHandCards.setText("Allow requests from players and spectators to show your hand cards");
cbAllowRequestToShowHandCards.setToolTipText("<html>This is the default setting used for your matches. If activated other players or spectators<br>\nof your match can send a request so you can allow them to see your hand cards.");
cbAllowRequestToShowHandCards.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbAllowRequestToShowHandCards.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbAllowRequestToShowHandCardsActionPerformed(evt);
}
});
javax.swing.GroupLayout main_gameLayout = new javax.swing.GroupLayout(main_game);
main_game.setLayout(main_gameLayout);
main_gameLayout.setHorizontalGroup(
main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createSequentialGroup()
.addContainerGap()
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createSequentialGroup()
.addComponent(cbAllowRequestToShowHandCards, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(main_gameLayout.createSequentialGroup()
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(showPlayerNamesPermanently, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(nonLandPermanentsInOnePile, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(showAbilityPickerForced, javax.swing.GroupLayout.Alignment.LEADING))
.addGap(0, 0, Short.MAX_VALUE))))
);
main_gameLayout.setVerticalGroup(
main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createSequentialGroup()
.addComponent(nonLandPermanentsInOnePile)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showPlayerNamesPermanently)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showAbilityPickerForced)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAllowRequestToShowHandCards))
);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
main_gamelog.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Game log"));
main_gamelog.setLayout(new java.awt.BorderLayout());
cbGameLogAutoSave.setSelected(true);
cbGameLogAutoSave.setText("Auto save game logs (to \"../Mage.Client/gamelogs/\" directory)");
@ -506,7 +565,20 @@ public class PreferencesDialog extends javax.swing.JDialog {
cbGameLogAutoSaveActionPerformed(evt);
}
});
main_gamelog.add(cbGameLogAutoSave, java.awt.BorderLayout.CENTER);
javax.swing.GroupLayout main_gamelogLayout = new javax.swing.GroupLayout(main_gamelog);
main_gamelog.setLayout(main_gamelogLayout);
main_gamelogLayout.setHorizontalGroup(
main_gamelogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gamelogLayout.createSequentialGroup()
.addContainerGap()
.addComponent(cbGameLogAutoSave, javax.swing.GroupLayout.PREFERRED_SIZE, 528, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
main_gamelogLayout.setVerticalGroup(
main_gamelogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbGameLogAutoSave, javax.swing.GroupLayout.Alignment.TRAILING)
);
javax.swing.GroupLayout tabMainLayout = new javax.swing.GroupLayout(tabMain);
tabMain.setLayout(tabMainLayout);
@ -524,12 +596,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(tabMainLayout.createSequentialGroup()
.addContainerGap()
.addComponent(main_card, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(main_card, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(main_game, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(main_gamelog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(145, Short.MAX_VALUE))
.addContainerGap(120, Short.MAX_VALUE))
);
main_card.getAccessibleContext().setAccessibleName("Game panel");
@ -1282,7 +1354,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabAvatars.setLayout(tabAvatarsLayout);
tabAvatarsLayout.setHorizontalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 582, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
);
tabAvatarsLayout.setVerticalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1495,13 +1567,13 @@ public class PreferencesDialog extends javax.swing.JDialog {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tabsPanel)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addComponent(tabsPanel)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1527,6 +1599,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.showPlayerNamesPermanently, KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
// Phases
@ -1591,6 +1664,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
try {
MageFrame.getSession().updatePreferencesForServer(
getSelectedAvatar(),
dialog.cbAllowRequestToShowHandCards.isSelected(),
dialog.showAbilityPickerForced.isSelected(),
getUserSkipPrioritySteps());
@ -1835,6 +1909,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_cbEnableSkipButtonsSoundsActionPerformed
private void cbAllowRequestToShowHandCardsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAllowRequestToShowHandCardsActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbAllowRequestToShowHandCardsActionPerformed
private void showProxySettings() {
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
this.pnlProxy.setVisible(true);
@ -1909,6 +1987,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
load(prefs, dialog.showPlayerNamesPermanently, KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
load(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true");
load(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true");
load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on","on");
@ -2243,6 +2322,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
MageFrame.getSession().updatePreferencesForServer(
id,
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),
getUserSkipPrioritySteps());
}
}
@ -2255,6 +2335,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JButton btnBrowseBackgroundImage;
private javax.swing.JButton btnBrowseBattlefieldImage;
private javax.swing.JButton btnBrowseImageLocation;
private javax.swing.JCheckBox cbAllowRequestToShowHandCards;
private javax.swing.JCheckBox cbCheckForNewImages;
private javax.swing.JCheckBox cbEnableBattlefieldBGM;
private javax.swing.JCheckBox cbEnableDraftSounds;

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="resizable" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="UserRequestMessage"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblText" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="289" max="32767" attributes="0"/>
<Component id="btn3" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btn2" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btn1" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lblText" pref="96" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btn1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btn2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btn3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblText">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="message to the user"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btn3">
<Properties>
<Property name="text" type="java.lang.String" value="btn3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn3ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btn2">
<Properties>
<Property name="text" type="java.lang.String" value="btn2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btn1">
<Properties>
<Property name="text" type="java.lang.String" value="btn1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn1ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View file

@ -0,0 +1,196 @@
/*
* 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.
*/
/*
* ErrorDialog.java
*
* Created on Dec 23, 2009, 11:01:32 AM
*/
package mage.client.dialog;
import mage.client.MageFrame;
import mage.constants.PlayerAction;
import mage.remote.Session;
import mage.view.UserRequestMessage;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class UserRequestDialog extends MageDialog {
private UserRequestMessage userRequestMessage;
/** Creates new form AskDialog */
public UserRequestDialog() {
initComponents();
}
public void showDialog(UserRequestMessage userRequestMessage) {
this.userRequestMessage = userRequestMessage;
this.setTitle(userRequestMessage.getTitel());
String text = "<html><p style=\"text-align:center; margin-left:50px; margin-right:50px\">" + userRequestMessage.getMessage() + "</p></html>";
this.lblText.setText(text);
if (userRequestMessage.getButton1Text() != null) {
this.btn1.setText(userRequestMessage.getButton1Text());
} else {
this.btn1.setVisible(false);
}
if (userRequestMessage.getButton2Text() != null) {
this.btn2.setText(userRequestMessage.getButton2Text());
} else {
this.btn2.setVisible(false);
}
if (userRequestMessage.getButton3Text() != null) {
this.btn3.setText(userRequestMessage.getButton3Text());
} else {
this.btn3.setVisible(false);
}
this.pack();
this.revalidate();
this.repaint();
this.setModal(true);
this.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblText = new javax.swing.JLabel();
btn3 = new javax.swing.JButton();
btn2 = new javax.swing.JButton();
btn1 = new javax.swing.JButton();
setResizable(true);
setTitle("UserRequestMessage");
lblText.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblText.setText("message to the user");
btn3.setText("btn3");
btn3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn3ActionPerformed(evt);
}
});
btn2.setText("btn2");
btn2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn2ActionPerformed(evt);
}
});
btn1.setText("btn1");
btn1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(0, 289, Short.MAX_VALUE)
.addComponent(btn3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btn1)
.addComponent(btn2)
.addComponent(btn3))
.addGap(12, 12, 12))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn1ActionPerformed
if (userRequestMessage.getButton1Action() != null) {
sendUserReplay(userRequestMessage.getButton1Action());
}
this.removeDialog();
}//GEN-LAST:event_btn1ActionPerformed
private void btn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn2ActionPerformed
if (userRequestMessage.getButton2Action() != null) {
sendUserReplay(userRequestMessage.getButton2Action());
}
this.removeDialog();
}//GEN-LAST:event_btn2ActionPerformed
private void btn3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn3ActionPerformed
if (userRequestMessage.getButton3Action() != null) {
sendUserReplay(userRequestMessage.getButton3Action());
}
this.removeDialog();
}//GEN-LAST:event_btn3ActionPerformed
private void sendUserReplay(PlayerAction playerAction) {
Session session = MageFrame.getSession();
switch(playerAction) {
case ADD_PERMISSION_TO_SEE_HAND_CARDS:
session.sendPlayerAction(playerAction, userRequestMessage.getGameId(), userRequestMessage.getRelatedUserId());
break;
default:
// not supported action
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btn1;
private javax.swing.JButton btn2;
private javax.swing.JButton btn3;
private javax.swing.JLabel lblText;
// End of variables declaration//GEN-END:variables
}

View file

@ -299,7 +299,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
}//GEN-LAST:event_btnSpecialActionPerformed
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.UNDO, gameId);
session.sendPlayerAction(PlayerAction.UNDO, gameId, null);
}
public void setHelperPanel(HelperPanel helper) {

View file

@ -152,7 +152,7 @@ public final class GamePanel extends javax.swing.JPanel {
private boolean initialized = false;
private int lastUpdatedTurn;
private boolean menuNameSet = false;
private boolean handCardsOfOpponentAvailable = false;
private Map<String, Card> loadedCards = new HashMap<>();
@ -388,17 +388,18 @@ public final class GamePanel extends javax.swing.JPanel {
this.feedbackPanel.init(gameId);
this.feedbackPanel.clear();
this.btnConcede.setVisible(false);
this.btnStopWatching.setVisible(true);
this.btnSwitchHands.setVisible(false);
this.chosenHandKey = "";
this.btnCancelSkip.setVisible(false);
this.btnSkipToNextTurn.setVisible(false);
this.btnSkipToEndTurn.setVisible(false);
this.btnSkipToNextMain.setVisible(false);
this.btnSkipStack.setVisible(false);
this.btnSkipToYourTurn.setVisible(false);
this.btnSkipToYourTurn.setVisible(false);
this.pnlReplay.setVisible(false);
this.gameChatPanel.clear();
@ -530,45 +531,59 @@ public final class GamePanel extends javax.swing.JPanel {
}
public synchronized void updateGame(GameView game, Map<String, Serializable> options) {
if (playerId == null || game.getHand() == null) {
if (playerId == null && game.getWatchedHands() == null) {
this.handContainer.setVisible(false);
} else {
this.handContainer.setVisible(true);
handCards.clear();
handCards.put(YOUR_HAND, game.getHand());
// Mark playable
if (game.getCanPlayInHand() != null) {
for (CardView card : handCards.get(YOUR_HAND).values()) {
if (game.getCanPlayInHand().contains(card.getId())) {
card.setPlayable(true);
}
}
}
// Get opponents hand cards if available
if (game.getOpponentHands() != null) {
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
if (game.getWatchedHands() != null) {
for (Map.Entry<String, SimpleCardsView> hand: game.getWatchedHands().entrySet()) {
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
}
}
if (!handCards.containsKey(chosenHandKey)) {
chosenHandKey = YOUR_HAND;
if (playerId != null) {
handCards.put(YOUR_HAND, game.getHand());
// Mark playable
if (game.getCanPlayInHand() != null) {
for (CardView card : handCards.get(YOUR_HAND).values()) {
if (game.getCanPlayInHand().contains(card.getId())) {
card.setPlayable(true);
}
}
}
// Get opponents hand cards if available (only possible for players)
if (game.getOpponentHands() != null) {
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
}
}
if (!handCards.containsKey(chosenHandKey)) {
chosenHandKey = YOUR_HAND;
}
} else if (chosenHandKey.isEmpty() && handCards.size() > 0) {
chosenHandKey = handCards.keySet().iterator().next();
}
if (chosenHandKey != null && handCards.containsKey(chosenHandKey)) {
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
}
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
hideAll();
// set visible only if we have any other hand visible than ours
boolean previous = btnSwitchHands.isVisible();
boolean visible = handCards.size() > 1;
if (previous != visible) {
btnSwitchHands.setVisible(visible);
if (visible) {
JOptionPane.showMessageDialog(null, "You control other player's turn. \nUse \"Switch Hand\" button to switch between cards in different hands.");
} else {
JOptionPane.showMessageDialog(null, "You lost control on other player's turn.");
if (playerId != null) {
// set visible only if we have any other hand visible than ours
btnSwitchHands.setVisible(handCards.size() > 1);
boolean change = (handCardsOfOpponentAvailable != (game.getOpponentHands() != null));
if (change) {
handCardsOfOpponentAvailable = !handCardsOfOpponentAvailable;
if (handCardsOfOpponentAvailable) {
JOptionPane.showMessageDialog(null, "You control other player's turn. \nUse \"Switch Hand\" button to switch between cards in different hands.");
} else {
JOptionPane.showMessageDialog(null, "You lost control on other player's turn.");
}
}
} else {
btnSwitchHands.setVisible(!handCards.isEmpty());
}
}
@ -1280,7 +1295,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnStopWatching.setBorder(new EmptyBorder(0,0,0,0));
btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getStopWatchButtonImage()));
btnStopWatching.setFocusable(false);
btnSwitchHands.setToolTipText("Stop watching this game.");
btnStopWatching.setToolTipText("Stop watching this game.");
btnStopWatching.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
@ -1620,42 +1635,42 @@ public final class GamePanel extends javax.swing.JPanel {
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
session.sendPlayerAction(PlayerAction.CONCEDE, gameId);
session.sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
}
}
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId);
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(true, false, false, false, false);
}
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId);
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, true, false, false, false);
}
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId);
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, true, false, false);
}
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId);
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, true, false);
}
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId);
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
AudioManager.playOnSkipButton();
updateSkipButtons(false, false, false, false, true);
}
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId);
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
AudioManager.playOnSkipButtonCancel();
updateSkipButtons(false, false, false, false, false);
}

View file

@ -64,7 +64,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
private UUID gameId;
private boolean smallMode = false;
private boolean playingMode = true;
private GamePanel gamePanel;
private final GamePanel gamePanel;
private final boolean playerItself;
private JCheckBoxMenuItem manaPoolMenuItem;
@ -72,23 +73,27 @@ public class PlayAreaPanel extends javax.swing.JPanel {
public static final int PANEL_HEIGHT_SMALL = 190;
/** Creates new form PlayAreaPanel
* @param isPlayer */
public PlayAreaPanel(boolean isPlayer) {
* @param player
* @param bigCard
* @param gameId
* @param isPlayer true if the client is a player / false if the client is a watcher
* @param playerItself true if it's the area of the player itself
* @param priorityTime
* @param gamePanel */
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean playerItself, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
//this(isPlayer);
this.playerItself = playerItself;
initComponents();
setOpaque(false);
battlefieldPanel.setOpaque(false);
popupMenu = new JPopupMenu();
if (isPlayer) {
addPopupMenuPlayer();
addPopupMenuPlayer(player.getUserData().allowRequestShowHandCards());
} else {
addPopupMenuWatcher();
}
this.add(popupMenu);
}
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
this(isPlayer);
this.gamePanel = gamePanel;
init(player, bigCard, gameId, priorityTime);
update(player);
@ -125,7 +130,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
private void addPopupMenuPlayer() {
private void addPopupMenuPlayer(boolean allowRequestToShowHandCards) {
JMenuItem menuItem;
@ -150,7 +155,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId);
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
}
});
@ -163,7 +168,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId);
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
}
});
@ -174,7 +179,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId);
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
}
});
@ -185,7 +190,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId);
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
}
});
menuItem = new JMenuItem("F9 - Skip everything until own next turn (stop on attack/block)");
@ -195,7 +200,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId);
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
}
});
@ -212,7 +217,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
public void actionPerformed(ActionEvent e) {
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
gamePanel.setMenuStates(manaPoolAutomatic);
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId);
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
}
});
@ -225,12 +230,53 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId);
gamePanel.getSession().sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
}
});
popupMenu.addSeparator();
if (!playerItself) {
menuItem = new JMenuItem("Request permission to see hand cards");
popupMenu.add(menuItem);
// Request to see hand cards
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
}
});
} else {
menuItem = new JCheckBoxMenuItem("Allow requests to show your hand cards", allowRequestToShowHandCards);
menuItem.setMnemonic(KeyEvent.VK_A);
menuItem.setToolTipText("If activated watchers or other players can request to see your hand cards. If you grant this to a user, it's valid for the complete match.");
popupMenu.add(menuItem);
// Requests allowed
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean requestsAllowed = ((JCheckBoxMenuItem)e.getSource()).getState();
gamePanel.getSession().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
}
});
menuItem = new JMenuItem("Revoke all permission(s) to see your hand cards");
menuItem.setMnemonic(KeyEvent.VK_P);
menuItem.setToolTipText("Revoke already granted permission for all spectators to see your hand cards.");
popupMenu.add(menuItem);
// revoke permissions to see hand cards
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
}
});
}
popupMenu.addSeparator();
menuItem = new JMenuItem("Concede game");
popupMenu.add(menuItem);
@ -239,7 +285,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent e) {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId);
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
}
}
});
@ -297,6 +343,18 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
}
});
menuItem = new JMenuItem("Request permission to see hand cards");
popupMenu.add(menuItem);
// Request to see hand cards
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.getSession().sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
}
});
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent Me) {

View file

@ -32,7 +32,6 @@ import java.util.UUID;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import mage.cards.decks.Deck;
import mage.choices.Choice;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import static mage.client.chat.ChatPanel.ChatType.TABLES;
@ -62,6 +61,7 @@ import mage.view.GameClientMessage;
import mage.view.GameEndView;
import mage.view.GameView;
import mage.view.TableClientMessage;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
/**
@ -252,7 +252,8 @@ public class CallbackClientImpl implements CallbackClient {
if (panel != null) {
panel.getChoice(message.getChoice(), callback.getObjectId());
} break;
}
break;
}
case "gamePlayMana":
{
@ -260,7 +261,8 @@ public class CallbackClientImpl implements CallbackClient {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playMana(message.getMessage(), message.getGameView(), callback.getMessageId());
} break;
}
break;
}
case "gamePlayXMana":
{
@ -268,7 +270,8 @@ public class CallbackClientImpl implements CallbackClient {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playXMana(message.getMessage(), message.getGameView(), callback.getMessageId());
} break;
}
break;
}
case "gameSelectAmount":
{
@ -346,7 +349,8 @@ public class CallbackClientImpl implements CallbackClient {
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
} break;
}
break;
}
case "draftUpdate":
{
@ -364,17 +368,21 @@ public class CallbackClientImpl implements CallbackClient {
// } else {
// logger.warn("message out of sequence - ignoring");
// }
// break;
break;
case "draftInit":
{
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
} break;
}
break;
}
case "tournamentInit":
break;
case "userRequestDialog":
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
break;
}
messageId = callback.getMessageId();
} catch (Exception ex) {