From a21f340553fe586ce44cb3d052a46a69fc0344a5 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 22 Feb 2014 08:03:02 +0000 Subject: [PATCH] Mapster32: Introduce m32_settings.cfg, analogous to settings.cfg, so that you can save your cvars and aliases for the editor. One potential use is to add r_togglecomposition "0" if you don't like Aero turning on and off every time you switch between 2D mode and 32-bit 3D mode. git-svn-id: https://svn.eduke32.com/eduke32@4344 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/editor.h | 3 ++ polymer/eduke32/build/src/config.c | 40 ++++++++++++++++++++++++++ polymer/eduke32/source/astub.c | 13 +++++++-- polymer/eduke32/source/config.c | 2 +- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 5e1c1c7f5..e1f548941 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -13,6 +13,9 @@ #define VERSION "2.0.0devel" +#define SETUPFILENAME "mapster32.cfg" +extern char setupfilename[BMAX_PATH]; + // Build keys #define BK_MOVEFORWARD 0 #define BK_MOVEBACKWARD 1 diff --git a/polymer/eduke32/build/src/config.c b/polymer/eduke32/build/src/config.c index 421ef0444..82588e0cb 100644 --- a/polymer/eduke32/build/src/config.c +++ b/polymer/eduke32/build/src/config.c @@ -346,6 +346,44 @@ int32_t loadsetup(const char *fn) return 0; } +void writesettings(void) // save binds and aliases to _m32_settings.cfg +{ + BFILE *fp; + char *ptr = Bstrdup(setupfilename); + char tempbuf[128]; + + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + Bsprintf(tempbuf, "m32_settings.cfg"); + else Bsprintf(tempbuf, "%s_m32_settings.cfg", strtok(ptr, ".")); + + fp = Bfopen(tempbuf, "wt"); + + if (fp) + { + Bfprintf(fp,"// this file is automatically generated by Mapster32\n"); + Bfprintf(fp,"// these settings take precedence over your main cfg file\n"); + Bfprintf(fp,"// do not modify if you lack common sense\n"); + + OSD_WriteAliases(fp); + OSD_WriteCvars(fp); + + Bfclose(fp); + + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + OSD_Printf("Wrote m32_settings.cfg\n"); + else OSD_Printf("Wrote %s_m32_settings.cfg\n",ptr); + + Bfree(ptr); + return; + } + + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + OSD_Printf("Error writing m32_settings.cfg: %s\n", strerror(errno)); + else OSD_Printf("Error writing %s_m32_settings.cfg: %s\n",ptr,strerror(errno)); + + Bfree(ptr); +} + int32_t writesetup(const char *fn) { BFILE *fp; @@ -654,5 +692,7 @@ int32_t writesetup(const char *fn) Bfclose(fp); + writesettings(); + return 0; } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 34cd5d237..bec489f0a 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -79,7 +79,7 @@ static char g_modDir[BMAX_PATH]; static char levelname[BMAX_PATH]; // static char *startwin_labeltext = "Starting Mapster32..."; -static char setupfilename[BMAX_PATH] = "mapster32.cfg"; +char setupfilename[BMAX_PATH] = SETUPFILENAME; int32_t fixmaponsave_sprites = 1; static int32_t fixmaponsave_walls = 0; @@ -10457,7 +10457,7 @@ int32_t ExtInit(void) #ifdef USE_OPENGL glusetexcache = -1; - if (Bstrcmp(setupfilename, "mapster32.cfg")) + if (Bstrcmp(setupfilename, SETUPFILENAME)) initprintf("Using config file \"%s\".\n",setupfilename); if (loadsetup(setupfilename) < 0) @@ -10511,6 +10511,15 @@ int32_t ExtInit(void) OSD_SetParameters(0,2, 0,0, 4,0); registerosdcommands(); + { + char *ptr = Bstrdup(setupfilename), *p = strtok(ptr,"."); + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + Bsprintf(tempbuf, "m32_settings.cfg"); + else Bsprintf(tempbuf,"%s_m32_settings.cfg",p); + OSD_Exec(tempbuf); + Bfree(ptr); + } + // backup pathsearchmode so that a later open // will hopefully be the same file pathsearchmode_oninit = pathsearchmode; diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index bc7b7f651..2f148db7d 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -735,7 +735,7 @@ void CONFIG_WriteBinds(void) // save binds and aliases to _settings.cfg if (fp) { - Bfprintf(fp,"// this file automatically generated by EDuke32\n"); + Bfprintf(fp,"// this file is automatically generated by EDuke32\n"); Bfprintf(fp,"// these settings take precedence over your main cfg file\n"); Bfprintf(fp,"// do not modify if you lack common sense\n");