Merge branch 'main' of https://github.com/nzp-team/glquake into swkbd

This commit is contained in:
Ian 2023-11-12 15:12:17 -05:00
commit f88c35ae1f
6 changed files with 176 additions and 26 deletions

View file

@ -66,6 +66,7 @@ int x_value, y_value;
void M_DrawPic (int x, int y, qpic_t *pic); void M_DrawPic (int x, int y, qpic_t *pic);
double HUD_Change_time;//hide hud when not chagned double HUD_Change_time;//hide hud when not chagned
double bettyprompt_time;
extern cvar_t waypoint_mode; extern cvar_t waypoint_mode;
@ -573,6 +574,7 @@ float color_shift_end[3];
float color_shift_steps[3]; float color_shift_steps[3];
int color_shift_init; int color_shift_init;
int blinking; int blinking;
float endroundchange;
int textstate; int textstate;
int value, value2; int value, value2;
@ -753,8 +755,16 @@ void HUD_Rounds (void)
} }
else if (cl.stats[STAT_ROUNDCHANGE] == 4)//blink white else if (cl.stats[STAT_ROUNDCHANGE] == 4)//blink white
{ {
blinking = ((int)(realtime*1000)&510) - 255; if (endroundchange > cl.time) {
blinking = (((int)(realtime*475)&510) - 255);
blinking = abs(blinking); blinking = abs(blinking);
} else {
if (blinking)
blinking = blinking - 1;
else
blinking = 0;
}
if (cl.stats[STAT_ROUNDS] > 0 && cl.stats[STAT_ROUNDS] < 11) if (cl.stats[STAT_ROUNDS] > 0 && cl.stats[STAT_ROUNDS] < 11)
{ {
for (i = 0; i < cl.stats[STAT_ROUNDS]; i++) for (i = 0; i < cl.stats[STAT_ROUNDS]; i++)
@ -804,6 +814,11 @@ void HUD_Rounds (void)
Draw_ColorPic (2 + x_offset, vid.height - sb_round_num[num[0]]->height - 4, sb_round_num[num[0]], 255, 255, 255, blinking); Draw_ColorPic (2 + x_offset, vid.height - sb_round_num[num[0]]->height - 4, sb_round_num[num[0]], 255, 255, 255, blinking);
x_offset = x_offset + sb_round_num[num[0]]->width - 8; x_offset = x_offset + sb_round_num[num[0]]->width - 8;
} }
if (endroundchange == 0) {
endroundchange = cl.time + 7.5;
blinking = 0;
}
} }
else if (cl.stats[STAT_ROUNDCHANGE] == 5)//blink white else if (cl.stats[STAT_ROUNDCHANGE] == 5)//blink white
{ {
@ -863,9 +878,16 @@ void HUD_Rounds (void)
} }
else if (cl.stats[STAT_ROUNDCHANGE] == 6)//blink white while fading back else if (cl.stats[STAT_ROUNDCHANGE] == 6)//blink white while fading back
{ {
if (endroundchange) {
endroundchange = 0;
blinking = 0;
}
color_shift_init = 0; color_shift_init = 0;
blinking = ((int)(realtime*1000)&510) - 255;
blinking = abs(blinking); blinking += (int)(host_frametime*475);
if (blinking > 255) blinking = 255;
if (cl.stats[STAT_ROUNDS] > 0 && cl.stats[STAT_ROUNDS] < 11) if (cl.stats[STAT_ROUNDS] > 0 && cl.stats[STAT_ROUNDS] < 11)
{ {
for (i = 0; i < cl.stats[STAT_ROUNDS]; i++) for (i = 0; i < cl.stats[STAT_ROUNDS]; i++)
@ -1348,6 +1370,28 @@ void HUD_Weapon (void)
Draw_String (x_value, y_value, str); Draw_String (x_value, y_value, str);
} }
/*
===============
HUD_BettyPrompt
===============
*/
void HUD_BettyPrompt (void)
{
char str[32];
char str2[32];
strcpy(str, va("Tap SWAP then press %s to\n", GetGrenadeButtonL()));
strcpy(str2, "place a Bouncing Betty\n");
int x, x2;
x = (vid.width - strlen(str)*8)/2;
x2 = (vid.width - strlen(str2)*8)/2;
Draw_String(x, 60, str);
Draw_String(x2, 72, str2);
Draw_Pic (x + 20*8 - 4, 56, GetButtonIcon("+grenade"));
}
/* /*
=============== ===============
HUD_Draw HUD_Draw
@ -1383,6 +1427,9 @@ void HUD_Draw (void)
return; return;
} }
if (bettyprompt_time > sv.time)
HUD_BettyPrompt();
HUD_Blood(); HUD_Blood();
HUD_Rounds(); HUD_Rounds();
HUD_Perks(); HUD_Perks();

View file

@ -1021,7 +1021,7 @@ void CL_ParseLimbUpdate (void)
#define SHOWNET(x) if(cl_shownet.value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x); #define SHOWNET(x) if(cl_shownet.value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x);
extern double bettyprompt_time;
void CL_ParseServerMessage (void) void CL_ParseServerMessage (void)
{ {
int cmd; int cmd;
@ -1115,6 +1115,10 @@ void CL_ParseServerMessage (void)
crosshair_pulse_grenade = true; crosshair_pulse_grenade = true;
break; break;
case svc_bettyprompt:
bettyprompt_time = sv.time + 4;
break;
case svc_stufftext: case svc_stufftext:
Cbuf_AddText (MSG_ReadString ()); Cbuf_AddText (MSG_ReadString ());
break; break;

View file

@ -339,6 +339,32 @@ char *GetUseButtonL ()
return " "; return " ";
} }
char *GetGrenadeButtonL ()
{
int j;
int l;
char *b;
l = strlen("+grenade");
for (j=0 ; j<256 ; j++)
{
b = keybindings[j];
if (!b)
continue;
if (!strncmp (b, "+grenade", l) )
{
if (!strcmp(Key_KeynumToString(j), "SELECT") ||
!strcmp(Key_KeynumToString(j), "LTRIGGER") ||
!strcmp(Key_KeynumToString(j), "RTRIGGER") ||
!strcmp(Key_KeynumToString(j), "HOME"))
return " ";
else
return " ";
}
}
return " ";
}
char *GetPerkName (int perk) char *GetPerkName (int perk)
{ {
switch (perk) switch (perk)

View file

@ -1231,26 +1231,40 @@ string strtrim (string)
*/ */
void PF_strtrim (void) void PF_strtrim (void)
{ {
char *m; int offset, length;
m = G_STRING(OFS_PARM0); int maxoffset; // 2001-10-25 Enhanced temp string handling by Maddes
char *str;
char *end;
char *c; str = G_STRING(OFS_PARM0);
c = m;
while (c != '\0' && *c == ' ') // figure out the new start
c++; while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r') {
m = c; offset++;
str++;
c = m + strlen (m) - 1;
while (c >= m)
{
if (*c == ' ')
*c = '\0';
else
break;
c--;
} }
G_INT(OFS_RETURN) = m - pr_strings;
// figure out the new end.
end = str + strlen (str);
while (end > str && (end[-1] == ' ' || end[-1] == '\t' || end[-1] == '\n' || end[-1] == '\r'))
end--;
length = end - str;
if (offset < 0)
offset = 0;
// 2001-10-25 Enhanced temp string handling by Maddes start
if (length >= PR_MAX_TEMPSTRING)
length = PR_MAX_TEMPSTRING-1;
// 2001-10-25 Enhanced temp string handling by Maddes end
if (length < 0)
length = 0;
//str += offset;
strncpy(pr_string_temp, str, length);
pr_string_temp[length] = 0;
G_INT(OFS_RETURN) = pr_string_temp - pr_strings;
}; };
/* /*
@ -1312,6 +1326,36 @@ void PF_strcat (void)
G_INT(OFS_RETURN) = pr_string_temp - pr_strings; G_INT(OFS_RETURN) = pr_string_temp - pr_strings;
} }
/*
=================
PF_strtolower
string strtolower (string)
=================
*/
void PF_strtolower(void)
{
char *s;
s = G_STRING(OFS_PARM0);
pr_string_temp[0] = 0;
if (strlen(s) < PR_MAX_TEMPSTRING)
{
strcpy(pr_string_temp, s);
}
else
{
strncpy(pr_string_temp, s, PR_MAX_TEMPSTRING);
pr_string_temp[PR_MAX_TEMPSTRING-1] = 0;
}
for(int i = 0; i < strlen(s); i++)
pr_string_temp[i] = tolower(pr_string_temp[i]);
G_INT(OFS_RETURN) = pr_string_temp - pr_strings;
}
/* /*
================= =================
PF_substring PF_substring
@ -3231,6 +3275,31 @@ void PF_GrenadePulse(void)
MSG_WriteByte (&client->message,svc_pulse); MSG_WriteByte (&client->message,svc_pulse);
} }
/*
=================
PF_BettyPrompt
draws status on hud on
how to use bouncing
betty.
nzp_bettyprompt()
=================
*/
void PF_BettyPrompt(void)
{
client_t *client;
int entnum;
entnum = G_EDICTNUM(OFS_PARM0);
if (entnum < 1 || entnum > svs.maxclients)
return;
client = &svs.clients[entnum-1];
MSG_WriteByte (&client->message, svc_bettyprompt);
}
/* /*
================= =================
PF_MaxZombies PF_MaxZombies
@ -3824,7 +3893,7 @@ PF_Fixme,
PF_Fixme, PF_Fixme,
PF_Fixme, PF_Fixme,
PF_Fixme, PF_Fixme,
PF_Fixme, PF_strtolower, // #480
PF_Fixme, PF_Fixme,
PF_Fixme, PF_Fixme,
PF_Fixme, PF_Fixme,
@ -3848,6 +3917,7 @@ PF_SongEgg, // #500
PF_MaxAmmo, // #501 PF_MaxAmmo, // #501
PF_GrenadePulse, // #502 PF_GrenadePulse, // #502
PF_MaxZombies, // #503 PF_MaxZombies, // #503
PF_BettyPrompt, // #504
PF_Fixme, PF_Fixme,
}; };

View file

@ -151,6 +151,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define svc_songegg 44 // [string] track name #define svc_songegg 44 // [string] track name
#define svc_maxammo 45 #define svc_maxammo 45
#define svc_pulse 46 #define svc_pulse 46
#define svc_bettyprompt 47
// //
// client to server // client to server

View file

@ -29,6 +29,8 @@ void SCR_SizeDown (void);
void SCR_BringDownConsole (void); void SCR_BringDownConsole (void);
void SCR_CenterPrint (char *str); void SCR_CenterPrint (char *str);
void SCR_UsePrint (int type, int cost, int weapon); void SCR_UsePrint (int type, int cost, int weapon);
qpic_t *GetButtonIcon (char *buttonname);
char *GetGrenadeButtonL();
void SCR_BeginLoadingPlaque (void); void SCR_BeginLoadingPlaque (void);
void SCR_EndLoadingPlaque (void); void SCR_EndLoadingPlaque (void);