Revision | f192097d753a2857a8e1bb4151665dffc336d625 (tree) |
---|---|
Time | 2023-03-08 00:03:03 |
Author | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Added a way to return a ScoreColumn's internal name (i.e. the name that will be used to define columns in SCORINFO).
@@ -156,7 +156,7 @@ | ||
156 | 156 | static ScoreColumn *scoreboard_ScanForColumn( FScanner &sc, const bool bMustBeDataColumn ); |
157 | 157 | |
158 | 158 | template<typename ColumnType> |
159 | -static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn, const char *pszColumnName ); | |
159 | +static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn ); | |
160 | 160 | |
161 | 161 | //***************************************************************************** |
162 | 162 | // CONSOLE VARIABLES |
@@ -435,6 +435,7 @@ | ||
435 | 435 | //***************************************************************************** |
436 | 436 | |
437 | 437 | ScoreColumn::ScoreColumn( const char *pszName ) : |
438 | + InternalName( pszName ), | |
438 | 439 | DisplayName( pszName ), |
439 | 440 | Alignment( COLUMNALIGN_LEFT ), |
440 | 441 | pCVar( NULL ), |
@@ -502,7 +503,7 @@ | ||
502 | 503 | // |
503 | 504 | //***************************************************************************** |
504 | 505 | |
505 | -void ScoreColumn::Parse( const FName Name, FScanner &sc ) | |
506 | +void ScoreColumn::Parse( FScanner &sc ) | |
506 | 507 | { |
507 | 508 | sc.MustGetToken( '{' ); |
508 | 509 |
@@ -524,17 +525,17 @@ | ||
524 | 525 | FString CommandName = sc.String; |
525 | 526 | |
526 | 527 | sc.MustGetToken( '=' ); |
527 | - ParseCommand( Name, sc, Command, CommandName ); | |
528 | + ParseCommand( sc, Command, CommandName ); | |
528 | 529 | } |
529 | 530 | } |
530 | 531 | |
531 | 532 | // [AK] Unless the ALWAYSUSESHORTESTWIDTH flag is enabled, columns must have a non-zero width. |
532 | 533 | if ((( ulFlags & COLUMNFLAG_ALWAYSUSESHORTESTWIDTH ) == false ) && ( ulSizing == 0 )) |
533 | - sc.ScriptError( "Column '%s' needs a size that's greater than zero.", Name.GetChars( )); | |
534 | + sc.ScriptError( "Column '%s' needs a size that's greater than zero.", GetInternalName( )); | |
534 | 535 | |
535 | 536 | // [AK] If the short name is longer than the display name, throw a fatal error. |
536 | 537 | if ( DisplayName.Len( ) < ShortName.Len( )) |
537 | - sc.ScriptError( "Column '%s' has a short name that's greater than its display name.", Name.GetChars( )); | |
538 | + sc.ScriptError( "Column '%s' has a short name that's greater than its display name.", GetInternalName( )); | |
538 | 539 | } |
539 | 540 | |
540 | 541 | //***************************************************************************** |
@@ -545,7 +546,7 @@ | ||
545 | 546 | // |
546 | 547 | //***************************************************************************** |
547 | 548 | |
548 | -void ScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
549 | +void ScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
549 | 550 | { |
550 | 551 | switch ( Command ) |
551 | 552 | { |
@@ -650,7 +651,7 @@ | ||
650 | 651 | } |
651 | 652 | |
652 | 653 | default: |
653 | - sc.ScriptError( "Couldn't process column command '%s' for column '%s'.", CommandName.GetChars( ), Name.GetChars( )); | |
654 | + sc.ScriptError( "Couldn't process column command '%s' for column '%s'.", CommandName.GetChars( ), GetInternalName( )); | |
654 | 655 | } |
655 | 656 | } |
656 | 657 |
@@ -1421,7 +1422,7 @@ | ||
1421 | 1422 | // |
1422 | 1423 | //***************************************************************************** |
1423 | 1424 | |
1424 | -void DataScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
1425 | +void DataScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
1425 | 1426 | { |
1426 | 1427 | switch ( Command ) |
1427 | 1428 | { |
@@ -1495,7 +1496,7 @@ | ||
1495 | 1496 | |
1496 | 1497 | // [AK] Parse any generic column commands if we reach here. |
1497 | 1498 | default: |
1498 | - ScoreColumn::ParseCommand( Name, sc, Command, CommandName ); | |
1499 | + ScoreColumn::ParseCommand( sc, Command, CommandName ); | |
1499 | 1500 | break; |
1500 | 1501 | } |
1501 | 1502 |
@@ -1504,10 +1505,10 @@ | ||
1504 | 1505 | if ( pCompositeColumn != NULL ) |
1505 | 1506 | { |
1506 | 1507 | if (( ulFlags & COLUMNFLAG_DONTSHOWHEADER ) == false ) |
1507 | - sc.ScriptError( "Tried to remove the 'DONTSHOWHEADER' flag from column '%s' which is inside a composite column.", Name.GetChars( )); | |
1508 | + sc.ScriptError( "Tried to remove the 'DONTSHOWHEADER' flag from column '%s' which is inside a composite column.", GetInternalName( )); | |
1508 | 1509 | |
1509 | 1510 | if ( Alignment != COLUMNALIGN_LEFT ) |
1510 | - sc.ScriptError( "Tried to change the alignment of column '%s' which is inside a composite column.", Name.GetChars( )); | |
1511 | + sc.ScriptError( "Tried to change the alignment of column '%s' which is inside a composite column.", GetInternalName( )); | |
1511 | 1512 | } |
1512 | 1513 | } |
1513 | 1514 |
@@ -1819,7 +1820,7 @@ | ||
1819 | 1820 | // |
1820 | 1821 | //***************************************************************************** |
1821 | 1822 | |
1822 | -void CustomScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
1823 | +void CustomScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
1823 | 1824 | { |
1824 | 1825 | switch ( Command ) |
1825 | 1826 | { |
@@ -1889,7 +1890,7 @@ | ||
1889 | 1890 | |
1890 | 1891 | // [AK] Parse any data column commands if we reach here. |
1891 | 1892 | default: |
1892 | - DataScoreColumn::ParseCommand( Name, sc, Command, CommandName ); | |
1893 | + DataScoreColumn::ParseCommand( sc, Command, CommandName ); | |
1893 | 1894 | break; |
1894 | 1895 | } |
1895 | 1896 | } |
@@ -1963,7 +1964,7 @@ | ||
1963 | 1964 | // |
1964 | 1965 | //***************************************************************************** |
1965 | 1966 | |
1966 | -void CompositeScoreColumn::ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
1967 | +void CompositeScoreColumn::ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ) | |
1967 | 1968 | { |
1968 | 1969 | switch ( Command ) |
1969 | 1970 | { |
@@ -1978,11 +1979,11 @@ | ||
1978 | 1979 | |
1979 | 1980 | // [AK] Don't add a data column that's already inside another composite column. |
1980 | 1981 | if (( pDataColumn->GetCompositeColumn( ) != NULL ) && ( pDataColumn->GetCompositeColumn( ) != this )) |
1981 | - sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside another composite column.", sc.String, Name.GetChars( )); | |
1982 | + sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside another composite column.", sc.String, GetInternalName( )); | |
1982 | 1983 | |
1983 | 1984 | // [AK] Don't add a data column that's already inside a scoreboard's column order. |
1984 | 1985 | if ( pDataColumn->GetScoreboard( ) != NULL ) |
1985 | - sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside a scoreboard's column order.", sc.String, Name.GetChars( )); | |
1986 | + sc.ScriptError( "Tried to put data column '%s' into composite column '%s', but it's already inside a scoreboard's column order.", sc.String, GetInternalName( )); | |
1986 | 1987 | |
1987 | 1988 | // [AK] All data columns require the DONTSHOWHEADER flag to be enabled to be inside a composite column. |
1988 | 1989 | if (( pDataColumn->GetFlags( ) & COLUMNFLAG_DONTSHOWHEADER ) == false ) |
@@ -1992,7 +1993,7 @@ | ||
1992 | 1993 | if ( pDataColumn->Alignment != COLUMNALIGN_LEFT ) |
1993 | 1994 | sc.ScriptError( "Data column '%s' must be aligned to the left before it can be put inside a composite column.", sc.String ); |
1994 | 1995 | |
1995 | - if ( scoreboard_TryPushingColumnToList( sc, SubColumns, pDataColumn, sc.String )) | |
1996 | + if ( scoreboard_TryPushingColumnToList( sc, SubColumns, pDataColumn )) | |
1996 | 1997 | pDataColumn->pCompositeColumn = this; |
1997 | 1998 | } while ( sc.CheckToken( ',' )); |
1998 | 1999 |
@@ -2004,7 +2005,7 @@ | ||
2004 | 2005 | |
2005 | 2006 | // [AK] Parse any generic column commands if we reach here. |
2006 | 2007 | default: |
2007 | - ScoreColumn::ParseCommand( Name, sc, Command, CommandName ); | |
2008 | + ScoreColumn::ParseCommand( sc, Command, CommandName ); | |
2008 | 2009 | break; |
2009 | 2010 | } |
2010 | 2011 | } |
@@ -2564,10 +2565,7 @@ | ||
2564 | 2565 | { |
2565 | 2566 | // [AK] Note that if we're adding a column to the rank order, then it must be a data column. |
2566 | 2567 | ScoreColumn *pColumn = scoreboard_ScanForColumn( sc, bAddToRankOrder ); |
2567 | - | |
2568 | - // [AK] The column's name should still be saved in sc.String, even after calling | |
2569 | - // the helper function above. | |
2570 | - const char *pszColumnName = sc.String; | |
2568 | + const char *pszColumnName = pColumn->GetInternalName( ); | |
2571 | 2569 | |
2572 | 2570 | if ( bAddToRankOrder ) |
2573 | 2571 | { |
@@ -2588,7 +2586,7 @@ | ||
2588 | 2586 | sc.ScriptError( "Column '%s' is part of a composite column that must be added to the column order before it can be added to the rank order.", pszColumnName ); |
2589 | 2587 | } |
2590 | 2588 | |
2591 | - scoreboard_TryPushingColumnToList( sc, RankOrder, pDataColumn, pszColumnName ); | |
2589 | + scoreboard_TryPushingColumnToList( sc, RankOrder, pDataColumn ); | |
2592 | 2590 | } |
2593 | 2591 | else |
2594 | 2592 | { |
@@ -2597,7 +2595,7 @@ | ||
2597 | 2595 | if (( pColumn->GetTemplate( ) == COLUMNTEMPLATE_DATA ) && ( static_cast<DataScoreColumn *>( pColumn )->GetCompositeColumn( ) != NULL )) |
2598 | 2596 | sc.ScriptError( "Column '%s' is part of a composite column and can't be added to the order list.", pszColumnName ); |
2599 | 2597 | |
2600 | - if ( scoreboard_TryPushingColumnToList( sc, ColumnOrder, pColumn, pszColumnName )) | |
2598 | + if ( scoreboard_TryPushingColumnToList( sc, ColumnOrder, pColumn )) | |
2601 | 2599 | { |
2602 | 2600 | pColumn->pScoreboard = this; |
2603 | 2601 |
@@ -4384,7 +4382,7 @@ | ||
4384 | 4382 | //***************************************************************************** |
4385 | 4383 | |
4386 | 4384 | template<typename ColumnType> |
4387 | -static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn, const char *pszColumnName ) | |
4385 | +static bool scoreboard_TryPushingColumnToList( FScanner &sc, TArray<ColumnType *> &ColumnList, ColumnType *pColumn ) | |
4388 | 4386 | { |
4389 | 4387 | // [AK] Make sure the pointer to the column isn't NULL. |
4390 | 4388 | if ( pColumn == NULL ) |
@@ -4393,12 +4391,10 @@ | ||
4393 | 4391 | // [AK] Make sure that this column isn't already inside this list. |
4394 | 4392 | for ( unsigned int i = 0; i < ColumnList.Size( ); i++ ) |
4395 | 4393 | { |
4394 | + // [AK] Print an error message to let the user know the issue. | |
4396 | 4395 | if ( ColumnList[i] == pColumn ) |
4397 | 4396 | { |
4398 | - // [AK] Print an error message to let the user know the issue. | |
4399 | - if ( pszColumnName != NULL ) | |
4400 | - sc.ScriptMessage( "Tried to put column '%s' into a list more than once.", pszColumnName ); | |
4401 | - | |
4397 | + sc.ScriptMessage( "Tried to put column '%s' into a list more than once.", pColumn->GetInternalName( )); | |
4402 | 4398 | return false; |
4403 | 4399 | } |
4404 | 4400 | } |
@@ -203,6 +203,7 @@ | ||
203 | 203 | ScoreColumn( const char *pszName ); |
204 | 204 | |
205 | 205 | Scoreboard *GetScoreboard( void ) const { return pScoreboard; } |
206 | + const char *GetInternalName( void ) const { return InternalName.GetChars( ); } | |
206 | 207 | const char *GetDisplayName( void ) const { return DisplayName.Len( ) > 0 ? DisplayName.GetChars( ) : NULL; } |
207 | 208 | const char *GetShortName( void ) const { return ShortName.Len( ) > 0 ? ShortName.GetChars( ) : NULL; } |
208 | 209 | FBaseCVar *GetCVar( void ) const { return pCVar; } |
@@ -217,7 +218,7 @@ | ||
217 | 218 | bool IsHidden( void ) const { return bHidden; } |
218 | 219 | bool ShouldUseShortName( void ) const { return bUseShortName; } |
219 | 220 | void SetHidden( bool bEnable ); |
220 | - void Parse( const FName Name, FScanner &sc ); | |
221 | + void Parse( FScanner &sc ); | |
221 | 222 | void DrawHeader( const LONG lYPos, const ULONG ulHeight, const float fAlpha ) const; |
222 | 223 | void DrawString( const char *pszString, FFont *pFont, const ULONG ulColor, const LONG lYPos, const ULONG ulHeight, const float fAlpha ) const; |
223 | 224 | void DrawColor( const PalEntry color, const LONG lYPos, const ULONG ulHeight, const float fAlpha, const int clipWidth, const int clipHeight ) const; |
@@ -225,7 +226,7 @@ | ||
225 | 226 | |
226 | 227 | virtual COLUMNTEMPLATE_e GetTemplate( void ) const { return COLUMNTEMPLATE_UNKNOWN; } |
227 | 228 | virtual bool IsCustomColumn( void ) const { return false; } |
228 | - virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
229 | + virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
229 | 230 | virtual void CheckIfUsable( void ); |
230 | 231 | virtual void Refresh( void ); |
231 | 232 | virtual void UpdateWidth( void ); |
@@ -234,6 +235,7 @@ | ||
234 | 235 | protected: |
235 | 236 | bool CanDrawForPlayer( const ULONG ulPlayer ) const; |
236 | 237 | |
238 | + const FName InternalName; | |
237 | 239 | FString DisplayName; |
238 | 240 | FString ShortName; |
239 | 241 | COLUMNALIGN_e Alignment; |
@@ -291,7 +293,7 @@ | ||
291 | 293 | virtual COLUMNDATA_e GetDataType( void ) const; |
292 | 294 | virtual ULONG GetValueWidth( const ColumnValue &Value ) const; |
293 | 295 | virtual ColumnValue GetValue( const ULONG ulPlayer ) const; |
294 | - virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
296 | + virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
295 | 297 | virtual void UpdateWidth( void ); |
296 | 298 | virtual void DrawValue( const ULONG ulPlayer, const ULONG ulColor, const LONG lYPos, const ULONG ulHeight, const float fAlpha ) const; |
297 | 299 |
@@ -354,7 +356,7 @@ | ||
354 | 356 | virtual void SetDataType( COLUMNDATA_e NewDataType ); |
355 | 357 | virtual void SetValue( const ULONG ulPlayer, const ColumnValue &Value ); |
356 | 358 | virtual void SetDefaultValue( const ColumnValue &Value ); |
357 | - virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
359 | + virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
358 | 360 | virtual void ResetToDefault( const ULONG ulPlayer, const bool bChangingLevel ); |
359 | 361 | |
360 | 362 | protected: |
@@ -382,7 +384,7 @@ | ||
382 | 384 | CompositeScoreColumn( const char *pszName ) : ScoreColumn( pszName ) { } |
383 | 385 | |
384 | 386 | virtual COLUMNTEMPLATE_e GetTemplate( void ) const { return COLUMNTEMPLATE_COMPOSITE; } |
385 | - virtual void ParseCommand( const FName Name, FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
387 | + virtual void ParseCommand( FScanner &sc, const COLUMNCMD_e Command, const FString CommandName ); | |
386 | 388 | virtual void CheckIfUsable( void ); |
387 | 389 | virtual void Refresh( void ); |
388 | 390 | virtual void UpdateWidth( void ); |