internal cleanup, r_menutint and r_skybox use callbacks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2210 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
571ea11411
commit
3fd1a224e3
8 changed files with 83 additions and 93 deletions
|
@ -287,7 +287,7 @@ struct mleaf_s *GLMod_PointInLeaf (struct model_s *model, float *p);
|
|||
void GLMod_Think (void);
|
||||
void GLMod_NowLoadExternal(void);
|
||||
void GLR_WipeStains(void);
|
||||
void R_LoadSkys (void);
|
||||
void GLR_LoadSkys (void);
|
||||
#endif
|
||||
|
||||
#if defined(SWQUAKE)
|
||||
|
|
|
@ -245,11 +245,11 @@ void R_BulletenForce_f (void);
|
|||
|
||||
rendererstate_t currentrendererstate;
|
||||
|
||||
cvar_t gl_skyboxname = SCVAR("r_skybox", "");
|
||||
cvar_t r_skyboxname = SCVARF("r_skybox", "", CVAR_RENDERERCALLBACK);
|
||||
cvar_t r_fastsky = SCVAR("r_fastsky", "0");
|
||||
cvar_t r_fastskycolour = SCVAR("r_fastskycolour", "0");
|
||||
|
||||
cvar_t r_menutint = SCVAR("r_menutint", "0.68 0.4 0.13");
|
||||
cvar_t r_menutint = SCVARF("r_menutint", "0.68 0.4 0.13", CVAR_RENDERERCALLBACK);
|
||||
|
||||
#if defined(RGLQUAKE)
|
||||
cvar_t gl_schematics = SCVAR("gl_schematics","0");
|
||||
|
@ -496,7 +496,7 @@ void Renderer_Init(void)
|
|||
|
||||
Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP);
|
||||
|
||||
Cvar_Register (&gl_skyboxname, GRAPHICALNICETIES);
|
||||
Cvar_Register (&r_skyboxname, GRAPHICALNICETIES);
|
||||
|
||||
Cvar_Register(&r_dodgytgafiles, "Bug fixes");
|
||||
Cvar_Register(&r_dodgypcxfiles, "Bug fixes");
|
||||
|
@ -1513,8 +1513,6 @@ qboolean R_ApplyRenderer (rendererstate_t *newr)
|
|||
|
||||
TRACE(("dbg: R_ApplyRenderer: old renderer closed\n"));
|
||||
|
||||
gl_skyboxname.modified = true;
|
||||
|
||||
pmove.numphysent = 0;
|
||||
|
||||
if (qrenderer) //graphics stuff only when not dedicated
|
||||
|
|
|
@ -2008,22 +2008,15 @@ Draw_FadeScreen
|
|||
================
|
||||
*/
|
||||
vec3_t fadecolor;
|
||||
vec3_t fadecolorreal;
|
||||
int faderender;
|
||||
int fademodified;
|
||||
|
||||
void GLDraw_FadeScreen (void)
|
||||
void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
extern cvar_t r_menutint, gl_menutint_shader;
|
||||
extern int scenepp_texture, scenepp_mt_program, scenepp_mt_parm_colorf, scenepp_mt_parm_inverti;
|
||||
|
||||
if (fademodified != r_menutint.modified)
|
||||
{
|
||||
// parse r_menutint and clear defaults
|
||||
faderender = GL_DST_COLOR;
|
||||
|
||||
if (r_menutint.string[0])
|
||||
SCR_StringToRGB(r_menutint.string, fadecolor, 1);
|
||||
if (var->string[0])
|
||||
SCR_StringToRGB(var->string, fadecolor, 1);
|
||||
else
|
||||
faderender = 0;
|
||||
|
||||
|
@ -2046,9 +2039,12 @@ void GLDraw_FadeScreen (void)
|
|||
fadecolor[2] = -(fadecolor[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fademodified = r_menutint.modified;
|
||||
}
|
||||
void GLDraw_FadeScreen (void)
|
||||
{
|
||||
extern cvar_t gl_menutint_shader;
|
||||
extern int scenepp_texture, scenepp_mt_program, scenepp_mt_parm_colorf, scenepp_mt_parm_inverti;
|
||||
|
||||
if (!faderender)
|
||||
return;
|
||||
|
|
|
@ -655,13 +655,15 @@ if (!data)
|
|||
void GLR_TimeRefresh_f (void);
|
||||
|
||||
extern cvar_t gl_bump;
|
||||
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount;
|
||||
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount, r_menutint;
|
||||
|
||||
// callback defines
|
||||
extern cvar_t crosshair, crosshairimage, crosshaircolor;
|
||||
extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname;
|
||||
void GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue);
|
||||
|
||||
void GLR_DeInit (void)
|
||||
{
|
||||
|
@ -674,6 +676,8 @@ void GLR_DeInit (void)
|
|||
Cvar_Unhook(&crosshair);
|
||||
Cvar_Unhook(&crosshairimage);
|
||||
Cvar_Unhook(&crosshaircolor);
|
||||
Cvar_Unhook(&r_skyboxname);
|
||||
Cvar_Unhook(&r_menutint);
|
||||
|
||||
GLDraw_DeInit();
|
||||
|
||||
|
@ -690,6 +694,8 @@ void GLR_Init (void)
|
|||
Cvar_Hook(&crosshair, GLCrosshair_Callback);
|
||||
Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback);
|
||||
Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback);
|
||||
Cvar_Hook(&r_skyboxname, GLR_Skyboxname_Callback);
|
||||
Cvar_Hook(&r_menutint, GLR_Menutint_Callback);
|
||||
|
||||
R_InitBubble();
|
||||
|
||||
|
@ -1043,7 +1049,7 @@ TRACE(("dbg: GLR_NewMap: figuring out skys and mirrors\n"));
|
|||
}
|
||||
TRACE(("dbg: GLR_NewMap: that skybox thang\n"));
|
||||
//#ifdef QUAKE2
|
||||
R_LoadSkys ();
|
||||
GLR_LoadSkys ();
|
||||
//#endif
|
||||
TRACE(("dbg: GLR_NewMap: ui\n"));
|
||||
#ifdef VM_UI
|
||||
|
|
|
@ -47,12 +47,11 @@ qboolean usingskybox;
|
|||
|
||||
msurface_t *warpface;
|
||||
|
||||
extern cvar_t gl_skyboxname;
|
||||
extern cvar_t r_skyboxname;
|
||||
extern cvar_t gl_skyboxdist;
|
||||
extern cvar_t r_fastsky;
|
||||
extern cvar_t r_fastskycolour;
|
||||
char defaultskybox[MAX_QPATH];
|
||||
qboolean reloadskybox;
|
||||
|
||||
int skyboxtex[6];
|
||||
|
||||
|
@ -301,15 +300,15 @@ static char *skyname_pattern[] = {
|
|||
"gfx/env/%s%s"
|
||||
};
|
||||
|
||||
void R_LoadSkys (void)
|
||||
void GLR_LoadSkys (void)
|
||||
{
|
||||
int i;
|
||||
char name[MAX_QPATH];
|
||||
char *boxname;
|
||||
int p, s;
|
||||
|
||||
if (*gl_skyboxname.string)
|
||||
boxname = gl_skyboxname.string; //user forced
|
||||
if (*r_skyboxname.string)
|
||||
boxname = r_skyboxname.string; //user forced
|
||||
else
|
||||
boxname = defaultskybox;
|
||||
|
||||
|
@ -350,7 +349,6 @@ void R_LoadSkys (void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
reloadskybox = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -358,13 +356,17 @@ qboolean GLR_CheckSky()
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
GLR_LoadSkys();
|
||||
}
|
||||
|
||||
void GLR_SetSky(char *name, float rotate, vec3_t axis) //called from the client code, once per level
|
||||
{
|
||||
Q_strncpyz(defaultskybox, name, sizeof(defaultskybox));
|
||||
if (!*gl_skyboxname.string) //don't override a user's settings
|
||||
{
|
||||
reloadskybox = true;
|
||||
}
|
||||
if (!*r_skyboxname.string) //don't override a user's settings
|
||||
GLR_Skyboxname_Callback(&r_skyboxname, "");
|
||||
|
||||
skyrotate = rotate;
|
||||
VectorCopy(axis, skyaxis);
|
||||
|
@ -772,14 +774,6 @@ void R_ClearSkyBox (void)
|
|||
usingskybox = false;
|
||||
return;
|
||||
}
|
||||
if (gl_skyboxname.modified)
|
||||
{
|
||||
gl_skyboxname.modified = false;
|
||||
reloadskybox = true;
|
||||
}
|
||||
|
||||
if (reloadskybox)
|
||||
R_LoadSkys();
|
||||
|
||||
if (!skyboxtex[0] || !skyboxtex[1] || !skyboxtex[2] || !skyboxtex[3] || !skyboxtex[4] || !skyboxtex[5])
|
||||
{
|
||||
|
|
|
@ -16,15 +16,11 @@ qbyte *pal555to8;
|
|||
int swzpal[TRANS_LEVELS][256];
|
||||
|
||||
// menutint
|
||||
palremap_t *RebuildMenuTint(void);
|
||||
palremap_t *mtpalremap;
|
||||
|
||||
// IB remap
|
||||
palremap_t *ib_remap;
|
||||
|
||||
extern cvar_t r_menutint;
|
||||
int mtmodified;
|
||||
|
||||
#define palette host_basepal
|
||||
#define _abs(x) ((x)*(x))
|
||||
|
||||
|
@ -44,7 +40,6 @@ void D_ShutdownTrans(void)
|
|||
}
|
||||
|
||||
mtpalremap = NULL;
|
||||
mtmodified = 0;
|
||||
ib_remap = NULL;
|
||||
}
|
||||
|
||||
|
@ -57,7 +52,6 @@ void D_InitTrans(void)
|
|||
|
||||
srctable = swzpal[0];
|
||||
dsttable = swzpal[TRANS_MAX];
|
||||
mtpalremap = RebuildMenuTint();
|
||||
ib_remap = D_IdentityRemap();
|
||||
}
|
||||
|
||||
|
@ -413,12 +407,12 @@ palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate,
|
|||
return palremaps + deref;
|
||||
}
|
||||
|
||||
palremap_t *RebuildMenuTint(void)
|
||||
palremap_t *RebuildMenuTint(struct cvar_s *var)
|
||||
{
|
||||
vec3_t rgb;
|
||||
|
||||
if (r_menutint.string[0])
|
||||
SCR_StringToRGB(r_menutint.string, rgb, 1);
|
||||
if (var->string[0])
|
||||
SCR_StringToRGB(var->string, rgb, 1);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
|
@ -443,17 +437,16 @@ void D_DereferenceRemap(palremap_t *palremap)
|
|||
}
|
||||
}
|
||||
|
||||
qbyte *D_GetMenuTintPal(void)
|
||||
void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
if (mtmodified != r_menutint.modified)
|
||||
{
|
||||
if (mtpalremap)
|
||||
D_DereferenceRemap(mtpalremap);
|
||||
|
||||
mtpalremap = RebuildMenuTint();
|
||||
mtmodified = r_menutint.modified;
|
||||
}
|
||||
mtpalremap = RebuildMenuTint(var);
|
||||
}
|
||||
|
||||
qbyte *D_GetMenuTintPal(void)
|
||||
{
|
||||
if (mtpalremap && mtpalremap != palremaps)
|
||||
return mtpalremap->pal;
|
||||
else
|
||||
|
|
|
@ -120,8 +120,6 @@ static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
|||
int r_skysideimage[6] = {5, 2, 4, 1, 0, 3};
|
||||
extern mtexinfo_t r_skytexinfo[6];
|
||||
|
||||
extern cvar_t gl_skyboxname;
|
||||
|
||||
char skyname[64];
|
||||
|
||||
/*
|
||||
|
@ -129,7 +127,7 @@ char skyname[64];
|
|||
R_LoadSkyBox
|
||||
================
|
||||
*/
|
||||
void R_LoadSkyBox (void)
|
||||
void SWR_LoadSkyBox (void)
|
||||
{
|
||||
#ifdef Q2BSPS
|
||||
void *Mod_LoadWall(char *name);
|
||||
|
@ -167,7 +165,7 @@ void SWR_SetSky (char *name, float rotate, vec3_t axis)
|
|||
r_skytexinfo[i].texture = NULL;
|
||||
}
|
||||
|
||||
R_LoadSkyBox();
|
||||
SWR_LoadSkyBox();
|
||||
}
|
||||
|
||||
qboolean SWR_CheckSky (void)
|
||||
|
@ -259,6 +257,12 @@ void R_InitSkyBox (void)
|
|||
Hunk_Check();
|
||||
}
|
||||
|
||||
void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
Q_strncpyz (skyname, var->string, sizeof(skyname));
|
||||
SWR_LoadSkyBox();
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_EmitSkyBox
|
||||
|
@ -274,13 +278,6 @@ qboolean R_EmitSkyBox (void)
|
|||
if (r_skyframe == r_framecount)
|
||||
return true; // already set this frame
|
||||
|
||||
if (gl_skyboxname.modified)
|
||||
{
|
||||
Q_strncpyz (skyname, gl_skyboxname.string, sizeof(skyname));
|
||||
R_LoadSkyBox();
|
||||
gl_skyboxname.modified = false;
|
||||
}
|
||||
|
||||
if (!*skyname) //none set
|
||||
return false;
|
||||
|
||||
|
|
|
@ -204,8 +204,10 @@ void SWR_InitTextures (void)
|
|||
}*/
|
||||
|
||||
// callback declares
|
||||
extern cvar_t crosshaircolor;
|
||||
extern cvar_t crosshaircolor, r_skyboxname, r_menutint;
|
||||
void SWCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue);
|
||||
|
||||
void SWR_DeInit (void)
|
||||
{
|
||||
|
@ -213,6 +215,8 @@ void SWR_DeInit (void)
|
|||
Cmd_RemoveCommand ("pointfile");
|
||||
|
||||
Cvar_Unhook(&crosshaircolor);
|
||||
Cvar_Unhook(&r_skyboxname);
|
||||
Cvar_Unhook(&r_menutint);
|
||||
|
||||
SWDraw_Shutdown();
|
||||
D_Shutdown();
|
||||
|
@ -235,6 +239,8 @@ void SWR_Init (void)
|
|||
Cmd_AddRemCommand ("timerefresh", SWR_TimeRefresh_f);
|
||||
|
||||
Cvar_Hook(&crosshaircolor, SWCrosshaircolor_Callback);
|
||||
Cvar_Hook(&r_skyboxname, SWR_Skyboxname_Callback);
|
||||
Cvar_Hook(&r_menutint, SWR_Menutint_Callback);
|
||||
|
||||
if (!r_maxedges.value)
|
||||
Cvar_SetValue (&r_maxedges, (float)NUMSTACKEDGES);
|
||||
|
|
Loading…
Reference in a new issue