Client: Move text-menus into their own titles[] channel, so that they don't

overwrite other texts being printed and vice versa.
This commit is contained in:
Marco Cawthorne 2021-01-02 21:22:56 +01:00
parent 6638e7324d
commit 523b1df3de
7 changed files with 64 additions and 59 deletions

View File

@ -23,8 +23,7 @@ bot::Pain(void)
player::Pain();
/* might as well target our attacker */
if (!m_eTarget)
m_eTarget = g_dmg_eAttacker;
m_eTarget = g_dmg_eAttacker;
}
void

View File

@ -122,7 +122,7 @@ void
Way_DeleteNode(int iID)
{
if (iID < 0i || iID >= g_iWaypoints) {
print("RT_DeleteWaypoint: invalid waypoint\n");
print("Way_DeleteNode: invalid waypoint\n");
return;
}
@ -151,7 +151,7 @@ void
Way_SetRadius(int iID, float flRadValue)
{
if (iID < 0i || iID >= g_iWaypoints) {
print("RT_Waypoint_SetRadius: invalid waypoint\n");
print("Way_SetRadius: invalid waypoint\n");
return;
}
g_pWaypoints[iID].m_flRadius = flRadValue;
@ -195,7 +195,7 @@ Way_FlagJump(void)
if (waylink_status == 0) {
way1 = Way_FindClosestNode(self.origin);
waylink_status = 1;
centerprint(self, "Selected first waypoint!\n");
env_message_single(self, "^2Selected first waypoint!\n");
} else if (waylink_status == 1) {
way2 = Way_FindClosestNode(self.origin);
waylink_status = 0;
@ -204,11 +204,11 @@ Way_FlagJump(void)
for (int b = 0i; b < g_pWaypoints[way1].m_numNeighbours; b++) {
if (g_pWaypoints[way1].m_pNeighbour[b].m_iNode == way2) {
g_pWaypoints[way1].m_pNeighbour[b].m_iFlags |= LF_JUMP;
env_message_single(self, "Jump-linked the two points!\n");
env_message_single(self, "^2Jump-linked the two points!\n");
}
}
} else {
centerprint(self, "Failed to link, the two points are the same!\n");
env_message_single(self, "^1Failed to link, the two points are the same!\n");
}
}
}
@ -222,7 +222,7 @@ Way_FlagCrouch(void)
if (waylink_status == 0) {
way1 = Way_FindClosestNode(self.origin);
waylink_status = 1;
centerprint(self, "Selected first waypoint!\n");
env_message_single(self, "^2Selected first waypoint!\n");
} else if (waylink_status == 1) {
way2 = Way_FindClosestNode(self.origin);
waylink_status = 0;
@ -231,11 +231,11 @@ Way_FlagCrouch(void)
for (int b = 0i; b < g_pWaypoints[way1].m_numNeighbours; b++) {
if (g_pWaypoints[way1].m_pNeighbour[b].m_iNode == way2) {
g_pWaypoints[way1].m_pNeighbour[b].m_iFlags |= LF_CROUCH;
env_message_single(self, "Crouch-linked the two points!\n");
env_message_single(self, "^2Crouch-linked the two points!\n");
}
}
} else {
centerprint(self, "Failed to link, the two points are the same!\n");
env_message_single(self, "^1Failed to link, the two points are the same!\n");
}
}
}
@ -249,7 +249,7 @@ Way_FlagWalk(void)
if (waylink_status == 0) {
way1 = Way_FindClosestNode(self.origin);
waylink_status = 1;
env_message_single(self, "Selected first waypoint!\n");
env_message_single(self, "^2Selected first waypoint!\n");
} else if (waylink_status == 1) {
way2 = Way_FindClosestNode(self.origin);
waylink_status = 0;
@ -258,11 +258,11 @@ Way_FlagWalk(void)
for (int b = 0i; b < g_pWaypoints[way1].m_numNeighbours; b++) {
if (g_pWaypoints[way1].m_pNeighbour[b].m_iNode == way2) {
g_pWaypoints[way1].m_pNeighbour[b].m_iFlags |= LF_WALK;
env_message_single(self, "Walk-linked the two points!\n");
env_message_single(self, "^2Walk-linked the two points!\n");
}
}
} else {
env_message_single(self, "Failed to link, the two points are the same!\n");
env_message_single(self, "^1Failed to link, the two points are the same!\n");
}
}
}
@ -300,14 +300,14 @@ Way_SaveFile(string filename)
filestream file;
if (!g_iWaypoints) {
centerprint(self, "^1ERROR: Tried to save empty waypoints.\n");
env_message_single(self, "^1ERROR: Tried to save empty waypoints.\n");
return;
}
file = fopen(filename, FILE_WRITE);
if (file < 0) {
print("RT_DumpWaypoints: unable to open ", filename, "\n");
print("Way_SaveFile: unable to open ", filename, "\n");
return;
}
@ -329,7 +329,7 @@ Way_ReadFile(string strFile)
{
float file = fopen(strFile, FILE_READ);
if (file < 0) {
print("Way_SaveFile: unable to open ", strFile, "\n");
print("Way_ReadFile: unable to open ", strFile, "\n");
return;
}
@ -368,16 +368,16 @@ Way_ConnectOne(void)
if (waylink_status == 0) {
way1 = Way_FindClosestNode(self.origin);
waylink_status = 1;
env_message_single(self, "Selected first waypoint!\n");
env_message_single(self, "^21/2 nodes selected... \n");
} else if (waylink_status == 1) {
way2 = Way_FindClosestNode(self.origin);
waylink_status = 0;
if (way1 != way2) {
Way_LinkNodes(&g_pWaypoints[way1], &g_pWaypoints[way2]);
env_message_single(self, "Linked first waypoint with second waypoint!\n");
env_message_single(self, "^22/2 nodes selected, done!\n");
} else {
env_message_single(self, "Failed to link, the two points are the same!\n");
env_message_single(self, "^1Failed to link, the two points are the same!\n");
}
}
}
@ -391,7 +391,7 @@ Way_ConnectTwo(void)
if (waylink_status == 0) {
way1 = Way_FindClosestNode(self.origin);
waylink_status = 1;
env_message_single(self, "Selected first waypoint!\n");
env_message_single(self, "^21/2 nodes selected... \n");
} else if (waylink_status == 1) {
way2 = Way_FindClosestNode(self.origin);
waylink_status = 0;
@ -399,9 +399,9 @@ Way_ConnectTwo(void)
if (way1 != way2) {
Way_LinkNodes(&g_pWaypoints[way1], &g_pWaypoints[way2]);
Way_LinkNodes(&g_pWaypoints[way2], &g_pWaypoints[way1]);
env_message_single(self, "Linked first waypoint with second waypoint!\n");
env_message_single(self, "^22/2 nodes selected, done!\n");
} else {
env_message_single(self, "Failed to link, the two points are the same!\n");
env_message_single(self, "^1Failed to link, the two points are the same!\n");
}
}
}

