* Deactivated macro button, becuase it's not working correctly (#2147).

This commit is contained in:
LevelX2 2017-07-29 17:39:13 +02:00
parent 94994dd3ec
commit 400bbba8e1
3 changed files with 92 additions and 76 deletions

View file

@ -305,7 +305,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.players.clear(); this.players.clear();
this.playersWhoLeft.clear(); this.playersWhoLeft.clear();
if (jLayeredPane!= null) { if (jLayeredPane != null) {
jLayeredPane.remove(abilityPicker); jLayeredPane.remove(abilityPicker);
jLayeredPane.remove(DialogManager.getManager(gameId)); jLayeredPane.remove(DialogManager.getManager(gameId));
} }
@ -1440,7 +1440,6 @@ public final class GamePanel extends javax.swing.JPanel {
int c = JComponent.WHEN_IN_FOCUSED_WINDOW; int c = JComponent.WHEN_IN_FOCUSED_WINDOW;
btnToggleMacro.setContentAreaFilled(false); btnToggleMacro.setContentAreaFilled(false);
btnToggleMacro.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); btnToggleMacro.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnToggleMacro.setIcon(new ImageIcon(ImageManagerImpl.instance.getToggleRecordMacroButtonImage())); btnToggleMacro.setIcon(new ImageIcon(ImageManagerImpl.instance.getToggleRecordMacroButtonImage()));
@ -1804,24 +1803,24 @@ public final class GamePanel extends javax.swing.JPanel {
pnlReplay.setLayout(gl_pnlReplay); pnlReplay.setLayout(gl_pnlReplay);
gl_pnlReplay.setHorizontalGroup( gl_pnlReplay.setHorizontalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlReplay.createSequentialGroup() .addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
gl_pnlReplay.setVerticalGroup( gl_pnlReplay.setVerticalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE) .addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE) .addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE) .addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE) .addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE) .addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
); );
// Game info panel (buttons on the right panel) // Game info panel (buttons on the right panel)
@ -1837,9 +1836,9 @@ public final class GamePanel extends javax.swing.JPanel {
.addComponent(btnSkipToEndStepBeforeYourTurn) .addComponent(btnSkipToEndStepBeforeYourTurn)
) )
.addGroup(gl_pnlShortCuts.createSequentialGroup() .addGroup(gl_pnlShortCuts.createSequentialGroup()
.addComponent(btnToggleMacro)
.addComponent(txtHoldPriority) .addComponent(txtHoldPriority)
.addComponent(txtSpellsCast) .addComponent(txtSpellsCast)
/* .addComponent(btnToggleMacro)*/
.addComponent(btnSwitchHands) .addComponent(btnSwitchHands)
.addComponent(btnCancelSkip) .addComponent(btnCancelSkip)
.addComponent(btnConcede) .addComponent(btnConcede)
@ -1935,46 +1934,46 @@ public final class GamePanel extends javax.swing.JPanel {
javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea); javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea);
gl_helperHandButtonsStackArea.setHorizontalGroup( gl_helperHandButtonsStackArea.setHorizontalGroup(
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING) gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup() .addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
// .addGap(0) // .addGap(0)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING) .addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup() .addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING) .addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
)
) )
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING) .addGap(0)
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) //.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
) .addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
) .addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(0) )))
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)))
); );
gl_helperHandButtonsStackArea.setVerticalGroup( gl_helperHandButtonsStackArea.setVerticalGroup(
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.TRAILING) gl_helperHandButtonsStackArea.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup() .addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING) .addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE) .addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
//.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGap(2)
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
) )
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup() //.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGap(2)
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
) )
) )
)
); );
pnlHelperHandButtonsStackArea.setLayout(gl_helperHandButtonsStackArea); pnlHelperHandButtonsStackArea.setLayout(gl_helperHandButtonsStackArea);
@ -2007,11 +2006,11 @@ public final class GamePanel extends javax.swing.JPanel {
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE) .addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE) .addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
); );
} }

View file

