mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Chnaged permanent row handling so creatures are always shown towards the opponent side.
This commit is contained in:
parent
e9993f980a
commit
7cfdd80c57
12 changed files with 89 additions and 60 deletions
|
@ -230,7 +230,8 @@
|
|||
<Component class="javax.swing.JCheckBox" name="nonLandPermanentsInOnePile">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="label" type="java.lang.String" value="Put non-land permanents in one pile"/>
|
||||
<Property name="text" type="java.lang.String" value="Put non-land permanents in same row as creatures"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="<html>If activated, all non land permanents are shown in one row.<br>
First creatures than other permanents. If not activated, creatures are<br>
shown in a separate row."/>
|
||||
</Properties>
|
||||
<AccessibilityProperties>
|
||||
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value="nonLandPermanentsInOnePile"/>
|
||||
|
|
|
@ -574,7 +574,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
main_game.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Game"));
|
||||
|
||||
nonLandPermanentsInOnePile.setSelected(true);
|
||||
nonLandPermanentsInOnePile.setLabel("Put non-land permanents in one pile");
|
||||
nonLandPermanentsInOnePile.setText("Put non-land permanents in same row as creatures");
|
||||
nonLandPermanentsInOnePile.setToolTipText("<html>If activated, all non land permanents are shown in one row.<br>\nFirst creatures than other permanents. If not activated, creatures are<br>\nshown in a separate row.");
|
||||
nonLandPermanentsInOnePile.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
nonLandPermanentsInOnePileActionPerformed(evt);
|
||||
|
|
|
@ -82,6 +82,8 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
private boolean addedCreature;
|
||||
|
||||
private boolean removedCreature;
|
||||
// defines if the battlefield is within a top (means top row of player panels) or a bottom player panel
|
||||
private boolean topPanelBattlefield;
|
||||
|
||||
/**
|
||||
* Creates new form BattlefieldPanel
|
||||
|
@ -131,6 +133,14 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
cardDimension = GUISizeHelper.battlefieldCardMaxDimension;
|
||||
}
|
||||
|
||||
public boolean isTopPanelBattlefield() {
|
||||
return topPanelBattlefield;
|
||||
}
|
||||
|
||||
public void setTopPanelBattlefield(boolean topPanelBattlefield) {
|
||||
this.topPanelBattlefield = topPanelBattlefield;
|
||||
}
|
||||
|
||||
public void update(Map<UUID, PermanentView> battlefield) {
|
||||
boolean changed = false;
|
||||
|
||||
|
|
|
@ -619,7 +619,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
PlayerView player = game.getPlayers().get(playerSeat);
|
||||
PlayAreaPanel playAreaPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
|
||||
new PlayAreaPanelOptions(game.isPlayer(), game.isPlayer(), game.isRollbackTurnsAllowed()));
|
||||
new PlayAreaPanelOptions(game.isPlayer(), game.isPlayer(), game.isRollbackTurnsAllowed(), row == 0));
|
||||
players.put(player.getPlayerId(), playAreaPanel);
|
||||
playersWhoLeft.put(player.getPlayerId(), false);
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
|
@ -663,7 +663,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
player = game.getPlayers().get(playerNum);
|
||||
PlayAreaPanel playerPanel = new PlayAreaPanel(player, bigCard, gameId, game.getPriorityTime(), this,
|
||||
new PlayAreaPanelOptions(game.isPlayer(), false, game.isRollbackTurnsAllowed()));
|
||||
new PlayAreaPanelOptions(game.isPlayer(), false, game.isRollbackTurnsAllowed(), row == 0));
|
||||
players.put(player.getPlayerId(), playerPanel);
|
||||
playersWhoLeft.put(player.getPlayerId(), false);
|
||||
c = new GridBagConstraints();
|
||||
|
@ -1207,10 +1207,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
holdingPriority = false;
|
||||
txtHoldPriority.setVisible(false);
|
||||
setMenuStates(
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
false);
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
false);
|
||||
|
||||
updateGame(gameView, options);
|
||||
boolean controllingPlayer = false;
|
||||
|
@ -2370,26 +2370,26 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
private static int holdPriorityMask = System.getProperty("os.name").contains("Mac OS X") ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK;
|
||||
|
||||
public void handleEvent(AWTEvent event) {
|
||||
if(event instanceof InputEvent) {
|
||||
if (event instanceof InputEvent) {
|
||||
int id = event.getID();
|
||||
boolean isActionEvent = false;
|
||||
if(id == MouseEvent.MOUSE_PRESSED)
|
||||
if (id == MouseEvent.MOUSE_PRESSED) {
|
||||
isActionEvent = true;
|
||||
else if(id == KeyEvent.KEY_PRESSED)
|
||||
{
|
||||
KeyEvent key = (KeyEvent)event;
|
||||
} else if (id == KeyEvent.KEY_PRESSED) {
|
||||
KeyEvent key = (KeyEvent) event;
|
||||
int keyCode = key.getKeyCode();
|
||||
if(keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_SPACE)
|
||||
if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_SPACE) {
|
||||
isActionEvent = true;
|
||||
}
|
||||
}
|
||||
if(isActionEvent) {
|
||||
InputEvent input = (InputEvent)event;
|
||||
if((input.getModifiersEx() & holdPriorityMask) != 0) {
|
||||
if (isActionEvent) {
|
||||
InputEvent input = (InputEvent) event;
|
||||
if ((input.getModifiersEx() & holdPriorityMask) != 0) {
|
||||
setMenuStates(
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
true);
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
true);
|
||||
holdPriority(true);
|
||||
}
|
||||
}
|
||||
|
@ -2397,13 +2397,14 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void holdPriority(boolean holdPriority) {
|
||||
if(holdingPriority != holdPriority) {
|
||||
if (holdingPriority != holdPriority) {
|
||||
holdingPriority = holdPriority;
|
||||
txtHoldPriority.setVisible(holdPriority);
|
||||
if(holdPriority)
|
||||
if (holdPriority) {
|
||||
session.sendPlayerAction(PlayerAction.HOLD_PRIORITY, gameId, null);
|
||||
else
|
||||
} else {
|
||||
session.sendPlayerAction(PlayerAction.UNHOLD_PRIORITY, gameId, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
holdPriorityMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean holdPriority = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
boolean holdPriority = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriority);
|
||||
gamePanel.holdPriority(holdPriority);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.setMnemonic(KeyEvent.VK_V);
|
||||
skipMenu.add(menuItem);
|
||||
menuItem.addActionListener(skipListener);
|
||||
|
||||
|
||||
menuItem = new JMenuItem("<html><b>F11</b> - Everything until end step prior to your own next turn");
|
||||
menuItem.setActionCommand("F11");
|
||||
menuItem.setToolTipText(everythingTooltipText);
|
||||
|
@ -312,8 +312,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted, useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
useFirstManaAbilityItem = new JCheckBoxMenuItem("Use first mana ability when tapping lands", false);
|
||||
useFirstManaAbilityItem.setMnemonic(KeyEvent.VK_F);
|
||||
useFirstManaAbilityItem.setToolTipText("<html>Use the first mana ability when<br>"
|
||||
|
@ -328,7 +328,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
boolean useFirstManaAbility = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_USE_FIRST_MANA_ABILITY, useFirstManaAbility ? "true" : "false");
|
||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbility, holdPriorityMenuItem.getState());
|
||||
gamePanel.getSession().sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON: PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
|
||||
gamePanel.getSession().sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON : PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -606,6 +606,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
playerPanel = new PlayerPanelExt();
|
||||
btnCheat = new javax.swing.JButton();
|
||||
battlefieldPanel = new mage.client.game.BattlefieldPanel();
|
||||
battlefieldPanel.setTopPanelBattlefield(options.topRow);
|
||||
|
||||
btnCheat.setText("Cheat");
|
||||
btnCheat.addActionListener(new java.awt.event.ActionListener() {
|
||||
|
@ -663,7 +664,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
if (manaPoolMenuItem2 != null) {
|
||||
manaPoolMenuItem2.setSelected(manaPoolAutomaticRestricted);
|
||||
}
|
||||
if (useFirstManaAbilityItem != null) {
|
||||
if (useFirstManaAbilityItem != null) {
|
||||
useFirstManaAbilityItem.setSelected(useFirstManaAbility);
|
||||
}
|
||||
if (holdPriorityMenuItem != null) {
|
||||
|
|
|
@ -34,10 +34,11 @@ package mage.client.game;
|
|||
*/
|
||||
public class PlayAreaPanelOptions {
|
||||
|
||||
public PlayAreaPanelOptions(boolean isPlayer, boolean playerItself, boolean rollbackTurnsAllowed) {
|
||||
public PlayAreaPanelOptions(boolean isPlayer, boolean playerItself, boolean rollbackTurnsAllowed, boolean topRow) {
|
||||
this.isPlayer = isPlayer;
|
||||
this.playerItself = playerItself;
|
||||
this.rollbackTurnsAllowed = rollbackTurnsAllowed;
|
||||
this.topRow = topRow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,4 +57,9 @@ public class PlayAreaPanelOptions {
|
|||
*/
|
||||
public boolean rollbackTurnsAllowed = false;
|
||||
|
||||
/**
|
||||
* true if the battlefield is on the top row of player areas
|
||||
*/
|
||||
public boolean topRow = false;
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public interface MagePlugins {
|
|||
|
||||
boolean isCounterPluginLoaded();
|
||||
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, boolean topRow);
|
||||
|
||||
void downloadSymbols();
|
||||
|
||||
|
|
|
@ -123,10 +123,9 @@ public class Plugins implements MagePlugins {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents) {
|
||||
sortingOptions.put("nonLandPermanentsInOnePile", PreferencesDialog.getCachedValue("nonLandPermanentsInOnePile", "false"));
|
||||
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, boolean topRow) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.sortPermanents(ui, permanents, sortingOptions);
|
||||
return this.cardPlugin.sortPermanents(ui, permanents, PreferencesDialog.getCachedValue("nonLandPermanentsInOnePile", "false").equals("true"), topRow);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package mage.client.util.layout;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
import mage.client.game.BattlefieldPanel;
|
||||
|
||||
/**
|
||||
* Interface for operations that modify cards' layout
|
||||
|
@ -11,7 +11,7 @@ public interface CardLayoutStrategy {
|
|||
|
||||
int getDefaultZOrder();
|
||||
|
||||
void onAdd(JLayeredPane jLayeredPane);
|
||||
void onAdd(BattlefieldPanel jLayeredPane);
|
||||
|
||||
void doLayout(JLayeredPane jLayeredPane, int battlefieldWidth);
|
||||
void doLayout(BattlefieldPanel jLayeredPane, int battlefieldWidth);
|
||||
}
|
||||
|
|
|
@ -31,16 +31,16 @@ public class OldCardLayoutStrategy implements CardLayoutStrategy {
|
|||
private static final int ATTACHMENT_MIN_DY_OFFSET = 12;
|
||||
|
||||
@Override
|
||||
public void doLayout(JLayeredPane jLayeredPane, int width) {
|
||||
Map<UUID, MagePermanent> permanents = ((BattlefieldPanel) jLayeredPane).getPermanents();
|
||||
JLayeredPane jPanel = ((BattlefieldPanel) jLayeredPane).getMainPanel();
|
||||
public void doLayout(BattlefieldPanel battlefieldPanel, int width) {
|
||||
Map<UUID, MagePermanent> permanents = battlefieldPanel.getPermanents();
|
||||
JLayeredPane jPanel = battlefieldPanel.getMainPanel();
|
||||
|
||||
int height = Plugins.getInstance().sortPermanents(((BattlefieldPanel) jLayeredPane).getUiComponentsList(), permanents.values());
|
||||
int height = Plugins.getInstance().sortPermanents(battlefieldPanel.getUiComponentsList(), permanents.values(), battlefieldPanel.isTopPanelBattlefield());
|
||||
jPanel.setPreferredSize(new Dimension(width - 30, height));
|
||||
|
||||
for (PermanentView permanent : ((BattlefieldPanel) jLayeredPane).getBattlefield().values()) {
|
||||
for (PermanentView permanent : battlefieldPanel.getBattlefield().values()) {
|
||||
if (permanent.getAttachments() != null) {
|
||||
groupAttachments(jLayeredPane, jPanel, permanents, permanent);
|
||||
groupAttachments(battlefieldPanel, jPanel, permanents, permanent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class OldCardLayoutStrategy implements CardLayoutStrategy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onAdd(JLayeredPane jLayeredPane) {
|
||||
public void onAdd(BattlefieldPanel jLayeredPane) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, Map<String, String> options) {
|
||||
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, boolean nonPermanentsOwnRow, boolean topPanel) {
|
||||
//TODO: add caching
|
||||
//requires to find out is position have been changed that includes:
|
||||
//adding/removing permanents, type change
|
||||
|
@ -151,7 +151,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
|
||||
int insertIndex = -1;
|
||||
|
||||
// Find lands with the same name.
|
||||
// Find already added lands with the same name.
|
||||
for (int i = 0, n = rowAllLands.size(); i < n; i++) {
|
||||
Stack stack = rowAllLands.get(i);
|
||||
MagePermanent firstPanel = stack.get(0);
|
||||
|
@ -204,12 +204,10 @@ public class CardPluginImpl implements CardPlugin {
|
|||
Row rowAllAttached = new Row(permanents, RowType.attached);
|
||||
|
||||
boolean othersOnTheRight = true;
|
||||
if (options != null && options.containsKey("nonLandPermanentsInOnePile")) {
|
||||
if (options.get("nonLandPermanentsInOnePile").equals("true")) {
|
||||
othersOnTheRight = false;
|
||||
rowAllCreatures.addAll(rowAllOthers);
|
||||
rowAllOthers.clear();
|
||||
}
|
||||
if (nonPermanentsOwnRow) {
|
||||
othersOnTheRight = false;
|
||||
rowAllCreatures.addAll(rowAllOthers);
|
||||
rowAllOthers.clear();
|
||||
}
|
||||
|
||||
cardWidth = cardWidthMax;
|
||||
|
@ -218,6 +216,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
playAreaHeight = rect.height;
|
||||
while (true) {
|
||||
rows.clear();
|
||||
// calculate values based on the card size that is changing with every iteration
|
||||
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
||||
extraCardSpacingX = Math.round(cardWidth * EXTRA_CARD_SPACING_X);
|
||||
cardSpacingX = cardHeight - cardWidth + extraCardSpacingX;
|
||||
|
@ -225,15 +224,26 @@ public class CardPluginImpl implements CardPlugin {
|
|||
stackSpacingX = stackVertical ? 0 : Math.round(cardWidth * STACK_SPACING_X);
|
||||
stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y);
|
||||
attachmentSpacingY = Math.round(cardHeight * ATTACHMENT_SPACING_Y);
|
||||
// clone data
|
||||
Row creatures = (Row) rowAllCreatures.clone();
|
||||
Row lands = (Row) rowAllLands.clone();
|
||||
Row others = (Row) rowAllOthers.clone();
|
||||
|
||||
// Wrap all creatures and lands.
|
||||
wrap(creatures, rows, -1);
|
||||
int afterCreaturesIndex = rows.size();
|
||||
wrap(lands, rows, afterCreaturesIndex);
|
||||
int afterLandsIndex = rows.size();
|
||||
wrap(others, rows, afterLandsIndex);
|
||||
int addOthersIndex;
|
||||
if (topPanel) {
|
||||
wrap(lands, rows, -1);
|
||||
wrap(others, rows, rows.size());
|
||||
addOthersIndex = rows.size();
|
||||
wrap(creatures, rows, addOthersIndex);
|
||||
} else {
|
||||
wrap(creatures, rows, -1);
|
||||
addOthersIndex = rows.size();
|
||||
wrap(lands, rows, rows.size());
|
||||
wrap(others, rows, rows.size());
|
||||
|
||||
}
|
||||
|
||||
// Store the current rows and others.
|
||||
List<Row> storedRows = new ArrayList<>(rows.size());
|
||||
for (Row row : rows) {
|
||||
|
@ -252,7 +262,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
rows = storedRows;
|
||||
others = storedOthers;
|
||||
// Try to put others on their own row(s) and fill in the rest.
|
||||
wrap(others, rows, afterCreaturesIndex);
|
||||
wrap(others, rows, addOthersIndex);
|
||||
for (Row row : rows) {
|
||||
fillRow(others, rows, row);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public interface CardPlugin extends Plugin {
|
|||
|
||||
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, Map<String, String> options);
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel);
|
||||
|
||||
/**
|
||||
* Download various symbols (mana, tap, set).
|
||||
|
|
Loading…
Reference in a new issue