checkstyle

This commit is contained in:
jendave
2011-10-26 19:54:07 +00:00
parent 32c981b068
commit d12136f714
9 changed files with 1523 additions and 1452 deletions

View File

@@ -5,7 +5,6 @@ import javax.swing.UIManager;
import net.slightlymagic.braids.util.UtilFunctions; import net.slightlymagic.braids.util.UtilFunctions;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor; import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
import arcane.ui.util.ManaSymbols; import arcane.ui.util.ManaSymbols;
import com.esotericsoftware.minlog.Log; import com.esotericsoftware.minlog.Log;
@@ -26,37 +25,48 @@ import forge.view.swing.OldGuiNewGame.CardStackAction;
import forge.view.swing.OldGuiNewGame.CardStackOffsetAction; import forge.view.swing.OldGuiNewGame.CardStackOffsetAction;
/** /**
* The main view for Forge: a java swing application. * The main view for Forge: a java swing application. All view class instances
* All view class instances should be accessible from here. * should be accessible from here.
*/ */
public class ApplicationView implements FView { public class ApplicationView implements FView {
private transient SplashFrame splashFrame; private transient SplashFrame splashFrame;
/** /**
* The splashFrame field is guaranteed to exist when this constructor * The splashFrame field is guaranteed to exist when this constructor exits.
* exits. *
* @param skin
* the skin
*/ */
public ApplicationView(final FSkin skin) { public ApplicationView(final FSkin skin) {
// We must use invokeAndWait here to fulfill the constructor's // We must use invokeAndWait here to fulfill the constructor's
// contract. // contract.
UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() { // NOPMD by Braids on 8/18/11 11:37 PM UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() { // NOPMD
public void run() { // by
splashFrame = new SplashFrame(skin); // Braids
} // on
}); // 8/18/11
// 11:37
// PM
public void run() {
splashFrame = new SplashFrame(skin);
}
});
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/18/11 11:37 PM SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on
public void run() { // 8/18/11 11:37 PM
splashFrame.setVisible(true); public void run() {
} splashFrame.setVisible(true);
}); }
});
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see forge.view.FView#getCardLoadingProgressMonitor() * @see forge.view.FView#getCardLoadingProgressMonitor()
*/ */
@Override @Override
@@ -65,15 +75,16 @@ public class ApplicationView implements FView {
if (splashFrame == null) { if (splashFrame == null) {
result = null; result = null;
} } else {
else {
result = splashFrame.getMonitorModel(); result = splashFrame.getMonitorModel();
} }
return result; return result;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see forge.view.FView#setModel(forge.model.FModel) * @see forge.view.FView#setModel(forge.model.FModel)
*/ */
@@ -105,62 +116,68 @@ public class ApplicationView implements FView {
Log.error("Error loading preferences: " + exn); Log.error("Error loading preferences: " + exn);
} }
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/7/11 1:07 PM: this isn't a web app SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/7/11
public void run() { // 1:07 PM: this isn't a web
final ForgePreferences finalPreferences = model.getPreferences(); // app
public void run() {
final ForgePreferences finalPreferences = model.getPreferences();
try { try {
if ("".equals(finalPreferences.laf)) { if ("".equals(finalPreferences.laf)) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} else { } else {
UIManager.setLookAndFeel(finalPreferences.laf); UIManager.setLookAndFeel(finalPreferences.laf);
}
} catch (Exception ex) {
ErrorViewer.showError(ex);
}
} }
} catch (Exception ex) { });
ErrorViewer.showError(ex);
}
}
});
// For the following two blocks, check if user has cancelled SplashFrame. // For the following two blocks, check if user has cancelled
// SplashFrame.
// Note: Error thrown sometimes because log file cannot be accessed // Note: Error thrown sometimes because log file cannot be accessed
if(!splashFrame.getSplashHasBeenClosed()) { if (!splashFrame.getSplashHasBeenClosed()) {
AllZone.getCardFactory(); // forces preloading of all cards AllZone.getCardFactory(); // forces preloading of all cards
} }
if(!splashFrame.getSplashHasBeenClosed()) { if (!splashFrame.getSplashHasBeenClosed()) {
try { try {
ManaSymbols.loadImages(); ManaSymbols.loadImages();
Constant.Runtime.gameType = GameType.Constructed; Constant.Runtime.gameType = GameType.Constructed;
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/7/11 1:07 PM: this isn't a web app SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids
public void run() { // on 8/7/11 1:07
AllZone.getInputControl().setComputer(new ComputerAI_Input(new ComputerAI_General())); // PM: this isn't a
// web app
public void run() {
AllZone.getInputControl().setComputer(new ComputerAI_Input(new ComputerAI_General()));
// Enable only one of the following two lines. The second // Enable only one of the following two lines.
// is useful for debugging. // The second
// is useful for debugging.
splashFrame.dispose(); splashFrame.dispose();
//splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
splashFrame = null;
splashFrame = null; if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
if (System.getenv("NG2") != null) { String[] argz = {};
if (System.getenv("NG2").equalsIgnoreCase("true")) { Gui_HomeScreen.main(argz);
String argz[] = {}; } else {
Gui_HomeScreen.main(argz); new OldGuiNewGame();
} else { }
new OldGuiNewGame(); } else {
new OldGuiNewGame();
}
} }
} else { });
new OldGuiNewGame();
}
}
});
} catch (Exception ex) { } catch (Exception ex) {
ErrorViewer.showError(ex); ErrorViewer.showError(ex);
} }
} // End if(splashHasBeenClosed) } // End if(splashHasBeenClosed)
} // End ApplicationView() } // End ApplicationView()
} }

File diff suppressed because it is too large Load Diff

View File

@@ -35,19 +35,20 @@ public final class Main {
final FView view = new ApplicationView(skin); final FView view = new ApplicationView(skin);
Singletons.setView(view); Singletons.setView(view);
// Need this soon after card factory is loaded // Need this soon after card factory is loaded
OldGuiNewGame.loadDynamicGamedata(); OldGuiNewGame.loadDynamicGamedata();
// TODO: this code should go elsewhere, like wherever we start a new game. // TODO this code should go elsewhere, like wherever we start a new
// It is only here to maintain semantic equality with the current code base. // game.
// It is only here to maintain semantic equality with the current
// code base.
model.resetGameState(); model.resetGameState();
view.setModel(model); view.setModel(model);
} } catch (Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: must
catch (Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: must catch all throwables here. // catch all throwables here.
ErrorViewer.showError(exn); ErrorViewer.showError(exn);
} }
} }

View File

