mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
Change OSD_CvarModified() to rely on a CVAR_MODIFIED flag set in osdcmd_cvar_set(), instead of merely comparing the current value to the default value. This leaves the storing of the default value (dval in osdcvar_t) in place for use in future features that haven't been programmed yet.
git-svn-id: https://svn.eduke32.com/eduke32@5946 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7d15f7fff7
commit
872d506d95
2 changed files with 30 additions and 33 deletions
|
@ -32,19 +32,20 @@ const char *OSD_StripColors(char *out, const char *in);
|
||||||
|
|
||||||
enum cvartype_t
|
enum cvartype_t
|
||||||
{
|
{
|
||||||
CVAR_FLOAT = 0x00000001,
|
CVAR_FLOAT = 0x00000001,
|
||||||
CVAR_INT = 0x00000002,
|
CVAR_INT = 0x00000002,
|
||||||
CVAR_UINT = 0x00000004,
|
CVAR_UINT = 0x00000004,
|
||||||
CVAR_BOOL = 0x00000008,
|
CVAR_BOOL = 0x00000008,
|
||||||
CVAR_STRING = 0x00000010,
|
CVAR_STRING = 0x00000010,
|
||||||
CVAR_DOUBLE = 0x00000020,
|
CVAR_DOUBLE = 0x00000020,
|
||||||
CVAR_LOCKED = 0x00000040,
|
CVAR_LOCKED = 0x00000040,
|
||||||
CVAR_MULTI = 0x00000080,
|
CVAR_MULTI = 0x00000080,
|
||||||
CVAR_NOSAVE = 0x00000100,
|
CVAR_NOSAVE = 0x00000100,
|
||||||
CVAR_FUNCPTR = 0x00000200,
|
CVAR_FUNCPTR = 0x00000200,
|
||||||
CVAR_RESTARTVID = 0x00000400,
|
CVAR_RESTARTVID = 0x00000400,
|
||||||
CVAR_INVALIDATEALL = 0x00000800,
|
CVAR_INVALIDATEALL = 0x00000800,
|
||||||
CVAR_INVALIDATEART = 0x00001000,
|
CVAR_INVALIDATEART = 0x00001000,
|
||||||
|
CVAR_MODIFIED = 0x00002000,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _symbol
|
typedef struct _symbol
|
||||||
|
|
|
@ -129,7 +129,7 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t OSD_CvarModified(const osdcvar_t *cvar)
|
static int OSD_CvarModified(const osdcvar_t *cvar)
|
||||||
{
|
{
|
||||||
if (!osd)
|
if (!osd)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -140,26 +140,7 @@ static int32_t OSD_CvarModified(const osdcvar_t *cvar)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rv = 0;
|
return (cvar->c.type & CVAR_MODIFIED) == CVAR_MODIFIED;
|
||||||
|
|
||||||
switch (cvar->c.type & (CVAR_BOOL|CVAR_INT|CVAR_UINT|CVAR_FLOAT|CVAR_DOUBLE|CVAR_STRING))
|
|
||||||
{
|
|
||||||
case CVAR_BOOL:
|
|
||||||
case CVAR_INT:
|
|
||||||
rv = (cvar->dval.i != *(int32_t *)cvar->c.vptr); break;
|
|
||||||
case CVAR_UINT:
|
|
||||||
rv = (cvar->dval.uint != *(uint32_t *)cvar->c.vptr); break;
|
|
||||||
case CVAR_FLOAT:
|
|
||||||
rv = (cvar->dval.f != *(float *)cvar->c.vptr); break;
|
|
||||||
case CVAR_DOUBLE:
|
|
||||||
rv = (cvar->dval.d != *(double *)cvar->c.vptr); break;
|
|
||||||
case CVAR_STRING:
|
|
||||||
rv = 1; break;
|
|
||||||
default:
|
|
||||||
EDUKE32_UNREACHABLE_SECTION(break);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// color code format is as follows:
|
// color code format is as follows:
|
||||||
|
@ -710,6 +691,8 @@ static int32_t _internal_osdfunc_toggle(const osdfuncparm_t *parm)
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int32_t *)osd->cvars[i].c.vptr = 1 - *(int32_t *)osd->cvars[i].c.vptr;
|
*(int32_t *)osd->cvars[i].c.vptr = 1 - *(int32_t *)osd->cvars[i].c.vptr;
|
||||||
|
osd->cvars[i].c.type |= CVAR_MODIFIED;
|
||||||
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2070,7 +2053,10 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
|
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(float *)osd->cvars[i].c.vptr = val;
|
*(float *)osd->cvars[i].c.vptr = val;
|
||||||
|
osd->cvars[i].c.type |= CVAR_MODIFIED;
|
||||||
|
|
||||||
if (!OSD_ParsingScript())
|
if (!OSD_ParsingScript())
|
||||||
OSD_Printf("%s %f",osd->cvars[i].c.name,val);
|
OSD_Printf("%s %f",osd->cvars[i].c.name,val);
|
||||||
}
|
}
|
||||||
|
@ -2091,7 +2077,10 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
|
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(double *)osd->cvars[i].c.vptr = val;
|
*(double *)osd->cvars[i].c.vptr = val;
|
||||||
|
osd->cvars[i].c.type |= CVAR_MODIFIED;
|
||||||
|
|
||||||
if (!OSD_ParsingScript())
|
if (!OSD_ParsingScript())
|
||||||
OSD_Printf("%s %f",osd->cvars[i].c.name,val);
|
OSD_Printf("%s %f",osd->cvars[i].c.name,val);
|
||||||
}
|
}
|
||||||
|
@ -2113,7 +2102,10 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
|
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int32_t *)osd->cvars[i].c.vptr = val;
|
*(int32_t *)osd->cvars[i].c.vptr = val;
|
||||||
|
osd->cvars[i].c.type |= CVAR_MODIFIED;
|
||||||
|
|
||||||
if (!OSD_ParsingScript())
|
if (!OSD_ParsingScript())
|
||||||
OSD_Printf("%s %d",osd->cvars[i].c.name,val);
|
OSD_Printf("%s %d",osd->cvars[i].c.name,val);
|
||||||
}
|
}
|
||||||
|
@ -2135,6 +2127,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
}
|
}
|
||||||
|
|
||||||
*(uint32_t *) osd->cvars[i].c.vptr = val;
|
*(uint32_t *) osd->cvars[i].c.vptr = val;
|
||||||
|
osd->cvars[i].c.type |= CVAR_MODIFIED;
|
||||||
|
|
||||||
if (!OSD_ParsingScript())
|
if (!OSD_ParsingScript())
|
||||||
OSD_Printf("%s %d", osd->cvars[i].c.name, val);
|
OSD_Printf("%s %d", osd->cvars[i].c.name, val);
|
||||||
|
@ -2150,6 +2143,9 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
Bstrncpy((char *)osd->cvars[i].c.vptr, parm->parms[0], osd->cvars[i].c.max-1);
|
Bstrncpy((char *)osd->cvars[i].c.vptr, parm->parms[0], osd->cvars[i].c.max-1);
|
||||||
((char *)osd->cvars[i].c.vptr)[osd->cvars[i].c.max-1] = 0;
|
((char *)osd->cvars[i].c.vptr)[osd->cvars[i].c.max-1] = 0;
|
||||||
|
|
||||||
|
osd->cvars[i].c.type |= CVAR_MODIFIED;
|
||||||
|
|
||||||
if (!OSD_ParsingScript())
|
if (!OSD_ParsingScript())
|
||||||
OSD_Printf("%s %s",osd->cvars[i].c.name,(char *)osd->cvars[i].c.vptr);
|
OSD_Printf("%s %s",osd->cvars[i].c.name,(char *)osd->cvars[i].c.vptr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue