From 493d621eb0bc73535b1a03263cd39d5ce06d3fc3 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 30 Apr 2009 01:07:08 +0000 Subject: [PATCH] More cvar shit git-svn-id: https://svn.eduke32.com/eduke32@1357 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 1 + polymer/eduke32/build/src/osd.c | 305 ++++++++++---------------- polymer/eduke32/build/src/polymost.c | 17 +- polymer/eduke32/source/config.c | 1 + polymer/eduke32/source/osdcmds.c | 5 +- 5 files changed, 128 insertions(+), 201 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index eff15f044..3be237584 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -620,6 +620,7 @@ extern int32_t r_parallaxskypanning; extern int32_t r_modelocclusionchecking; extern int32_t r_fullbrights; extern int32_t r_downsize; +extern int32_t r_downsizevar; extern int32_t mdtims, omdtims; extern int32_t glrendmode; #endif diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index cb72fcc1f..7b0e13ae3 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -159,9 +159,9 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar) return -1; } if ((*cp < '0') || - (*cp > '9' && *cp < 'A') || - (*cp > 'Z' && *cp < 'a' && *cp != '_') || - (*cp > 'z')) + (*cp > '9' && *cp < 'A') || + (*cp > 'Z' && *cp < 'a' && *cp != '_') || + (*cp > 'z')) { OSD_Printf("OSD_RegisterCvar(): illegal character in cvar name \"%s\"\n", cvar->name); return -1; @@ -479,119 +479,6 @@ static int32_t _internal_osdfunc_unalias(const osdfuncparm_t *parm) return OSDCMD_OK; } -static int32_t _internal_osdfunc_vars(const osdfuncparm_t *parm) -{ - int32_t showval = (parm->numparms < 1); - - if (!Bstrcasecmp(parm->name, "osdrows")) - { - if (showval) { OSD_Printf("osdrows is %d\n", osdrows); return OSDCMD_OK; } - else - { - osdrows = atoi(parm->parms[0]); - if (osdrows < 1) osdrows = 1; - else if (osdrows > osdmaxrows) osdrows = osdmaxrows; - if (osdrowscur!=-1)osdrowscur = osdrows; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "osdpromptshade")) - { - if (showval) { OSD_Printf("osdpromptshade is %d\n", osdpromptshade); return OSDCMD_OK; } - else - { - osdpromptshade = atoi(parm->parms[0]); - if (osdpromptshade < -128) osdpromptshade = -128; - else if (osdpromptshade > 127) osdpromptshade = 127; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "osdeditshade")) - { - if (showval) { OSD_Printf("osdeditshade is %d\n", osdeditshade); return OSDCMD_OK; } - else - { - osdeditshade = atoi(parm->parms[0]); - if (osdeditshade < 0) osdeditshade = 0; - else if (osdeditshade > 7) osdeditshade = 7; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "osdtextshade")) - { - if (showval) { OSD_Printf("osdtextshade is %d\n", osdtextshade); return OSDCMD_OK; } - else - { - osdtextshade = atoi(parm->parms[0]); - if (osdtextshade < 0) osdtextshade = 0; - else if (osdtextshade > 7) osdtextshade = 7; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - - else if (!Bstrcasecmp(parm->name, "osdpromptpal")) - { - if (showval) { OSD_Printf("osdpromptpal is %d\n", osdpromptpal); return OSDCMD_OK; } - else - { - osdpromptpal = atoi(parm->parms[0]); - if (osdpromptpal < 0) osdpromptpal = 0; - else if (osdpromptpal > MAXPALOOKUPS-1) osdpromptpal = MAXPALOOKUPS; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "osdeditpal")) - { - if (showval) { OSD_Printf("osdeditpal is %d\n", osdeditpal); return OSDCMD_OK; } - else - { - osdeditpal = atoi(parm->parms[0]); - if (osdeditpal < 0) osdeditpal = 0; - else if (osdeditpal > MAXPALOOKUPS-1) osdeditpal = MAXPALOOKUPS; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "osdtextpal")) - { - if (showval) { OSD_Printf("osdtextpal is %d\n", osdtextpal); return OSDCMD_OK; } - else - { - osdtextpal = atoi(parm->parms[0]); - if (osdtextpal < 0) osdtextpal = 0; - else if (osdtextpal > MAXPALOOKUPS-1) osdtextpal = MAXPALOOKUPS; - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "osdtextmode")) - { - if (showval) { OSD_Printf("osdtextmode is %d\n", osdtextmode); return OSDCMD_OK; } - else - { - OSD_SetTextMode(atoi(parm->parms[0]) != 0); - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - else if (!Bstrcasecmp(parm->name, "logcutoff")) - { - if (showval) { OSD_Printf("logcutoff is %d\n", logcutoff); return OSDCMD_OK; } - else - { - logcutoff = atoi(parm->parms[0]); - OSD_Printf("%s\n",parm->raw); - return OSDCMD_OK; - } - } - return OSDCMD_SHOWHELP; -} - static int32_t _internal_osdfunc_listsymbols(const osdfuncparm_t *parm) { symbol_t *i; @@ -698,23 +585,62 @@ void OSD_Cleanup(void) } +static int32_t osdcmd_cvar_set_osd(const osdfuncparm_t *parm) +{ + int32_t r = osdcmd_cvar_set(parm); + + if (r == OSDCMD_OK) + { + if (!Bstrcasecmp(parm->name, "osdrows")) + { + if (osdrows > osdmaxrows) osdrows = osdmaxrows; + if (osdrowscur!=-1)osdrowscur = osdrows; + return r; + } + else if (!Bstrcasecmp(parm->name, "osdtextmode")) + { + OSD_SetTextMode(osdtextmode); + return r; + } + } + return r; +} + // // OSD_Init() -- Initializes the on-screen display // void OSD_Init(void) { + uint32_t i; + cvar_t cvars_osd[] = + { + { "osdeditpal","osdeditpal: sets the palette of the OSD input text",(void *)&osdeditpal, CVAR_INT, 0, 0, MAXPALOOKUPS-1 }, + { "osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",(void *)&osdpromptpal, CVAR_INT, 0, 0, MAXPALOOKUPS-1 }, + { "osdtextpal","osdtextpal: sets the palette of the OSD text",(void *)&osdtextpal, CVAR_INT, 0, 0, MAXPALOOKUPS-1 }, + { "osdeditshade","osdeditshade: sets the shade of the OSD input text",(void *)&osdeditshade, CVAR_INT, 0, 0, 7 }, + { "osdtextshade","osdtextshade: sets the shade of the OSD text",(void *)&osdtextshade, CVAR_INT, 0, 0, 7 }, + { "osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",(void *)&osdpromptshade, CVAR_INT, 0, -128, 127 }, + { "logcutoff","logcutoff: sets the maximal line count of the log file",(void *)&logcutoff, CVAR_INT, 0, 0, 262144 }, + { "osdrows","osdrows: sets the number of visible lines of the OSD",(void *)&osdrows, CVAR_INT|CVAR_FUNCPTR, 0, 0, MAXPALOOKUPS-1 }, + { "osdtextmode","osdtextmode: set OSD text mode (0:graphical, 1:fast)",(void *)&osdtextmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 0, 1 }, + }; + Bmemset(osdtext, 32, TEXTSIZE); Bmemset(osdfmt, osdtextpal+(osdtextshade<<5), TEXTSIZE); Bmemset(osdsymbptrs, 0, sizeof(osdsymbptrs)); osdnumsymbols = osdnumcvars = 0; + osdlines = osdinited = 1; hash_init(&osdsymbolsH); hash_init(&osdcvarsH); - osdlines=1; - - osdinited=1; + for (i=0; iparms[0], "%f", &val); - - if (val < cvars[i].min || val > cvars[i].max) - { - OSD_Printf("%s value out of range\n",cvars[i].name); - return OSDCMD_OK; - } - *(float*)cvars[i].var = val; - if (!OSD_ParsingScript()) - OSD_Printf("%s %f",cvars[i].name,val); + OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(float*)cvars[i].var,(char*)cvars[i].helpstr); + return OSDCMD_OK; } - break; + + sscanf(parm->parms[0], "%f", &val); + + if (val < cvars[i].min || val > cvars[i].max) + { + OSD_Printf("%s value out of range\n",cvars[i].name); + return OSDCMD_OK; + } + *(float*)cvars[i].var = val; + if (!OSD_ParsingScript()) + OSD_Printf("%s %f",cvars[i].name,val); + } + break; case CVAR_INT: case CVAR_UNSIGNEDINT: case CVAR_BOOL: + { + int32_t val; + if (showval) { - int32_t val; - if (showval) - { - OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t*)cvars[i].var,(char*)cvars[i].helpstr); - return OSDCMD_OK; - } - - val = atoi(parm->parms[0]); - if (cvars[i].type == CVAR_BOOL) val = val != 0; - - if (val < cvars[i].min || val > cvars[i].max) - { - OSD_Printf("%s value out of range\n",cvars[i].name); - return OSDCMD_OK; - } - *(int32_t*)cvars[i].var = val; - if (!OSD_ParsingScript()) - OSD_Printf("%s %d",cvars[i].name,val); + OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t*)cvars[i].var,(char*)cvars[i].helpstr); + return OSDCMD_OK; } - break; + + val = atoi(parm->parms[0]); + if (cvars[i].type == CVAR_BOOL) val = val != 0; + + if (val < cvars[i].min || val > cvars[i].max) + { + OSD_Printf("%s value out of range\n",cvars[i].name); + return OSDCMD_OK; + } + *(int32_t*)cvars[i].var = val; + if (!OSD_ParsingScript()) + OSD_Printf("%s %d",cvars[i].name,val); + } + break; case CVAR_STRING: + { + if (showval) { - if (showval) - { - OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char*)cvars[i].var,(char*)cvars[i].helpstr); - return OSDCMD_OK; - } - - Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1); - ((char*)cvars[i].var)[cvars[i].extra-1] = 0; - if (!OSD_ParsingScript()) - OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var); + OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char*)cvars[i].var,(char*)cvars[i].helpstr); + return OSDCMD_OK; } - break; + + Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1); + ((char*)cvars[i].var)[cvars[i].extra-1] = 0; + if (!OSD_ParsingScript()) + OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var); + } + break; default: break; - } + } // if (cvars[i].type&CVAR_MULTI) // G_UpdatePlayerFromMenu(); } @@ -2045,22 +1962,22 @@ void OSD_WriteCvars(const char *setupfilename) for (i=0; iname, "r_downsize")) { - invalidatecache(); - resetvideomode(); - if (setgamemode(fullscreen,xdim,ydim,bpp)) - OSD_Printf("restartvid: Reset failed...\n"); + if (r_downsize != r_downsizevar) + { + invalidatecache(); + resetvideomode(); + if (setgamemode(fullscreen,xdim,ydim,bpp)) + OSD_Printf("restartvid: Reset failed...\n"); + } + r_downsize = r_downsizevar; return r; } else if (!Bstrcasecmp(parm->name, "r_textureanisotropy")) @@ -5931,7 +5938,7 @@ void polymost_initosdfuncs(void) { "r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",(void *)&r_animsmoothing, CVAR_BOOL, 0, 0, 1 }, { "r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",(void *)&r_modelocclusionchecking, CVAR_INT, 0, 0, 2 }, { "r_detailmapping","r_detailmapping: enable/disable detail mapping",(void *)&r_detailmapping, CVAR_BOOL, 0, 0, 1 }, - { "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *)&r_downsize, CVAR_INT|CVAR_FUNCPTR, 0, 0, 5 }, + { "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *)&r_downsizevar, CVAR_INT|CVAR_FUNCPTR, 0, 0, 5 }, { "r_fullbrights","r_fullbrights: enable/disable fullbright textures",(void *)&r_fullbrights, CVAR_BOOL, 0, 0, 1 }, { "r_glowmapping","r_glowmapping: enable/disable glow mapping",(void *)&r_glowmapping, CVAR_BOOL, 0, 0, 1 }, /* diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index aa716c1bd..048616368 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -793,6 +793,7 @@ int32_t CONFIG_ReadSetup(void) else glrendmode = 3; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode", &gltexfiltermode); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", &r_downsize); + r_downsizevar = r_downsize; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr", &glusetexcompr); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 4de519906..574439c5d 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -23,11 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //------------------------------------------------------------------------- #include "compat.h" -#include "osd.h" #include "osdcmds.h" #include "baselayer.h" #include "duke3d.h" #include "crc32.h" +#include "osd.h" #include "osdfuncs.h" #include #include @@ -1246,7 +1246,6 @@ static int32_t osdcmd_cvar_set_game(const osdfuncparm_t *parm) int32_t registerosdcommands(void) { uint32_t i; - osdcmd_cheatsinfo_stat.cheatnum = -1; cvar_t cvars_game[] = { @@ -1317,6 +1316,8 @@ int32_t registerosdcommands(void) }; + osdcmd_cheatsinfo_stat.cheatnum = -1; + for (i=0; i