mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
Fixed that to allow watchers of a game to see the hand cards of players did not work correctly.
This commit is contained in:
parent
c0db6dfdc8
commit
c65adebc57
14 changed files with 129 additions and 68 deletions
|
|
@ -712,6 +712,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
String proxyPassword = prefs.get("proxyPassword", "");
|
||||
int avatarId = PreferencesDialog.getSelectedAvatar();
|
||||
boolean showAbilityPickerForced = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true");
|
||||
|
||||
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
Connection connection = new Connection();
|
||||
|
|
@ -725,6 +727,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
connection.setProxyPassword(proxyPassword);
|
||||
connection.setAvatarId(avatarId);
|
||||
connection.setShowAbilityPickerForced(showAbilityPickerForced);
|
||||
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
|
||||
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
|
||||
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
|
||||
if (MageFrame.connect(connection)) {
|
||||
|
|
|
|||
|
|
@ -332,6 +332,7 @@ public class ConnectDialog extends MageDialog {
|
|||
int avatarId = PreferencesDialog.getSelectedAvatar();
|
||||
connection.setAvatarId(avatarId);
|
||||
boolean showAbilityPickerForced = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true");
|
||||
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
|
||||
connection.setShowAbilityPickerForced(showAbilityPickerForced);
|
||||
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
|
||||
logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort());
|
||||
|
|
|
|||
|
|
@ -1681,9 +1681,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
try {
|
||||
MageFrame.getSession().updatePreferencesForServer(
|
||||
getSelectedAvatar(),
|
||||
dialog.cbAllowRequestToShowHandCards.isSelected(),
|
||||
getSelectedAvatar(),
|
||||
dialog.showAbilityPickerForced.isSelected(),
|
||||
dialog.cbAllowRequestToShowHandCards.isSelected(),
|
||||
getUserSkipPrioritySteps());
|
||||
|
||||
prefs.flush();
|
||||
|
|
@ -2235,6 +2235,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
save(prefs, checkBox, propName, PHASE_ON, PHASE_OFF, false);
|
||||
}
|
||||
|
||||
public static void setPrefValue(String key, boolean value) {
|
||||
switch(key) {
|
||||
case KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS:
|
||||
dialog.cbAllowRequestToShowHandCards.setSelected(value);
|
||||
save(MageFrame.getPreferences(), dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String noValue, boolean updateCache) {
|
||||
prefs.put(propName, checkBox.isSelected() ? yesValue : noValue);
|
||||
if (updateCache) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.event.MouseListener;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
|
|
@ -50,6 +51,8 @@ import javax.swing.event.ChangeListener;
|
|||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.view.PlayerView;
|
||||
|
||||
|
|
@ -68,6 +71,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
private final boolean playerItself;
|
||||
|
||||
private JCheckBoxMenuItem manaPoolMenuItem;
|
||||
private JCheckBoxMenuItem allowViewHandCardsMenuItem;
|
||||
|
||||
public static final int PANEL_HEIGHT = 242;
|
||||
public static final int PANEL_HEIGHT_SMALL = 190;
|
||||
|
|
@ -248,16 +252,17 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
} 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);
|
||||
allowViewHandCardsMenuItem = new JCheckBoxMenuItem("Allow requests to show your hand cards", allowRequestToShowHandCards);
|
||||
allowViewHandCardsMenuItem.setMnemonic(KeyEvent.VK_A);
|
||||
allowViewHandCardsMenuItem.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(allowViewHandCardsMenuItem);
|
||||
|
||||
// Requests allowed
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean requestsAllowed = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
PreferencesDialog.setPrefValue(KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, requestsAllowed);
|
||||
gamePanel.getSession().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
|
@ -391,6 +396,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
public final void update(PlayerView player) {
|
||||
this.playerPanel.update(player);
|
||||
this.battlefieldPanel.update(player.getBattlefield());
|
||||
if (this.allowViewHandCardsMenuItem != null) {
|
||||
this.allowViewHandCardsMenuItem.setSelected(player.getUserData().allowRequestShowHandCards());
|
||||
}
|
||||
}
|
||||
|
||||
public mage.client.game.BattlefieldPanel getBattlefieldPanel() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue