ref: 33304ee6ff09806002181e6b739e2a4859be1ade
parent: 3fd97506e16b5c6e4f744ebe211d698c3e734619
author: Simon Howard <[email protected]>
date: Wed Oct 25 14:12:08 EDT 2006
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
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -533,3 +533,47 @@
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;
+}
+
--- a/setup/configfile.h
+++ b/setup/configfile.h
@@ -35,5 +35,8 @@
void M_SetConfigDir(void);
+void M_SaveMainDefaults(char *filename);
+void M_SaveExtraDefaults(char *filename);
+
#endif
--- a/setup/display.c
+++ b/setup/display.c
@@ -49,7 +49,7 @@
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;
--- 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 @@
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 @@
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)