mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
checkstyle
This commit is contained in:
@@ -5,7 +5,6 @@ import javax.swing.UIManager;
|
||||
|
||||
import net.slightlymagic.braids.util.UtilFunctions;
|
||||
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||
|
||||
import arcane.ui.util.ManaSymbols;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
@@ -26,59 +25,71 @@ import forge.view.swing.OldGuiNewGame.CardStackAction;
|
||||
import forge.view.swing.OldGuiNewGame.CardStackOffsetAction;
|
||||
|
||||
/**
|
||||
* The main view for Forge: a java swing application.
|
||||
* All view class instances should be accessible from here.
|
||||
* The main view for Forge: a java swing application. All view class instances
|
||||
* should be accessible from here.
|
||||
*/
|
||||
public class ApplicationView implements FView {
|
||||
|
||||
private transient SplashFrame splashFrame;
|
||||
|
||||
/**
|
||||
* The splashFrame field is guaranteed to exist when this constructor
|
||||
* exits.
|
||||
* The splashFrame field is guaranteed to exist when this constructor exits.
|
||||
*
|
||||
* @param skin
|
||||
* the skin
|
||||
*/
|
||||
public ApplicationView(final FSkin skin) {
|
||||
|
||||
// We must use invokeAndWait here to fulfill the constructor's
|
||||
// contract.
|
||||
|
||||
UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() { // NOPMD by Braids on 8/18/11 11:37 PM
|
||||
public void run() {
|
||||
splashFrame = new SplashFrame(skin);
|
||||
}
|
||||
});
|
||||
UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() { // NOPMD
|
||||
// by
|
||||
// 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
|
||||
public void run() {
|
||||
splashFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/18/11 11:37 PM
|
||||
public void run() {
|
||||
splashFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.view.FView#getCardLoadingProgressMonitor()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public final BraidsProgressMonitor getCardLoadingProgressMonitor() {
|
||||
BraidsProgressMonitor result;
|
||||
|
||||
if (splashFrame == null) {
|
||||
result = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result = splashFrame.getMonitorModel();
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.view.FView#setModel(forge.model.FModel)
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public final void setModel(final FModel model) {
|
||||
public final void setModel(final FModel model) {
|
||||
try {
|
||||
|
||||
final ForgePreferences preferences = model.getPreferences();
|
||||
@@ -98,69 +109,75 @@ public class ApplicationView implements FView {
|
||||
CardSizesAction.set(preferences.cardSize);
|
||||
OldGuiNewGame.upldDrftCheckBox.setSelected(preferences.uploadDraftAI);
|
||||
OldGuiNewGame.foilRandomCheckBox.setSelected(preferences.randCFoil);
|
||||
|
||||
|
||||
AllZone.setSkin(new FSkin(preferences.skin));
|
||||
|
||||
} catch (Exception 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
|
||||
public void run() {
|
||||
final ForgePreferences finalPreferences = model.getPreferences();
|
||||
|
||||
try {
|
||||
if ("".equals(finalPreferences.laf)) {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} else {
|
||||
UIManager.setLookAndFeel(finalPreferences.laf);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// For the following two blocks, check if user has cancelled SplashFrame.
|
||||
// Note: Error thrown sometimes because log file cannot be accessed
|
||||
if(!splashFrame.getSplashHasBeenClosed()) {
|
||||
AllZone.getCardFactory(); // forces preloading of all cards
|
||||
}
|
||||
|
||||
if(!splashFrame.getSplashHasBeenClosed()) {
|
||||
try {
|
||||
ManaSymbols.loadImages();
|
||||
|
||||
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 on 8/7/11
|
||||
// 1:07 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
|
||||
// is useful for debugging.
|
||||
|
||||
splashFrame.dispose();
|
||||
//splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
|
||||
splashFrame = null;
|
||||
|
||||
if (System.getenv("NG2") != null) {
|
||||
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
||||
String argz[] = {};
|
||||
Gui_HomeScreen.main(argz);
|
||||
final ForgePreferences finalPreferences = model.getPreferences();
|
||||
|
||||
try {
|
||||
if ("".equals(finalPreferences.laf)) {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
UIManager.setLookAndFeel(finalPreferences.laf);
|
||||
}
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// For the following two blocks, check if user has cancelled
|
||||
// SplashFrame.
|
||||
// Note: Error thrown sometimes because log file cannot be accessed
|
||||
if (!splashFrame.getSplashHasBeenClosed()) {
|
||||
AllZone.getCardFactory(); // forces preloading of all cards
|
||||
}
|
||||
|
||||
if (!splashFrame.getSplashHasBeenClosed()) {
|
||||
try {
|
||||
ManaSymbols.loadImages();
|
||||
|
||||
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
|
||||
public void run() {
|
||||
AllZone.getInputControl().setComputer(new ComputerAI_Input(new ComputerAI_General()));
|
||||
|
||||
// Enable only one of the following two lines.
|
||||
// The second
|
||||
// is useful for debugging.
|
||||
|
||||
splashFrame.dispose();
|
||||
// splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
splashFrame = null;
|
||||
|
||||
if (System.getenv("NG2") != null) {
|
||||
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
||||
String[] argz = {};
|
||||
Gui_HomeScreen.main(argz);
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
}
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
}
|
||||
} // End if(splashHasBeenClosed)
|
||||
} // End if(splashHasBeenClosed)
|
||||
|
||||
} // End ApplicationView()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@ public final class Main {
|
||||
|
||||
/**
|
||||
* main method for Forge's swing application view.
|
||||
*
|
||||
*
|
||||
* @param args
|
||||
* an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
@@ -30,24 +30,25 @@ public final class Main {
|
||||
try {
|
||||
final FModel model = new FModel(null);
|
||||
Singletons.setModel(model);
|
||||
|
||||
|
||||
FSkin skin = new FSkin(model.preferences.skin);
|
||||
final FView view = new ApplicationView(skin);
|
||||
Singletons.setView(view);
|
||||
|
||||
|
||||
// Need this soon after card factory is loaded
|
||||
OldGuiNewGame.loadDynamicGamedata();
|
||||
|
||||
// TODO: this code should go elsewhere, like wherever we start a new game.
|
||||
// It is only here to maintain semantic equality with the current code base.
|
||||
|
||||
OldGuiNewGame.loadDynamicGamedata();
|
||||
|
||||
// TODO this code should go elsewhere, like wherever we start a new
|
||||
// game.
|
||||
// It is only here to maintain semantic equality with the current
|
||||
// code base.
|
||||
|
||||
model.resetGameState();
|
||||
|
||||
view.setModel(model);
|
||||
|
||||
}
|
||||
catch (Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: must catch all throwables here.
|
||||
} catch (Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: must
|
||||
// catch all throwables here.
|
||||
ErrorViewer.showError(exn);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,15 +10,15 @@ import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import forge.gui.skin.FSkin;
|
||||
|
||||
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||
import forge.gui.skin.FSkin;
|
||||
|
||||
/**
|
||||
* Shows the splash frame as the application starts.
|
||||
@@ -26,37 +26,42 @@ import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||
@SuppressWarnings("serial")
|
||||
public class SplashFrame extends JFrame {
|
||||
|
||||
// Inits: Visual changes can be made here.
|
||||
private static final int BAR_PADDING_X = 20;
|
||||
private static final int BAR_PADDING_Y = 20;
|
||||
private static final int BAR_HEIGHT = 57;
|
||||
|
||||
private static final int DISCLAIMER_HEIGHT = 20;
|
||||
private static final int DISCLAIMER_TOP = 300;
|
||||
private static final int DISCLAIMER_FONT_SIZE = 9;
|
||||
private static final Color DISCLAIMER_COLOR = Color.white;
|
||||
|
||||
//private static final int CLOSEBTN_PADDING_X = 15;
|
||||
private static final int CLOSEBTN_PADDING_Y = 15;
|
||||
private static final int CLOSEBTN_SIDELENGTH = 15;
|
||||
private static final Color CLOSEBTN_COLOR = new Color(215,208,188);
|
||||
|
||||
// Inits: Visual changes can be made here.
|
||||
private static final int BAR_PADDING_X = 20;
|
||||
private static final int BAR_PADDING_Y = 20;
|
||||
private static final int BAR_HEIGHT = 57;
|
||||
|
||||
private static final int DISCLAIMER_HEIGHT = 20;
|
||||
private static final int DISCLAIMER_TOP = 300;
|
||||
private static final int DISCLAIMER_FONT_SIZE = 9;
|
||||
private static final Color DISCLAIMER_COLOR = Color.white;
|
||||
|
||||
// private static final int CLOSEBTN_PADDING_X = 15;
|
||||
private static final int CLOSEBTN_PADDING_Y = 15;
|
||||
private static final int CLOSEBTN_SIDELENGTH = 15;
|
||||
private static final Color CLOSEBTN_COLOR = new Color(215, 208, 188);
|
||||
|
||||
private SplashProgressModel monitorModel = null;
|
||||
private SplashProgressComponent monitorView = null;
|
||||
|
||||
|
||||
private boolean SplashHasBeenClosed = false;
|
||||
|
||||
/**
|
||||
* <p>Create the frame; this <strong>must</strong> be called from an event
|
||||
* dispatch thread.</p>
|
||||
*
|
||||
* <!-- CheckStyle won't let me use at-throws. -->
|
||||
* Throws {@link IllegalStateException} if not called from an event
|
||||
* <p>
|
||||
* Create the frame; this <strong>must</strong> be called from an event
|
||||
* 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();
|
||||
|
||||
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
throw new IllegalStateException("SplashFrame() must be called from an event dispatch thread.");
|
||||
}
|
||||
@@ -76,121 +81,132 @@ public class SplashFrame extends JFrame {
|
||||
// Insert JPanel to hold content above background
|
||||
final JPanel contentPane = new JPanel();
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
// 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,
|
||||
splashWidthPx, DISCLAIMER_HEIGHT);
|
||||
lblDisclaimer.setBounds(0, DISCLAIMER_TOP, splashWidthPx, DISCLAIMER_HEIGHT);
|
||||
|
||||
lblDisclaimer.setFont(new Font("Tahoma", Font.PLAIN, DISCLAIMER_FONT_SIZE));
|
||||
lblDisclaimer.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblDisclaimer.setForeground(DISCLAIMER_COLOR);
|
||||
contentPane.add(lblDisclaimer);
|
||||
|
||||
|
||||
// Add close button
|
||||
final JButton btnClose = new JButton("X");
|
||||
btnClose.setBounds(splashWidthPx- (2 * CLOSEBTN_PADDING_Y),
|
||||
CLOSEBTN_PADDING_Y,CLOSEBTN_SIDELENGTH,CLOSEBTN_SIDELENGTH);
|
||||
btnClose.setBounds(splashWidthPx - (2 * CLOSEBTN_PADDING_Y), CLOSEBTN_PADDING_Y, CLOSEBTN_SIDELENGTH,
|
||||
CLOSEBTN_SIDELENGTH);
|
||||
btnClose.setForeground(CLOSEBTN_COLOR);
|
||||
btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR));
|
||||
btnClose.setOpaque(false);
|
||||
btnClose.setBackground(new Color(0,0,0));
|
||||
btnClose.setBackground(new Color(0, 0, 0));
|
||||
btnClose.setFocusPainted(false);
|
||||
contentPane.add(btnClose);
|
||||
|
||||
|
||||
// Action handler: button hover effect
|
||||
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.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.setForeground(CLOSEBTN_COLOR);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Action handler: button close
|
||||
btnClose.addActionListener(new closeAction());
|
||||
|
||||
|
||||
// Action handler: esc key close
|
||||
contentPane.getInputMap().put(
|
||||
KeyStroke.getKeyStroke( "ESCAPE" ), "escAction" );
|
||||
contentPane.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "escAction");
|
||||
|
||||
contentPane.getActionMap().put("escAction", new closeAction());
|
||||
|
||||
|
||||
// Set UI to color splash bar fill with theme colors
|
||||
UIManager.put("ProgressBar.foreground", skin.bg1b); // Filled
|
||||
UIManager.put("ProgressBar.selectionForeground",skin.txt1a);// Filled
|
||||
|
||||
UIManager.put("ProgressBar.foreground", skin.bg1b); // Filled
|
||||
UIManager.put("ProgressBar.selectionForeground", skin.txt1a); // Filled
|
||||
|
||||
// Instantiate model and view and tie together.
|
||||
monitorModel = new SplashProgressModel();
|
||||
monitorView = new SplashProgressComponent();
|
||||
|
||||
|
||||
monitorModel.setCurrentView(monitorView);
|
||||
monitorView.setCurrentModel(monitorModel);
|
||||
|
||||
|
||||
// Add prog bar + message, bg image
|
||||
monitorView.displayUpdate("Assembling file list...");
|
||||
monitorView.setBounds(BAR_PADDING_X, splashHeightPx - BAR_PADDING_Y - BAR_HEIGHT,
|
||||
splashWidthPx - (2 * BAR_PADDING_X), BAR_HEIGHT);
|
||||
monitorView.setBounds(BAR_PADDING_X, splashHeightPx - BAR_PADDING_Y - BAR_HEIGHT, splashWidthPx
|
||||
- (2 * BAR_PADDING_X), BAR_HEIGHT);
|
||||
contentPane.add(monitorView);
|
||||
|
||||
|
||||
contentPane.setOpaque(false);
|
||||
final JLabel bgLabel = new JLabel(bgIcon);
|
||||
|
||||
// Do not pass Integer.MIN_VALUE directly here; it must be packaged in an Integer
|
||||
// instance. Otherwise, GUI components will not draw unless moused over.
|
||||
|
||||
// Do not pass Integer.MIN_VALUE directly here; it must be packaged in
|
||||
// an Integer
|
||||
// instance. Otherwise, GUI components will not draw unless moused over.
|
||||
getLayeredPane().add(bgLabel, Integer.valueOf(Integer.MIN_VALUE));
|
||||
|
||||
bgLabel.setBounds(0, 0, splashWidthPx, splashHeightPx);
|
||||
|
||||
pack();
|
||||
pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
return monitorView;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for progress monitor model.
|
||||
*
|
||||
* @return the BraidsProgressMonitor model used in the splash frame.
|
||||
*/
|
||||
public final BraidsProgressMonitor getMonitorModel() {
|
||||
return monitorModel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public final boolean getSplashHasBeenClosed() {
|
||||
return SplashHasBeenClosed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>closeAction</p>
|
||||
* Closes the splash frame by toggling "has been closed" switch
|
||||
* (to cancel preloading) and dispose() (to discard JFrame).
|
||||
* @param SplashHasBeenClosed boolean.
|
||||
*/
|
||||
* <p>
|
||||
* closeAction
|
||||
* </p>
|
||||
* 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 {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
setSplashHasBeenClosed(true);
|
||||
dispose();
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import javax.swing.SwingUtilities;
|
||||
import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor;
|
||||
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")
|
||||
public class SplashProgressComponent extends JProgressBar {
|
||||
@@ -22,66 +22,63 @@ public class SplashProgressComponent extends JProgressBar {
|
||||
*/
|
||||
public SplashProgressComponent() {
|
||||
super();
|
||||
|
||||
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
throw new IllegalStateException("must be called from within an event dispatch thread");
|
||||
}
|
||||
|
||||
|
||||
setString("");
|
||||
setStringPainted(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates progress bar stripe and text with current state of model.
|
||||
*
|
||||
*/
|
||||
public final void updateProgressBar() {
|
||||
// Update bar "stripe"
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
stripeUpdate();
|
||||
stripeUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
// Update bar message
|
||||
// Note: shouldUpdateUI() severely retards motion
|
||||
// of the preloader, so is temporarily disabled.
|
||||
//if (getCurrentModel().shouldUpdateUI()) {
|
||||
if ((getCurrentModel().getNumPhases() > 1)) {
|
||||
displayUpdate(
|
||||
"Phase " + getCurrentModel().getCurrentPhase() + ". "
|
||||
//+ getUnitsCompletedSoFarThisPhase() + " units processed. "
|
||||
//+ "Overall: " + getTotalPercentCompleteAsString() + "% complete, "
|
||||
+ "Overall ETA in " + getCurrentModel().getRelativeETAAsString(true) + "."
|
||||
);
|
||||
}
|
||||
else {
|
||||
displayUpdate(
|
||||
//"Overall: " +
|
||||
getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
|
||||
//+ "(" + getTotalPercentCompleteAsString() + "%); "
|
||||
+ "ETA in " + getCurrentModel().getRelativeETAAsString(true) + "."
|
||||
);
|
||||
}
|
||||
// getCurrentModel().justUpdatedUI();
|
||||
//}
|
||||
|
||||
|
||||
// Update bar message
|
||||
// Note: shouldUpdateUI() severely retards motion
|
||||
// of the preloader, so is temporarily disabled.
|
||||
// if (getCurrentModel().shouldUpdateUI()) {
|
||||
if ((getCurrentModel().getNumPhases() > 1)) {
|
||||
displayUpdate("Phase " + getCurrentModel().getCurrentPhase() + ". "
|
||||
// + getUnitsCompletedSoFarThisPhase() + " units processed. "
|
||||
// + "Overall: " + getTotalPercentCompleteAsString() +
|
||||
// "% complete, "
|
||||
+ "Overall ETA in " + getCurrentModel().getRelativeETAAsString(true) + ".");
|
||||
} else {
|
||||
displayUpdate(
|
||||
// "Overall: " +
|
||||
getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
|
||||
// + "(" + getTotalPercentCompleteAsString() + "%); "
|
||||
+ "ETA in " + getCurrentModel().getRelativeETAAsString(true) + ".");
|
||||
}
|
||||
// getCurrentModel().justUpdatedUI();
|
||||
// }
|
||||
|
||||
if (getCurrentModel().getCurrentPhase() == getCurrentModel().getNumPhases()
|
||||
&& getCurrentModel().getUnitsCompletedSoFarThisPhase() >= getCurrentModel().getTotalUnitsThisPhase())
|
||||
&& getCurrentModel().getUnitsCompletedSoFarThisPhase() >= getCurrentModel().getTotalUnitsThisPhase())
|
||||
{
|
||||
displayUpdate("Done! Firing up the GUI...");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the message inside the progress dialog; does not always work on
|
||||
* all platforms.
|
||||
*
|
||||
* @param message the message to display
|
||||
* Shows the message inside the progress dialog; does not always work on all
|
||||
* platforms.
|
||||
*
|
||||
* @param message
|
||||
* the message to display
|
||||
*/
|
||||
public final void displayUpdate(final String message) {
|
||||
final Runnable proc = new Runnable() {
|
||||
final Runnable proc = new Runnable() {
|
||||
public void run() {
|
||||
setString(message);
|
||||
getCurrentModel().justUpdatedUI();
|
||||
@@ -90,46 +87,46 @@ public class SplashProgressComponent extends JProgressBar {
|
||||
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
proc.run();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SwingUtilities.invokeLater(proc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Moves the stripe inside the progress dialog.
|
||||
*
|
||||
*/
|
||||
*
|
||||
*/
|
||||
public final void stripeUpdate() {
|
||||
completed = getCurrentModel().getUnitsCompletedSoFarThisPhase();
|
||||
total = getCurrentModel().getTotalUnitsThisPhase();
|
||||
|
||||
setValue((int)Math.round((int)completed/total*100));
|
||||
|
||||
setValue((int) Math.round((int) completed / total * 100));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the stripe inside the progress dialog back to zero.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final void stripeReset() {
|
||||
setValue(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the model from which this component uses data.
|
||||
*
|
||||
* @param neoModel
|
||||
* the new current model
|
||||
*/
|
||||
public void setCurrentModel(BaseProgressMonitor neoModel) {
|
||||
public final void setCurrentModel(final BaseProgressMonitor neoModel) {
|
||||
currentModel = neoModel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets model from which this component uses data.
|
||||
*
|
||||
* @return
|
||||
* @return the current model
|
||||
*/
|
||||
public BraidsProgressMonitor getCurrentModel() {
|
||||
public final BraidsProgressMonitor getCurrentModel() {
|
||||
return currentModel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,50 +2,59 @@ package forge.view.swing;
|
||||
|
||||
import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates an instance of BaseProgressMonitor that is used in the splash frame.
|
||||
*
|
||||
* Not all mutators notify the view yet.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SplashProgressModel extends BaseProgressMonitor {
|
||||
|
||||
private SplashProgressComponent currentView = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor called with no arguments, indicating 1 phase
|
||||
* and number of phase units assumed to be 1 also (can be updated later).
|
||||
* @param numPhases
|
||||
* Constructor called with no arguments, indicating 1 phase and number of
|
||||
* phase units assumed to be 1 also (can be updated later).
|
||||
*
|
||||
*/
|
||||
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)
|
||||
* @param numUnits long
|
||||
*/
|
||||
public void incrementUnitsCompletedThisPhase(long numUnits) {
|
||||
@Override
|
||||
public final void incrementUnitsCompletedThisPhase(final long numUnits) {
|
||||
super.incrementUnitsCompletedThisPhase(numUnits);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets view to which data is sent for display
|
||||
* Sets view to which data is sent for display.
|
||||
*
|
||||
* @param neoView
|
||||
* the new current view
|
||||
*/
|
||||
public void setCurrentView(SplashProgressComponent neoView) {
|
||||
public final void setCurrentView(final SplashProgressComponent neoView) {
|
||||
currentView = neoView;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.AbstractBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.AllZone;
|
||||
import forge.Phase;
|
||||
import forge.Player;
|
||||
@@ -24,47 +25,62 @@ import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants.LANG.WinLoseFrame.WINLOSETEXT;
|
||||
import forge.quest.data.QuestMatchState;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
/** <p>WinLoseFrame.</p>
|
||||
* VIEW - Core display for win/lose UI shown after completing a game.
|
||||
* Uses handlers to customize central panel for various game modes.
|
||||
*
|
||||
/**
|
||||
* <p>
|
||||
* WinLoseFrame.
|
||||
* </p>
|
||||
* VIEW - Core display for win/lose UI shown after completing a game. Uses
|
||||
* handlers to customize central panel for various game modes.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class WinLoseFrame extends JFrame {
|
||||
|
||||
private QuestMatchState matchState;
|
||||
private WinLoseModeHandler modeHandler;
|
||||
|
||||
|
||||
/** The btn continue. */
|
||||
public FButton btnContinue;
|
||||
|
||||
/** The btn quit. */
|
||||
public FButton btnQuit;
|
||||
|
||||
/** The btn restart. */
|
||||
public FButton btnRestart;
|
||||
|
||||
|
||||
/** The lbl title. */
|
||||
public JLabel lblTitle;
|
||||
|
||||
/** The lbl stats. */
|
||||
public JLabel lblStats;
|
||||
|
||||
|
||||
/** The pnl custom. */
|
||||
public JPanel pnlCustom;
|
||||
|
||||
|
||||
/**
|
||||
* <p>WinLoseFrame.</p>
|
||||
* <p>
|
||||
* WinLoseFrame.
|
||||
* </p>
|
||||
* Starts win/lose UI with default display.
|
||||
*
|
||||
*/
|
||||
public WinLoseFrame() {
|
||||
this(new WinLoseModeHandler());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>WinLoseFrame.</p>
|
||||
* Starts the standard win/lose UI with custom display
|
||||
* for different game modes (quest, puzzle, etc.)
|
||||
* <p>
|
||||
* WinLoseFrame.
|
||||
* </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();
|
||||
|
||||
|
||||
// modeHandler handles the unique display for different game modes.
|
||||
modeHandler = mh;
|
||||
modeHandler.setView(this);
|
||||
@@ -74,81 +90,87 @@ public class WinLoseFrame extends JFrame {
|
||||
FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10"));
|
||||
contentPanel.setBGImg(AllZone.getSkin().texture1);
|
||||
contentPanel.setBorder(new WinLoseBorder());
|
||||
getContentPane().add(contentPanel);
|
||||
|
||||
//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
|
||||
getContentPane().add(contentPanel);
|
||||
|
||||
// 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
|
||||
int HEAD_HEIGHT = 150;
|
||||
int FOOT_HEIGHT = 182;
|
||||
int FRAME_WIDTH_SMALL = 300;
|
||||
int FRAME_WIDTH_BIG = 600;
|
||||
|
||||
|
||||
// Head panel
|
||||
JPanel pnlHead = new JPanel(new MigLayout("wrap, fill"));
|
||||
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.setForeground(Color.white);
|
||||
lblTitle.setForeground(Color.white);
|
||||
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.setForeground(Color.white);
|
||||
lblStats.setForeground(Color.white);
|
||||
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(lblStats, "growx");
|
||||
|
||||
|
||||
// Custom display panel in center; populated later by mode handler.
|
||||
JScrollPane scroller = new JScrollPane();
|
||||
scroller.getVerticalScrollBar().setUnitIncrement(16);
|
||||
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);
|
||||
contentPanel.add(scroller,"w 96%!, align center, gapleft 2%");
|
||||
contentPanel.add(scroller, "w 96%!, align center, gapleft 2%");
|
||||
scroller.getViewport().add(pnlCustom);
|
||||
|
||||
// Foot panel
|
||||
|
||||
// Foot panel
|
||||
JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3"));
|
||||
pnlFoot.setOpaque(false);
|
||||
contentPanel.add(pnlFoot,"width " + FRAME_WIDTH_SMALL + "!, align center");
|
||||
|
||||
this.btnContinue = new FButton("Continue");
|
||||
this.btnRestart = new FButton("Restart");
|
||||
this.btnQuit = new FButton("Quit");
|
||||
|
||||
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(btnQuit,"h 36:36, w 200!, gap 0 0 5 5, align center");
|
||||
|
||||
contentPanel.add(pnlFoot, "width " + FRAME_WIDTH_SMALL + "!, align center");
|
||||
|
||||
this.btnContinue = new FButton("Continue");
|
||||
this.btnRestart = new FButton("Restart");
|
||||
this.btnQuit = new FButton("Quit");
|
||||
|
||||
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(btnQuit, "h 36:36, w 200!, gap 0 0 5 5, align center");
|
||||
|
||||
// Button actions
|
||||
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() {
|
||||
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() {
|
||||
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
|
||||
Phase.setGameBegins(0);
|
||||
|
||||
|
||||
if (matchState.isMatchOver()) {
|
||||
btnContinue.setEnabled(false);
|
||||
btnQuit.grabFocus();
|
||||
}
|
||||
|
||||
// Show Wins and Loses
|
||||
Player human = AllZone.getHumanPlayer();
|
||||
Player human = AllZone.getHumanPlayer();
|
||||
int humanWins = matchState.countGamesWonBy(human.getName());
|
||||
int humanLosses = matchState.getGamesPlayedCount() - humanWins;
|
||||
|
||||
int humanLosses = matchState.getGamesPlayedCount() - humanWins;
|
||||
|
||||
lblStats.setText(ForgeProps.getLocalized(WINLOSETEXT.WON) + humanWins
|
||||
+ ForgeProps.getLocalized(WINLOSETEXT.LOST) + humanLosses);
|
||||
|
||||
@@ -158,78 +180,89 @@ public class WinLoseFrame extends JFrame {
|
||||
} else {
|
||||
lblTitle.setText(ForgeProps.getLocalized(WINLOSETEXT.LOSE));
|
||||
}
|
||||
|
||||
|
||||
// Populate custom panel, if necessary.
|
||||
boolean hasContents = modeHandler.populateCustomPanel();
|
||||
if(!hasContents) { scroller.setVisible(false); }
|
||||
|
||||
if (!hasContents) {
|
||||
scroller.setVisible(false);
|
||||
}
|
||||
|
||||
// Size and show frame
|
||||
Dimension screen = this.getToolkit().getScreenSize();
|
||||
Rectangle bounds = this.getBounds();
|
||||
|
||||
if(hasContents) {
|
||||
|
||||
if (hasContents) {
|
||||
bounds.height = screen.height - 150;
|
||||
scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG,
|
||||
screen.height - HEAD_HEIGHT - FOOT_HEIGHT));
|
||||
scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG, screen.height - HEAD_HEIGHT - FOOT_HEIGHT));
|
||||
bounds.width = FRAME_WIDTH_BIG;
|
||||
bounds.x = (screen.width - FRAME_WIDTH_BIG)/2;
|
||||
bounds.y = (screen.height - bounds.height)/2;
|
||||
}
|
||||
else {
|
||||
bounds.x = (screen.width - FRAME_WIDTH_BIG) / 2;
|
||||
bounds.y = (screen.height - bounds.height) / 2;
|
||||
} else {
|
||||
bounds.height = HEAD_HEIGHT + FOOT_HEIGHT;
|
||||
bounds.width = FRAME_WIDTH_SMALL;
|
||||
bounds.x = (screen.width - FRAME_WIDTH_SMALL)/2;
|
||||
bounds.y = (screen.height - bounds.height)/2;
|
||||
bounds.x = (screen.width - FRAME_WIDTH_SMALL) / 2;
|
||||
bounds.y = (screen.height - bounds.height) / 2;
|
||||
}
|
||||
|
||||
|
||||
this.setBackground(AllZone.getSkin().bg1a);
|
||||
this.setBounds(bounds);
|
||||
this.setBounds(bounds);
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
this.setUndecorated(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>continueButton_actionPerformed.</p>
|
||||
*
|
||||
* @param e a {@link java.awt.event.ActionEvent} object.
|
||||
* <p>
|
||||
* continueButton_actionPerformed.
|
||||
* </p>
|
||||
*
|
||||
* @param e
|
||||
* a {@link java.awt.event.ActionEvent} object.
|
||||
*/
|
||||
final void btnContinue_actionPerformed(ActionEvent e) {
|
||||
final void btnContinue_actionPerformed(final ActionEvent e) {
|
||||
closeWinLoseFrame();
|
||||
AllZone.getDisplay().setVisible(true);
|
||||
modeHandler.startNextRound();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>restartButton_actionPerformed.</p>
|
||||
*
|
||||
* @param e a {@link java.awt.event.ActionEvent} object.
|
||||
* <p>
|
||||
* restartButton_actionPerformed.
|
||||
* </p>
|
||||
*
|
||||
* @param e
|
||||
* a {@link java.awt.event.ActionEvent} object.
|
||||
*/
|
||||
final void btnRestart_actionPerformed(ActionEvent e) {
|
||||
closeWinLoseFrame();
|
||||
final void btnRestart_actionPerformed(final ActionEvent e) {
|
||||
closeWinLoseFrame();
|
||||
AllZone.getDisplay().setVisible(true);
|
||||
matchState.reset();
|
||||
modeHandler.startNextRound();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>btnQuit_actionPerformed.</p>
|
||||
*
|
||||
* @param e a {@link java.awt.event.ActionEvent} object.
|
||||
* <p>
|
||||
* btnQuit_actionPerformed.
|
||||
* </p>
|
||||
*
|
||||
* @param e
|
||||
* a {@link java.awt.event.ActionEvent} object.
|
||||
*/
|
||||
final void btnQuit_actionPerformed(ActionEvent e) {
|
||||
closeWinLoseFrame();
|
||||
final void btnQuit_actionPerformed(final ActionEvent e) {
|
||||
closeWinLoseFrame();
|
||||
matchState.reset();
|
||||
modeHandler.actionOnQuit();
|
||||
modeHandler.actionOnQuit();
|
||||
|
||||
// clear Image caches, so the program doesn't get slower and slower
|
||||
// not needed with soft values - will shrink as needed
|
||||
// ImageUtil.rotatedCache.clear();
|
||||
// ImageCache.cache.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>closeWinLoseFrame.</p>
|
||||
* <p>
|
||||
* closeWinLoseFrame.
|
||||
* </p>
|
||||
* Disposes WinLoseFrame UI.
|
||||
*
|
||||
* @return {@link javax.swing.JFrame} display frame
|
||||
@@ -242,15 +275,14 @@ public class WinLoseFrame extends JFrame {
|
||||
this.dispose();
|
||||
return frame;
|
||||
}
|
||||
|
||||
private class WinLoseBorder extends AbstractBorder {
|
||||
public void paintBorder(Component c,
|
||||
Graphics g, int x, int y, int width,
|
||||
int height) {
|
||||
g.setColor(AllZone.getSkin().txt1a);
|
||||
g.drawRect(x+1, y+1, width-3, height-3);
|
||||
g.setColor(AllZone.getSkin().bg1a);
|
||||
g.drawRect(x+3, y+3, width-7, height-7);
|
||||
}
|
||||
|
||||
private class WinLoseBorder extends AbstractBorder {
|
||||
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
|
||||
final int height) {
|
||||
g.setColor(AllZone.getSkin().txt1a);
|
||||
g.drawRect(x + 1, y + 1, width - 3, height - 3);
|
||||
g.setColor(AllZone.getSkin().bg1a);
|
||||
g.drawRect(x + 3, y + 3, width - 7, height - 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,36 +3,44 @@ package forge.view.swing;
|
||||
import forge.AllZone;
|
||||
import forge.Constant;
|
||||
|
||||
/**
|
||||
* <p>WinLoseModeHandler.</p>
|
||||
/**
|
||||
* <p>
|
||||
* WinLoseModeHandler.
|
||||
* </p>
|
||||
*
|
||||
* Superclass of custom mode handling for win/lose UI. Can add swing components
|
||||
* to custom center panel. Custom mode handling for quest, puzzle, etc. should
|
||||
* extend this class.
|
||||
*
|
||||
* Superclass of custom mode handling for win/lose UI. Can add swing components
|
||||
* to custom center panel. Custom mode handling for quest, puzzle, etc.
|
||||
* should extend this class.
|
||||
*
|
||||
*/
|
||||
public class WinLoseModeHandler {
|
||||
|
||||
|
||||
/** The view. */
|
||||
protected WinLoseFrame view;
|
||||
|
||||
|
||||
/**
|
||||
* <p>actionOnQuit.</p>
|
||||
* Action performed when "continue" button is pressed in default win/lose UI.
|
||||
* <p>
|
||||
* actionOnQuit.
|
||||
* </p>
|
||||
* Action performed when "continue" button is pressed in default win/lose
|
||||
* UI.
|
||||
*
|
||||
*/
|
||||
public void actionOnContinue() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>actionOnQuit.</p>
|
||||
* <p>
|
||||
* actionOnQuit.
|
||||
* </p>
|
||||
* 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").equalsIgnoreCase("true")) {
|
||||
String argz[] = {};
|
||||
String[] argz = {};
|
||||
Gui_HomeScreen.main(argz);
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
@@ -41,45 +49,54 @@ public class WinLoseModeHandler {
|
||||
new OldGuiNewGame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>actionOnRestart.</p>
|
||||
* <p>
|
||||
* actionOnRestart.
|
||||
* </p>
|
||||
* Action performed when "restart" button is pressed in default win/lose UI.
|
||||
*
|
||||
*/
|
||||
public void actionOnRestart() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>startNextRound.</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.
|
||||
* <p>
|
||||
* startNextRound.
|
||||
* </p>
|
||||
* Either continues or restarts a current game. May be overridden for use
|
||||
* with other game modes.
|
||||
*
|
||||
*/
|
||||
public void startNextRound() {
|
||||
public final void startNextRound() {
|
||||
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>populateCustomPanel.</p>
|
||||
* May be overridden as required by various mode handlers to show
|
||||
* custom information in center panel. Default configuration is empty.
|
||||
* <p>
|
||||
* populateCustomPanel.
|
||||
* </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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>setView.</p>
|
||||
* Links win/lose swing frame to mode handler, mostly to allow
|
||||
* direct manipulation of custom center panel.
|
||||
* <p>
|
||||
* setView.
|
||||
* </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) {
|
||||
view = wlh;
|
||||
public final void setView(final WinLoseFrame wlh) {
|
||||
view = wlh;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user