FTE: Report menu status to other clients and draw on HUD

This commit is contained in:
MotoLegacy 2024-01-11 10:40:10 -05:00
parent 238e9d995d
commit a41eeb23c6
6 changed files with 33 additions and 5 deletions

View file

@ -2249,7 +2249,7 @@ string(string cvarname) cvar_description = #518; /*
float(optional float timetype) gettime = #519;
DEP string(float keynum) keynumtostring_omgwtf = #520;
__deprecated("Does not support modifiers") string(string command, optional float bindmap) findkeysforcommand = #521; /*
string(string command, optional float bindmap) findkeysforcommand = #521; /*
Returns a list of keycodes that perform the given console command in a format that can only be parsed via tokenize (NOT tokenize_console). This only and always returns two values - if only one key is actually bound, -1 will be returned. The bindmap argument is listed for compatibility with dp-specific defs, but is ignored in FTE. */
string(string command, optional float bindmap) findkeysforcommandex = #0:findkeysforcommandex; /*

View file

@ -1585,6 +1585,18 @@ void(float width, float height) HUD_PlayerNames =
float player_number = getplayerkeyfloat(i, "viewentity");
string text = getplayerkeyvalue(i, "name");
entity client = findfloat(world, playernum, player_number);
if (client == world || client.movetype == MOVETYPE_BOUNCE)
continue;
// Append "[CHAT] " to the player name if the user is in message mode
if (client.is_in_menu == 2)
text = strcat("[CHAT] ", text);
// Similarly, append "[PAUSED] " to the player name if the user is paused
else if (client.is_in_menu == 1)
text = strcat("[PAUSED] ", text);
entity plr = findfloat(world, playernum, player_number);
vector player_origin = plr.origin + '0 0 48';
vector screen_position = project(player_origin);

View file

@ -559,6 +559,7 @@ noref void(float isnew) CSQC_Ent_Update =
self.stance = readbyte();
self.points = readfloat(); // FIXME: this should be made a short, but I know we use price of 1 for some test maps, so I can't do /10 *10 shenanigans.
self.kills = readshort();
self.is_in_menu = readbyte();
RegisterPointChange(self.points - old_points, self.playernum);
@ -990,11 +991,13 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
{
//in menu.qc
Draw_Menu();
setlocaluserinfo(0, "in_menu", "1");
}
else
{
HUD_Draw(g_width, g_height);
Chat_Draw();
setlocaluserinfo(0, "in_menu", "0");
}
};
@ -1041,19 +1044,19 @@ noref float(string cmd) CSQC_ConsoleCommand =
void(float scanx, float setval) Input_Movecheck =
{
tokenize(findkeysforcommandex("+moveleft"));
tokenize(findkeysforcommand("+moveleft"));
if (scanx == stof(argv(0)))
K_LEFTDOWN = setval;
tokenize(findkeysforcommandex("+moveright"));
tokenize(findkeysforcommand("+moveright"));
if (scanx == stof(argv(0)))
K_RIGHTDOWN = setval;
tokenize(findkeysforcommandex("+forward"));
tokenize(findkeysforcommand("+forward"));
if (scanx == stof(argv(0)))
K_FORWARDDOWN = setval;
tokenize(findkeysforcommandex("+back"));
tokenize(findkeysforcommand("+back"));
if (scanx == stof(argv(0)))
K_BACKDOWN = setval;
}

View file

@ -614,6 +614,7 @@ float Player_SendEntity( entity ePVEnt, float flChanged ) {
WriteByte( MSG_ENTITY, self.stance ); // Player Stance
WriteFloat( MSG_ENTITY, self.points ); // Player Score
WriteShort( MSG_ENTITY, self.kills ); // Player Kills
WriteByte( MSG_ENTITY, self.is_in_menu ); // Player is in a Menu State
return TRUE;
}

View file

@ -548,6 +548,13 @@ void() PlayerPostThink =
// Network everything
self.SendFlags = 1;
// Obtain menu state from CSQC via infokeys.
self.is_in_menu = stof(infokey(self, "in_menu"));
if (self.is_in_menu != 1)
if (infokey(self, "chat") == "1")
self.is_in_menu = 2;
#endif // FTE
@ -997,6 +1004,7 @@ void() ClientDisconnect =
// Network everything
self.SendFlags = 1;
self.is_in_menu = 0;
#endif // FTE
};

View file

@ -263,6 +263,10 @@ float map_compatibility_mode;
.float playernum;
float game_over;
#ifdef FTE
.float is_in_menu;
#endif // FTE
//
// invert float takes in float value between 0 and 1, inverts position
// eg: 0.1 returns 0.9, 0.34 returns 0.66