@@ -1,7 +1,65 @@
package forge.view.swing; package forge.view.swing;
import static net.slightlymagic.braids.util.UtilFunctions.safeToString;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.TitledBorder;
import net.miginfocom.swing.MigLayout;
import com.esotericsoftware.minlog.Log; import com.esotericsoftware.minlog.Log;
import forge.*;
import forge.AllZone;
import forge.Command;
import forge.Constant;
import forge.Constant_StringArrayList;
import forge.FileUtil;
import forge.GUI_ImportPicture;
import forge.GuiDisplay4;
import forge.GuiDownloadQuestImages;
import forge.Gui_DownloadPictures_LQ;
import forge.Gui_DownloadPrices;
import forge.Gui_DownloadSetPictures_LQ;
import forge.ImageCache;
import forge.MyRandom;
import forge.PlayerType;
import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckGeneration; import forge.deck.DeckGeneration;
import forge.deck.DeckManager; import forge.deck.DeckManager;
@@ -13,8 +71,8 @@ import forge.game.limited.CardPoolLimitation;
import forge.game.limited.SealedDeck; import forge.game.limited.SealedDeck;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import forge.gui.ListChooser; import forge.gui.ListChooser;
import forge.gui.deckeditor.DeckEditorDraft;
import forge.gui.deckeditor.DeckEditorCommon; import forge.gui.deckeditor.DeckEditorCommon;
import forge.gui.deckeditor.DeckEditorDraft;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.item.ItemPool; import forge.item.ItemPool;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
@@ -25,21 +83,6 @@ import forge.properties.NewConstants;
import forge.properties.NewConstants.LANG.OldGuiNewGame.MENU_BAR.MENU; import forge.properties.NewConstants.LANG.OldGuiNewGame.MENU_BAR.MENU;
import forge.properties.NewConstants.LANG.OldGuiNewGame.MENU_BAR.OPTIONS; import forge.properties.NewConstants.LANG.OldGuiNewGame.MENU_BAR.OPTIONS;
import forge.quest.gui.QuestOptions; import forge.quest.gui.QuestOptions;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.*;
import java.util.List;
import static net.slightlymagic.braids.util.UtilFunctions.safeToString;
/*CHOPPIC*/ /*CHOPPIC*/
@@ -82,14 +125,17 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
// @SuppressWarnings("unused") // @SuppressWarnings("unused")
// titledBorder2 // titledBorder2
/** Constant <code>newGuiCheckBox</code> */ /** Constant <code>newGuiCheckBox</code>. */
// private static JCheckBox newGuiCheckBox = new JCheckBox("", true); // private static JCheckBox newGuiCheckBox = new JCheckBox("", true);
/** Constant <code>smoothLandCheckBox</code>. */ /** Constant <code>smoothLandCheckBox</code>. */
static JCheckBox smoothLandCheckBox = new JCheckBox("", false); static JCheckBox smoothLandCheckBox = new JCheckBox("", false);
/** Constant <code>devModeCheckBox</code>. */ /** Constant <code>devModeCheckBox</code>. */
static JCheckBox devModeCheckBox = new JCheckBox("", true); static JCheckBox devModeCheckBox = new JCheckBox("", true);
/** The upld drft check box. */
static JCheckBox upldDrftCheckBox = new JCheckBox("", true); static JCheckBox upldDrftCheckBox = new JCheckBox("", true);
/** The foil random check box. */
static JCheckBox foilRandomCheckBox = new JCheckBox("", true); static JCheckBox foilRandomCheckBox = new JCheckBox("", true);
// GenerateConstructedDeck.get2Colors() and GenerateSealedDeck.get2Colors() // GenerateConstructedDeck.get2Colors() and GenerateSealedDeck.get2Colors()
@@ -179,7 +225,6 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
setupMenu(); setupMenu();
setVisible(true); setVisible(true);
Log.WARN(); // set logging level to warn Log.WARN(); // set logging level to warn
SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(this);
} }
@@ -198,15 +243,14 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
// LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION, // LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION,
// DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, IMPORT_PICTURE, // DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, IMPORT_PICTURE,
// CARD_SIZES_ACTION, // CARD_SIZES_ACTION,
LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ, DOWNLOAD_ACTION_QUEST, LOOK_AND_FEEL_ACTION, DNLD_PRICES_ACTION, DOWNLOAD_ACTION_LQ, DOWNLOAD_ACTION_SETLQ,
IMPORT_PICTURE, CARD_SIZES_ACTION, CARD_STACK_ACTION, CARD_STACK_OFFSET_ACTION, BUGZ_REPORTER_ACTION, DOWNLOAD_ACTION_QUEST, IMPORT_PICTURE, CARD_SIZES_ACTION, CARD_STACK_ACTION, CARD_STACK_OFFSET_ACTION,
ErrorViewer.ALL_THREADS_ACTION, ABOUT_ACTION, EXIT_ACTION }; BUGZ_REPORTER_ACTION, ErrorViewer.ALL_THREADS_ACTION, ABOUT_ACTION, EXIT_ACTION };
JMenu menu = new JMenu(ForgeProps.getLocalized(MENU.TITLE)); JMenu menu = new JMenu(ForgeProps.getLocalized(MENU.TITLE));
for (Action a : actions) { for (Action a : actions) {
menu.add(a); menu.add(a);
if (a.equals(LOOK_AND_FEEL_ACTION) || a.equals(IMPORT_PICTURE) || a.equals(CARD_STACK_OFFSET_ACTION) if (a.equals(LOOK_AND_FEEL_ACTION) || a.equals(IMPORT_PICTURE) || a.equals(CARD_STACK_OFFSET_ACTION)
|| a.equals(ErrorViewer.ALL_THREADS_ACTION)) || a.equals(ErrorViewer.ALL_THREADS_ACTION)) {
{
menu.addSeparator(); menu.addSeparator();
} }
} }
@@ -217,18 +261,18 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
JMenu generatedDeck = new JMenu(ForgeProps.getLocalized(MENU_BAR.OPTIONS.GENERATE.TITLE)); JMenu generatedDeck = new JMenu(ForgeProps.getLocalized(MENU_BAR.OPTIONS.GENERATE.TITLE));
generatedDeck.add(removeSmallCreatures); generatedDeck.add(removeSmallCreatures);
removeSmallCreatures.addActionListener(new ActionListener () { removeSmallCreatures.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) { public void actionPerformed(final ActionEvent arg0) {
Singletons.getModel().getPreferences().deckGenRmvSmall = removeSmallCreatures.isSelected(); Singletons.getModel().getPreferences().deckGenRmvSmall = removeSmallCreatures.isSelected();
} }
}); });
generatedDeck.add(removeArtifacts); generatedDeck.add(removeArtifacts);
removeArtifacts.addActionListener(new ActionListener () { removeArtifacts.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) { public void actionPerformed(final ActionEvent arg0) {
Singletons.getModel().getPreferences().deckGenRmvArtifacts = removeArtifacts.isSelected(); Singletons.getModel().getPreferences().deckGenRmvArtifacts = removeArtifacts.isSelected();
} }
}); });
JMenu optionsMenu = new JMenu(ForgeProps.getLocalized(OPTIONS.TITLE)); JMenu optionsMenu = new JMenu(ForgeProps.getLocalized(OPTIONS.TITLE));
optionsMenu.add(generatedDeck); optionsMenu.add(generatedDeck);
@@ -335,8 +379,8 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
else { else {
throw new IllegalStateException( throw new IllegalStateException("choice <<" + safeToString(o)
"choice <<" + safeToString(o) + ">> does not equal any of the sealedTypes."); + ">> does not equal any of the sealedTypes.");
} }
ItemPool<CardPrinted> sDeck = sd.getCardpool(); ItemPool<CardPrinted> sDeck = sd.getCardpool();
@@ -361,8 +405,12 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
Constant.Runtime.HumanDeck[0] = deck; Constant.Runtime.HumanDeck[0] = deck;
Constant.Runtime.gameType = GameType.Sealed; Constant.Runtime.gameType = GameType.Sealed;
//Deck aiDeck = sd.buildAIDeck(sDeck.toForgeCardList()); // Deck aiDeck = sd.buildAIDeck(sDeck.toForgeCardList());
Deck aiDeck = sd.buildAIDeck(sd.getCardpool().toForgeCardList()); // AI will use different cardpool Deck aiDeck = sd.buildAIDeck(sd.getCardpool().toForgeCardList()); // AI
// will
// use
// different
// cardpool
aiDeck.setName("AI_" + sDeckName); aiDeck.setName("AI_" + sDeckName);
aiDeck.setPlayerType(PlayerType.COMPUTER); aiDeck.setPlayerType(PlayerType.COMPUTER);
deckManager.addDeck(aiDeck); deckManager.addDeck(aiDeck);
@@ -371,7 +419,6 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
deckEditorButtonActionPerformed(GameType.Sealed, deck); deckEditorButtonActionPerformed(GameType.Sealed, deck);
Constant.Runtime.ComputerDeck[0] = aiDeck; Constant.Runtime.ComputerDeck[0] = aiDeck;
} else { } else {
new OldGuiNewGame(); new OldGuiNewGame();
@@ -575,8 +622,9 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
ImageIcon bkgd = new ImageIcon("res/images/ui/newgame_background.jpg"); ImageIcon bkgd = new ImageIcon("res/images/ui/newgame_background.jpg");
JLabel myLabel = new JLabel(bkgd); JLabel myLabel = new JLabel(bkgd);
// Do not pass Integer.MIN_VALUE directly here; it must be packaged in an Integer // Do not pass Integer.MIN_VALUE directly here; it must be packaged in
// instance. Otherwise, GUI components will not draw unless moused over. // an Integer
// instance. Otherwise, GUI components will not draw unless moused over.
getLayeredPane().add(myLabel, Integer.valueOf(Integer.MIN_VALUE)); getLayeredPane().add(myLabel, Integer.valueOf(Integer.MIN_VALUE));
myLabel.setBounds(0, 0, bkgd.getIconWidth(), bkgd.getIconHeight()); myLabel.setBounds(0, 0, bkgd.getIconWidth(), bkgd.getIconHeight());
@@ -632,8 +680,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
* deckEditorButton_actionPerformed. * deckEditorButton_actionPerformed.
* </p> * </p>
* *
* @param e * @param gt
* a {@link java.awt.event.ActionEvent} object. * the gt
* @param deck
* the deck
*/ */
final void deckEditorButtonActionPerformed(final GameType gt, final Deck deck) { final void deckEditorButtonActionPerformed(final GameType gt, final Deck deck) {
@@ -793,7 +843,6 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
dispose(); dispose();
} // startButton_actionPerformed() } // startButton_actionPerformed()
/** /**
* <p> * <p>
* singleRadioButton_actionPerformed. * singleRadioButton_actionPerformed.
@@ -831,44 +880,47 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
allDecks = getDecks(); allDecks = getDecks();
switch (Constant.Runtime.gameType) { switch (Constant.Runtime.gameType) {
case Sealed: case Sealed:
humanComboBox.addItem("New Sealed"); humanComboBox.addItem("New Sealed");
computerComboBox.addItem("New Sealed"); computerComboBox.addItem("New Sealed");
for (Deck allDeck : allDecks) { for (Deck allDeck : allDecks) {
if (allDeck.getDeckType().equals(GameType.Sealed)) { if (allDeck.getDeckType().equals(GameType.Sealed)) {
JComboBox boxToAdd = allDeck.getPlayerType() == PlayerType.COMPUTER ? computerComboBox : humanComboBox; JComboBox boxToAdd = allDeck.getPlayerType() == PlayerType.COMPUTER ? computerComboBox
boxToAdd.addItem(allDeck.getName()); : humanComboBox;
} boxToAdd.addItem(allDeck.getName());
} // for
break;
case Constructed:
humanComboBox.addItem("Generate Deck");
computerComboBox.addItem("Generate Deck");
humanComboBox.addItem("Random");
computerComboBox.addItem("Random");
for (Deck allDeck : allDecks) {
if (allDeck.getDeckType().equals(GameType.Constructed)) {
humanComboBox.addItem(allDeck.getName());
computerComboBox.addItem(allDeck.getName());
}
} // for
break;
case Draft:
humanComboBox.addItem("New Draft");
Object[] key = deckManager.getDraftDecks().keySet().toArray();
Arrays.sort(key);
for (Object aKey : key) {
humanComboBox.addItem(aKey);
} }
} // for
break;
case Constructed:
humanComboBox.addItem("Generate Deck");
computerComboBox.addItem("Generate Deck");
for (int i = 0; i < 7; i++) { humanComboBox.addItem("Random");
computerComboBox.addItem("" + (i + 1)); computerComboBox.addItem("Random");
for (Deck allDeck : allDecks) {
if (allDeck.getDeckType().equals(GameType.Constructed)) {
humanComboBox.addItem(allDeck.getName());
computerComboBox.addItem(allDeck.getName());
} }
break; } // for
break;
case Draft:
humanComboBox.addItem("New Draft");
Object[] key = deckManager.getDraftDecks().keySet().toArray();
Arrays.sort(key);
for (Object aKey : key) {
humanComboBox.addItem(aKey);
}
for (int i = 0; i < 7; i++) {
computerComboBox.addItem("" + (i + 1));
}
break;
default:
break;
} }
// not sure if the code below is useful or not // not sure if the code below is useful or not
// this will select the deck that you previously used // this will select the deck that you previously used
@@ -906,16 +958,21 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
return out; return out;
} // getDecks() } // getDecks()
/**
* Draft radio button action performed.
*
* @param e
* the e
*/
final void draftRadioButtonActionPerformed(final ActionEvent e) { final void draftRadioButtonActionPerformed(final ActionEvent e) {
Constant.Runtime.gameType = GameType.Draft; Constant.Runtime.gameType = GameType.Draft;
updateDeckComboBoxes(); updateDeckComboBoxes();
} }
/** /**
* The Class LookAndFeelAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class LookAndFeelAction extends AbstractAction { public static class LookAndFeelAction extends AbstractAction {
@@ -923,8 +980,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
private Component c; private Component c;
/** /**
* Instantiates a new look and feel action.
* *
* @param component * @param component
* the component
*/ */
public LookAndFeelAction(final Component component) { public LookAndFeelAction(final Component component) {
super(ForgeProps.getLocalized(MENU_BAR.MENU.LF)); super(ForgeProps.getLocalized(MENU_BAR.MENU.LF));
@@ -932,7 +991,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Action performed.
*
* @param e * @param e
* the e
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
@@ -974,8 +1036,8 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
"org.pushingpixels.substance.api.skin.SubstanceOfficeSilver2007LookAndFeel"); "org.pushingpixels.substance.api.skin.SubstanceOfficeSilver2007LookAndFeel");
LAFMap.put("Raven", "org.pushingpixels.substance.api.skin.SubstanceRavenLookAndFeel"); LAFMap.put("Raven", "org.pushingpixels.substance.api.skin.SubstanceRavenLookAndFeel");
LAFMap.put("Raven Graphite", "org.pushingpixels.substance.api.skin.SubstanceRavenGraphiteLookAndFeel"); LAFMap.put("Raven Graphite", "org.pushingpixels.substance.api.skin.SubstanceRavenGraphiteLookAndFeel");
//LAFMap.put("Raven Graphite Glass", // LAFMap.put("Raven Graphite Glass",
//"org.pushingpixels.substance.api.skin.SubstanceRavenGraphiteGlassLookAndFeel"); // "org.pushingpixels.substance.api.skin.SubstanceRavenGraphiteGlassLookAndFeel");
LAFMap.put("Sahara", "org.pushingpixels.substance.api.skin.SubstanceSaharaLookAndFeel"); LAFMap.put("Sahara", "org.pushingpixels.substance.api.skin.SubstanceSaharaLookAndFeel");
LAFMap.put("Twilight", "org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel"); LAFMap.put("Twilight", "org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel");
@@ -1007,23 +1069,30 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
} }
/** /**
* * The Class DownloadPriceAction.
* @author dhudson *
* * @author dhudson
*/ */
public static class DownloadPriceAction extends AbstractAction { public static class DownloadPriceAction extends AbstractAction {
private static final long serialVersionUID = 929877827872974298L; private static final long serialVersionUID = 929877827872974298L;
/** /**
* * Instantiates a new download price action.
*/ */
public DownloadPriceAction() { public DownloadPriceAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADPRICE)); super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADPRICE));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
Gui_DownloadPrices gdp = new Gui_DownloadPrices(); Gui_DownloadPrices gdp = new Gui_DownloadPrices();
@@ -1032,9 +1101,9 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class BugzReporterAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class BugzReporterAction extends AbstractAction { public static class BugzReporterAction extends AbstractAction {
@@ -1044,21 +1113,27 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
private static final long serialVersionUID = 6354047838575733085L; private static final long serialVersionUID = 6354047838575733085L;
/** /**
* * Instantiates a new bugz reporter action.
*/ */
public BugzReporterAction() { public BugzReporterAction() {
super("Report Bug"); super("Report Bug");
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
BugzReporter br = new BugzReporter(); BugzReporter br = new BugzReporter();
br.setVisible(true); br.setVisible(true);
} }
} }
/* /*
@@ -1074,23 +1149,30 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
* Gui_DownloadPictures.startDownload(null); } } * Gui_DownloadPictures.startDownload(null); } }
*/ */
/** /**
* The Class DownloadActionLQ.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class DownloadActionLQ extends AbstractAction { public static class DownloadActionLQ extends AbstractAction {
private static final long serialVersionUID = -6234380664413874813L; private static final long serialVersionUID = -6234380664413874813L;
/** /**
* * Instantiates a new download action lq.
*/ */
public DownloadActionLQ() { public DownloadActionLQ() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADLQ)); super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADLQ));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
new Gui_DownloadPictures_LQ(null); new Gui_DownloadPictures_LQ(null);
@@ -1098,22 +1180,29 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class DownloadActionSetLQ.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class DownloadActionSetLQ extends AbstractAction { public static class DownloadActionSetLQ extends AbstractAction {
private static final long serialVersionUID = 2947202546752930L; private static final long serialVersionUID = 2947202546752930L;
/** /**
* * Instantiates a new download action set lq.
*/ */
public DownloadActionSetLQ() { public DownloadActionSetLQ() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADSETLQ)); super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADSETLQ));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
new Gui_DownloadSetPictures_LQ(null); new Gui_DownloadSetPictures_LQ(null);
@@ -1121,47 +1210,61 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* * The Class DownloadActionQuest.
* @author slapshot5 *
* * @author slapshot5
*/ */
public static class DownloadActionQuest extends AbstractAction { public static class DownloadActionQuest extends AbstractAction {
private static final long serialVersionUID = -4439763134551377894L; private static final long serialVersionUID = -4439763134551377894L;
/** /**
* * Instantiates a new download action quest.
*/ */
public DownloadActionQuest() { public DownloadActionQuest() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADQUESTIMG)); super(ForgeProps.getLocalized(MENU_BAR.MENU.DOWNLOADQUESTIMG));
} }
/** /*
* * (non-Javadoc)
*/ *
public final void actionPerformed(final ActionEvent e) { * @see
//GuiDownloadQuestImages.startDownload(null); * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
new GuiDownloadQuestImages(null); * )
} */
} /**
* @param e ActionEvent
*/
public final void actionPerformed(final ActionEvent e) {
// GuiDownloadQuestImages.startDownload(null);
new GuiDownloadQuestImages(null);
}
}
/** /**
* The Class ImportPictureAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class ImportPictureAction extends AbstractAction { public static class ImportPictureAction extends AbstractAction {
private static final long serialVersionUID = 6893292814498031508L; private static final long serialVersionUID = 6893292814498031508L;
/** /**
* * Instantiates a new import picture action.
*/ */
public ImportPictureAction() { public ImportPictureAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.IMPORTPICTURE)); super(ForgeProps.getLocalized(MENU_BAR.MENU.IMPORTPICTURE));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
GUI_ImportPicture ip = new GUI_ImportPicture(null); GUI_ImportPicture ip = new GUI_ImportPicture(null);
@@ -1170,25 +1273,32 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class CardSizesAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class CardSizesAction extends AbstractAction { public static class CardSizesAction extends AbstractAction {
private static final long serialVersionUID = -2900235618450319571L; private static final long serialVersionUID = -2900235618450319571L;
private static String[] keys = {"Tiny", "Smaller", "Small", "Medium", "Large", "Huge"}; private static String[] keys = { "Tiny", "Smaller", "Small", "Medium", "Large", "Huge" };
private static int[] widths = {52, 80, 120, 200, 300, 400}; private static int[] widths = { 52, 80, 120, 200, 300, 400 };
/** /**
* * Instantiates a new card sizes action.
*/ */
public CardSizesAction() { public CardSizesAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.CARD_SIZES)); super(ForgeProps.getLocalized(MENU_BAR.MENU.CARD_SIZES));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
ListChooser<String> ch = new ListChooser<String>("Choose one", "Choose a new max card size", 0, 1, keys); ListChooser<String> ch = new ListChooser<String>("Choose one", "Choose a new max card size", 0, 1, keys);
@@ -1206,8 +1316,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Sets the.
* *
* @param index * @param index
* the index
*/ */
public static void set(final int index) { public static void set(final int index) {
Singletons.getModel().getPreferences().cardSize = CardSizeType.valueOf(keys[index].toLowerCase()); Singletons.getModel().getPreferences().cardSize = CardSizeType.valueOf(keys[index].toLowerCase());
@@ -1216,8 +1328,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Sets the.
* *
* @param s * @param s
* the s
*/ */
public static void set(final CardSizeType s) { public static void set(final CardSizeType s) {
Singletons.getModel().getPreferences().cardSize = s; Singletons.getModel().getPreferences().cardSize = s;
@@ -1234,30 +1348,37 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class CardStackAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class CardStackAction extends AbstractAction { public static class CardStackAction extends AbstractAction {
private static final long serialVersionUID = -3770527681359311455L; private static final long serialVersionUID = -3770527681359311455L;
private static String[] keys = {"3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; private static String[] keys = {"3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
private static int[] values = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; private static int[] values = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
/** /**
* * Instantiates a new card stack action.
*/ */
public CardStackAction() { public CardStackAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.CARD_STACK)); super(ForgeProps.getLocalized(MENU_BAR.MENU.CARD_STACK));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
ListChooser<String> ch = new ListChooser<String>("Choose one", "Choose the max size of a stack", 0, 1, ListChooser<String> ch
keys); = new ListChooser<String>("Choose one", "Choose the max size of a stack", 0, 1, keys);
if (ch.show()) { if (ch.show()) {
try { try {
@@ -1274,8 +1395,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Sets the.
* *
* @param index * @param index
* the index
*/ */
public static void set(final int index) { public static void set(final int index) {
Singletons.getModel().getPreferences().maxStackSize = values[index]; Singletons.getModel().getPreferences().maxStackSize = values[index];
@@ -1283,8 +1406,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Sets the val.
* *
* @param val * @param val
* the new val
*/ */
public static void setVal(final int val) { public static void setVal(final int val) {
Singletons.getModel().getPreferences().maxStackSize = val; Singletons.getModel().getPreferences().maxStackSize = val;
@@ -1293,25 +1418,32 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class CardStackOffsetAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class CardStackOffsetAction extends AbstractAction { public static class CardStackOffsetAction extends AbstractAction {
private static final long serialVersionUID = 5021304777748833975L; private static final long serialVersionUID = 5021304777748833975L;
private static String[] keys = {"Tiny", "Small", "Medium", "Large"}; private static String[] keys = {"Tiny", "Small", "Medium", "Large"};
private static int[] offsets = {5, 7, 10, 15}; private static int[] offsets = { 5, 7, 10, 15 };
/** /**
* * Instantiates a new card stack offset action.
*/ */
public CardStackOffsetAction() { public CardStackOffsetAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.CARD_STACK_OFFSET)); super(ForgeProps.getLocalized(MENU_BAR.MENU.CARD_STACK_OFFSET));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
ListChooser<String> ch = new ListChooser<String>("Choose one", "Choose a stack offset value", 0, 1, keys); ListChooser<String> ch = new ListChooser<String>("Choose one", "Choose a stack offset value", 0, 1, keys);
@@ -1330,8 +1462,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Sets the.
* *
* @param index * @param index
* the index
*/ */
public static void set(final int index) { public static void set(final int index) {
Singletons.getModel().getPreferences().stackOffset = StackOffsetType.valueOf(keys[index].toLowerCase()); Singletons.getModel().getPreferences().stackOffset = StackOffsetType.valueOf(keys[index].toLowerCase());
@@ -1339,8 +1473,10 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* Sets the.
* *
* @param s * @param s
* the s
*/ */
public static void set(final StackOffsetType s) { public static void set(final StackOffsetType s) {
Singletons.getModel().getPreferences().stackOffset = s; Singletons.getModel().getPreferences().stackOffset = s;
@@ -1356,23 +1492,30 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class HowToPlayAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class HowToPlayAction extends AbstractAction { public static class HowToPlayAction extends AbstractAction {
private static final long serialVersionUID = 5552000208438248428L; private static final long serialVersionUID = 5552000208438248428L;
/** /**
* * Instantiates a new how to play action.
*/ */
public HowToPlayAction() { public HowToPlayAction() {
super(ForgeProps.getLocalized(LANG.HowTo.TITLE)); super(ForgeProps.getLocalized(LANG.HowTo.TITLE));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
String text = ForgeProps.getLocalized(LANG.HowTo.MESSAGE); String text = ForgeProps.getLocalized(LANG.HowTo.MESSAGE);
@@ -1389,23 +1532,30 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* The Class AboutAction.
* *
* @author dhudson * @author dhudson
*
*/ */
public static class AboutAction extends AbstractAction { public static class AboutAction extends AbstractAction {
private static final long serialVersionUID = 5492173304463396871L; private static final long serialVersionUID = 5492173304463396871L;
/** /**
* * Instantiates a new about action.
*/ */
public AboutAction() { public AboutAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.ABOUT)); super(ForgeProps.getLocalized(MENU_BAR.MENU.ABOUT));
} }
/** /*
* (non-Javadoc)
* *
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
* )
*/
/**
* @param e ActionEvent
*/ */
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
JTextArea area = new JTextArea(12, 25); JTextArea area = new JTextArea(12, 25);
@@ -1432,27 +1582,34 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* * The Class ExitAction.
* @author slapshot5 *
* * @author slapshot5
*/ */
public static class ExitAction extends AbstractAction { public static class ExitAction extends AbstractAction {
private static final long serialVersionUID = -319036939657136034L; private static final long serialVersionUID = -319036939657136034L;
/** /**
* * Instantiates a new exit action.
*/ */
public ExitAction() { public ExitAction() {
super(ForgeProps.getLocalized(MENU_BAR.MENU.EXIT)); super(ForgeProps.getLocalized(MENU_BAR.MENU.EXIT));
} }
/** /*
* * (non-Javadoc)
*/ *
public final void actionPerformed(final ActionEvent e) { * @see
System.exit(0); * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent
} * )
} */
/**
* @param e ActionEvent
*/
public final void actionPerformed(final ActionEvent e) {
System.exit(0);
}
}
/** /**
* <p> * <p>
@@ -1521,7 +1678,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
/** /**
* * Load dynamic gamedata.
*/ */
public static void loadDynamicGamedata() { public static void loadDynamicGamedata() {
if (!Constant.CardTypes.loaded[0]) { if (!Constant.CardTypes.loaded[0]) {
@@ -1620,9 +1777,9 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
} }
Constant.Keywords.loaded[0] = true; Constant.Keywords.loaded[0] = true;
/* /*
if (Constant.Runtime.DevMode[0]) { * if (Constant.Runtime.DevMode[0]) {
System.out.println(Constant.Keywords.NonStackingList[0].list); * System.out.println(Constant.Keywords.NonStackingList[0].list); }
}*/ */
} }
/* /*

View File

@@ -10,15 +10,15 @@ import javax.swing.BorderFactory;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import forge.gui.skin.FSkin;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor; import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
import forge.gui.skin.FSkin;
/** /**
* Shows the splash frame as the application starts. * Shows the splash frame as the application starts.
@@ -27,19 +27,19 @@ import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
public class SplashFrame extends JFrame { public class SplashFrame extends JFrame {
// Inits: Visual changes can be made here. // Inits: Visual changes can be made here.
private static final int BAR_PADDING_X = 20; private static final int BAR_PADDING_X = 20;
private static final int BAR_PADDING_Y = 20; private static final int BAR_PADDING_Y = 20;
private static final int BAR_HEIGHT = 57; private static final int BAR_HEIGHT = 57;
private static final int DISCLAIMER_HEIGHT = 20; private static final int DISCLAIMER_HEIGHT = 20;
private static final int DISCLAIMER_TOP = 300; private static final int DISCLAIMER_TOP = 300;
private static final int DISCLAIMER_FONT_SIZE = 9; private static final int DISCLAIMER_FONT_SIZE = 9;
private static final Color DISCLAIMER_COLOR = Color.white; private static final Color DISCLAIMER_COLOR = Color.white;
//private static final int CLOSEBTN_PADDING_X = 15; // private static final int CLOSEBTN_PADDING_X = 15;
private static final int CLOSEBTN_PADDING_Y = 15; private static final int CLOSEBTN_PADDING_Y = 15;
private static final int CLOSEBTN_SIDELENGTH = 15; private static final int CLOSEBTN_SIDELENGTH = 15;
private static final Color CLOSEBTN_COLOR = new Color(215,208,188); private static final Color CLOSEBTN_COLOR = new Color(215, 208, 188);
private SplashProgressModel monitorModel = null; private SplashProgressModel monitorModel = null;
private SplashProgressComponent monitorView = null; private SplashProgressComponent monitorView = null;
@@ -47,14 +47,19 @@ public class SplashFrame extends JFrame {
private boolean SplashHasBeenClosed = false; private boolean SplashHasBeenClosed = false;
/** /**
* <p>Create the frame; this <strong>must</strong> be called from an event * <p>
* dispatch thread.</p> * Create the frame; this <strong>must</strong> be called from an event
*
* <!-- CheckStyle won't let me use at-throws. -->
* Throws {@link IllegalStateException} if not called from an event
* dispatch thread. * dispatch thread.
* </p>
*
* <!-- CheckStyle won't let me use at-throws. --> Throws
* {@link IllegalStateException} if not called from an event dispatch
* thread.
*
* @param skin
* the skin
*/ */
public SplashFrame(FSkin skin) { public SplashFrame(final FSkin skin) {
super(); super();
if (!SwingUtilities.isEventDispatchThread()) { if (!SwingUtilities.isEventDispatchThread()) {
@@ -79,10 +84,10 @@ public class SplashFrame extends JFrame {
contentPane.setLayout(null); contentPane.setLayout(null);
// Add disclaimer // Add disclaimer
final JLabel lblDisclaimer = new JLabel("<html><center>Forge is not affiliated in any way with Wizards of the Coast.<br>Forge is open source software, released under the GNU Public License.</center></html>"); final JLabel lblDisclaimer = new JLabel(
"<html><center>Forge is not affiliated in any way with Wizards of the Coast.<br>Forge is open source software, released under the GNU Public License.</center></html>");
lblDisclaimer.setBounds(0, DISCLAIMER_TOP, lblDisclaimer.setBounds(0, DISCLAIMER_TOP, splashWidthPx, DISCLAIMER_HEIGHT);
splashWidthPx, DISCLAIMER_HEIGHT);
lblDisclaimer.setFont(new Font("Tahoma", Font.PLAIN, DISCLAIMER_FONT_SIZE)); lblDisclaimer.setFont(new Font("Tahoma", Font.PLAIN, DISCLAIMER_FONT_SIZE));
lblDisclaimer.setHorizontalAlignment(SwingConstants.CENTER); lblDisclaimer.setHorizontalAlignment(SwingConstants.CENTER);
@@ -91,23 +96,23 @@ public class SplashFrame extends JFrame {
// Add close button // Add close button
final JButton btnClose = new JButton("X"); final JButton btnClose = new JButton("X");
btnClose.setBounds(splashWidthPx- (2 * CLOSEBTN_PADDING_Y), btnClose.setBounds(splashWidthPx - (2 * CLOSEBTN_PADDING_Y), CLOSEBTN_PADDING_Y, CLOSEBTN_SIDELENGTH,
CLOSEBTN_PADDING_Y,CLOSEBTN_SIDELENGTH,CLOSEBTN_SIDELENGTH); CLOSEBTN_SIDELENGTH);
btnClose.setForeground(CLOSEBTN_COLOR); btnClose.setForeground(CLOSEBTN_COLOR);
btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR)); btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR));
btnClose.setOpaque(false); btnClose.setOpaque(false);
btnClose.setBackground(new Color(0,0,0)); btnClose.setBackground(new Color(0, 0, 0));
btnClose.setFocusPainted(false); btnClose.setFocusPainted(false);
contentPane.add(btnClose); contentPane.add(btnClose);
// Action handler: button hover effect // Action handler: button hover effect
btnClose.addMouseListener(new java.awt.event.MouseAdapter() { btnClose.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) { public void mouseEntered(final java.awt.event.MouseEvent evt) {
btnClose.setBorder(BorderFactory.createLineBorder(Color.white)); btnClose.setBorder(BorderFactory.createLineBorder(Color.white));
btnClose.setForeground(Color.white); btnClose.setForeground(Color.white);
} }
public void mouseExited(java.awt.event.MouseEvent evt) { public void mouseExited(final java.awt.event.MouseEvent evt) {
btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR)); btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR));
btnClose.setForeground(CLOSEBTN_COLOR); btnClose.setForeground(CLOSEBTN_COLOR);
} }
@@ -117,14 +122,13 @@ public class SplashFrame extends JFrame {
btnClose.addActionListener(new closeAction()); btnClose.addActionListener(new closeAction());
// Action handler: esc key close // Action handler: esc key close
contentPane.getInputMap().put( contentPane.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "escAction");
KeyStroke.getKeyStroke( "ESCAPE" ), "escAction" );
contentPane.getActionMap().put("escAction", new closeAction()); contentPane.getActionMap().put("escAction", new closeAction());
// Set UI to color splash bar fill with theme colors // Set UI to color splash bar fill with theme colors
UIManager.put("ProgressBar.foreground", skin.bg1b); // Filled UIManager.put("ProgressBar.foreground", skin.bg1b); // Filled
UIManager.put("ProgressBar.selectionForeground",skin.txt1a);// Filled UIManager.put("ProgressBar.selectionForeground", skin.txt1a); // Filled
// Instantiate model and view and tie together. // Instantiate model and view and tie together.
monitorModel = new SplashProgressModel(); monitorModel = new SplashProgressModel();
@@ -135,15 +139,16 @@ public class SplashFrame extends JFrame {
// Add prog bar + message, bg image // Add prog bar + message, bg image
monitorView.displayUpdate("Assembling file list..."); monitorView.displayUpdate("Assembling file list...");
monitorView.setBounds(BAR_PADDING_X, splashHeightPx - BAR_PADDING_Y - BAR_HEIGHT, monitorView.setBounds(BAR_PADDING_X, splashHeightPx - BAR_PADDING_Y - BAR_HEIGHT, splashWidthPx
splashWidthPx - (2 * BAR_PADDING_X), BAR_HEIGHT); - (2 * BAR_PADDING_X), BAR_HEIGHT);
contentPane.add(monitorView); contentPane.add(monitorView);
contentPane.setOpaque(false); contentPane.setOpaque(false);
final JLabel bgLabel = new JLabel(bgIcon); final JLabel bgLabel = new JLabel(bgIcon);
// Do not pass Integer.MIN_VALUE directly here; it must be packaged in an Integer // Do not pass Integer.MIN_VALUE directly here; it must be packaged in
// instance. Otherwise, GUI components will not draw unless moused over. // an Integer
// instance. Otherwise, GUI components will not draw unless moused over.
getLayeredPane().add(bgLabel, Integer.valueOf(Integer.MIN_VALUE)); getLayeredPane().add(bgLabel, Integer.valueOf(Integer.MIN_VALUE));
bgLabel.setBounds(0, 0, splashWidthPx, splashHeightPx); bgLabel.setBounds(0, 0, splashWidthPx, splashHeightPx);
@@ -153,7 +158,9 @@ public class SplashFrame extends JFrame {
/** /**
* Getter for progress bar view. * Getter for progress bar view.
* @return the SplashViewProgressMonitor progress bar used in the splash frame. *
* @return the SplashViewProgressMonitor progress bar used in the splash
* frame.
*/ */
public final SplashProgressComponent getMonitorView() { public final SplashProgressComponent getMonitorView() {
return monitorView; return monitorView;
@@ -161,6 +168,7 @@ public class SplashFrame extends JFrame {
/** /**
* Getter for progress monitor model. * Getter for progress monitor model.
*
* @return the BraidsProgressMonitor model used in the splash frame. * @return the BraidsProgressMonitor model used in the splash frame.
*/ */
public final BraidsProgressMonitor getMonitorModel() { public final BraidsProgressMonitor getMonitorModel() {
@@ -168,7 +176,9 @@ public class SplashFrame extends JFrame {
} }
/** /**
* Returns state of splash frame, to determine if GUI should continue loading. * Returns state of splash frame, to determine if GUI should continue
* loading.
*
* @return SplashHasBeenClosed boolean. * @return SplashHasBeenClosed boolean.
*/ */
public final boolean getSplashHasBeenClosed() { public final boolean getSplashHasBeenClosed() {
@@ -177,20 +187,26 @@ public class SplashFrame extends JFrame {
/** /**
* Sets state of splash frame, to determine if GUI should continue loading. * Sets state of splash frame, to determine if GUI should continue loading.
* @param SplashHasBeenClosed boolean. *
* @param neoState
* the new splash has been closed
*/ */
public final void setSplashHasBeenClosed(boolean neoState) { public final void setSplashHasBeenClosed(final boolean neoState) {
SplashHasBeenClosed = neoState; SplashHasBeenClosed = neoState;
} }
/** /**
* <p>closeAction</p> * <p>
* Closes the splash frame by toggling "has been closed" switch * closeAction
* (to cancel preloading) and dispose() (to discard JFrame). * </p>
* @param SplashHasBeenClosed boolean. * Closes the splash frame by toggling "has been closed" switch (to cancel
* preloading) and dispose() (to discard JFrame).
*
* @param SplashHasBeenClosed
* boolean.
*/ */
private class closeAction extends AbstractAction { private class closeAction extends AbstractAction {
public void actionPerformed(ActionEvent e) { public void actionPerformed(final ActionEvent e) {
setSplashHasBeenClosed(true); setSplashHasBeenClosed(true);
dispose(); dispose();
} }

View File

@@ -7,7 +7,7 @@ import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor; import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
/** /**
* Swing component view, to be used with BaseProgressMonitor. * Swing component view, to be used with BaseProgressMonitor.
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -39,46 +39,43 @@ public class SplashProgressComponent extends JProgressBar {
// Update bar "stripe" // Update bar "stripe"
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
stripeUpdate(); stripeUpdate();
} }
}); });
// Update bar message // Update bar message
// Note: shouldUpdateUI() severely retards motion // Note: shouldUpdateUI() severely retards motion
// of the preloader, so is temporarily disabled. // of the preloader, so is temporarily disabled.
//if (getCurrentModel().shouldUpdateUI()) { // if (getCurrentModel().shouldUpdateUI()) {
if ((getCurrentModel().getNumPhases() > 1)) { if ((getCurrentModel().getNumPhases() > 1)) {
displayUpdate( displayUpdate("Phase " + getCurrentModel().getCurrentPhase() + ". "
"Phase " + getCurrentModel().getCurrentPhase() + ". " // + getUnitsCompletedSoFarThisPhase() + " units processed. "
//+ getUnitsCompletedSoFarThisPhase() + " units processed. " // + "Overall: " + getTotalPercentCompleteAsString() +
//+ "Overall: " + getTotalPercentCompleteAsString() + "% complete, " // "% complete, "
+ "Overall ETA in " + getCurrentModel().getRelativeETAAsString(true) + "." + "Overall ETA in " + getCurrentModel().getRelativeETAAsString(true) + ".");
); } else {
} displayUpdate(
else { // "Overall: " +
displayUpdate( getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
//"Overall: " + // + "(" + getTotalPercentCompleteAsString() + "%); "
getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; " + "ETA in " + getCurrentModel().getRelativeETAAsString(true) + ".");
//+ "(" + getTotalPercentCompleteAsString() + "%); " }
+ "ETA in " + getCurrentModel().getRelativeETAAsString(true) + "." // getCurrentModel().justUpdatedUI();
); // }
}
// getCurrentModel().justUpdatedUI();
//}
if (getCurrentModel().getCurrentPhase() == getCurrentModel().getNumPhases() if (getCurrentModel().getCurrentPhase() == getCurrentModel().getNumPhases()
&& getCurrentModel().getUnitsCompletedSoFarThisPhase() >= getCurrentModel().getTotalUnitsThisPhase()) && getCurrentModel().getUnitsCompletedSoFarThisPhase() >= getCurrentModel().getTotalUnitsThisPhase())
{ {
displayUpdate("Done! Firing up the GUI..."); displayUpdate("Done! Firing up the GUI...");
} }
} }
/** /**
* Shows the message inside the progress dialog; does not always work on * Shows the message inside the progress dialog; does not always work on all
* all platforms. * platforms.
* *
* @param message the message to display * @param message
* the message to display
*/ */
public final void displayUpdate(final String message) { public final void displayUpdate(final String message) {
final Runnable proc = new Runnable() { final Runnable proc = new Runnable() {
@@ -90,8 +87,7 @@ public class SplashProgressComponent extends JProgressBar {
if (SwingUtilities.isEventDispatchThread()) { if (SwingUtilities.isEventDispatchThread()) {
proc.run(); proc.run();
} } else {
else {
SwingUtilities.invokeLater(proc); SwingUtilities.invokeLater(proc);
} }
} }
@@ -104,7 +100,7 @@ public class SplashProgressComponent extends JProgressBar {
completed = getCurrentModel().getUnitsCompletedSoFarThisPhase(); completed = getCurrentModel().getUnitsCompletedSoFarThisPhase();
total = getCurrentModel().getTotalUnitsThisPhase(); total = getCurrentModel().getTotalUnitsThisPhase();
setValue((int)Math.round((int)completed/total*100)); setValue((int) Math.round((int) completed / total * 100));
} }
/** /**
@@ -119,17 +115,18 @@ public class SplashProgressComponent extends JProgressBar {
* Retrieves the model from which this component uses data. * Retrieves the model from which this component uses data.
* *
* @param neoModel * @param neoModel
* the new current model
*/ */
public void setCurrentModel(BaseProgressMonitor neoModel) { public final void setCurrentModel(final BaseProgressMonitor neoModel) {
currentModel = neoModel; currentModel = neoModel;
} }
/** /**
* Sets model from which this component uses data. * Sets model from which this component uses data.
* *
* @return * @return the current model
*/ */
public BraidsProgressMonitor getCurrentModel() { public final BraidsProgressMonitor getCurrentModel() {
return currentModel; return currentModel;
} }
} }

View File

@@ -13,38 +13,47 @@ public class SplashProgressModel extends BaseProgressMonitor {
private SplashProgressComponent currentView = null; private SplashProgressComponent currentView = null;
/** /**
* Constructor called with no arguments, indicating 1 phase * Constructor called with no arguments, indicating 1 phase and number of
* and number of phase units assumed to be 1 also (can be updated later). * phase units assumed to be 1 also (can be updated later).
* @param numPhases *
*/ */
public SplashProgressModel() { public SplashProgressModel() {
super(); super();
} }
@Override /*
* (non-Javadoc)
*
* @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#
* incrementUnitsCompletedThisPhase(long)
*/
/** /**
* @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#incrementUnitsCompletedThisPhase(long) * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#incrementUnitsCompletedThisPhase(long)
* @param numUnits long
*/ */
public void incrementUnitsCompletedThisPhase(long numUnits) { @Override
public final void incrementUnitsCompletedThisPhase(final long numUnits) {
super.incrementUnitsCompletedThisPhase(numUnits); super.incrementUnitsCompletedThisPhase(numUnits);
getCurrentView().updateProgressBar(); getCurrentView().updateProgressBar();
} }
/** /**
* Gets view from which data is sent for display * Gets view from which data is sent for display.
* *
* @return * @return the current view
*/ */
public SplashProgressComponent getCurrentView() { public final SplashProgressComponent getCurrentView() {
return currentView; return currentView;
} }
/** /**
* Sets view to which data is sent for display * Sets view to which data is sent for display.
* *
* @param neoView * @param neoView
* the new current view
*/ */
public void setCurrentView(SplashProgressComponent neoView) { public final void setCurrentView(final SplashProgressComponent neoView) {
currentView = neoView; currentView = neoView;
} }

View File

@@ -15,6 +15,7 @@ import javax.swing.JScrollPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.border.AbstractBorder; import javax.swing.border.AbstractBorder;
import net.miginfocom.swing.MigLayout;
import forge.AllZone; import forge.AllZone;
import forge.Phase; import forge.Phase;
import forge.Player; import forge.Player;
@@ -24,11 +25,12 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants.LANG.WinLoseFrame.WINLOSETEXT; import forge.properties.NewConstants.LANG.WinLoseFrame.WINLOSETEXT;
import forge.quest.data.QuestMatchState; import forge.quest.data.QuestMatchState;
import net.miginfocom.swing.MigLayout; /**
* <p>
/** <p>WinLoseFrame.</p> * WinLoseFrame.
* VIEW - Core display for win/lose UI shown after completing a game. * </p>
* Uses handlers to customize central panel for various game modes. * VIEW - Core display for win/lose UI shown after completing a game. Uses
* handlers to customize central panel for various game modes.
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -37,17 +39,28 @@ public class WinLoseFrame extends JFrame {
private QuestMatchState matchState; private QuestMatchState matchState;
private WinLoseModeHandler modeHandler; private WinLoseModeHandler modeHandler;
/** The btn continue. */
public FButton btnContinue; public FButton btnContinue;
/** The btn quit. */
public FButton btnQuit; public FButton btnQuit;
/** The btn restart. */
public FButton btnRestart; public FButton btnRestart;
/** The lbl title. */
public JLabel lblTitle; public JLabel lblTitle;
/** The lbl stats. */
public JLabel lblStats; public JLabel lblStats;
/** The pnl custom. */
public JPanel pnlCustom; public JPanel pnlCustom;
/** /**
* <p>WinLoseFrame.</p> * <p>
* WinLoseFrame.
* </p>
* Starts win/lose UI with default display. * Starts win/lose UI with default display.
* *
*/ */
@@ -56,13 +69,16 @@ public class WinLoseFrame extends JFrame {
} }
/** /**
* <p>WinLoseFrame.</p> * <p>
* Starts the standard win/lose UI with custom display * WinLoseFrame.
* for different game modes (quest, puzzle, etc.) * </p>
* Starts the standard win/lose UI with custom display for different game
* modes (quest, puzzle, etc.)
* *
* @param mh {@link forge.view.swing.WinLoseModeHandler} * @param mh
* {@link forge.view.swing.WinLoseModeHandler}
*/ */
public WinLoseFrame(WinLoseModeHandler mh) { public WinLoseFrame(final WinLoseModeHandler mh) {
super(); super();
// modeHandler handles the unique display for different game modes. // modeHandler handles the unique display for different game modes.
@@ -76,8 +92,8 @@ public class WinLoseFrame extends JFrame {
contentPanel.setBorder(new WinLoseBorder()); contentPanel.setBorder(new WinLoseBorder());
getContentPane().add(contentPanel); getContentPane().add(contentPanel);
//Footer should be at least 150 to keep buttons in-pane on Mac OS X // Footer should be at least 150 to keep buttons in-pane on Mac OS X
//it needs to be > 175 now that skinning is used // it needs to be > 175 now that skinning is used
int HEAD_HEIGHT = 150; int HEAD_HEIGHT = 150;
int FOOT_HEIGHT = 182; int FOOT_HEIGHT = 182;
int FRAME_WIDTH_SMALL = 300; int FRAME_WIDTH_SMALL = 300;
@@ -86,17 +102,17 @@ public class WinLoseFrame extends JFrame {
// Head panel // Head panel
JPanel pnlHead = new JPanel(new MigLayout("wrap, fill")); JPanel pnlHead = new JPanel(new MigLayout("wrap, fill"));
pnlHead.setOpaque(false); pnlHead.setOpaque(false);
contentPanel.add(pnlHead,"width " + FRAME_WIDTH_SMALL + "!, align center"); contentPanel.add(pnlHead, "width " + FRAME_WIDTH_SMALL + "!, align center");
lblTitle = new JLabel("WinLoseFrame > lblTitle is broken."); lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
lblTitle.setForeground(Color.white); lblTitle.setForeground(Color.white);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER); lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN,26)); lblTitle.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN, 26));
lblStats = new JLabel("WinLoseFrame > lblStats is broken."); lblStats = new JLabel("WinLoseFrame > lblStats is broken.");
lblStats.setForeground(Color.white); lblStats.setForeground(Color.white);
lblStats.setHorizontalAlignment(SwingConstants.CENTER); lblStats.setHorizontalAlignment(SwingConstants.CENTER);
lblStats.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN,26)); lblStats.setFont(AllZone.getSkin().font1.deriveFont(Font.PLAIN, 26));
pnlHead.add(lblTitle, "growx"); pnlHead.add(lblTitle, "growx");
pnlHead.add(lblStats, "growx"); pnlHead.add(lblStats, "growx");
@@ -105,35 +121,41 @@ public class WinLoseFrame extends JFrame {
JScrollPane scroller = new JScrollPane(); JScrollPane scroller = new JScrollPane();
scroller.getVerticalScrollBar().setUnitIncrement(16); scroller.getVerticalScrollBar().setUnitIncrement(16);
pnlCustom = new JPanel(new MigLayout("wrap, fillx")); pnlCustom = new JPanel(new MigLayout("wrap, fillx"));
pnlCustom.setBackground(new Color(111,87,59)); pnlCustom.setBackground(new Color(111, 87, 59));
pnlCustom.setForeground(Color.white); pnlCustom.setForeground(Color.white);
contentPanel.add(scroller,"w 96%!, align center, gapleft 2%"); contentPanel.add(scroller, "w 96%!, align center, gapleft 2%");
scroller.getViewport().add(pnlCustom); scroller.getViewport().add(pnlCustom);
// Foot panel // Foot panel
JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3")); JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3"));
pnlFoot.setOpaque(false); pnlFoot.setOpaque(false);
contentPanel.add(pnlFoot,"width " + FRAME_WIDTH_SMALL + "!, align center"); contentPanel.add(pnlFoot, "width " + FRAME_WIDTH_SMALL + "!, align center");
this.btnContinue = new FButton("Continue"); this.btnContinue = new FButton("Continue");
this.btnRestart = new FButton("Restart"); this.btnRestart = new FButton("Restart");
this.btnQuit = new FButton("Quit"); this.btnQuit = new FButton("Quit");
pnlFoot.add(btnContinue,"h 36:36, w 200!, gap 0 0 5 5, align center"); pnlFoot.add(btnContinue, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(btnRestart,"h 36:36, w 200!, gap 0 0 5 5, align center"); pnlFoot.add(btnRestart, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(btnQuit,"h 36:36, w 200!, gap 0 0 5 5, align center"); pnlFoot.add(btnQuit, "h 36:36, w 200!, gap 0 0 5 5, align center");
// Button actions // Button actions
btnQuit.addActionListener(new java.awt.event.ActionListener() { btnQuit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final ActionEvent e) { btnQuit_actionPerformed(e); } public void actionPerformed(final ActionEvent e) {
btnQuit_actionPerformed(e);
}
}); });
btnContinue.addActionListener(new java.awt.event.ActionListener() { btnContinue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final ActionEvent e) { btnContinue_actionPerformed(e); } public void actionPerformed(final ActionEvent e) {
btnContinue_actionPerformed(e);
}
}); });
btnRestart.addActionListener(new java.awt.event.ActionListener() { btnRestart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final ActionEvent e) { btnRestart_actionPerformed(e); } public void actionPerformed(final ActionEvent e) {
btnRestart_actionPerformed(e);
}
}); });
// End game and set state of "continue" button // End game and set state of "continue" button
@@ -161,25 +183,25 @@ public class WinLoseFrame extends JFrame {
// Populate custom panel, if necessary. // Populate custom panel, if necessary.
boolean hasContents = modeHandler.populateCustomPanel(); boolean hasContents = modeHandler.populateCustomPanel();
if(!hasContents) { scroller.setVisible(false); } if (!hasContents) {
scroller.setVisible(false);
}
// Size and show frame // Size and show frame
Dimension screen = this.getToolkit().getScreenSize(); Dimension screen = this.getToolkit().getScreenSize();
Rectangle bounds = this.getBounds(); Rectangle bounds = this.getBounds();
if(hasContents) { if (hasContents) {
bounds.height = screen.height - 150; bounds.height = screen.height - 150;
scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG, scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG, screen.height - HEAD_HEIGHT - FOOT_HEIGHT));
screen.height - HEAD_HEIGHT - FOOT_HEIGHT));
bounds.width = FRAME_WIDTH_BIG; bounds.width = FRAME_WIDTH_BIG;
bounds.x = (screen.width - FRAME_WIDTH_BIG)/2; bounds.x = (screen.width - FRAME_WIDTH_BIG) / 2;
bounds.y = (screen.height - bounds.height)/2; bounds.y = (screen.height - bounds.height) / 2;
} } else {
else {
bounds.height = HEAD_HEIGHT + FOOT_HEIGHT; bounds.height = HEAD_HEIGHT + FOOT_HEIGHT;
bounds.width = FRAME_WIDTH_SMALL; bounds.width = FRAME_WIDTH_SMALL;
bounds.x = (screen.width - FRAME_WIDTH_SMALL)/2; bounds.x = (screen.width - FRAME_WIDTH_SMALL) / 2;
bounds.y = (screen.height - bounds.height)/2; bounds.y = (screen.height - bounds.height) / 2;
} }
this.setBackground(AllZone.getSkin().bg1a); this.setBackground(AllZone.getSkin().bg1a);
@@ -190,22 +212,28 @@ public class WinLoseFrame extends JFrame {
} }
/** /**
* <p>continueButton_actionPerformed.</p> * <p>
* continueButton_actionPerformed.
* </p>
* *
* @param e a {@link java.awt.event.ActionEvent} object. * @param e
* a {@link java.awt.event.ActionEvent} object.
*/ */
final void btnContinue_actionPerformed(ActionEvent e) { final void btnContinue_actionPerformed(final ActionEvent e) {
closeWinLoseFrame(); closeWinLoseFrame();
AllZone.getDisplay().setVisible(true); AllZone.getDisplay().setVisible(true);
modeHandler.startNextRound(); modeHandler.startNextRound();
} }
/** /**
* <p>restartButton_actionPerformed.</p> * <p>
* restartButton_actionPerformed.
* </p>
* *
* @param e a {@link java.awt.event.ActionEvent} object. * @param e
* a {@link java.awt.event.ActionEvent} object.
*/ */
final void btnRestart_actionPerformed(ActionEvent e) { final void btnRestart_actionPerformed(final ActionEvent e) {
closeWinLoseFrame(); closeWinLoseFrame();
AllZone.getDisplay().setVisible(true); AllZone.getDisplay().setVisible(true);
matchState.reset(); matchState.reset();
@@ -213,11 +241,14 @@ public class WinLoseFrame extends JFrame {
} }
/** /**
* <p>btnQuit_actionPerformed.</p> * <p>
* btnQuit_actionPerformed.
* </p>
* *
* @param e a {@link java.awt.event.ActionEvent} object. * @param e
* a {@link java.awt.event.ActionEvent} object.
*/ */
final void btnQuit_actionPerformed(ActionEvent e) { final void btnQuit_actionPerformed(final ActionEvent e) {
closeWinLoseFrame(); closeWinLoseFrame();
matchState.reset(); matchState.reset();
modeHandler.actionOnQuit(); modeHandler.actionOnQuit();
@@ -229,7 +260,9 @@ public class WinLoseFrame extends JFrame {
} }
/** /**
* <p>closeWinLoseFrame.</p> * <p>
* closeWinLoseFrame.
* </p>
* Disposes WinLoseFrame UI. * Disposes WinLoseFrame UI.
* *
* @return {@link javax.swing.JFrame} display frame * @return {@link javax.swing.JFrame} display frame
@@ -244,13 +277,12 @@ public class WinLoseFrame extends JFrame {
} }
private class WinLoseBorder extends AbstractBorder { private class WinLoseBorder extends AbstractBorder {
public void paintBorder(Component c, public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
Graphics g, int x, int y, int width, final int height) {
int height) { g.setColor(AllZone.getSkin().txt1a);
g.setColor(AllZone.getSkin().txt1a); g.drawRect(x + 1, y + 1, width - 3, height - 3);
g.drawRect(x+1, y+1, width-3, height-3); g.setColor(AllZone.getSkin().bg1a);
g.setColor(AllZone.getSkin().bg1a); g.drawRect(x + 3, y + 3, width - 7, height - 7);
g.drawRect(x+3, y+3, width-7, height-7); }
}
} }
} }

View File

@@ -4,20 +4,26 @@ import forge.AllZone;
import forge.Constant; import forge.Constant;
/** /**
* <p>WinLoseModeHandler.</p> * <p>
* WinLoseModeHandler.
* </p>
* *
* Superclass of custom mode handling for win/lose UI. Can add swing components * Superclass of custom mode handling for win/lose UI. Can add swing components
* to custom center panel. Custom mode handling for quest, puzzle, etc. * to custom center panel. Custom mode handling for quest, puzzle, etc. should
* should extend this class. * extend this class.
* *
*/ */
public class WinLoseModeHandler { public class WinLoseModeHandler {
/** The view. */
protected WinLoseFrame view; protected WinLoseFrame view;
/** /**
* <p>actionOnQuit.</p> * <p>
* Action performed when "continue" button is pressed in default win/lose UI. * actionOnQuit.
* </p>
* Action performed when "continue" button is pressed in default win/lose
* UI.
* *
*/ */
public void actionOnContinue() { public void actionOnContinue() {
@@ -25,14 +31,16 @@ public class WinLoseModeHandler {
} }
/** /**
* <p>actionOnQuit.</p> * <p>
* actionOnQuit.
* </p>
* Action performed when "quit" button is pressed in default win/lose UI. * Action performed when "quit" button is pressed in default win/lose UI.
* *
*/ */
public void actionOnQuit() { public final void actionOnQuit() {
if (System.getenv("NG2") != null) { if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) { if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {}; String[] argz = {};
Gui_HomeScreen.main(argz); Gui_HomeScreen.main(argz);
} else { } else {
new OldGuiNewGame(); new OldGuiNewGame();
@@ -43,7 +51,9 @@ public class WinLoseModeHandler {
} }
/** /**
* <p>actionOnRestart.</p> * <p>
* actionOnRestart.
* </p>
* Action performed when "restart" button is pressed in default win/lose UI. * Action performed when "restart" button is pressed in default win/lose UI.
* *
*/ */
@@ -52,34 +62,41 @@ public class WinLoseModeHandler {
} }
/** /**
* <p>startNextRound.</p> * <p>
* Either continues or restarts a current game. May be overridden * startNextRound.
* for use with other game modes. * </p>
* Either continues or restarts a current game. May be overridden for use
* with other game modes.
* *
* @param e a {@link java.awt.event.ActionEvent} object.
*/ */
public void startNextRound() { public final void startNextRound() {
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]); AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
} }
/** /**
* <p>populateCustomPanel.</p> * <p>
* May be overridden as required by various mode handlers to show * populateCustomPanel.
* custom information in center panel. Default configuration is empty. * </p>
* May be overridden as required by various mode handlers to show custom
* information in center panel. Default configuration is empty.
* *
* @param boolean indicating if custom panel has contents. * @return true, if successful
*/ */
public boolean populateCustomPanel() { public final boolean populateCustomPanel() {
return false; return false;
} }
/** /**
* <p>setView.</p> * <p>
* Links win/lose swing frame to mode handler, mostly to allow * setView.
* direct manipulation of custom center panel. * </p>
* Links win/lose swing frame to mode handler, mostly to allow direct
* manipulation of custom center panel.
* *
* @param wlh
* the new view
*/ */
public void setView(WinLoseFrame wlh) { public final void setView(final WinLoseFrame wlh) {
view = wlh; view = wlh;
} }
} }