Remove pSecondColumnString

* Use the new columns added to Text instead
* Changed most functions to allow choosing a column
* Removed unneeded SecondColumn specific functions to lessen code duplication
* Lots of formatting changes to Popupbox.cpp, indentation was messed up in majority of the functions
This commit is contained in:
Asdow
2025-04-13 22:26:32 +03:00
parent 865288e622
commit 36a84ffe59
4 changed files with 508 additions and 855 deletions
@@ -180,11 +180,12 @@ void CreateDestroyTownInfoBox( void )
// set highlight color // set highlight color
SetBoxHighLight(ghTownMineBox, FONT_WHITE); SetBoxHighLight(ghTownMineBox, FONT_WHITE);
SetBoxSecondColumnForeground( ghTownMineBox, FONT_WHITE ); const auto column = 1;
SetBoxSecondColumnBackground( ghTownMineBox, FONT_BLACK ); SetBoxColumnForeground( ghTownMineBox, FONT_WHITE, column );
SetBoxSecondColumnHighLight( ghTownMineBox, FONT_WHITE ); SetBoxColumnBackground( ghTownMineBox, FONT_BLACK, column );
SetBoxSecondColumnShade( ghTownMineBox, FONT_BLACK ); SetBoxColumnHighLight( ghTownMineBox, FONT_WHITE, column );
SetBoxSecondColumnFont( ghTownMineBox, BLOCKFONT2 ); SetBoxColumnShade( ghTownMineBox, FONT_BLACK, column );
SetBoxColumnFont( ghTownMineBox, BLOCKFONT2, column );
SetBoxSecondColumnMinimumOffset( ghTownMineBox, 20 ); SetBoxSecondColumnMinimumOffset( ghTownMineBox, 20 );
// unhighlighted color // unhighlighted color
+21 -21
View File
@@ -3796,27 +3796,27 @@ void AddStringsToMoveBox( void )
// add title // add title
GetShortSectorString( sSelMapX, sSelMapY, sStringB ); GetShortSectorString( sSelMapX, sSelMapY, sStringB );
swprintf( sString, L"%s %s", pMovementMenuStrings[ 0 ], sStringB ); swprintf( sString, L"%s %s", pMovementMenuStrings[ 0 ], sStringB );
AddStringToBoxColumn(&hStringHandle, sString, 0 ); AddMonoString(&hStringHandle, sString, 0 );
// Add empty lines to other columns // Add empty lines to other columns
for ( size_t i = 1; i < MAX_POPUP_BOX_COLUMNS; i++ ) for ( size_t i = 1; i < MAX_POPUP_BOX_COLUMNS; i++ )
{ {
AddStringToBoxColumn( &hStringHandle, L"", i); AddMonoString( &hStringHandle, L"", i);
} }
// blank line // blank line
for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ ) for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ )
{ {
AddStringToBoxColumn( &hStringHandle, L"", i ); AddMonoString( &hStringHandle, L"", i );
} }
// add Select all line // add Select all line
if (giNumberOfSquadsInSectorMoving > 1) if (giNumberOfSquadsInSectorMoving > 1)
{ {
swprintf(sString, L"%s", pMovementMenuStrings[4]); swprintf(sString, L"%s", pMovementMenuStrings[4]);
AddStringToBoxColumn( &hStringHandle, sString, 0 ); AddMonoString( &hStringHandle, sString, 0 );
for ( size_t i = 1; i < MAX_POPUP_BOX_COLUMNS; i++ ) for ( size_t i = 1; i < MAX_POPUP_BOX_COLUMNS; i++ )
{ {
AddStringToBoxColumn( &hStringHandle, L"", i ); AddMonoString( &hStringHandle, L"", i );
} }
} }
@@ -3842,21 +3842,21 @@ void AddStringsToMoveBox( void )
// Determine which column to add // Determine which column to add
if (!isFirstColumnFull) if (!isFirstColumnFull)
{ {
AddStringToBoxColumn( &hStringHandle, sString, 0 ); AddMonoString( &hStringHandle, sString, 0 );
} }
else if ( !secondColumnFull ) else if ( !secondColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 1 ); AddMonoString( &hStringHandle, sString, 1 );
gColumnEntries[1] += 1; gColumnEntries[1] += 1;
} }
else if ( !thirdColumnFull ) else if ( !thirdColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 2 ); AddMonoString( &hStringHandle, sString, 2 );
gColumnEntries[2] += 1; gColumnEntries[2] += 1;
} }
else else
{ {
AddStringToBoxColumn( &hStringHandle, sString, 3 ); AddMonoString( &hStringHandle, sString, 3 );
gColumnEntries[3] += 1; gColumnEntries[3] += 1;
} }
entries += 1; entries += 1;
@@ -3878,21 +3878,21 @@ void AddStringsToMoveBox( void )
if ( !isFirstColumnFull ) if ( !isFirstColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 0 ); AddMonoString( &hStringHandle, sString, 0 );
} }
else if ( !secondColumnFull ) else if ( !secondColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 1 ); AddMonoString( &hStringHandle, sString, 1 );
gColumnEntries[1] += 1; gColumnEntries[1] += 1;
} }
else if ( !thirdColumnFull ) else if ( !thirdColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 2 ); AddMonoString( &hStringHandle, sString, 2 );
gColumnEntries[2] += 1; gColumnEntries[2] += 1;
} }
else else
{ {
AddStringToBoxColumn( &hStringHandle, sString, 3 ); AddMonoString( &hStringHandle, sString, 3 );
gColumnEntries[3] += 1; gColumnEntries[3] += 1;
} }
entries += 1; entries += 1;
@@ -3930,21 +3930,21 @@ void AddStringsToMoveBox( void )
if ( !isFirstColumnFull ) if ( !isFirstColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 0 ); AddMonoString( &hStringHandle, sString, 0 );
} }
else if ( !secondColumnFull ) else if ( !secondColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 1 ); AddMonoString( &hStringHandle, sString, 1 );
gColumnEntries[1] += 1; gColumnEntries[1] += 1;
} }
else if ( !thirdColumnFull ) else if ( !thirdColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 2 ); AddMonoString( &hStringHandle, sString, 2 );
gColumnEntries[2] += 1; gColumnEntries[2] += 1;
} }
else else
{ {
AddStringToBoxColumn( &hStringHandle, sString, 3 ); AddMonoString( &hStringHandle, sString, 3 );
gColumnEntries[3] += 1; gColumnEntries[3] += 1;
} }
entries += 1; entries += 1;
@@ -3966,21 +3966,21 @@ void AddStringsToMoveBox( void )
if ( !isFirstColumnFull ) if ( !isFirstColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 0 ); AddMonoString( &hStringHandle, sString, 0 );
} }
else if ( !secondColumnFull ) else if ( !secondColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 1 ); AddMonoString( &hStringHandle, sString, 1 );
gColumnEntries[1] += 1; gColumnEntries[1] += 1;
} }
else if ( !thirdColumnFull ) else if ( !thirdColumnFull )
{ {
AddStringToBoxColumn( &hStringHandle, sString, 2 ); AddMonoString( &hStringHandle, sString, 2 );
gColumnEntries[2] += 1; gColumnEntries[2] += 1;
} }
else else
{ {
AddStringToBoxColumn( &hStringHandle, sString, 3 ); AddMonoString( &hStringHandle, sString, 3 );
gColumnEntries[3] += 1; gColumnEntries[3] += 1;
} }
entries += 1; entries += 1;
+467 -795
View File
File diff suppressed because it is too large Load Diff
+14 -34
View File
@@ -47,14 +47,11 @@ struct popupbox{
UINT32 uiBuffer; UINT32 uiBuffer;
UINT32 uiSecondColumnMinimunOffset; UINT32 uiSecondColumnMinimunOffset;
UINT32 uiSecondColumnCurrentOffset; UINT32 uiSecondColumnCurrentOffset;
INT16 usSecondColumnOffsetAdjustment;
UINT32 uiBoxMinWidth; UINT32 uiBoxMinWidth;
BOOLEAN fUpdated; BOOLEAN fUpdated;
BOOLEAN fShowBox; BOOLEAN fShowBox;
POPUPSTRINGPTR Text[MAX_POPUP_BOX_COLUMNS][ MAX_POPUP_BOX_STRING_COUNT ]; POPUPSTRINGPTR Text[MAX_POPUP_BOX_COLUMNS][ MAX_POPUP_BOX_STRING_COUNT ];
// TODO Remove pSecondColumnString
POPUPSTRINGPTR pSecondColumnString[ MAX_POPUP_BOX_STRING_COUNT ];
}; };
typedef struct popupbox PopUpBo; typedef struct popupbox PopUpBo;
@@ -76,8 +73,7 @@ UINT32 GetLineSpace( INT32 hBoxHandle );
void SetBoxBuffer(INT32 hBoxHandle, UINT32 uiBuffer); void SetBoxBuffer(INT32 hBoxHandle, UINT32 uiBuffer);
void SetBoxPosition(INT32 hBoxHandle,SGPPoint Position); void SetBoxPosition(INT32 hBoxHandle,SGPPoint Position);
void GetBoxPosition( INT32 hBoxHandle, SGPPoint *Position ); void GetBoxPosition( INT32 hBoxHandle, SGPPoint *Position );
UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle ); UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle, UINT8 column = 0 );
UINT32 GetNumberOfSecondaryLinesOfTextInBox(INT32 hBoxHandle);
UINT32 GetTotalNumberOfLinesOfTextInBox( INT32 hBoxHandle ); UINT32 GetTotalNumberOfLinesOfTextInBox( INT32 hBoxHandle );
UINT32 GetBoxSecondColumnCurrentOffset( INT32 hBoxHandle ); UINT32 GetBoxSecondColumnCurrentOffset( INT32 hBoxHandle );
void SetBoxSize( INT32 hBoxHandle, SGPRect Dimensions ); void SetBoxSize( INT32 hBoxHandle, SGPRect Dimensions );
@@ -85,8 +81,8 @@ void GetBoxSize( INT32 hBoxHandle, SGPRect *Dimensions );
void SetBoxFlags( INT32 hBoxHandle, UINT32 uiFlags); void SetBoxFlags( INT32 hBoxHandle, UINT32 uiFlags);
void SetBorderType(INT32 hBoxHandle,INT32 BorderObjectIndex); void SetBorderType(INT32 hBoxHandle,INT32 BorderObjectIndex);
void SetBackGroundSurface(INT32 hBoxHandle, INT32 BackGroundSurfaceIndex); void SetBackGroundSurface(INT32 hBoxHandle, INT32 BackGroundSurfaceIndex);
void AddMonoString(UINT32 *hStringHandle, STR16 pString); void AddMonoString(UINT32 *hStringHandle, STR16 pString, UINT8 column = 0);
void AddColorString(INT32 *hStringHandle, STR16 pString); void AddColorString(INT32 *hStringHandle, STR16 pString, UINT8 column = 0);
void SetPopUpStringFont(INT32 hStringHandle, UINT32 uiFont); void SetPopUpStringFont(INT32 hStringHandle, UINT32 uiFont);
void SetBoxFont(INT32 hBoxHandle, UINT32 uiFont); void SetBoxFont(INT32 hBoxHandle, UINT32 uiFont);
UINT32 GetBoxFont( INT32 hBoxHandle ); UINT32 GetBoxFont( INT32 hBoxHandle );
@@ -98,13 +94,11 @@ void SetBoxForeground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxBackground(INT32 hBoxHandle, UINT8 ubColor); void SetBoxBackground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxHighLight(INT32 hBoxHandle, UINT8 ubColor); void SetBoxHighLight(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxShade(INT32 hBoxHandle, UINT8 ubColor); void SetBoxShade(INT32 hBoxHandle, UINT8 ubColor);
void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 );
void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 );
void HighLightLine( INT32 hStringHandle, UINT8 column ); void HighLightLine( INT32 hStringHandle, UINT8 column = 0 );
void HighLight2ndLine( INT32 hStringHandle );
void HighLightBoxLine( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 ); void HighLightBoxLine( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 );
void HighLight2ndBoxLine( INT32 hBoxHandle, INT32 iLineNumber ); void UnHighLightLine(INT32 hStringHandle, UINT8 column = 0);
void UnHighLightLine(INT32 hStringHandle);
void UnHighLightBox(INT32 hBoxHandle); void UnHighLightBox(INT32 hBoxHandle);
void RemoveOneCurrentBoxString(INT32 hStringHandle, BOOLEAN fFillGaps); void RemoveOneCurrentBoxString(INT32 hStringHandle, BOOLEAN fFillGaps);
void RemoveAllCurrentBoxStrings( void ); void RemoveAllCurrentBoxStrings( void );
@@ -116,9 +110,6 @@ void DisplayOnePopupBox( UINT32 uiIndex, UINT32 uiBuffer );
void SetCurrentBox(INT32 hBoxHandle); void SetCurrentBox(INT32 hBoxHandle);
void GetCurrentBox(INT32 *hBoxHandle); void GetCurrentBox(INT32 *hBoxHandle);
void AddStringToBoxColumn( UINT32 *hStringHandle, STR16 pString, UINT8 column );
void AddColumnMonoString( UINT32 *hStringHandle, STR16 pString, UINT8 column );
// resize this box to the text it contains // resize this box to the text it contains
void ResizeBoxToText(INT32 hBoxHandle); void ResizeBoxToText(INT32 hBoxHandle);
@@ -147,10 +138,6 @@ void HideAllBoxes( void );
// add the second column monocrome string // add the second column monocrome string
void AddSecondColumnMonoString( UINT32 *hStringHandle, STR16 pString ); void AddSecondColumnMonoString( UINT32 *hStringHandle, STR16 pString );
void AddMonoStringToSecondColumn(UINT32* hStringHandle, STR16 pString);
// set the 2nd column font for this box
void SetBoxSecondColumnFont(INT32 hBoxHandle, UINT32 uiFont);
// set the minimum offset // set the minimum offset
void SetBoxSecondColumnMinimumOffset( INT32 hBoxHandle, UINT32 uiWidth ); void SetBoxSecondColumnMinimumOffset( INT32 hBoxHandle, UINT32 uiWidth );
@@ -164,24 +151,17 @@ void SetStringSecondColumnHighLight(INT32 hStringHandle, UINT8 ubColor);
void SetStringSecondColumnShade(INT32 hStringHandle, UINT8 ubShade); void SetStringSecondColumnShade(INT32 hStringHandle, UINT8 ubShade);
// now on a box wide basis, one if recomened to use this function after adding all the strings..rather than on an individual basis // now on a box wide basis, one if recomened to use this function after adding all the strings..rather than on an individual basis
void SetBoxSecondColumnForeground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxSecondColumnBackground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxSecondColumnHighLight(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxSecondColumnShade(INT32 hBoxHandle, UINT8 ubColor);
// Manual adjustment for 2nd column offset, eg. when 1st column has a title text that's wider than the rest and you want to move 2nd column texts towards the 1st column some.
void SetBoxSecondColumnOffsetAdjustment(INT32 hBoxHandle, INT16 x);
// Set attributes by column // Set attributes by column
void SetBoxColumnForeground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); void SetBoxColumnForeground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 );
void SetBoxColumnBackground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); void SetBoxColumnBackground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 );
void SetBoxColumnHighLight( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); void SetBoxColumnHighLight( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 );
void SetBoxColumnShade( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); void SetBoxColumnShade( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 );
void SetBoxColumnFont( INT32 hBoxHandle, UINT32 uiFont, UINT8 column ); void SetBoxColumnFont( INT32 hBoxHandle, UINT32 uiFont, UINT8 column = 0 );
// secondary shades for boxes // secondary shades for boxes
void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 );
void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 );
void SetBoxSecondaryShade( INT32 iBox, UINT8 ubColor ); void SetBoxSecondaryShade( INT32 iBox, UINT8 ubColor );