@ -87,7 +87,6 @@ public class HumanPlayer extends PlayerImpl {
protected static FilterAttackingCreature filterAttack = new FilterAttackingCreature(); protected static FilterAttackingCreature filterAttack = new FilterAttackingCreature();
protected static FilterBlockingCreature filterBlock = new FilterBlockingCreature(); protected static FilterBlockingCreature filterBlock = new FilterBlockingCreature();
protected final Choice replacementEffectChoice; protected final Choice replacementEffectChoice;
private static final Logger logger = Logger.getLogger(HumanPlayer.class); private static final Logger logger = Logger.getLogger(HumanPlayer.class);
protected HashSet<String> autoSelectReplacementEffects = new HashSet<>(); protected HashSet<String> autoSelectReplacementEffects = new HashSet<>();
@ -119,9 +118,26 @@ public class HumanPlayer extends PlayerImpl {
public HumanPlayer(final HumanPlayer player) { public HumanPlayer(final HumanPlayer player) {
super(player); super(player);
this.replacementEffectChoice = player.replacementEffectChoice;
this.autoSelectReplacementEffects.addAll(autoSelectReplacementEffects); this.autoSelectReplacementEffects.addAll(autoSelectReplacementEffects);
this.currentlyUnpaidMana = player.currentlyUnpaidMana; this.currentlyUnpaidMana = player.currentlyUnpaidMana;
this.replacementEffectChoice = player.replacementEffectChoice;
this.triggerAutoOrderAbilityFirst.addAll(player.triggerAutoOrderAbilityFirst);
this.triggerAutoOrderAbilityLast.addAll(player.triggerAutoOrderAbilityLast);
this.triggerAutoOrderNameFirst.addAll(player.triggerAutoOrderNameFirst);
this.triggerAutoOrderNameLast.addAll(player.triggerAutoOrderNameLast);
this.requestAutoAnswerId.putAll(player.requestAutoAnswerId);
this.requestAutoAnswerText.putAll(player.requestAutoAnswerText);
this.holdingPriority = player.holdingPriority;
this.actionQueue.addAll(player.actionQueue);
this.actionQueueSaved.addAll(player.actionQueueSaved);
this.actionIterations = player.actionIterations;
this.recordingMacro = player.recordingMacro;
this.macroTriggeredSelectionFlag = player.macroTriggeredSelectionFlag;
this.activatingMacro = player.activatingMacro;
} }
protected boolean isExecutingMacro() { protected boolean isExecutingMacro() {
@ -134,6 +150,7 @@ public class HumanPlayer extends PlayerImpl {
if (actionQueue.isEmpty() && actionIterations > 0 && !actionQueueSaved.isEmpty()) { if (actionQueue.isEmpty() && actionIterations > 0 && !actionQueueSaved.isEmpty()) {
actionQueue = new LinkedList(actionQueueSaved); actionQueue = new LinkedList(actionQueueSaved);
actionIterations--; actionIterations--;
// logger.info("MACRO iteration: " + actionIterations);
} }
PlayerResponse action = actionQueue.poll(); PlayerResponse action = actionQueue.poll();
if (action != null) { if (action != null) {
@ -158,6 +175,11 @@ public class HumanPlayer extends PlayerImpl {
protected void waitForResponse(Game game) { protected void waitForResponse(Game game) {
if (isExecutingMacro()) { if (isExecutingMacro()) {
pullResponseFromQueue(game); pullResponseFromQueue(game);
// logger.info("MACRO pull from queue: " + response.toString());
// try {
// TimeUnit.MILLISECONDS.sleep(1000);
// } catch (InterruptedException e) {
// }
return; return;
} }
response.clear(); response.clear();
@ -166,7 +188,7 @@ public class HumanPlayer extends PlayerImpl {
synchronized (response) { synchronized (response) {
try { try {
response.wait(); response.wait();
logger.debug("Got response from player: " + getId()); logger.info("Got response from player: " + response.toString());
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
logger.error("Response error for player " + getName() + " gameId: " + game.getId(), ex); logger.error("Response error for player " + getName() + " gameId: " + game.getId(), ex);
} finally { } finally {
@ -174,7 +196,7 @@ public class HumanPlayer extends PlayerImpl {
} }
} }
if (recordingMacro && !macroTriggeredSelectionFlag) { if (recordingMacro && !macroTriggeredSelectionFlag) {
logger.debug("Adding an action " + response); // logger.info("Adding an action " + response);
actionQueueSaved.add(new PlayerResponse(response)); actionQueueSaved.add(new PlayerResponse(response));
} }
} }

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.player.human; package mage.player.human;
import java.io.Serializable; import java.io.Serializable;
@ -49,18 +48,14 @@ public class PlayerResponse implements Serializable {
clear(); clear();
} }
@Override
public String toString() { public String toString() {
return new StringBuilder((responseString == null) ? "null" : responseString) return ((responseString == null) ? "null" : responseString)
.append(',') + ',' + responseUUID
.append(responseUUID) + ',' + responseBoolean
.append(',') + ',' + responseInteger
.append(responseBoolean) + ',' + responseManaType
.append(',') + ',' + responseManaTypePlayerId;
.append(responseInteger)
.append(',')
.append(responseManaType)
.append(',')
.append(responseManaTypePlayerId).toString();
} }
public PlayerResponse(PlayerResponse other) { public PlayerResponse(PlayerResponse other) {