rewrites to optionals

This commit is contained in:
ingmargoudt 2017-03-19 19:48:00 +01:00
parent 348faa345b
commit ff6c6405aa
28 changed files with 760 additions and 494 deletions

View file

@ -80,6 +80,7 @@ import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import mage.cards.Card;
import mage.cards.action.ActionCallback;
import mage.choices.Choice;
@ -99,7 +100,9 @@ import mage.client.dialog.PickChoiceDialog;
import mage.client.dialog.PickNumberDialog;
import mage.client.dialog.PickPileDialog;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.*;
import mage.client.dialog.ShowCardsDialog;
import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.adapters.MageActionCallback;
@ -116,11 +119,13 @@ import mage.constants.Constants;
import mage.constants.EnlargeMode;
import mage.constants.PhaseStep;
import mage.constants.PlayerAction;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_FIRST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
import mage.constants.Zone;
import mage.game.events.PlayerQueryEvent;
import mage.view.AbilityPickerView;
@ -139,7 +144,6 @@ import org.mage.card.arcane.CardPanel;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
/**
*
* @author BetaSteward_at_googlemail.com, nantuko8
*/
public final class GamePanel extends javax.swing.JPanel {
@ -194,6 +198,7 @@ public final class GamePanel extends javax.swing.JPanel {
TRIGGER_ORDER
}
// CardView popupMenu was invoked last
private CardView cardViewPopupMenu;
@ -497,7 +502,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.pnlReplay.setVisible(false);
this.gameChatPanel.clear();
this.gameChatPanel.connect(SessionHandler.getGameChatId(gameId));
SessionHandler.getGameChatId(gameId).ifPresent(uuid -> this.gameChatPanel.connect(uuid));
if (!SessionHandler.joinGame(gameId)) {
removeGame();
} else {
@ -529,7 +534,8 @@ public final class GamePanel extends javax.swing.JPanel {
this.pnlReplay.setVisible(false);
this.gameChatPanel.clear();
this.gameChatPanel.connect(SessionHandler.getGameChatId(gameId));
SessionHandler.getGameChatId(gameId).ifPresent(uuid ->
this.gameChatPanel.connect(uuid));
if (!SessionHandler.watchGame(gameId)) {
removeGame();
}
@ -1770,24 +1776,24 @@ public final class GamePanel extends javax.swing.JPanel {
pnlReplay.setLayout(gl_pnlReplay);
gl_pnlReplay.setHorizontalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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)
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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)
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
);
gl_pnlReplay.setVerticalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
);
// Game info panel (buttons on the right panel)
@ -1861,8 +1867,8 @@ public final class GamePanel extends javax.swing.JPanel {
}
};
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"Main2", "Cleanup", "Next_Turn"};
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"Main2", "Cleanup", "Next_Turn"};
for (String name : phases) {
createPhaseButton(name, phasesMouseAdapter);
}
@ -1899,46 +1905,46 @@ public final class GamePanel extends javax.swing.JPanel {
javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea);
gl_helperHandButtonsStackArea.setHorizontalGroup(
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
// .addGap(0)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
// .addGap(0)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(helper, 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)
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
)
)
.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)
)))
.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.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.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()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, 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)
//.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()
.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);
@ -1971,11 +1977,11 @@ public final class GamePanel extends javax.swing.JPanel {
this.setLayout(layout);
layout.setHorizontalGroup(
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.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)
);
}
@ -2353,7 +2359,7 @@ public final class GamePanel extends javax.swing.JPanel {
private mage.client.components.ability.AbilityPicker abilityPicker;
private mage.client.cards.BigCard bigCard;
// private JPanel cancelSkipPanel;
// private JPanel cancelSkipPanel;
private KeyboundButton btnCancelSkip;
private KeyboundButton btnSkipToNextTurn; // F4
private KeyboundButton btnSkipToEndTurn; // F5