Splash screen now loaded from skin (theme).

This commit is contained in:
Doublestrike
2011-10-08 09:44:37 +00:00
parent 1650a7f304
commit 84017a7a47
5 changed files with 19 additions and 13 deletions

View File

@@ -35,7 +35,8 @@ public class FSkin {
public ImageIcon btnRover = null;
public ImageIcon btnLdown = null;
public ImageIcon btnMdown = null;
public ImageIcon btnRdown = null;
public ImageIcon btnRdown = null;
public ImageIcon splash = null;
public Color bg1a = Color.red;
public Color bg1b = Color.red;
@@ -68,6 +69,7 @@ public class FSkin {
private final String btnLdownfile = "btnLdown.png";
private final String btnMdownfile = "btnMdown.png";
private final String btnRdownfile = "btnRdown.png";
private final String splashfile = "bg_splash.jpg";
private ImageIcon tempImg;
private Font tempFont;
@@ -165,6 +167,7 @@ public class FSkin {
btnLdown = retrieveImage(dirName + btnLdownfile);
btnMdown = retrieveImage(dirName + btnMdownfile);
btnRdown = retrieveImage(dirName + btnRdownfile);
splash = retrieveImage(dirName + splashfile);
// Color palette
File file= new File(dirName + paletteFile);

View File

@@ -31,7 +31,7 @@ public class FModel {
private final transient PrintStream oldSystemOut;
private final transient PrintStream oldSystemErr;
private BuildInfo buildInfo;
private ForgePreferences preferences;
public ForgePreferences preferences;
private FGameState gameState;
/**

View File

@@ -37,14 +37,14 @@ public class ApplicationView implements FView {
* The splashFrame field is guaranteed to exist when this constructor
* exits.
*/
public ApplicationView() {
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();
splashFrame = new SplashFrame(skin);
}
});

View File

@@ -3,6 +3,7 @@ package forge.view.swing;
import forge.Singletons;
import forge.error.ErrorViewer;
import forge.error.ExceptionHandler;
import forge.gui.skin.FSkin;
import forge.model.FModel;
import forge.view.FView;
@@ -27,10 +28,13 @@ public final class Main {
public static void main(final String[] args) {
ExceptionHandler.registerErrorHandling();
try {
final FView view = new ApplicationView();
Singletons.setView(view);
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();

View File

@@ -15,6 +15,7 @@ import javax.swing.JLabel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import forge.gui.skin.FSkin;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
@@ -24,9 +25,7 @@ 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 String BG_ADDRESS = "res/images/ui/forgeSplash.jpg";
// 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;
@@ -54,17 +53,17 @@ public class SplashFrame extends JFrame {
* Throws {@link IllegalStateException} if not called from an event
* dispatch thread.
*/
public SplashFrame() {
public SplashFrame(FSkin skin) {
super();
if (!SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("SplashFrame() must be called from an event dispatch thread.");
}
setUndecorated(true);
// Load icon and set preferred JFrame properties.
final ImageIcon bgIcon = new ImageIcon(BG_ADDRESS);
// Set preferred JFrame properties.
final ImageIcon bgIcon = skin.splash;
final int splashWidthPx = bgIcon.getIconWidth();
final int splashHeightPx = bgIcon.getIconHeight();