Make menuqc respect qs's scr_menuscale cvar instead of scr_sbarscale.

This commit is contained in:
Shpoike 2020-07-19 01:42:15 +01:00
parent 5842eb70e8
commit 8b6737a436
6 changed files with 56 additions and 9 deletions

View file

@ -826,6 +826,12 @@ void GL_SetCanvas (canvastype newcanvas)
glOrtho (0, 640, 200, 0, -99999, 99999);
glViewport (glx + (glwidth - 320*s) / 2, gly + (glheight - 200*s) / 2, 640*s, 200*s);
break;
case CANVAS_MENUQC:
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
glOrtho (0, glwidth/s, glheight/s, 0, -99999, 99999);
glViewport (glx, gly, glwidth, glheight);
break;
case CANVAS_CSQC:
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
glOrtho (0, glwidth/s, glheight/s, 0, -99999, 99999);

View file

@ -495,7 +495,9 @@ void IN_MouseMotion(int dx, int dy, int wx, int wy)
PR_SwitchQCVM(&cls.menu_qcvm);
if (qcvm->cursorforced)
{
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
float s;
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
wx /= s;
wy /= s;

View file

@ -2863,7 +2863,8 @@ void M_Draw (void)
{
if (cls.menu_qcvm.extfuncs.m_draw)
{ //Spike -- menuqc
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
float s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
if (!host_initialized)
return;
MQC_Begin();
@ -2875,7 +2876,7 @@ void M_Draw (void)
S_ExtraUpdate ();
}
GL_SetCanvas (CANVAS_CSQC);
GL_SetCanvas (CANVAS_MENUQC);
glEnable (GL_BLEND); //in the finest tradition of glquake, we litter gl state calls all over the place. yay state trackers.
glDisable (GL_ALPHA_TEST); //in the finest tradition of glquake, we litter gl state calls all over the place. yay state trackers.
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

View file

@ -2084,15 +2084,28 @@ static void PF_clientstate (void)
static void PF_cvar_menuhack (void)
{ //hack around menuqc expecting vid_conwidth/vid_conheight to work.
const char *str = G_STRING(OFS_PARM0);
float s;
if (!strcmp(str, "vid_conwidth"))
{
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
if (qcvm == &cls.menu_qcvm)
{
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
}
else
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
G_FLOAT(OFS_RETURN) = vid.width/s;
}
else if (!strcmp(str, "vid_conheight"))
{
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
if (qcvm == &cls.menu_qcvm)
{
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
}
else
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
G_FLOAT(OFS_RETURN) = vid.height/s;
}
else

View file

@ -4824,7 +4824,14 @@ static void PF_cl_stringwidth(void)
static void PF_cl_drawsetclip(void)
{
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
float s;
if (qcvm == &cls.menu_qcvm)
{
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
}
else
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
float x = G_FLOAT(OFS_PARM0)*s;
float y = G_FLOAT(OFS_PARM1)*s;
@ -5380,7 +5387,14 @@ static void PF_m_getkeydest(void)
}
static void PF_m_getmousepos(void)
{
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
float s;
if (qcvm == &cls.menu_qcvm)
{
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
}
else
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
G_FLOAT(OFS_RETURN+0) = vid.cursorpos[0]/s;
G_FLOAT(OFS_RETURN+1) = vid.cursorpos[1]/s;
@ -5886,7 +5900,14 @@ void R_RenderScene (void);
float CalcFovy (float fov_x, float width, float height);
static void PF_m_renderscene(void)
{
float s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
float s;
if (qcvm == &cls.menu_qcvm)
{
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
s = CLAMP (1.0, scr_menuscale.value, s);
}
else
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
VectorCopy(viewprops.origin, r_refdef.vieworg);
VectorCopy(viewprops.angles, r_refdef.viewangles);
@ -5912,6 +5933,9 @@ static void PF_m_renderscene(void)
vid.recalc_refdef = true;
GL_Set2D();
if (qcvm == &cls.menu_qcvm)
GL_SetCanvas (CANVAS_MENUQC);
else
GL_SetCanvas (CANVAS_CSQC);
glEnable (GL_BLEND);
glDisable (GL_ALPHA_TEST);

View file

@ -69,6 +69,7 @@ typedef enum {
CANVAS_BOTTOMRIGHT,
CANVAS_TOPRIGHT,
CANVAS_CSQC,
CANVAS_MENUQC,
CANVAS_INVALID = -1
} canvastype;
extern cvar_t scr_menuscale;