View File

@ -84,7 +84,7 @@ drawstring_r(vector p, string t, vector s, vector c, float a, float f)
drawstring(p, t, s, c, a, f);
}
void GameMessage_Setup(string);
void GameMessage_Setup(string, int);
void Game_Input(void);
void View_SetMuzzleflash(int);
void View_PlayAnimation(int);

View File

@ -653,7 +653,7 @@ CSQC_ConsoleCommand(string sCMD)
CMap_Build();
break;
case "titles_test":
GameMessage_Setup(argv(1));
GameMessage_Setup(argv(1), 0);
break;
case "vox_test":
Vox_Play(sCMD);

View File

@ -28,7 +28,7 @@ typedef struct
float m_flFXTime;
float m_flTime;
} gametext_t;
gametext_t g_textchannels[5];
gametext_t g_textchannels[6];
/* for effect 2 */
int
@ -134,7 +134,7 @@ GameText_Draw(void)
{
drawfont = FONT_20;
for (int i = 0; i < 5; i++) {
for (int i = 0i; i < 6; i++) {
GameText_DrawMessage(i, g_textchannels[i].m_flTime - g_textchannels[i].m_flFXTime, 0);
GameText_DrawMessage(i, g_textchannels[i].m_flTime, 1);
g_textchannels[i].m_flTime += clframetime;
@ -147,6 +147,12 @@ void
GameText_Parse(void)
{
int chan = readbyte();
/* last channel is reserved for text menus */
if (!(chan >= 0 && chan <= 4)) {
return;
}
g_textchannels[chan].m_strMessage = Titles_ParseFunString(readstring());
g_textchannels[chan].m_flPosX = readfloat();
g_textchannels[chan].m_flPosY = readfloat();
@ -165,7 +171,7 @@ GameText_Parse(void)
}
void
GameMessage_Setup(string message)
GameMessage_Setup(string message, int channel)
{
int findid = -1;
@ -176,26 +182,26 @@ GameMessage_Setup(string message)
}
if (findid < 0) {
g_textchannels[0].m_strMessage = Titles_ParseFunString(message);
g_textchannels[0].m_flTime = 0.0f;
g_textchannels[0].m_flPosX = -1;
g_textchannels[0].m_flPosY = 0.75f;
g_textchannels[0].m_flFadeIn = 0.5f;
g_textchannels[0].m_flFadeOut = 0.5f;
g_textchannels[0].m_flHoldTime = 4.0f;
g_textchannels[0].m_vecColor1 = [1,1,1];
g_textchannels[0].m_vecColor2 = [1,1,1];
g_textchannels[channel].m_strMessage = Titles_ParseFunString(message);
g_textchannels[channel].m_flTime = 0.0f;
g_textchannels[channel].m_flPosX = -1;
g_textchannels[channel].m_flPosY = 0.75f;
g_textchannels[channel].m_flFadeIn = 0.5f;
g_textchannels[channel].m_flFadeOut = 0.5f;
g_textchannels[channel].m_flHoldTime = 2.0f;
g_textchannels[channel].m_vecColor1 = [1,1,1];
g_textchannels[channel].m_vecColor2 = [1,1,1];
} else {
g_textchannels[0].m_strMessage = g_titles[findid].m_strMessage;
g_textchannels[0].m_flTime = 0.0f;
g_textchannels[0].m_flPosX = g_titles[findid].m_flPosX;
g_textchannels[0].m_flPosY = g_titles[findid].m_flPosY;
g_textchannels[0].m_flFadeIn = g_titles[findid].m_flFadeIn;
g_textchannels[0].m_flFadeOut = g_titles[findid].m_flFadeOut;
g_textchannels[0].m_flHoldTime = g_titles[findid].m_flHoldTime;
g_textchannels[0].m_vecColor1 = g_titles[findid].m_vecColor1;
g_textchannels[0].m_vecColor2 = g_titles[findid].m_vecColor2;
g_textchannels[0].m_iEffect = g_titles[findid].m_iEffect;
g_textchannels[channel].m_strMessage = g_titles[findid].m_strMessage;
g_textchannels[channel].m_flTime = 0.0f;
g_textchannels[channel].m_flPosX = g_titles[findid].m_flPosX;
g_textchannels[channel].m_flPosY = g_titles[findid].m_flPosY;
g_textchannels[channel].m_flFadeIn = g_titles[findid].m_flFadeIn;
g_textchannels[channel].m_flFadeOut = g_titles[findid].m_flFadeOut;
g_textchannels[channel].m_flHoldTime = g_titles[findid].m_flHoldTime;
g_textchannels[channel].m_vecColor1 = g_titles[findid].m_vecColor1;
g_textchannels[channel].m_vecColor2 = g_titles[findid].m_vecColor2;
g_textchannels[channel].m_iEffect = g_titles[findid].m_iEffect;
}
}
@ -208,7 +214,7 @@ GameMessage_Parse(void)
string findme;
findme = strtoupper(readstring());
GameMessage_Setup(findme);
GameMessage_Setup(findme, 0);
strSound = readstring();
flVolume = readfloat();

View File

@ -20,7 +20,7 @@ void
Textmenu_Call(string menu)
{
g_textmenu = menu;
g_textchannels[0].m_flTime = 0.0f;
g_textchannels[5].m_flTime = 0.0f;
g_textmenucheck = 0.0f;
}
@ -32,16 +32,16 @@ Textmenu_Draw(void)
}
if (g_textmenu) {
GameMessage_Setup(g_textmenu);
g_textchannels[0].m_flTime = 0.0f;
g_textchannels[0].m_flPosX = 0.1;
g_textchannels[0].m_flPosY = -1;
g_textchannels[0].m_flFadeIn =
g_textchannels[0].m_flFadeOut = 0.0f;
g_textchannels[0].m_flHoldTime = 0.5;
g_textchannels[0].m_vecColor1 = [1,1,1];
g_textchannels[0].m_vecColor2 = [0,0,0];
g_textchannels[0].m_iEffect = 0;
GameMessage_Setup(g_textmenu, 5);
g_textchannels[5].m_flTime = 0.0f;
g_textchannels[5].m_flPosX = 0.1;
g_textchannels[5].m_flPosY = -1;
g_textchannels[5].m_flFadeIn =
g_textchannels[5].m_flFadeOut = 0.0f;
g_textchannels[5].m_flHoldTime = 0.5;
g_textchannels[5].m_vecColor1 = [1,1,1];
g_textchannels[5].m_vecColor2 = [0,0,0];
g_textchannels[5].m_iEffect = 0;
g_textmenucheck = cltime + 0.5;
}
}

View File

@ -56,7 +56,7 @@ void worldspawn::SpawnKey(string strField, string strKey)
{
switch (strField) {
case "chaptertitle":
GameMessage_Setup(strKey);
GameMessage_Setup(strKey, 0);
break;
case "skyname":
g_strSkyName = strKey;