aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/qcommon
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-09-26 12:07:32 +0000
committerHolger Zickner <[email protected]>2004-09-26 12:07:32 +0000
commit9063e3e8a2630739f482e846dcbb52d3a4e67037 (patch)
treef7010b3a736d9ef1832278b6d78f86e98dab1ba5 /src/jake2/qcommon
parent658f4658239b097c83ca116035df28df61386175 (diff)
reorganized install dialog
Diffstat (limited to 'src/jake2/qcommon')
-rw-r--r--src/jake2/qcommon/Q2DataDialog.java211
1 files changed, 158 insertions, 53 deletions
diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java
index ee0d6a0..a95d6cf 100644
--- a/src/jake2/qcommon/Q2DataDialog.java
+++ b/src/jake2/qcommon/Q2DataDialog.java
@@ -25,7 +25,6 @@ import javax.swing.*;
*/
public class Q2DataDialog extends javax.swing.JDialog {
- /** Creates new form Q2DataDialog */
public Q2DataDialog() {
super();
initComponents();
@@ -38,11 +37,6 @@ public class Q2DataDialog extends javax.swing.JDialog {
jTextField1.setText(dir);
}
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
private void initComponents() {//GEN-BEGIN:initComponents
java.awt.GridBagConstraints gridBagConstraints;
@@ -51,7 +45,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
status = new JLabel("initializing Jake2...");
jTextField1 = new javax.swing.JTextField();
changeButton = new javax.swing.JButton();
- installButton = new javax.swing.JButton();
+ cancelButton = new javax.swing.JButton();
exitButton = new javax.swing.JButton();
okButton = new javax.swing.JButton();
@@ -66,47 +60,47 @@ public class Q2DataDialog extends javax.swing.JDialog {
});
choosePanel.setLayout(new java.awt.GridBagLayout());
-
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;
gridBagConstraints.gridy = 0;
- gridBagConstraints.gridwidth = 2;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.gridwidth = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 2);
+ gridBagConstraints.weightx = 1;
choosePanel.add(jTextField1, gridBagConstraints);
- changeButton.setText("change");
+ changeButton.setText("...");
changeButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
changeButtonActionPerformed(evt);
}
});
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 0;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.gridwidth = 1;
+ gridBagConstraints.weightx = 0;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
+ gridBagConstraints.insets = new java.awt.Insets(5, 2, 5, 5);
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
choosePanel.add(changeButton, gridBagConstraints);
- installButton.setText("Install");
- installButton.addActionListener(new java.awt.event.ActionListener() {
+ cancelButton.setText("Cancel");
+ cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- installButtonActionPerformed(evt);
+ cancelButtonActionPerformed(evt);
}
});
-
- gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- choosePanel.add(installButton, gridBagConstraints);
+ gridBagConstraints.gridwidth = 4;
+ gridBagConstraints.weighty = 0;
+ gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
+ choosePanel.add(cancelButton, gridBagConstraints);
exitButton.setText("Exit");
exitButton.addActionListener(new java.awt.event.ActionListener() {
@@ -114,11 +108,10 @@ public class Q2DataDialog extends javax.swing.JDialog {
exitButtonActionPerformed(evt);
}
});
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.gridwidth = 1;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
choosePanel.add(exitButton, gridBagConstraints);
okButton.setText("OK");
@@ -127,16 +120,13 @@ public class Q2DataDialog extends javax.swing.JDialog {
okButtonActionPerformed(evt);
}
});
-
- gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
- choosePanel.add(okButton, gridBagConstraints);
-
- //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH);
+ gridBagConstraints.gridwidth = 2;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
+ choosePanel.add(okButton, gridBagConstraints);
+
Jake2Canvas c = new Jake2Canvas();
getContentPane().add(c, BorderLayout.CENTER);
@@ -156,21 +146,21 @@ public class Q2DataDialog extends javax.swing.JDialog {
progressPanel = new ProgressPanel(this);
installPanel = new InstallPanel(this);
+ notFoundPanel = new NotFoundPanel(this);
pack();
- }//GEN-END:initComponents
-
+ }
- private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed
- showInstallPanel();
- }//GEN-LAST:event_installButtonActionPerformed
-
- private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
+ private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ showNotFoundPanel();
+ }
+
+ private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(1);
dispose();
- }//GEN-LAST:event_exitButtonActionPerformed
-
- private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+ }
+
+ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (dir != null) {
Cvar.Set("cddir", dir);
@@ -180,7 +170,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
synchronized(this) {
notifyAll();
}
- }//GEN-LAST:event_okButtonActionPerformed
+ }
private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
JFileChooser chooser = new JFileChooser();
@@ -207,12 +197,13 @@ public class Q2DataDialog extends javax.swing.JDialog {
// 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.JButton cancelButton;
private Jake2Canvas canvas;
private javax.swing.JPanel choosePanel;
private JPanel statusPanel;
private ProgressPanel progressPanel;
private InstallPanel installPanel;
+ private NotFoundPanel notFoundPanel;
private JLabel status;
private javax.swing.JTextField jTextField1;
private javax.swing.JButton okButton;
@@ -224,6 +215,7 @@ public class Q2DataDialog extends javax.swing.JDialog {
getContentPane().remove(statusPanel);
getContentPane().remove(progressPanel);
getContentPane().remove(installPanel);
+ getContentPane().remove(notFoundPanel);
getContentPane().add(choosePanel, BorderLayout.SOUTH);
validate();
repaint();
@@ -248,18 +240,27 @@ public class Q2DataDialog extends javax.swing.JDialog {
void showInstallPanel() {
getContentPane().remove(choosePanel);
getContentPane().remove(statusPanel);
+ getContentPane().remove(notFoundPanel);
getContentPane().add(installPanel, BorderLayout.SOUTH);
validate();
repaint();
}
+ void showNotFoundPanel() {
+ getContentPane().remove(choosePanel);
+ getContentPane().remove(statusPanel);
+ getContentPane().add(notFoundPanel, BorderLayout.SOUTH);
+ validate();
+ repaint();
+ }
+
void setStatus(String text) {
status.setText(text);
}
void testQ2Data() {
while (FS.LoadFile("pics/colormap.pcx") == null) {
- showChooseDialog();
+ showNotFoundPanel();
try {
synchronized(this) {
@@ -291,10 +292,110 @@ public class Q2DataDialog extends javax.swing.JDialog {
}
+ static class NotFoundPanel extends JPanel {
+
+ private Q2DataDialog parent;
+ private ButtonGroup selection;
+ private JRadioButton dir;
+ private JRadioButton install;
+ private JButton exit;
+ private JButton ok;
+ private JLabel message;
+
+ NotFoundPanel(Q2DataDialog d) {
+ parent = d;
+ initComponents();
+ }
+
+ private void initComponents() {
+ GridBagConstraints constraints = new GridBagConstraints();
+ setLayout(new GridBagLayout());
+ Dimension d = new Dimension(400, 100);
+ setMinimumSize(d);
+ setMaximumSize(d);
+ setPreferredSize(d);
+
+ message = new JLabel("Quake2 level data not found");
+ message.setForeground(Color.RED);
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+ constraints.gridwidth = 2;
+ constraints.insets = new Insets(5, 5, 5, 5);
+ constraints.anchor = GridBagConstraints.CENTER;
+ add(message, constraints);
+
+ constraints.gridx = 1;
+ constraints.gridy = 1;
+ constraints.gridwidth = 2;
+ constraints.weightx = 1;
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.insets = new Insets(0, 2, 0, 5);
+ constraints.anchor = GridBagConstraints.WEST;
+ add(new JLabel("select baseq2 directory from existing Quake2 installation"), constraints);
+
+ constraints.gridx = 1;
+ constraints.gridy = 2;
+ add(new JLabel("download and install Quake2 demo data (38MB)"), constraints);
+
+ selection = new ButtonGroup();
+ dir = new JRadioButton();
+ install = new JRadioButton();
+ selection.add(dir);
+ selection.add(install);
+
+ constraints.gridx = 0;
+ constraints.gridy = 1;
+ constraints.gridwidth = 1;
+ constraints.weightx = 0;
+ constraints.insets = new Insets(0, 5, 0, 2);
+ constraints.fill = GridBagConstraints.NONE;
+ constraints.anchor = GridBagConstraints.EAST;
+ dir.setSelected(true);
+ add(dir, constraints);
+
+ constraints.gridx = 0;
+ constraints.gridy = 2;
+ add(install, constraints);
+
+ constraints.gridx = 0;
+ constraints.gridy = 3;
+ constraints.gridwidth = 2;
+ constraints.weighty = 1;
+ constraints.insets = new Insets(5, 5, 5, 5);
+ constraints.fill = GridBagConstraints.NONE;
+ constraints.anchor = GridBagConstraints.SOUTHWEST;
+ exit = new JButton("Exit");
+ exit.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.exit(0);
+ }});
+ add(exit, constraints);
+
+ constraints.gridx = 2;
+ constraints.gridy = 3;
+ constraints.gridwidth = 1;
+ constraints.anchor = GridBagConstraints.SOUTHEAST;
+ ok = new JButton("OK");
+ ok.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ ok();
+ }});
+ add(ok, constraints);
+ }
+
+ private void ok() {
+ if (dir.isSelected()) {
+ parent.showChooseDialog();
+ } else {
+ parent.showInstallPanel();
+ }
+ }
+ }
+
static class InstallPanel extends JPanel {
private static final String[][] mirrors = {
- {"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home
+ //{"LOC gate", "ftp://gate/q2-314-demo-x86.exe"}, // local test @home
{"DE ftp.fu-berlin.de", "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe"},
{"UK ftp.demon.co.uk", "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe"},
{"SE ftp.fragzone.se", "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe"},
@@ -396,7 +497,11 @@ public class Q2DataDialog extends javax.swing.JDialog {
add(install, constraints);
}
+ private void readMirrors() {
+ }
+
private void initMirrors() {
+ readMirrors();
for (int i = 0; i < mirrors.length; i++) {
mirrorBox.addItem(mirrors[i][0]);
}
@@ -428,8 +533,8 @@ public class Q2DataDialog extends javax.swing.JDialog {
String dir = null;
try {
dir = chooser.getSelectedFile().getCanonicalPath();
- } catch (IOException e) {}
- destDir.setText(dir);
+ } catch (Exception e) {}
+ if (dir != null) destDir.setText(dir);
}
}