foxygit / doom Log in
commit 33304ee6ff09806002181e6b739e2a4859be1ade
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Wed Oct 25 18:12:08 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Wed Oct 25 18:12:08 2006 +0000

    Make the "test controls" option work - write the current config to
    temporary config files and make Doom use these when executing it.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 738
---
 setup/configfile.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 setup/configfile.h |  3 +++
 setup/display.c    |  2 +-
 setup/execute.c    | 25 ++++++++++++++++++++++++-
 4 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/setup/configfile.c b/setup/configfile.c
index 6042d318..f974f043 100644
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -533,3 +533,47 @@ void M_LoadDefaults (void)
     LoadDefaultCollection(&extra_defaults);
 }

+//
+// Save normal (default.cfg) defaults to a given file
+//
+
+void M_SaveMainDefaults(char *filename)
+{
+    char *main_filename;
+
+    // Save the normal filename and set this one
+
+    main_filename = doom_defaults.filename;
+    doom_defaults.filename = filename;
+
+    // Save the file
+
+    SaveDefaultCollection(&doom_defaults);
+
+    // Restore the normal filename
+
+    doom_defaults.filename = main_filename;
+}
+
+//
+// Save extra (chocolate-doom.cfg) defaults to a given file
+//
+
+void M_SaveExtraDefaults(char *filename)
+{
+    char *main_filename;
+
+    // Save the normal filename and set this one
+
+    main_filename = extra_defaults.filename;
+    extra_defaults.filename = filename;
+
+    // Save the file
+
+    SaveDefaultCollection(&extra_defaults);
+
+    // Restore the normal filename
+
+    extra_defaults.filename = main_filename;
+}
+
diff --git a/setup/configfile.h b/setup/configfile.h
index 63113cc1..f7c6156e 100644
--- a/setup/configfile.h
+++ b/setup/configfile.h
@@ -35,5 +35,8 @@ void M_SaveDefaults (void);

 void M_SetConfigDir(void);

+void M_SaveMainDefaults(char *filename);
+void M_SaveExtraDefaults(char *filename);
+
 #endif

diff --git a/setup/display.c b/setup/display.c
index cecd7e12..c494ebe5 100644
--- a/setup/display.c
+++ b/setup/display.c
@@ -49,7 +49,7 @@ static vidmode_t modes[] =
 static int vidmode = 0;

 int autoadjust_video_settings = 1;
-int fullscreen = 0;
+int fullscreen = 1;
 int screenmultiply = 1;
 int startup_delay = 0;
 int show_endoom = 1;
diff --git a/setup/execute.c b/setup/execute.c
index 5e8a24ea..fb1ac722 100644
--- a/setup/execute.c
+++ b/setup/execute.c
@@ -28,6 +28,7 @@

 #include "textscreen.h"

+#include "configfile.h"
 #include "execute.h"
 #include "m_argv.h"

@@ -121,6 +122,8 @@ void ExecuteDoom(execute_context_t *context)
 static void TestCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
 {
     execute_context_t *exec;
+    char *main_cfg;
+    char *extra_cfg;
     txt_window_t *testwindow;
     txt_label_t *label;

@@ -131,14 +134,34 @@ static void TestCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
     TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);
     TXT_AddWidget(testwindow, label);
     TXT_DrawDesktop();
-
+
+    // Save temporary configuration files with the current configuration
+
+#ifdef _WIN32
+    main_cfg = "tmp.cfg";
+    extra_cfg = "extratmp.cfg";
+#else
+    main_cfg = "/tmp/tmp.cfg";
+    extra_cfg = "/tmp/extratmp.cfg";
+#endif
+
+    M_SaveMainDefaults(main_cfg);
+    M_SaveExtraDefaults(extra_cfg);
+
     // Run with the -testcontrols parameter

     exec = NewExecuteContext();
     AddCmdLineParameter(exec, "-testcontrols");
+    AddCmdLineParameter(exec, "-config %s", main_cfg);
+    AddCmdLineParameter(exec, "-extraconfig %s", extra_cfg);
     ExecuteDoom(exec);

     TXT_CloseWindow(testwindow);
+
+    // Delete the temporary config files
+
+    remove(main_cfg);
+    remove(extra_cfg);
 }

 txt_window_action_t *TestConfigAction(void)