Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions code/ui/ui_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7789,6 +7789,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
int xPos,textWidth;
vec4_t red;
menuDef_t *parent;
const float tAdjust = DC->frameTime / (1000.0 / UI_TARGET_FPS);
red[0] = red[3] = 1;
red[1] = red[2] = 0;

Expand All @@ -7813,17 +7814,17 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
if (DC->realTime > item->window.nextTime)
{
float rx, ry, a, c, s, w, h;
item->window.nextTime = DC->realTime + item->window.offsetTime;
item->window.nextTime = DC->realTime + (item->window.offsetTime * tAdjust);

@Razish Razish Mar 3, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if also adjusting the debouncer is correct since we're adjusting the translation based on the current frametime / 60fps frametime.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can be sure that most users have exactly 60 fps (vsync with most common displays) or more in the menus, thus this should only decrease the amount of tiggered updates. One could argue that this is bad for higher freqency displays, as the interpolation won't work in this case for the frames in between. Probably better to get rid of it, but I wouldn't mind if menu anmiations are capped at the defined fps.

// translate
w = item->window.rectClient.w / 2;
h = item->window.rectClient.h / 2;
rx = item->window.rectClient.x + w - item->window.rectEffects.x;
ry = item->window.rectClient.y + h - item->window.rectEffects.y;
rx = item->window.rectClient.x + ((w - item->window.rectEffects.x) * tAdjust);
ry = item->window.rectClient.y + ((h - item->window.rectEffects.y) * tAdjust);
a = (float) (3 * M_PI / 180);
c = cos(a);
s = sin(a);
item->window.rectClient.x = (rx * c - ry * s) + item->window.rectEffects.x - w;
item->window.rectClient.y = (rx * s + ry * c) + item->window.rectEffects.y - h;
item->window.rectClient.x = (rx * c - ry * s) + ((item->window.rectEffects.x - w) * tAdjust);
item->window.rectClient.y = (rx * s + ry * c) + ((item->window.rectEffects.y - h) * tAdjust);
Item_UpdatePosition(item);

}
Expand All @@ -7835,7 +7836,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
if (DC->realTime > item->window.nextTime)
{
int done = 0;
item->window.nextTime = DC->realTime + item->window.offsetTime;
item->window.nextTime = DC->realTime + (item->window.offsetTime * tAdjust);

// transition the x,y
if (item->window.rectClient.x == item->window.rectEffects.x)
Expand All @@ -7846,7 +7847,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (item->window.rectClient.x < item->window.rectEffects.x)
{
item->window.rectClient.x += item->window.rectEffects2.x;
item->window.rectClient.x += item->window.rectEffects2.x * tAdjust;
if (item->window.rectClient.x > item->window.rectEffects.x)
{
item->window.rectClient.x = item->window.rectEffects.x;
Expand All @@ -7855,7 +7856,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
item->window.rectClient.x -= item->window.rectEffects2.x;
item->window.rectClient.x -= item->window.rectEffects2.x * tAdjust;
if (item->window.rectClient.x < item->window.rectEffects.x)
{
item->window.rectClient.x = item->window.rectEffects.x;
Expand All @@ -7872,7 +7873,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (item->window.rectClient.y < item->window.rectEffects.y)
{
item->window.rectClient.y += item->window.rectEffects2.y;
item->window.rectClient.y += item->window.rectEffects2.y * tAdjust;
if (item->window.rectClient.y > item->window.rectEffects.y)
{
item->window.rectClient.y = item->window.rectEffects.y;
Expand All @@ -7881,7 +7882,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
item->window.rectClient.y -= item->window.rectEffects2.y;
item->window.rectClient.y -= item->window.rectEffects2.y * tAdjust;
if (item->window.rectClient.y < item->window.rectEffects.y)
{
item->window.rectClient.y = item->window.rectEffects.y;
Expand All @@ -7898,7 +7899,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (item->window.rectClient.w < item->window.rectEffects.w)
{
item->window.rectClient.w += item->window.rectEffects2.w;
item->window.rectClient.w += item->window.rectEffects2.w * tAdjust;
if (item->window.rectClient.w > item->window.rectEffects.w)
{
item->window.rectClient.w = item->window.rectEffects.w;
Expand All @@ -7907,7 +7908,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
item->window.rectClient.w -= item->window.rectEffects2.w;
item->window.rectClient.w -= item->window.rectEffects2.w * tAdjust;
if (item->window.rectClient.w < item->window.rectEffects.w)
{
item->window.rectClient.w = item->window.rectEffects.w;
Expand All @@ -7924,7 +7925,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (item->window.rectClient.h < item->window.rectEffects.h)
{
item->window.rectClient.h += item->window.rectEffects2.h;
item->window.rectClient.h += item->window.rectEffects2.h * tAdjust;
if (item->window.rectClient.h > item->window.rectEffects.h)
{
item->window.rectClient.h = item->window.rectEffects.h;
Expand All @@ -7933,7 +7934,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
item->window.rectClient.h -= item->window.rectEffects2.h;
item->window.rectClient.h -= item->window.rectEffects2.h * tAdjust;
if (item->window.rectClient.h < item->window.rectEffects.h)
{
item->window.rectClient.h = item->window.rectEffects.h;
Expand Down Expand Up @@ -7968,7 +7969,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
if (DC->realTime > item->window.nextTime)
{
int done = 0;
item->window.nextTime = DC->realTime + item->window.offsetTime;
item->window.nextTime = DC->realTime + (item->window.offsetTime * tAdjust);


// transition the x,y,z max
Expand All @@ -7980,7 +7981,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->g2maxs[0] < modelptr->g2maxs2[0])
{
modelptr->g2maxs[0] += modelptr->g2maxsEffect[0];
modelptr->g2maxs[0] += modelptr->g2maxsEffect[0] * tAdjust;
if (modelptr->g2maxs[0] > modelptr->g2maxs2[0])
{
modelptr->g2maxs[0] = modelptr->g2maxs2[0];
Expand All @@ -7989,7 +7990,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->g2maxs[0] -= modelptr->g2maxsEffect[0];
modelptr->g2maxs[0] -= modelptr->g2maxsEffect[0] * tAdjust;
if (modelptr->g2maxs[0] < modelptr->g2maxs2[0])
{
modelptr->g2maxs[0] = modelptr->g2maxs2[0];
Expand All @@ -8006,7 +8007,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->g2maxs[1] < modelptr->g2maxs2[1])
{
modelptr->g2maxs[1] += modelptr->g2maxsEffect[1];
modelptr->g2maxs[1] += modelptr->g2maxsEffect[1] * tAdjust;
if (modelptr->g2maxs[1] > modelptr->g2maxs2[1])
{
modelptr->g2maxs[1] = modelptr->g2maxs2[1];
Expand All @@ -8015,7 +8016,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->g2maxs[1] -= modelptr->g2maxsEffect[1];
modelptr->g2maxs[1] -= modelptr->g2maxsEffect[1] * tAdjust;
if (modelptr->g2maxs[1] < modelptr->g2maxs2[1])
{
modelptr->g2maxs[1] = modelptr->g2maxs2[1];
Expand All @@ -8035,7 +8036,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->g2maxs[2] < modelptr->g2maxs2[2])
{
modelptr->g2maxs[2] += modelptr->g2maxsEffect[2];
modelptr->g2maxs[2] += modelptr->g2maxsEffect[2] * tAdjust;
if (modelptr->g2maxs[2] > modelptr->g2maxs2[2])
{
modelptr->g2maxs[2] = modelptr->g2maxs2[2];
Expand All @@ -8044,7 +8045,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->g2maxs[2] -= modelptr->g2maxsEffect[2];
modelptr->g2maxs[2] -= modelptr->g2maxsEffect[2] * tAdjust;
if (modelptr->g2maxs[2] < modelptr->g2maxs2[2])
{
modelptr->g2maxs[2] = modelptr->g2maxs2[2];
Expand All @@ -8062,7 +8063,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->g2mins[0] < modelptr->g2mins2[0])
{
modelptr->g2mins[0] += modelptr->g2minsEffect[0];
modelptr->g2mins[0] += modelptr->g2minsEffect[0] * tAdjust;
if (modelptr->g2mins[0] > modelptr->g2mins2[0])
{
modelptr->g2mins[0] = modelptr->g2mins2[0];
Expand All @@ -8071,7 +8072,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->g2mins[0] -= modelptr->g2minsEffect[0];
modelptr->g2mins[0] -= modelptr->g2minsEffect[0] * tAdjust;
if (modelptr->g2mins[0] < modelptr->g2mins2[0])
{
modelptr->g2mins[0] = modelptr->g2mins2[0];
Expand All @@ -8088,7 +8089,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->g2mins[1] < modelptr->g2mins2[1])
{
modelptr->g2mins[1] += modelptr->g2minsEffect[1];
modelptr->g2mins[1] += modelptr->g2minsEffect[1] * tAdjust;
if (modelptr->g2mins[1] > modelptr->g2mins2[1])
{
modelptr->g2mins[1] = modelptr->g2mins2[1];
Expand All @@ -8097,7 +8098,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->g2mins[1] -= modelptr->g2minsEffect[1];
modelptr->g2mins[1] -= modelptr->g2minsEffect[1] * tAdjust;
if (modelptr->g2mins[1] < modelptr->g2mins2[1])
{
modelptr->g2mins[1] = modelptr->g2mins2[1];
Expand All @@ -8117,7 +8118,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->g2mins[2] < modelptr->g2mins2[2])
{
modelptr->g2mins[2] += modelptr->g2minsEffect[2];
modelptr->g2mins[2] += modelptr->g2minsEffect[2] * tAdjust;
if (modelptr->g2mins[2] > modelptr->g2mins2[2])
{
modelptr->g2mins[2] = modelptr->g2mins2[2];
Expand All @@ -8126,7 +8127,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->g2mins[2] -= modelptr->g2minsEffect[2];
modelptr->g2mins[2] -= modelptr->g2minsEffect[2] * tAdjust;
if (modelptr->g2mins[2] < modelptr->g2mins2[2])
{
modelptr->g2mins[2] = modelptr->g2mins2[2];
Expand All @@ -8146,7 +8147,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->fov_x < modelptr->fov_x2)
{
modelptr->fov_x += modelptr->fov_Effectx;
modelptr->fov_x += modelptr->fov_Effectx * tAdjust;
if (modelptr->fov_x > modelptr->fov_x2)
{
modelptr->fov_x = modelptr->fov_x2;
Expand All @@ -8155,7 +8156,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->fov_x -= modelptr->fov_Effectx;
modelptr->fov_x -= modelptr->fov_Effectx * tAdjust;
if (modelptr->fov_x < modelptr->fov_x2)
{
modelptr->fov_x = modelptr->fov_x2;
Expand All @@ -8173,7 +8174,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
{
if (modelptr->fov_y < modelptr->fov_y2)
{
modelptr->fov_y += modelptr->fov_Effecty;
modelptr->fov_y += modelptr->fov_Effecty * tAdjust;
if (modelptr->fov_y > modelptr->fov_y2)
{
modelptr->fov_y = modelptr->fov_y2;
Expand All @@ -8182,7 +8183,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}
else
{
modelptr->fov_y -= modelptr->fov_Effecty;
modelptr->fov_y -= modelptr->fov_Effecty * tAdjust;
if (modelptr->fov_y < modelptr->fov_y2)
{
modelptr->fov_y = modelptr->fov_y2;
Expand Down Expand Up @@ -8423,18 +8424,19 @@ void Fade(int *flags, float *f, float clamp, int *nextTime, int offsetTime, qboo
{
if (DC->realTime > *nextTime)
{
*nextTime = DC->realTime + offsetTime;
const float tAdjust = DC->frameTime / (1000.0 / UI_TARGET_FPS);
*nextTime = DC->realTime + (offsetTime * tAdjust);
if (*flags & WINDOW_FADINGOUT)
{
*f -= fadeAmount;
*f -= fadeAmount * tAdjust;
if (bFlags && *f <= 0.0)
{
*flags &= ~(WINDOW_FADINGOUT | WINDOW_VISIBLE);
}
}
else
{
*f += fadeAmount;
*f += fadeAmount * tAdjust;
if (*f >= clamp)
{
*f = clamp;
Expand Down
1 change: 1 addition & 0 deletions code/ui/ui_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum {
SSF_PNG
};

#define UI_TARGET_FPS 60
#define MAX_TOKENLENGTH 1024
#define MAX_OPEN_MENUS 16
#define MAX_TEXTSCROLL_LINES 256
Expand Down
Loading