aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/qcommon
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-09-18 12:36:53 +0000
committerHolger Zickner <[email protected]>2004-09-18 12:36:53 +0000
commit6fe4be0be3db81d64f551dbb5ab88541e5050d15 (patch)
tree5caa8c400662fa220bc5bceea1751412e5c70da3 /src/jake2/qcommon
parentca3ba393a3dac463c97f6f0a77d3cb130208e4f5 (diff)
first version of data chooser/installer
Diffstat (limited to 'src/jake2/qcommon')
-rw-r--r--src/jake2/qcommon/Q2DataDialog.java202
-rw-r--r--src/jake2/qcommon/Q2DataTest.java23
-rw-r--r--src/jake2/qcommon/Qcommon.java14
3 files changed, 238 insertions, 1 deletions
diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java
new file mode 100644
index 0000000..34426d6
--- /dev/null
+++ b/src/jake2/qcommon/Q2DataDialog.java
@@ -0,0 +1,202 @@
+/*
+ * Q2DataDialog.java
+ *
+ * Created on 17. September 2004, 20:13
+ */
+
+package jake2.qcommon;
+
+import jake2.Globals;
+
+import java.awt.DisplayMode;
+import java.awt.GraphicsEnvironment;
+import java.io.IOException;
+
+import javax.swing.JFileChooser;
+
+/**
+ *
+ * @author hoz
+ */
+public class Q2DataDialog extends javax.swing.JDialog {
+
+ /** Creates new form Q2DataDialog */
+ public Q2DataDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ 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
+ * 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;
+
+ jPanel1 = new javax.swing.JPanel();
+ jPanel2 = new javax.swing.JPanel();
+ jTextField1 = new javax.swing.JTextField();
+ changeButton = new javax.swing.JButton();
+ installButton = new javax.swing.JButton();
+ exitButton = new javax.swing.JButton();
+ okButton = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+ setTitle("Looking for Quake2 level data...");
+ setModal(true);
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ formWindowClosing(evt);
+ }
+ });
+
+ 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());
+
+ jPanel2.setMaximumSize(new java.awt.Dimension(400, 100));
+ jPanel2.setMinimumSize(new java.awt.Dimension(400, 100));
+ jPanel2.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;
+ jPanel2.add(jTextField1, gridBagConstraints);
+
+ changeButton.setText("change");
+ 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.gridy = 0;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
+ jPanel2.add(changeButton, gridBagConstraints);
+
+ installButton.setText("Install");
+ installButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installButtonActionPerformed(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;
+ jPanel2.add(installButton, gridBagConstraints);
+
+ exitButton.setText("Exit");
+ exitButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ exitButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ jPanel2.add(exitButton, gridBagConstraints);
+
+ okButton.setText("OK");
+ okButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ 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;
+ jPanel2.add(okButton, gridBagConstraints);
+
+ getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
+
+ pack();
+ }//GEN-END:initComponents
+
+ private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_installButtonActionPerformed
+
+ 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
+
+ Cvar.Set("cddir", dir);
+ FS.setCDDir();
+
+ synchronized (this) {
+ notify();
+ }
+ dispose();
+ }//GEN-LAST:event_okButtonActionPerformed
+
+ private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
+ chooser.setMultiSelectionEnabled(false);
+ chooser.setDialogTitle("choose a valid baseq2 directory");
+ chooser.showDialog(this, "OK");
+
+ dir = null;
+ try {
+ dir = chooser.getSelectedFile().getCanonicalPath();
+ } catch (IOException e) {}
+ jTextField1.setText(dir);
+
+ }//GEN-LAST:event_changeButtonActionPerformed
+
+ 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();
+ }
+
+ // 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 javax.swing.JTextField jTextField1;
+ private javax.swing.JButton okButton;
+ // End of variables declaration//GEN-END:variables
+
+ private String dir;
+}
diff --git a/src/jake2/qcommon/Q2DataTest.java b/src/jake2/qcommon/Q2DataTest.java
new file mode 100644
index 0000000..9d76b0e
--- /dev/null
+++ b/src/jake2/qcommon/Q2DataTest.java
@@ -0,0 +1,23 @@
+/*
+ * Q2DataTest.java
+ * Copyright Bytonic Software (C) 2004
+ *
+ * $Id: Q2DataTest.java,v 1.1 2004-09-18 12:36:53 hzi Exp $
+ */
+package jake2.qcommon;
+
+/**
+ * Q2DataTest
+ */
+public class Q2DataTest {
+
+ static void run() {
+ while (FS.LoadFile("pics/colormap.pcx") == null) {
+ Q2DataDialog d = new Q2DataDialog(null, true);
+ d.setVisible(true);
+ try {
+ d.wait();
+ } catch (Exception e) {}
+ }
+ }
+}
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index e260079..f052963 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.6 2004-09-06 20:30:21 hzi Exp $
+ * $Id: Qcommon.java,v 1.7 2004-09-18 12:36:53 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -82,6 +82,10 @@ public final class Qcommon extends Globals {
Cbuf.AddEarlyCommands(true);
Cbuf.Execute();
+ FS.setCDDir(); // use cddir from config.cfg
+ Q2DataTest.run(); // test for valid baseq2
+ reconfigure(); // reload default.cfg and config.cfg
+
//
// init commands and vars
//
@@ -227,5 +231,13 @@ public final class Qcommon extends Globals {
}
}
+ static void reconfigure() {
+ Cbuf.AddText("exec default.cfg\n");
+ Cbuf.Execute();
+ Cvar.Set("vid_fullscreen", "0");
+ Cbuf.AddText("exec config.cfg\n");
+ Cbuf.AddEarlyCommands(true);
+ Cbuf.Execute();
+ }
}