# HG changeset patch # User Adam Kaminski # Date 1623433404 14400 # Fri Jun 11 13:43:24 2021 -0400 # Node ID 6f5b5f2dbc103937856bd1ca5222aa4475c1fe01 # Parent a11fe289b542220fa159dfd467d1b158a89d5ed0 Limit strings on the scoreboard are now appended after each other to condense the height of the scoreboard's header as much as possible. diff -r a11fe289b542 -r 6f5b5f2dbc10 src/scoreboard.cpp --- a/src/scoreboard.cpp Fri Jun 11 12:14:08 2021 -0400 +++ b/src/scoreboard.cpp Fri Jun 11 13:43:24 2021 -0400 @@ -1687,19 +1687,56 @@ } //***************************************************************************** +// [AK] Checks if we can append this limit string to the previous one. +// +void scoreboard_AppendLimit( std::list &lines, FString &limit ) +{ + // [AK] This shouldn't be done on the server console and there must already be a limit on the list. + if (( NETWORK_GetState( ) != NETSTATE_SERVER ) && ( lines.empty( ) == false )) + { + FString prevLimitString = lines.back( ); + lines.pop_back( ); + + prevLimitString += TEXTCOLOR_DARKGRAY " - " TEXTCOLOR_NORMAL; + limit.Insert( 0, prevLimitString ); + } +} + +//***************************************************************************** // [RC] Helper method for SCOREBOARD_BuildLimitStrings. Creates a "x things remaining" message. +// [AK] Added the bAppend parameter to append a limit string to a previous one. // -void scoreboard_AddSingleLimit( std::list &lines, bool condition, int remaining, const char *pszUnitName ) +void scoreboard_AddSingleLimit( std::list &lines, bool condition, int remaining, const char *pszUnitName, bool bAppend = false ) { if ( condition && remaining > 0 ) { FString limitString; limitString.Format( "%d %s%s left", static_cast( remaining ), pszUnitName, remaining == 1 ? "" : "s" ); + + // [AK] Try to append this limit with the previous one. + if ( bAppend ) + scoreboard_AppendLimit( lines, limitString ); + lines.push_back( limitString ); } } //***************************************************************************** +// [AK] Creates the time limit message to be shown on the scoreboard or server console. +// +void scoreboard_AddTimeLimit( std::list &lines ) +{ + FString TimeLeftString; + FString limitString; + + GAMEMODE_GetTimeLeftString( TimeLeftString ); + // [AK] Also print "round" when there's more than one duel match to be played. + limitString.Format( "%s ends in %s", (( duel && duellimit > 1 ) || ( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSEARNWINS )) ? "Round" : "Level", TimeLeftString.GetChars( )); + scoreboard_AppendLimit( lines, limitString ); + lines.push_back( limitString ); +} + +//***************************************************************************** // // [RC] Builds the series of "x frags left / 3rd match between the two / 15:10 remain" strings. Used here and in serverconsole.cpp // @@ -1710,6 +1747,8 @@ ULONG ulFlags = GAMEMODE_GetCurrentFlags( ); LONG lRemaining = SCOREBOARD_GetLeftToLimit( ); + const bool bTimeLimitActive = GAMEMODE_IsTimelimitActive( ); + bool bTimeLimitAdded = false; FString text; // Build the fraglimit string. @@ -1718,11 +1757,26 @@ // Build the duellimit and "wins" string. if ( duel && duellimit ) { + // [AK] If there's a fraglimit and a duellimit string, the timelimit string should be put in-between them + // on the scoreboard to organize the info better (frags left on the left, duels left on the right). + if (( bTimeLimitActive ) && ( NETWORK_GetState( ) != NETSTATE_SERVER ) && ( lines.empty( ) == false )) + { + scoreboard_AddTimeLimit( lines ); + bTimeLimitAdded = true; + } + // [TL] The number of duels left is the maximum number of duels less the number of duels fought. // [AK] We already confirmed we're using duel limits, so we can now add this string unconditionally. - scoreboard_AddSingleLimit( lines, true, duellimit - DUEL_GetNumDuels( ), "duel" ); + scoreboard_AddSingleLimit( lines, true, duellimit - DUEL_GetNumDuels( ), "duel", true ); + + // [AK] If we haven't added the timelimit string yet, append it to the duellimit string on the scoreboard. + if (( bTimeLimitActive ) && ( bTimeLimitAdded == false ) && ( NETWORK_GetState( ) != NETSTATE_SERVER )) + { + scoreboard_AddTimeLimit( lines ); + bTimeLimitAdded = true; + } + text = DUEL_GetChampionString( ); - if ( text.IsNotEmpty( )) { if ( !bAcceptColors ) @@ -1738,17 +1792,18 @@ scoreboard_AddSingleLimit( lines, invasion && wavelimit, wavelimit - INVASION_GetCurrentWave( ), "wave" ); // Render the timelimit string. - [BB] if the gamemode uses it. - if ( GAMEMODE_IsTimelimitActive() ) + // [AK] Don't put this string on the scoreboard if we've already done so, or if this is a cooperative game mode (we'll add it in later). + if (( bTimeLimitActive ) && ( bTimeLimitAdded == false ) && (( NETWORK_GetState( ) == NETSTATE_SERVER ) || (( ulFlags & GMF_COOPERATIVE ) == false ))) { - FString TimeLeftString; - GAMEMODE_GetTimeLeftString ( TimeLeftString ); - text.Format( "%s ends in %s", ulFlags & GMF_PLAYERSEARNWINS ? "Round" : "Level", TimeLeftString.GetChars( )); - lines.push_back( text ); + scoreboard_AddTimeLimit( lines ); + bTimeLimitAdded = true; } // [AK] Build the coop strings. if ( ulFlags & GMF_COOPERATIVE ) { + ULONG ulNumLimits = 0; + // Render the number of monsters left in coop. // [AK] Unless we're playing invasion, only do this when there are actually monsters on the level. if (( ulFlags & GMF_PLAYERSEARNKILLS ) && (( invasion ) || ( level.total_monsters > 0 ))) @@ -1759,6 +1814,16 @@ text.Format( "%d% monsters left", static_cast( lRemaining )); lines.push_back( text ); + ulNumLimits++; + } + + // [AK] If there's monsters and secrets on the current level, the timelimit string should be put in-between + // them on the scoreboard to organize the info better (monsters left on the left, secrets left on the right). + if (( bTimeLimitActive ) && ( NETWORK_GetState( ) != NETSTATE_SERVER ) && ( lines.empty( ) == false )) + { + scoreboard_AddTimeLimit( lines ); + bTimeLimitAdded = true; + ulNumLimits++; } // [AK] Render the number of secrets left. @@ -1766,13 +1831,28 @@ { lRemaining = level.total_secrets - level.found_secrets; text.Format( "%d secret%s left", static_cast( lRemaining ), lRemaining == 1 ? "" : "s" ); + scoreboard_AppendLimit( lines, text ); lines.push_back( text ); + ulNumLimits++; } + // [AK] If we haven't added the timelimit string yet, append it to the "secrets left" string on the scoreboard. + if (( bTimeLimitActive ) && ( bTimeLimitAdded == false ) && ( NETWORK_GetState( ) != NETSTATE_SERVER )) + { + scoreboard_AddTimeLimit( lines ); + bTimeLimitAdded = true; + ulNumLimits++; + } + // [WS] Show the damage factor. if ( sv_coop_damagefactor != 1.0f ) { text.Format( "Damage factor is %.2f", static_cast( sv_coop_damagefactor )); + + // [AK] Append the damage factor to the previous string if there aren't too many limits already. + if ( ulNumLimits == 1 ) + scoreboard_AppendLimit( lines, text ); + lines.push_back( text ); } }