From 36a84ffe5937f0e1b474953f9ff6d26388cbe7e4 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 13 Apr 2025 21:37:14 +0300 Subject: [PATCH] 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 --- .../Map Screen Interface TownMine Info.cpp | 11 +- Strategic/Map Screen Interface.cpp | 42 +- Utils/PopUpBox.cpp | 1262 ++++++----------- Utils/PopUpBox.h | 48 +- 4 files changed, 508 insertions(+), 855 deletions(-) diff --git a/Strategic/Map Screen Interface TownMine Info.cpp b/Strategic/Map Screen Interface TownMine Info.cpp index 17294d0a..6fd9748c 100644 --- a/Strategic/Map Screen Interface TownMine Info.cpp +++ b/Strategic/Map Screen Interface TownMine Info.cpp @@ -180,11 +180,12 @@ void CreateDestroyTownInfoBox( void ) // set highlight color SetBoxHighLight(ghTownMineBox, FONT_WHITE); - SetBoxSecondColumnForeground( ghTownMineBox, FONT_WHITE ); - SetBoxSecondColumnBackground( ghTownMineBox, FONT_BLACK ); - SetBoxSecondColumnHighLight( ghTownMineBox, FONT_WHITE ); - SetBoxSecondColumnShade( ghTownMineBox, FONT_BLACK ); - SetBoxSecondColumnFont( ghTownMineBox, BLOCKFONT2 ); + const auto column = 1; + SetBoxColumnForeground( ghTownMineBox, FONT_WHITE, column ); + SetBoxColumnBackground( ghTownMineBox, FONT_BLACK, column ); + SetBoxColumnHighLight( ghTownMineBox, FONT_WHITE, column ); + SetBoxColumnShade( ghTownMineBox, FONT_BLACK, column ); + SetBoxColumnFont( ghTownMineBox, BLOCKFONT2, column ); SetBoxSecondColumnMinimumOffset( ghTownMineBox, 20 ); // unhighlighted color diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index ecca6342..4812b167 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -3796,27 +3796,27 @@ void AddStringsToMoveBox( void ) // add title GetShortSectorString( sSelMapX, sSelMapY, sStringB ); swprintf( sString, L"%s %s", pMovementMenuStrings[ 0 ], sStringB ); - AddStringToBoxColumn(&hStringHandle, sString, 0 ); + AddMonoString(&hStringHandle, sString, 0 ); // Add empty lines to other columns for ( size_t i = 1; i < MAX_POPUP_BOX_COLUMNS; i++ ) { - AddStringToBoxColumn( &hStringHandle, L"", i); + AddMonoString( &hStringHandle, L"", i); } // blank line for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ ) { - AddStringToBoxColumn( &hStringHandle, L"", i ); + AddMonoString( &hStringHandle, L"", i ); } // add Select all line if (giNumberOfSquadsInSectorMoving > 1) { 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++ ) { - AddStringToBoxColumn( &hStringHandle, L"", i ); + AddMonoString( &hStringHandle, L"", i ); } } @@ -3842,21 +3842,21 @@ void AddStringsToMoveBox( void ) // Determine which column to add if (!isFirstColumnFull) { - AddStringToBoxColumn( &hStringHandle, sString, 0 ); + AddMonoString( &hStringHandle, sString, 0 ); } else if ( !secondColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 1 ); + AddMonoString( &hStringHandle, sString, 1 ); gColumnEntries[1] += 1; } else if ( !thirdColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 2 ); + AddMonoString( &hStringHandle, sString, 2 ); gColumnEntries[2] += 1; } else { - AddStringToBoxColumn( &hStringHandle, sString, 3 ); + AddMonoString( &hStringHandle, sString, 3 ); gColumnEntries[3] += 1; } entries += 1; @@ -3878,21 +3878,21 @@ void AddStringsToMoveBox( void ) if ( !isFirstColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 0 ); + AddMonoString( &hStringHandle, sString, 0 ); } else if ( !secondColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 1 ); + AddMonoString( &hStringHandle, sString, 1 ); gColumnEntries[1] += 1; } else if ( !thirdColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 2 ); + AddMonoString( &hStringHandle, sString, 2 ); gColumnEntries[2] += 1; } else { - AddStringToBoxColumn( &hStringHandle, sString, 3 ); + AddMonoString( &hStringHandle, sString, 3 ); gColumnEntries[3] += 1; } entries += 1; @@ -3930,21 +3930,21 @@ void AddStringsToMoveBox( void ) if ( !isFirstColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 0 ); + AddMonoString( &hStringHandle, sString, 0 ); } else if ( !secondColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 1 ); + AddMonoString( &hStringHandle, sString, 1 ); gColumnEntries[1] += 1; } else if ( !thirdColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 2 ); + AddMonoString( &hStringHandle, sString, 2 ); gColumnEntries[2] += 1; } else { - AddStringToBoxColumn( &hStringHandle, sString, 3 ); + AddMonoString( &hStringHandle, sString, 3 ); gColumnEntries[3] += 1; } entries += 1; @@ -3966,21 +3966,21 @@ void AddStringsToMoveBox( void ) if ( !isFirstColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 0 ); + AddMonoString( &hStringHandle, sString, 0 ); } else if ( !secondColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 1 ); + AddMonoString( &hStringHandle, sString, 1 ); gColumnEntries[1] += 1; } else if ( !thirdColumnFull ) { - AddStringToBoxColumn( &hStringHandle, sString, 2 ); + AddMonoString( &hStringHandle, sString, 2 ); gColumnEntries[2] += 1; } else { - AddStringToBoxColumn( &hStringHandle, sString, 3 ); + AddMonoString( &hStringHandle, sString, 3 ); gColumnEntries[3] += 1; } entries += 1; diff --git a/Utils/PopUpBox.cpp b/Utils/PopUpBox.cpp index 168cad0a..b0bd06a4 100644 --- a/Utils/PopUpBox.cpp +++ b/Utils/PopUpBox.cpp @@ -1,5 +1,5 @@ #include "PopUpBox.h" - #include "sysutil.h" +#include "sysutil.h" #define BORDER_WIDTH 16 @@ -13,8 +13,8 @@ #define BOTTOM_RIGHT_CORNER 3 -BOOLEAN DrawBox(UINT32 uiCounter); -BOOLEAN DrawBoxText(UINT32 uiCounter); +BOOLEAN DrawBox( UINT32 uiCounter ); +BOOLEAN DrawBoxText( UINT32 uiCounter ); void RemoveCurrentBoxPrimaryText( INT32 hStringHandle ); void RemoveCurrentBoxSecondaryText( INT32 hStringHandle ); @@ -29,105 +29,101 @@ void InitPopUpBoxList() } -void InitPopUpBox(INT32 hBoxHandle) +void InitPopUpBox( INT32 hBoxHandle ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); - memset(PopUpBoxList[hBoxHandle], 0, sizeof(PopUpBo)); + Assert( PopUpBoxList[hBoxHandle] ); + memset( PopUpBoxList[hBoxHandle], 0, sizeof( PopUpBo ) ); } -void SetLineSpace(INT32 hBoxHandle, UINT32 uiLineSpace) +void SetLineSpace( INT32 hBoxHandle, UINT32 uiLineSpace ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); - PopUpBoxList[hBoxHandle]->uiLineSpace=uiLineSpace; - return; + Assert( PopUpBoxList[hBoxHandle] ); + PopUpBoxList[hBoxHandle]->uiLineSpace = uiLineSpace; + return; } UINT32 GetLineSpace( INT32 hBoxHandle ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return( 0 ); + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) + return(0); - Assert( PopUpBoxList[ hBoxHandle ] ); + Assert( PopUpBoxList[hBoxHandle] ); // return number of pixels between lines for this box - return( PopUpBoxList[hBoxHandle]->uiLineSpace ); + return(PopUpBoxList[hBoxHandle]->uiLineSpace); } void SpecifyBoxMinWidth( INT32 hBoxHandle, INT32 iMinWidth ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - PopUpBoxList[hBoxHandle]->uiBoxMinWidth = iMinWidth; + box->uiBoxMinWidth = iMinWidth; // check if the box is currently too small - if( PopUpBoxList[hBoxHandle]->Dimensions.iRight < iMinWidth ) + if ( box->Dimensions.iRight < iMinWidth ) { - PopUpBoxList[hBoxHandle]->Dimensions.iRight = iMinWidth; + box->Dimensions.iRight = iMinWidth; } return; } -BOOLEAN CreatePopUpBox(INT32 *phBoxHandle, SGPRect Dimensions, SGPPoint Position, UINT32 uiFlags) +BOOLEAN CreatePopUpBox( INT32 *phBoxHandle, SGPRect Dimensions, SGPPoint Position, UINT32 uiFlags ) { - INT32 iCounter=0; - INT32 iCount=0; - PopUpBoxPt pBox=NULL; + INT32 iCounter = 0; + INT32 iCount = 0; + PopUpBoxPt pBox = NULL; // find first free box - for(iCounter=0; ( iCounter < MAX_POPUP_BOX_COUNT ) && ( PopUpBoxList[iCounter] != NULL ); iCounter++); + for ( iCounter = 0; (iCounter < MAX_POPUP_BOX_COUNT) && (PopUpBoxList[iCounter] != NULL); iCounter++ ); - if( iCounter >= MAX_POPUP_BOX_COUNT ) + if ( iCounter >= MAX_POPUP_BOX_COUNT ) { // ran out of available popup boxes - probably not freeing them up right! - Assert(0); + Assert( 0 ); return FALSE; } - iCount=iCounter; - *phBoxHandle=iCount; + iCount = iCounter; + *phBoxHandle = iCount; - pBox= (PopUpBoxPt) MemAlloc(sizeof(PopUpBo)); - if (pBox == NULL) + pBox = (PopUpBoxPt)MemAlloc( sizeof( PopUpBo ) ); + if ( pBox == NULL ) { return FALSE; } - PopUpBoxList[iCount]=pBox; + PopUpBoxList[iCount] = pBox; - InitPopUpBox(iCount); - SetBoxPosition(iCount, Position); - SetBoxSize(iCount, Dimensions); - SetBoxFlags(iCount, uiFlags); + InitPopUpBox( iCount ); + SetBoxPosition( iCount, Position ); + SetBoxSize( iCount, Dimensions ); + SetBoxFlags( iCount, uiFlags ); for ( UINT8 col = 0; col < MAX_POPUP_BOX_COLUMNS; ++col ) { - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; ++iCounter) + for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; ++iCounter ) { PopUpBoxList[iCount]->Text[col][iCounter] = NULL; } } - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) - { - PopUpBoxList[iCount]->pSecondColumnString[iCounter] = NULL; - } - - SetCurrentBox(iCount); + SetCurrentBox( iCount ); SpecifyBoxMinWidth( iCount, 0 ); SetBoxSecondColumnMinimumOffset( iCount, 0 ); SetBoxSecondColumnCurrentOffset( iCount, 0 ); @@ -138,35 +134,37 @@ BOOLEAN CreatePopUpBox(INT32 *phBoxHandle, SGPRect Dimensions, SGPPoint Position } -void SetBoxFlags( INT32 hBoxHandle, UINT32 uiFlags) +void SetBoxFlags( INT32 hBoxHandle, UINT32 uiFlags ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - PopUpBoxList[hBoxHandle]->uiFlags=uiFlags; - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; + box->uiFlags = uiFlags; + box->fUpdated = FALSE; - return; + return; } -void SetMargins(INT32 hBoxHandle, UINT32 uiLeft, UINT32 uiTop, UINT32 uiBottom, UINT32 uiRight) +void SetMargins( INT32 hBoxHandle, UINT32 uiLeft, UINT32 uiTop, UINT32 uiBottom, UINT32 uiRight ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - PopUpBoxList[hBoxHandle]->uiLeftMargin=uiLeft; - PopUpBoxList[hBoxHandle]->uiRightMargin=uiRight; - PopUpBoxList[hBoxHandle]->uiTopMargin=uiTop; - PopUpBoxList[hBoxHandle]->uiBottomMargin=uiBottom; + box->uiLeftMargin = uiLeft; + box->uiRightMargin = uiRight; + box->uiTopMargin = uiTop; + box->uiBottomMargin = uiBottom; - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; + box->fUpdated = FALSE; - return; + return; } @@ -174,183 +172,192 @@ UINT32 GetTopMarginSize( INT32 hBoxHandle ) { // return size of top margin, for mouse region offsets - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return( 0 ); + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) + return(0); - Assert( PopUpBoxList[ hBoxHandle ] ); + Assert( PopUpBoxList[hBoxHandle] ); - return( PopUpBoxList[hBoxHandle]->uiTopMargin ); + return(PopUpBoxList[hBoxHandle]->uiTopMargin); } -void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ) +void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column ) { // shade iLineNumber Line in box indexed by hBoxHandle if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[hBoxHandle] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - if ( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber] != NULL ) + if ( box->Text[column][iLineNumber] != NULL ) { // set current box SetCurrentBox( hBoxHandle ); // shade line - PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fShadeFlag = TRUE; + box->Text[column][iLineNumber]->fShadeFlag = TRUE; } } -void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ) +void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column ) { // unshade iLineNumber in box indexed by hBoxHandle - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - if( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]!=NULL) + if ( box->Text[column][iLineNumber] != NULL ) { // set current box SetCurrentBox( hBoxHandle ); // shade line - PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fShadeFlag = FALSE; + box->Text[column][iLineNumber]->fShadeFlag = FALSE; } } -void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ) +void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column ) { // shade iLineNumber Line in box indexed by hBoxHandle - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - if( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]!=NULL) + if ( box->Text[column][iLineNumber] != NULL ) { // set current box SetCurrentBox( hBoxHandle ); // shade line - PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fSecondaryShadeFlag = TRUE; + box->Text[column][iLineNumber]->fSecondaryShadeFlag = TRUE; } } -void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ) +void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column ) { // unshade iLineNumber in box indexed by hBoxHandle - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - if( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]!=NULL) + if ( box->Text[column][iLineNumber] != NULL ) { // set current box SetCurrentBox( hBoxHandle ); // shade line - PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fSecondaryShadeFlag = FALSE; + box->Text[column][iLineNumber]->fSecondaryShadeFlag = FALSE; } } -void SetBoxBuffer(INT32 hBoxHandle, UINT32 uiBuffer) +void SetBoxBuffer( INT32 hBoxHandle, UINT32 uiBuffer ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - PopUpBoxList[hBoxHandle]->uiBuffer=uiBuffer; + box->uiBuffer = uiBuffer; - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; + box->fUpdated = FALSE; } -void SetBoxPosition( INT32 hBoxHandle,SGPPoint Position ) +void SetBoxPosition( INT32 hBoxHandle, SGPPoint Position ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - PopUpBoxList[hBoxHandle]->Position.iX=Position.iX; - PopUpBoxList[hBoxHandle]->Position.iY=Position.iY; + box->Position.iX = Position.iX; + box->Position.iY = Position.iY; - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; + box->fUpdated = FALSE; } void GetBoxPosition( INT32 hBoxHandle, SGPPoint *Position ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - Position->iX = PopUpBoxList[hBoxHandle]->Position.iX; - Position->iY = PopUpBoxList[hBoxHandle]->Position.iY; + Position->iX = box->Position.iX; + Position->iY = box->Position.iY; } -void SetBoxSize(INT32 hBoxHandle,SGPRect Dimensions) +void SetBoxSize( INT32 hBoxHandle, SGPRect Dimensions ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - PopUpBoxList[hBoxHandle]->Dimensions.iLeft=Dimensions.iLeft; - PopUpBoxList[hBoxHandle]->Dimensions.iBottom=Dimensions.iBottom; - PopUpBoxList[hBoxHandle]->Dimensions.iRight=Dimensions.iRight; - PopUpBoxList[hBoxHandle]->Dimensions.iTop=Dimensions.iTop; + box->Dimensions.iLeft = Dimensions.iLeft; + box->Dimensions.iBottom = Dimensions.iBottom; + box->Dimensions.iRight = Dimensions.iRight; + box->Dimensions.iTop = Dimensions.iTop; - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; + box->fUpdated = FALSE; } void GetBoxSize( INT32 hBoxHandle, SGPRect *Dimensions ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); + auto box = PopUpBoxList[hBoxHandle]; + Assert( box ); - Dimensions->iLeft = PopUpBoxList[hBoxHandle]->Dimensions.iLeft; - Dimensions->iBottom = PopUpBoxList[hBoxHandle]->Dimensions.iBottom; - Dimensions->iRight = PopUpBoxList[hBoxHandle]->Dimensions.iRight; - Dimensions->iTop = PopUpBoxList[hBoxHandle]->Dimensions.iTop; + Dimensions->iLeft = box->Dimensions.iLeft; + Dimensions->iBottom = box->Dimensions.iBottom; + Dimensions->iRight = box->Dimensions.iRight; + Dimensions->iTop = box->Dimensions.iTop; } -void SetBorderType(INT32 hBoxHandle, INT32 iBorderObjectIndex) +void SetBorderType( INT32 hBoxHandle, INT32 iBorderObjectIndex ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); - PopUpBoxList[hBoxHandle]->iBorderObjectIndex=iBorderObjectIndex; + Assert( PopUpBoxList[hBoxHandle] ); + PopUpBoxList[hBoxHandle]->iBorderObjectIndex = iBorderObjectIndex; } -void SetBackGroundSurface(INT32 hBoxHandle, INT32 iBackGroundSurfaceIndex) +void SetBackGroundSurface( INT32 hBoxHandle, INT32 iBackGroundSurfaceIndex ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ hBoxHandle ] ); - PopUpBoxList[hBoxHandle]->iBackGroundSurface=iBackGroundSurfaceIndex; + Assert( PopUpBoxList[hBoxHandle] ); + PopUpBoxList[hBoxHandle]->iBackGroundSurface = iBackGroundSurfaceIndex; } -// adds a FIRST column string to the CURRENT popup box -void AddMonoString( UINT32 *hStringHandle, STR16 pString ) +// Adds a string to the first available slot in the column +void AddMonoString( UINT32 *hStringHandle, STR16 pString, UINT8 column ) { STR16 pLocalString = NULL; POPUPSTRINGPTR pStringSt = NULL; @@ -360,10 +367,11 @@ void AddMonoString( UINT32 *hStringHandle, STR16 pString ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); // find first free slot in list - for ( iCounter = 0; (iCounter < MAX_POPUP_BOX_STRING_COUNT) && (PopUpBoxList[guiCurrentBox]->Text[0][iCounter] != NULL); iCounter++ ); + for ( iCounter = 0; (iCounter < MAX_POPUP_BOX_STRING_COUNT) && (box->Text[column][iCounter] != NULL); iCounter++ ); if ( iCounter >= MAX_POPUP_BOX_STRING_COUNT ) { @@ -382,17 +390,17 @@ void AddMonoString( UINT32 *hStringHandle, STR16 pString ) wcscpy( pLocalString, pString ); - RemoveCurrentBoxPrimaryText( iCounter ); + RemoveCurrentBoxText( iCounter, column ); - PopUpBoxList[guiCurrentBox]->Text[0][iCounter] = pStringSt; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->fColorFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->pString = pLocalString; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->fShadeFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->fHighLightFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->fSecondaryShadeFlag = FALSE; + box->Text[column][iCounter] = pStringSt; + box->Text[column][iCounter]->fColorFlag = FALSE; + box->Text[column][iCounter]->pString = pLocalString; + box->Text[column][iCounter]->fShadeFlag = FALSE; + box->Text[column][iCounter]->fHighLightFlag = FALSE; + box->Text[column][iCounter]->fSecondaryShadeFlag = FALSE; *hStringHandle = iCounter; - PopUpBoxList[guiCurrentBox]->fUpdated = FALSE; + box->fUpdated = FALSE; return; } @@ -400,232 +408,97 @@ void AddMonoString( UINT32 *hStringHandle, STR16 pString ) // Adds string to the current popup box 2nd column. !!! String's position is the LAST used position in the 1st column !!! void AddSecondColumnMonoString( UINT32 *hStringHandle, STR16 pString ) { - STR16 pLocalString=NULL; - POPUPSTRINGPTR pStringSt=NULL; - INT32 iCounter=0; + STR16 pLocalString = NULL; + POPUPSTRINGPTR pStringSt = NULL; + INT32 iCounter = 0; - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); // find the LAST USED text string index - for( iCounter = 0; ( iCounter + 1 < MAX_POPUP_BOX_STRING_COUNT ) && ( PopUpBoxList[guiCurrentBox]->Text[0][ iCounter + 1 ] != NULL ); iCounter++ ); + for ( iCounter = 0; (iCounter + 1 < MAX_POPUP_BOX_STRING_COUNT) && (box->Text[0][iCounter + 1] != NULL); iCounter++ ); if ( iCounter >= MAX_POPUP_BOX_STRING_COUNT ) { // using too many text lines, or not freeing them up properly - Assert(0); + Assert( 0 ); return; } - pStringSt=(POPUPSTRING *)(MemAlloc(sizeof(POPUPSTRING))); - if (pStringSt == NULL) + pStringSt = (POPUPSTRING *)(MemAlloc( sizeof( POPUPSTRING ) )); + if ( pStringSt == NULL ) return; - pLocalString=(STR16)MemAlloc((wcslen(pString)+1)*sizeof(CHAR16)); - if (pLocalString == NULL) + pLocalString = (STR16)MemAlloc( (wcslen( pString ) + 1) * sizeof( CHAR16 ) ); + if ( pLocalString == NULL ) return; - wcscpy(pLocalString, pString); + wcscpy( pLocalString, pString ); RemoveCurrentBoxSecondaryText( iCounter ); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]=pStringSt; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->fColorFlag=FALSE; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->pString=pLocalString; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->fShadeFlag = FALSE; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->fHighLightFlag = FALSE; - - *hStringHandle=iCounter; - - return; -} - -// Adds a string to the first available slot in the second column -void AddMonoStringToSecondColumn(UINT32* hStringHandle, STR16 pString) -{ - STR16 pLocalString = NULL; - POPUPSTRINGPTR pStringSt = NULL; - INT32 iCounter = 0; - - - if ((guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT)) - return; - - Assert(PopUpBoxList[guiCurrentBox] != NULL); - - // find the free text string index in 2nd column - for (iCounter = 0; (iCounter < MAX_POPUP_BOX_STRING_COUNT) && (PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter] != NULL); iCounter++); - - if (iCounter >= MAX_POPUP_BOX_STRING_COUNT) - { - // using too many text lines, or not freeing them up properly - Assert(0); - return; - } - - pStringSt = (POPUPSTRING*)(MemAlloc(sizeof(POPUPSTRING))); - if (pStringSt == NULL) - return; - - pLocalString = (STR16)MemAlloc((wcslen(pString) + 1) * sizeof(CHAR16)); - if (pLocalString == NULL) - return; - - wcscpy(pLocalString, pString); - - RemoveCurrentBoxSecondaryText(iCounter); - - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter] = pStringSt; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->fColorFlag = FALSE; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->pString = pLocalString; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->fShadeFlag = FALSE; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[iCounter]->fHighLightFlag = FALSE; + box->Text[1][iCounter] = pStringSt; + box->Text[1][iCounter]->fColorFlag = FALSE; + box->Text[1][iCounter]->pString = pLocalString; + box->Text[1][iCounter]->fShadeFlag = FALSE; + box->Text[1][iCounter]->fHighLightFlag = FALSE; + box->Text[1][iCounter]->fSecondaryShadeFlag = FALSE; *hStringHandle = iCounter; return; } -// Adds a string to the first available slot in the column -void AddStringToBoxColumn( UINT32 *hStringHandle, STR16 pString, UINT8 column ) -{ - STR16 pLocalString = NULL; - POPUPSTRINGPTR pStringSt = NULL; - INT32 iCounter = 0; - - - if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) || column >= MAX_POPUP_BOX_COLUMNS ) - return; - - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - - // find first free slot in list - for ( iCounter = 0; (iCounter < MAX_POPUP_BOX_STRING_COUNT) && (PopUpBoxList[guiCurrentBox]->Text[column][iCounter] != NULL); iCounter++ ); - - if ( iCounter >= MAX_POPUP_BOX_STRING_COUNT ) - { - // using too many text lines, or not freeing them up properly - Assert( 0 ); - return; - } - - pStringSt = (POPUPSTRING *)(MemAlloc( sizeof( POPUPSTRING ) )); - if ( pStringSt == NULL ) - return; - - pLocalString = (STR16)MemAlloc( (wcslen( pString ) + 1) * sizeof( CHAR16 ) ); - if ( pLocalString == NULL ) - return; - - wcscpy( pLocalString, pString ); - - RemoveCurrentBoxText( iCounter, column ); - - PopUpBoxList[guiCurrentBox]->Text[column][iCounter] = pStringSt; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fColorFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->pString = pLocalString; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fShadeFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fHighLightFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fSecondaryShadeFlag = FALSE; - - *hStringHandle = iCounter; - PopUpBoxList[guiCurrentBox]->fUpdated = FALSE; - return; -} - -// Adds string to the current popup box column besides first. !!! String's position is the LAST used position in the 1st column !!! -void AddColumnMonoString( UINT32 *hStringHandle, STR16 pString, UINT8 column ) -{ - STR16 pLocalString = NULL; - POPUPSTRINGPTR pStringSt = NULL; - INT32 iCounter = 0; - - - if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) || column < 1 || column >= MAX_POPUP_BOX_COLUMNS) - return; - - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - - // find the LAST USED text string index - for ( iCounter = 0; (iCounter + 1 < MAX_POPUP_BOX_STRING_COUNT) && (PopUpBoxList[guiCurrentBox]->Text[0][iCounter + 1] != NULL); iCounter++ ); - - if ( iCounter >= MAX_POPUP_BOX_STRING_COUNT ) - { - // using too many text lines, or not freeing them up properly - Assert( 0 ); - return; - } - - pStringSt = (POPUPSTRING *)(MemAlloc( sizeof( POPUPSTRING ) )); - if ( pStringSt == NULL ) - return; - - pLocalString = (STR16)MemAlloc( (wcslen( pString ) + 1) * sizeof( CHAR16 ) ); - if ( pLocalString == NULL ) - return; - - wcscpy( pLocalString, pString ); - - RemoveCurrentBoxText( iCounter, column ); - - PopUpBoxList[guiCurrentBox]->Text[column][iCounter] = pStringSt; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fColorFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->pString = pLocalString; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fShadeFlag = FALSE; - PopUpBoxList[guiCurrentBox]->Text[column][iCounter]->fHighLightFlag = FALSE; - - *hStringHandle = iCounter; - return; -} - // Adds a COLORED first column string to the CURRENT box -void AddColorString(INT32 *hStringHandle, STR16 pString) +void AddColorString( INT32 *hStringHandle, STR16 pString, UINT8 column ) { - STR16 pLocalString; - POPUPSTRINGPTR pStringSt=NULL; - INT32 iCounter=0; + STR16 pLocalString; + POPUPSTRINGPTR pStringSt = NULL; + INT32 iCounter = 0; - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); - // find first free slot in list - for( iCounter = 0; ( iCounter < MAX_POPUP_BOX_STRING_COUNT ) && ( PopUpBoxList[guiCurrentBox]->Text[0][iCounter] != NULL ); iCounter++ ); + // find first free slot in list + for ( iCounter = 0; (iCounter < MAX_POPUP_BOX_STRING_COUNT) && (box->Text[column][iCounter] != NULL); iCounter++ ); + + if ( iCounter >= MAX_POPUP_BOX_STRING_COUNT ) + { + // using too many text lines, or not freeing them up properly + Assert( 0 ); + return; + } + + pStringSt = (POPUPSTRING *)(MemAlloc( sizeof( POPUPSTRING ) )); + if ( pStringSt == NULL ) + return; + + pLocalString = (STR16)MemAlloc( (wcslen( pString ) + 1) * sizeof( CHAR16 ) ); + if ( pLocalString == NULL ) + return; + + wcscpy( pLocalString, pString ); + + RemoveCurrentBoxText( iCounter, column ); + + box->Text[column][iCounter] = pStringSt; + box->Text[column][iCounter]->fColorFlag = TRUE; + box->Text[column][iCounter]->pString = pLocalString; + + *hStringHandle = iCounter; + + box->fUpdated = FALSE; - if ( iCounter >= MAX_POPUP_BOX_STRING_COUNT ) - { - // using too many text lines, or not freeing them up properly - Assert(0); return; - } - - pStringSt=(POPUPSTRING *)(MemAlloc(sizeof(POPUPSTRING))); - if (pStringSt == NULL) - return; - - pLocalString=(STR16)MemAlloc((wcslen(pString)+1)*sizeof(CHAR16)); - if (pLocalString == NULL) - return; - - wcscpy(pLocalString, pString); - - RemoveCurrentBoxPrimaryText( iCounter ); - - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]=pStringSt; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->fColorFlag=TRUE; - PopUpBoxList[guiCurrentBox]->Text[0][iCounter]->pString=pLocalString; - - *hStringHandle=iCounter; - - PopUpBoxList[guiCurrentBox]->fUpdated = FALSE; - - return; } @@ -637,22 +510,22 @@ void ResizeBoxForSecondStrings( INT32 hBoxHandle ) UINT32 uiBaseWidth, uiThisWidth; - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - pBox = ( PopUpBoxList[ hBoxHandle ] ); + pBox = (PopUpBoxList[hBoxHandle]); Assert( pBox ); uiBaseWidth = pBox->uiLeftMargin + pBox->uiSecondColumnMinimunOffset; // check string sizes - for( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) + for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) { - if( pBox->Text[0][ iCounter ] ) + if ( pBox->Text[0][iCounter] ) { - uiThisWidth = uiBaseWidth + StringPixLength( pBox->Text[0][ iCounter ]->pString, pBox->Text[0][ iCounter ]->uiFont ); + uiThisWidth = uiBaseWidth + StringPixLength( pBox->Text[0][iCounter]->pString, pBox->Text[0][iCounter]->uiFont ); - if( uiThisWidth > pBox->uiSecondColumnCurrentOffset ) + if ( uiThisWidth > pBox->uiSecondColumnCurrentOffset ) { pBox->uiSecondColumnCurrentOffset = uiThisWidth; } @@ -708,39 +581,18 @@ static void ResizeStrategicMvtBoxForSecondStrings( INT32 hBoxHandle ) } -UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle ) +UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle, UINT8 column ) { INT32 iCounter = 0; - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return( 0 ); - - // count number of lines - // check string size - for( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) - { - if( PopUpBoxList[ hBoxHandle ]->Text[0][ iCounter ] == NULL ) - { - break; - } - } - - return( iCounter ); -} - - -UINT32 GetNumberOfSecondaryLinesOfTextInBox(INT32 hBoxHandle) -{ - INT32 iCounter = 0; - - if ((hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT)) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return(0); // count number of lines // check string size - for (iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++) + for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) { - if (PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter] == NULL) + if ( PopUpBoxList[hBoxHandle]->Text[column][iCounter] == NULL ) { break; } @@ -749,6 +601,7 @@ UINT32 GetNumberOfSecondaryLinesOfTextInBox(INT32 hBoxHandle) return(iCounter); } + UINT32 GetTotalNumberOfLinesOfTextInBox( INT32 hBoxHandle ) { UINT32 lines = 0; @@ -780,17 +633,17 @@ void SetBoxFont( INT32 hBoxHandle, UINT32 uiFont ) if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) + for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ ) { - if ( PopUpBoxList[hBoxHandle]->Text[0][uiCounter] != NULL ) + for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { - PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->uiFont = uiFont; + if ( PopUpBoxList[hBoxHandle]->Text[i][uiCounter] != NULL ) + { + PopUpBoxList[hBoxHandle]->Text[i][uiCounter]->uiFont = uiFont; + } } } - // set up the 2nd column font - SetBoxSecondColumnFont( hBoxHandle, uiFont ); - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; return; @@ -798,7 +651,7 @@ void SetBoxFont( INT32 hBoxHandle, UINT32 uiFont ) void SetBoxSecondColumnMinimumOffset( INT32 hBoxHandle, UINT32 uiWidth ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; PopUpBoxList[hBoxHandle]->uiSecondColumnMinimunOffset = uiWidth; @@ -807,41 +660,13 @@ void SetBoxSecondColumnMinimumOffset( INT32 hBoxHandle, UINT32 uiWidth ) void SetBoxSecondColumnCurrentOffset( INT32 hBoxHandle, UINT32 uiCurrentOffset ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; PopUpBoxList[hBoxHandle]->uiSecondColumnCurrentOffset = uiCurrentOffset; return; } -void SetBoxSecondColumnOffsetAdjustment(INT32 hBoxHandle, INT16 x) -{ - if ((hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT)) - return; - - PopUpBoxList[hBoxHandle]->usSecondColumnOffsetAdjustment = x; - return; -} - -void SetBoxSecondColumnFont( INT32 hBoxHandle, UINT32 uiFont ) -{ - UINT32 iCounter = 0; - - if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) - return; - - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) - { - if ( PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter] ) - { - PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter]->uiFont = uiFont; - } - } - - PopUpBoxList[hBoxHandle]->fUpdated = FALSE; - - return; -} void SetBoxColumnFont( INT32 hBoxHandle, UINT32 uiFont, UINT8 column ) { @@ -864,27 +689,27 @@ void SetBoxColumnFont( INT32 hBoxHandle, UINT32 uiFont, UINT8 column ) UINT32 GetBoxFont( INT32 hBoxHandle ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return( 0 ); + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) + return(0); - Assert( PopUpBoxList[ hBoxHandle ] ); - Assert( PopUpBoxList[ hBoxHandle ]->Text[0][ 0 ] ); + Assert( PopUpBoxList[hBoxHandle] ); + Assert( PopUpBoxList[hBoxHandle]->Text[0][0] ); // return font id of first line of text of box - return( PopUpBoxList[hBoxHandle]->Text[0][ 0 ]->uiFont ); + return(PopUpBoxList[hBoxHandle]->Text[0][0]->uiFont); } // set the foreground color of this string in this pop up box void SetBoxLineForeground( INT32 iBox, INT32 iStringValue, UINT8 ubColor ) { - if ( ( iBox < 0 ) || ( iBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (iBox < 0) || (iBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ iBox ] ); - Assert( PopUpBoxList[ iBox ]->Text[0][iStringValue] ); + Assert( PopUpBoxList[iBox] ); + Assert( PopUpBoxList[iBox]->Text[0][iStringValue] ); - PopUpBoxList[iBox]->Text[0][iStringValue]->ubForegroundColor=ubColor; + PopUpBoxList[iBox]->Text[0][iStringValue]->ubForegroundColor = ubColor; return; } @@ -892,16 +717,16 @@ void SetBoxSecondaryShade( INT32 iBox, UINT8 ubColor ) { UINT32 uiCounter; - if ( ( iBox < 0 ) || ( iBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (iBox < 0) || (iBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[ iBox ] ); + Assert( PopUpBoxList[iBox] ); for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { - if (PopUpBoxList[iBox]->Text[0][uiCounter]!=NULL) + if ( PopUpBoxList[iBox]->Text[0][uiCounter] != NULL ) { - PopUpBoxList[iBox]->Text[0][uiCounter]->ubSecondaryShade=ubColor; + PopUpBoxList[iBox]->Text[0][uiCounter]->ubSecondaryShade = ubColor; } } return; @@ -909,30 +734,31 @@ void SetBoxSecondaryShade( INT32 iBox, UINT8 ubColor ) // The following functions operate on the CURRENT box - -void SetPopUpStringFont(INT32 hStringHandle, UINT32 uiFont) +void SetPopUpStringFont( INT32 hStringHandle, UINT32 uiFont ) { - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[0][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->uiFont=uiFont; - return; + box->Text[0][hStringHandle]->uiFont = uiFont; + return; } -void SetPopUpSecondColumnStringFont(INT32 hStringHandle, UINT32 uiFont) +void SetPopUpSecondColumnStringFont( INT32 hStringHandle, UINT32 uiFont ) { - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[1][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->uiFont=uiFont; - return; + box->Text[1][hStringHandle]->uiFont = uiFont; + return; } @@ -942,10 +768,11 @@ void SetStringSecondaryShade( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[0][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->ubSecondaryShade = ubColor; + box->Text[0][hStringHandle]->ubSecondaryShade = ubColor; return; } @@ -954,10 +781,11 @@ void SetStringForeground( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[0][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->ubForegroundColor = ubColor; + box->Text[0][hStringHandle]->ubForegroundColor = ubColor; return; } @@ -966,10 +794,11 @@ void SetStringBackground( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[0][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->ubBackgroundColor = ubColor; + box->Text[0][hStringHandle]->ubBackgroundColor = ubColor; return; } @@ -978,10 +807,11 @@ void SetStringHighLight( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[0][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->ubHighLight = ubColor; + box->Text[0][hStringHandle]->ubHighLight = ubColor; return; } @@ -991,10 +821,11 @@ void SetStringShade( INT32 hStringHandle, UINT8 ubShade ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[0][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->ubShade = ubShade; + box->Text[0][hStringHandle]->ubShade = ubShade; return; } @@ -1003,10 +834,11 @@ void SetStringSecondColumnForeground( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[1][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->ubForegroundColor = ubColor; + box->Text[1][hStringHandle]->ubForegroundColor = ubColor; return; } @@ -1015,10 +847,11 @@ void SetStringSecondColumnBackground( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[1][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->ubBackgroundColor = ubColor; + box->Text[1][hStringHandle]->ubBackgroundColor = ubColor; return; } @@ -1027,10 +860,11 @@ void SetStringSecondColumnHighLight( INT32 hStringHandle, UINT8 ubColor ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[1][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->ubHighLight = ubColor; + box->Text[1][hStringHandle]->ubHighLight = ubColor; return; } @@ -1040,171 +874,95 @@ void SetStringSecondColumnShade( INT32 hStringHandle, UINT8 ubShade ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - Assert( PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle] ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + Assert( box->Text[1][hStringHandle] ); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->ubShade = ubShade; + box->Text[1][hStringHandle]->ubShade = ubShade; return; } -void SetBoxForeground(INT32 hBoxHandle, UINT8 ubColor) +void SetBoxForeground( INT32 hBoxHandle, UINT8 ubColor ) { UINT32 uiCounter; - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return; - - Assert( PopUpBoxList[hBoxHandle] != NULL ); - - for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) - { - if (PopUpBoxList[hBoxHandle]->Text[0][uiCounter]!=NULL) - { - PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubForegroundColor=ubColor; - } - } - return; -} - -void SetBoxBackground(INT32 hBoxHandle, UINT8 ubColor) -{ - UINT32 uiCounter; - - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return; - - Assert( PopUpBoxList[hBoxHandle] != NULL ); - - for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) - { - if (PopUpBoxList[hBoxHandle]->Text[0][uiCounter]!=NULL) - { - PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubBackgroundColor=ubColor; - } - } - return; -} - -void SetBoxHighLight(INT32 hBoxHandle, UINT8 ubColor) -{ - UINT32 uiCounter; - - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return; - - Assert( PopUpBoxList[hBoxHandle] != NULL ); - - for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) - { - if (PopUpBoxList[hBoxHandle]->Text[0][uiCounter]!=NULL) - { - PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubHighLight=ubColor; - } - } - return; -} - -void SetBoxShade(INT32 hBoxHandle, UINT8 ubColor) -{ - UINT32 uiCounter; - - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return; - - Assert( PopUpBoxList[hBoxHandle] != NULL ); - - for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) - { - if (PopUpBoxList[hBoxHandle]->Text[0][uiCounter]!=NULL) - { - PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubShade=ubColor; - } - } - return; -} - -void SetBoxSecondColumnForeground( INT32 hBoxHandle, UINT8 ubColor ) -{ - UINT32 iCounter = 0; - if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; Assert( PopUpBoxList[hBoxHandle] != NULL ); - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) + for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { - if ( PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter] ) + if ( PopUpBoxList[hBoxHandle]->Text[0][uiCounter] != NULL ) { - PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter]->ubForegroundColor = ubColor; + PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubForegroundColor = ubColor; } } - return; } -void SetBoxSecondColumnBackground( INT32 hBoxHandle, UINT8 ubColor ) +void SetBoxBackground( INT32 hBoxHandle, UINT8 ubColor ) { - UINT32 iCounter = 0; + UINT32 uiCounter; if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; Assert( PopUpBoxList[hBoxHandle] != NULL ); - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) + for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { - if ( PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter] ) + if ( PopUpBoxList[hBoxHandle]->Text[0][uiCounter] != NULL ) { - PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter]->ubBackgroundColor = ubColor; + PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubBackgroundColor = ubColor; } } - return; } -void SetBoxSecondColumnHighLight( INT32 hBoxHandle, UINT8 ubColor ) +void SetBoxHighLight( INT32 hBoxHandle, UINT8 ubColor ) { - UINT32 iCounter = 0; + UINT32 uiCounter; if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; Assert( PopUpBoxList[hBoxHandle] != NULL ); - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) + for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { - if ( PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter] ) + if ( PopUpBoxList[hBoxHandle]->Text[0][uiCounter] != NULL ) { - PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter]->ubHighLight = ubColor; + PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubHighLight = ubColor; } } - return; } -void SetBoxSecondColumnShade( INT32 hBoxHandle, UINT8 ubColor ) +void SetBoxShade( INT32 hBoxHandle, UINT8 ubColor ) { - UINT32 iCounter = 0; + UINT32 uiCounter; if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; Assert( PopUpBoxList[hBoxHandle] != NULL ); - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) + for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { - if ( PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter] ) + if ( PopUpBoxList[hBoxHandle]->Text[0][uiCounter] != NULL ) { - PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter]->ubShade = ubColor; + PopUpBoxList[hBoxHandle]->Text[0][uiCounter]->ubShade = ubColor; } } return; } + + void SetBoxColumnForeground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ) { if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) @@ -1293,55 +1051,44 @@ void HighLightLine( INT32 hStringHandle, UINT8 column ) return; } -void HighLight2ndLine( INT32 hStringHandle ) + +BOOLEAN GetShadeFlag( INT32 hStringHandle ) { if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) - return; + return(FALSE); auto box = PopUpBoxList[guiCurrentBox]; Assert( box != NULL ); - if ( !box->pSecondColumnString[hStringHandle] ) - return; - box->pSecondColumnString[hStringHandle]->fHighLightFlag = TRUE; - return; -} - -BOOLEAN GetShadeFlag( INT32 hStringHandle ) -{ - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( !box->Text[0][hStringHandle] ) return(FALSE); - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - - if(!PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]) - return( FALSE ); - - return( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->fShadeFlag); + return(box->Text[0][hStringHandle]->fShadeFlag); } BOOLEAN GetSecondaryShadeFlag( INT32 hStringHandle ) { - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return(FALSE); - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); - if(!PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]) - return( FALSE ); + if ( !box->Text[0][hStringHandle] ) + return(FALSE); - return( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->fSecondaryShadeFlag ); + return(box->Text[0][hStringHandle]->fSecondaryShadeFlag); } void HighLightBoxLine( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; // highlight iLineNumber Line in box indexed by hBoxHandle - if( PopUpBoxList[hBoxHandle]->Text[column][iLineNumber]!=NULL) + if ( PopUpBoxList[hBoxHandle]->Text[column][iLineNumber] != NULL ) { // set current box SetCurrentBox( hBoxHandle ); @@ -1353,122 +1100,103 @@ void HighLightBoxLine( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column ) return; } -void HighLight2ndBoxLine( INT32 hBoxHandle, INT32 iLineNumber ) -{ - if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) - return; - - // highlight iLineNumber Line in box indexed by hBoxHandle - if ( PopUpBoxList[hBoxHandle]->pSecondColumnString[iLineNumber] != NULL ) - { - SetCurrentBox( hBoxHandle ); - HighLight2ndLine( iLineNumber ); - } - - return; -} BOOLEAN GetBoxShadeFlag( INT32 hBoxHandle, INT32 iLineNumber ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return(FALSE); - if( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]!=NULL) + if ( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber] != NULL ) { - return( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fShadeFlag ); + return(PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fShadeFlag); } - return( FALSE ); + return(FALSE); } BOOLEAN GetBoxSecondaryShadeFlag( INT32 hBoxHandle, INT32 iLineNumber ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return(FALSE); - if( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]!=NULL) + if ( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber] != NULL ) { - return( PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fSecondaryShadeFlag ); + return(PopUpBoxList[hBoxHandle]->Text[0][iLineNumber]->fSecondaryShadeFlag); } - return( FALSE ); + return(FALSE); } -void UnHighLightLine( INT32 hStringHandle ) +void UnHighLightLine( INT32 hStringHandle, UINT8 column ) { if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); - if ( !PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] ) + if ( !box->Text[column][hStringHandle] ) return; - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->fHighLightFlag = FALSE; + box->Text[column][hStringHandle]->fHighLightFlag = FALSE; return; } void UnHighLightBox( INT32 hBoxHandle ) { - INT32 iCounter = 0; - if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; auto box = PopUpBoxList[hBoxHandle]; for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ ) { - for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) + for ( INT32 iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) { if ( box->Text[i][iCounter] ) box->Text[i][iCounter]->fHighLightFlag = FALSE; } } +} + +void UnHighLightSecondColumnLine( INT32 hStringHandle ) +{ + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) + return; + + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); + + if ( !box->Text[1][hStringHandle] ) + return; + + box->Text[1][hStringHandle]->fHighLightFlag = FALSE; + return; +} + +void UnHighLightSecondColumnBox( INT32 hBoxHandle ) +{ + INT32 iCounter = 0; + + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) + return; for ( iCounter = 0; iCounter < MAX_POPUP_BOX_STRING_COUNT; iCounter++ ) { - if ( box->pSecondColumnString[iCounter] ) - box->pSecondColumnString[iCounter]->fHighLightFlag = FALSE; + if ( PopUpBoxList[hBoxHandle]->Text[1][iCounter] ) + PopUpBoxList[hBoxHandle]->Text[1][iCounter]->fHighLightFlag = FALSE; } } -void UnHighLightSecondColumnLine(INT32 hStringHandle) +void RemoveOneCurrentBoxString( INT32 hStringHandle, BOOLEAN fFillGaps ) { - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + UINT32 uiCounter = 0; + + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); - - if(!PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]) - return; - - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->fHighLightFlag=FALSE; - return; -} - -void UnHighLightSecondColumnBox(INT32 hBoxHandle) -{ - INT32 iCounter=0; - - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) - return; - - for(iCounter=0; iCounter pSecondColumnString[iCounter]) - PopUpBoxList[hBoxHandle]->pSecondColumnString[iCounter]->fHighLightFlag=FALSE; - } -} - -void RemoveOneCurrentBoxString(INT32 hStringHandle, BOOLEAN fFillGaps) -{ - UINT32 uiCounter=0; - - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) - return; - - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); Assert( hStringHandle < MAX_POPUP_BOX_STRING_COUNT ); RemoveCurrentBoxPrimaryText( hStringHandle ); @@ -1477,27 +1205,25 @@ void RemoveOneCurrentBoxString(INT32 hStringHandle, BOOLEAN fFillGaps) if ( fFillGaps ) { // shuffle all strings down a slot to fill in the gap - for ( uiCounter = hStringHandle; uiCounter < ( MAX_POPUP_BOX_STRING_COUNT - 1 ); uiCounter++ ) + for ( uiCounter = hStringHandle; uiCounter < (MAX_POPUP_BOX_STRING_COUNT - 1); uiCounter++ ) { - PopUpBoxList[guiCurrentBox]->Text[0][uiCounter]=PopUpBoxList[guiCurrentBox]->Text[0][uiCounter+1]; - PopUpBoxList[guiCurrentBox]->pSecondColumnString[uiCounter]=PopUpBoxList[guiCurrentBox]->pSecondColumnString[uiCounter+1]; + box->Text[0][uiCounter] = box->Text[0][uiCounter + 1]; + box->Text[1][uiCounter] = box->Text[1][uiCounter + 1]; } } - PopUpBoxList[guiCurrentBox]->fUpdated = FALSE; + box->fUpdated = FALSE; } void RemoveAllCurrentBoxStrings( void ) { - UINT32 uiCounter; - if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) || !PopUpBoxList[guiCurrentBox] ) return; for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ ) { - for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) + for ( UINT32 uiCounter = 0; uiCounter < MAX_POPUP_BOX_STRING_COUNT; uiCounter++ ) { RemoveCurrentBoxText( uiCounter, i ); } @@ -1529,14 +1255,14 @@ void RemoveBox( INT32 hBoxHandle ) -void ShowBox(INT32 hBoxHandle) +void ShowBox( INT32 hBoxHandle ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - if( PopUpBoxList[hBoxHandle] != NULL ) + if ( PopUpBoxList[hBoxHandle] != NULL ) { - if( PopUpBoxList[hBoxHandle]->fShowBox == FALSE ) + if ( PopUpBoxList[hBoxHandle]->fShowBox == FALSE ) { PopUpBoxList[hBoxHandle]->fShowBox = TRUE; PopUpBoxList[hBoxHandle]->fUpdated = FALSE; @@ -1544,14 +1270,14 @@ void ShowBox(INT32 hBoxHandle) } } -void HideBox(INT32 hBoxHandle) +void HideBox( INT32 hBoxHandle ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; - if( PopUpBoxList[hBoxHandle] != NULL ) + if ( PopUpBoxList[hBoxHandle] != NULL ) { - if( PopUpBoxList[hBoxHandle]->fShowBox == TRUE ) + if ( PopUpBoxList[hBoxHandle]->fShowBox == TRUE ) { PopUpBoxList[hBoxHandle]->fShowBox = FALSE; PopUpBoxList[hBoxHandle]->fUpdated = FALSE; @@ -1561,27 +1287,27 @@ void HideBox(INT32 hBoxHandle) -void SetCurrentBox(INT32 hBoxHandle) +void SetCurrentBox( INT32 hBoxHandle ) { - if ( ( hBoxHandle < 0 ) || ( hBoxHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) return; guiCurrentBox = hBoxHandle; } -void GetCurrentBox(INT32 *hBoxHandle) +void GetCurrentBox( INT32 *hBoxHandle ) { *hBoxHandle = guiCurrentBox; } -void DisplayBoxes(UINT32 uiBuffer) +void DisplayBoxes( UINT32 uiBuffer ) { UINT32 uiCounter; - for( uiCounter=0; uiCounter < MAX_POPUP_BOX_COUNT; uiCounter++ ) + for ( uiCounter = 0; uiCounter < MAX_POPUP_BOX_COUNT; uiCounter++ ) { DisplayOnePopupBox( uiCounter, uiBuffer ); } @@ -1609,75 +1335,75 @@ void DisplayOnePopupBox( UINT32 uiIndex, UINT32 uiBuffer ) // force an update of this box void ForceUpDateOfBox( UINT32 uiIndex ) { - if ( ( uiIndex < 0 ) || ( uiIndex >= MAX_POPUP_BOX_COUNT ) ) + if ( (uiIndex < 0) || (uiIndex >= MAX_POPUP_BOX_COUNT) ) return; - if( PopUpBoxList[ uiIndex ] != NULL ) + if ( PopUpBoxList[uiIndex] != NULL ) { - PopUpBoxList[ uiIndex ]->fUpdated = FALSE; + PopUpBoxList[uiIndex]->fUpdated = FALSE; } } -BOOLEAN DrawBox(UINT32 uiCounter) +BOOLEAN DrawBox( UINT32 uiCounter ) { // will build pop up box in usTopX, usTopY with dimensions usWidth and usHeight UINT32 uiNumTilesWide; UINT32 uiNumTilesHigh; - UINT32 uiCount=0; + UINT32 uiCount = 0; HVOBJECT hBoxHandle; HVSURFACE hSrcVSurface; UINT32 uiDestPitchBYTES; UINT32 uiSrcPitchBYTES; - UINT16 *pDestBuf; - UINT8 *pSrcBuf; + UINT16 *pDestBuf; + UINT8 *pSrcBuf; SGPRect clip; UINT16 usTopX, usTopY; UINT16 usWidth, usHeight; - if ( ( uiCounter < 0 ) || ( uiCounter >= MAX_POPUP_BOX_COUNT ) ) + if ( (uiCounter < 0) || (uiCounter >= MAX_POPUP_BOX_COUNT) ) return(FALSE); - - Assert( PopUpBoxList[uiCounter] != NULL ); + auto box = PopUpBoxList[uiCounter]; + Assert( box != NULL ); // only update if we need to - if( PopUpBoxList[uiCounter]->fUpdated == TRUE ) + if ( box->fUpdated == TRUE ) { - return( FALSE ); + return(FALSE); } - PopUpBoxList[uiCounter]->fUpdated = TRUE; + box->fUpdated = TRUE; - if( PopUpBoxList[uiCounter]->uiFlags & POPUP_BOX_FLAG_RESIZE ) + if ( box->uiFlags & POPUP_BOX_FLAG_RESIZE ) { - ResizeBoxToText(uiCounter); + ResizeBoxToText( uiCounter ); } - usTopX=(UINT16)PopUpBoxList[uiCounter]->Position.iX; - usTopY=(UINT16)PopUpBoxList[uiCounter]->Position.iY; - usWidth = ((UINT16)(PopUpBoxList[uiCounter]->Dimensions.iRight - PopUpBoxList[uiCounter]->Dimensions.iLeft + PopUpBoxList[uiCounter]->usSecondColumnOffsetAdjustment)); - usHeight=((UINT16)(PopUpBoxList[uiCounter]->Dimensions.iBottom-PopUpBoxList[uiCounter]->Dimensions.iTop)); + usTopX = (UINT16)box->Position.iX; + usTopY = (UINT16)box->Position.iY; + usWidth = ((UINT16)(box->Dimensions.iRight - box->Dimensions.iLeft)); + usHeight = ((UINT16)(box->Dimensions.iBottom - box->Dimensions.iTop)); //CHRISL: Adjust position for screen limits - if((usTopX + usWidth) > SCREEN_WIDTH && usTopX > ((usTopX + usWidth) - SCREEN_WIDTH)) + if ( (usTopX + usWidth) > SCREEN_WIDTH && usTopX > ((usTopX + usWidth) - SCREEN_WIDTH) ) { usTopX -= ((usTopX + usWidth) - SCREEN_WIDTH); - PopUpBoxList[uiCounter]->Position.iX -= (PopUpBoxList[uiCounter]->Position.iX - usTopX); + box->Position.iX -= (box->Position.iX - usTopX); } - if((usTopY + usHeight) > SCREEN_HEIGHT && usTopY > ((usTopY + usHeight) - SCREEN_HEIGHT)) + if ( (usTopY + usHeight) > SCREEN_HEIGHT && usTopY > ((usTopY + usHeight) - SCREEN_HEIGHT) ) { usTopY -= ((usTopY + usHeight) - SCREEN_HEIGHT); - PopUpBoxList[uiCounter]->Position.iY -= (PopUpBoxList[uiCounter]->Position.iY - usTopY); + box->Position.iY -= (box->Position.iY - usTopY); } // check if we have a min width, if so then update box for such - if( ( PopUpBoxList[uiCounter]->uiBoxMinWidth ) && ( usWidth < PopUpBoxList[uiCounter]->uiBoxMinWidth ) ) + if ( (box->uiBoxMinWidth) && (usWidth < box->uiBoxMinWidth) ) { - usWidth = ( INT16 )( PopUpBoxList[uiCounter]->uiBoxMinWidth ); + usWidth = (INT16)(box->uiBoxMinWidth); } // make sure it will fit on screen! @@ -1685,56 +1411,56 @@ BOOLEAN DrawBox(UINT32 uiCounter) Assert( usTopY + usHeight <= SCREEN_HEIGHT ); // subtract 4 because the 2 2-pixel corners are handled separately - uiNumTilesWide=((usWidth-4)/BORDER_WIDTH); - uiNumTilesHigh=((usHeight-4)/BORDER_HEIGHT); + uiNumTilesWide = ((usWidth - 4) / BORDER_WIDTH); + uiNumTilesHigh = ((usHeight - 4) / BORDER_HEIGHT); - clip.iLeft=0; - clip.iRight=clip.iLeft+usWidth; - clip.iTop=0; - clip.iBottom=clip.iTop+usHeight; + clip.iLeft = 0; + clip.iRight = clip.iLeft + usWidth; + clip.iTop = 0; + clip.iBottom = clip.iTop + usHeight; // blit in texture first, then borders // blit in surface - pDestBuf = (UINT16*)LockVideoSurface(PopUpBoxList[uiCounter]->uiBuffer, &uiDestPitchBYTES); - CHECKF( GetVideoSurface( &hSrcVSurface, PopUpBoxList[uiCounter]->iBackGroundSurface) ); - pSrcBuf = LockVideoSurface( PopUpBoxList[uiCounter]->iBackGroundSurface, &uiSrcPitchBYTES); - Blt8BPPDataSubTo16BPPBuffer( pDestBuf, uiDestPitchBYTES, hSrcVSurface, pSrcBuf,uiSrcPitchBYTES,usTopX,usTopY, &clip); - UnLockVideoSurface( PopUpBoxList[uiCounter]->iBackGroundSurface); - UnLockVideoSurface(PopUpBoxList[uiCounter]->uiBuffer); - GetVideoObject(&hBoxHandle, PopUpBoxList[uiCounter]->iBorderObjectIndex); + pDestBuf = (UINT16 *)LockVideoSurface( box->uiBuffer, &uiDestPitchBYTES ); + CHECKF( GetVideoSurface( &hSrcVSurface, box->iBackGroundSurface ) ); + pSrcBuf = LockVideoSurface( box->iBackGroundSurface, &uiSrcPitchBYTES ); + Blt8BPPDataSubTo16BPPBuffer( pDestBuf, uiDestPitchBYTES, hSrcVSurface, pSrcBuf, uiSrcPitchBYTES, usTopX, usTopY, &clip ); + UnLockVideoSurface( box->iBackGroundSurface ); + UnLockVideoSurface( box->uiBuffer ); + GetVideoObject( &hBoxHandle, box->iBorderObjectIndex ); // blit in 4 corners (they're 2x2 pixels) - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, TOP_LEFT_CORNER,usTopX,usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, TOP_RIGHT_CORNER,usTopX+usWidth-2,usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, BOTTOM_RIGHT_CORNER,usTopX+usWidth-2,usTopY+usHeight-2, VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, BOTTOM_LEFT_CORNER,usTopX,usTopY+usHeight-2, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, TOP_LEFT_CORNER, usTopX, usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, TOP_RIGHT_CORNER, usTopX + usWidth - 2, usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, BOTTOM_RIGHT_CORNER, usTopX + usWidth - 2, usTopY + usHeight - 2, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, BOTTOM_LEFT_CORNER, usTopX, usTopY + usHeight - 2, VO_BLT_SRCTRANSPARENCY, NULL ); // blit in edges - if (uiNumTilesWide > 0) + if ( uiNumTilesWide > 0 ) { // full pieces - for (uiCount=0; uiCount uiBuffer, hBoxHandle, TOP_EDGE, usTopX+2+(uiCount*BORDER_WIDTH),usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, BOTTOM_EDGE,usTopX+2+(uiCount*BORDER_WIDTH),usTopY+usHeight-2, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, TOP_EDGE, usTopX + 2 + (uiCount * BORDER_WIDTH), usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, BOTTOM_EDGE, usTopX + 2 + (uiCount * BORDER_WIDTH), usTopY + usHeight - 2, VO_BLT_SRCTRANSPARENCY, NULL ); } // partial pieces - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, TOP_EDGE, usTopX+usWidth-2-BORDER_WIDTH,usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, BOTTOM_EDGE,usTopX+usWidth-2-BORDER_WIDTH,usTopY+usHeight-2, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, TOP_EDGE, usTopX + usWidth - 2 - BORDER_WIDTH, usTopY, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, BOTTOM_EDGE, usTopX + usWidth - 2 - BORDER_WIDTH, usTopY + usHeight - 2, VO_BLT_SRCTRANSPARENCY, NULL ); } - if (uiNumTilesHigh > 0) + if ( uiNumTilesHigh > 0 ) { // full pieces - for (uiCount=0; uiCount uiBuffer, hBoxHandle, SIDE_EDGE,usTopX, usTopY+2+(uiCount*BORDER_HEIGHT), VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, SIDE_EDGE,usTopX+usWidth-2,usTopY+2+(uiCount*BORDER_HEIGHT), VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, SIDE_EDGE, usTopX, usTopY + 2 + (uiCount * BORDER_HEIGHT), VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, SIDE_EDGE, usTopX + usWidth - 2, usTopY + 2 + (uiCount * BORDER_HEIGHT), VO_BLT_SRCTRANSPARENCY, NULL ); } // partial pieces - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, SIDE_EDGE,usTopX, usTopY+usHeight-2-BORDER_HEIGHT, VO_BLT_SRCTRANSPARENCY, NULL ); - BltVideoObject(PopUpBoxList[uiCounter]->uiBuffer, hBoxHandle, SIDE_EDGE,usTopX+usWidth-2,usTopY+usHeight-2-BORDER_HEIGHT, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, SIDE_EDGE, usTopX, usTopY + usHeight - 2 - BORDER_HEIGHT, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( box->uiBuffer, hBoxHandle, SIDE_EDGE, usTopX + usWidth - 2, usTopY + usHeight - 2 - BORDER_HEIGHT, VO_BLT_SRCTRANSPARENCY, NULL ); } InvalidateRegion( usTopX, usTopY, usTopX + usWidth, usTopY + usHeight ); @@ -1753,9 +1479,9 @@ BOOLEAN DrawBoxText( UINT32 uiCounter ) if ( (uiCounter < 0) || (uiCounter >= MAX_POPUP_BOX_COUNT) ) return(FALSE); - Assert( PopUpBoxList[uiCounter] != NULL ); - auto box = PopUpBoxList[uiCounter]; + Assert( box != NULL ); + //clip text? if ( box->uiFlags & POPUP_BOX_FLAG_CLIP_TEXT ) { @@ -1768,7 +1494,6 @@ BOOLEAN DrawBoxText( UINT32 uiCounter ) for ( size_t i = 0; i < MAX_POPUP_BOX_COLUMNS; i++ ) { - for ( uiCount = 0; uiCount < MAX_POPUP_BOX_STRING_COUNT; uiCount++ ) { auto entry = box->Text[i][uiCount]; @@ -1816,7 +1541,7 @@ BOOLEAN DrawBoxText( UINT32 uiCounter ) } else { - uX = box->Position.iX + box->uiLeftMargin + box->uiSecondColumnCurrentOffset*i; + uX = box->Position.iX + box->uiLeftMargin + box->uiSecondColumnCurrentOffset * i; uY = ((INT16)(box->Position.iY + uiCount * GetFontHeight( entry->uiFont ) + box->uiTopMargin + uiCount * box->uiLineSpace)); } @@ -1826,53 +1551,6 @@ BOOLEAN DrawBoxText( UINT32 uiCounter ) } } - for ( uiCount = 0; uiCount < MAX_POPUP_BOX_STRING_COUNT; uiCount++ ) - { - // there is secondary text in this line? - if ( box->pSecondColumnString[uiCount] ) - { - // set font - SetFont( box->pSecondColumnString[uiCount]->uiFont ); - - // are we highlighting?...shading?..or neither - if ( (box->pSecondColumnString[uiCount]->fHighLightFlag == FALSE) && (box->pSecondColumnString[uiCount]->fShadeFlag == FALSE) ) - { - // neither - SetFontForeground( box->pSecondColumnString[uiCount]->ubForegroundColor ); - } - else if ( (box->pSecondColumnString[uiCount]->fHighLightFlag == TRUE) ) - { - // highlight - SetFontForeground( box->pSecondColumnString[uiCount]->ubHighLight ); - } - else - { - //shading - SetFontForeground( box->pSecondColumnString[uiCount]->ubShade ); - } - - // set background - SetFontBackground( box->pSecondColumnString[uiCount]->ubBackgroundColor ); - - // copy string - wcsncpy( sString, box->pSecondColumnString[uiCount]->pString, wcslen( box->pSecondColumnString[uiCount]->pString ) + 1 ); - - // centering? - if ( box->uiFlags & POPUP_BOX_FLAG_CENTER_TEXT ) - { - FindFontCenterCoordinates( ((INT16)(box->Position.iX + box->uiLeftMargin)), ((INT16)(box->Position.iY + uiCount * GetFontHeight( box->pSecondColumnString[uiCount]->uiFont ) + box->uiTopMargin + uiCount * box->uiLineSpace)), ((INT16)(box->Dimensions.iRight - (box->uiRightMargin + box->uiLeftMargin + 2))), ((INT16)GetFontHeight( box->pSecondColumnString[uiCount]->uiFont )), (sString), ((INT32)box->pSecondColumnString[uiCount]->uiFont), &uX, &uY ); - } - else - { - uX = ((INT16)(box->Position.iX + box->uiLeftMargin + box->uiSecondColumnCurrentOffset + box->usSecondColumnOffsetAdjustment)); - uY = ((INT16)(box->Position.iY + uiCount * GetFontHeight( box->pSecondColumnString[uiCount]->uiFont ) + box->uiTopMargin + uiCount * box->uiLineSpace)); - } - - // print - mprintf( uX, uY, box->pSecondColumnString[uiCount]->pString ); - } - } - if ( box->uiBuffer != guiSAVEBUFFER ) { @@ -1892,7 +1570,7 @@ void ResizeBoxToText( INT32 hBoxHandle ) INT32 iWidth = 0; INT32 iHeight = 0; INT32 iCurrString = 0; - INT32 iSecondColumnLength = 0; + INT32 iColumnLength = 0; if ( (hBoxHandle < 0) || (hBoxHandle >= MAX_POPUP_BOX_COUNT) ) @@ -1912,49 +1590,40 @@ void ResizeBoxToText( INT32 hBoxHandle ) auto box = PopUpBoxList[hBoxHandle]; const UINT32 margins = box->uiLeftMargin + box->uiRightMargin; - iHeight = box->uiTopMargin + box->uiBottomMargin; + const auto columnOffset = box->uiSecondColumnCurrentOffset; for ( iCurrString = 0; iCurrString < MAX_POPUP_BOX_STRING_COUNT; iCurrString++ ) { if ( box->Text[0][iCurrString] != NULL ) { - if ( box->Text[3][iCurrString] != NULL && wcscmp( box->Text[3][iCurrString]->pString, L"") != 0) + if ( box->Text[3][iCurrString] != NULL && wcscmp( box->Text[3][iCurrString]->pString, L"" ) != 0 ) { - iSecondColumnLength = StringPixLength( box->Text[3][iCurrString]->pString, box->Text[3][iCurrString]->uiFont ); - if ( 3*box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins > iWidth ) + iColumnLength = StringPixLength( box->Text[3][iCurrString]->pString, box->Text[3][iCurrString]->uiFont ); + if ( 3 * columnOffset + iColumnLength + margins > iWidth ) { - iWidth = 3*box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins; + iWidth = 3 * columnOffset + iColumnLength + margins; } } else if ( box->Text[2][iCurrString] != NULL && wcscmp( box->Text[2][iCurrString]->pString, L"" ) != 0 ) { - iSecondColumnLength = StringPixLength( box->Text[2][iCurrString]->pString, box->Text[2][iCurrString]->uiFont ); - if ( 2*box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins > iWidth ) + iColumnLength = StringPixLength( box->Text[2][iCurrString]->pString, box->Text[2][iCurrString]->uiFont ); + if ( 2 * columnOffset + iColumnLength + margins > iWidth ) { - iWidth = 2*box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins; + iWidth = 2 * columnOffset + iColumnLength + margins; } } else if ( box->Text[1][iCurrString] != NULL && wcscmp( box->Text[1][iCurrString]->pString, L"" ) != 0 ) { - iSecondColumnLength = StringPixLength( box->Text[1][iCurrString]->pString, box->Text[1][iCurrString]->uiFont ); - if ( box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins > iWidth ) + iColumnLength = StringPixLength( box->Text[1][iCurrString]->pString, box->Text[1][iCurrString]->uiFont ); + if ( columnOffset + iColumnLength + margins > iWidth ) { - iWidth = box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins; + iWidth = columnOffset + iColumnLength + margins; } } - if ( box->pSecondColumnString[iCurrString] != NULL ) - { - iSecondColumnLength = StringPixLength( box->pSecondColumnString[iCurrString]->pString, box->pSecondColumnString[iCurrString]->uiFont ); - if ( box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins > iWidth ) - { - iWidth = box->uiSecondColumnCurrentOffset + iSecondColumnLength + margins; - } - } - INT32 iFirstColumnLength = StringPixLength( box->Text[0][iCurrString]->pString, box->Text[0][iCurrString]->uiFont ) + margins; if ( iFirstColumnLength > iWidth ) iWidth = iFirstColumnLength; @@ -1984,15 +1653,15 @@ void ResizeBoxToText( INT32 hBoxHandle ) BOOLEAN IsBoxShown( UINT32 uiHandle ) { - if ( ( uiHandle < 0 ) || ( uiHandle >= MAX_POPUP_BOX_COUNT ) ) + if ( (uiHandle < 0) || (uiHandle >= MAX_POPUP_BOX_COUNT) ) return(FALSE); - if( PopUpBoxList[ uiHandle ] == NULL ) + if ( PopUpBoxList[uiHandle] == NULL ) { - return ( FALSE ); + return (FALSE); } - return( PopUpBoxList[ uiHandle ]->fShowBox ); + return(PopUpBoxList[uiHandle]->fShowBox); } @@ -2001,7 +1670,7 @@ void MarkAllBoxesAsAltered( void ) INT32 iCounter = 0; // mark all boxes as altered - for( iCounter = 0; iCounter < MAX_POPUP_BOX_COUNT; iCounter++ ) + for ( iCounter = 0; iCounter < MAX_POPUP_BOX_COUNT; iCounter++ ) { ForceUpDateOfBox( iCounter ); } @@ -2015,7 +1684,7 @@ void HideAllBoxes( void ) INT32 iCounter = 0; // hide all the boxes that are shown - for(iCounter=0; iCounter < MAX_POPUP_BOX_COUNT; iCounter++) + for ( iCounter = 0; iCounter < MAX_POPUP_BOX_COUNT; iCounter++ ) { HideBox( iCounter ); } @@ -2024,43 +1693,45 @@ void HideAllBoxes( void ) void RemoveCurrentBoxPrimaryText( INT32 hStringHandle ) { - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); Assert( hStringHandle < MAX_POPUP_BOX_STRING_COUNT ); // remove & release primary text - if(PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle] != NULL) + if ( box->Text[0][hStringHandle] != NULL ) { - if ( PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->pString ) + if ( box->Text[0][hStringHandle]->pString ) { - MemFree(PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]->pString); + MemFree( box->Text[0][hStringHandle]->pString ); } - MemFree(PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]); - PopUpBoxList[guiCurrentBox]->Text[0][hStringHandle]=NULL; + MemFree( box->Text[0][hStringHandle] ); + box->Text[0][hStringHandle] = NULL; } } void RemoveCurrentBoxSecondaryText( INT32 hStringHandle ) { - if ( ( guiCurrentBox < 0 ) || ( guiCurrentBox >= MAX_POPUP_BOX_COUNT ) ) + if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); Assert( hStringHandle < MAX_POPUP_BOX_STRING_COUNT ); // remove & release secondary strings - if(PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle] != NULL) + if ( box->Text[1][hStringHandle] != NULL ) { - if ( PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->pString ) + if ( box->Text[1][hStringHandle]->pString ) { - MemFree(PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]->pString); + MemFree( box->Text[1][hStringHandle]->pString ); } - MemFree(PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]); - PopUpBoxList[guiCurrentBox]->pSecondColumnString[hStringHandle]=NULL; + MemFree( box->Text[1][hStringHandle] ); + box->Text[1][hStringHandle] = NULL; } } @@ -2069,11 +1740,12 @@ void RemoveCurrentBoxText( INT32 hStringHandle, UINT8 column ) if ( (guiCurrentBox < 0) || (guiCurrentBox >= MAX_POPUP_BOX_COUNT) || column >= MAX_POPUP_BOX_COLUMNS ) return; - Assert( PopUpBoxList[guiCurrentBox] != NULL ); + auto box = PopUpBoxList[guiCurrentBox]; + Assert( box != NULL ); Assert( hStringHandle < MAX_POPUP_BOX_STRING_COUNT ); // remove & release text - auto textColumn = PopUpBoxList[guiCurrentBox]->Text[column]; + auto textColumn = box->Text[column]; if ( textColumn[hStringHandle] != NULL ) { diff --git a/Utils/PopUpBox.h b/Utils/PopUpBox.h index a140b179..f1b4ded7 100644 --- a/Utils/PopUpBox.h +++ b/Utils/PopUpBox.h @@ -47,14 +47,11 @@ struct popupbox{ UINT32 uiBuffer; UINT32 uiSecondColumnMinimunOffset; UINT32 uiSecondColumnCurrentOffset; - INT16 usSecondColumnOffsetAdjustment; UINT32 uiBoxMinWidth; BOOLEAN fUpdated; BOOLEAN fShowBox; 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; @@ -76,8 +73,7 @@ UINT32 GetLineSpace( INT32 hBoxHandle ); void SetBoxBuffer(INT32 hBoxHandle, UINT32 uiBuffer); void SetBoxPosition(INT32 hBoxHandle,SGPPoint Position); void GetBoxPosition( INT32 hBoxHandle, SGPPoint *Position ); -UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle ); -UINT32 GetNumberOfSecondaryLinesOfTextInBox(INT32 hBoxHandle); +UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle, UINT8 column = 0 ); UINT32 GetTotalNumberOfLinesOfTextInBox( INT32 hBoxHandle ); UINT32 GetBoxSecondColumnCurrentOffset( INT32 hBoxHandle ); void SetBoxSize( INT32 hBoxHandle, SGPRect Dimensions ); @@ -85,8 +81,8 @@ void GetBoxSize( INT32 hBoxHandle, SGPRect *Dimensions ); void SetBoxFlags( INT32 hBoxHandle, UINT32 uiFlags); void SetBorderType(INT32 hBoxHandle,INT32 BorderObjectIndex); void SetBackGroundSurface(INT32 hBoxHandle, INT32 BackGroundSurfaceIndex); -void AddMonoString(UINT32 *hStringHandle, STR16 pString); -void AddColorString(INT32 *hStringHandle, STR16 pString); +void AddMonoString(UINT32 *hStringHandle, STR16 pString, UINT8 column = 0); +void AddColorString(INT32 *hStringHandle, STR16 pString, UINT8 column = 0); void SetPopUpStringFont(INT32 hStringHandle, UINT32 uiFont); void SetBoxFont(INT32 hBoxHandle, UINT32 uiFont); UINT32 GetBoxFont( INT32 hBoxHandle ); @@ -98,13 +94,11 @@ void SetBoxForeground(INT32 hBoxHandle, UINT8 ubColor); void SetBoxBackground(INT32 hBoxHandle, UINT8 ubColor); void SetBoxHighLight(INT32 hBoxHandle, UINT8 ubColor); void SetBoxShade(INT32 hBoxHandle, UINT8 ubColor); -void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); -void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); -void HighLightLine( INT32 hStringHandle, UINT8 column ); -void HighLight2ndLine( INT32 hStringHandle ); +void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 ); +void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 ); +void HighLightLine( INT32 hStringHandle, UINT8 column = 0 ); void HighLightBoxLine( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 ); -void HighLight2ndBoxLine( INT32 hBoxHandle, INT32 iLineNumber ); -void UnHighLightLine(INT32 hStringHandle); +void UnHighLightLine(INT32 hStringHandle, UINT8 column = 0); void UnHighLightBox(INT32 hBoxHandle); void RemoveOneCurrentBoxString(INT32 hStringHandle, BOOLEAN fFillGaps); void RemoveAllCurrentBoxStrings( void ); @@ -116,9 +110,6 @@ void DisplayOnePopupBox( UINT32 uiIndex, UINT32 uiBuffer ); void SetCurrentBox(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 void ResizeBoxToText(INT32 hBoxHandle); @@ -147,10 +138,6 @@ void HideAllBoxes( void ); // add the second column monocrome string 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 void SetBoxSecondColumnMinimumOffset( INT32 hBoxHandle, UINT32 uiWidth ); @@ -164,24 +151,17 @@ void SetStringSecondColumnHighLight(INT32 hStringHandle, UINT8 ubColor); 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 -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 -void SetBoxColumnForeground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); -void SetBoxColumnBackground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); -void SetBoxColumnHighLight( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); -void SetBoxColumnShade( INT32 hBoxHandle, UINT8 ubColor, UINT8 column ); -void SetBoxColumnFont( INT32 hBoxHandle, UINT32 uiFont, UINT8 column ); +void SetBoxColumnForeground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 ); +void SetBoxColumnBackground( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 ); +void SetBoxColumnHighLight( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 ); +void SetBoxColumnShade( INT32 hBoxHandle, UINT8 ubColor, UINT8 column = 0 ); +void SetBoxColumnFont( INT32 hBoxHandle, UINT32 uiFont, UINT8 column = 0 ); // secondary shades for boxes -void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); -void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber ); +void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 ); +void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber, UINT8 column = 0 ); void SetBoxSecondaryShade( INT32 iBox, UINT8 ubColor );