shithub: choc

Download patch

ref: d57d467f53271502ebace92a3ff958ca695cd8e9
parent: 30b2e71c09f4de8d8f1d643da27e06ae6b0ea98e
author: Simon Howard <[email protected]>
date: Mon Oct 23 14:16:02 EDT 2006

Load configuration on startup and save on quit. Functional setup
program!

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 720

--- a/setup/configfile.h
+++ b/setup/configfile.h
@@ -28,10 +28,12 @@
 #ifndef __SETUP_CONFIG__
 #define __SETUP_CONFIG__
 
+extern char *configdir;
 
 void M_LoadDefaults (void);
 void M_SaveDefaults (void);
 
+void M_SetConfigDir(void);
 
 #endif
 
--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -23,6 +23,9 @@
 #include "config.h"
 #include "textscreen.h"
 
+#include "configfile.h"
+#include "m_argv.h"
+
 #include "compatibility.h"
 #include "display.h"
 #include "keyboard.h"
@@ -34,7 +37,7 @@
 {
     if (dosave != NULL)
     {
-        printf("Saving config\n");
+        M_SaveDefaults();
     }
 
     exit(0);
@@ -101,8 +104,25 @@
     TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action);
 }
 
-int main(int argc, char *argv[])
+//
+// Initialise all configuration variables, load config file, etc
+//
+
+static void InitConfig(void)
 {
+    SetChatMacroDefaults();
+    SetPlayerNameDefault();
+
+    M_SetConfigDir();
+    M_LoadDefaults();
+}
+
+// 
+// Initialise and run the textscreen GUI.
+//
+
+static void RunGUI(void)
+{
     TXT_Init();
     TXT_SetDesktopTitle(PACKAGE_NAME " Setup ver " PACKAGE_VERSION);
     
@@ -109,6 +129,15 @@
     MainMenu();
 
     TXT_GUIMainLoop();
+}
+
+int main(int argc, char *argv[])
+{
+    myargc = argc;
+    myargv = argv;
+
+    InitConfig();
+    RunGUI();
 
     return 0;
 }
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -313,7 +313,7 @@
     TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction());
 }
 
-static void SetChatMacroDefaults(void)
+void SetChatMacroDefaults(void)
 {
     int i;
     char *defaults[] = 
@@ -341,7 +341,7 @@
     }
 }
 
-static void SetPlayerNameDefault(void)
+void SetPlayerNameDefault(void)
 {
     if (player_name == NULL)
     {
@@ -366,9 +366,6 @@
     txt_table_t *table;
     char buf[10];
     int i;
-
-    SetChatMacroDefaults();
-    SetPlayerNameDefault();
 
     window = TXT_NewWindow("Multiplayer Configuration");
 
--- a/setup/multiplayer.h
+++ b/setup/multiplayer.h
@@ -29,5 +29,8 @@
 void JoinMultiGame(void);
 void MultiplayerConfig(void);
 
+void SetChatMacroDefaults(void);
+void SetPlayerNameDefault(void);
+
 #endif /* #ifndef SETUP_MULTIPLAYER_H */