Updated splash frame close functionality to also cancel preloading and gui creation process if user has closed splash frame.

This commit is contained in:
Doublestrike
2011-08-30 15:50:10 +00:00
parent a9da41acb3
commit 3dd01f4b0d
2 changed files with 49 additions and 22 deletions

View File

@@ -117,27 +117,35 @@ public class ApplicationView implements FView {
}
});
AllZone.getCardFactory(); // forces preloading of all cards
try {
Constant.Runtime.GameType[0] = Constant.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.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;
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()) {
System.out.println("splashFrame still running");
try {
Constant.Runtime.GameType[0] = Constant.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.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;
new OldGuiNewGame();
}
});
} catch (Exception ex) {
ErrorViewer.showError(ex);
}
} // End if(splashHasBeenClosed)
}
} // End ApplicationView()
}

View File

@@ -42,6 +42,8 @@ public class SplashFrame extends JFrame {
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
@@ -102,6 +104,7 @@ public class SplashFrame extends JFrame {
@Override
public void actionPerformed(ActionEvent ae)
{
setSplashHasBeenClosed(true);
dispose();
}
});
@@ -155,10 +158,26 @@ public class SplashFrame extends JFrame {
/**
* Getter for progress monitor model.
* @return the BaseProgressMonitor model used in the splash frame.
* @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.
* @return SplashHasBeenClosed boolean.
*/
public final boolean getSplashHasBeenClosed() {
return SplashHasBeenClosed;
}
/**
* Sets state of splash frame, to determine if GUI should continue loading.
* @param SplashHasBeenClosed boolean.
*/
public final void setSplashHasBeenClosed(boolean neoState) {
SplashHasBeenClosed = neoState;
}
}