# HG changeset patch # User Adam Kaminski # Date 1619382556 14400 # Sun Apr 25 16:29:16 2021 -0400 # Node ID 0e511c679c4106f7479ffe22541b194c35c40468 # Parent 7dec2d8e9d7ab17573e349e10fc2901c95cdeecf The chat cursor now blinks while the client is typing a message. diff -r 7dec2d8e9d7a -r 0e511c679c41 src/chat.cpp --- a/src/chat.cpp Tue Apr 20 01:09:16 2021 -0400 +++ b/src/chat.cpp Sun Apr 25 16:29:16 2021 -0400 @@ -131,6 +131,9 @@ // [AK] The index of the player we're sending a private chat message to. static ULONG g_ulChatPlayer = 0; +// [AK] A ticker that's used for controlling the blink of the cursor. +static ULONG g_ulChatTicker = 0; + // [AK] A collection of previously sent chat message from each player plus the server. static RingBuffer g_SavedChatMessages[MAXPLAYERS + 1]; @@ -367,6 +370,9 @@ if ( IsInTabCompletion == false ) ResetTabCompletion(); + + // [AK] Ensure that the cursor is always white while typing. + g_ulChatTicker = 0; } //***************************************************************************** @@ -546,6 +552,10 @@ } } + // [AK] Reset the chat cursor's ticker if it goes too high. + if (( g_ulChatMode != CHATMODE_NONE ) && ( ++g_ulChatTicker >= TICRATE )) + g_ulChatTicker = 0; + // [AK] If we're typing a chat message to another player, we must constantly check if // they're in the game. If not, cancel the message entirely. if ( g_ulChatMode == CHATMODE_PRIVATE_SEND ) @@ -695,7 +705,7 @@ void CHAT_Render( void ) { FString prompt = "Say: "; - static const char *cursor = gameinfo.gametype == GAME_Doom ? "_" : "["; + FString cursor = gameinfo.gametype == GAME_Doom ? "_" : "["; bool scale = ( con_scaletext ) && ( con_virtualwidth > 0 ) && ( con_virtualheight > 0 ); float scaleX = 1.0f; float scaleY = 1.0f; @@ -721,6 +731,13 @@ int chatWidth = static_cast ( SCREENWIDTH * scaleX ); chatWidth -= static_cast ( round( SmallFont->GetCharWidth( '_' ) * scaleX * 2 + SmallFont->StringWidth( prompt )) ); + // [AK] Also blink the cursor between black and white. + if ( g_ulChatTicker >= C_BLINKRATE ) + { + cursor.Insert( 0, TEXTCOLOR_BLACK ); + cursor += TEXTCOLOR_GRAY; + } + // Build the message that we will display to clients. FString displayString = g_ChatBuffer.GetMessage(); // Insert the cursor string into the message. @@ -1009,6 +1026,9 @@ // Tell the server we're beginning to chat. if ( NETWORK_GetState( ) == NETSTATE_CLIENT ) CLIENTCOMMANDS_StartChat( ); + + // [AK] Ensure that the cursor starts off as white. + g_ulChatTicker = 0; } else {