mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Huge update to the GUI codebase.
- Make match screen in gui-desktop non-singleton, allowing multiple games to be played simultaneously. - Separate global gui commands (IGuiBase) from game-specific gui commands (IGuiGame), allowing games to send their commands to the correct gui.
This commit is contained in:
@@ -6,8 +6,10 @@ import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,24 +24,19 @@ import com.google.common.base.Function;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.control.GuiTimer;
|
||||
import forge.deck.CardPool;
|
||||
import forge.download.GuiDownloadService;
|
||||
import forge.download.GuiDownloader;
|
||||
import forge.error.BugReportDialog;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.DelayedReveal;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.gui.BoxedProductCardListViewer;
|
||||
import forge.gui.CardListViewer;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.interfaces.IGuiGame;
|
||||
import forge.interfaces.IGuiTimer;
|
||||
import forge.item.PaperCard;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.model.FModel;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.screens.deckeditor.controllers.CEditorQuestCardShop;
|
||||
import forge.screens.match.CMatchUI;
|
||||
@@ -53,9 +50,7 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.util.BuildInfo;
|
||||
import forge.util.Callback;
|
||||
import forge.util.FCollectionView;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
|
||||
public class GuiDesktop implements IGuiBase {
|
||||
@Override
|
||||
@@ -153,19 +148,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
return FOptionPane.showOptionDialog(message, title, icon == null ? null : FSkin.getImage(icon), options, defaultOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showCardOptionDialog(final CardView card, String message, String title, FSkinProp skinIcon, String[] options, int defaultOption) {
|
||||
if (card != null) {
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiBase.getInterface().setCard(card);
|
||||
}
|
||||
});
|
||||
}
|
||||
return showOptionDialog(message, title, skinIcon, options, defaultOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String showInputDialog(String message, String title, FSkinProp icon, String initialInput, String[] inputOptions) {
|
||||
return FOptionPane.showInputDialog(message, title, icon == null ? null : FSkin.getImage(icon), initialInput, inputOptions);
|
||||
@@ -182,31 +164,13 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
final List<T> sourceChoices, final List<T> destChoices) {
|
||||
/*if ((sourceChoices != null && !sourceChoices.isEmpty() && sourceChoices.iterator().next() instanceof GameObject)
|
||||
|| (destChoices != null && !destChoices.isEmpty() && destChoices.iterator().next() instanceof GameObject)) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}*/
|
||||
return GuiChoose.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperCard> sideboard(CardPool sideboard, CardPool main) {
|
||||
return GuiChoose.sideboard(sideboard.toFlatList(), main.toFlatList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameEntityView chooseSingleEntityForEffect(String title, FCollectionView<? extends GameEntity> optionList, DelayedReveal delayedReveal, boolean isOptional, PlayerControllerHuman controller) {
|
||||
if (delayedReveal != null) {
|
||||
delayedReveal.reveal(controller); //TODO: Merge this into search dialog
|
||||
}
|
||||
controller.tempShow(optionList);
|
||||
List<GameEntityView> gameEntityViews = GameEntityView.getEntityCollection(optionList);
|
||||
if (isOptional) {
|
||||
return SGuiChoose.oneOrNone(title, gameEntityViews);
|
||||
}
|
||||
return SGuiChoose.one(title, gameEntityViews);
|
||||
return GuiChoose.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,12 +196,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCard(final CardView card) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String showFileDialog(String title, String defaultDir) {
|
||||
final JFileChooser fc = new JFileChooser(defaultDir);
|
||||
@@ -273,7 +231,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void browseToUrl(String url) throws Exception {
|
||||
public void browseToUrl(String url) throws IOException, URISyntaxException {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
}
|
||||
|
||||
@@ -310,8 +268,12 @@ public class GuiDesktop implements IGuiBase {
|
||||
Singletons.getView().getFrame().validate();
|
||||
}
|
||||
|
||||
public IGuiGame getNewGuiGame() {
|
||||
return new CMatchUI();
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi) {
|
||||
CMatchUI.SINGLETON_INSTANCE.avatarImages.put(player.getName(), ihi.getIconImageKey());
|
||||
public HostedMatch hostMatch() {
|
||||
return new HostedMatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,8 @@ import com.mortennobel.imagescaling.ResampleOp;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -83,8 +83,8 @@ public class ImageCache {
|
||||
* retrieve an image from the cache. returns null if the image is not found in the cache
|
||||
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
|
||||
*/
|
||||
public static BufferedImage getImage(final CardView card, final int width, final int height) {
|
||||
final String key = MatchUtil.getCardImageKey(card.getCurrentState());
|
||||
public static BufferedImage getImage(final CardView card, final PlayerView viewer, final int width, final int height) {
|
||||
final String key = card.getCurrentState().getImageKey(viewer);
|
||||
return scaleImage(key, width, height, true);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ImageCache {
|
||||
public static BufferedImage getImage(InventoryItem ii, int width, int height) {
|
||||
return scaleImage(ImageKeys.getImageKey(ii, false), width, height, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* retrieve an icon from the cache. returns the current skin's ICO_UNKNOWN if the icon image is not found
|
||||
* in the cache and cannot be loaded from disk.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.control;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.KeyEventDispatcher;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
@@ -33,11 +34,12 @@ import javax.swing.JLayeredPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.control.KeyboardShortcuts.Shortcut;
|
||||
import forge.gui.GuiDialog;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
@@ -45,7 +47,7 @@ import forge.gui.framework.InvalidLayoutFileException;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
import forge.gui.framework.SOverflowUtil;
|
||||
import forge.gui.framework.SResizingUtil;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.menus.ForgeMenu;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
@@ -55,7 +57,6 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.io.QuestDataIO;
|
||||
import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.FFrame;
|
||||
@@ -73,16 +74,16 @@ public enum FControl implements KeyEventDispatcher {
|
||||
instance;
|
||||
|
||||
private ForgeMenu forgeMenu;
|
||||
private List<Shortcut> shortcuts;
|
||||
private JLayeredPane display;
|
||||
private FScreen currentScreen;
|
||||
private boolean altKeyLastDown;
|
||||
private CloseAction closeAction;
|
||||
private List<HostedMatch> currentMatches = Lists.newArrayList();
|
||||
|
||||
public static enum CloseAction {
|
||||
NONE,
|
||||
CLOSE_SCREEN,
|
||||
EXIT_FORGE
|
||||
EXIT_FORGE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,10 +152,10 @@ public enum FControl implements KeyEventDispatcher {
|
||||
public boolean canExitForge(boolean forRestart) {
|
||||
String action = (forRestart ? "Restart" : "Exit");
|
||||
String userPrompt = "Are you sure you wish to " + (forRestart ? "restart" : "exit") + " Forge?";
|
||||
if (MatchUtil.getGame() != null) {
|
||||
if (!currentMatches.isEmpty()) {
|
||||
userPrompt = "A game is currently active. " + userPrompt;
|
||||
}
|
||||
if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, "Cancel", MatchUtil.getGame() == null)) { //default Yes if no game active
|
||||
if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, "Cancel", currentMatches.isEmpty())) { //default Yes if no game active
|
||||
return false;
|
||||
}
|
||||
if (!CDeckEditorUI.SINGLETON_INSTANCE.canSwitchAway(true)) {
|
||||
@@ -174,12 +175,9 @@ public enum FControl implements KeyEventDispatcher {
|
||||
|
||||
/** After view and model have been initialized, control can start.*/
|
||||
public void initialize() {
|
||||
MatchUtil.setController(CMatchUI.SINGLETON_INSTANCE);
|
||||
|
||||
// Preloads skin components (using progress bar).
|
||||
FSkin.loadFull(true);
|
||||
|
||||
shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
|
||||
display = FView.SINGLETON_INSTANCE.getLpnDocument();
|
||||
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
@@ -227,7 +225,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
|
||||
private void setGlobalKeyboardHandler() {
|
||||
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
manager.addKeyEventDispatcher(this);
|
||||
}
|
||||
|
||||
@@ -245,10 +243,10 @@ public enum FControl implements KeyEventDispatcher {
|
||||
/**
|
||||
* Switches between display screens in top level JFrame.
|
||||
*/
|
||||
public boolean setCurrentScreen(FScreen screen) {
|
||||
public boolean setCurrentScreen(final FScreen screen) {
|
||||
return setCurrentScreen(screen, false);
|
||||
}
|
||||
public boolean setCurrentScreen(FScreen screen, boolean previousScreenClosed) {
|
||||
public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) {
|
||||
//TODO: Uncomment the line below if this function stops being used to refresh
|
||||
//the current screen in some places (such as Continue and Restart in the match screen)
|
||||
//if (currentScreen == screen) { return; }
|
||||
@@ -258,8 +256,8 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentScreen == FScreen.MATCH_SCREEN) { //hide targeting overlay and reset image if was on match screen
|
||||
SOverlayUtils.hideTargetingOverlay();
|
||||
if (currentScreen != null && currentScreen.isMatchScreen()) { //hide targeting overlay and reset image if was on match screen
|
||||
//SOverlayUtils.hideTargetingOverlay();
|
||||
if (isMatchBackgroundImageVisible()) {
|
||||
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage(new ImageIcon());
|
||||
}
|
||||
@@ -272,6 +270,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
currentScreen = screen;
|
||||
|
||||
//load layout for new current screen
|
||||
screen.getController().register();
|
||||
try {
|
||||
SLayoutIO.loadLayout(null);
|
||||
} catch (InvalidLayoutFileException ex) {
|
||||
@@ -281,14 +280,14 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
screen.getView().populate();
|
||||
screen.getController().initialize();
|
||||
screen.getView().populate();
|
||||
|
||||
if (screen == FScreen.MATCH_SCREEN) {
|
||||
if (screen.isMatchScreen()) {
|
||||
if (isMatchBackgroundImageVisible()) {
|
||||
FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage(FSkin.getIcon(FSkinProp.BG_MATCH));
|
||||
}
|
||||
SOverlayUtils.showTargetingOverlay();
|
||||
//SOverlayUtils.showTargetingOverlay();
|
||||
}
|
||||
|
||||
Singletons.getView().getNavigationBar().updateSelectedTab();
|
||||
@@ -305,11 +304,6 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return setCurrentScreen(screen);
|
||||
}
|
||||
|
||||
/** @return List<Shortcut> A list of attached keyboard shortcut descriptions and properties. */
|
||||
public List<Shortcut> getShortcuts() {
|
||||
return shortcuts;
|
||||
}
|
||||
|
||||
/** Remove all children from a specified layer. */
|
||||
private void clearChildren(final int layer0) {
|
||||
final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument().getComponentsInLayer(layer0);
|
||||
@@ -331,6 +325,10 @@ public enum FControl implements KeyEventDispatcher {
|
||||
if (children.length != 0) { children[0].setSize(display.getSize()); }
|
||||
}
|
||||
|
||||
public Dimension getDisplaySize() {
|
||||
return display.getSize();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent)
|
||||
*/
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
package forge.control;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.home.settings.VSubmenuPreferences.KeyboardShortcutField;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -22,6 +7,24 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ActionMap;
|
||||
import javax.swing.InputMap;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.home.settings.VSubmenuPreferences.KeyboardShortcutField;
|
||||
import forge.screens.match.CMatchUI;
|
||||
|
||||
/**
|
||||
* Consolidates keyboard shortcut assembly into one location
|
||||
* for all shortcuts in the project.
|
||||
@@ -30,6 +33,11 @@ import java.util.List;
|
||||
* and you're done.
|
||||
*/
|
||||
public class KeyboardShortcuts {
|
||||
|
||||
public static List<Shortcut> getKeyboardShortcuts() {
|
||||
return attachKeyboardShortcuts(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches all keyboard shortcuts for match UI,
|
||||
* and returns a list of shortcuts with necessary properties for later access.
|
||||
@@ -37,19 +45,19 @@ public class KeyboardShortcuts {
|
||||
* @return List<Shortcut> Shortcut objects
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static List<Shortcut> attachKeyboardShortcuts() {
|
||||
public static List<Shortcut> attachKeyboardShortcuts(final CMatchUI matchUI) {
|
||||
final JComponent c = Singletons.getView().getFrame().getLayeredPane();
|
||||
final InputMap im = c.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
final ActionMap am = c.getActionMap();
|
||||
|
||||
List<Shortcut> list = new ArrayList<Shortcut>();
|
||||
final List<Shortcut> list = new ArrayList<Shortcut>();
|
||||
|
||||
//========== Match Shortcuts
|
||||
/** Show stack. */
|
||||
final Action actShowStack = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
}
|
||||
};
|
||||
@@ -58,7 +66,7 @@ public class KeyboardShortcuts {
|
||||
final Action actShowCombat = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
SDisplayUtil.showTab(EDocID.REPORT_COMBAT.getDoc());
|
||||
}
|
||||
};
|
||||
@@ -67,7 +75,7 @@ public class KeyboardShortcuts {
|
||||
final Action actShowConsole = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||
}
|
||||
};
|
||||
@@ -76,7 +84,7 @@ public class KeyboardShortcuts {
|
||||
final Action actShowPlayers = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
SDisplayUtil.showTab(EDocID.REPORT_PLAYERS.getDoc());
|
||||
}
|
||||
};
|
||||
@@ -85,7 +93,7 @@ public class KeyboardShortcuts {
|
||||
final Action actShowDev = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
if (ForgePreferences.DEV_MODE) {
|
||||
SDisplayUtil.showTab(EDocID.DEV_MODE.getDoc());
|
||||
}
|
||||
@@ -96,8 +104,9 @@ public class KeyboardShortcuts {
|
||||
final Action actConcede = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
MatchUtil.concede();
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
if (matchUI == null) { return; }
|
||||
matchUI.getGameController().concede();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,8 +114,9 @@ public class KeyboardShortcuts {
|
||||
final Action actEndTurn = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
CDock.SINGLETON_INSTANCE.endTurn();
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
if (matchUI == null) { return; }
|
||||
matchUI.getGameController().passPriorityUntilEndOfTurn();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,8 +124,9 @@ public class KeyboardShortcuts {
|
||||
final Action actAllAttack = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
MatchUtil.alphaStrike();
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
if (matchUI == null) { return; }
|
||||
matchUI.getGameController().alphaStrike();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -123,8 +134,9 @@ public class KeyboardShortcuts {
|
||||
final Action actTgtOverlay = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
CDock.SINGLETON_INSTANCE.toggleTargeting();
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||
if (matchUI == null) { return; }
|
||||
matchUI.getCDock().toggleTargeting();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import forge.quest.QuestController;
|
||||
import forge.quest.QuestEvent;
|
||||
import forge.quest.QuestEventChallenge;
|
||||
import forge.quest.QuestUtil;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -42,7 +43,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
private NetDeckCategory netDeckCategory;
|
||||
private boolean refreshingDeckType;
|
||||
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Constructed);
|
||||
private final DeckManager lstDecks;
|
||||
private final FLabel btnViewDeck = new FLabel.ButtonBuilder().text("View Deck").fontSize(14).build();
|
||||
private final FLabel btnRandom = new FLabel.ButtonBuilder().fontSize(14).build();
|
||||
|
||||
@@ -52,9 +53,9 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
private FPref stateSetting = null;
|
||||
|
||||
//Show dialog to select a deck
|
||||
public static Deck promptForDeck(String title, DeckType defaultDeckType, boolean forAi) {
|
||||
public static Deck promptForDeck(final CDetailPicture cDetailPicture, final String title, final DeckType defaultDeckType, final boolean forAi) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
final FDeckChooser chooser = new FDeckChooser(forAi);
|
||||
final FDeckChooser chooser = new FDeckChooser(cDetailPicture, forAi);
|
||||
chooser.initialize(defaultDeckType);
|
||||
chooser.populate();
|
||||
Dimension parentSize = JOptionPane.getRootFrame().getSize();
|
||||
@@ -76,7 +77,8 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return null;
|
||||
}
|
||||
|
||||
public FDeckChooser(boolean forAi) {
|
||||
public FDeckChooser(final CDetailPicture cDetailPicture, final boolean forAi) {
|
||||
lstDecks = new DeckManager(GameType.Constructed, cDetailPicture);
|
||||
setOpaque(false);
|
||||
isAi = forAi;
|
||||
UiCommand cmdViewDeck = new UiCommand() {
|
||||
|
||||
@@ -47,15 +47,15 @@ public class FDeckViewer extends FDialog {
|
||||
public static void show(final Deck deck) {
|
||||
if (deck == null) { return; }
|
||||
|
||||
FDeckViewer deckViewer = new FDeckViewer(deck);
|
||||
final FDeckViewer deckViewer = new FDeckViewer(deck);
|
||||
deckViewer.setVisible(true);
|
||||
deckViewer.dispose();
|
||||
}
|
||||
|
||||
private FDeckViewer(Deck deck0) {
|
||||
private FDeckViewer(final Deck deck0) {
|
||||
this.deck = deck0;
|
||||
this.setTitle(deck.getName());
|
||||
this.cardManager = new CardManager(false) {
|
||||
this.cardManager = new CardManager(null, false) {
|
||||
@Override //show hovered card in Image View in dialog instead of main Detail/Picture panes
|
||||
protected ImageView<PaperCard> createImageView(final ItemManagerModel<PaperCard> model0) {
|
||||
return new ImageView<PaperCard>(this, model0) {
|
||||
|
||||
@@ -31,16 +31,15 @@ import javax.swing.border.EmptyBorder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRarity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.toolbox.FHtmlViewer;
|
||||
import forge.toolbox.FLabel;
|
||||
@@ -189,7 +188,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canShow = MatchUtil.canCardBeShown(card);
|
||||
boolean canShow = true;
|
||||
|
||||
if (state.getManaCost().isNoCost() || !canShow) {
|
||||
nameCostLabel.setText(CardDetailUtil.formatCardName(card, canShow, isInAltState));
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class CardPicturePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage getImage() {
|
||||
private BufferedImage getImage() {
|
||||
if (displayed instanceof InventoryItem) {
|
||||
final InventoryItem item = (InventoryItem) displayed;
|
||||
return ImageCache.getOriginalImage(ImageKeys.getImageKey(item, false), true);
|
||||
|
||||
@@ -69,11 +69,11 @@ public class DualListBox<T> extends FDialog {
|
||||
private boolean sideboardingMode = false;
|
||||
private boolean showCard = true;
|
||||
|
||||
public DualListBox(int remainingSources, List<T> sourceElements, List<T> destElements) {
|
||||
this(remainingSources, remainingSources, sourceElements, destElements);
|
||||
}
|
||||
|
||||
public DualListBox(int remainingSourcesMin, int remainingSourcesMax, List<T> sourceElements, List<T> destElements) {
|
||||
private final CMatchUI matchUI;
|
||||
|
||||
public DualListBox(final int remainingSourcesMin, final int remainingSourcesMax, final List<T> sourceElements, final List<T> destElements, final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
|
||||
targetRemainingSourcesMin = remainingSourcesMin;
|
||||
targetRemainingSourcesMax = remainingSourcesMax;
|
||||
sourceListModel = new UnsortedListModel<T>();
|
||||
@@ -152,15 +152,15 @@ public class DualListBox<T> extends FDialog {
|
||||
autoButton = new FButton("Auto");
|
||||
autoButton.addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { _addAll(); _finish(); } });
|
||||
|
||||
FPanel leftPanel = new FPanel(new BorderLayout());
|
||||
final FPanel leftPanel = new FPanel(new BorderLayout());
|
||||
selectOrder = new FLabel.Builder().text("Select Order:").build();
|
||||
leftPanel.add(selectOrder, BorderLayout.NORTH);
|
||||
leftPanel.add(new FScrollPane(sourceList, true), BorderLayout.CENTER);
|
||||
leftPanel.add(okButton, BorderLayout.SOUTH);
|
||||
|
||||
FPanel centerPanel = new FPanel(new GridLayout(6, 1));
|
||||
final FPanel centerPanel = new FPanel(new GridLayout(6, 1));
|
||||
centerPanel.setBorderToggle(false);
|
||||
JPanel emptyPanel = new JPanel();
|
||||
final JPanel emptyPanel = new JPanel();
|
||||
emptyPanel.setOpaque(false);
|
||||
centerPanel.add(emptyPanel); // empty panel to take up the first slot
|
||||
centerPanel.add(addButton);
|
||||
@@ -170,7 +170,7 @@ public class DualListBox<T> extends FDialog {
|
||||
|
||||
orderedLabel = new FLabel.Builder().build();
|
||||
|
||||
FPanel rightPanel = new FPanel(new BorderLayout());
|
||||
final FPanel rightPanel = new FPanel(new BorderLayout());
|
||||
rightPanel.add(orderedLabel, BorderLayout.NORTH);
|
||||
rightPanel.add(new FScrollPane(destList, true), BorderLayout.CENTER);
|
||||
rightPanel.add(autoButton, BorderLayout.SOUTH);
|
||||
@@ -337,10 +337,12 @@ public class DualListBox<T> extends FDialog {
|
||||
card = Card.getCardForUi((IPaperCard) obj).getView();
|
||||
}
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
if (card != null) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
||||
GuiUtils.setPanelSelection(card);
|
||||
if (matchUI != null) {
|
||||
matchUI.clearPanelSelections();
|
||||
if (card != null) {
|
||||
matchUI.setCard(card);
|
||||
matchUI.setPanelSelection(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,9 @@ public class GuiChoose {
|
||||
}
|
||||
|
||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display) {
|
||||
return getChoices(message, min, max, choices, selected, display, null);
|
||||
}
|
||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display, final CMatchUI matchUI) {
|
||||
if (choices == null || choices.isEmpty()) {
|
||||
if (min == 0) {
|
||||
return new ArrayList<T>();
|
||||
@@ -195,36 +198,38 @@ public class GuiChoose {
|
||||
throw new RuntimeException("choice required from empty list");
|
||||
}
|
||||
|
||||
Callable<List<T>> showChoice = new Callable<List<T>>() {
|
||||
final Callable<List<T>> showChoice = new Callable<List<T>>() {
|
||||
@Override
|
||||
public List<T> call() {
|
||||
ListChooser<T> c = new ListChooser<T>(message, min, max, choices, display);
|
||||
final JList<T> list = c.getLstChoices();
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(final ListSelectionEvent ev) {
|
||||
final T sel = list.getSelectedValue();
|
||||
if (sel instanceof InventoryItem) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard((InventoryItem) list.getSelectedValue());
|
||||
return;
|
||||
}
|
||||
if (matchUI != null) {
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(final ListSelectionEvent ev) {
|
||||
final T sel = list.getSelectedValue();
|
||||
if (sel instanceof InventoryItem) {
|
||||
matchUI.setCard((InventoryItem) list.getSelectedValue());
|
||||
return;
|
||||
}
|
||||
|
||||
final CardView card;
|
||||
if (sel instanceof CardStateView) {
|
||||
card = ((CardStateView) sel).getCard();
|
||||
} else if (sel instanceof CardView) {
|
||||
card = (CardView) sel;
|
||||
} else {
|
||||
card = null;
|
||||
}
|
||||
if (card != null) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
||||
final CardView card;
|
||||
if (sel instanceof CardStateView) {
|
||||
card = ((CardStateView) sel).getCard();
|
||||
} else if (sel instanceof CardView) {
|
||||
card = (CardView) sel;
|
||||
} else {
|
||||
card = null;
|
||||
}
|
||||
if (card != null) {
|
||||
matchUI.setCard(card);
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
GuiUtils.setPanelSelection(card);
|
||||
matchUI.clearPanelSelections();
|
||||
matchUI.setPanelSelection(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (selected != null) {
|
||||
c.show(selected);
|
||||
@@ -233,7 +238,9 @@ public class GuiChoose {
|
||||
c.show();
|
||||
}
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
if (matchUI != null) {
|
||||
matchUI.clearPanelSelections();
|
||||
}
|
||||
return c.getSelectedValues();
|
||||
}
|
||||
};
|
||||
@@ -248,34 +255,28 @@ public class GuiChoose {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> many(final String title, final String topCaption, int cnt, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return order(title, topCaption, cnt, cnt, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T> List<T> many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
int m2 = min >= 0 ? sourceChoices.size() - min : -1;
|
||||
int m1 = max >= 0 ? sourceChoices.size() - max : -1;
|
||||
return order(title, topCaption, m1, m2, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T> List<T> order(final String title, final String top, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return order(title, top, 0, 0, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T extends Comparable<? super T>> List<T> sideboard(List<T> sideboard, List<T> deck) {
|
||||
public static <T extends Comparable<? super T>> List<T> sideboard(final CMatchUI matchUI, final List<T> sideboard, final List<T> deck) {
|
||||
Collections.sort(deck);
|
||||
Collections.sort(sideboard);
|
||||
return order("Sideboard", "Main Deck", -1, -1, sideboard, deck, null, true);
|
||||
}
|
||||
|
||||
public static <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices) {
|
||||
return order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, null, false, null);
|
||||
}
|
||||
public static <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
return order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode, null);
|
||||
}
|
||||
public static <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode, final CMatchUI matchUI) {
|
||||
// An input box for handling the order of choices.
|
||||
|
||||
Callable<List<T>> callable = new Callable<List<T>>() {
|
||||
@Override
|
||||
public List<T> call() throws Exception {
|
||||
DualListBox<T> dual = new DualListBox<T>(remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices);
|
||||
DualListBox<T> dual = new DualListBox<T>(remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, matchUI);
|
||||
dual.setSecondColumnLabelText(top);
|
||||
|
||||
dual.setSideboardMode(sideboardingMode);
|
||||
@@ -283,8 +284,8 @@ public class GuiChoose {
|
||||
dual.setTitle(title);
|
||||
dual.pack();
|
||||
dual.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
if (referenceCard != null) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(referenceCard);
|
||||
if (matchUI != null && referenceCard != null) {
|
||||
matchUI.setCard(referenceCard);
|
||||
// MARKED FOR UPDATE
|
||||
}
|
||||
dual.setVisible(true);
|
||||
@@ -292,7 +293,9 @@ public class GuiChoose {
|
||||
List<T> objects = dual.getOrderedList();
|
||||
|
||||
dual.dispose();
|
||||
GuiUtils.clearPanelSelections();
|
||||
if (matchUI != null) {
|
||||
matchUI.clearPanelSelections();
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,21 +20,24 @@ public class GuiDialog {
|
||||
private static final String[] defaultConfirmOptions = { "Yes", "No" };
|
||||
|
||||
public static boolean confirm(final CardView c, final String question) {
|
||||
return GuiDialog.confirm(c, question, true, null);
|
||||
return confirm(c, question, true, null);
|
||||
}
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultChoice) {
|
||||
return GuiDialog.confirm(c, question, defaultChoice, null);
|
||||
return confirm(c, question, defaultChoice, null);
|
||||
}
|
||||
public static boolean confirm(final CardView c, final String question, String[] options) {
|
||||
return GuiDialog.confirm(c, question, true, options);
|
||||
return confirm(c, question, true, options);
|
||||
}
|
||||
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||
return confirm(c, question, defaultIsYes, options, null);
|
||||
}
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options, final CMatchUI matchUI) {
|
||||
Callable<Boolean> confirmTask = new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
if (c != null) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(c);
|
||||
if (matchUI != null && c != null) {
|
||||
matchUI.setCard(c);
|
||||
}
|
||||
|
||||
final String title = c == null ? "Question" : c + " - Ability";
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
@@ -32,11 +31,6 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import forge.game.card.CardView;
|
||||
import forge.screens.match.VMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* GuiUtils class.
|
||||
@@ -72,37 +66,6 @@ public final class GuiUtils {
|
||||
return ttf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all visually highlighted card panels on the battlefield.
|
||||
*/
|
||||
public static void clearPanelSelections() {
|
||||
List<VField> view = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||
for (VField v : view) {
|
||||
for (CardPanel p : v.getTabletop().getCardPanels()) {
|
||||
p.setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight a card on the playfield.
|
||||
*
|
||||
* @param card
|
||||
* a card to be highlighted
|
||||
*/
|
||||
public static void setPanelSelection(final CardView card) {
|
||||
mainLoop:
|
||||
for (final VField v : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
final List<CardPanel> panels = v.getTabletop().getCardPanels();
|
||||
for (final CardPanel p : panels) {
|
||||
if (p.getCard().equals(card)) {
|
||||
p.setSelected(true);
|
||||
break mainLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int minItemWidth = 100;
|
||||
private static final int itemHeight = 25;
|
||||
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
package forge.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.FocusManager;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.screens.match.TargetingOverlay;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedButton;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.FocusManager;
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* All overlay interaction is handled here.
|
||||
@@ -148,14 +151,4 @@ public final class SOverlayUtils {
|
||||
_overlayHasFocus = false;
|
||||
}
|
||||
|
||||
public static void showTargetingOverlay() {
|
||||
TargetingOverlay.SINGLETON_INSTANCE.getPanel().setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes child components and closes overlay.
|
||||
*/
|
||||
public static void hideTargetingOverlay() {
|
||||
TargetingOverlay.SINGLETON_INSTANCE.getPanel().setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ public class CEmptyDoc implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -3,13 +3,23 @@
|
||||
*/
|
||||
package forge.gui.framework;
|
||||
|
||||
import forge.screens.deckeditor.views.*;
|
||||
import forge.screens.deckeditor.views.VAllDecks;
|
||||
import forge.screens.deckeditor.views.VCardCatalog;
|
||||
import forge.screens.deckeditor.views.VCurrentDeck;
|
||||
import forge.screens.deckeditor.views.VDeckgen;
|
||||
import forge.screens.deckeditor.views.VProbabilities;
|
||||
import forge.screens.deckeditor.views.VStatistics;
|
||||
import forge.screens.home.gauntlet.VSubmenuGauntletBuild;
|
||||
import forge.screens.home.gauntlet.VSubmenuGauntletContests;
|
||||
import forge.screens.home.gauntlet.VSubmenuGauntletLoad;
|
||||
import forge.screens.home.gauntlet.VSubmenuGauntletQuick;
|
||||
import forge.screens.home.online.VSubmenuOnlineLobby;
|
||||
import forge.screens.home.quest.*;
|
||||
import forge.screens.home.quest.VSubmenuChallenges;
|
||||
import forge.screens.home.quest.VSubmenuDuels;
|
||||
import forge.screens.home.quest.VSubmenuQuestData;
|
||||
import forge.screens.home.quest.VSubmenuQuestDecks;
|
||||
import forge.screens.home.quest.VSubmenuQuestDraft;
|
||||
import forge.screens.home.quest.VSubmenuQuestPrefs;
|
||||
import forge.screens.home.sanctioned.VSubmenuConstructed;
|
||||
import forge.screens.home.sanctioned.VSubmenuDraft;
|
||||
import forge.screens.home.sanctioned.VSubmenuSealed;
|
||||
@@ -19,7 +29,6 @@ import forge.screens.home.settings.VSubmenuAvatars;
|
||||
import forge.screens.home.settings.VSubmenuDownloaders;
|
||||
import forge.screens.home.settings.VSubmenuPreferences;
|
||||
import forge.screens.home.settings.VSubmenuReleaseNotes;
|
||||
import forge.screens.match.views.*;
|
||||
import forge.screens.workshop.views.VCardDesigner;
|
||||
import forge.screens.workshop.views.VCardScript;
|
||||
import forge.screens.workshop.views.VWorkshopCatalog;
|
||||
@@ -31,9 +40,9 @@ import forge.screens.workshop.views.VWorkshopCatalog;
|
||||
* <br><br><i>(E at beginning of class name denotes an enum.)</i>
|
||||
*/
|
||||
public enum EDocID {
|
||||
CARD_PICTURE (VPicture.SINGLETON_INSTANCE),
|
||||
CARD_DETAIL (VDetail.SINGLETON_INSTANCE),
|
||||
CARD_ANTES (VAntes.SINGLETON_INSTANCE),
|
||||
CARD_PICTURE (),
|
||||
CARD_DETAIL (),
|
||||
CARD_ANTES (),
|
||||
|
||||
EDITOR_ALLDECKS (VAllDecks.SINGLETON_INSTANCE),
|
||||
EDITOR_STATISTICS (VStatistics.SINGLETON_INSTANCE),
|
||||
@@ -67,53 +76,63 @@ public enum EDocID {
|
||||
HOME_LOBBY (VSubmenuOnlineLobby.SINGLETON_INSTANCE),
|
||||
HOME_RELEASE_NOTES (VSubmenuReleaseNotes.SINGLETON_INSTANCE),
|
||||
|
||||
REPORT_MESSAGE (VPrompt.SINGLETON_INSTANCE),
|
||||
REPORT_STACK (VStack.SINGLETON_INSTANCE),
|
||||
REPORT_COMBAT (VCombat.SINGLETON_INSTANCE),
|
||||
REPORT_LOG (VLog.SINGLETON_INSTANCE),
|
||||
REPORT_PLAYERS (VPlayers.SINGLETON_INSTANCE),
|
||||
REPORT_MESSAGE (),
|
||||
REPORT_STACK (),
|
||||
REPORT_COMBAT (),
|
||||
REPORT_LOG (),
|
||||
REPORT_PLAYERS (),
|
||||
|
||||
DEV_MODE (VDev.SINGLETON_INSTANCE),
|
||||
BUTTON_DOCK (VDock.SINGLETON_INSTANCE),
|
||||
DEV_MODE (),
|
||||
BUTTON_DOCK (),
|
||||
|
||||
// Non-user battlefields (AI or teammate), use setDoc to register.
|
||||
FIELD_0 (null),
|
||||
FIELD_1 (null),
|
||||
FIELD_2 (null),
|
||||
FIELD_3 (null),
|
||||
FIELD_4 (null),
|
||||
FIELD_5 (null),
|
||||
FIELD_6 (null),
|
||||
FIELD_7 (null),
|
||||
// Battlefields, use setDoc to register.
|
||||
FIELD_0 (),
|
||||
FIELD_1 (),
|
||||
FIELD_2 (),
|
||||
FIELD_3 (),
|
||||
FIELD_4 (),
|
||||
FIELD_5 (),
|
||||
FIELD_6 (),
|
||||
FIELD_7 (),
|
||||
|
||||
// Non-user hands (AI or teammate), use setDoc to register.
|
||||
HAND_0 (null),
|
||||
HAND_1 (null),
|
||||
HAND_2 (null),
|
||||
HAND_3 (null),
|
||||
HAND_4 (null),
|
||||
HAND_5 (null),
|
||||
HAND_6 (null),
|
||||
HAND_7 (null),
|
||||
// Hands, use setDoc to register.
|
||||
HAND_0 (),
|
||||
HAND_1 (),
|
||||
HAND_2 (),
|
||||
HAND_3 (),
|
||||
HAND_4 (),
|
||||
HAND_5 (),
|
||||
HAND_6 (),
|
||||
HAND_7 (),
|
||||
|
||||
COMMAND_0 (null),
|
||||
COMMAND_1 (null),
|
||||
COMMAND_2 (null),
|
||||
COMMAND_3 (null),
|
||||
COMMAND_4 (null),
|
||||
COMMAND_5 (null),
|
||||
COMMAND_6 (null),
|
||||
COMMAND_7 (null);
|
||||
// Command zones, use setDoc to register.
|
||||
COMMAND_0 (),
|
||||
COMMAND_1 (),
|
||||
COMMAND_2 (),
|
||||
COMMAND_3 (),
|
||||
COMMAND_4 (),
|
||||
COMMAND_5 (),
|
||||
COMMAND_6 (),
|
||||
COMMAND_7 ();
|
||||
|
||||
public final static EDocID[] Commands = new EDocID[] {COMMAND_0, COMMAND_1, COMMAND_2, COMMAND_3, COMMAND_4, COMMAND_5, COMMAND_6, COMMAND_7};
|
||||
public final static EDocID[] Fields = new EDocID[] {FIELD_0, FIELD_1, FIELD_2, FIELD_3, FIELD_4, FIELD_5, FIELD_6, FIELD_7};
|
||||
public final static EDocID[] Hands = new EDocID[] {HAND_0, HAND_1, HAND_2, HAND_3, HAND_4, HAND_5, HAND_6, HAND_7};
|
||||
static {
|
||||
for (int i = 0; i < 8; i++) EDocID.Fields[i].setDoc(new VEmptyDoc(EDocID.Fields[i]));
|
||||
for (int i = 0; i < 8; i++) EDocID.Commands[i].setDoc(new VEmptyDoc(EDocID.Commands[i]));
|
||||
for (int i = 0; i < 8; i++) EDocID.Hands[i].setDoc(new VEmptyDoc(EDocID.Hands[i]));
|
||||
}
|
||||
|
||||
// End enum declarations, start enum methods.
|
||||
private IVDoc<? extends ICDoc> vDoc;
|
||||
|
||||
private EDocID() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/** @param doc0   {@link forge.gui.framework.IVDoc} */
|
||||
EDocID(final IVDoc<? extends ICDoc> doc0) {
|
||||
private EDocID(final IVDoc<? extends ICDoc> doc0) {
|
||||
this.vDoc = doc0;
|
||||
}
|
||||
|
||||
@@ -124,7 +143,7 @@ public enum EDocID {
|
||||
|
||||
/** @return {@link forge.gui.framework.IVDoc} */
|
||||
public IVDoc<? extends ICDoc> getDoc() {
|
||||
if (vDoc == null) { throw new NullPointerException("No document found for " + this.name() + "."); }
|
||||
//if (vDoc == null) { throw new NullPointerException("No document found for " + this.name() + "."); }
|
||||
return vDoc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package forge.gui.framework;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.properties.FileLocation;
|
||||
@@ -17,144 +19,152 @@ import forge.screens.workshop.VWorkshopUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
|
||||
import java.io.File;
|
||||
import forge.view.FView;
|
||||
|
||||
/**
|
||||
* Definitions for Forge screens
|
||||
*
|
||||
*/
|
||||
public enum FScreen {
|
||||
HOME_SCREEN(
|
||||
public class FScreen {
|
||||
public static final FScreen HOME_SCREEN = new FScreen(
|
||||
VHomeUI.SINGLETON_INSTANCE,
|
||||
CHomeUI.SINGLETON_INSTANCE,
|
||||
"Home",
|
||||
FSkin.getIcon(FSkinProp.ICO_FAVICON),
|
||||
false,
|
||||
"Exit Forge",
|
||||
null),
|
||||
MATCH_SCREEN(
|
||||
VMatchUI.SINGLETON_INSTANCE,
|
||||
CMatchUI.SINGLETON_INSTANCE,
|
||||
"Game",
|
||||
FSkin.getIcon(FSkinProp.ICO_ALPHASTRIKE), //TODO: Create icon for match screen
|
||||
true,
|
||||
"Concede Game",
|
||||
ForgeConstants.MATCH_LAYOUT_FILE),
|
||||
WORKSHOP_SCREEN(
|
||||
null,
|
||||
false);
|
||||
public static final FScreen WORKSHOP_SCREEN = new FScreen(
|
||||
VWorkshopUI.SINGLETON_INSTANCE,
|
||||
CWorkshopUI.SINGLETON_INSTANCE,
|
||||
"Workshop",
|
||||
FSkin.getIcon(FSkinProp.ICO_SETTINGS), //TODO: Create icon for workshop screen
|
||||
false,
|
||||
"Back to Home",
|
||||
ForgeConstants.WORKSHOP_LAYOUT_FILE),
|
||||
DECK_EDITOR_CONSTRUCTED(
|
||||
ForgeConstants.WORKSHOP_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_CONSTRUCTED = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
false,
|
||||
"Back to Home",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_ARCHENEMY(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_ARCHENEMY = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Scheme Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_COMMANDER(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_COMMANDER = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Commander Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_PLANECHASE(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_PLANECHASE = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Planar Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_VANGUARD(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_VANGUARD = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Vanguard Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_DRAFT(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_DRAFT = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Draft Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_SEALED(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_SEALED = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Sealed Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_QUEST(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_QUEST = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Quest Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DECK_EDITOR_QUEST_TOURNAMENT(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DECK_EDITOR_QUEST_TOURNAMENT = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Quest Tournament Deck Editor",
|
||||
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||
true,
|
||||
"Close Editor",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
QUEST_CARD_SHOP(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen QUEST_CARD_SHOP = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Spell Shop",
|
||||
FSkin.getIcon(FSkinProp.ICO_QUEST_BOOK),
|
||||
true,
|
||||
"Leave Shop",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
DRAFTING_PROCESS(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen DRAFTING_PROCESS = new FScreen(
|
||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||
"Draft",
|
||||
FSkin.getImage(FSkinProp.IMG_ZONE_HAND),
|
||||
true,
|
||||
"Leave Draft",
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE),
|
||||
QUEST_BAZAAR(
|
||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||
false);
|
||||
public static final FScreen QUEST_BAZAAR = new FScreen(
|
||||
VBazaarUI.SINGLETON_INSTANCE,
|
||||
CBazaarUI.SINGLETON_INSTANCE,
|
||||
"Bazaar",
|
||||
FSkin.getIcon(FSkinProp.ICO_QUEST_BOTTLES),
|
||||
true,
|
||||
"Leave Bazaar",
|
||||
null);
|
||||
null,
|
||||
false);
|
||||
|
||||
private final IVTopLevelUI view;
|
||||
private final ICDoc controller;
|
||||
private final String tabCaption;
|
||||
private String tabCaption;
|
||||
private final SkinImage tabIcon;
|
||||
private final boolean allowTabClose;
|
||||
private final String closeButtonTooltip;
|
||||
private final FileLocation layoutFile;
|
||||
|
||||
private FScreen(IVTopLevelUI view0, ICDoc controller0, String tabCaption0, SkinImage tabIcon0, boolean allowTabClose0, String closeButtonTooltip0, FileLocation layoutFile0) {
|
||||
private final boolean isMatch;
|
||||
|
||||
private FScreen(final IVTopLevelUI view0, final ICDoc controller0,
|
||||
final String tabCaption0, final SkinImage tabIcon0,
|
||||
final boolean allowTabClose0, final String closeButtonTooltip0,
|
||||
final FileLocation layoutFile0, final boolean isMatch) {
|
||||
this.view = view0;
|
||||
this.controller = controller0;
|
||||
this.tabCaption = tabCaption0;
|
||||
@@ -162,6 +172,19 @@ public enum FScreen {
|
||||
this.allowTabClose = allowTabClose0;
|
||||
this.closeButtonTooltip = closeButtonTooltip0;
|
||||
this.layoutFile = layoutFile0;
|
||||
this.isMatch = isMatch;
|
||||
}
|
||||
|
||||
public static FScreen getMatchScreen(final CMatchUI controller, final VMatchUI view) {
|
||||
return new FScreen(
|
||||
view,
|
||||
controller,
|
||||
"Game",
|
||||
FSkin.getIcon(FSkinProp.ICO_ALPHASTRIKE), //TODO: Create icon for match screen
|
||||
true,
|
||||
"Concede Game",
|
||||
ForgeConstants.MATCH_LAYOUT_FILE,
|
||||
true);
|
||||
}
|
||||
|
||||
public IVTopLevelUI getView() {
|
||||
@@ -175,23 +198,27 @@ public enum FScreen {
|
||||
public String getTabCaption() {
|
||||
return tabCaption;
|
||||
}
|
||||
|
||||
public void setTabCaption(final String caption) {
|
||||
this.tabCaption = caption;
|
||||
FView.SINGLETON_INSTANCE.getNavigationBar().updateTitle(this);
|
||||
}
|
||||
|
||||
public SkinImage getTabIcon() {
|
||||
return tabIcon;
|
||||
}
|
||||
|
||||
|
||||
public boolean allowTabClose() {
|
||||
return allowTabClose;
|
||||
}
|
||||
|
||||
|
||||
public String getCloseButtonTooltip() {
|
||||
return closeButtonTooltip;
|
||||
}
|
||||
|
||||
|
||||
public boolean onSwitching(FScreen toScreen) {
|
||||
return view.onSwitching(this, toScreen);
|
||||
}
|
||||
|
||||
|
||||
public boolean onClosing() {
|
||||
return view.onClosing(this);
|
||||
}
|
||||
@@ -202,17 +229,22 @@ public enum FScreen {
|
||||
|
||||
public boolean deleteLayoutFile() {
|
||||
if (layoutFile == null) { return false; }
|
||||
|
||||
return deleteLayoutFile(layoutFile);
|
||||
}
|
||||
public static boolean deleteMatchLayoutFile() {
|
||||
return deleteLayoutFile(ForgeConstants.MATCH_LAYOUT_FILE);
|
||||
}
|
||||
private static boolean deleteLayoutFile(final FileLocation file) {
|
||||
try {
|
||||
File file = new File(layoutFile.userPrefLoc);
|
||||
file.delete();
|
||||
File f = new File(file.userPrefLoc);
|
||||
f.delete();
|
||||
return true;
|
||||
}
|
||||
catch (final Exception e) {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
FOptionPane.showErrorDialog("Failed to delete layout file.");
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void open() {
|
||||
@@ -222,4 +254,8 @@ public enum FScreen {
|
||||
public void close() {
|
||||
Singletons.getView().getNavigationBar().closeTab(this);
|
||||
}
|
||||
|
||||
public boolean isMatchScreen() {
|
||||
return isMatch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,33 @@ package forge.gui.framework;
|
||||
import forge.UiCommand;
|
||||
|
||||
/**
|
||||
* Dictates methods required for any controller
|
||||
* of an {@link forge.gui.framework.IVDoc}.
|
||||
* Dictates methods required for any controller of an
|
||||
* {@link forge.gui.framework.IVDoc}.
|
||||
*
|
||||
* <br><br><i>(I at beginning of class name denotes an interface.)</i>
|
||||
* <br><i>(C at beginning of class name denotes a controller class.)</i>
|
||||
* <br>
|
||||
* <br>
|
||||
* <i>(I at beginning of class name denotes an interface.)</i><br>
|
||||
* <i>(C at beginning of class name denotes a controller class.)</i>
|
||||
*/
|
||||
public interface ICDoc {
|
||||
/**
|
||||
* Fires when this controller's view tab is selected.
|
||||
* Since this method is fired when all tabs are first
|
||||
* initialized, be wary of NPEs created by referring to
|
||||
* non-existent components.
|
||||
* Fires when this controller's view tab is selected. Since this method is
|
||||
* fired when all tabs are first initialized, be wary of NPEs created by
|
||||
* referring to non-existent components.
|
||||
*
|
||||
* @return {@link forge.UiCommand} */
|
||||
* @return {@link forge.UiCommand}
|
||||
*/
|
||||
UiCommand getCommandOnSelect();
|
||||
|
||||
/**
|
||||
* This method is called once, after the view singleton has been fully realized
|
||||
* for the first time. It should execute operations which should only
|
||||
* be done once, but require non-null view components.
|
||||
* <br><br>
|
||||
* This method should only be called once, in FView, after singletons are populated.
|
||||
* Asks this controller to register its docs, so that a layout can be
|
||||
* applied to them.
|
||||
*/
|
||||
void register();
|
||||
|
||||
/**
|
||||
* This method is called every time the user switches to the tab containing
|
||||
* this item.
|
||||
*/
|
||||
void initialize();
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package forge.gui.framework;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.properties.FileLocation;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.toolbox.FAbsolutePositioner;
|
||||
import forge.toolbox.SaveOpenDialog;
|
||||
import forge.toolbox.SaveOpenDialog.Filetypes;
|
||||
import forge.util.CollectionSuppliers;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.util.maps.HashMapOfLists;
|
||||
@@ -49,6 +53,54 @@ public final class SLayoutIO {
|
||||
|
||||
private final static AtomicBoolean saveWindowRequested = new AtomicBoolean(false);
|
||||
|
||||
|
||||
public static void saveLayout() {
|
||||
final SaveOpenDialog dlgSave = new SaveOpenDialog();
|
||||
final FileLocation layoutFile = Singletons.getControl().getCurrentScreen().getLayoutFile();
|
||||
final File defFile = layoutFile != null ? new File(layoutFile.userPrefLoc) : null;
|
||||
final File saveFile = dlgSave.SaveDialog(defFile, Filetypes.LAYOUT);
|
||||
if (saveFile != null) {
|
||||
SLayoutIO.saveLayout(saveFile);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openLayout() {
|
||||
SOverlayUtils.genericOverlay();
|
||||
|
||||
final SaveOpenDialog dlgOpen = new SaveOpenDialog();
|
||||
final FileLocation layoutFile = Singletons.getControl().getCurrentScreen().getLayoutFile();
|
||||
final File defFile = layoutFile != null ? new File(layoutFile.userPrefLoc) : null;
|
||||
final File loadFile = dlgOpen.OpenDialog(defFile, Filetypes.LAYOUT);
|
||||
|
||||
if (loadFile != null) {
|
||||
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
|
||||
// let it redraw everything first
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (loadFile != null) {
|
||||
SLayoutIO.loadLayout(loadFile);
|
||||
SLayoutIO.saveLayout(null);
|
||||
}
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void revertLayout() {
|
||||
SOverlayUtils.genericOverlay();
|
||||
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override public void run() {
|
||||
SLayoutIO.loadLayout(null);
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void saveWindowLayout() {
|
||||
if (saveWindowRequested.getAndSet(true)) { return; }
|
||||
ThreadUtil.delay(500, new Runnable() {
|
||||
|
||||
@@ -7,6 +7,8 @@ import forge.itemmanager.filters.*;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestWorld;
|
||||
import forge.screens.home.quest.DialogChooseSets;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -19,8 +21,8 @@ import java.util.Map.Entry;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CardManager extends ItemManager<PaperCard> {
|
||||
public CardManager(boolean wantUnique0) {
|
||||
super(PaperCard.class, wantUnique0);
|
||||
public CardManager(final CDetailPicture cDetailPicture, final boolean wantUnique0) {
|
||||
super(PaperCard.class, cDetailPicture, wantUnique0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
package forge.itemmanager;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
@@ -12,7 +30,13 @@ import forge.game.IHasGameType;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.itemmanager.filters.*;
|
||||
import forge.itemmanager.filters.DeckColorFilter;
|
||||
import forge.itemmanager.filters.DeckFolderFilter;
|
||||
import forge.itemmanager.filters.DeckFormatFilter;
|
||||
import forge.itemmanager.filters.DeckQuestWorldFilter;
|
||||
import forge.itemmanager.filters.DeckSearchFilter;
|
||||
import forge.itemmanager.filters.DeckSetFilter;
|
||||
import forge.itemmanager.filters.ItemFilter;
|
||||
import forge.itemmanager.views.ItemCellRenderer;
|
||||
import forge.itemmanager.views.ItemListView;
|
||||
import forge.itemmanager.views.ItemTableColumn;
|
||||
@@ -24,21 +48,10 @@ import forge.screens.deckeditor.controllers.ACEditorBase;
|
||||
import forge.screens.deckeditor.controllers.CEditorLimited;
|
||||
import forge.screens.deckeditor.controllers.CEditorQuest;
|
||||
import forge.screens.home.quest.DialogChooseSets;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* ItemManager for decks
|
||||
*
|
||||
@@ -59,8 +72,8 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
|
||||
*
|
||||
* @param gt
|
||||
*/
|
||||
public DeckManager(final GameType gt) {
|
||||
super(DeckProxy.class, true);
|
||||
public DeckManager(final GameType gt, final CDetailPicture cDetailPicture) {
|
||||
super(DeckProxy.class, cDetailPicture, true);
|
||||
this.gameType = gt;
|
||||
|
||||
this.addSelectionListener(new ListSelectionListener() {
|
||||
|
||||
@@ -31,6 +31,7 @@ import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.ItemManagerModel;
|
||||
import forge.itemmanager.filters.ItemFilter;
|
||||
import forge.itemmanager.views.*;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.toolbox.*;
|
||||
import forge.toolbox.FSkin.Colors;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
@@ -74,6 +75,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
|
||||
private UiCommand itemActivateCommand;
|
||||
private ContextMenuBuilder contextMenuBuilder;
|
||||
private final Class<T> genericType;
|
||||
private final CDetailPicture cDetailPicture;
|
||||
private ItemManagerConfig config;
|
||||
private final ArrayList<ListSelectionListener> selectionListeners = new ArrayList<ListSelectionListener>();
|
||||
|
||||
@@ -125,7 +127,8 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
|
||||
* @param statLabels0 stat labels for this item manager
|
||||
* @param wantUnique0 whether this table should display only one item with the same name
|
||||
*/
|
||||
protected ItemManager(final Class<T> genericType0, final boolean wantUnique0) {
|
||||
protected ItemManager(final Class<T> genericType0, final CDetailPicture cDetailPicture, final boolean wantUnique0) {
|
||||
this.cDetailPicture = cDetailPicture;
|
||||
this.genericType = genericType0;
|
||||
this.wantUnique = wantUnique0;
|
||||
this.model = new ItemManagerModel<T>(genericType0);
|
||||
@@ -144,6 +147,10 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
|
||||
return new ImageView<T>(this, model0);
|
||||
}
|
||||
|
||||
public final CDetailPicture getCDetailPicture() {
|
||||
return cDetailPicture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize item manager if needed
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.itemmanager;
|
||||
|
||||
import forge.item.InventoryItem;
|
||||
import forge.itemmanager.filters.ItemFilter;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -11,8 +12,8 @@ import javax.swing.*;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public final class SpellShopManager extends ItemManager<InventoryItem> {
|
||||
public SpellShopManager(boolean wantUnique0) {
|
||||
super(InventoryItem.class, wantUnique0);
|
||||
public SpellShopManager(final CDetailPicture cDetailPicture, final boolean wantUnique0) {
|
||||
super(InventoryItem.class, cDetailPicture, wantUnique0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
package forge.itemmanager.views;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.DeckProxy;
|
||||
@@ -14,26 +43,19 @@ import forge.itemmanager.ItemManager;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.ItemManagerModel;
|
||||
import forge.itemmanager.SItemManagerUtil;
|
||||
import forge.screens.match.controllers.CDetail;
|
||||
import forge.screens.match.controllers.CPicture;
|
||||
import forge.toolbox.*;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.toolbox.FComboBoxWrapper;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.FTextField;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private static final int PADDING = 5;
|
||||
private static final float PILE_SPACING_Y = 0.1f;
|
||||
@@ -137,7 +159,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private final FComboBoxWrapper<Object> cbPileByOptions = new FComboBoxWrapper<Object>();
|
||||
private final FComboBoxWrapper<Integer> cbColumnCount = new FComboBoxWrapper<Integer>();
|
||||
|
||||
public ImageView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) {
|
||||
public ImageView(final ItemManager<T> itemManager0, final ItemManagerModel<T> model0) {
|
||||
super(itemManager0, model0);
|
||||
|
||||
SItemManagerUtil.populateImageViewOptions(itemManager0, cbGroupByOptions, cbPileByOptions);
|
||||
@@ -728,9 +750,11 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void showHoveredItem(T item) {
|
||||
CDetail.SINGLETON_INSTANCE.showCard(item);
|
||||
CPicture.SINGLETON_INSTANCE.showImage(item);
|
||||
protected void showHoveredItem(final T item) {
|
||||
final CDetailPicture cDetailPicture = itemManager.getCDetailPicture();
|
||||
if (cDetailPicture != null) {
|
||||
cDetailPicture.showItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,40 @@
|
||||
package forge.itemmanager.views;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.PopupFactory;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.item.InventoryItem;
|
||||
import forge.itemmanager.ColumnDef;
|
||||
import forge.itemmanager.ItemManager;
|
||||
@@ -9,24 +44,9 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FScrollPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.ToolTipListener;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import forge.toolbox.ToolTipListener;
|
||||
|
||||
public abstract class ItemView<T extends InventoryItem> {
|
||||
private static final SkinColor BORDER_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT);
|
||||
@@ -44,7 +64,7 @@ public abstract class ItemView<T extends InventoryItem> {
|
||||
private boolean isIncrementalSearchActive = false;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
protected ItemView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) {
|
||||
protected ItemView(final ItemManager<T> itemManager0, final ItemManagerModel<T> model0) {
|
||||
this.itemManager = itemManager0;
|
||||
this.model = model0;
|
||||
this.scroller = new FScrollPane(false) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class ForgeMenu {
|
||||
provider = provider0;
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
public void refresh() {
|
||||
activeShortcuts.clear();
|
||||
popupMenu = new JPopupMenu();
|
||||
@@ -66,7 +66,7 @@ public final class ForgeMenu {
|
||||
}
|
||||
}
|
||||
}
|
||||
add(LayoutMenu.getMenu());
|
||||
add(new LayoutMenu().getMenu());
|
||||
add(HelpMenu.getMenu());
|
||||
addSeparator();
|
||||
add(getMenuItem_Restart());
|
||||
|
||||
@@ -1,40 +1,46 @@
|
||||
package forge.menus;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.gui.MouseUtil;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedMenuItem;
|
||||
import forge.view.FFrame;
|
||||
import forge.view.FView;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* Returns a JMenu containing options associated with game screen layout.
|
||||
* <p>
|
||||
* Replicates options available in Dock tab.
|
||||
*/
|
||||
public final class LayoutMenu {
|
||||
private LayoutMenu() { }
|
||||
public LayoutMenu() {
|
||||
}
|
||||
|
||||
private static final CDock controller = CDock.SINGLETON_INSTANCE;
|
||||
private static FScreen currentScreen;
|
||||
private FScreen currentScreen;
|
||||
private static final ForgePreferences prefs = FModel.getPreferences();
|
||||
private static boolean showIcons = false;
|
||||
private boolean showIcons = false;
|
||||
|
||||
public static JMenu getMenu() {
|
||||
public JMenu getMenu() {
|
||||
currentScreen = Singletons.getControl().getCurrentScreen();
|
||||
|
||||
JMenu menu = new JMenu("Layout");
|
||||
@@ -53,16 +59,16 @@ public final class LayoutMenu {
|
||||
return menu;
|
||||
}
|
||||
|
||||
private static JMenu getMenu_ViewOptions() {
|
||||
private JMenu getMenu_ViewOptions() {
|
||||
JMenu menu = new JMenu("View");
|
||||
menu.add(getMenuItem_ShowTabs());
|
||||
if (currentScreen == FScreen.MATCH_SCREEN) {
|
||||
if (currentScreen != null && currentScreen.isMatchScreen()) {
|
||||
menu.add(getMenuItem_ShowBackgroundImage());
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
private static JMenu getMenu_FileOptions() {
|
||||
private JMenu getMenu_FileOptions() {
|
||||
JMenu menu = new JMenu("File");
|
||||
menu.add(getMenuItem_OpenLayout());
|
||||
menu.add(getMenuItem_SaveLayout());
|
||||
@@ -138,50 +144,50 @@ public final class LayoutMenu {
|
||||
};
|
||||
}
|
||||
|
||||
private static JMenuItem getMenuItem_SaveLayout() {
|
||||
private JMenuItem getMenuItem_SaveLayout() {
|
||||
SkinnedMenuItem menuItem = new SkinnedMenuItem("Save Current Layout");
|
||||
menuItem.setIcon((showIcons ? MenuUtil.getMenuIcon(FSkinProp.ICO_SAVELAYOUT) : null));
|
||||
menuItem.addActionListener(getSaveLayoutAction());
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
private static ActionListener getSaveLayoutAction() {
|
||||
private ActionListener getSaveLayoutAction() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.saveLayout();
|
||||
SLayoutIO.saveLayout();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static JMenuItem getMenuItem_OpenLayout() {
|
||||
private JMenuItem getMenuItem_OpenLayout() {
|
||||
SkinnedMenuItem menuItem = new SkinnedMenuItem("Open...");
|
||||
menuItem.setIcon((showIcons ? MenuUtil.getMenuIcon(FSkinProp.ICO_OPENLAYOUT) : null));
|
||||
menuItem.addActionListener(getOpenLayoutAction());
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
private static ActionListener getOpenLayoutAction() {
|
||||
private ActionListener getOpenLayoutAction() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.openLayout();
|
||||
SLayoutIO.openLayout();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static JMenuItem getMenuItem_RevertLayout() {
|
||||
private JMenuItem getMenuItem_RevertLayout() {
|
||||
SkinnedMenuItem menuItem = new SkinnedMenuItem("Refresh");
|
||||
menuItem.setIcon((showIcons ? MenuUtil.getMenuIcon(FSkinProp.ICO_REVERTLAYOUT) : null));
|
||||
menuItem.addActionListener(getRevertLayoutAction());
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
private static ActionListener getRevertLayoutAction() {
|
||||
private ActionListener getRevertLayoutAction() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.revertLayout();
|
||||
SLayoutIO.revertLayout();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ public enum CBazaarUI implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -17,32 +17,36 @@
|
||||
*/
|
||||
package forge.screens.deckeditor;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.deck.DeckBase;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.deck.io.DeckPreferences;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.itemmanager.ItemManager;
|
||||
import forge.screens.deckeditor.controllers.*;
|
||||
import forge.screens.deckeditor.views.VAllDecks;
|
||||
import forge.screens.deckeditor.views.VCardCatalog;
|
||||
import forge.screens.deckeditor.views.VCurrentDeck;
|
||||
import forge.screens.match.controllers.CDetail;
|
||||
import forge.screens.match.controllers.CPicture;
|
||||
import forge.util.ItemPool;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.deck.DeckBase;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.deck.io.DeckPreferences;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.itemmanager.ItemManager;
|
||||
import forge.screens.deckeditor.controllers.ACEditorBase;
|
||||
import forge.screens.deckeditor.controllers.CEditorConstructed;
|
||||
import forge.screens.deckeditor.controllers.CProbabilities;
|
||||
import forge.screens.deckeditor.controllers.CStatistics;
|
||||
import forge.screens.deckeditor.controllers.DeckController;
|
||||
import forge.screens.deckeditor.views.VAllDecks;
|
||||
import forge.screens.deckeditor.views.VCardCatalog;
|
||||
import forge.screens.deckeditor.views.VCurrentDeck;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.util.ItemPool;
|
||||
|
||||
/**
|
||||
* Constructs instance of deck editor UI controller, used as a single point of
|
||||
* top-level control for child UIs. Tasks targeting the view of individual
|
||||
@@ -57,9 +61,14 @@ public enum CDeckEditorUI implements ICDoc {
|
||||
|
||||
private final HashMap<FScreen, ACEditorBase<? extends InventoryItem, ? extends DeckBase>> screenChildControllers;
|
||||
private ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController;
|
||||
private final CDetailPicture cDetailPicture;
|
||||
private final VAllDecks vAllDecks;
|
||||
|
||||
private CDeckEditorUI() {
|
||||
screenChildControllers = new HashMap<FScreen, ACEditorBase<? extends InventoryItem, ? extends DeckBase>>();
|
||||
this.cDetailPicture = new CDetailPicture();
|
||||
this.vAllDecks = VAllDecks.SINGLETON_INSTANCE;
|
||||
this.vAllDecks.setCDetailPicture(cDetailPicture);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,8 +76,7 @@ public enum CDeckEditorUI implements ICDoc {
|
||||
* @param item
|
||||
*/
|
||||
public void setCard(final InventoryItem item) {
|
||||
CDetail.SINGLETON_INSTANCE.showCard(item);
|
||||
CPicture.SINGLETON_INSTANCE.showImage(item);
|
||||
cDetailPicture.showItem(item);
|
||||
}
|
||||
|
||||
public boolean hasChanges() {
|
||||
@@ -292,6 +300,12 @@ public enum CDeckEditorUI implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
EDocID.CARD_PICTURE.setDoc(cDetailPicture.getCPicture().getView());
|
||||
EDocID.CARD_DETAIL.setDoc(cDetailPicture.getCDetail().getView());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@@ -308,9 +322,9 @@ public enum CDeckEditorUI implements ICDoc {
|
||||
|
||||
String currentDeckStr = DeckPreferences.getCurrentDeck();
|
||||
if (currentDeckStr != null) {
|
||||
DeckProxy deck = VAllDecks.SINGLETON_INSTANCE.getLstDecks().stringToItem(currentDeckStr);
|
||||
DeckProxy deck = vAllDecks.getLstDecks().stringToItem(currentDeckStr);
|
||||
if (deck != null) {
|
||||
VAllDecks.SINGLETON_INSTANCE.getLstDecks().setSelectedItem(deck);
|
||||
vAllDecks.getLstDecks().setSelectedItem(deck);
|
||||
childController.getDeckController().load(deck.getPath(), deck.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.screens.deckeditor.menus.CDeckEditorUIMenus;
|
||||
import forge.screens.deckeditor.views.VCardCatalog;
|
||||
import forge.screens.deckeditor.views.VCurrentDeck;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.toolbox.ContextMenuBuilder;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
@@ -71,6 +72,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
private ItemManager<TItem> catalogManager;
|
||||
private ItemManager<TItem> deckManager;
|
||||
protected DeckSection sectionMode = DeckSection.Main;
|
||||
private final CDetailPicture cDetailPicture = new CDetailPicture();
|
||||
|
||||
// card transfer buttons
|
||||
private final FLabel btnAdd = new FLabel.Builder()
|
||||
@@ -119,6 +121,10 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
return this.sectionMode;
|
||||
}
|
||||
|
||||
protected final CDetailPicture getCDetailPicture() {
|
||||
return cDetailPicture;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.menubar.IMenuProvider#getMenus()
|
||||
*/
|
||||
@@ -525,4 +531,5 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
KeyEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ public enum CAllDecks implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,10 @@ public enum CCardCatalog implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -68,6 +68,10 @@ public enum CCurrentDeck implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,10 @@ public enum CDeckgen implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -73,8 +73,8 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
||||
commanderPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_COMMANDER, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||
normalPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(), PaperCard.class);
|
||||
|
||||
CardManager catalogManager = new CardManager(true);
|
||||
CardManager deckManager = new CardManager(true);
|
||||
CardManager catalogManager = new CardManager(getCDetailPicture(), true);
|
||||
CardManager deckManager = new CardManager(getCDetailPicture(), true);
|
||||
|
||||
catalogManager.setCaption("Catalog");
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
schemePool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard.FN_GET_RULES)), PaperCard.class);
|
||||
conspiracyPool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_CONSPIRACY, PaperCard.FN_GET_RULES)), PaperCard.class);
|
||||
|
||||
CardManager catalogManager = new CardManager(false); // TODO: restore the functionality of the "want uniques only" toggle
|
||||
CardManager deckManager = new CardManager(false); // IMPORTANT: must *always* show all cards in the deck, otherwise cards with different art get ignored!
|
||||
CardManager catalogManager = new CardManager(getCDetailPicture(), false); // TODO: restore the functionality of the "want uniques only" toggle
|
||||
CardManager deckManager = new CardManager(getCDetailPicture(), false); // IMPORTANT: must *always* show all cards in the deck, otherwise cards with different art get ignored!
|
||||
|
||||
catalogManager.setCaption("Catalog");
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
|
||||
public CEditorDraftingProcess() {
|
||||
super(FScreen.DRAFTING_PROCESS);
|
||||
|
||||
final CardManager catalogManager = new CardManager(false);
|
||||
final CardManager deckManager = new CardManager(false);
|
||||
final CardManager catalogManager = new CardManager(getCDetailPicture(), false);
|
||||
final CardManager deckManager = new CardManager(getCDetailPicture(), false);
|
||||
|
||||
//hide filters and options panel so more of pack is visible by default
|
||||
catalogManager.setHideViewOptions(1, true);
|
||||
|
||||
@@ -61,8 +61,8 @@ public final class CEditorLimited extends ACEditorBase<PaperCard, DeckGroup> {
|
||||
public CEditorLimited(final IStorage<DeckGroup> deckMap0, FScreen screen0) {
|
||||
super(screen0);
|
||||
|
||||
final CardManager catalogManager = new CardManager(false);
|
||||
final CardManager deckManager = new CardManager(false);
|
||||
final CardManager catalogManager = new CardManager(getCDetailPicture(), false);
|
||||
final CardManager deckManager = new CardManager(getCDetailPicture(), false);
|
||||
|
||||
catalogManager.setCaption("Sideboard");
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ public final class CEditorQuest extends ACEditorBase<PaperCard, Deck> {
|
||||
|
||||
this.questData = questData0;
|
||||
|
||||
final CardManager catalogManager = new CardManager(false);
|
||||
final CardManager deckManager = new CardManager(false);
|
||||
final CardManager catalogManager = new CardManager(getCDetailPicture(), false);
|
||||
final CardManager deckManager = new CardManager(getCDetailPicture(), false);
|
||||
|
||||
catalogManager.setCaption("Quest Inventory");
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
||||
|
||||
this.questData = qd;
|
||||
|
||||
final SpellShopManager catalogManager = new SpellShopManager(false);
|
||||
final SpellShopManager deckManager = new SpellShopManager(false);
|
||||
final SpellShopManager catalogManager = new SpellShopManager(getCDetailPicture(), false);
|
||||
final SpellShopManager deckManager = new SpellShopManager(getCDetailPicture(), false);
|
||||
|
||||
catalogManager.setCaption("Spell Shop");
|
||||
deckManager.setCaption("Quest Inventory");
|
||||
|
||||
@@ -78,8 +78,8 @@ public class CEditorQuestDraftingProcess extends ACEditorBase<PaperCard, DeckGro
|
||||
public CEditorQuestDraftingProcess() {
|
||||
super(FScreen.DRAFTING_PROCESS);
|
||||
|
||||
final CardManager catalogManager = new CardManager(false);
|
||||
final CardManager deckManager = new CardManager(false);
|
||||
final CardManager catalogManager = new CardManager(getCDetailPicture(), false);
|
||||
final CardManager deckManager = new CardManager(getCDetailPicture(), false);
|
||||
|
||||
//hide filters and options panel so more of pack is visible by default
|
||||
catalogManager.setHideViewOptions(1, true);
|
||||
|
||||
@@ -100,8 +100,8 @@ public final class CEditorQuestLimited extends ACEditorBase<PaperCard, DeckGroup
|
||||
|
||||
this.questData = questData0;
|
||||
|
||||
final CardManager catalogManager = new CardManager(false);
|
||||
final CardManager deckManager = new CardManager(false);
|
||||
final CardManager catalogManager = new CardManager(getCDetailPicture(), false);
|
||||
final CardManager deckManager = new CardManager(getCDetailPicture(), false);
|
||||
|
||||
catalogManager.setCaption("Sideboard");
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public final class CEditorVariant extends ACEditorBase<PaperCard, Deck> {
|
||||
this.cardPoolCondition = poolCondition;
|
||||
this.sectionMode = deckSection0;
|
||||
|
||||
CardManager catalogManager = new CardManager(true);
|
||||
CardManager deckManager = new CardManager(true);
|
||||
CardManager catalogManager = new CardManager(getCDetailPicture(), true);
|
||||
CardManager deckManager = new CardManager(getCDetailPicture(), true);
|
||||
|
||||
catalogManager.setCaption("Catalog");
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ public class CEditorWinstonProcess extends ACEditorBase<PaperCard, DeckGroup> {
|
||||
public CEditorWinstonProcess() {
|
||||
super(FScreen.DRAFTING_PROCESS);
|
||||
|
||||
final CardManager catalogManager = new CardManager(false);
|
||||
final CardManager deckManager = new CardManager(false);
|
||||
final CardManager catalogManager = new CardManager(getCDetailPicture(), false);
|
||||
final CardManager deckManager = new CardManager(getCDetailPicture(), false);
|
||||
|
||||
//hide filters and options panel so more of pack is visible by default
|
||||
catalogManager.setHideViewOptions(1, true);
|
||||
|
||||
@@ -32,6 +32,10 @@ public enum CProbabilities implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,10 @@ public enum CStatistics implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@ import forge.gui.framework.IVDoc;
|
||||
import forge.itemmanager.DeckManager;
|
||||
import forge.itemmanager.ItemManagerContainer;
|
||||
import forge.screens.deckeditor.controllers.CAllDecks;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -25,12 +26,7 @@ public enum VAllDecks implements IVDoc<CAllDecks> {
|
||||
private DragCell parentCell;
|
||||
private final DragTab tab = new DragTab("All Decks");
|
||||
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Constructed);
|
||||
|
||||
//========== Constructor
|
||||
private VAllDecks() {
|
||||
lstDecks.setCaption("Decks");
|
||||
}
|
||||
private DeckManager lstDecks;
|
||||
|
||||
//========== Overridden methods
|
||||
|
||||
@@ -91,4 +87,9 @@ public enum VAllDecks implements IVDoc<CAllDecks> {
|
||||
public DeckManager getLstDecks() {
|
||||
return lstDecks;
|
||||
}
|
||||
|
||||
public void setCDetailPicture(final CDetailPicture cDetailPicture) {
|
||||
this.lstDecks = new DeckManager(GameType.Constructed, cDetailPicture);
|
||||
this.lstDecks.setCaption("Decks");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ public enum CHomeUI implements ICDoc, IMenuProvider {
|
||||
return lblSelected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.ICDoc#intialize()
|
||||
*/
|
||||
@@ -128,8 +132,7 @@ public enum CHomeUI implements ICDoc, IMenuProvider {
|
||||
private void selectPrevious() {
|
||||
EDocID selected = null;
|
||||
try {
|
||||
selected = EDocID.valueOf(FModel
|
||||
.getPreferences().getPref(FPref.SUBMENU_CURRENTMENU));
|
||||
selected = EDocID.valueOf(FModel.getPreferences().getPref(FPref.SUBMENU_CURRENTMENU));
|
||||
} catch (final Exception e) { }
|
||||
|
||||
if (selected != null && VHomeUI.SINGLETON_INSTANCE.getAllSubmenuLabels().get(selected) != null) {
|
||||
|
||||
@@ -83,6 +83,10 @@ public enum CSubmenuGauntletBuild implements ICDoc {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.home.ICSubmenu#initialize()
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.gauntlet;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameType;
|
||||
@@ -8,7 +9,7 @@ import forge.gauntlet.GauntletData;
|
||||
import forge.gauntlet.GauntletIO;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
|
||||
@@ -51,6 +52,10 @@ public enum CSubmenuGauntletContests implements ICDoc {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.home.ICSubmenu#initialize()
|
||||
*/
|
||||
@@ -82,8 +87,7 @@ public enum CSubmenuGauntletContests implements ICDoc {
|
||||
|
||||
if (gd.getUserDeck() != null) {
|
||||
userDeck = gd.getUserDeck();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
userDeck = view.getLstDecks().getPlayer().getDeck();
|
||||
gd.setUserDeck(userDeck);
|
||||
}
|
||||
@@ -99,14 +103,15 @@ public enum CSubmenuGauntletContests implements ICDoc {
|
||||
}
|
||||
});
|
||||
|
||||
Deck aiDeck = gd.getDecks().get(gd.getCompleted());
|
||||
final Deck aiDeck = gd.getDecks().get(gd.getCompleted());
|
||||
|
||||
List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
|
||||
starter.add(new RegisteredPlayer(gd.getUserDeck()).setPlayer(GamePlayerUtil.getGuiPlayer()));
|
||||
final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
final RegisteredPlayer human = new RegisteredPlayer(gd.getUserDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||
starter.add(human);
|
||||
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||
|
||||
MatchUtil.startMatch(GameType.Gauntlet, starter);
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch.startMatch(GameType.Gauntlet, null, starter, human, GuiBase.getInterface().getNewGuiGame());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.gauntlet;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckType;
|
||||
@@ -10,7 +11,7 @@ import forge.gauntlet.GauntletData;
|
||||
import forge.gauntlet.GauntletIO;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
|
||||
@@ -56,6 +57,10 @@ public enum CSubmenuGauntletLoad implements ICDoc {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.home.ICSubmenu#initialize()
|
||||
*/
|
||||
@@ -113,7 +118,7 @@ public enum CSubmenuGauntletLoad implements ICDoc {
|
||||
Deck userDeck = gd.getUserDeck();
|
||||
if (userDeck == null) {
|
||||
//give user a chance to select a deck if none saved with gauntlet
|
||||
userDeck = FDeckChooser.promptForDeck("Select a deck to play for this gauntlet", DeckType.CUSTOM_DECK, false);
|
||||
userDeck = FDeckChooser.promptForDeck(null, "Select a deck to play for this gauntlet", DeckType.CUSTOM_DECK, false);
|
||||
if (userDeck == null) { return; } //prevent crash if user doesn't select a deck
|
||||
gd.setUserDeck(userDeck);
|
||||
GauntletIO.saveGauntlet(gd);
|
||||
@@ -129,11 +134,13 @@ public enum CSubmenuGauntletLoad implements ICDoc {
|
||||
}
|
||||
});
|
||||
|
||||
List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
starter.add(new RegisteredPlayer(userDeck).setPlayer(GamePlayerUtil.getGuiPlayer()));
|
||||
final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
final RegisteredPlayer human = new RegisteredPlayer(userDeck).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||
starter.add(human);
|
||||
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||
|
||||
MatchUtil.startMatch(GameType.Gauntlet, starter);
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch.startMatch(GameType.Gauntlet, null, starter, human, GuiBase.getInterface().getNewGuiGame());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.gauntlet;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.deck.DeckType;
|
||||
import forge.game.GameType;
|
||||
@@ -8,7 +9,7 @@ import forge.gauntlet.GauntletData;
|
||||
import forge.gauntlet.GauntletUtil;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.player.GamePlayerUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -44,6 +45,10 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.home.ICSubmenu#initialize()
|
||||
*/
|
||||
@@ -64,7 +69,7 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
||||
});
|
||||
|
||||
// Find appropriate filename for new save, create and set new save file.
|
||||
List<DeckType> allowedDeckTypes = new ArrayList<DeckType>();
|
||||
final List<DeckType> allowedDeckTypes = new ArrayList<DeckType>();
|
||||
if (view.getBoxColorDecks().isSelected()) { allowedDeckTypes.add(DeckType.COLOR_DECK); }
|
||||
if (view.getBoxThemeDecks().isSelected()) { allowedDeckTypes.add(DeckType.THEME_DECK); }
|
||||
if (view.getBoxUserDecks().isSelected()) { allowedDeckTypes.add(DeckType.CUSTOM_DECK); }
|
||||
@@ -73,11 +78,13 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
||||
|
||||
final GauntletData gd = GauntletUtil.createQuickGauntlet(view.getLstDecks().getPlayer().getDeck(), view.getSliOpponents().getValue(), allowedDeckTypes);
|
||||
|
||||
List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
starter.add(new RegisteredPlayer(gd.getUserDeck()).setPlayer(GamePlayerUtil.getGuiPlayer()));
|
||||
final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
final RegisteredPlayer human = new RegisteredPlayer(gd.getUserDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||
starter.add(human);
|
||||
starter.add(new RegisteredPlayer(gd.getDecks().get(gd.getCompleted())).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||
|
||||
MatchUtil.startMatch(GameType.Gauntlet, starter);
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch.startMatch(GameType.Gauntlet, null, starter, human, GuiBase.getInterface().getNewGuiGame());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -40,7 +40,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu<CSubmenuGauntletBuild> {
|
||||
private final JPanel pnlStrut = new JPanel();
|
||||
private final JPanel pnlDirections = new JPanel();
|
||||
|
||||
private final FDeckChooser lstLeft = new FDeckChooser(false);
|
||||
private final FDeckChooser lstLeft = new FDeckChooser(null, false);
|
||||
private final JList<String> lstRight = new FList<String>();
|
||||
|
||||
private final FScrollPane scrRight = new FScrollPane(lstRight, true,
|
||||
|
||||
@@ -42,7 +42,7 @@ public enum VSubmenuGauntletContests implements IVSubmenu<CSubmenuGauntletContes
|
||||
private final SkinnedPanel pnlLoad = new SkinnedPanel(new MigLayout("insets 0, gap 0, wrap"));
|
||||
|
||||
private final ContestGauntletLister gauntletList = new ContestGauntletLister();
|
||||
private final FDeckChooser lstDecks = new FDeckChooser(false);
|
||||
private final FDeckChooser lstDecks = new FDeckChooser(null, false);
|
||||
|
||||
private final FScrollPane scrLeft = new FScrollPane(gauntletList, false,
|
||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
@@ -53,7 +53,7 @@ public enum VSubmenuGauntletQuick implements IVSubmenu<CSubmenuGauntletQuick> {
|
||||
private final JCheckBox boxColorDecks = new FCheckBox(DeckType.COLOR_DECK.toString());
|
||||
private final JCheckBox boxThemeDecks = new FCheckBox(DeckType.THEME_DECK.toString());
|
||||
|
||||
private final FDeckChooser lstDecks = new FDeckChooser(false);
|
||||
private final FDeckChooser lstDecks = new FDeckChooser(null, false);
|
||||
|
||||
private final FLabel lblOptions = new FLabel.Builder().fontSize(16)
|
||||
.fontStyle(Font.BOLD).text("OPTIONS").fontAlign(SwingConstants.CENTER).build();
|
||||
|
||||
@@ -4,6 +4,7 @@ import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.menus.IMenuProvider;
|
||||
import forge.menus.MenuUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -26,6 +27,10 @@ public enum CSubmenuOnlineLobby implements ICDoc, IMenuProvider {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ public enum CSubmenuChallenges implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#initialize()
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,10 @@ public enum CSubmenuDuels implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#initialize()
|
||||
*/
|
||||
|
||||
@@ -45,6 +45,10 @@ public enum CSubmenuQuestData implements ICDoc {
|
||||
private final UiCommand cmdQuestUpdate = new UiCommand() { @Override
|
||||
public void run() { update(); } };
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -48,6 +48,10 @@ public enum CSubmenuQuestDecks implements ICDoc {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,7 @@ import forge.gui.GuiChoose;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.interfaces.IGuiGame;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.DeckManager;
|
||||
@@ -38,6 +39,7 @@ import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.JXButtonPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -56,7 +58,12 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
private static final DecimalFormat NUMBER_FORMATTER = new DecimalFormat("#,###");
|
||||
|
||||
private boolean drafting = false;
|
||||
|
||||
private IGuiGame gui = null;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Override
|
||||
public void initialize() {
|
||||
@@ -333,7 +340,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
view.setMode(Mode.TOURNAMENT_ACTIVE);
|
||||
}
|
||||
|
||||
QuestDraftUtils.update();
|
||||
QuestDraftUtils.update(gui);
|
||||
|
||||
switch (view.getMode()) {
|
||||
|
||||
@@ -489,7 +496,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
}
|
||||
|
||||
private void editDeck() {
|
||||
VCurrentDeck.SINGLETON_INSTANCE.setItemManager(new DeckManager(GameType.Draft));
|
||||
VCurrentDeck.SINGLETON_INSTANCE.setItemManager(new DeckManager(GameType.Draft, null));
|
||||
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_QUEST_TOURNAMENT);
|
||||
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorQuestLimited(FModel.getQuest()));
|
||||
FModel.getQuest().save();
|
||||
@@ -549,15 +556,16 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
}
|
||||
|
||||
private void startNextMatch() {
|
||||
|
||||
String message = QuestDraftUtils.getDeckLegality();
|
||||
|
||||
if (message != null) {
|
||||
|
||||
final String message = QuestDraftUtils.getDeckLegality();
|
||||
|
||||
if (message != null) {
|
||||
FOptionPane.showMessageDialog(message, "Deck Invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
QuestDraftUtils.startNextMatch();
|
||||
|
||||
gui = GuiBase.getInterface().getNewGuiGame();
|
||||
QuestDraftUtils.startNextMatch(gui);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ public enum CSubmenuQuestPrefs implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum VSubmenuQuestDecks implements IVSubmenu<CSubmenuQuestDecks> {
|
||||
/** */
|
||||
private final LblHeader lblTitle = new LblHeader("Quest Decks");
|
||||
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Quest);
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Quest, null);
|
||||
|
||||
private final FLabel lblInfo = new FLabel.Builder()
|
||||
.fontAlign(SwingConstants.LEFT).fontSize(16).fontStyle(Font.BOLD)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.sanctioned;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.UiCommand;
|
||||
import forge.deck.CardPool;
|
||||
@@ -12,8 +13,9 @@ import forge.game.GameType;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.gui.GuiDialog;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.interfaces.IGuiGame;
|
||||
import forge.item.PaperCard;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.menus.IMenuProvider;
|
||||
import forge.menus.MenuUtil;
|
||||
import forge.model.CardCollections;
|
||||
@@ -28,10 +30,13 @@ import forge.util.storage.IStorage;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -49,6 +54,10 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
|
||||
private final VSubmenuConstructed view = VSubmenuConstructed.SINGLETON_INSTANCE;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.home.ICSubmenu#initialize()
|
||||
*/
|
||||
@@ -226,10 +235,13 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
}
|
||||
}
|
||||
|
||||
List<RegisteredPlayer> players = new ArrayList<RegisteredPlayer>();
|
||||
final List<RegisteredPlayer> players = new ArrayList<RegisteredPlayer>();
|
||||
final Map<RegisteredPlayer, IGuiGame> guis = Maps.newHashMap();
|
||||
final IGuiGame gui = GuiBase.getInterface().getNewGuiGame();
|
||||
for (final int i : view.getParticipants()) {
|
||||
String name = view.getPlayerName(i);
|
||||
LobbyPlayer lobbyPlayer = view.isPlayerAI(i)
|
||||
final String name = view.getPlayerName(i);
|
||||
final boolean isAI = view.isPlayerAI(i);
|
||||
final LobbyPlayer lobbyPlayer = isAI
|
||||
? GamePlayerUtil.createAiPlayer(name, view.getPlayerAvatar(i), view.getAiOptions(i))
|
||||
: GamePlayerUtil.getGuiPlayer(name, i);
|
||||
RegisteredPlayer rp = view.getDeckChooser(i).getPlayer();
|
||||
@@ -237,25 +249,23 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
if (variantTypes.isEmpty()) {
|
||||
rp.setTeamNumber(view.getTeam(i));
|
||||
players.add(rp.setPlayer(lobbyPlayer));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Deck deck = null;
|
||||
PaperCard vanguardAvatar = null;
|
||||
if (isCommanderMatch) {
|
||||
Object selected = view.getCommanderDeckLists().get(i).getSelectedValue();
|
||||
final Object selected = view.getCommanderDeckLists().get(i).getSelectedValue();
|
||||
if (selected instanceof String) {
|
||||
String sel = (String) selected;
|
||||
IStorage<Deck> comDecks = FModel.getDecks().getCommander();
|
||||
final String sel = (String) selected;
|
||||
final IStorage<Deck> comDecks = FModel.getDecks().getCommander();
|
||||
if (sel.equals("Random") && comDecks.size() > 0) {
|
||||
deck = Aggregates.random(comDecks);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
deck = (Deck) selected;
|
||||
}
|
||||
GameType commanderGameType = isTinyLeadersMatch ? GameType.TinyLeaders : GameType.Commander;
|
||||
if (deck == null) { //Can be null if player deselects the list selection or chose Generate
|
||||
deck = DeckgenUtil.generateCommanderDeck(view.isPlayerAI(i), commanderGameType);
|
||||
deck = DeckgenUtil.generateCommanderDeck(isAI, commanderGameType);
|
||||
}
|
||||
if (checkLegality) {
|
||||
String errMsg = commanderGameType.getDeckFormat().getDeckConformanceProblem(deck);
|
||||
@@ -264,8 +274,7 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (autoGenerateVariant != null) {
|
||||
} else if (autoGenerateVariant != null) {
|
||||
deck = autoGenerateVariant.autoGenerateDeck(rp);
|
||||
CardPool avatarPool = deck.get(DeckSection.Avatar);
|
||||
if (avatarPool != null) {
|
||||
@@ -276,7 +285,7 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
// Initialise variables for other variants
|
||||
deck = deck == null ? rp.getDeck() : deck;
|
||||
Iterable<PaperCard> schemes = null;
|
||||
boolean playerIsArchenemy = view.isPlayerArchenemy(i);
|
||||
final boolean playerIsArchenemy = view.isPlayerArchenemy(i);
|
||||
Iterable<PaperCard> planes = null;
|
||||
|
||||
//Archenemy
|
||||
@@ -354,10 +363,10 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
if (sel.contains("Use deck's default avatar") && deck.has(DeckSection.Avatar)) {
|
||||
vanguardAvatar = deck.get(DeckSection.Avatar).get(0);
|
||||
} else { //Only other string is "Random"
|
||||
if (!view.isPlayerAI(i)) { //Human
|
||||
vanguardAvatar = Aggregates.random(view.getNonRandomHumanAvatars());
|
||||
} else { //AI
|
||||
if (isAI) { //AI
|
||||
vanguardAvatar = Aggregates.random(view.getNonRandomAiAvatars());
|
||||
} else { //Human
|
||||
vanguardAvatar = Aggregates.random(view.getNonRandomHumanAvatars());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -374,10 +383,15 @@ public enum CSubmenuConstructed implements ICDoc, IMenuProvider {
|
||||
rp.setTeamNumber(view.getTeam(i));
|
||||
players.add(rp.setPlayer(lobbyPlayer));
|
||||
}
|
||||
|
||||
if (!isAI) {
|
||||
guis.put(rp, gui);
|
||||
}
|
||||
view.getDeckChooser(i).saveState();
|
||||
}
|
||||
|
||||
MatchUtil.startMatch(GameType.Constructed, variantTypes, players);
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch.startMatch(GameType.Constructed, variantTypes, players, guis);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.sanctioned;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
@@ -14,7 +15,7 @@ import forge.gui.framework.ICDoc;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.limited.BoosterDraft;
|
||||
import forge.limited.LimitedPoolType;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -47,6 +48,10 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@@ -131,20 +136,22 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
}
|
||||
});
|
||||
|
||||
DeckGroup opponentDecks = FModel.getDecks().getDraft().get(humanDeck.getName());
|
||||
Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
|
||||
final DeckGroup opponentDecks = FModel.getDecks().getDraft().get(humanDeck.getName());
|
||||
final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
|
||||
if (aiDeck == null) {
|
||||
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||
}
|
||||
|
||||
List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
starter.add(new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer()));
|
||||
final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
final RegisteredPlayer human = new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||
starter.add(human);
|
||||
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||
for (RegisteredPlayer pl : starter) {
|
||||
pl.assignConspiracies();
|
||||
}
|
||||
|
||||
MatchUtil.startMatch(GameType.Draft, starter);
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch.startMatch(GameType.Draft, null, starter, human, GuiBase.getInterface().getNewGuiGame());
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -40,6 +40,10 @@ public enum CSubmenuSealed implements ICDoc {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.sanctioned;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
@@ -8,7 +9,7 @@ import forge.game.GameType;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.HostedMatch;
|
||||
import forge.model.FModel;
|
||||
import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.deck.DeckProxy;
|
||||
@@ -47,6 +48,10 @@ public enum CSubmenuWinston implements ICDoc {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@@ -122,17 +127,19 @@ public enum CSubmenuWinston implements ICDoc {
|
||||
}
|
||||
});
|
||||
|
||||
DeckGroup opponentDecks = FModel.getDecks().getWinston().get(humanDeck.getName());
|
||||
Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
|
||||
final DeckGroup opponentDecks = FModel.getDecks().getWinston().get(humanDeck.getName());
|
||||
final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
|
||||
if (aiDeck == null) {
|
||||
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||
}
|
||||
|
||||
List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
starter.add(new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer()));
|
||||
final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
|
||||
final RegisteredPlayer human = new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||
starter.add(human);
|
||||
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||
|
||||
MatchUtil.startMatch(GameType.Winston, starter);
|
||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||
hostedMatch.startMatch(GameType.Winston, null, starter, human, GuiBase.getInterface().getNewGuiGame());
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -286,7 +286,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
String labelConstraints = "gaptop 10px, gapbottom 5px";
|
||||
|
||||
// Main deck
|
||||
final FDeckChooser mainChooser = new FDeckChooser(isPlayerAI(playerIndex));
|
||||
final FDeckChooser mainChooser = new FDeckChooser(null, isPlayerAI(playerIndex));
|
||||
mainChooser.initialize();
|
||||
mainChooser.getLstDecks().setSelectCommand(new UiCommand() {
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
||||
private final JPanel pnlStart = new JPanel();
|
||||
private final StartButton btnStart = new StartButton();
|
||||
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Draft);
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Draft, null);
|
||||
|
||||
private final JRadioButton radSingle = new FRadioButton("Play one opponent");
|
||||
private final JRadioButton radAll = new FRadioButton("Play all 7 opponents");
|
||||
@@ -66,7 +66,7 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
||||
lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
lstDecks.setCaption("Draft Decks");
|
||||
|
||||
JXButtonPanel grpPanel = new JXButtonPanel();
|
||||
final JXButtonPanel grpPanel = new JXButtonPanel();
|
||||
grpPanel.add(radSingle, "w 200px!, h 30px!");
|
||||
grpPanel.add(radAll, "w 200px!, h 30px!");
|
||||
radSingle.setSelected(true);
|
||||
|
||||
@@ -44,7 +44,7 @@ public enum VSubmenuSealed implements IVSubmenu<CSubmenuSealed> {
|
||||
private final LblHeader lblTitle = new LblHeader("Sanctioned Format: Sealed Deck");
|
||||
|
||||
private final StartButton btnStart = new StartButton();
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Sealed);
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Sealed, null);
|
||||
|
||||
private final FLabel lblInfo = new FLabel.Builder()
|
||||
.fontAlign(SwingConstants.LEFT).fontSize(16).fontStyle(Font.BOLD)
|
||||
|
||||
@@ -34,7 +34,7 @@ public enum VSubmenuWinston implements IVSubmenu<CSubmenuWinston> {
|
||||
private final JPanel pnlStart = new JPanel();
|
||||
private final StartButton btnStart = new StartButton();
|
||||
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Winston);
|
||||
private final DeckManager lstDecks = new DeckManager(GameType.Winston, null);
|
||||
private final JList<String> lstAI = new FList<String>();
|
||||
|
||||
private final JLabel lblInfo = new FLabel.Builder()
|
||||
|
||||
@@ -20,6 +20,10 @@ public enum CSubmenuAchievements implements ICDoc {
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,10 @@ public enum CSubmenuAvatars implements ICDoc {
|
||||
|
||||
private final VSubmenuAvatars view = VSubmenuAvatars.SINGLETON_INSTANCE;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ public enum CSubmenuDownloaders implements ICDoc {
|
||||
public void run() { BugReporter.reportBug(null); }
|
||||
};
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -47,6 +47,10 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
|
||||
private final List<Pair<JCheckBox, FPref>> lstControls = new ArrayList<Pair<JCheckBox,FPref>>();
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@@ -105,6 +109,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
lstControls.add(Pair.of(view.getCbCompactMainMenu(), FPref.UI_COMPACT_MAIN_MENU));
|
||||
lstControls.add(Pair.of(view.getCbPromptFreeBlocks(), FPref.MATCHPREF_PROMPT_FREE_BLOCKS));
|
||||
lstControls.add(Pair.of(view.getCbPauseWhileMinimized(), FPref.UI_PAUSE_WHILE_MINIMIZED));
|
||||
lstControls.add(Pair.of(view.getCbWorkshopSyntax(), FPref.DEV_WORKSHOP_SYNTAX));
|
||||
|
||||
lstControls.add(Pair.of(view.getCbCompactPrompt(), FPref.UI_COMPACT_PROMPT));
|
||||
lstControls.add(Pair.of(view.getCbHideReminderText(), FPref.UI_HIDE_REMINDER_TEXT));
|
||||
@@ -250,7 +255,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
"the Dock tab -> Save Layout option in the Match screen.\n\n" +
|
||||
"Reset layout?";
|
||||
if (FOptionPane.showConfirmDialog(userPrompt, "Reset Match Screen Layout")) {
|
||||
if (FScreen.MATCH_SCREEN.deleteLayoutFile()) {
|
||||
if (FScreen.deleteMatchLayoutFile()) {
|
||||
FOptionPane.showMessageDialog("Match Screen layout has been reset.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,10 @@ public enum CSubmenuReleaseNotes implements ICDoc {
|
||||
//private ForgePreferences prefs;
|
||||
private boolean isReleaseNotesUpdated = false;
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
package forge.screens.home.settings;
|
||||
|
||||
import forge.Singletons;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.control.FControl.CloseAction;
|
||||
import forge.control.KeyboardShortcuts;
|
||||
import forge.control.KeyboardShortcuts.Shortcut;
|
||||
@@ -13,22 +34,13 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.home.EMenuGroup;
|
||||
import forge.screens.home.IVSubmenu;
|
||||
import forge.screens.home.VHomeUI;
|
||||
import forge.toolbox.*;
|
||||
import forge.toolbox.FCheckBox;
|
||||
import forge.toolbox.FComboBoxPanel;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.toolbox.FSkin.SkinnedTextField;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of preferences submenu singleton.
|
||||
@@ -66,6 +78,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
private final JCheckBox cbManaBurn = new OptionsCheckBox("Mana Burn");
|
||||
private final JCheckBox cbManaLostPrompt = new OptionsCheckBox("Prompt Mana Pool Emptying");
|
||||
private final JCheckBox cbDevMode = new OptionsCheckBox("Developer Mode");
|
||||
private final JCheckBox cbWorkshopSyntax = new OptionsCheckBox("Workshop Syntax Checker");
|
||||
private final JCheckBox cbEnforceDeckLegality = new OptionsCheckBox("Deck Conformance");
|
||||
private final JCheckBox cbCloneImgSource = new OptionsCheckBox("Clones Use Original Card Art");
|
||||
private final JCheckBox cbScaleLarger = new OptionsCheckBox("Scale Image Larger");
|
||||
@@ -181,6 +194,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
pnlPrefs.add(cbDevMode, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Enables menu with functions for testing during development."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbWorkshopSyntax, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Enables syntax checking of card scripts in the Workshop. Note: functionality still in testing phase!"), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbpGameLogEntryType, "w 80%!, gap 10% 0 0 10px, span 2 1");
|
||||
pnlPrefs.add(new NoteLabel("Changes how much information is displayed in the game log. Sorted by least to most verbose."), regularConstraints);
|
||||
|
||||
@@ -240,7 +256,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
final JLabel lblShortcuts = new SectionLabel("Keyboard Shortcuts");
|
||||
pnlPrefs.add(lblShortcuts, sectionConstraints + ", gaptop 2%");
|
||||
|
||||
final List<Shortcut> shortcuts = Singletons.getControl().getShortcuts();
|
||||
final List<Shortcut> shortcuts = KeyboardShortcuts.getKeyboardShortcuts();
|
||||
|
||||
for (final Shortcut s : shortcuts) {
|
||||
pnlPrefs.add(new FLabel.Builder().text(s.getDescription())
|
||||
@@ -486,6 +502,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
return cbDevMode;
|
||||
}
|
||||
|
||||
public JCheckBox getCbWorkshopSyntax() {
|
||||
return cbWorkshopSyntax;
|
||||
}
|
||||
|
||||
public FComboBoxPanel<String> getAiProfilesComboBoxPanel() {
|
||||
return cbpAiProfiles;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,13 @@ import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JPopupMenu;
|
||||
@@ -32,21 +36,30 @@ import javax.swing.MenuElement;
|
||||
import javax.swing.MenuSelectionManager;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.ImageCache;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.Game;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.control.KeyboardShortcuts;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deckchooser.FDeckViewer;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.GameView;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.DelayedReveal;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -62,33 +75,38 @@ import forge.gui.framework.SDisplayUtil;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
import forge.interfaces.IButton;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.match.IMatchController;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.item.PaperCard;
|
||||
import forge.match.AbstractGuiGame;
|
||||
import forge.menus.IMenuProvider;
|
||||
import forge.model.FModel;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.controllers.CAntes;
|
||||
import forge.screens.match.controllers.CCombat;
|
||||
import forge.screens.match.controllers.CDetail;
|
||||
import forge.screens.match.controllers.CDetailPicture;
|
||||
import forge.screens.match.controllers.CDev;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.screens.match.controllers.CLog;
|
||||
import forge.screens.match.controllers.CPicture;
|
||||
import forge.screens.match.controllers.CPlayers;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.controllers.CStack;
|
||||
import forge.screens.match.menus.CMatchUIMenus;
|
||||
import forge.screens.match.views.VCommand;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VHand;
|
||||
import forge.screens.match.views.VPlayers;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.toolbox.special.PhaseIndicator;
|
||||
import forge.toolbox.special.PhaseLabel;
|
||||
import forge.util.FCollectionView;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.view.FView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import forge.view.arcane.FloatingCardArea;
|
||||
|
||||
@@ -100,17 +118,119 @@ import forge.view.arcane.FloatingCardArea;
|
||||
*
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*/
|
||||
public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
SINGLETON_INSTANCE;
|
||||
public final class CMatchUI
|
||||
extends AbstractGuiGame
|
||||
implements ICDoc, IMenuProvider {
|
||||
|
||||
private List<PlayerView> sortedPlayers;
|
||||
private final FScreen screen;
|
||||
|
||||
private FCollectionView<PlayerView> sortedPlayers;
|
||||
/** Players attached to this UI */
|
||||
private VMatchUI view;
|
||||
private boolean allHands;
|
||||
private boolean showOverlay = true;
|
||||
|
||||
private IVDoc<? extends ICDoc> selectedDocBeforeCombat;
|
||||
public final Map<String, String> avatarImages = new HashMap<String, String>();
|
||||
|
||||
private final CAntes cAntes = new CAntes(this);
|
||||
private final CCombat cCombat = new CCombat();
|
||||
private final CDetailPicture cDetailPicture = new CDetailPicture(this);
|
||||
private final CDev cDev = new CDev(this);
|
||||
private final CDock cDock = new CDock(this);
|
||||
private final CLog cLog = new CLog(this);
|
||||
private final CPlayers cPlayers = new CPlayers(this);
|
||||
private final CPrompt cPrompt = new CPrompt(this);
|
||||
private final CStack cStack = new CStack(this);
|
||||
private final TargetingOverlay targetingOverlay = new TargetingOverlay(this);
|
||||
private final Map<EDocID, IVDoc<? extends ICDoc>> myDocs;
|
||||
|
||||
public CMatchUI() {
|
||||
this.view = new VMatchUI(this);
|
||||
this.screen = FScreen.getMatchScreen(this, view);
|
||||
Singletons.getView().getLpnDocument().add(targetingOverlay.getPanel(), FView.TARGETING_LAYER);
|
||||
targetingOverlay.getPanel().setSize(Singletons.getControl().getDisplaySize());
|
||||
this.myDocs = new EnumMap<EDocID, IVDoc<? extends ICDoc>>(EDocID.class);
|
||||
this.myDocs.put(EDocID.CARD_PICTURE, getCDetailPicture().getCPicture().getView());
|
||||
this.myDocs.put(EDocID.CARD_DETAIL, getCDetailPicture().getCDetail().getView());
|
||||
this.myDocs.put(EDocID.CARD_ANTES, getCAntes().getView());
|
||||
this.myDocs.put(EDocID.REPORT_MESSAGE, getCPrompt().getView());
|
||||
this.myDocs.put(EDocID.REPORT_STACK, getCStack().getView());
|
||||
this.myDocs.put(EDocID.REPORT_COMBAT, getCCombat().getView());
|
||||
this.myDocs.put(EDocID.REPORT_LOG, getCLog().getView());
|
||||
this.myDocs.put(EDocID.REPORT_PLAYERS, getCPlayers().getView());
|
||||
this.myDocs.put(EDocID.DEV_MODE, getCDev().getView());
|
||||
this.myDocs.put(EDocID.BUTTON_DOCK, getCDock().getView());;
|
||||
}
|
||||
|
||||
private void registerDocs() {
|
||||
for (final Entry<EDocID, IVDoc<? extends ICDoc>> doc : myDocs.entrySet()) {
|
||||
doc.getKey().setDoc(doc.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCurrentScreen() {
|
||||
return Singletons.getControl().getCurrentScreen() == this.screen;
|
||||
}
|
||||
|
||||
private boolean isInGame() {
|
||||
return getGameView() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameView(final GameView gameView) {
|
||||
super.setGameView(gameView);
|
||||
screen.setTabCaption(gameView.getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCurrentPlayer(final PlayerView player) {
|
||||
// No action necessary
|
||||
}
|
||||
|
||||
public CAntes getCAntes() {
|
||||
return cAntes;
|
||||
}
|
||||
public CCombat getCCombat() {
|
||||
return cCombat;
|
||||
}
|
||||
public CDetailPicture getCDetailPicture() {
|
||||
return cDetailPicture;
|
||||
}
|
||||
public CDev getCDev() {
|
||||
return cDev;
|
||||
}
|
||||
public CDock getCDock() {
|
||||
return cDock;
|
||||
}
|
||||
public CLog getCLog() {
|
||||
return cLog;
|
||||
}
|
||||
public CPlayers getCPlayers() {
|
||||
return cPlayers;
|
||||
}
|
||||
public CPrompt getCPrompt() {
|
||||
return cPrompt;
|
||||
}
|
||||
public CStack getCStack() {
|
||||
return cStack;
|
||||
}
|
||||
public TargetingOverlay getTargetingOverlay() {
|
||||
return targetingOverlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* View deck list.
|
||||
*/
|
||||
public void viewDeckList() {
|
||||
if (!isInGame()) {
|
||||
return;
|
||||
}
|
||||
final Deck deck = getGameView().getDeck(getCurrentPlayer().getLobbyPlayerName());
|
||||
if (deck != null) {
|
||||
FDeckViewer.show(deck);
|
||||
}
|
||||
}
|
||||
|
||||
private SkinImage getPlayerAvatar(final PlayerView p, final int defaultIndex) {
|
||||
if (avatarImages.containsKey(p.getLobbyPlayerName())) {
|
||||
return ImageCache.getIcon(avatarImages.get(p.getLobbyPlayerName()));
|
||||
@@ -125,11 +245,10 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
view.getLblAvatar().getResizeTimer().start();
|
||||
}
|
||||
|
||||
public void initMatch(final List<PlayerView> sortedPlayers0, final boolean allHands0) {
|
||||
sortedPlayers = sortedPlayers0;
|
||||
allHands = allHands0;
|
||||
view = VMatchUI.SINGLETON_INSTANCE;
|
||||
// TODO fix for use with multiplayer
|
||||
public void initMatch(final FCollectionView<PlayerView> sortedPlayers, final FCollectionView<PlayerView> myPlayers) {
|
||||
this.sortedPlayers = sortedPlayers;
|
||||
this.setLocalPlayers(myPlayers);
|
||||
allHands = sortedPlayers.size() == getLocalPlayerCount();
|
||||
|
||||
final String[] indices = FModel.getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
||||
|
||||
@@ -140,10 +259,15 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
for (final PlayerView p : sortedPlayers) {
|
||||
// A field must be initialized after it's instantiated, to update player info.
|
||||
// No player, no init.
|
||||
VField f = new VField(EDocID.Fields[i], p);
|
||||
VCommand c = new VCommand(EDocID.Commands[i], p);
|
||||
final EDocID fieldDoc = EDocID.Fields[i];
|
||||
final VField f = new VField(this, fieldDoc, p);
|
||||
fields.add(f);
|
||||
myDocs.put(fieldDoc, f);
|
||||
|
||||
final EDocID commandDoc = EDocID.Commands[i];
|
||||
final VCommand c = new VCommand(this, commandDoc, p);
|
||||
commands.add(c);
|
||||
myDocs.put(commandDoc, c);
|
||||
|
||||
//setAvatar(f, new ImageIcon(FSkin.getAvatars().get()));
|
||||
setAvatar(f, getPlayerAvatar(p, Integer.parseInt(indices[i > 2 ? 1 : 0])));
|
||||
@@ -152,24 +276,26 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
i++;
|
||||
}
|
||||
|
||||
// Replace old instances
|
||||
view.setCommandViews(commands);
|
||||
view.setFieldViews(fields);
|
||||
|
||||
VPlayers.SINGLETON_INSTANCE.init(sortedPlayers0);
|
||||
getCPlayers().getView().init(this.sortedPlayers);
|
||||
|
||||
initHandViews();
|
||||
registerDocs();
|
||||
}
|
||||
|
||||
public void initHandViews() {
|
||||
private void initHandViews() {
|
||||
final List<VHand> hands = new ArrayList<VHand>();
|
||||
|
||||
int i = 0;
|
||||
for (final PlayerView p : sortedPlayers) {
|
||||
if (allHands || !p.isAI() || CardView.mayViewAny(p.getHand(), p)) {
|
||||
VHand newHand = new VHand(EDocID.Hands[i], p);
|
||||
if (allHands || isLocalPlayer(p) || CardView.mayViewAny(p.getHand(), getCurrentPlayer())) {
|
||||
final EDocID doc = EDocID.Hands[i];
|
||||
final VHand newHand = new VHand(this, doc, p);
|
||||
newHand.getLayoutControl().initialize();
|
||||
hands.add(newHand);
|
||||
myDocs.put(doc, newHand);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -187,23 +313,28 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
}
|
||||
|
||||
public void showMessage(final String s0) {
|
||||
CPrompt.SINGLETON_INSTANCE.setMessage(s0);
|
||||
public List<VField> getFieldViews() {
|
||||
return view.getFieldViews();
|
||||
}
|
||||
public VField getFieldViewFor(final PlayerView p) {
|
||||
final int idx = getPlayerIndex(p);
|
||||
return idx < 0 ? null : getFieldViews().get(idx);
|
||||
}
|
||||
|
||||
public VField getFieldViewFor(PlayerView p) {
|
||||
int idx = getPlayerIndex(p);
|
||||
return idx < 0 ? null :view.getFieldViews().get(idx);
|
||||
public List<VCommand> getCommandViews() {
|
||||
return view.getCommandViews();
|
||||
}
|
||||
public VCommand getCommandFor(final PlayerView p) {
|
||||
final int idx = getPlayerIndex(p);
|
||||
return idx < 0 ? null : getCommandViews().get(idx);
|
||||
}
|
||||
|
||||
public VCommand getCommandFor(PlayerView p) {
|
||||
int idx = getPlayerIndex(p);
|
||||
return idx < 0 ? null :view.getCommandViews().get(idx);
|
||||
public List<VHand> getHandViews() {
|
||||
return view.getHands();
|
||||
}
|
||||
|
||||
public VHand getHandFor(PlayerView p) {
|
||||
int idx = getPlayerIndex(p);
|
||||
List<VHand> allHands = view.getHands();
|
||||
public VHand getHandFor(final PlayerView p) {
|
||||
final int idx = getPlayerIndex(p);
|
||||
final List<VHand> allHands = getHandViews();
|
||||
return idx < 0 || idx >= allHands.size() ? null : allHands.get(idx);
|
||||
}
|
||||
|
||||
@@ -215,26 +346,25 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
* @param phase   {@link java.lang.String}
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public final boolean stopAtPhase(final PlayerView turn, final PhaseType phase) {
|
||||
VField vf = getFieldViewFor(turn);
|
||||
PhaseLabel label = vf.getPhaseIndicator()
|
||||
.getLabelFor(phase);
|
||||
final VField vf = getFieldViewFor(turn);
|
||||
final PhaseLabel label = vf.getPhaseIndicator() .getLabelFor(phase);
|
||||
return label == null || label.getEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCard(final CardView c) {
|
||||
this.setCard(c, false);
|
||||
}
|
||||
|
||||
public void setCard(final CardView c, final boolean isInAltState) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
CDetail.SINGLETON_INSTANCE.showCard(c, isInAltState);
|
||||
CPicture.SINGLETON_INSTANCE.showCard(c, isInAltState);
|
||||
cDetailPicture.showCard(c, isInAltState);
|
||||
}
|
||||
|
||||
public void setCard(final InventoryItem c) {
|
||||
CDetail.SINGLETON_INSTANCE.showCard(c);
|
||||
CPicture.SINGLETON_INSTANCE.showImage(c);
|
||||
public void setCard(final InventoryItem item) {
|
||||
cDetailPicture.showItem(item);
|
||||
}
|
||||
|
||||
private int getPlayerIndex(PlayerView player) {
|
||||
@@ -243,8 +373,8 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public void showCombat() {
|
||||
CombatView combat = MatchUtil.getGameView().getCombat();
|
||||
if (combat != null && combat.getNumAttackers() > 0 && MatchUtil.getGameView().peekStack() == null) {
|
||||
final CombatView combat = getGameView().getCombat();
|
||||
if (combat != null && combat.getNumAttackers() > 0 && getGameView().peekStack() == null) {
|
||||
if (selectedDocBeforeCombat == null) {
|
||||
IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc();
|
||||
if (combatDoc.getParentCell() != null) {
|
||||
@@ -262,22 +392,22 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
SDisplayUtil.showTab(selectedDocBeforeCombat);
|
||||
selectedDocBeforeCombat = null;
|
||||
}
|
||||
CCombat.SINGLETON_INSTANCE.setModel(combat);
|
||||
CCombat.SINGLETON_INSTANCE.update();
|
||||
getCCombat().setModel(combat);
|
||||
getCCombat().update();
|
||||
} // showCombat(CombatView)
|
||||
|
||||
public void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate) {
|
||||
//System.out.println("updateZones " + zonesToUpdate);
|
||||
for (Pair<PlayerView, ZoneType> kv : zonesToUpdate) {
|
||||
PlayerView owner = kv.getKey();
|
||||
ZoneType zt = kv.getValue();
|
||||
@Override
|
||||
public void updateZones(final List<Pair<PlayerView, ZoneType>> zonesToUpdate) {
|
||||
for (final Pair<PlayerView, ZoneType> kv : zonesToUpdate) {
|
||||
final PlayerView owner = kv.getKey();
|
||||
final ZoneType zt = kv.getValue();
|
||||
|
||||
switch (zt) {
|
||||
case Battlefield:
|
||||
getFieldViewFor(owner).getTabletop().setupPlayZone();
|
||||
break;
|
||||
case Hand:
|
||||
VHand vHand = getHandFor(owner);
|
||||
final VHand vHand = getHandFor(owner);
|
||||
if (vHand != null) {
|
||||
vHand.getLayoutControl().updateHand();
|
||||
}
|
||||
@@ -288,7 +418,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
getCommandFor(owner).getTabletop().setupPlayZone();
|
||||
break;
|
||||
case Ante:
|
||||
CAntes.SINGLETON_INSTANCE.update();
|
||||
cAntes.update();
|
||||
break;
|
||||
default:
|
||||
final VField vf = getFieldViewFor(owner);
|
||||
@@ -302,6 +432,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
|
||||
// Player's mana pool changes
|
||||
@Override
|
||||
public void updateManaPool(final Iterable<PlayerView> manaPoolUpdate) {
|
||||
for (final PlayerView p : manaPoolUpdate) {
|
||||
getFieldViewFor(p).getDetailsPanel().updateManaPool();
|
||||
@@ -310,19 +441,21 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
|
||||
// Player's lives and poison counters
|
||||
@Override
|
||||
public void updateLives(final Iterable<PlayerView> livesUpdate) {
|
||||
for (final PlayerView p : livesUpdate) {
|
||||
getFieldViewFor(p).updateDetails();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSingleCard(final CardView c) {
|
||||
ZoneType zone = c.getZone();
|
||||
final ZoneType zone = c.getZone();
|
||||
if (zone == null) { return; }
|
||||
|
||||
switch (zone) {
|
||||
case Battlefield:
|
||||
VField battlefield = getFieldViewFor(c.getController());
|
||||
final VField battlefield = getFieldViewFor(c.getController());
|
||||
if (battlefield != null) {
|
||||
battlefield.getTabletop().updateCard(c, false);
|
||||
}
|
||||
@@ -337,7 +470,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
break;
|
||||
case Command:
|
||||
VCommand command = getCommandFor(c.getController());
|
||||
final VCommand command = getCommandFor(c.getController());
|
||||
if (command != null) {
|
||||
command.getTabletop().updateCard(c, false);
|
||||
}
|
||||
@@ -347,15 +480,9 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshCardDetails(final Iterable<CardView> cards) {
|
||||
for (final CardView c : cards) {
|
||||
updateSingleCard(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JMenu> getMenus() {
|
||||
return new CMatchUIMenus().getMenus();
|
||||
return new CMatchUIMenus(this).getMenus(cDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -364,28 +491,42 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
Singletons.getControl().getForgeMenu().setProvider(this);
|
||||
public void register() {
|
||||
initHandViews();
|
||||
registerDocs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() { }
|
||||
public void initialize() {
|
||||
Singletons.getControl().getForgeMenu().setProvider(this);
|
||||
updatePlayerControl();
|
||||
KeyboardShortcuts.attachKeyboardShortcuts(this);
|
||||
for (final IVDoc<? extends ICDoc> view : myDocs.values()) {
|
||||
final ICDoc layoutControl = view.getLayoutControl();
|
||||
layoutControl.initialize();
|
||||
layoutControl.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
public void repaintCardOverlays() {
|
||||
List<CardPanel> panels = getVisibleCardPanels();
|
||||
for (CardPanel panel : panels) {
|
||||
final List<CardPanel> panels = getVisibleCardPanels();
|
||||
for (final CardPanel panel : panels) {
|
||||
panel.repaintOverlays();
|
||||
}
|
||||
}
|
||||
private List<CardPanel> getVisibleCardPanels() {
|
||||
List<CardPanel> panels = new ArrayList<CardPanel>();
|
||||
for (VHand h : view.getHands()) {
|
||||
final List<CardPanel> panels = new ArrayList<CardPanel>();
|
||||
for (final VHand h : view.getHands()) {
|
||||
panels.addAll(h.getHandArea().getCardPanels());
|
||||
}
|
||||
for (VField f : view.getFieldViews()) {
|
||||
for (final VField f : view.getFieldViews()) {
|
||||
panels.addAll(f.getTabletop().getCardPanels());
|
||||
}
|
||||
for (VCommand c : view.getCommandViews()) {
|
||||
for (final VCommand c : view.getCommandViews()) {
|
||||
panels.addAll(c.getTabletop().getCardPanels());
|
||||
}
|
||||
return panels;
|
||||
@@ -393,28 +534,17 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public boolean resetForNewGame() {
|
||||
if (MatchUtil.getGame() != null) {
|
||||
Singletons.getControl().setCurrentScreen(FScreen.MATCH_SCREEN);
|
||||
SOverlayUtils.hideOverlay();
|
||||
FOptionPane.showMessageDialog("Cannot start a new game while another game is already in progress.");
|
||||
return false; //TODO: See if it's possible to run multiple games at once without crashing
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hotSeatMode() {
|
||||
return true; //Desktop game only supports hot seat mode for Human v. Human
|
||||
public IButton getBtnOK(final PlayerView playerView) {
|
||||
return view.getBtnOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButton getBtnOK(PlayerView playerView) {
|
||||
return VMatchUI.SINGLETON_INSTANCE.getBtnOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButton getBtnCancel(PlayerView playerView) {
|
||||
return VMatchUI.SINGLETON_INSTANCE.getBtnCancel();
|
||||
public IButton getBtnCancel(final PlayerView playerView) {
|
||||
return view.getBtnCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,18 +562,16 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public void flashIncorrectAction() {
|
||||
SDisplayUtil.remind(VPrompt.SINGLETON_INSTANCE);
|
||||
SDisplayUtil.remind(getCPrompt().getView());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
GameView gameView = MatchUtil.getGameView();
|
||||
final PlayerView p = gameView.getPlayerTurn();
|
||||
final PhaseType ph = gameView.getPhase();
|
||||
final CMatchUI matchUi = CMatchUI.SINGLETON_INSTANCE;
|
||||
PhaseLabel lbl = matchUi.getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph);
|
||||
final PlayerView p = getGameView().getPlayerTurn();
|
||||
final PhaseType ph = getGameView().getPhase();
|
||||
PhaseLabel lbl = getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph);
|
||||
|
||||
matchUi.resetAllPhaseButtons();
|
||||
resetAllPhaseButtons();
|
||||
if (lbl != null) {
|
||||
lbl.setActive(true);
|
||||
}
|
||||
@@ -451,18 +579,18 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public void updateTurn(final PlayerView player) {
|
||||
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(player);
|
||||
VField nextField = getFieldViewFor(player);
|
||||
SDisplayUtil.showTab(nextField);
|
||||
CPrompt.SINGLETON_INSTANCE.updateText();
|
||||
CMatchUI.SINGLETON_INSTANCE.repaintCardOverlays();
|
||||
cPrompt.updateText();
|
||||
repaintCardOverlays();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlayerControl() {
|
||||
CMatchUI.SINGLETON_INSTANCE.initHandViews();
|
||||
initHandViews();
|
||||
SLayoutIO.loadLayout(null);
|
||||
VMatchUI.SINGLETON_INSTANCE.populate();
|
||||
for (VHand h : VMatchUI.SINGLETON_INSTANCE.getHands()) {
|
||||
view.populate();
|
||||
for (final VHand h : getHandViews()) {
|
||||
h.getLayoutControl().updateHand();
|
||||
}
|
||||
}
|
||||
@@ -480,7 +608,9 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
@Override
|
||||
public void finishGame() {
|
||||
FloatingCardArea.closeAll(); //ensure floating card areas cleared and closed after the game
|
||||
new ViewWinLose(MatchUtil.getGameView());
|
||||
if (hasLocalPlayers() || getGameView().isMatchOver()) {
|
||||
new ViewWinLose(getGameView(), this);
|
||||
}
|
||||
if (showOverlay) {
|
||||
SOverlayUtils.showOverlay();
|
||||
}
|
||||
@@ -488,12 +618,38 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public void updateStack() {
|
||||
CStack.SINGLETON_INSTANCE.update();
|
||||
getCStack().update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all visually highlighted card panels on the battlefield.
|
||||
*/
|
||||
public void clearPanelSelections() {
|
||||
final List<VField> fields = view.getFieldViews();
|
||||
for (final VField field : fields) {
|
||||
for (final CardPanel p : field.getTabletop().getCardPanels()) {
|
||||
p.setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight a card on the playfield.
|
||||
*
|
||||
* @param card
|
||||
* a card to be highlighted
|
||||
*/
|
||||
@Override
|
||||
public void setPanelSelection(final CardView c) {
|
||||
GuiUtils.setPanelSelection(c);
|
||||
public void setPanelSelection(final CardView card) {
|
||||
for (final VField v : view.getFieldViews()) {
|
||||
final List<CardPanel> panels = v.getTabletop().getCardPanels();
|
||||
for (final CardPanel p : panels) {
|
||||
if (p.getCard().equals(card)) {
|
||||
p.setSelected(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -534,7 +690,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CPrompt.SINGLETON_INSTANCE.selectAbility(ab);
|
||||
cPrompt.selectAbility(ab);
|
||||
}
|
||||
}, enabled);
|
||||
if (shortcut > 0) {
|
||||
@@ -559,7 +715,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
@Override
|
||||
public void showPromptMessage(final PlayerView playerView, final String message) {
|
||||
CMatchUI.SINGLETON_INSTANCE.showMessage(message);
|
||||
cPrompt.setMessage(message);
|
||||
}
|
||||
|
||||
public Object showManaPool(final PlayerView player) {
|
||||
@@ -571,6 +727,121 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
//not needed since mana pool icons are always visible
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<CardView, Integer> assignDamage(final CardView attacker,
|
||||
final List<CardView> blockers, final int damage,
|
||||
final GameEntityView defender, final boolean overrideOrder) {
|
||||
if (damage <= 0) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
// If the first blocker can absorb all of the damage, don't show the Assign Damage dialog
|
||||
final CardView firstBlocker = blockers.get(0);
|
||||
if (!overrideOrder && !attacker.getCurrentState().hasDeathtouch() && firstBlocker.getLethalDamage() >= damage) {
|
||||
return ImmutableMap.of(firstBlocker, damage);
|
||||
}
|
||||
|
||||
final AtomicReference<Map<CardView, Integer>> result = new AtomicReference<Map<CardView,Integer>>();
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final VAssignDamage v = new VAssignDamage(CMatchUI.this, attacker, blockers, damage, defender, overrideOrder);
|
||||
result.set(v.getDamageMap());
|
||||
}});
|
||||
return result.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hear(LobbyPlayer player, String message) {
|
||||
FNetOverlay.SINGLETON_INSTANCE.addMessage(player.getName(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openView(final FCollectionView<PlayerView> myPlayers) {
|
||||
getGameView().getGameLog().addObserver(getCLog());
|
||||
|
||||
initMatch(getGameView().getPlayers(), myPlayers);
|
||||
|
||||
actuateMatchPreferences();
|
||||
|
||||
Singletons.getControl().setCurrentScreen(screen);
|
||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||
|
||||
// per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch
|
||||
//Set Field shown to current player.
|
||||
//if (util.getHumanCount() > 0) {
|
||||
final VField nextField = getFieldViewFor(getGameView().getPlayers().get(0));
|
||||
SDisplayUtil.showTab(nextField);
|
||||
//}
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterGameEnd() {
|
||||
Singletons.getView().getNavigationBar().closeTab(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showOptionDialog(final String message, final String title, final FSkinProp icon, final String[] options, final int defaultOption) {
|
||||
return FOptionPane.showOptionDialog(message, title, icon == null ? null : FSkin.getImage(icon), options, defaultOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showCardOptionDialog(final CardView card, final String message, final String title, final FSkinProp skinIcon, final String[] options, final int defaultOption) {
|
||||
if (card != null) {
|
||||
setCard(card);
|
||||
}
|
||||
return showOptionDialog(message, title, skinIcon, options, defaultOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String showInputDialog(final String message, final String title, final FSkinProp icon, final String initialInput, final String[] inputOptions) {
|
||||
return FOptionPane.showInputDialog(message, title, icon == null ? null : FSkin.getImage(icon), initialInput, inputOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display) {
|
||||
/*if ((choices != null && !choices.isEmpty() && choices.iterator().next() instanceof GameObject) || selected instanceof GameObject) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}*/
|
||||
return GuiChoose.getChoices(message, min, max, choices, selected, display);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
/*if ((sourceChoices != null && !sourceChoices.isEmpty() && sourceChoices.iterator().next() instanceof GameObject)
|
||||
|| (destChoices != null && !destChoices.isEmpty() && destChoices.iterator().next() instanceof GameObject)) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}*/
|
||||
return GuiChoose.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperCard> sideboard(final CardPool sideboard, final CardPool main) {
|
||||
return GuiChoose.sideboard(this, sideboard.toFlatList(), main.toFlatList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameEntityView chooseSingleEntityForEffect(final String title, final FCollectionView<? extends GameEntity> optionList, final DelayedReveal delayedReveal, final boolean isOptional, final PlayerControllerHuman controller) {
|
||||
if (delayedReveal != null) {
|
||||
delayedReveal.reveal(controller); //TODO: Merge this into search dialog
|
||||
}
|
||||
controller.tempShow(optionList);
|
||||
final List<GameEntityView> gameEntityViews = GameEntityView.getEntityCollection(optionList);
|
||||
if (isOptional) {
|
||||
return oneOrNone(title, gameEntityViews);
|
||||
}
|
||||
return one(title, gameEntityViews);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerAvatar(final LobbyPlayer player, final IHasIcon ihi) {
|
||||
avatarImages.put(player.getName(), ihi.getIconImageKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZones(final Collection<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
@@ -589,66 +860,10 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
public void restoreOldZones(final Map<PlayerView, Object> playersToRestoreZonesFor) {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<CardView, Integer> assignDamage(final CardView attacker,
|
||||
final List<CardView> blockers, final int damage,
|
||||
final GameEntityView defender, final boolean overrideOrder) {
|
||||
final Object[] result = { null }; // how else can I extract a value from EDT thread?
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VAssignDamage v = new VAssignDamage(attacker, blockers, damage, defender, overrideOrder);
|
||||
result[0] = v.getDamageMap();
|
||||
}});
|
||||
return (Map<CardView, Integer>)result[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hear(LobbyPlayer player, String message) {
|
||||
FNetOverlay.SINGLETON_INSTANCE.addMessage(player.getName(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startNewMatch(final Match match) {
|
||||
SOverlayUtils.startGameOverlay();
|
||||
SOverlayUtils.showOverlay();
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.startGame(match);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openView(List<Player> sortedPlayers) {
|
||||
Game game = MatchUtil.getGame();
|
||||
game.getGameLog().addObserver(CLog.SINGLETON_INSTANCE);
|
||||
|
||||
List<PlayerView> sortedPlayerViews = new ArrayList<PlayerView>();
|
||||
for (Player p : sortedPlayers) {
|
||||
sortedPlayerViews.add(PlayerView.get(p));
|
||||
}
|
||||
CMatchUI.SINGLETON_INSTANCE.initMatch(sortedPlayerViews, MatchUtil.getHumanCount() != 1);
|
||||
|
||||
actuateMatchPreferences();
|
||||
|
||||
Singletons.getControl().setCurrentScreen(FScreen.MATCH_SCREEN);
|
||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||
|
||||
// per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch
|
||||
//Set Field shown to current player.
|
||||
if (MatchUtil.getHumanCount() > 0) {
|
||||
final VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(sortedPlayerViews.get(0));
|
||||
SDisplayUtil.showTab(nextField);
|
||||
}
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterGameEnd() {
|
||||
Singletons.getView().getNavigationBar().closeTab(FScreen.MATCH_SCREEN);
|
||||
public boolean isUiSetToSkipPhase(final PlayerView playerTurn, final PhaseType phase) {
|
||||
final PhaseLabel label = getFieldViewFor(playerTurn).getPhaseIndicator().getLabelFor(phase);
|
||||
return label != null && !label.getEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -656,7 +871,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
*/
|
||||
public void writeMatchPreferences() {
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
final List<VField> fieldViews = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||
final List<VField> fieldViews = getFieldViews();
|
||||
|
||||
// AI field is at index [1]
|
||||
PhaseIndicator fvAi = fieldViews.get(1).getPhaseIndicator();
|
||||
@@ -696,7 +911,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
*/
|
||||
private void actuateMatchPreferences() {
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
final List<VField> fieldViews = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||
final List<VField> fieldViews = getFieldViews();
|
||||
|
||||
// Human field is at index [0]
|
||||
PhaseIndicator fvHuman = fieldViews.get(0).getPhaseIndicator();
|
||||
@@ -732,4 +947,31 @@ public enum CMatchUI implements ICDoc, IMenuProvider, IMatchController {
|
||||
|
||||
//Singletons.getView().getViewMatch().setLayoutParams(prefs.getPref(FPref.UI_LAYOUT_PARAMS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(String message, String title) {
|
||||
SOptionPane.showMessageDialog(message, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showErrorDialog(String message, String title) {
|
||||
SOptionPane.showErrorDialog(message, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||
final String title = c == null ? "Question" : c + " - Ability";
|
||||
final String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
||||
final String[] opts = options == null ? SGuiChoose.defaultConfirmOptions : options;
|
||||
final int reply = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
|
||||
return reply == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showConfirmDialog(final String message, final String title, final String yesButtonText, final String noButtonText, final boolean defaultYes) {
|
||||
final String[] options = {yesButtonText, noButtonText};
|
||||
final int reply = SOptionPane.showOptionDialog(message, title, SOptionPane.QUESTION_ICON, options, defaultYes ? 0 : 1);
|
||||
return reply == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import forge.Singletons;
|
||||
import forge.game.GameView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.interfaces.IGameController;
|
||||
import forge.match.NextGameDecision;
|
||||
|
||||
/**
|
||||
* Default controller for a ViewWinLose object. This class can
|
||||
@@ -20,12 +21,14 @@ import forge.match.MatchUtil;
|
||||
public class ControlWinLose {
|
||||
private final ViewWinLose view;
|
||||
protected final GameView lastGame;
|
||||
protected final CMatchUI matchUI;
|
||||
|
||||
/** @param v   ViewWinLose
|
||||
* @param match */
|
||||
public ControlWinLose(final ViewWinLose v, final GameView game0) {
|
||||
public ControlWinLose(final ViewWinLose v, final GameView game0, final CMatchUI matchUI) {
|
||||
this.view = v;
|
||||
this.lastGame = game0;
|
||||
this.matchUI = matchUI;
|
||||
addListeners();
|
||||
}
|
||||
|
||||
@@ -58,21 +61,27 @@ public class ControlWinLose {
|
||||
public void actionOnContinue() {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
MatchUtil.continueMatch();
|
||||
for (final IGameController controller : matchUI.getGameControllers()) {
|
||||
controller.nextGameDecision(NextGameDecision.CONTINUE);
|
||||
}
|
||||
}
|
||||
|
||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||
public void actionOnRestart() {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
MatchUtil.restartMatch();
|
||||
for (final IGameController controller : matchUI.getGameControllers()) {
|
||||
controller.nextGameDecision(NextGameDecision.NEW);
|
||||
}
|
||||
}
|
||||
|
||||
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
||||
public void actionOnQuit() {
|
||||
// Reset other stuff
|
||||
saveOptions();
|
||||
MatchUtil.endCurrentGame();
|
||||
for (final IGameController controller : matchUI.getGameControllers()) {
|
||||
controller.nextGameDecision(NextGameDecision.QUIT);
|
||||
}
|
||||
Singletons.getControl().setCurrentScreen(FScreen.HOME_SCREEN);
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
@@ -82,7 +91,7 @@ public class ControlWinLose {
|
||||
* with other game modes.
|
||||
*/
|
||||
public void saveOptions() {
|
||||
CMatchUI.SINGLETON_INSTANCE.writeMatchPreferences();
|
||||
matchUI.writeMatchPreferences();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,8 +45,8 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match
|
||||
*/
|
||||
public GauntletWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
public GauntletWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) {
|
||||
super(view0, game0, matchUI);
|
||||
controller = new GauntletWinLoseController(view0, game0) {
|
||||
@Override
|
||||
protected void showOutcome(String message1, String message2, FSkinProp icon, List<String> lstEventNames, List<String> lstEventRecords, int len, int num) {
|
||||
|
||||
@@ -46,8 +46,8 @@ public class LimitedWinLose extends ControlWinLose {
|
||||
* @param view0 {@link forge.screens.match.ViewWinLose}
|
||||
* @param match {@link forge.game.Match}
|
||||
*/
|
||||
public LimitedWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
public LimitedWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) {
|
||||
super(view0, game0, matchUI);
|
||||
controller = new LimitedWinLoseController(view0, game0) {
|
||||
@Override
|
||||
protected void showOutcome(Runnable runnable) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package forge.screens.match;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
@@ -25,7 +26,7 @@ import forge.game.GameView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.match.NextGameDecision;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.quest.QuestController;
|
||||
@@ -48,7 +49,6 @@ import forge.toolbox.FSkin;
|
||||
*/
|
||||
public class QuestDraftWinLose extends ControlWinLose {
|
||||
private final transient ViewWinLose view;
|
||||
|
||||
private final transient QuestController qData;
|
||||
|
||||
/**
|
||||
@@ -57,8 +57,8 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestDraftWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
public QuestDraftWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) {
|
||||
super(view0, game0, matchUI);
|
||||
this.view = view0;
|
||||
qData = FModel.getQuest();
|
||||
}
|
||||
@@ -97,11 +97,11 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
if (lastGame.isMatchOver()) {
|
||||
this.actionOnQuitMatch();
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.update();
|
||||
QuestDraftUtils.update(matchUI);
|
||||
}
|
||||
else {
|
||||
this.actionOnContinue();
|
||||
QuestDraftUtils.update();
|
||||
QuestDraftUtils.update(matchUI);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -113,21 +113,20 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
view.getBtnQuit().setEnabled(true);
|
||||
view.getBtnContinue().setEnabled(false);
|
||||
view.getBtnQuit().setText("Continue Tournament");
|
||||
for (ActionListener listener : view.getBtnQuit().getActionListeners()) {
|
||||
for (final ActionListener listener : view.getBtnQuit().getActionListeners()) {
|
||||
view.getBtnQuit().removeActionListener(listener);
|
||||
}
|
||||
view.getBtnQuit().addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
MatchUtil.endCurrentGame();
|
||||
matchUI.getGameController().nextGameDecision(NextGameDecision.CONTINUE);
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.continueMatches();
|
||||
QuestDraftUtils.continueMatches(matchUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
view.getBtnQuit().setEnabled(true);
|
||||
for (ActionListener listener : view.getBtnQuit().getActionListeners()) {
|
||||
for (final ActionListener listener : view.getBtnQuit().getActionListeners()) {
|
||||
view.getBtnQuit().removeActionListener(listener);
|
||||
}
|
||||
view.getBtnQuit().setText("Forfeit Tournament");
|
||||
@@ -135,9 +134,9 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (FOptionPane.showOptionDialog("Quitting the match now will forfeit the tournament!\n\nReally quit?", "Really Quit Tournament?", FSkin.getImage(FSkinProp.ICO_WARNING).scale(2), new String[] { "Yes", "No" }, 1) == 0) {
|
||||
MatchUtil.endCurrentGame();
|
||||
matchUI.getGameController().nextGameDecision(NextGameDecision.QUIT);
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.continueMatches();
|
||||
QuestDraftUtils.continueMatches(matchUI);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -156,9 +155,8 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
qData.setCurrentEvent(null);
|
||||
qData.save();
|
||||
FModel.getQuestPreferences().save();
|
||||
CMatchUI.SINGLETON_INSTANCE.writeMatchPreferences();
|
||||
matchUI.writeMatchPreferences();
|
||||
|
||||
MatchUtil.endCurrentGame();
|
||||
Singletons.getControl().setCurrentScreen(FScreen.HOME_SCREEN);
|
||||
|
||||
SOverlayUtils.hideOverlay();
|
||||
|
||||
@@ -39,8 +39,8 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestWinLose(final ViewWinLose view0, final GameView game0) {
|
||||
super(view0, game0);
|
||||
public QuestWinLose(final ViewWinLose view0, final GameView game0, final CMatchUI matchUI) {
|
||||
super(view0, game0, matchUI);
|
||||
controller = new QuestWinLoseController(game0, view0);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@@ -40,11 +41,8 @@ import forge.game.card.CardView;
|
||||
import forge.game.combat.CombatView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.StackItemView;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.screens.match.controllers.CDock.ArcState;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VStack;
|
||||
import forge.screens.match.views.VStack.StackInstanceTextArea;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
@@ -56,9 +54,8 @@ import forge.view.arcane.CardPanel;
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public enum TargetingOverlay {
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
public class TargetingOverlay {
|
||||
private final CMatchUI matchUI;
|
||||
private final OverlayPanel pnl = new OverlayPanel();
|
||||
private final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||
private final List<Arc> arcsFoe = new ArrayList<Arc>();
|
||||
@@ -67,7 +64,7 @@ public enum TargetingOverlay {
|
||||
private static class Arc {
|
||||
private final int x1, y1, x2, y2;
|
||||
|
||||
private Arc(Point end, Point start) {
|
||||
private Arc(final Point end, final Point start) {
|
||||
x1 = start.x;
|
||||
y1 = start.y;
|
||||
x2 = end.x;
|
||||
@@ -75,15 +72,16 @@ public enum TargetingOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<CardView> cardsVisualized = new HashSet<CardView>();
|
||||
private final Set<CardView> cardsVisualized = new HashSet<CardView>();
|
||||
private CardPanel activePanel = null;
|
||||
|
||||
/**
|
||||
* Semi-transparent overlay panel. Should be used with layered panes.
|
||||
*/
|
||||
private TargetingOverlay() {
|
||||
public TargetingOverlay(final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
pnl.setOpaque(false);
|
||||
pnl.setVisible(false);
|
||||
pnl.setVisible(true);
|
||||
pnl.setFocusTraversalKeysEnabled(false);
|
||||
pnl.setBackground(FSkin.getColor(FSkin.Colors.CLR_ZEBRA));
|
||||
}
|
||||
@@ -103,18 +101,18 @@ public enum TargetingOverlay {
|
||||
cardPanels.clear();
|
||||
cardsVisualized.clear();
|
||||
|
||||
StackInstanceTextArea activeStackItem = VStack.SINGLETON_INSTANCE.getHoveredItem();
|
||||
final StackInstanceTextArea activeStackItem = matchUI.getCStack().getView().getHoveredItem();
|
||||
|
||||
switch (CDock.SINGLETON_INSTANCE.getArcState()) {
|
||||
case 0:
|
||||
switch (matchUI.getCDock().getArcState()) {
|
||||
case OFF:
|
||||
return;
|
||||
case 1:
|
||||
case MOUSEOVER:
|
||||
// Draw only hovered card
|
||||
activePanel = null;
|
||||
for (VField f : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
for (final VField f : matchUI.getFieldViews()) {
|
||||
cardPanels.addAll(f.getTabletop().getCardPanels());
|
||||
List<CardPanel> cPanels = f.getTabletop().getCardPanels();
|
||||
for (CardPanel c : cPanels) {
|
||||
final List<CardPanel> cPanels = f.getTabletop().getCardPanels();
|
||||
for (final CardPanel c : cPanels) {
|
||||
if (c.isSelected()) {
|
||||
activePanel = c;
|
||||
break;
|
||||
@@ -123,9 +121,9 @@ public enum TargetingOverlay {
|
||||
}
|
||||
if (activePanel == null && activeStackItem == null) { return; }
|
||||
break;
|
||||
default:
|
||||
case ON:
|
||||
// Draw all
|
||||
for (VField f : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
for (final VField f : matchUI.getFieldViews()) {
|
||||
cardPanels.addAll(f.getTabletop().getCardPanels());
|
||||
}
|
||||
}
|
||||
@@ -147,7 +145,7 @@ public enum TargetingOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
if (CDock.SINGLETON_INSTANCE.getArcState() == 1) {
|
||||
if (matchUI.getCDock().getArcState() == ArcState.MOUSEOVER) {
|
||||
// Only work with the active panel
|
||||
if (activePanel != null) {
|
||||
addArcsForCard(activePanel.getCard(), endpoints, combat);
|
||||
@@ -185,9 +183,9 @@ public enum TargetingOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
private Point getPlayerTargetingArrowPoint(PlayerView p, Point locOnScreen) {
|
||||
JPanel avatarArea = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(p).getAvatarArea();
|
||||
Point point = avatarArea.getLocationOnScreen();
|
||||
private Point getPlayerTargetingArrowPoint(final PlayerView p, final Point locOnScreen) {
|
||||
final JPanel avatarArea = matchUI.getFieldViewFor(p).getAvatarArea();
|
||||
final Point point = avatarArea.getLocationOnScreen();
|
||||
point.x += avatarArea.getWidth() / 2 - locOnScreen.x;
|
||||
point.y += avatarArea.getHeight() / 2 - locOnScreen.y;
|
||||
return point;
|
||||
@@ -350,7 +348,7 @@ public enum TargetingOverlay {
|
||||
g2d.setTransform(af);
|
||||
}
|
||||
|
||||
public void drawArcs(Graphics2D g2d, Color color, List<Arc> arcs) {
|
||||
private void drawArcs(Graphics2D g2d, Color color, List<Arc> arcs) {
|
||||
for (Arc arc : arcs) {
|
||||
drawArrow(g2d, arc.x1, arc.y1, arc.x2, arc.y2, color);
|
||||
}
|
||||
@@ -367,16 +365,19 @@ public enum TargetingOverlay {
|
||||
@Override
|
||||
public void paintComponent(final Graphics g) {
|
||||
// No need for this except in match view
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.paintComponent(g);
|
||||
|
||||
// 0 is off
|
||||
int overlaystate = CDock.SINGLETON_INSTANCE.getArcState();
|
||||
if (overlaystate == 0) { return; }
|
||||
final ArcState overlaystate = matchUI.getCDock().getArcState();
|
||||
|
||||
// Arcs are off
|
||||
if (overlaystate == ArcState.OFF) { return; }
|
||||
|
||||
// Arc drawing
|
||||
final GameView gameView = MatchUtil.getGameView();
|
||||
final GameView gameView = matchUI.getGameView();
|
||||
if (gameView != null) {
|
||||
assembleArcs(gameView.getCombat());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
@@ -60,6 +59,8 @@ import forge.view.arcane.CardPanel;
|
||||
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
|
||||
*/
|
||||
public class VAssignDamage {
|
||||
private final CMatchUI matchUI;
|
||||
|
||||
// Width and height of blocker dialog
|
||||
private final int wDlg = 700;
|
||||
private final int hDlg = 500;
|
||||
@@ -82,7 +83,7 @@ public class VAssignDamage {
|
||||
private final FButton btnReset = new FButton("Reset");
|
||||
private final FButton btnAuto = new FButton("Auto");
|
||||
|
||||
|
||||
|
||||
private static class DamageTarget {
|
||||
public final CardView card;
|
||||
public final JLabel label;
|
||||
@@ -145,7 +146,9 @@ public class VAssignDamage {
|
||||
* @param overrideOrder override combatant order
|
||||
|
||||
*/
|
||||
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender0, boolean overrideOrder) {
|
||||
public VAssignDamage(final CMatchUI matchUI, final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender0, boolean overrideOrder) {
|
||||
this.matchUI = matchUI;
|
||||
|
||||
dlg.setTitle("Assign damage dealt by " + attacker);
|
||||
|
||||
// Set damage storage vars
|
||||
@@ -162,7 +165,7 @@ public class VAssignDamage {
|
||||
pnlMain.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
|
||||
// Attacker area
|
||||
final CardPanel pnlAttacker = new CardPanel(attacker);
|
||||
final CardPanel pnlAttacker = new CardPanel(matchUI, attacker);
|
||||
pnlAttacker.setOpaque(false);
|
||||
pnlAttacker.setCardBounds(0, 0, 105, 150);
|
||||
|
||||
@@ -183,23 +186,22 @@ public class VAssignDamage {
|
||||
|
||||
// Top row of cards...
|
||||
for (final CardView c : blockers) {
|
||||
DamageTarget dt = new DamageTarget(c, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
final DamageTarget dt = new DamageTarget(c, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
damage.put(c, dt);
|
||||
defenders.add(dt);
|
||||
addPanelForDefender(pnlDefenders, c);
|
||||
}
|
||||
|
||||
if (attackerHasTrample) {
|
||||
DamageTarget dt = new DamageTarget(null, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
final DamageTarget dt = new DamageTarget(null, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
damage.put(null, dt);
|
||||
defenders.add(dt);
|
||||
CardView fakeCard = null;
|
||||
if (defender instanceof CardView) {
|
||||
fakeCard = (CardView)defender;
|
||||
}
|
||||
else if (defender instanceof PlayerView) {
|
||||
} else if (defender instanceof PlayerView) {
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
fakeCard = new CardView(-1, null, defender.toString(), p, CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayerName()));
|
||||
fakeCard = new CardView(-1, null, defender.toString(), p, matchUI.avatarImages.get(p.getLobbyPlayerName()));
|
||||
}
|
||||
addPanelForDefender(pnlDefenders, fakeCard);
|
||||
}
|
||||
@@ -208,7 +210,7 @@ public class VAssignDamage {
|
||||
// If trample allowed, make card placeholder
|
||||
|
||||
// ... bottom row of labels.
|
||||
for (DamageTarget l : defenders) {
|
||||
for (final DamageTarget l : defenders) {
|
||||
pnlDefenders.add(l.label, "w 145px!, h 30px!, gap 5px 5px 0 5px");
|
||||
}
|
||||
|
||||
@@ -226,7 +228,7 @@ public class VAssignDamage {
|
||||
pnlMain.add(scrDefenders, "w 96%!, gap 2% 0 0 0, pushy, growy, ax center, span 2");
|
||||
pnlMain.add(lblAssignRemaining, "w 96%!, gap 2% 0 0 0, ax center, span 2");
|
||||
|
||||
JPanel pnlButtons = new JPanel(new MigLayout("insets 0, gap 0, ax center"));
|
||||
final JPanel pnlButtons = new JPanel(new MigLayout("insets 0, gap 0, ax center"));
|
||||
pnlButtons.setOpaque(false);
|
||||
pnlButtons.add(btnAuto, "w 110px!, h 30px!, gap 0 10px 0 0");
|
||||
pnlButtons.add(btnOK, "w 110px!, h 30px!, gap 0 10px 0 0");
|
||||
@@ -260,7 +262,7 @@ public class VAssignDamage {
|
||||
* @param defender
|
||||
*/
|
||||
private void addPanelForDefender(final JPanel pnlDefenders, final CardView defender) {
|
||||
final CardPanel cp = new CardPanel(defender);
|
||||
final CardPanel cp = new CardPanel(matchUI, defender);
|
||||
cp.setCardBounds(0, 0, 105, 150);
|
||||
cp.setOpaque(true);
|
||||
pnlDefenders.add(cp, "w 145px!, h 170px!, gap 5px 5px 3px 3px, ax center");
|
||||
@@ -436,7 +438,7 @@ public class VAssignDamage {
|
||||
if (card == null) {
|
||||
if (defender instanceof PlayerView) {
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
lethalDamage = attackerHasInfect ? MatchUtil.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
lethalDamage = attackerHasInfect ? matchUI.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
}
|
||||
else if (defender instanceof CardView) { // planeswalker
|
||||
final CardView pw = (CardView)defender;
|
||||
|
||||
@@ -10,7 +10,6 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FCheckBox;
|
||||
import forge.toolbox.FList;
|
||||
@@ -31,12 +30,12 @@ public class VAutoYields extends FDialog {
|
||||
private final FCheckBox chkDisableAll;
|
||||
private final List<String> autoYields;
|
||||
|
||||
public VAutoYields(final PlayerControllerHuman humanController) {
|
||||
public VAutoYields(final CMatchUI matchUI) {
|
||||
super();
|
||||
setTitle("Auto-Yields");
|
||||
|
||||
autoYields = new ArrayList<String>();
|
||||
for (final String autoYield : humanController.getAutoYields()) {
|
||||
for (final String autoYield : matchUI.getAutoYields()) {
|
||||
autoYields.add(autoYield);
|
||||
}
|
||||
lstAutoYields = new FList<String>(new AutoYieldsListModel());
|
||||
@@ -48,11 +47,11 @@ public class VAutoYields extends FDialog {
|
||||
|
||||
listScroller = new FScrollPane(lstAutoYields, true);
|
||||
|
||||
chkDisableAll = new FCheckBox("Disable All Auto Yields", humanController.getDisableAutoYields());
|
||||
chkDisableAll = new FCheckBox("Disable All Auto Yields", matchUI.getDisableAutoYields());
|
||||
chkDisableAll.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
humanController.setDisableAutoYields(chkDisableAll.isSelected());
|
||||
matchUI.setDisableAutoYields(chkDisableAll.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -71,7 +70,7 @@ public class VAutoYields extends FDialog {
|
||||
if (selected != null) {
|
||||
autoYields.remove(selected);
|
||||
btnRemove.setEnabled(autoYields.size() > 0);
|
||||
humanController.setShouldAutoYield(selected, false);
|
||||
matchUI.setShouldAutoYield(selected, false);
|
||||
VAutoYields.this.revalidate();
|
||||
lstAutoYields.repaint();
|
||||
}
|
||||
@@ -115,8 +114,7 @@ public class VAutoYields extends FDialog {
|
||||
if (lstAutoYields.getCount() > 0) {
|
||||
setVisible(true);
|
||||
dispose();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
FOptionPane.showMessageDialog("There are no active auto-yields.", "No Auto-Yields", FOptionPane.INFORMATION_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package forge.screens.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.GameView;
|
||||
import forge.gui.framework.*;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.IVTopLevelUI;
|
||||
import forge.gui.framework.SRearrangingUtil;
|
||||
import forge.gui.framework.VEmptyDoc;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.screens.match.views.*;
|
||||
import forge.screens.match.views.VCommand;
|
||||
import forge.screens.match.views.VDev;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VHand;
|
||||
import forge.sound.MusicPlaylist;
|
||||
import forge.sound.SoundSystem;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.view.FView;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Top level view class for match UI drag layout.<br>
|
||||
* Has access methods for all draggable documents.<br>
|
||||
@@ -22,26 +30,16 @@ import java.util.List;
|
||||
*
|
||||
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
|
||||
*/
|
||||
public enum VMatchUI implements IVTopLevelUI {
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
public class VMatchUI implements IVTopLevelUI {
|
||||
private List<VCommand> lstCommands = new ArrayList<VCommand>();
|
||||
private List<VField> lstFields = new ArrayList<VField>();
|
||||
private List<VHand> lstHands = new ArrayList<VHand>();
|
||||
|
||||
// Other instantiations
|
||||
private boolean wasClosed;
|
||||
private final CMatchUI control = null;
|
||||
private final CMatchUI control;
|
||||
|
||||
private VMatchUI() {
|
||||
createEmptyDocs();
|
||||
}
|
||||
|
||||
private void createEmptyDocs() {
|
||||
// Create empty docs for all slots
|
||||
for (int i = 0; i < 8; i++) EDocID.Fields[i].setDoc(new VEmptyDoc(EDocID.Fields[i]));
|
||||
for (int i = 0; i < 8; i++) EDocID.Commands[i].setDoc(new VEmptyDoc(EDocID.Commands[i]));
|
||||
for (int i = 0; i < 8; i++) EDocID.Hands[i].setDoc(new VEmptyDoc(EDocID.Hands[i]));
|
||||
VMatchUI(final CMatchUI control) {
|
||||
this.control = control;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,36 +49,28 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
@Override
|
||||
public void populate() {
|
||||
// Dev mode disabled? Remove from parent cell if exists.
|
||||
final VDev vDev = getControl().getCDev().getView();
|
||||
if (!ForgePreferences.DEV_MODE) {
|
||||
if (VDev.SINGLETON_INSTANCE.getParentCell() != null) {
|
||||
final DragCell parent = VDev.SINGLETON_INSTANCE.getParentCell();
|
||||
parent.removeDoc(VDev.SINGLETON_INSTANCE);
|
||||
VDev.SINGLETON_INSTANCE.setParentCell(null);
|
||||
if (vDev.getParentCell() != null) {
|
||||
final DragCell parent = vDev.getParentCell();
|
||||
parent.removeDoc(vDev);
|
||||
vDev.setParentCell(null);
|
||||
|
||||
// If dev mode was first tab, the new first tab needs re-selecting.
|
||||
if (parent.getDocs().size() > 0) {
|
||||
parent.setSelected(parent.getDocs().get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dev mode enabled? May already by added, or put in message cell by default.
|
||||
else {
|
||||
if (VDev.SINGLETON_INSTANCE.getParentCell() == null) {
|
||||
VPrompt.SINGLETON_INSTANCE.getParentCell().addDoc(VDev.SINGLETON_INSTANCE);
|
||||
}
|
||||
} else if (vDev.getParentCell() == null) {
|
||||
// Dev mode enabled? May already by added, or put in message cell by default.
|
||||
getControl().getCPrompt().getView().getParentCell().addDoc(vDev);
|
||||
}
|
||||
|
||||
//Clear previous match views if screen was previously closed
|
||||
if (wasClosed) {
|
||||
wasClosed = false;
|
||||
}
|
||||
else { //focus first enabled Prompt button if returning to match screen
|
||||
if (getBtnOK().isEnabled()) {
|
||||
getBtnOK().requestFocusInWindow();
|
||||
}
|
||||
else if (getBtnCancel().isEnabled()) {
|
||||
getBtnCancel().requestFocusInWindow();
|
||||
}
|
||||
//focus first enabled Prompt button if returning to match screen
|
||||
if (getBtnOK().isEnabled()) {
|
||||
getBtnOK().requestFocusInWindow();
|
||||
} else if (getBtnCancel().isEnabled()) {
|
||||
getBtnCancel().requestFocusInWindow();
|
||||
}
|
||||
|
||||
// Add extra players alternatively to existing user/AI field panels.
|
||||
@@ -150,18 +140,18 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
}
|
||||
|
||||
public FButton getBtnCancel() {
|
||||
return VPrompt.SINGLETON_INSTANCE.getBtnCancel();
|
||||
return getControl().getCPrompt().getView().getBtnCancel();
|
||||
}
|
||||
|
||||
public FButton getBtnOK() {
|
||||
return VPrompt.SINGLETON_INSTANCE.getBtnOK();
|
||||
return getControl().getCPrompt().getView().getBtnOK();
|
||||
}
|
||||
|
||||
public List<VCommand> getCommandViews() {
|
||||
return lstCommands;
|
||||
}
|
||||
|
||||
public void setCommandViews(List<VCommand> lstCommands0) {
|
||||
public void setCommandViews(final List<VCommand> lstCommands0) {
|
||||
this.lstCommands = lstCommands0;
|
||||
}
|
||||
|
||||
@@ -170,22 +160,25 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSwitching(FScreen fromScreen, FScreen toScreen) {
|
||||
public boolean onSwitching(final FScreen fromScreen, final FScreen toScreen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onClosing(FScreen screen) {
|
||||
final GameView gameView = MatchUtil.getGameView();
|
||||
public boolean onClosing(final FScreen screen) {
|
||||
if (!Singletons.getControl().getCurrentScreen().equals(screen)) {
|
||||
Singletons.getControl().setCurrentScreen(screen);
|
||||
}
|
||||
|
||||
final GameView gameView = control.getGameView();
|
||||
if (gameView != null && !gameView.isGameOver()) {
|
||||
MatchUtil.concede();
|
||||
control.concede();
|
||||
return false; //delay hiding tab even if concede successful
|
||||
}
|
||||
|
||||
//switch back to menus music when closing screen
|
||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
|
||||
|
||||
wasClosed = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.FTextArea;
|
||||
|
||||
public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
private final ControlWinLose control;
|
||||
|
||||
private final FButton btnContinue, btnRestart, btnQuit;
|
||||
private final SkinnedPanel pnlCustom;
|
||||
|
||||
@@ -55,9 +57,9 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
private static final String CONSTRAINTS_CARDS_LARGE = "w 95%!, h 600px!, gap 0 0 0 20px";
|
||||
|
||||
private final GameView game;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public ViewWinLose(final GameView game0) {
|
||||
public ViewWinLose(final GameView game0, final CMatchUI matchUI) {
|
||||
this.game = game0;
|
||||
|
||||
final JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel();
|
||||
@@ -76,27 +78,28 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
ControlWinLose control = null;
|
||||
switch (game0.getGameType()) {
|
||||
case Quest:
|
||||
control = new QuestWinLose(this, game0);
|
||||
control = new QuestWinLose(this, game0, matchUI);
|
||||
break;
|
||||
case QuestDraft:
|
||||
control = new QuestDraftWinLose(this, game0);
|
||||
control = new QuestDraftWinLose(this, game0, matchUI);
|
||||
break;
|
||||
case Draft:
|
||||
if (!FModel.getGauntletMini().isGauntletDraft()) {
|
||||
break;
|
||||
}
|
||||
case Sealed:
|
||||
control = new LimitedWinLose(this, game0);
|
||||
control = new LimitedWinLose(this, game0, matchUI);
|
||||
break;
|
||||
case Gauntlet:
|
||||
control = new GauntletWinLose(this, game0);
|
||||
control = new GauntletWinLose(this, game0, matchUI);
|
||||
break;
|
||||
default: // will catch it after switch
|
||||
break;
|
||||
}
|
||||
if (null == control) {
|
||||
control = new ControlWinLose(this, game0);
|
||||
control = new ControlWinLose(this, game0, matchUI);
|
||||
}
|
||||
this.control = control;
|
||||
|
||||
pnlLeft.setOpaque(false);
|
||||
pnlRight.setOpaque(false);
|
||||
@@ -180,6 +183,8 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
pnlLog.add(btnCopyLog, "center, w pref+16, h pref+8");
|
||||
pnlLeft.add(pnlLog, "w 100%!");
|
||||
|
||||
lblTitle.setText(composeTitle(game0));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -194,11 +199,12 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
}
|
||||
});
|
||||
|
||||
lblTitle.setText(composeTitle(game0));
|
||||
|
||||
showGameOutcomeSummary();
|
||||
showPlayerScores();
|
||||
}
|
||||
|
||||
public final ControlWinLose getControl() {
|
||||
return control;
|
||||
}
|
||||
|
||||
private String composeTitle(final GameView game) {
|
||||
@@ -234,8 +240,9 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
}
|
||||
|
||||
private void showGameOutcomeSummary() {
|
||||
for (final GameLogEntry o : game.getGameLog().getLogEntriesExact(GameLogEntryType.GAME_OUTCOME))
|
||||
for (final GameLogEntry o : game.getGameLog().getLogEntriesExact(GameLogEntryType.GAME_OUTCOME)) {
|
||||
pnlOutcomes.add(new FLabel.Builder().text(o.message).fontSize(14).build(), "h 20!");
|
||||
}
|
||||
}
|
||||
|
||||
private void showPlayerScores() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import forge.view.arcane.FloatingCardArea;
|
||||
*/
|
||||
public class ZoneAction extends ForgeAction {
|
||||
private static final long serialVersionUID = -5822976087772388839L;
|
||||
private final CMatchUI matchUI;
|
||||
private final PlayerView player;
|
||||
private final ZoneType zone;
|
||||
|
||||
@@ -22,14 +23,15 @@ public class ZoneAction extends ForgeAction {
|
||||
* the "zones" of a player field: hand, graveyard, etc. The library
|
||||
* "zone" is an exception to the rule; it's handled in DeckListAction.
|
||||
*/
|
||||
public ZoneAction(final PlayerView player0, final ZoneType zone0, final MatchConstants property) {
|
||||
public ZoneAction(final CMatchUI matchUI, final PlayerView player0, final ZoneType zone0, final MatchConstants property) {
|
||||
super(property);
|
||||
this.matchUI = matchUI;
|
||||
player = player0;
|
||||
zone = zone0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
FloatingCardArea.show(player, zone);
|
||||
FloatingCardArea.show(matchUI, player, zone);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VAntes;
|
||||
|
||||
/**
|
||||
@@ -10,9 +11,13 @@ import forge.screens.match.views.VAntes;
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*
|
||||
*/
|
||||
public enum CAntes implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
public class CAntes implements ICDoc {
|
||||
private final CMatchUI matchUI;
|
||||
private final VAntes view;
|
||||
public CAntes(final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
this.view = new VAntes(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -22,6 +27,10 @@ public enum CAntes implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@@ -34,6 +43,14 @@ public enum CAntes implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
VAntes.SINGLETON_INSTANCE.update();
|
||||
view.update();
|
||||
}
|
||||
|
||||
public CMatchUI getMatchUI() {
|
||||
return matchUI;
|
||||
}
|
||||
|
||||
public VAntes getView() {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,17 @@ import forge.util.Lang;
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*
|
||||
*/
|
||||
public enum CCombat implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
public class CCombat implements ICDoc {
|
||||
|
||||
private CombatView combat;
|
||||
private final VCombat view;
|
||||
public CCombat() {
|
||||
view = new VCombat(this);
|
||||
}
|
||||
|
||||
public VCombat getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -35,6 +41,10 @@ public enum CCombat implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@@ -49,9 +59,9 @@ public enum CCombat implements ICDoc {
|
||||
public void update() {
|
||||
final CombatView localCombat = this.combat; // noone will re-assign this from other thread.
|
||||
if (localCombat != null) {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(localCombat.getNumAttackers(), getCombatDescription(localCombat));
|
||||
view.updateCombat(localCombat.getNumAttackers(), getCombatDescription(localCombat));
|
||||
} else {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(0, "");
|
||||
view.updateCombat(0, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@ public class CCommand implements ICDoc {
|
||||
this.view = v0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ import java.awt.event.MouseEvent;
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.CardView;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.views.VDetail;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
|
||||
@@ -34,37 +32,43 @@ import forge.toolbox.FMouseAdapter;
|
||||
*
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*/
|
||||
public enum CDetail implements ICDoc {
|
||||
SINGLETON_INSTANCE;
|
||||
public class CDetail implements ICDoc {
|
||||
private final VDetail view;
|
||||
CDetail(final CDetailPicture controller) {
|
||||
this.view = new VDetail(this);
|
||||
|
||||
private VDetail view = VDetail.SINGLETON_INSTANCE;
|
||||
this.view.getPnlDetail().addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void onLeftClick(final MouseEvent e) {
|
||||
controller.flip();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public VDetail getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
*
|
||||
* @param c   {@link CardView} object
|
||||
* @param isInAltState whether to draw the flip side of the card.
|
||||
*/
|
||||
public void showCard(final CardView c) {
|
||||
this.showCard(c, false);
|
||||
}
|
||||
|
||||
public void showCard(final CardView c, final boolean isInAltState) {
|
||||
view.getLblFlipcard().setVisible(c != null && MatchUtil.canCardBeFlipped(c));
|
||||
view.getPnlDetail().setCard(c, isInAltState);
|
||||
void showCard(final CardView c, final boolean isInAltState, final boolean mayView, final boolean mayFlip) {
|
||||
final CardView toShow = mayView ? c : null;
|
||||
view.getLblFlipcard().setVisible(toShow != null && mayFlip);
|
||||
view.getPnlDetail().setCard(toShow, isInAltState);
|
||||
if (view.getParentCell() != null) {
|
||||
view.getParentCell().repaintSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public void showCard(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
showCard(CardView.getCardForUi((IPaperCard)item));
|
||||
} else if (item instanceof InventoryItemFromSet) {
|
||||
void showItem(final InventoryItem item) {
|
||||
if (item instanceof InventoryItemFromSet) {
|
||||
view.getLblFlipcard().setVisible(false);
|
||||
view.getPnlDetail().setItem((InventoryItemFromSet)item);
|
||||
view.getParentCell().repaintSelf();
|
||||
} else {
|
||||
showCard((CardView)null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,14 +77,13 @@ public enum CDetail implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
view.getPnlDetail().addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void onLeftClick(final MouseEvent e) {
|
||||
CPicture.SINGLETON_INSTANCE.flipCard();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.interfaces.IMayViewCards;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
|
||||
/**
|
||||
* Class that controls and links a {@link CDetail} and a {@link CPicture}.
|
||||
*/
|
||||
public class CDetailPicture {
|
||||
|
||||
private final CDetail cDetail;
|
||||
private final CPicture cPicture;
|
||||
private final IMayViewCards mayView;
|
||||
|
||||
private CardView currentView = null;
|
||||
private boolean isDisplayAlt = false, alwaysDisplayAlt = false;
|
||||
|
||||
public CDetailPicture() {
|
||||
this(IMayViewCards.ALL);
|
||||
}
|
||||
public CDetailPicture(final IMayViewCards mayView) {
|
||||
this.mayView = mayView;
|
||||
this.cDetail = new CDetail(this);
|
||||
this.cPicture = new CPicture(this);
|
||||
}
|
||||
|
||||
CardView getCurrentCard() {
|
||||
return currentView;
|
||||
}
|
||||
public CDetail getCDetail() {
|
||||
return cDetail;
|
||||
}
|
||||
public CPicture getCPicture() {
|
||||
return cPicture;
|
||||
}
|
||||
|
||||
public void showCard(final CardView c, final boolean showAlt) {
|
||||
currentView = c;
|
||||
final boolean mayView = mayView(), mayFlip = mayView && mayFlip();
|
||||
isDisplayAlt = mayFlip && showAlt;
|
||||
alwaysDisplayAlt = mayView && mayFlip && c.isFaceDown();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays image associated with either a {@code Card}
|
||||
* or {@code InventoryItem} instance.
|
||||
*/
|
||||
public void showItem(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
final IPaperCard paperCard = ((IPaperCard)item);
|
||||
final CardView c = CardView.getCardForUi(paperCard);
|
||||
if (paperCard.isFoil() && c.getCurrentState().getFoilIndex() == 0) {
|
||||
// FIXME should assign a random foil here in all cases
|
||||
// (currently assigns 1 for the deck editors where foils "flicker" otherwise)
|
||||
if (item instanceof Card) {
|
||||
c.getCurrentState().setFoilIndexOverride(-1); //-1 to choose random
|
||||
} else if (item instanceof IPaperCard) {
|
||||
c.getCurrentState().setFoilIndexOverride(1);
|
||||
}
|
||||
}
|
||||
showCard(c, false);
|
||||
} else {
|
||||
currentView = null;
|
||||
isDisplayAlt = false;
|
||||
alwaysDisplayAlt = false;
|
||||
|
||||
cDetail.showItem(item);
|
||||
cPicture.showItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void flip() {
|
||||
if (mayFlip()) {
|
||||
isDisplayAlt = !isDisplayAlt;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private void update() {
|
||||
final boolean mayView = mayView(), mayFlip = mayFlip();
|
||||
cDetail.showCard(currentView, isDisplayAlt, mayView, mayFlip);
|
||||
cPicture.showCard(currentView, isDisplayAlt, mayView, mayFlip || alwaysDisplayAlt);
|
||||
}
|
||||
|
||||
private boolean mayView() {
|
||||
return mayView.mayView(currentView);
|
||||
}
|
||||
|
||||
private boolean mayFlip() {
|
||||
return mayView.mayFlip(currentView);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import java.awt.event.MouseListener;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.interfaces.IGameController;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VDev;
|
||||
|
||||
/**
|
||||
@@ -15,8 +16,36 @@ import forge.screens.match.views.VDev;
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*
|
||||
*/
|
||||
public enum CDev implements ICDoc {
|
||||
SINGLETON_INSTANCE;
|
||||
public class CDev implements ICDoc {
|
||||
|
||||
private final CMatchUI matchUI;
|
||||
private final VDev view;
|
||||
public CDev(final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
this.view = new VDev(this);
|
||||
|
||||
view.getLblUnlimitedLands().addMouseListener(madUnlimited);
|
||||
view.getLblViewAll().addMouseListener(madViewAll);
|
||||
view.getLblGenerateMana().addMouseListener(madMana);
|
||||
view.getLblSetupGame().addMouseListener(madSetup);
|
||||
view.getLblDumpGame().addMouseListener(madDump);
|
||||
view.getLblTutor().addMouseListener(madTutor);
|
||||
view.getLblCardToHand().addMouseListener(madCardToHand);
|
||||
view.getLblCounterPermanent().addMouseListener(madCounter);
|
||||
view.getLblTapPermanent().addMouseListener(madTap);
|
||||
view.getLblUntapPermanent().addMouseListener(madUntap);
|
||||
view.getLblSetLife().addMouseListener(madLife);
|
||||
view.getLblWinGame().addMouseListener(madWinGame);
|
||||
view.getLblCardToBattlefield().addMouseListener(madCardToBattlefield);
|
||||
view.getLblRiggedRoll().addMouseListener(madRiggedRoll);
|
||||
view.getLblWalkTo().addMouseListener(madWalkToPlane);
|
||||
}
|
||||
public final IGameController getController() {
|
||||
return matchUI.getGameController();
|
||||
}
|
||||
public final VDev getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
private final MouseListener madUnlimited = new MouseAdapter() {
|
||||
@Override
|
||||
@@ -25,9 +54,9 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void togglePlayManyLandsPerTurn() {
|
||||
boolean newValue = !VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().getToggled();
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(newValue);
|
||||
MatchUtil.getHumanController().cheat().setCanPlayUnlimitedLands(newValue);
|
||||
final boolean newValue = !view.getLblUnlimitedLands().getToggled();
|
||||
view.getLblUnlimitedLands().setToggled(newValue);
|
||||
getController().cheat().setCanPlayUnlimitedLands(newValue);
|
||||
}
|
||||
|
||||
private final MouseListener madViewAll = new MouseAdapter() {
|
||||
@@ -37,9 +66,9 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void toggleViewAllCards() {
|
||||
boolean newValue = !VDev.SINGLETON_INSTANCE.getLblViewAll().getToggled();
|
||||
VDev.SINGLETON_INSTANCE.getLblViewAll().setToggled(newValue);
|
||||
MatchUtil.getHumanController().cheat().setViewAllCards(newValue);
|
||||
final boolean newValue = !view.getLblViewAll().getToggled();
|
||||
view.getLblViewAll().setToggled(newValue);
|
||||
getController().cheat().setViewAllCards(newValue);
|
||||
}
|
||||
|
||||
private final MouseListener madMana = new MouseAdapter() {
|
||||
@@ -49,7 +78,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void generateMana() {
|
||||
MatchUtil.getHumanController().cheat().generateMana();
|
||||
getController().cheat().generateMana();
|
||||
}
|
||||
|
||||
private final MouseListener madSetup = new MouseAdapter() {
|
||||
@@ -59,7 +88,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void setupGameState() {
|
||||
MatchUtil.getHumanController().cheat().setupGameState();
|
||||
getController().cheat().setupGameState();
|
||||
}
|
||||
|
||||
private final MouseListener madDump = new MouseAdapter() {
|
||||
@@ -69,7 +98,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void dumpGameState() {
|
||||
MatchUtil.getHumanController().cheat().dumpGameState();
|
||||
getController().cheat().dumpGameState();
|
||||
}
|
||||
|
||||
private final MouseListener madTutor = new MouseAdapter() {
|
||||
@@ -79,7 +108,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void tutorForCard() {
|
||||
MatchUtil.getHumanController().cheat().tutorForCard();
|
||||
getController().cheat().tutorForCard();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToHand = new MouseAdapter() {
|
||||
@@ -89,7 +118,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void addCardToHand() {
|
||||
MatchUtil.getHumanController().cheat().addCardToHand();
|
||||
getController().cheat().addCardToHand();
|
||||
}
|
||||
|
||||
private final MouseListener madCounter = new MouseAdapter() {
|
||||
@@ -99,7 +128,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void addCounterToPermanent() {
|
||||
MatchUtil.getHumanController().cheat().addCountersToPermanent();
|
||||
getController().cheat().addCountersToPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madTap = new MouseAdapter() {
|
||||
@@ -109,7 +138,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void tapPermanent() {
|
||||
MatchUtil.getHumanController().cheat().tapPermanents();
|
||||
getController().cheat().tapPermanents();
|
||||
}
|
||||
|
||||
private final MouseListener madUntap = new MouseAdapter() {
|
||||
@@ -119,7 +148,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void untapPermanent() {
|
||||
MatchUtil.getHumanController().cheat().untapPermanents();
|
||||
getController().cheat().untapPermanents();
|
||||
}
|
||||
|
||||
private final MouseListener madLife = new MouseAdapter() {
|
||||
@@ -129,7 +158,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void setPlayerLife() {
|
||||
MatchUtil.getHumanController().cheat().setPlayerLife();
|
||||
getController().cheat().setPlayerLife();
|
||||
}
|
||||
|
||||
private final MouseListener madWinGame = new MouseAdapter() {
|
||||
@@ -139,7 +168,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void winGame() {
|
||||
MatchUtil.getHumanController().cheat().winGame();
|
||||
getController().cheat().winGame();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToBattlefield = new MouseAdapter() {
|
||||
@@ -149,7 +178,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void addCardToBattlefield() {
|
||||
MatchUtil.getHumanController().cheat().addCardToBattlefield();
|
||||
getController().cheat().addCardToBattlefield();
|
||||
}
|
||||
|
||||
private final MouseListener madRiggedRoll = new MouseAdapter() {
|
||||
@@ -159,7 +188,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void riggedPlanerRoll() {
|
||||
MatchUtil.getHumanController().cheat().riggedPlanarRoll();
|
||||
getController().cheat().riggedPlanarRoll();
|
||||
}
|
||||
|
||||
private final MouseListener madWalkToPlane = new MouseAdapter() {
|
||||
@@ -169,7 +198,7 @@ public enum CDev implements ICDoc {
|
||||
}
|
||||
};
|
||||
public void planeswalkTo() {
|
||||
MatchUtil.getHumanController().cheat().planeswalkTo();
|
||||
getController().cheat().planeswalkTo();
|
||||
}
|
||||
|
||||
//========== End mouse listener inits
|
||||
@@ -182,26 +211,15 @@ public enum CDev implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().addMouseListener(madUnlimited);
|
||||
VDev.SINGLETON_INSTANCE.getLblViewAll().addMouseListener(madViewAll);
|
||||
VDev.SINGLETON_INSTANCE.getLblGenerateMana().addMouseListener(madMana);
|
||||
VDev.SINGLETON_INSTANCE.getLblSetupGame().addMouseListener(madSetup);
|
||||
VDev.SINGLETON_INSTANCE.getLblDumpGame().addMouseListener(madDump);
|
||||
VDev.SINGLETON_INSTANCE.getLblTutor().addMouseListener(madTutor);
|
||||
VDev.SINGLETON_INSTANCE.getLblCardToHand().addMouseListener(madCardToHand);
|
||||
VDev.SINGLETON_INSTANCE.getLblCounterPermanent().addMouseListener(madCounter);
|
||||
VDev.SINGLETON_INSTANCE.getLblTapPermanent().addMouseListener(madTap);
|
||||
VDev.SINGLETON_INSTANCE.getLblUntapPermanent().addMouseListener(madUntap);
|
||||
VDev.SINGLETON_INSTANCE.getLblSetLife().addMouseListener(madLife);
|
||||
VDev.SINGLETON_INSTANCE.getLblWinGame().addMouseListener(madWinGame);
|
||||
VDev.SINGLETON_INSTANCE.getLblCardToBattlefield().addMouseListener(madCardToBattlefield);
|
||||
VDev.SINGLETON_INSTANCE.getLblRiggedRoll().addMouseListener(madRiggedRoll);
|
||||
VDev.SINGLETON_INSTANCE.getLblWalkTo().addMouseListener(madWalkToPlane);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -209,7 +227,9 @@ public enum CDev implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().setToggled(MatchUtil.getHumanController().canPlayUnlimitedLands());
|
||||
VDev.SINGLETON_INSTANCE.getLblViewAll().setToggled(MatchUtil.getHumanController().mayLookAtAllCards());
|
||||
if (getController() != null) {
|
||||
view.getLblUnlimitedLands().setToggled(!getController().canPlayUnlimitedLands());
|
||||
view.getLblViewAll().setToggled(!getController().mayLookAtAllCards());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,101 +17,50 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.Deck;
|
||||
import forge.deckchooser.FDeckViewer;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.properties.FileLocation;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VDock;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.SaveOpenDialog;
|
||||
import forge.toolbox.SaveOpenDialog.Filetypes;
|
||||
import forge.view.FView;
|
||||
|
||||
/**
|
||||
* Controls the dock panel in the match UI.
|
||||
*
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*/
|
||||
public enum CDock implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
public class CDock implements ICDoc {
|
||||
|
||||
private int arcState;
|
||||
private ArcState arcState;
|
||||
private final Iterator<ArcState> arcStateIterator = Iterators.cycle(ArcState.values());
|
||||
|
||||
private final CMatchUI matchUI;
|
||||
private final VDock view;
|
||||
public CDock(final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
this.view = new VDock(this);
|
||||
}
|
||||
|
||||
public enum ArcState { OFF, MOUSEOVER, ON; }
|
||||
|
||||
public VDock getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* End turn.
|
||||
*/
|
||||
public void endTurn() {
|
||||
CPrompt.SINGLETON_INSTANCE.passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
public void revertLayout() {
|
||||
SOverlayUtils.genericOverlay();
|
||||
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override public void run() {
|
||||
SLayoutIO.loadLayout(null);
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveLayout() {
|
||||
final SaveOpenDialog dlgSave = new SaveOpenDialog();
|
||||
final FileLocation layoutFile = Singletons.getControl().getCurrentScreen().getLayoutFile();
|
||||
final File defFile = layoutFile != null ? new File(layoutFile.userPrefLoc) : null;
|
||||
final File saveFile = dlgSave.SaveDialog(defFile, Filetypes.LAYOUT);
|
||||
if (saveFile != null) {
|
||||
SLayoutIO.saveLayout(saveFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void openLayout() {
|
||||
SOverlayUtils.genericOverlay();
|
||||
|
||||
final SaveOpenDialog dlgOpen = new SaveOpenDialog();
|
||||
final FileLocation layoutFile = Singletons.getControl().getCurrentScreen().getLayoutFile();
|
||||
final File defFile = layoutFile != null ? new File(layoutFile.userPrefLoc) : null;
|
||||
final File loadFile = dlgOpen.OpenDialog(defFile, Filetypes.LAYOUT);
|
||||
|
||||
if (loadFile != null) {
|
||||
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
|
||||
// let it redraw everything first
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (loadFile != null) {
|
||||
SLayoutIO.loadLayout(loadFile);
|
||||
SLayoutIO.saveLayout(null);
|
||||
}
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View deck list.
|
||||
*/
|
||||
public void viewDeckList() {
|
||||
final Deck deck = MatchUtil.getGameView().getDeck(GamePlayerUtil.getGuiPlayer());
|
||||
if (deck != null) {
|
||||
FDeckViewer.show(deck);
|
||||
}
|
||||
matchUI.getCPrompt().passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,46 +69,45 @@ public enum CDock implements ICDoc {
|
||||
* 1 = draw on card mouseover<br>
|
||||
* 2 = always draw
|
||||
*/
|
||||
public int getArcState() {
|
||||
public ArcState getArcState() {
|
||||
return arcState;
|
||||
}
|
||||
|
||||
/** @param state0 int */
|
||||
private void refreshArcStateDisplay() {
|
||||
switch (arcState) {
|
||||
case 0:
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setToolTipText("Targeting arcs: Off");
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setIcon(FSkin.getIcon(FSkinProp.ICO_ARCSOFF));
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().repaintSelf();
|
||||
case OFF:
|
||||
view.getBtnTargeting().setToolTipText("Targeting arcs: Off");
|
||||
view.getBtnTargeting().setIcon(FSkin.getIcon(FSkinProp.ICO_ARCSOFF));
|
||||
view.getBtnTargeting().repaintSelf();
|
||||
break;
|
||||
case 1:
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setToolTipText("Targeting arcs: Card mouseover");
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setIcon(FSkin.getIcon(FSkinProp.ICO_ARCSHOVER));
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().repaintSelf();
|
||||
case MOUSEOVER:
|
||||
view.getBtnTargeting().setToolTipText("Targeting arcs: Card mouseover");
|
||||
view.getBtnTargeting().setIcon(FSkin.getIcon(FSkinProp.ICO_ARCSHOVER));
|
||||
view.getBtnTargeting().repaintSelf();
|
||||
break;
|
||||
default:
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setIcon(FSkin.getIcon(FSkinProp.ICO_ARCSON));
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setToolTipText("Targeting arcs: Always on");
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().repaintSelf();
|
||||
case ON:
|
||||
view.getBtnTargeting().setToolTipText("Targeting arcs: Always on");
|
||||
view.getBtnTargeting().setIcon(FSkin.getIcon(FSkinProp.ICO_ARCSON));
|
||||
view.getBtnTargeting().repaintSelf();
|
||||
break;
|
||||
}
|
||||
|
||||
FModel.getPreferences().setPref(FPref.UI_TARGETING_OVERLAY, String.valueOf(arcState));
|
||||
//FModel.SINGLETON_INSTANCE.getPreferences().save();
|
||||
FModel.getPreferences().setPref(FPref.UI_TARGETING_OVERLAY, String.valueOf(arcState.ordinal()));
|
||||
FModel.getPreferences().save();
|
||||
}
|
||||
|
||||
/** Toggle targeting overlay painting. */
|
||||
public void toggleTargeting() {
|
||||
arcState++;
|
||||
|
||||
if (arcState == 3) { arcState = 0; }
|
||||
arcState = arcStateIterator.next();
|
||||
|
||||
refreshArcStateDisplay();
|
||||
FView.SINGLETON_INSTANCE.getFrame().repaint(); // repaint the match UI
|
||||
Singletons.getView().getFrame().repaint(); // repaint the match UI
|
||||
}
|
||||
|
||||
public void setArcState(int state) {
|
||||
public void setArcState(final ArcState state) {
|
||||
arcState = state;
|
||||
while (arcStateIterator.next() != arcState) { /* Put the iterator to the correct value */ };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -170,6 +118,10 @@ public enum CDock implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@@ -178,68 +130,58 @@ public enum CDock implements ICDoc {
|
||||
public void initialize() {
|
||||
final String temp = FModel.getPreferences()
|
||||
.getPref(FPref.UI_TARGETING_OVERLAY);
|
||||
|
||||
// Old preference used boolean; new preference needs 0-1-2
|
||||
// (none, mouseover, solid). Can remove this conditional
|
||||
// statement after a while...Doublestrike 17-10-12
|
||||
if (temp.equals("0") || temp.equals("1")) {
|
||||
arcState = Integer.valueOf(temp);
|
||||
}
|
||||
else {
|
||||
arcState = 2;
|
||||
}
|
||||
|
||||
setArcState(ArcState.values()[Integer.valueOf(temp)]);
|
||||
refreshArcStateDisplay();
|
||||
|
||||
VDock.SINGLETON_INSTANCE.getBtnConcede().setCommand(new UiCommand() {
|
||||
view.getBtnConcede().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.concede();
|
||||
matchUI.concede();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnSettings().setCommand(new UiCommand() {
|
||||
view.getBtnSettings().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
SOverlayUtils.showOverlay();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnEndTurn().setCommand(new UiCommand() {
|
||||
view.getBtnEndTurn().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
endTurn();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnViewDeckList().setCommand(new UiCommand() {
|
||||
view.getBtnViewDeckList().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
viewDeckList();
|
||||
matchUI.viewDeckList();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnRevertLayout().setCommand(new UiCommand() {
|
||||
view.getBtnRevertLayout().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
revertLayout();
|
||||
SLayoutIO.revertLayout();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnOpenLayout().setCommand(new UiCommand() {
|
||||
view.getBtnOpenLayout().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
openLayout();
|
||||
SLayoutIO.openLayout();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnSaveLayout().setCommand(new UiCommand() {
|
||||
view.getBtnSaveLayout().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
saveLayout();
|
||||
SLayoutIO.saveLayout();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnAlphaStrike().setCommand(new UiCommand() {
|
||||
view.getBtnAlphaStrike().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
MatchUtil.getHumanController().alphaStrike();
|
||||
matchUI.getGameController().alphaStrike();
|
||||
}
|
||||
});
|
||||
VDock.SINGLETON_INSTANCE.getBtnTargeting().setCommand(new UiCommand() {
|
||||
view.getBtnTargeting().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
toggleTargeting();
|
||||
|
||||
@@ -29,7 +29,7 @@ import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.ZoneAction;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
@@ -38,6 +38,7 @@ import forge.toolbox.MouseTriggerEvent;
|
||||
* Controls Swing components of a player's field instance.
|
||||
*/
|
||||
public class CField implements ICDoc {
|
||||
private final CMatchUI matchUI;
|
||||
// The one who owns cards on this side of table
|
||||
private final PlayerView player;
|
||||
private final VField view;
|
||||
@@ -46,7 +47,7 @@ public class CField implements ICDoc {
|
||||
private final MouseListener madAvatar = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
CPrompt.SINGLETON_INSTANCE.selectPlayer(player, new MouseTriggerEvent(e));
|
||||
matchUI.getCPrompt().selectPlayer(player, new MouseTriggerEvent(e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,20 +58,21 @@ public class CField implements ICDoc {
|
||||
* @param v0   {@link forge.screens.match.views.VField}
|
||||
* @param playerViewer
|
||||
*/
|
||||
public CField(final PlayerView player0, final VField v0) {
|
||||
public CField(final CMatchUI matchUI, final PlayerView player0, final VField v0) {
|
||||
this.matchUI = matchUI;
|
||||
this.player = player0;
|
||||
this.view = v0;
|
||||
|
||||
final ZoneAction handAction = new ZoneAction(player, ZoneType.Hand, MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(player, ZoneType.Library, MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(player, ZoneType.Exile, MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD);
|
||||
final ZoneAction flashBackAction = new ZoneAction(player, ZoneType.Flashback, MatchConstants.HUMANFLASHBACK);
|
||||
final ZoneAction handAction = new ZoneAction(matchUI, player, ZoneType.Hand, MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(matchUI, player, ZoneType.Library, MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(matchUI, player, ZoneType.Exile, MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(matchUI, player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD);
|
||||
final ZoneAction flashBackAction = new ZoneAction(matchUI, player, ZoneType.Flashback, MatchConstants.HUMANFLASHBACK);
|
||||
|
||||
Function<Byte, Boolean> manaAction = new Function<Byte, Boolean>() {
|
||||
final Function<Byte, Boolean> manaAction = new Function<Byte, Boolean>() {
|
||||
public Boolean apply(Byte colorCode) {
|
||||
if (CField.this.player.isLobbyPlayer(Singletons.getControl().getGuiPlayer())) {
|
||||
return MatchUtil.getHumanController().useMana(colorCode.byteValue());
|
||||
return matchUI.getGameController().useMana(colorCode.byteValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -79,6 +81,14 @@ public class CField implements ICDoc {
|
||||
view.getDetailsPanel().setupMouseActions(handAction, libraryAction, exileAction, graveAction, flashBackAction, manaAction);
|
||||
}
|
||||
|
||||
public final CMatchUI getMatchUI() {
|
||||
return matchUI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
if (initializedAlready) { return; }
|
||||
|
||||
@@ -35,7 +35,6 @@ import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
@@ -49,6 +48,7 @@ import forge.view.arcane.util.CardPanelMouseAdapter;
|
||||
* Controls Swing components of a player's hand instance.
|
||||
*/
|
||||
public class CHand implements ICDoc {
|
||||
private final CMatchUI matchUI;
|
||||
private final PlayerView player;
|
||||
private final VHand view;
|
||||
private final List<CardView> ordering = Lists.newArrayList();
|
||||
@@ -59,7 +59,8 @@ public class CHand implements ICDoc {
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
* @param v0   {@link forge.screens.match.views.VHand}
|
||||
*/
|
||||
public CHand(final PlayerView p0, final VHand v0) {
|
||||
public CHand(final CMatchUI matchUI, final PlayerView p0, final VHand v0) {
|
||||
this.matchUI = matchUI;
|
||||
this.player = p0;
|
||||
this.view = v0;
|
||||
v0.getHandArea().addCardPanelMouseListener(new CardPanelMouseAdapter() {
|
||||
@@ -75,6 +76,10 @@ public class CHand implements ICDoc {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
}
|
||||
@@ -92,7 +97,7 @@ public class CHand implements ICDoc {
|
||||
|
||||
final HandArea p = view.getHandArea();
|
||||
|
||||
VField vf = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(player);
|
||||
final VField vf = matchUI.getFieldViewFor(player);
|
||||
if (vf == null) {
|
||||
return;
|
||||
}
|
||||
@@ -105,15 +110,18 @@ public class CHand implements ICDoc {
|
||||
}
|
||||
|
||||
// Don't perform animations if the user's in another tab.
|
||||
if (!FScreen.MATCH_SCREEN.equals(Singletons.getControl().getCurrentScreen())) {
|
||||
if (!matchUI.isCurrentScreen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//update card panels in hand area
|
||||
|
||||
final List<CardView> cards;
|
||||
synchronized (player) {
|
||||
cards = ImmutableList.copyOf(player.getHand());
|
||||
if (player.getHand() == null) {
|
||||
cards = ImmutableList.of();
|
||||
} else {
|
||||
synchronized (player) {
|
||||
cards = ImmutableList.copyOf(player.getHand());
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (ordering) {
|
||||
@@ -133,7 +141,7 @@ public class CHand implements ICDoc {
|
||||
for (final CardView card : ordering) {
|
||||
CardPanel cardPanel = p.getCardPanel(card.getId());
|
||||
if (cardPanel == null) { //create placeholders for new cards
|
||||
cardPanel = new CardPanel(card);
|
||||
cardPanel = new CardPanel(matchUI, card);
|
||||
cardPanel.setDisplayEnabled(false);
|
||||
placeholders.add(cardPanel);
|
||||
}
|
||||
@@ -164,7 +172,7 @@ public class CHand implements ICDoc {
|
||||
endY = toPos.y;
|
||||
|
||||
if (Singletons.getView().getFrame().isShowing()) {
|
||||
final CardPanel animationPanel = new CardPanel(placeholder.getCard());
|
||||
final CardPanel animationPanel = new CardPanel(matchUI, placeholder.getCard());
|
||||
Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, placeholder,
|
||||
layeredPane, 500);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package forge.screens.match.controllers;
|
||||
import forge.UiCommand;
|
||||
import forge.FThreads;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VLog;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
@@ -13,9 +15,21 @@ import java.util.Observer;
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*
|
||||
*/
|
||||
public enum CLog implements ICDoc, Observer {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
public class CLog implements ICDoc, Observer {
|
||||
|
||||
private final CMatchUI matchUI;
|
||||
private final VLog view;
|
||||
public CLog(final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
this.view = new VLog(this);
|
||||
}
|
||||
|
||||
public final CMatchUI getMatchUI() {
|
||||
return matchUI;
|
||||
}
|
||||
public final VLog getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -25,6 +39,10 @@ public enum CLog implements ICDoc, Observer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@@ -36,7 +54,7 @@ public enum CLog implements ICDoc, Observer {
|
||||
private final Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VLog.SINGLETON_INSTANCE.updateConsole();
|
||||
view.updateConsole();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,13 +24,11 @@ import java.awt.event.MouseWheelListener;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.match.views.VPicture;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
@@ -38,73 +36,46 @@ import forge.toolbox.special.CardZoomer;
|
||||
/**
|
||||
* Singleton controller for VPicture.
|
||||
* <p>
|
||||
* Can be used to display images associated with a {@code Card} or
|
||||
* {@code InventoryItem} in {@code CardPicturePanel}.<br>
|
||||
* Can be used to display images associated with a {@link Card} or
|
||||
* {@link InventoryItem} in {@link CardPicturePanel}.<br>
|
||||
* <br>
|
||||
* Can also be used to display details associated with a {@code Card}.
|
||||
*
|
||||
* @version: $Id:$
|
||||
*
|
||||
* Can also be used to display details associated with a {@link Card}.
|
||||
*/
|
||||
public enum CPicture implements ICDoc {
|
||||
SINGLETON_INSTANCE;
|
||||
public class CPicture implements ICDoc {
|
||||
private final CDetailPicture controller;
|
||||
private final VPicture view;
|
||||
CPicture(final CDetailPicture controller) {
|
||||
this.controller = controller;
|
||||
this.view = new VPicture(this);
|
||||
picturePanel = this.view.getPnlPicture();
|
||||
flipIndicator = this.view.getLblFlipcard();
|
||||
|
||||
setMouseWheelListener();
|
||||
setMouseButtonListener();
|
||||
}
|
||||
|
||||
public VPicture getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
// For brevity, local shortcuts to singletons & child controls...
|
||||
private final VPicture view = VPicture.SINGLETON_INSTANCE;
|
||||
private final CardPicturePanel picturePanel = this.view.getPnlPicture();
|
||||
private final JLabel flipIndicator = this.view.getLblFlipcard();
|
||||
private final CardPicturePanel picturePanel;
|
||||
private final JLabel flipIndicator;
|
||||
private final CardZoomer zoomer = CardZoomer.SINGLETON_INSTANCE;
|
||||
|
||||
private CardView currentView = null;
|
||||
private boolean isDisplayAlt = false, alwaysDisplayAlt = false;
|
||||
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
*
|
||||
*/
|
||||
public void showCard(final CardView c, boolean showAlt) {
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canFlip = MatchUtil.canCardBeFlipped(c);
|
||||
|
||||
currentView = c;
|
||||
isDisplayAlt = showAlt;
|
||||
alwaysDisplayAlt = canFlip && c.isFaceDown();
|
||||
flipIndicator.setVisible(canFlip);
|
||||
picturePanel.setCard(c.getState(isDisplayAlt || alwaysDisplayAlt));
|
||||
if (showAlt && canFlip) {
|
||||
flipCard();
|
||||
}
|
||||
void showCard(final CardView c, final boolean isInAltState, final boolean mayView, final boolean mayFlip) {
|
||||
final CardStateView toShow = c != null && mayView ? c.getState(isInAltState) : null;
|
||||
flipIndicator.setVisible(toShow != null && mayFlip);
|
||||
picturePanel.setCard(toShow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays image associated with either a {@code Card}
|
||||
* or {@code InventoryItem} instance.
|
||||
*/
|
||||
public void showImage(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
final IPaperCard paperCard = ((IPaperCard)item);
|
||||
final CardView c = CardView.getCardForUi(paperCard);
|
||||
if (paperCard.isFoil() && c.getCurrentState().getFoilIndex() == 0) {
|
||||
// FIXME should assign a random foil here in all cases
|
||||
// (currently assigns 1 for the deck editors where foils "flicker" otherwise)
|
||||
if (item instanceof Card) {
|
||||
c.getCurrentState().setFoilIndexOverride(-1); //-1 to choose random
|
||||
}
|
||||
else if (item instanceof IPaperCard) {
|
||||
c.getCurrentState().setFoilIndexOverride(1);
|
||||
}
|
||||
}
|
||||
showCard(c, false);
|
||||
} else {
|
||||
currentView = null;
|
||||
isDisplayAlt = false;
|
||||
alwaysDisplayAlt = false;
|
||||
flipIndicator.setVisible(false);
|
||||
picturePanel.setCard(item);
|
||||
}
|
||||
void showItem(final InventoryItem item) {
|
||||
flipIndicator.setVisible(false);
|
||||
picturePanel.setCard(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,10 +83,12 @@ public enum CPicture implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
setMouseWheelListener();
|
||||
setMouseButtonListener();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,21 +101,21 @@ public enum CPicture implements ICDoc {
|
||||
private void setMouseButtonListener() {
|
||||
this.picturePanel.addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void onLeftClick(MouseEvent e) {
|
||||
flipCard();
|
||||
public void onLeftClick(final MouseEvent e) {
|
||||
controller.flip();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMiddleMouseDown(MouseEvent e) {
|
||||
public void onMiddleMouseDown(final MouseEvent e) {
|
||||
if (isCardDisplayed()) {
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(currentView);
|
||||
zoomer.doMouseButtonZoom(controller.getCurrentCard());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMiddleMouseUp(MouseEvent e) {
|
||||
public void onMiddleMouseUp(final MouseEvent e) {
|
||||
if (isCardDisplayed()) {
|
||||
CardZoomer.SINGLETON_INSTANCE.closeZoomer();
|
||||
zoomer.closeZoomer();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -157,10 +130,10 @@ public enum CPicture implements ICDoc {
|
||||
private void setMouseWheelListener() {
|
||||
picturePanel.addMouseWheelListener(new MouseWheelListener() {
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent arg0) {
|
||||
public void mouseWheelMoved(final MouseWheelEvent arg0) {
|
||||
if (isCardDisplayed()) {
|
||||
if (arg0.getWheelRotation() < 0) {
|
||||
zoomer.doMouseWheelZoom(currentView);
|
||||
zoomer.doMouseWheelZoom(controller.getCurrentCard());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,18 +141,11 @@ public enum CPicture implements ICDoc {
|
||||
}
|
||||
|
||||
private boolean isCardDisplayed() {
|
||||
return (currentView != null);
|
||||
return controller.getCurrentCard() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
public void flipCard() {
|
||||
if (MatchUtil.canCardBeFlipped(currentView)) {
|
||||
isDisplayAlt = !isDisplayAlt;
|
||||
picturePanel.setCard(currentView.getState(isDisplayAlt || alwaysDisplayAlt));
|
||||
CDetail.SINGLETON_INSTANCE.showCard(currentView, isDisplayAlt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VPlayers;
|
||||
|
||||
/**
|
||||
@@ -10,9 +11,21 @@ import forge.screens.match.views.VPlayers;
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*
|
||||
*/
|
||||
public enum CPlayers implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
public class CPlayers implements ICDoc {
|
||||
|
||||
private final CMatchUI matchUI;
|
||||
private final VPlayers view;
|
||||
public CPlayers(final CMatchUI matchUI) {
|
||||
this.matchUI = matchUI;
|
||||
this.view = new VPlayers(this);
|
||||
}
|
||||
|
||||
public final CMatchUI getMatchUI() {
|
||||
return matchUI;
|
||||
}
|
||||
public final VPlayers getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -22,6 +35,10 @@ public enum CPlayers implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#initialize()
|
||||
*/
|
||||
@@ -34,6 +51,6 @@ public enum CPlayers implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
VPlayers.SINGLETON_INSTANCE.update();
|
||||
view.update();
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user