aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-09-19 19:53:51 +0000
committerHolger Zickner <[email protected]>2004-09-19 19:53:51 +0000
commit0c42216204e5ec7c9b6a9bf143aa9fb069998fa0 (patch)
tree64cc5d31096a37413752951d16f1fe9e20533752 /src/jake2
parent1c1d51f84701813daa86ec4f7aa1df97a5ce09c1 (diff)
splash screen with status messages
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/Jake2.java8
-rw-r--r--src/jake2/qcommon/Q2DataDialog.java131
-rw-r--r--src/jake2/qcommon/Q2DataTest.java15
-rw-r--r--src/jake2/qcommon/Qcommon.java9
4 files changed, 116 insertions, 47 deletions
diff --git a/src/jake2/Jake2.java b/src/jake2/Jake2.java
index 65c8075..8701969 100644
--- a/src/jake2/Jake2.java
+++ b/src/jake2/Jake2.java
@@ -2,7 +2,7 @@
* Jake2.java
* Copyright (C) 2003
*
- * $Id: Jake2.java,v 1.3 2004-07-09 06:50:51 hzi Exp $
+ * $Id: Jake2.java,v 1.4 2004-09-19 19:53:51 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2;
import jake2.client.SCR;
+import jake2.qcommon.*;
import jake2.qcommon.Cvar;
import jake2.qcommon.Qcommon;
import jake2.sys.Sys;
@@ -35,7 +36,8 @@ import jake2.sys.Sys;
*/
public final class Jake2 {
-
+ public static Q2DataDialog Q2Dialog = new Q2DataDialog();
+
/**
* main is used to start the game. Quake2 for Java supports the
* following command line arguments:
@@ -43,6 +45,8 @@ public final class Jake2 {
*/
public static void main(String[] args) {
+ Q2Dialog.setVisible(true);
+
// in C the first arg is the filename
int argc = (args == null) ? 1 : args.length + 1;
String[] c_args = new String[argc];
diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java
index 34426d6..65d1f33 100644
--- a/src/jake2/qcommon/Q2DataDialog.java
+++ b/src/jake2/qcommon/Q2DataDialog.java
@@ -6,13 +6,14 @@
package jake2.qcommon;
-import jake2.Globals;
-
+import java.awt.*;
import java.awt.DisplayMode;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
+import javax.swing.*;
import javax.swing.JFileChooser;
+import javax.swing.JPanel;
/**
*
@@ -21,13 +22,14 @@ import javax.swing.JFileChooser;
public class Q2DataDialog extends javax.swing.JDialog {
/** Creates new form Q2DataDialog */
- public Q2DataDialog(java.awt.Frame parent, boolean modal) {
- super(parent, modal);
+ public Q2DataDialog() {
+ super();
initComponents();
- DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
- int x = (mode.getWidth() - getWidth()) / 2;
- int y = (mode.getHeight() - getHeight()) / 2;
- setLocation(x, y);
+
+ DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
+ int x = (mode.getWidth() - getWidth()) / 2;
+ int y = (mode.getHeight() - getHeight()) / 2;
+ setLocation(x, y);
}
/** This method is called from within the constructor to
@@ -38,8 +40,9 @@ public class Q2DataDialog extends javax.swing.JDialog {
private void initComponents() {//GEN-BEGIN:initComponents
java.awt.GridBagConstraints gridBagConstraints;
- jPanel1 = new javax.swing.JPanel();
- jPanel2 = new javax.swing.JPanel();
+ choosePanel = new javax.swing.JPanel();
+ statusPanel = new JPanel();
+ status = new JLabel("initializing Jake2...");
jTextField1 = new javax.swing.JTextField();
changeButton = new javax.swing.JButton();
installButton = new javax.swing.JButton();
@@ -47,8 +50,8 @@ public class Q2DataDialog extends javax.swing.JDialog {
okButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setTitle("Looking for Quake2 level data...");
- setModal(true);
+ setTitle("Jake2 - Bytonic Software");
+
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
@@ -56,18 +59,11 @@ public class Q2DataDialog extends javax.swing.JDialog {
}
});
- jPanel1.setBackground(new java.awt.Color(255, 255, 255));
- jPanel1.setDoubleBuffered(false);
- jPanel1.setMaximumSize(new java.awt.Dimension(400, 200));
- jPanel1.setMinimumSize(new java.awt.Dimension(400, 200));
- jPanel1.setPreferredSize(new java.awt.Dimension(400, 200));
- getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
-
- jPanel2.setLayout(new java.awt.GridBagLayout());
+ choosePanel.setLayout(new java.awt.GridBagLayout());
- jPanel2.setMaximumSize(new java.awt.Dimension(400, 100));
- jPanel2.setMinimumSize(new java.awt.Dimension(400, 100));
- jPanel2.setPreferredSize(new java.awt.Dimension(400, 100));
+ choosePanel.setMaximumSize(new java.awt.Dimension(400, 100));
+ choosePanel.setMinimumSize(new java.awt.Dimension(400, 100));
+ choosePanel.setPreferredSize(new java.awt.Dimension(400, 100));
jTextField1.setPreferredSize(null);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
@@ -76,7 +72,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints.weightx = 1.0;
- jPanel2.add(jTextField1, gridBagConstraints);
+ choosePanel.add(jTextField1, gridBagConstraints);
changeButton.setText("change");
changeButton.addActionListener(new java.awt.event.ActionListener() {
@@ -90,7 +86,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
- jPanel2.add(changeButton, gridBagConstraints);
+ choosePanel.add(changeButton, gridBagConstraints);
installButton.setText("Install");
installButton.addActionListener(new java.awt.event.ActionListener() {
@@ -104,7 +100,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- jPanel2.add(installButton, gridBagConstraints);
+ choosePanel.add(installButton, gridBagConstraints);
exitButton.setText("Exit");
exitButton.addActionListener(new java.awt.event.ActionListener() {
@@ -117,7 +113,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- jPanel2.add(exitButton, gridBagConstraints);
+ choosePanel.add(exitButton, gridBagConstraints);
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
@@ -131,10 +127,27 @@ public class Q2DataDialog extends javax.swing.JDialog {
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
- jPanel2.add(okButton, gridBagConstraints);
-
- getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
-
+ choosePanel.add(okButton, gridBagConstraints);
+
+ //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH);
+
+ Jake2Canvas c = new Jake2Canvas();
+ getContentPane().add(c, BorderLayout.CENTER);
+
+ statusPanel.setLayout(new java.awt.GridBagLayout());
+ statusPanel.setMaximumSize(new java.awt.Dimension(400, 100));
+ statusPanel.setMinimumSize(new java.awt.Dimension(400, 100));
+ statusPanel.setPreferredSize(new java.awt.Dimension(400, 100));
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridwidth = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.weightx = 1.0;
+ statusPanel.add(status, gridBagConstraints);
+ getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
+
pack();
}//GEN-END:initComponents
@@ -145,7 +158,6 @@ public class Q2DataDialog extends javax.swing.JDialog {
private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
System.exit(1);
dispose();
- notifyAll();
}//GEN-LAST:event_exitButtonActionPerformed
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
@@ -153,10 +165,9 @@ public class Q2DataDialog extends javax.swing.JDialog {
Cvar.Set("cddir", dir);
FS.setCDDir();
- synchronized (this) {
- notify();
+ synchronized(this) {
+ notifyAll();
}
- dispose();
}//GEN-LAST:event_okButtonActionPerformed
private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
@@ -178,25 +189,67 @@ public class Q2DataDialog extends javax.swing.JDialog {
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
System.exit(1);
dispose();
- notifyAll();
}//GEN-LAST:event_formWindowClosing
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
- new Q2DataDialog(new javax.swing.JFrame(), true).show();
+ new Q2DataDialog().show();
+ System.out.println("Hi");
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton changeButton;
private javax.swing.JButton exitButton;
private javax.swing.JButton installButton;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
+ private Jake2Canvas canvas;
+ private javax.swing.JPanel choosePanel;
+ private JPanel statusPanel;
+ private JLabel status;
private javax.swing.JTextField jTextField1;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables
private String dir;
+
+ void showChooseDialog() {
+ getContentPane().remove(statusPanel);
+ getContentPane().add(choosePanel, BorderLayout.SOUTH);
+ validate();
+ repaint();
+ }
+
+ void showStatus() {
+ getContentPane().remove(choosePanel);
+ getContentPane().add(statusPanel, BorderLayout.SOUTH);
+ validate();
+ repaint();
+ }
+
+ void setStatus(String text) {
+ status.setText(text);
+ }
+
+ static class Jake2Canvas extends Canvas {
+ private Image image;
+ Jake2Canvas() {
+ setSize(400, 200);
+ image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/splash.png"));
+ while (!Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, null)) {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {}
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.awt.Component#paint(java.awt.Graphics)
+ */
+ public void paint(Graphics g) {
+ g.drawImage(image, 0, 0, null);
+ }
+
+ }
}
diff --git a/src/jake2/qcommon/Q2DataTest.java b/src/jake2/qcommon/Q2DataTest.java
index 9d76b0e..5606b99 100644
--- a/src/jake2/qcommon/Q2DataTest.java
+++ b/src/jake2/qcommon/Q2DataTest.java
@@ -2,10 +2,12 @@
* Q2DataTest.java
* Copyright Bytonic Software (C) 2004
*
- * $Id: Q2DataTest.java,v 1.1 2004-09-18 12:36:53 hzi Exp $
+ * $Id: Q2DataTest.java,v 1.2 2004-09-19 19:53:51 hzi Exp $
*/
package jake2.qcommon;
+import jake2.Jake2;
+
/**
* Q2DataTest
*/
@@ -13,11 +15,14 @@ public class Q2DataTest {
static void run() {
while (FS.LoadFile("pics/colormap.pcx") == null) {
- Q2DataDialog d = new Q2DataDialog(null, true);
- d.setVisible(true);
+ Jake2.Q2Dialog.showChooseDialog();
+
try {
- d.wait();
- } catch (Exception e) {}
+ synchronized(Jake2.Q2Dialog) {
+ Jake2.Q2Dialog.wait();
+ }
+ } catch (InterruptedException e) {}
}
+ Jake2.Q2Dialog.showStatus();
}
}
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index f052963..369332b 100644
--- a/src/jake2/qcommon/Qcommon.java
+++ b/src/jake2/qcommon/Qcommon.java
@@ -2,7 +2,7 @@
* Qcommon.java
* Copyright 2003
*
- * $Id: Qcommon.java,v 1.7 2004-09-18 12:36:53 hzi Exp $
+ * $Id: Qcommon.java,v 1.8 2004-09-19 19:53:51 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.qcommon;
import jake2.Globals;
+import jake2.Jake2;
import jake2.client.*;
import jake2.game.Cmd;
import jake2.server.SV_MAIN;
@@ -72,8 +73,10 @@ public final class Qcommon extends Globals {
Cbuf.AddEarlyCommands(false);
Cbuf.Execute();
+ Jake2.Q2Dialog.setStatus("initializing filesystem...");
FS.InitFilesystem();
+ Jake2.Q2Dialog.setStatus("loading config...");
Cbuf.AddText("exec default.cfg\n");
Cbuf.Execute();
Cvar.Set("vid_fullscreen", "0");
@@ -108,10 +111,13 @@ public final class Qcommon extends Globals {
Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
+ Jake2.Q2Dialog.setStatus("initializing network subsystem...");
NET.NET_Init(); //ok
Netchan.Netchan_Init(); //ok
+ Jake2.Q2Dialog.setStatus("initializing server subsystem...");
SV_MAIN.SV_Init(); //ok
+ Jake2.Q2Dialog.setStatus("initializing client subsystem...");
CL.Init();
// add + commands from command line
@@ -126,6 +132,7 @@ public final class Qcommon extends Globals {
}
Com.Printf("====== Quake2 Initialized ======\n\n");
+ Jake2.Q2Dialog.dispose();
} catch (longjmpException e) {
Sys.Error("Error during initialization");