More cvar shit

git-svn-id: https://svn.eduke32.com/eduke32@1357 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-04-30 01:07:08 +00:00
parent d11e8789e3
commit 493d621eb0
5 changed files with 128 additions and 201 deletions

View file

@ -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

View file

@ -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; i<sizeof(cvars_osd)/sizeof(cvars_osd[0]); i++)
{
OSD_RegisterCvar(&cvars_osd[i]);
if (cvars_osd[i].type & CVAR_FUNCPTR) OSD_RegisterFunction(cvars_osd[i].name, cvars_osd[i].helpstr, osdcmd_cvar_set_osd);
else OSD_RegisterFunction(cvars_osd[i].name, cvars_osd[i].helpstr, osdcmd_cvar_set);
}
OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias);
OSD_RegisterFunction("clear","clear: clears the console text buffer",_internal_osdfunc_clear);
@ -722,15 +648,6 @@ void OSD_Init(void)
OSD_RegisterFunction("help","help: displays help for the specified cvar or command; \"listsymbols\" to show all commands",_internal_osdfunc_help);
OSD_RegisterFunction("history","history: displays the console command history",_internal_osdfunc_history);
OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols);
OSD_RegisterFunction("logcutoff","logcutoff: sets the maximal line count of the log file",_internal_osdfunc_vars);
OSD_RegisterFunction("osdeditpal","osdeditpal: sets the palette of the OSD input text",_internal_osdfunc_vars);
OSD_RegisterFunction("osdeditshade","osdeditshade: sets the shade of the OSD input text",_internal_osdfunc_vars);
OSD_RegisterFunction("osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",_internal_osdfunc_vars);
OSD_RegisterFunction("osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",_internal_osdfunc_vars);
OSD_RegisterFunction("osdrows","osdrows: sets the number of visible lines of the OSD",_internal_osdfunc_vars);
OSD_RegisterFunction("osdtextmode","osdtextmode: set OSD text mode (0:graphical, 1:fast)",_internal_osdfunc_vars);
OSD_RegisterFunction("osdtextpal","osdtextpal: sets the palette of the OSD text",_internal_osdfunc_vars);
OSD_RegisterFunction("osdtextshade","osdtextshade: sets the shade of the OSD text",_internal_osdfunc_vars);
OSD_RegisterFunction("unalias","unalias: removes an alias created with \"alias\"",_internal_osdfunc_unalias);
atexit(OSD_Cleanup);

View file

@ -179,6 +179,7 @@ int32_t r_fullbrights = 1;
// texture downsizing
// is medium quality a good default?
int32_t r_downsize = 1;
int32_t r_downsizevar = 1;
// used for fogcalc
float fogresult, fogcol[4], fogtable[4*MAXPALOOKUPS];
@ -829,6 +830,8 @@ void invalidatecache(void)
{
int32_t i;
r_downsizevar = r_downsize; // update the cvar representation when the menu changes r_downsize
polymost_glreset();
if (cachefilehandle != -1)
{
@ -5899,11 +5902,15 @@ static int32_t osdcmd_cvar_set_polymost(const osdfuncparm_t *parm)
return r;
}
else if (!Bstrcasecmp(parm->name, "r_downsize"))
{
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 },
/*

View file

@ -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);

View file

@ -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 <ctype.h>
#include <limits.h>
@ -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<sizeof(cvars_game)/sizeof(cvars_game[0]); i++)
{
OSD_RegisterCvar(&cvars_game[i]);