diff --git a/Ja2/SaveLoadScreen.cpp b/Ja2/SaveLoadScreen.cpp index a1a30800f..4b44f31d7 100644 --- a/Ja2/SaveLoadScreen.cpp +++ b/Ja2/SaveLoadScreen.cpp @@ -1398,7 +1398,6 @@ BOOLEAN DisplaySaveGameEntry( INT32 bEntryID ) CHAR16 zDateString[128]; CHAR16 zLocationString[128]; CHAR16 zNumMercsString[128]; - CHAR16 zBalanceString[128]; SAVED_GAME_HEADER SaveGameHeader; HVOBJECT hPixHandle; UINT16 usPosX=SLG_FIRST_SAVED_SPOT_X; @@ -1669,11 +1668,6 @@ BOOLEAN DisplaySaveGameEntry( INT32 bEntryID ) } } - //Get the current balance - swprintf( zBalanceString, L"%d", SaveGameHeader.iCurrentBalance); - InsertCommasForDollarFigure( zBalanceString ); - InsertDollarSignInToString( zBalanceString ); - // // Display the Saved game information // @@ -1692,7 +1686,7 @@ BOOLEAN DisplaySaveGameEntry( INT32 bEntryID ) //The balance if(!is_networked) - DrawTextToScreen( zBalanceString, (UINT16)(usPosX+SLG_BALANCE_OFFSET_X), (UINT16)(usPosY+SLG_BALANCE_OFFSET_Y), 0, uiFont, ubFontColor, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); + DrawTextToScreen(FormatMoney(SaveGameHeader.iCurrentBalance).data(), (UINT16)(usPosX + SLG_BALANCE_OFFSET_X), (UINT16)(usPosY + SLG_BALANCE_OFFSET_Y), 0, uiFont, ubFontColor, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); if( gbSaveGameArray[ VAL_SLOT_START + bEntryID ] || ( gfSaveGame && !gfUserInTextInputMode && ( gbSelectedSaveLocation == bEntryID ) ) ) { diff --git a/Laptop/AimMembers.cpp b/Laptop/AimMembers.cpp index f783d528f..63acc6fb5 100644 --- a/Laptop/AimMembers.cpp +++ b/Laptop/AimMembers.cpp @@ -1099,7 +1099,6 @@ BOOLEAN RenderAIMMembers() HVOBJECT hPriceHandle; HVOBJECT hWeaponBoxHandle; UINT16 x, uiPosX; - CHAR16 wTemp[50]; DrawAimDefaults(); @@ -1144,11 +1143,8 @@ BOOLEAN RenderAIMMembers() //Display Option Gear Cost text DrawTextToScreen(CharacterInfo[AIM_MEMBER_OPTIONAL_GEAR_NSGI], AIM_MEMBER_OPTIONAL_GEAR_X_NSGI, EXPLOSIVE_Y_NSGI, AIM_CONTRACT_WIDTH_NSGI, AIM_M_FONT_STATIC_TEXT, AIM_M_COLOR_STATIC_TEXT, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED ); - swprintf(wTemp, L"%d", gMercProfiles[gbCurrentSoldier].usOptionalGearCost); - InsertCommasForDollarFigure( wTemp ); - InsertDollarSignInToString( wTemp ); uiPosX = AIM_MEMBER_OPTIONAL_GEAR_X_NSGI + StringPixLength( CharacterInfo[AIM_MEMBER_OPTIONAL_GEAR_NSGI], AIM_M_FONT_STATIC_TEXT) + 5; - DrawTextToScreen(wTemp, AIM_MEMBER_OPTIONAL_GEAR_COST_X_NSGI, EXPLOSIVE_Y_NSGI, FEE_WIDTH_NSGI, AIM_M_FONT_STATIC_TEXT, AIM_M_COLOR_DYNAMIC_TEXT, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED ); + DrawTextToScreen(FormatMoney(gMercProfiles[gbCurrentSoldier].usOptionalGearCost).data(), AIM_MEMBER_OPTIONAL_GEAR_COST_X_NSGI, EXPLOSIVE_Y_NSGI, FEE_WIDTH_NSGI, AIM_M_FONT_STATIC_TEXT, AIM_M_COLOR_DYNAMIC_TEXT, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); #endif // JA2UB } else @@ -1191,11 +1187,8 @@ BOOLEAN RenderAIMMembers() //Display Option Gear Cost text DrawTextToScreen(CharacterInfo[AIM_MEMBER_OPTIONAL_GEAR], AIM_MEMBER_OPTIONAL_GEAR_X, AIM_MEMBER_OPTIONAL_GEAR_Y, 0, AIM_M_FONT_STATIC_TEXT, AIM_M_COLOR_STATIC_TEXT, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); - swprintf(wTemp, L"%d", gMercProfiles[gbCurrentSoldier].usOptionalGearCost); - InsertCommasForDollarFigure( wTemp ); - InsertDollarSignInToString( wTemp ); uiPosX = AIM_MEMBER_OPTIONAL_GEAR_X + StringPixLength( CharacterInfo[AIM_MEMBER_OPTIONAL_GEAR], AIM_M_FONT_STATIC_TEXT) + 5; - DrawTextToScreen(wTemp, uiPosX, AIM_MEMBER_OPTIONAL_GEAR_Y, 0, AIM_M_FONT_STATIC_TEXT, AIM_M_COLOR_DYNAMIC_TEXT, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); + DrawTextToScreen(FormatMoney(gMercProfiles[gbCurrentSoldier].usOptionalGearCost).data(), uiPosX, AIM_MEMBER_OPTIONAL_GEAR_Y, 0, AIM_M_FONT_STATIC_TEXT, AIM_M_COLOR_DYNAMIC_TEXT, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); #endif } @@ -1261,16 +1254,6 @@ BOOLEAN DrawNumeralsToScreen(INT32 iNumber, INT8 bWidth, UINT16 usLocX, UINT16 u return(TRUE); } -static auto FormatMoney(INT32 iNumber) -> std::wstring -{ - CHAR16 sStr[10]; - - swprintf(sStr, L"%d",iNumber); - InsertCommasForDollarFigure( sStr ); - InsertDollarSignInToString( sStr ); - - return std::wstring(sStr); -} void SelectFaceRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason ) @@ -1347,15 +1330,10 @@ BOOLEAN UpdateMercInfo(void) //if medical deposit is required if( gMercProfiles[gbCurrentSoldier].bMedicalDeposit ) { - CHAR16 zTemp[40]; CHAR16 sMedicalString[40]; // Display the medical cost - swprintf( zTemp, L"%d", gMercProfiles[ gbCurrentSoldier ].sMedicalDepositAmount ); - InsertCommasForDollarFigure( zTemp ); - InsertDollarSignInToString( zTemp ); - - swprintf( sMedicalString, L"%s %s", zTemp, CharacterInfo[AIM_MEMBER_MEDICAL_DEPOSIT_REQ] ); + swprintf( sMedicalString, L"%s %s", FormatMoney(gMercProfiles[gbCurrentSoldier].sMedicalDepositAmount).data(), CharacterInfo[AIM_MEMBER_MEDICAL_DEPOSIT_REQ] ); // If the string will be displayed in more then 2 lines, recenter the string if( ( DisplayWrappedString( 0, 0, AIM_MEDICAL_DEPOSIT_WIDTH_NSGI, 2, AIM_FONT12ARIAL, AIM_M_COLOR_DYNAMIC_TEXT, sMedicalString, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED | DONT_DISPLAY_TEXT ) / GetFontHeight( AIM_FONT12ARIAL ) ) > 2 ) @@ -1413,11 +1391,7 @@ BOOLEAN UpdateMercInfo(void) CHAR16 sMedicalString[40]; // Display the medical cost - swprintf( zTemp, L"%d", gMercProfiles[ gbCurrentSoldier ].sMedicalDepositAmount ); - InsertCommasForDollarFigure( zTemp ); - InsertDollarSignInToString( zTemp ); - - swprintf( sMedicalString, L"%s %s", zTemp, CharacterInfo[AIM_MEMBER_MEDICAL_DEPOSIT_REQ] ); + swprintf( sMedicalString, L"%s %s", FormatMoney(gMercProfiles[gbCurrentSoldier].sMedicalDepositAmount).data(), CharacterInfo[AIM_MEMBER_MEDICAL_DEPOSIT_REQ] ); // If the string will be displayed in more then 2 lines, recenter the string if( ( DisplayWrappedString( 0, 0, AIM_MEDICAL_DEPOSIT_WIDTH, 2, AIM_FONT12ARIAL, AIM_M_COLOR_DYNAMIC_TEXT, sMedicalString, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED | DONT_DISPLAY_TEXT ) / GetFontHeight( AIM_FONT12ARIAL ) ) > 2 ) @@ -2696,7 +2670,6 @@ void DisplaySelectLights(BOOLEAN fContractDown, BOOLEAN fBuyEquipDown) UINT32 DisplayMercChargeAmount() { CHAR16 wTemp[50]; - CHAR16 wDollarTemp[50]; HVOBJECT hImageHandle; @@ -2742,24 +2715,17 @@ UINT32 DisplayMercChargeAmount() } - swprintf( wDollarTemp, L"%d", giContractAmount); - InsertCommasForDollarFigure( wDollarTemp ); - InsertDollarSignInToString( wDollarTemp ); - //if the merc hasnt just been hired // if( FindSoldierByProfileID( gbCurrentSoldier, TRUE ) == NULL ) { -#ifdef JA2UB - // Don't even have to pay for medical insurance! What a DEAL! - swprintf(wTemp, L"%s", wDollarTemp); -#else - if( gMercProfiles[ gbCurrentSoldier ].bMedicalDeposit ) - swprintf(wTemp, L"%s %s", wDollarTemp, VideoConfercingText[AIM_MEMBER_WITH_MEDICAL] ); - else - swprintf(wTemp, L"%s", wDollarTemp ); -#endif // JA2UB + auto contractAmount{ FormatMoney(giContractAmount) }; +#ifndef JA2UB + if (gMercProfiles[gbCurrentSoldier].bMedicalDeposit) + contractAmount += L" "; + contractAmount += VideoConfercingText[AIM_MEMBER_WITH_MEDICAL]; +#endif - DrawTextToScreen(wTemp, AIM_CONTRACT_CHARGE_AMOUNNT_X+1, AIM_CONTRACT_CHARGE_AMOUNNT_Y+3, 0, AIM_M_VIDEO_CONTRACT_AMOUNT_FONT, AIM_M_VIDEO_CONTRACT_AMOUNT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); + DrawTextToScreen(contractAmount.data(), AIM_CONTRACT_CHARGE_AMOUNNT_X + 1, AIM_CONTRACT_CHARGE_AMOUNNT_Y + 3, 0, AIM_M_VIDEO_CONTRACT_AMOUNT_FONT, AIM_M_VIDEO_CONTRACT_AMOUNT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); } return(giContractAmount); diff --git a/Laptop/BobbyRGuns.cpp b/Laptop/BobbyRGuns.cpp index 7acdf0ddb..5a8b6e29b 100644 --- a/Laptop/BobbyRGuns.cpp +++ b/Laptop/BobbyRGuns.cpp @@ -1424,8 +1424,6 @@ BOOLEAN DisplayItemInfo(UINT32 uiItemClass, INT32 iFilter, INT32 iSubFilter) UINT8 ubCount=0; UINT16 PosY, usTextPosY; UINT16 usItemIndex; - CHAR16 sDollarTemp[60]; - CHAR16 sTemp[60]; CHAR16 sPage[60]; INT16 pItemNumbers[ BOBBYR_NUM_WEAPONS_ON_PAGE ]; BOOLEAN bAddItem = FALSE; @@ -1434,11 +1432,8 @@ BOOLEAN DisplayItemInfo(UINT32 uiItemClass, INT32 iFilter, INT32 iSubFilter) usTextPosY = BOBBYR_ITEM_DESC_START_Y; //Display the subtotal at the bottom of the screen - swprintf( sDollarTemp, L"%d", CalculateTotalPurchasePrice() ); - InsertCommasForDollarFigure( sDollarTemp ); - InsertDollarSignInToString( sDollarTemp ); - swprintf( sTemp, L"%s %s", BobbyRText[BOBBYR_GUNS_SUB_TOTAL], sDollarTemp ); - DrawTextToScreen(sTemp, BOBBYR_ORDER_SUBTOTAL_X, BOBBYR_ORDER_SUBTOTAL_Y, 0, BOBBYR_ORDER_TITLE_FONT, BOBBYR_ORDER_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED | TEXT_SHADOWED); + auto subtotal{ std::wstring(BobbyRText[BOBBYR_GUNS_SUB_TOTAL]) + std::wstring(L" ") + FormatMoney(CalculateTotalPurchasePrice()) }; + DrawTextToScreen(subtotal.data(), BOBBYR_ORDER_SUBTOTAL_X, BOBBYR_ORDER_SUBTOTAL_Y, 0, BOBBYR_ORDER_TITLE_FONT, BOBBYR_ORDER_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED | TEXT_SHADOWED); //Buggler: Display the current page & total pages at the bottom of the screen swprintf( sPage, L"%d / %d", gubCurPage + 1, gubNumPages ); @@ -2059,11 +2054,7 @@ UINT16 DisplayCostAndQty(UINT16 usPosY, UINT16 usIndex, UINT16 usFontHeight, UIN DrawTextToScreen(BobbyRText[BOBBYR_GUNS_COST], BOBBYR_ITEM_COST_TEXT_X, (UINT16)usPosY, BOBBYR_ITEM_COST_TEXT_WIDTH, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); usPosY += usFontHeight + 2; - swprintf(sTemp, L"%d", CalcBobbyRayCost( usIndex, usBobbyIndex, fUsed )); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - - DrawTextToScreen(sTemp, BOBBYR_ITEM_COST_NUM_X, (UINT16)usPosY, BOBBYR_ITEM_COST_TEXT_WIDTH, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_ITEM_DESC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen(FormatMoney(CalcBobbyRayCost(usIndex, usBobbyIndex, fUsed)).data(), BOBBYR_ITEM_COST_NUM_X, (UINT16)usPosY, BOBBYR_ITEM_COST_TEXT_WIDTH, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_ITEM_DESC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); usPosY += usFontHeight + 2; diff --git a/Laptop/BobbyRMailOrder.cpp b/Laptop/BobbyRMailOrder.cpp index b52436361..6c9a05eed 100644 --- a/Laptop/BobbyRMailOrder.cpp +++ b/Laptop/BobbyRMailOrder.cpp @@ -1127,19 +1127,11 @@ void DisplayPurchasedItems( BOOLEAN fCalledFromOrderPage, UINT16 usGridX, UINT16 DrawTextToScreen(sText, (UINT16)(usGridX+BOBBYR_GRID_THIRD_COLUMN_X+2), usPosY, BOBBYR_GRID_THIRD_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); //unit price - swprintf(sTemp, L"%d", CalcBobbyRayCost( pBobbyRayPurchase[i].usItemIndex, pBobbyRayPurchase[i].usBobbyItemIndex, pBobbyRayPurchase[i].fUsed )); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - - DrawTextToScreen(sTemp, (UINT16)(usGridX+BOBBYR_GRID_FOURTH_COLUMN_X-2), usPosY, BOBBYR_GRID_FOURTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen(FormatMoney(CalcBobbyRayCost(pBobbyRayPurchase[i].usItemIndex, pBobbyRayPurchase[i].usBobbyItemIndex, pBobbyRayPurchase[i].fUsed)).data(), (UINT16)(usGridX+BOBBYR_GRID_FOURTH_COLUMN_X-2), usPosY, BOBBYR_GRID_FOURTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); uiTotal += CalcBobbyRayCost( pBobbyRayPurchase[i].usItemIndex, pBobbyRayPurchase[i].usBobbyItemIndex, pBobbyRayPurchase[i].fUsed ) * pBobbyRayPurchase[i].ubNumberPurchased; - swprintf(sTemp, L"%d", uiTotal ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - - DrawTextToScreen(sTemp, (UINT16)(usGridX+BOBBYR_GRID_FIFTH_COLUMN_X-2), usPosY, BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen(FormatMoney(uiTotal).data(), (UINT16)(usGridX+BOBBYR_GRID_FIFTH_COLUMN_X-2), usPosY, BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); usPosY += BOBBYR_GRID_ROW_OFFSET; } @@ -1259,7 +1251,6 @@ void DisplayPurchasedItems( BOOLEAN fCalledFromOrderPage, UINT16 usGridX, UINT16 void DisplayShippingCosts( BOOLEAN fCalledFromOrderPage, INT32 iSubTotal, UINT16 usGridX, UINT16 usGridY, INT32 iOrderNum ) { - CHAR16 sTemp[20]; HVOBJECT hPixHandle; INT32 iShippingCost = 0; // INT32 iTotal; @@ -1331,27 +1322,15 @@ void DisplayShippingCosts( BOOLEAN fCalledFromOrderPage, INT32 iSubTotal, UINT16 if( iSubTotal ) { //Display the subtotal - swprintf(sTemp, L"%d", iSubTotal ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - - DrawTextToScreen(sTemp, (UINT16)(usGridX + BOBBYR_GRID_FIFTH_COLUMN_X-2), (UINT16)(usGridY + BOBBYR_SUBTOTAL_Y), BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen(FormatMoney(iSubTotal).data(), (UINT16)(usGridX + BOBBYR_GRID_FIFTH_COLUMN_X - 2), (UINT16)(usGridY + BOBBYR_SUBTOTAL_Y), BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); //Display the shipping and handling charge - swprintf(sTemp, L"%d", iShippingCost ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - - DrawTextToScreen(sTemp, (UINT16)(usGridX + BOBBYR_GRID_FIFTH_COLUMN_X-2), (UINT16)(usGridY + BOBBYR_SHIPPING_N_HANDLE_Y), BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen(FormatMoney(iShippingCost).data(), (UINT16)(usGridX + BOBBYR_GRID_FIFTH_COLUMN_X - 2), (UINT16)(usGridY + BOBBYR_SHIPPING_N_HANDLE_Y), BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); //Display the grand total giGrandTotal = iSubTotal + iShippingCost; - swprintf(sTemp, L"%d", giGrandTotal ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - - DrawTextToScreen(sTemp, (UINT16)(usGridX + BOBBYR_GRID_FIFTH_COLUMN_X-2), (UINT16)(usGridY + BOBBYR_GRAND_TOTAL_Y), BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen(FormatMoney(giGrandTotal).data(), (UINT16)(usGridX + BOBBYR_GRID_FIFTH_COLUMN_X - 2), (UINT16)(usGridY + BOBBYR_GRAND_TOTAL_Y), BOBBYR_GRID_FIFTH_COLUMN_WIDTH, BOBBYR_ORDER_DYNAMIC_TEXT_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); } InvalidateRegion(iScreenWidthOffset + 333,iScreenHeightOffset + 326,iScreenWidthOffset + 374,iScreenHeightOffset + 400); @@ -1830,7 +1809,7 @@ void DrawSelectedCity( UINT8 ubCityNumber ) void DisplayShippingLocationCity() { - CHAR16 sTemp[40]; + std::wstring sTemp{ L"$0" }; UINT16 usPosY; //display the name on the title bar @@ -1853,39 +1832,29 @@ void DisplayShippingLocationCity() //Display the shipping cost usPosY = BOBBYR_OVERNIGHT_EXPRESS_Y; - wcscpy(sTemp, L"$0"); - if( gbSelectedCity != -1 ) { // swprintf( sTemp, L"%d", ( INT32 )(BobbyROrderLocations[gbSelectedCity].usOverNightExpress/GetWeightBasedOnMetricOption( 1 ) ) ); - swprintf( sTemp, L"%d", ( INT32 )(gPostalService.GetDestinationFee(0, gDestinationTable[gbSelectedCity]->usID) / GetWeightBasedOnMetricOption( 1 ) ) ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); + sTemp = FormatMoney(static_cast(gPostalService.GetDestinationFee(0, gDestinationTable[gbSelectedCity]->usID) / GetWeightBasedOnMetricOption(1))); } - DrawTextToScreen(sTemp, BOBBYR_SHIPPING_SPEED_NUMBER_X, usPosY, BOBBYR_SHIPPING_SPEED_NUMBER_WIDTH, BOBBYR_DROPDOWN_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED ); + DrawTextToScreen(sTemp.data(), BOBBYR_SHIPPING_SPEED_NUMBER_X, usPosY, BOBBYR_SHIPPING_SPEED_NUMBER_WIDTH, BOBBYR_DROPDOWN_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); usPosY +=BOBBYR_GRID_ROW_OFFSET; if( gbSelectedCity != -1 ) { -// swprintf( sTemp, L"%d", ( INT32 )( BobbyROrderLocations[gbSelectedCity].us2DaysService / GetWeightBasedOnMetricOption( 1 ) ) ); - swprintf( sTemp, L"%d", ( INT32 )(gPostalService.GetDestinationFee(1, gDestinationTable[gbSelectedCity]->usID) / GetWeightBasedOnMetricOption( 1 ) ) ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); + sTemp = FormatMoney(static_cast(gPostalService.GetDestinationFee(1, gDestinationTable[gbSelectedCity]->usID) / GetWeightBasedOnMetricOption(1))); } - DrawTextToScreen(sTemp, BOBBYR_SHIPPING_SPEED_NUMBER_X, usPosY, BOBBYR_SHIPPING_SPEED_NUMBER_WIDTH, BOBBYR_DROPDOWN_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED ); + DrawTextToScreen(sTemp.data(), BOBBYR_SHIPPING_SPEED_NUMBER_X, usPosY, BOBBYR_SHIPPING_SPEED_NUMBER_WIDTH, BOBBYR_DROPDOWN_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); usPosY +=BOBBYR_GRID_ROW_OFFSET; if( gbSelectedCity != -1 ) { -// swprintf( sTemp, L"%d", (INT32 )( BobbyROrderLocations[gbSelectedCity].usStandardService / GetWeightBasedOnMetricOption( 1 ) ) ); - swprintf( sTemp, L"%d", ( INT32 )(gPostalService.GetDestinationFee(2, gDestinationTable[gbSelectedCity]->usID) / GetWeightBasedOnMetricOption( 1 ) ) ); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); + sTemp = FormatMoney(static_cast(gPostalService.GetDestinationFee(2, gDestinationTable[gbSelectedCity]->usID) / GetWeightBasedOnMetricOption(1))); } - DrawTextToScreen(sTemp, BOBBYR_SHIPPING_SPEED_NUMBER_X, usPosY, BOBBYR_SHIPPING_SPEED_NUMBER_WIDTH, BOBBYR_DROPDOWN_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED ); + DrawTextToScreen(sTemp.data(), BOBBYR_SHIPPING_SPEED_NUMBER_X, usPosY, BOBBYR_SHIPPING_SPEED_NUMBER_WIDTH, BOBBYR_DROPDOWN_FONT, BOBBYR_ORDER_DYNAMIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); } void SelectCloseDroDownRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason ) diff --git a/Laptop/email.cpp b/Laptop/email.cpp index 433055439..723b464b1 100644 --- a/Laptop/email.cpp +++ b/Laptop/email.cpp @@ -6165,15 +6165,8 @@ BOOLEAN ReplaceMercNameAndAmountWithProperData( CHAR16 *pFinishedString, EmailPt } else { - CHAR16 sDollarAmount[64]; - - swprintf( sDollarAmount, L"%d", pMail->iFirstData ); - - InsertCommasForDollarFigure( sDollarAmount ); - InsertDollarSignInToString( sDollarAmount ); - //add the mercs name to the string - wcscat( pFinishedString, sDollarAmount ); + wcscat( pFinishedString, FormatMoney(pMail->iFirstData).data() ); } } else diff --git a/Laptop/finances.cpp b/Laptop/finances.cpp index e785f1a3b..96ffee3c7 100644 --- a/Laptop/finances.cpp +++ b/Laptop/finances.cpp @@ -808,31 +808,15 @@ void DrawRecordsText( void ) if(pCurFinance->iAmount >=0) { // increase in asset - debit - swprintf(sString, L"%d", pCurFinance->iAmount); - // insert commas - InsertCommasForDollarFigure( sString ); - // insert dollar sight for first record in the list -//DEF: 3/19/99: removed cause we want to see the dollar sign on ALL entries -// if( iCounter == 0 ) - { - InsertDollarSignInToString( sString ); - } - + swprintf(sString, L"%s", FormatMoney(pCurFinance->iAmount).data()); FindFontCenterCoordinates(RECORD_DEBIT_X,0,RECORD_DEBIT_WIDTH,0, sString, FINANCE_TEXT_FONT,&usX, &usY); mprintf(usX, 12+RECORD_Y + (iCounter * ( GetFontHeight( FINANCE_TEXT_FONT ) + 6 ) ), sString); } else { // decrease in asset - credit - swprintf(sString, L"%d", pCurFinance->iAmount * (-1)); + swprintf(sString, L"%s", FormatMoney(pCurFinance->iAmount * (-1)).data()); SetFontForeground(FONT_RED); - InsertCommasForDollarFigure( sString ); - // insert dollar sight for first record in the list -//DEF: 3/19/99: removed cause we want to see the dollar sign on ALL entries -// if( iCounter == 0 ) - { - InsertDollarSignInToString( sString ); - } FindFontCenterCoordinates(RECORD_CREDIT_X ,0 , RECORD_CREDIT_WIDTH,0, sString, FINANCE_TEXT_FONT,&usX, &usY); mprintf(usX, 12+RECORD_Y + (iCounter * ( GetFontHeight( FINANCE_TEXT_FONT ) + 6 ) ), sString); @@ -860,15 +844,7 @@ void DrawRecordsText( void ) // print the balance string - swprintf(sString, L"%d", iBalance); - InsertCommasForDollarFigure( sString ); - // insert dollar sight for first record in the list -//DEF: 3/19/99: removed cause we want to see the dollar sign on ALL entries -// if( iCounter == 0 ) - { - InsertDollarSignInToString( sString ); - } - + swprintf(sString, L"%s", FormatMoney(iBalance).data()); FindFontCenterCoordinates(RECORD_BALANCE_X,0,RECORD_BALANCE_WIDTH,0, sString, FINANCE_TEXT_FONT,&usX, &usY); mprintf(usX, 12+RECORD_Y + (iCounter * ( GetFontHeight( FINANCE_TEXT_FONT ) + 6 ) ), sString); @@ -921,7 +897,7 @@ void InvalidateLapTopScreen( void ) void DrawSummaryText( void ) { INT16 usX, usY; - CHAR16 pString[100]; + std::wstring tmp{}; INT32 iBalance = 0; @@ -949,98 +925,68 @@ void DrawSummaryText( void ) // yesterdays income iBalance = GetPreviousDaysIncome( ); - swprintf(pString, L"%d", iBalance ); - - InsertCommasForDollarFigure( pString ); - - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); + tmp = FormatMoney(iBalance); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0, tmp.data(), FINANCE_TEXT_FONT, &usX, &usY); - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); - - mprintf(usX,YESTERDAYS_INCOME,pString); + mprintf(usX,YESTERDAYS_INCOME,tmp.data()); SetFontForeground( FONT_BLACK ); // yesterdays other iBalance = GetYesterdaysOtherDeposits( ); - swprintf(pString, L"%d", iBalance ); - - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); - - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); + tmp = FormatMoney(iBalance); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0, tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,YESTERDAYS_OTHER,pString); + mprintf(usX,YESTERDAYS_OTHER,tmp.data()); SetFontForeground( FONT_RED ); // yesterdays debits - iBalance = GetYesterdaysDebits( ); if( iBalance < 0 ) { SetFontForeground( FONT_RED ); iBalance *= -1; } + tmp = FormatMoney(iBalance); - swprintf(pString, L"%d", iBalance ); - - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); - - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0, tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,YESTERDAYS_DEBITS,pString); + mprintf(usX,YESTERDAYS_DEBITS,tmp.data()); SetFontForeground( FONT_BLACK ); // yesterdays balance..ending balance..so todays balance then iBalance = GetTodaysBalance( ); - if( iBalance < 0 ) { SetFontForeground( FONT_RED ); iBalance *= -1; } + tmp = FormatMoney(iBalance); - swprintf(pString, L"%d", iBalance ); - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); - - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0, tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,YESTERDAYS_BALANCE,pString); + mprintf(usX,YESTERDAYS_BALANCE,tmp.data()); SetFontForeground( FONT_BLACK ); // todays income iBalance = GetTodaysDaysIncome( ); - swprintf(pString, L"%d", iBalance ); + tmp = FormatMoney(iBalance); - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); - - mprintf(usX,TODAYS_INCOME,pString); + mprintf(usX,TODAYS_INCOME,tmp.data()); SetFontForeground( FONT_BLACK ); // todays other iBalance = GetTodaysOtherDeposits( ); - swprintf(pString, L"%d", iBalance ); - - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); + tmp = FormatMoney(iBalance); - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,TODAYS_OTHER,pString); + mprintf(usX,TODAYS_OTHER,tmp.data()); SetFontForeground( FONT_RED ); @@ -1053,15 +999,11 @@ void DrawSummaryText( void ) iBalance *= ( -1 ); } - swprintf(pString, L"%d", iBalance ); + tmp = FormatMoney(iBalance); - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); - - mprintf(usX,TODAYS_DEBITS,pString); + mprintf(usX,TODAYS_DEBITS,tmp.data()); SetFontForeground( FONT_BLACK ); @@ -1069,36 +1011,23 @@ void DrawSummaryText( void ) iBalance = GetCurrentBalance( ); if( iBalance < 0 ) { - iBalance *= -1; SetFontForeground( FONT_RED ); - swprintf(pString, L"%d", iBalance ); iBalance *= -1; } - else - { - swprintf(pString, L"%d", iBalance ); - } - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); - - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,TODAYS_CURRENT_BALANCE,pString); + tmp = FormatMoney(iBalance); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); + mprintf(usX,TODAYS_CURRENT_BALANCE,tmp.data()); SetFontForeground( FONT_BLACK ); // todays forcast income iBalance = GetProjectedTotalDailyIncome( ); - swprintf(pString, L"%d", iBalance ); - - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); + tmp = FormatMoney(iBalance); - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,TODAYS_CURRENT_FORCAST_INCOME,pString); + mprintf(usX,TODAYS_CURRENT_FORCAST_INCOME,tmp.data()); SetFontForeground( FONT_BLACK ); @@ -1107,22 +1036,13 @@ void DrawSummaryText( void ) iBalance = GetCurrentBalance( ) + GetProjectedTotalDailyIncome( ); if( iBalance < 0 ) { - iBalance *= -1; SetFontForeground( FONT_RED ); - swprintf(pString, L"%d", iBalance ); iBalance *= -1; } - else - { - swprintf(pString, L"%d", iBalance ); - } - - InsertCommasForDollarFigure( pString ); - if( iBalance != 0 ) - InsertDollarSignInToString( pString ); - FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,pString,FINANCE_TEXT_FONT, &usX, &usY); - mprintf(usX,TODAYS_CURRENT_FORCAST_BALANCE,pString); + tmp = FormatMoney(iBalance); + FindFontRightCoordinates(0,0,iScreenWidthOffset + 580,0,tmp.data(),FINANCE_TEXT_FONT, &usX, &usY); + mprintf(usX,TODAYS_CURRENT_FORCAST_BALANCE,tmp.data()); SetFontForeground( FONT_BLACK ); @@ -1990,96 +1910,6 @@ BOOLEAN LoadInRecords( UINT32 uiPage ) return( TRUE ); } -void InsertCommasForDollarFigure( STR16 pString ) -{ - INT16 sCounter =0; - INT16 sZeroCount =0; - INT16 sTempCounter = 0; - INT16 sEndPosition = 0; - - // go to end of dollar figure - while( pString[ sCounter ] != 0 ) - { - sCounter++; - } - - // negative? - if( pString[0] == '-' ) - { - // stop one slot in advance of normal - sEndPosition = 1; - } - - // is there under $1,000? - if( sCounter < 4 ) - { - // can't do anything, return - return; - } - - // at end, start backing up until beginning - while( sCounter > sEndPosition ) - { - - - // enough for a comma? - if( sZeroCount==3 ) - { - // reset count - sZeroCount =0; - // set tempcounter to current counter - sTempCounter = sCounter; - - // run until end - while( pString[ sTempCounter ] != 0 ) - { - sTempCounter++; - } - // now shift everything over ot the right one place until sTempCounter = sCounter - while( sTempCounter >= sCounter ) - { - pString[ sTempCounter+1 ] = pString[ sTempCounter ]; - sTempCounter--; - } - // now insert comma - pString[ sCounter ]=L','; - } - - // increment count of digits - sZeroCount++; - - // decrement counter - sCounter--; - } - - return; - -} - -void InsertDollarSignInToString( STR16 pString ) -{ - // run to end of string, copy everything in string 2 places right, insert a space at pString[ 1 ] and a L'$' at pString[ 0 ] - - INT32 iCounter =0; - - // run to end of string - while( pString[ iCounter ] != 0 ) - { - iCounter++; - } - - // now copy over - while( iCounter >= 0 ) - { - pString[ iCounter + 1] = pString[ iCounter ]; - iCounter--; - } - - pString[ 0 ] = L'$'; - - return; -} - INT32 GetPreviousBalanceToDate( void ) { diff --git a/Laptop/finances.h b/Laptop/finances.h index 6c03e4861..b9898ba39 100644 --- a/Laptop/finances.h +++ b/Laptop/finances.h @@ -73,8 +73,6 @@ typedef struct finance *FinanceUnitPtr; extern FinanceUnitPtr pFinanceListHead; //extern INT32 iCurrentBalance; UINT32 AddTransactionToPlayersBook(UINT8 ubCode, UINT8 ubSecondCode, UINT32 uiDate, INT32 iAmount); -void InsertDollarSignInToString( STR16 pString ); -void InsertCommasForDollarFigure( STR16 pString ); INT32 GetTodaysDaysIncome( void ); INT32 GetProjectedTotalDailyIncome( void ); INT32 GetProjectedExpenses( void ); // HEADROCK HAM 3.6: Projected daily expenses. diff --git a/Laptop/insurance Contract.cpp b/Laptop/insurance Contract.cpp index 6e6730a5d..413493ea8 100644 --- a/Laptop/insurance Contract.cpp +++ b/Laptop/insurance Contract.cpp @@ -700,6 +700,7 @@ BOOLEAN DisplayOrderGrid( UINT8 ubGridNumber, UINT8 ubMercID ) iCostOfContract = 0; } + std::wstring amountRefund{}; if( iCostOfContract < 0 ) { //shouldnt get in here now since we can longer give refunds @@ -712,19 +713,16 @@ BOOLEAN DisplayOrderGrid( UINT8 ubGridNumber, UINT8 ubMercID ) DrawTextToScreen( sText, (UINT16)(usPosX+INS_CTRCT_EMPLYMNT_CNTRCT_TEXT_OFFSET_X), INS_CTRCT_ORDER_GRID1_Y+INS_CTRCT_PREMIUM_OWING_OFFSET_Y, INS_CTRCT_ORDER_GRID_WIDTH, INS_FONT_MED, INS_FONT_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); //display the amount of refund - swprintf( sText, L"%d", iCostOfContract ); - InsertCommasForDollarFigure( sText ); - InsertDollarSignInToString( sText ); + amountRefund = FormatMoney(iCostOfContract); } if( IsMercDead( ubMercID ) ) { - swprintf( sText, L"0"); - InsertDollarSignInToString( sText ); + amountRefund = L"$0"; } //display the amount owing - DrawTextToScreen( sText, (UINT16)(usPosX+32), INS_CTRCT_ORDER_GRID1_Y+179, 72, INS_FONT_MED, INS_FONT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED ); + DrawTextToScreen( amountRefund.data(), (UINT16)(usPosX + 32), INS_CTRCT_ORDER_GRID1_Y + 179, 72, INS_FONT_MED, INS_FONT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); diff --git a/Laptop/laptop.cpp b/Laptop/laptop.cpp index 220d808fa..b6f556cfe 100644 --- a/Laptop/laptop.cpp +++ b/Laptop/laptop.cpp @@ -5084,36 +5084,28 @@ void ShouldNewMailBeDisplayed() void DisplayPlayersBalanceToDate( void ) { // print players balance to date - CHAR16 sString[ 100 ]; INT16 sX, sY; - // initialize string - memset( sString, 0, sizeof( sString ) ); - // font stuff SetFont( FONT10ARIAL); SetFontForeground( 142 ); SetFontShadow(NO_SHADOW); // parse straigth number - swprintf( sString, L"%d", LaptopSaveInfo.iCurrentBalance ); - - // put in commas, then dollar sign - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + std::wstring sString{FormatMoney(LaptopSaveInfo.iCurrentBalance)}; // get center - FindFontCenterCoordinates( (INT16)LAPTOP_ICON_TEXT_X, iScreenHeightOffset, (INT16)(LAPTOP_ICON_TEXT_WIDTH) ,(INT16)(LAPTOP_ICON_TEXT_HEIGHT), sString, LAPTOPICONFONT, &sX, &sY ); + FindFontCenterCoordinates( (INT16)LAPTOP_ICON_TEXT_X, iScreenHeightOffset, (INT16)(LAPTOP_ICON_TEXT_WIDTH) ,(INT16)(LAPTOP_ICON_TEXT_HEIGHT), sString.data(), LAPTOPICONFONT, &sX, &sY); // gprintfdirty( sX , LAPTOP_ICON_TEXT_FINANCIAL_Y + 10, sString ); // printf it! if( ButtonList[ gLaptopButton[ 5 ] ]->uiFlags & BUTTON_CLICKED_ON ) { - mprintf( sX + 5, LAPTOP_ICON_TEXT_FINANCIAL_Y + 10 + 5, sString); + mprintf( sX + 5, LAPTOP_ICON_TEXT_FINANCIAL_Y + 10 + 5, sString.data()); } else { - mprintf( sX, LAPTOP_ICON_TEXT_FINANCIAL_Y + 10, sString); + mprintf( sX, LAPTOP_ICON_TEXT_FINANCIAL_Y + 10, sString.data()); } // reset shadow @@ -6207,7 +6199,6 @@ void DeleteDesktopBackground( void ) void PrintBalance( void ) { - CHAR16 pString[ 32 ]; // UINT16 usX, usY; SetFont( FONT10ARIAL ); @@ -6215,17 +6206,15 @@ void PrintBalance( void ) SetFontBackground( FONT_BLACK ); SetFontShadow( NO_SHADOW ); - swprintf(pString, L"%d", LaptopSaveInfo.iCurrentBalance); - InsertCommasForDollarFigure( pString ); - InsertDollarSignInToString( pString ); + std::wstring pString{ FormatMoney(LaptopSaveInfo.iCurrentBalance) }; if( ButtonList[ gLaptopButton[ 5 ] ]->uiFlags & BUTTON_CLICKED_ON ) { - mprintf(iScreenWidthOffset + 48, iScreenHeightOffset + 273,pString); + mprintf(iScreenWidthOffset + 48, iScreenHeightOffset + 273,pString.data()); } else { - mprintf(iScreenWidthOffset + 47, iScreenHeightOffset + 272,pString); + mprintf(iScreenWidthOffset + 47, iScreenHeightOffset + 272,pString.data()); } diff --git a/Laptop/mercs Account.cpp b/Laptop/mercs Account.cpp index a67487215..7215086d8 100644 --- a/Laptop/mercs Account.cpp +++ b/Laptop/mercs Account.cpp @@ -446,13 +446,8 @@ void BtnMercAuthorizeButtonCallback(GUI_BUTTON *btn,INT32 reason) btn->uiFlags &= (~BUTTON_CLICKED_ON ); - swprintf( wzDollarAmount, L"%d", giMercTotalContractCharge ); - - InsertCommasForDollarFigure( wzDollarAmount ); - InsertDollarSignInToString( wzDollarAmount ); - //create the string to show to the user - swprintf( wzAuthorizeString, MercAccountText[MERC_ACCOUNT_AUTHORIZE_CONFIRMATION], wzDollarAmount ); + swprintf( wzAuthorizeString, MercAccountText[MERC_ACCOUNT_AUTHORIZE_CONFIRMATION], FormatMoney(giMercTotalContractCharge).data()); DoLapTopMessageBox( MSG_BOX_BLUE_ON_GREY, wzAuthorizeString, LAPTOP_SCREEN, MSG_BOX_FLAG_YESNO, MercAuthorizePaymentMessageBoxCallBack ); diff --git a/Laptop/mercs Files.cpp b/Laptop/mercs Files.cpp index 7d4df0232..f5fcc483c 100644 --- a/Laptop/mercs Files.cpp +++ b/Laptop/mercs Files.cpp @@ -977,8 +977,7 @@ void DisplayMercsStats( UINT8 ubMercID ) { UINT16 usPosY, usPosX; CHAR16 sPage[60]; - CHAR16 sTemp[128]; - CHAR16 sString[128]; + std::wstring sString{}; CHAR16 NsString[128]; CHAR16 N2sString[128]; UINT8 ubColor; @@ -1058,21 +1057,15 @@ void DisplayMercsStats( UINT8 ubMercID ) DrawTextToScreen( CharacterInfo[AIM_MEMBER_FEE], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_TITLE_FONT, MERC_TITLE_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); usPosX = MERC_STATS_SECOND_COL_X + StringPixLength( CharacterInfo[AIM_MEMBER_FEE], MERC_NAME_FONT ); - swprintf( sString, L"%d", gMercProfiles[ubMercID].uiWeeklySalary ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + sString = FormatMoney(gMercProfiles[ubMercID].uiWeeklySalary); #else DrawTextToScreen( MercInfo[MERC_FILES_SALARY], MERC_STATS_SECOND_COL_X, usPosY, 0, MERC_STATS_FONT, MERC_STATIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); usPosX = MERC_STATS_SECOND_COL_X + StringPixLength( MercInfo[MERC_FILES_SALARY], MERC_NAME_FONT ); - swprintf( sString, L"%d", gMercProfiles[ubMercID].sSalary ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); - swprintf( sTemp, L" %s", MercInfo[MERC_FILES_PER_DAY] ); + sString = FormatMoney(gMercProfiles[ubMercID].sSalary) + L" " + std::wstring(MercInfo[MERC_FILES_PER_DAY]); #endif // JA2UB - wcscat( sString, sTemp ); - DrawTextToScreen( sString, usPosX, usPosY, 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); + DrawTextToScreen( sString.data(), usPosX, usPosY, 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); // Buggler: Display current MERC index & total MERC members at the bottom of the screen swprintf( sPage, L"%d / %d", gubCurMercIndex + 1, LaptopSaveInfo.gubLastMercIndex + 1 ); @@ -1103,10 +1096,8 @@ void DisplayMercsStats( UINT8 ubMercID ) #endif // JA2UB swprintf( NsString, L"+ " ); - swprintf(sTemp, L"%d",gMercProfiles[ ubMercID ].usOptionalGearCost); - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - wcscat( NsString, sTemp ); + sString = FormatMoney(gMercProfiles[ ubMercID ].usOptionalGearCost); + wcscat( NsString, sString.data() ); DrawTextToScreen( NsString, usPosX, usPosY, 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); usPosY += MERC_SPACE_BN_LINES; @@ -1115,13 +1106,11 @@ void DisplayMercsStats( UINT8 ubMercID ) swprintf(N2sString, L"= "); #ifdef JA2UB - swprintf( sTemp, L"%d", gMercProfiles[ubMercID].usOptionalGearCost + gMercProfiles[ubMercID].uiWeeklySalary ); + sString = FormatMoney(gMercProfiles[ubMercID].usOptionalGearCost + gMercProfiles[ubMercID].uiWeeklySalary); #else - swprintf(sTemp, L"%d",gMercProfiles[ ubMercID ].usOptionalGearCost+gMercProfiles[ ubMercID ].sSalary); + sString = FormatMoney(gMercProfiles[ ubMercID ].usOptionalGearCost+gMercProfiles[ ubMercID ].sSalary); #endif - InsertCommasForDollarFigure( sTemp ); - InsertDollarSignInToString( sTemp ); - wcscat( N2sString, sTemp ); + wcscat( N2sString, sString.data() ); DrawTextToScreen( N2sString, usPosX, usPosY, 95, MERC_NAME_FONT, MERC_DYNAMIC_STATS_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); } } diff --git a/Laptop/personnel.cpp b/Laptop/personnel.cpp index fbc2e9ca0..82d2da004 100644 --- a/Laptop/personnel.cpp +++ b/Laptop/personnel.cpp @@ -3298,7 +3298,6 @@ INT32 GetHighestDailyCostOfCurrentTeam( void ) void DisplayCostOfCurrentTeam( void ) { // display number on team - CHAR16 sString[ 32 ]; INT16 sX, sY; // font stuff @@ -3307,38 +3306,30 @@ void DisplayCostOfCurrentTeam( void ) SetFontForeground( PERS_TEXT_FONT_COLOR ); if (fCurrentTeamMode) { + std::wstring sString{}; // daily cost mprintf( PERS_CURR_TEAM_COST_X, PERS_CURR_TEAM_COST_Y, pPersonelTeamStrings[ 2 ] ); - swprintf( sString, L"%d", GetTotalDailyCostOfCurrentTeam( ) ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); - - FindFontRightCoordinates((INT16)(PERS_CURR_TEAM_COST_X),0,PERS_CURR_TEAM_WIDTH,0,sString, PERS_FONT, &sX, &sY); + sString = FormatMoney( GetTotalDailyCostOfCurrentTeam( ) ); + FindFontRightCoordinates((INT16)(PERS_CURR_TEAM_COST_X),0,PERS_CURR_TEAM_WIDTH,0,sString.data(), PERS_FONT, &sX, &sY); - mprintf( sX ,PERS_CURR_TEAM_COST_Y, sString ); + mprintf( sX ,PERS_CURR_TEAM_COST_Y, sString.data() ); // highest cost mprintf( PERS_CURR_TEAM_COST_X, PERS_CURR_TEAM_HIGHEST_Y, pPersonelTeamStrings[ 3 ] ); - swprintf( sString, L"%d", GetHighestDailyCostOfCurrentTeam( ) ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + sString = FormatMoney( GetHighestDailyCostOfCurrentTeam( ) ); + FindFontRightCoordinates((INT16)(PERS_CURR_TEAM_COST_X),0,PERS_CURR_TEAM_WIDTH,0,sString.data(), PERS_FONT, &sX, &sY); - FindFontRightCoordinates((INT16)(PERS_CURR_TEAM_COST_X),0,PERS_CURR_TEAM_WIDTH,0,sString, PERS_FONT, &sX, &sY); - - mprintf( sX ,PERS_CURR_TEAM_HIGHEST_Y, sString ); + mprintf( sX ,PERS_CURR_TEAM_HIGHEST_Y, sString.data() ); // the lowest cost mprintf( PERS_CURR_TEAM_COST_X, PERS_CURR_TEAM_LOWEST_Y, pPersonelTeamStrings[ 4 ] ); - swprintf( sString, L"%d", GetLowestDailyCostOfCurrentTeam( ) ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); - - FindFontRightCoordinates((INT16)(PERS_CURR_TEAM_COST_X),0,PERS_CURR_TEAM_WIDTH,0,sString, PERS_FONT, &sX, &sY); + sString = FormatMoney( GetLowestDailyCostOfCurrentTeam( ) ); + FindFontRightCoordinates((INT16)(PERS_CURR_TEAM_COST_X),0,PERS_CURR_TEAM_WIDTH,0,sString.data(), PERS_FONT, &sX, &sY); - mprintf( sX ,PERS_CURR_TEAM_LOWEST_Y, sString ); + mprintf( sX ,PERS_CURR_TEAM_LOWEST_Y, sString.data() ); } } @@ -5931,7 +5922,7 @@ void DisplayAmountOnCurrentMerc( void ) { // will display the amount that the merc is carrying on him or herself SOLDIERTYPE *pSoldier = NULL; - CHAR16 sString[ 64 ]; + std::wstring sString{}; INT16 sX, sY; if (currentTeamIndex == -1) { @@ -5941,13 +5932,7 @@ void DisplayAmountOnCurrentMerc( void ) pSoldier = currentTeamList[currentTeamIndex]; } - INT32 iFunds = GetFundsOnMerc( pSoldier ); - - swprintf( sString, L"%d", iFunds ); - - // insert commas and dollar sign - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + sString = FormatMoney( GetFundsOnMerc( pSoldier ) ); // set font SetFont( ATM_FONT ); @@ -5957,10 +5942,10 @@ void DisplayAmountOnCurrentMerc( void ) SetFontBackground( FONT_BLACK ); // right justify - FindFontRightCoordinates( ATM_DISPLAY_X, ATM_DISPLAY_Y, ATM_DISPLAY_WIDTH, ATM_DISPLAY_HEIGHT, sString, ATM_FONT, &sX, &sY ); + FindFontRightCoordinates( ATM_DISPLAY_X, ATM_DISPLAY_Y, ATM_DISPLAY_WIDTH, ATM_DISPLAY_HEIGHT, sString.data(), ATM_FONT, &sX, &sY); // print string - mprintf( sX, sY, sString ); + mprintf( sX, sY, sString.data() ); } void HandlePersonnelKeyboard( void ) @@ -6292,11 +6277,7 @@ void DisplayEmploymentinformation( SoldierID iId, INT32 iSlot ) swprintf( sString, L"%d", gMercProfiles[ Menptr[ iId ].ubProfile ].uiTotalCostToDate ); } */ - swprintf( sString, L"%d", pMercProfile->uiTotalCostToDate ); - - // insert commas and dollar sign - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + swprintf( sString, L"%s", FormatMoney(pMercProfile->uiTotalCostToDate).data() ); /* DEF:3/19/99: @@ -6321,34 +6302,22 @@ DEF:3/19/99: if( pSoldier->bTypeOfLastContract == CONTRACT_EXTEND_2_WEEK ) { // 2 week contract - swprintf( sStringA, L"%d", pMercProfile->uiBiWeeklySalary / 14 ); - InsertCommasForDollarFigure( sStringA ); - InsertDollarSignInToString( sStringA ); - swprintf( sString, L"%s", sStringA ); + swprintf( sString, L"%s", FormatMoney( pMercProfile->uiBiWeeklySalary / 14 ).data() ); } else if( pSoldier->bTypeOfLastContract == CONTRACT_EXTEND_1_WEEK ) { // 1 week contract - swprintf( sStringA, L"%d", pMercProfile->uiWeeklySalary / 7 ); - InsertCommasForDollarFigure( sStringA ); - InsertDollarSignInToString( sStringA ); - swprintf( sString, L"%s", sStringA ); + swprintf( sString, L"%s", FormatMoney( pMercProfile->uiWeeklySalary / 7 ).data() ); } else { // daily rate - swprintf( sStringA, L"%d", pMercProfile->sSalary ); - InsertCommasForDollarFigure( sStringA ); - InsertDollarSignInToString( sStringA ); - swprintf( sString, L"%s", sStringA ); + swprintf( sString, L"%s", FormatMoney( pMercProfile->sSalary ).data() ); } } else { - swprintf( sStringA, L"%d", pMercProfile->sSalary ); - InsertCommasForDollarFigure( sStringA ); - InsertDollarSignInToString( sStringA ); - swprintf( sString, L"%s", sStringA ); + swprintf( sString, L"%s", FormatMoney( pMercProfile->sSalary ).data() ); } FindFontRightCoordinates( (INT16)(x + Prsnl_DATA_OffSetX), 0, TEXT_BOX_WIDTH - 20, 0, sString, PERS_FONT, &sX, &sY ); @@ -6369,9 +6338,7 @@ DEF:3/19/99: { mprintf((INT16)(pPersonnelScreenPoints[iCounter-1].x+(iSlot*TEXT_BOX_WIDTH)),pPersonnelScreenPoints[iCounter-1].y,pPersonnelScreenStrings[PRSNL_TXT_UNPAID_AMOUNT]); - swprintf( sString, L"%d", pMercProfile->sSalary * pMercProfile->iMercMercContractLength ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + swprintf( sString, L"%s", FormatMoney( pMercProfile->sSalary * pMercProfile->iMercMercContractLength ).data() ); FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[iCounter-1].x+(iSlot*TEXT_BOX_WIDTH)+Prsnl_DATA_OffSetX),0,TEXT_BOX_WIDTH-20,0,sString, PERS_FONT, &sX, &sY); mprintf(sX,pPersonnelScreenPoints[iCounter-1].y,sString); @@ -6380,11 +6347,7 @@ DEF:3/19/99: { mprintf((INT16)(pPersonnelScreenPoints[iCounter-1].x+(iSlot*TEXT_BOX_WIDTH)),pPersonnelScreenPoints[iCounter-1].y,pPersonnelScreenStrings[PRSNL_TXT_MED_DEPOSIT]); - swprintf(sString, L"%d",pMercProfile->sMedicalDepositAmount); - - // insert commas and dollar sign - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + swprintf(sString, L"%s", FormatMoney(pMercProfile->sMedicalDepositAmount).data()); FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[iCounter-1].x+(iSlot*TEXT_BOX_WIDTH)+Prsnl_DATA_OffSetX),0,TEXT_BOX_WIDTH-20,0,sString, PERS_FONT, &sX, &sY); mprintf(sX,pPersonnelScreenPoints[iCounter-1].y,sString); diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index ec43255e7..9bed0fb4f 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -15169,14 +15169,12 @@ void CreateContractBox( SOLDIERTYPE *pCharacter ) if( pCharacter->ubWhatKindOfMercAmI != MERC_TYPE__AIM_MERC ) { - swprintf( sDollarString, L"%d", 0 ); + swprintf( sDollarString, L"%s", FormatMoney(0).data() ); } else { - swprintf( sDollarString, L"%d", gMercProfiles[ pCharacter->ubProfile ].sSalary ); + swprintf( sDollarString, L"%s", FormatMoney(gMercProfiles[ pCharacter->ubProfile ].sSalary).data() ); } - InsertCommasForDollarFigure( sDollarString ); - InsertDollarSignInToString( sDollarString ); swprintf( sString, L"%s ( %s )", pContractStrings[uiCounter], sDollarString); AddMonoString(&hStringHandle, sString); break; @@ -15184,15 +15182,13 @@ void CreateContractBox( SOLDIERTYPE *pCharacter ) if( pCharacter->ubWhatKindOfMercAmI != MERC_TYPE__AIM_MERC ) { - swprintf( sDollarString, L"%d", 0 ); + swprintf( sDollarString, L"%s", FormatMoney(0).data() ); } else { - swprintf( sDollarString, L"%d", gMercProfiles[ pCharacter->ubProfile ].uiWeeklySalary ); + swprintf( sDollarString, L"%s", FormatMoney(gMercProfiles[ pCharacter->ubProfile ].uiWeeklySalary).data() ); } - InsertCommasForDollarFigure( sDollarString ); - InsertDollarSignInToString( sDollarString ); swprintf( sString, L"%s ( %s )", pContractStrings[uiCounter], sDollarString ); AddMonoString(&hStringHandle, sString); break; @@ -15200,16 +15196,14 @@ void CreateContractBox( SOLDIERTYPE *pCharacter ) if( pCharacter->ubWhatKindOfMercAmI != MERC_TYPE__AIM_MERC ) { - swprintf( sDollarString, L"%d", 0 ); + swprintf( sDollarString, L"%s", FormatMoney(0).data() ); } else { - swprintf( sDollarString, L"%d", gMercProfiles[ pCharacter->ubProfile ].uiBiWeeklySalary ); + swprintf( sDollarString, L"%s", FormatMoney(gMercProfiles[ pCharacter->ubProfile ].uiBiWeeklySalary).data() ); } - InsertCommasForDollarFigure( sDollarString ); - InsertDollarSignInToString( sDollarString ); swprintf( sString, L"%s ( %s )", pContractStrings[uiCounter], sDollarString); AddMonoString(&hStringHandle, sString); break; @@ -15299,10 +15293,8 @@ void CreateContractBoxMultiSelect(INT32 DailySalaries, INT32 WeeklySalaries, INT //} //else { - swprintf(sDollarString, L"%d", DailySalaries); + swprintf(sDollarString, L"%s", FormatMoney(DailySalaries).data() ); } - InsertCommasForDollarFigure(sDollarString); - InsertDollarSignInToString(sDollarString); swprintf(sString, L"%s ( %s )", pContractStrings[uiCounter], sDollarString); AddMonoString(&hStringHandle, sString); break; @@ -15314,11 +15306,9 @@ void CreateContractBoxMultiSelect(INT32 DailySalaries, INT32 WeeklySalaries, INT //} //else { - swprintf(sDollarString, L"%d", WeeklySalaries); + swprintf(sDollarString, L"%s", FormatMoney(WeeklySalaries).data()); } - InsertCommasForDollarFigure(sDollarString); - InsertDollarSignInToString(sDollarString); swprintf(sString, L"%s ( %s )", pContractStrings[uiCounter], sDollarString); AddMonoString(&hStringHandle, sString); break; @@ -15330,12 +15320,10 @@ void CreateContractBoxMultiSelect(INT32 DailySalaries, INT32 WeeklySalaries, INT //} //else { - swprintf(sDollarString, L"%d", BiweeklySalaries); + swprintf(sDollarString, L"%s", FormatMoney(BiweeklySalaries).data()); } - InsertCommasForDollarFigure(sDollarString); - InsertDollarSignInToString(sDollarString); swprintf(sString, L"%s ( %s )", pContractStrings[uiCounter], sDollarString); AddMonoString(&hStringHandle, sString); break; diff --git a/Strategic/Map Screen Interface Bottom.cpp b/Strategic/Map Screen Interface Bottom.cpp index 907467c04..04aa27db6 100644 --- a/Strategic/Map Screen Interface Bottom.cpp +++ b/Strategic/Map Screen Interface Bottom.cpp @@ -1562,7 +1562,7 @@ void DisplayCurrentBalanceTitleForMapBottom( void ) void DisplayCurrentBalanceForMapBottom( void ) { // show the current balance for the player on the map panel bottom - CHAR16 sString[ 128 ]; + std::wstring sString; INT16 sFontX, sFontY; // ste the font buffer @@ -1573,22 +1573,18 @@ void DisplayCurrentBalanceForMapBottom( void ) SetFontForeground( 183 ); SetFontBackground( FONT_BLACK ); - swprintf( sString, L"%d", LaptopSaveInfo.iCurrentBalance ); - - // insert - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + sString = FormatMoney( LaptopSaveInfo.iCurrentBalance ); VarFindFontCenterCoordinates( UI_BOTTOM.Text.CurrentBalance.x, UI_BOTTOM.Text.CurrentBalance.y, UI_BOTTOM.Text.CurrentBalance.width, UI_BOTTOM.Text.CurrentBalance.height, - COMPFONT, &sFontX, &sFontY, sString + COMPFONT, &sFontX, &sFontY, sString.data() ); // print it - mprintf( sFontX, sFontY, L"%s", sString ); + mprintf( sFontX, sFontY, L"%s", sString.data() ); return; } @@ -1667,7 +1663,7 @@ void DisplayProjectedDailyMineIncome( void ) { INT32 iRate = 0; static INT32 iOldRate = -1; - CHAR16 sString[ 128 ]; + std::wstring sString; INT16 sFontX, sFontY; // grab the rate from the financial system @@ -1692,22 +1688,18 @@ void DisplayProjectedDailyMineIncome( void ) SetFontForeground( 183 ); SetFontBackground( FONT_BLACK ); - swprintf( sString, L"%d", iRate ); - - // insert - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + sString = FormatMoney( iRate ); VarFindFontCenterCoordinates( UI_BOTTOM.Text.CurrentIncome.x, UI_BOTTOM.Text.CurrentIncome.y, UI_BOTTOM.Text.CurrentIncome.width, UI_BOTTOM.Text.CurrentIncome.height, - COMPFONT, &sFontX, &sFontY, sString + COMPFONT, &sFontX, &sFontY, sString.data() ); // print it - mprintf( sFontX, sFontY, L"%s", sString ); + mprintf( sFontX, sFontY, L"%s", sString.data() ); return; } @@ -1716,7 +1708,6 @@ void DisplayProjectedDailyExpenses( void ) { INT32 iRate = 0; static INT32 iOldExpensesRate = -1; - CHAR16 sString[ 128 ]; INT16 sFontX, sFontY; // grab the rate from the financial system @@ -1749,22 +1740,18 @@ void DisplayProjectedDailyExpenses( void ) } SetFontBackground( FONT_BLACK ); - swprintf( sString, L"%d", iRate ); - - // insert extra characters - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + auto rate{FormatMoney(iRate)}; VarFindFontCenterCoordinates( UI_BOTTOM.Text.CurrentExpenses.x, UI_BOTTOM.Text.CurrentExpenses.y, UI_BOTTOM.Text.CurrentExpenses.width, UI_BOTTOM.Text.CurrentExpenses.height, - COMPFONT, &sFontX, &sFontY, sString + COMPFONT, &sFontX, &sFontY, rate.data() ); // print it - mprintf( sFontX, sFontY, L"%s", sString ); + mprintf( sFontX, sFontY, L"%s", rate.data()); return; } diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 190895cbb..846b2bfd2 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -4378,9 +4378,7 @@ void DisplayDistancesForHelicopter( void ) if( (INT32)uiTripCost > LaptopSaveInfo.iCurrentBalance ) SetFontForeground( FONT_LTRED ); - swprintf( sString, L"%d", uiTripCost ); - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); + swprintf( sString, L"%s", FormatMoney(uiTripCost).data()); FindFontRightCoordinates(UI_MAP.HeliETA.PopupBox.x + 5, ( INT16 ) (UI_MAP.HeliETA.PopupBox.y + 5 + 3 * GetFontHeight( MAP_FONT ) ), UI_MAP.HeliETA.PopupBox.width, 0, sString, MAP_FONT, &sX, &sY ); mprintf( sX, ( INT16 ) ( sYPosition + 5 + 3 * GetFontHeight( MAP_FONT ) ), sString ); @@ -4857,9 +4855,7 @@ void BlitMineText( INT16 sMapX, INT16 sMapY ) if (PlayerControlsMine(ubMineIndex) && !gMineStatus[ ubMineIndex ].fEmpty) { // show current production - swprintf( wSubString, L"%d", PredictDailyIncomeFromAMine(ubMineIndex, TRUE) ); - InsertCommasForDollarFigure( wSubString ); - InsertDollarSignInToString( wSubString ); + swprintf( wSubString, L"%s", FormatMoney(PredictDailyIncomeFromAMine(ubMineIndex, TRUE)).data()); wcscpy( wString, wSubString ); /* diff --git a/Strategic/Map Screen Interface TownMine Info.cpp b/Strategic/Map Screen Interface TownMine Info.cpp index c2ede643c..3168f3d85 100644 --- a/Strategic/Map Screen Interface TownMine Info.cpp +++ b/Strategic/Map Screen Interface TownMine Info.cpp @@ -549,20 +549,14 @@ void AddTextToMineBox( void ) swprintf( wString, L"%s:", pwMineStrings[ 3 ]); AddMonoString( &hStringHandle, wString ); - swprintf( wString, L"%d", PredictDailyIncomeFromAMine( ubMineIndex, TRUE ) ); - InsertCommasForDollarFigure( wString ); - InsertDollarSignInToString( wString ); - AddSecondColumnMonoString( &hStringHandle, wString ); + AddSecondColumnMonoString( &hStringHandle, FormatMoney(PredictDailyIncomeFromAMine(ubMineIndex, TRUE)).data() ); // potential production swprintf( wString, L"%s:", pwMineStrings[ 4 ]); AddMonoString( &hStringHandle, wString ); - swprintf( wString, L"%d", GetMaxDailyRemovalFromMine( ubMineIndex ) ); - InsertCommasForDollarFigure( wString ); - InsertDollarSignInToString( wString ); - AddSecondColumnMonoString( &hStringHandle, wString ); + AddSecondColumnMonoString( &hStringHandle, FormatMoney(GetMaxDailyRemovalFromMine(ubMineIndex)).data()); // if potential is not nil @@ -616,9 +610,7 @@ void AddTextToMineBox( void ) wcscpy( wString, L"Remaining (DEBUG):"); AddMonoString( &hStringHandle, wString ); - swprintf( wString, L"%d", GetTotalLeftInMine( ubMineIndex ) ); - InsertCommasForDollarFigure( wString ); - InsertDollarSignInToString( wString ); + swprintf( wString, L"%s", FormatMoney( GetTotalLeftInMine( ubMineIndex ) ).data() ); AddSecondColumnMonoString( &hStringHandle, wString ); #endif diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index c171463f0..b133c1008 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -6261,11 +6261,7 @@ BOOLEAN NotifyPlayerWhenEnemyTakesControlOfImportantSector( INT16 sSectorX, INT1 iValue = GetProjectedTotalDailyIncome( ); // parse the string - swprintf( sStringC, L"%d", iValue ); - - // insert - InsertCommasForDollarFigure( sStringC ); - InsertDollarSignInToString( sStringC ); + swprintf( sStringC, L"%s", FormatMoney(iValue).data()); swprintf( sStringB, pMapErrorString[ 16 ], sString, sStringC ); diff --git a/Strategic/Merc Contract.cpp b/Strategic/Merc Contract.cpp index 21a8259f1..040d9df05 100644 --- a/Strategic/Merc Contract.cpp +++ b/Strategic/Merc Contract.cpp @@ -1518,16 +1518,8 @@ void HandleNotifyPlayerCantAffordInsurance( void ) void HandleNotifyPlayerCanAffordInsurance( SOLDIERTYPE *pSoldier, UINT8 ubLength, INT32 iCost ) { CHAR16 sString[ 128 ]; - CHAR16 sStringA[ 32 ]; - //parse the cost - swprintf( sStringA, L"%d",iCost ); - - // insert the commans and dollar sign - InsertCommasForDollarFigure( sStringA ); - InsertDollarSignInToString( sStringA ); - - swprintf( sString, zMarksMapScreenText[ 10 ], pSoldier->GetName(), sStringA, ubLength ); + swprintf( sString, zMarksMapScreenText[ 10 ], pSoldier->GetName(), FormatMoney(iCost).data(), ubLength ); //Set the length to the global variable ( so we know how long the contract is in the callback ) gubContractLength = ubLength; diff --git a/Strategic/Strategic Merc Handler.cpp b/Strategic/Strategic Merc Handler.cpp index ab46eae36..2499b70f2 100644 --- a/Strategic/Strategic Merc Handler.cpp +++ b/Strategic/Strategic Merc Handler.cpp @@ -318,15 +318,8 @@ void MercDailyUpdate() } else { - CHAR16 zMoney[128]; - - //create a string for the salary owed to the npc - swprintf( zMoney, L"%d", sSalary ); - InsertCommasForDollarFigure( zMoney ); - InsertDollarSignInToString( zMoney ); - //Display a screen msg indicating that the npc was NOT paid - ScreenMsg( FONT_MCOLOR_WHITE, MSG_INTERFACE, pMessageStrings[ MSG_CANT_AFFORD_TO_PAY_NPC_DAILY_SALARY_MSG ], gMercProfiles[ pSoldier->ubProfile ].zNickname, zMoney ); + ScreenMsg( FONT_MCOLOR_WHITE, MSG_INTERFACE, pMessageStrings[ MSG_CANT_AFFORD_TO_PAY_NPC_DAILY_SALARY_MSG ], gMercProfiles[ pSoldier->ubProfile ].zNickname, FormatMoney(sSalary).data() ); //if the merc hasnt been paid for NUM_DAYS_TILL_UNPAID_RPC_QUITS days, the merc will quit if( ( gMercProfiles[ pSoldier->ubProfile ].iBalance - sSalary ) <= -( sSalary * NUM_DAYS_TILL_UNPAID_RPC_QUITS ) ) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 0d5886c2f..41cf5fa61 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -3228,35 +3228,29 @@ void DrawCharacterInfo(INT16 sCharNumber) iDailyCost = gMercProfiles[ pSoldier->ubProfile ].sSalary; } - swprintf(sString, L"%d", iDailyCost ); - // insert commas and dollar sign - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); { + auto tmpMoney{ FormatMoney(iDailyCost) }; const auto x = UI_CHARPANEL.Text.Salary.x; const auto y = UI_CHARPANEL.Text.Salary.y; const auto w = UI_CHARPANEL.Text.Salary.width; const auto h = UI_CHARPANEL.Text.Salary.height; - FindFontRightCoordinates(x, y, w, h, sString, CHAR_FONT, &usX, &usY); - DrawString(sString, usX, usY, CHAR_FONT); + FindFontRightCoordinates(x, y, w, h, tmpMoney.data(), CHAR_FONT, &usX, &usY); + DrawString(tmpMoney.data(), usX, usY, CHAR_FONT); } // medical deposit if( gMercProfiles[ gCharactersList[ sCharNumber ].usSolID->ubProfile ].sMedicalDepositAmount > 0 ) { - swprintf(sString, L"%d", gMercProfiles[ gCharactersList[ sCharNumber ].usSolID->ubProfile ].sMedicalDepositAmount ); + auto tmpMoney{ FormatMoney(gMercProfiles[gCharactersList[sCharNumber].usSolID->ubProfile].sMedicalDepositAmount) }; - // insert commas and dollar sign - InsertCommasForDollarFigure( sString ); - InsertDollarSignInToString( sString ); { const auto x = UI_CHARPANEL.Text.Medical.x; const auto y = UI_CHARPANEL.Text.Medical.y; const auto w = UI_CHARPANEL.Text.Medical.width; const auto h = UI_CHARPANEL.Text.Medical.height; - FindFontRightCoordinates(x, y, w, h, sString, CHAR_FONT, &usX, &usY); - DrawString(sString, usX, y, CHAR_FONT); + FindFontRightCoordinates(x, y, w, h, tmpMoney.data(), CHAR_FONT, &usX, &usY); + DrawString(tmpMoney.data(), usX, y, CHAR_FONT); } } diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index 0bbd0ecfd..08912171a 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -474,7 +474,6 @@ void HandleDialogue( ) BOOLEAN fDoneTalking = FALSE; SOLDIERTYPE *pSoldier = NULL; CHAR16 zText[ 512 ]; - CHAR16 zMoney[128]; // we don't want to just delay action of some events, we want to pause the whole queue, regardless of the event if( gfDialogueQueuePaused ) @@ -1055,18 +1054,16 @@ void HandleDialogue( ) if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOPKEEPER ) { + std::wstring zMoney{}; if( QItem.uiSpecialEventData < 3 ) { // post a notice if the player wants to withdraw money from thier account to cover the difference? - swprintf( zMoney, L"%d", QItem.uiSpecialEventData2 ); - InsertCommasForDollarFigure( zMoney ); - InsertDollarSignInToString( zMoney ); + zMoney = FormatMoney(QItem.uiSpecialEventData2); } else if ( QItem.uiSpecialEventData > 7 ) { // post a notice if the player wants to withdraw money from thier account to cover the difference? - swprintf( zMoney, L"%d", QItem.uiSpecialEventData2 ); - InsertCommasForDollarFigure( zMoney ); + zMoney = FormatMoney(QItem.uiSpecialEventData2); } switch( QItem.uiSpecialEventData ) diff --git a/Tactical/Interface Dialogue.cpp b/Tactical/Interface Dialogue.cpp index 07fece5b5..13ac11495 100644 --- a/Tactical/Interface Dialogue.cpp +++ b/Tactical/Interface Dialogue.cpp @@ -4634,8 +4634,7 @@ void StartDialogueMessageBox( UINT8 ubProfileID, UINT16 usMessageBoxType ) case NPC_ACTION_ASK_ABOUT_PAYING_RPC: case NPC_ACTION_ASK_ABOUT_PAYING_RPC_WITH_DAILY_SALARY: case NPC_ACTION_REDUCE_CONRAD_SALARY_CONDITIONS: - swprintf( zTemp2, L"%d", gMercProfiles[ubProfileID].sSalary ); - InsertDollarSignInToString( zTemp2 ); + swprintf( zTemp2, L"%s", FormatMoney(gMercProfiles[ubProfileID].sSalary).data()); swprintf( zTemp, TacticalStr[ HIRE_PROMPT ], gMercProfiles[ubProfileID].zNickname, zTemp2 ); DoMessageBox( MSG_BOX_BASIC_STYLE, zTemp, GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, DialogueMessageBoxCallBack, NULL ); break; @@ -4644,8 +4643,7 @@ void StartDialogueMessageBox( UINT8 ubProfileID, UINT16 usMessageBoxType ) DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ BOXING_PROMPT ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, DialogueMessageBoxCallBack, NULL ); break; case NPC_ACTION_BUY_LEATHER_KEVLAR_VEST: - swprintf( zTemp2, L"%d", Item[LEATHER_JACKET_W_KEVLAR].usPrice ); - InsertDollarSignInToString( zTemp2 ); + swprintf( zTemp2, L"%s", FormatMoney(Item[LEATHER_JACKET_W_KEVLAR].usPrice).data()); swprintf( zTemp, TacticalStr[ BUY_VEST_PROMPT ], ItemNames[LEATHER_JACKET_W_KEVLAR], zTemp2 ); DoMessageBox( MSG_BOX_BASIC_STYLE, zTemp, GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, DialogueMessageBoxCallBack, NULL ); break; @@ -4666,15 +4664,13 @@ void StartDialogueMessageBox( UINT8 ubProfileID, UINT16 usMessageBoxType ) { iTemp -= giHospitalRefund; } - swprintf( zTemp2, L"%ld", iTemp ); - InsertDollarSignInToString( zTemp2 ); + swprintf( zTemp2, L"%s", FormatMoney(iTemp).data()); swprintf( zTemp, TacticalStr[ PAY_MONEY_PROMPT ], zTemp2 ); DoMessageBox( MSG_BOX_BASIC_STYLE, zTemp, GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, DialogueMessageBoxCallBack, NULL ); break; case NPC_ACTION_BUY_VEHICLE_REQUESTOR: - swprintf( zTemp2, L"%ld", 10000 ); - InsertDollarSignInToString( zTemp2 ); + swprintf( zTemp2, L"%s", FormatMoney(10000).data()); swprintf( zTemp, TacticalStr[ PAY_MONEY_PROMPT ], zTemp2 ); DoMessageBox( MSG_BOX_BASIC_STYLE, zTemp, GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, DialogueMessageBoxCallBack, NULL ); diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 4dda8a178..841d15c37 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -7931,9 +7931,7 @@ void RenderItemDescriptionBox( ) //Display the total amount of money remaining SetFontForeground( 5 ); - swprintf( pStr, L"%ld", gRemoveMoney.uiMoneyRemaining ); - InsertCommasForDollarFigure( pStr ); - InsertDollarSignInToString( pStr ); + swprintf( pStr, L"%s", FormatMoney(gRemoveMoney.uiMoneyRemaining).data() ); if (UsingNewInventorySystem() == true) FindFontRightCoordinates( gMoneyStats[ 4 ].sX + 50, gMoneyStats[ 4 ].sY, ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); else @@ -7942,9 +7940,7 @@ void RenderItemDescriptionBox( ) //Display the total amount of money removing SetFontForeground( 5 ); - swprintf( pStr, L"%ld", gRemoveMoney.uiMoneyRemoving ); - InsertCommasForDollarFigure( pStr ); - InsertDollarSignInToString( pStr ); + swprintf( pStr, L"%s", FormatMoney(gRemoveMoney.uiMoneyRemoving).data() ); if (UsingNewInventorySystem() == true) FindFontRightCoordinates( gMoneyStats[ 5 ].sX + 50, gMoneyStats[ 5 ].sY, ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); else @@ -7973,9 +7969,7 @@ void RenderItemDescriptionBox( ) // { SetFontForeground( FONT_FCOLOR_WHITE ); SetFontShadow( DEFAULT_SHADOW ); - swprintf( pStr, L"%ld", (*gpItemDescObject)[gubItemDescStatusIndex]->data.money.uiMoneyAmount ); - InsertCommasForDollarFigure( pStr ); - InsertDollarSignInToString( pStr ); + swprintf( pStr, L"%s", FormatMoney((*gpItemDescObject)[gubItemDescStatusIndex]->data.money.uiMoneyAmount).data() ); if( guiCurrentItemDescriptionScreen == MAP_SCREEN ) FindFontRightCoordinates( (INT16)(ITEMDESC_NAME_X), (INT16)(ITEMDESC_NAME_Y ), 245, ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY); else if ( UsingEDBSystem() > 0 ) @@ -11470,9 +11464,7 @@ void RenderItemPickupMenu( ) if ( Item[ pObject->usItem ].usItemClass == IC_MONEY ) { CHAR16 pStr2[20]; - swprintf( pStr2, L"%ld", (*pObject)[0]->data.money.uiMoneyAmount ); - InsertCommasForDollarFigure( pStr2 ); - InsertDollarSignInToString( pStr2 ); + swprintf( pStr2, L"%s", FormatMoney((*pObject)[0]->data.money.uiMoneyAmount ).data()); swprintf( pStr, L"%s (%ls)", ItemNames[ pObject->usItem ], pStr2 ); } @@ -12216,9 +12208,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier case MONEY: //Money { - swprintf( pStr, L"%ld", (*pObject)[subObject]->data.money.uiMoneyAmount ); - InsertCommasForDollarFigure( pStr ); - InsertDollarSignInToString( pStr ); + swprintf( pStr, L"%s", FormatMoney((*pObject)[subObject]->data.money.uiMoneyAmount ).data()); } break; @@ -12227,9 +12217,7 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier //if ( Item[ usItem ].usItemClass == IC_MONEY ) { CHAR16 pStr2[20]; - swprintf( pStr2, L"%ld", (*pObject)[subObject]->data.money.uiMoneyAmount ); - InsertCommasForDollarFigure( pStr2 ); - InsertDollarSignInToString( pStr2 ); + swprintf( pStr2, L"%s", FormatMoney((*pObject)[subObject]->data.money.uiMoneyAmount ).data()); swprintf( pStr, L"%s (%ls)", ItemNames[ usItem ], pStr2 ); } diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index d399f0f64..ce0f11cf6 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -7783,10 +7783,7 @@ void SMInvMoneyButtonCallback( MOUSE_REGION * pRegion, INT32 iReason ) guiPendingOverrideEvent = A_CHANGE_TO_MOVE; HandleTacticalUI( ); - swprintf( zMoney, L"%d", (*gpItemPointer)[0]->data.money.uiMoneyAmount ); - - InsertCommasForDollarFigure( zMoney ); - InsertDollarSignInToString( zMoney ); + swprintf( zMoney, L"%s", FormatMoney((*gpItemPointer)[0]->data.money.uiMoneyAmount ).data()); //ask the user if they are sure they want to deposit the money swprintf( zText, gzMoneyWithdrawMessageText[ CONFIRMATION_TO_DEPOSIT_MONEY_TO_ACCOUNT ], zMoney ); diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index ace03ba28..c82cdce08 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -1524,15 +1524,13 @@ BOOLEAN RenderShopKeeperInterface() // display shopkeeper budget DisplayWrappedString( SKI_BUDGET_X, SKI_BUDGET_Y, SKI_BUDGET_WIDTH, 2, SKI_LABEL_FONT, SKI_TITLE_COLOR, SKI_Text[SKI_TEXT_BUDGET], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); - swprintf( zMoney, L"%d", gArmsDealerStatus[gbSelectedArmsDealerID].uiArmsDealersCash ); - - InsertCommasForDollarFigure( zMoney ); + swprintf( zMoney, L"%s", FormatMoney(gArmsDealerStatus[gbSelectedArmsDealerID].uiArmsDealersCash).data() ); CHAR16 zTemp2[64]; if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL ) swprintf( zTemp2, L"%s Intel", zMoney ); else - swprintf( zTemp2, L"$%s", zMoney ); + swprintf( zTemp2, L"%s", zMoney ); DrawTextToScreen( zTemp2, SKI_BUDGET_X, SKI_BUDGET_OFFSET_TO_VALUE, SKI_BUDGET_WIDTH, FONT10ARIAL, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, TRUE, CENTER_JUSTIFIED ); @@ -1554,15 +1552,13 @@ BOOLEAN RenderShopKeeperInterface() //Display the players current balance value if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL ) { - swprintf( zMoney, L"%d", (int)(GetIntel()) ); - InsertCommasForDollarFigure( zMoney ); + swprintf( zMoney, L"%s", FormatMoney((int)(GetIntel()) ).data()); swprintf( zTemp2, L"%s Intel", zMoney ); } else { - swprintf( zMoney, L"%d", LaptopSaveInfo.iCurrentBalance ); - InsertCommasForDollarFigure( zMoney ); - swprintf( zTemp2, L"$%s", zMoney ); + swprintf( zMoney, L"%s", FormatMoney(LaptopSaveInfo.iCurrentBalance ).data()); + swprintf( zTemp2, L"%s", zMoney ); } DrawTextToScreen( zTemp2, SKI_PLAYERS_CURRENT_BALANCE_X, SKI_PLAYERS_CURRENT_BALANCE_OFFSET_TO_VALUE, SKI_PLAYERS_CURRENT_BALANCE_WIDTH, FONT10ARIAL, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, TRUE, CENTER_JUSTIFIED ); @@ -1732,14 +1728,12 @@ void DisplayAllDealersCash() DrawTextToScreen( gMercProfiles[ armsDealerInfo[ bArmsDealer ].ubShopKeeperID ].zNickname, SCREEN_X_OFFSET + 540, SCREEN_Y_OFFSET + usPosY, 0, FONT10ARIAL, SKI_TITLE_COLOR, FONT_MCOLOR_BLACK, TRUE, LEFT_JUSTIFIED ); //Display the arms dealer cash on hand - swprintf( zTemp, L"%d", gArmsDealerStatus[ bArmsDealer ].uiArmsDealersCash ); - - InsertCommasForDollarFigure( zTemp ); + swprintf( zTemp, L"%s", FormatMoney(gArmsDealerStatus[ bArmsDealer ].uiArmsDealersCash ).data()); if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL ) swprintf( zTemp2, L"%s Intel", zTemp ); else - swprintf( zTemp2, L"$%s", zTemp ); + swprintf( zTemp2, L"%s", zTemp ); ubForeColor = ( UINT8 ) ( ( bArmsDealer == gbSelectedArmsDealerID ) ? SKI_BUTTON_COLOR : SKI_TITLE_COLOR ); DrawTextToScreen( zTemp2, SCREEN_X_OFFSET + 590, SCREEN_Y_OFFSET + usPosY, 0, FONT10ARIAL, ubForeColor, FONT_MCOLOR_BLACK, TRUE, LEFT_JUSTIFIED ); @@ -2789,14 +2783,13 @@ UINT32 DisplayInvSlot( UINT16 ubSlotNum, UINT16 usItemIndex, UINT16 usPosX, UINT //if the item has a price, display it if( uiItemCost != 0 ) { - swprintf( zTemp, L"%d", uiItemCost ); - InsertCommasForDollarFigure( zTemp ); + swprintf( zTemp, L"%s", FormatMoney(uiItemCost).data() ); CHAR16 zTemp2[64]; if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL ) swprintf( zTemp2, L"%s Intel", zTemp ); else - swprintf( zTemp2, L"$%s", zTemp ); + swprintf( zTemp2, L"%s", zTemp ); DrawTextToScreen( zTemp2, (UINT16)(usPosX+SKI_INV_PRICE_OFFSET_X), (UINT16)(usPosY+SKI_INV_PRICE_OFFSET_Y+4), SKI_INV_SLOT_WIDTH, SKI_ITEM_DESC_FONT, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); } @@ -3462,14 +3455,13 @@ void DisplayArmsDealerOfferArea() if( gubSkiDirtyLevel == SKI_DIRTY_LEVEL2 ) { //Display the total cost text - swprintf( zTemp, L"%d", uiTotalCost ); - InsertCommasForDollarFigure( zTemp ); + swprintf( zTemp, L"%s", FormatMoney(uiTotalCost).data() ); CHAR16 zTemp2[64]; if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL ) swprintf( zTemp2, L"%s Intel", zTemp ); else - swprintf( zTemp2, L"$%s", zTemp ); + swprintf( zTemp2, L"%s", zTemp ); DrawTextToScreen( zTemp2, SKI_ARMS_DEALER_TOTAL_COST_X, (UINT16)(SKI_ARMS_DEALER_TOTAL_COST_Y+5), SKI_INV_SLOT_WIDTH, SKI_LABEL_FONT, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); } @@ -3727,14 +3719,13 @@ void DisplayPlayersOfferArea() if( gubSkiDirtyLevel == SKI_DIRTY_LEVEL2 ) { //Display the total cost text - swprintf( zTemp, L"%d", uiTotalCost ); - InsertCommasForDollarFigure( zTemp ); + swprintf( zTemp, L"%s", FormatMoney(uiTotalCost).data() ); CHAR16 zTemp2[64]; if ( armsDealerInfo[gbSelectedArmsDealerID].uiFlags & ARMS_DEALER_DEALWITHINTEL ) swprintf( zTemp2, L"%s Intel", zTemp ); else - swprintf( zTemp2, L"$%s", zTemp ); + swprintf( zTemp2, L"%s", zTemp ); DrawTextToScreen( zTemp2, SKI_TOTAL_VALUE_X, SKI_TOTAL_VALUE_OFFSET_TO_VALUE, SKI_INV_SLOT_WIDTH, SKI_LABEL_FONT, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); } diff --git a/TacticalAI/NPC.cpp b/TacticalAI/NPC.cpp index 91cc5951d..1c5842a16 100644 --- a/TacticalAI/NPC.cpp +++ b/TacticalAI/NPC.cpp @@ -1546,8 +1546,7 @@ BOOLEAN HandleNPCBeingGivenMoneyByPlayer( UINT8 ubNPC, UINT32 uiMoneyAmount, UIN { CHAR16 sTempString[ 100 ]; - swprintf( sTempString, L"%ld", iCost - uiMoneyAmount - giHospitalTempBalance ); - InsertDollarSignInToString( sTempString ); + swprintf( sTempString, L"%s", FormatMoney(iCost - uiMoneyAmount - giHospitalTempBalance).data()); // not enough cash ScreenMsg( FONT_MCOLOR_LTYELLOW, diff --git a/Utils/Text Utils.cpp b/Utils/Text Utils.cpp index 154ef0035..7ef2bb523 100644 --- a/Utils/Text Utils.cpp +++ b/Utils/Text Utils.cpp @@ -5,6 +5,19 @@ #include #include +auto FormatMoney(INT32 iNumber) -> std::wstring +{ + static std::wstringstream wss([] { + std::wstringstream ss; + ss.imbue(std::locale("")); + return ss; + }()); + wss.str(L""); + wss << iNumber; + + return L"$" + wss.str(); +} + BOOLEAN LoadItemInfo(UINT16 ubIndex, STR16 pNameString, STR16 pInfoString ) { int j = 0; diff --git a/i18n/include/Text.h b/i18n/include/Text.h index 58a7154c7..470398476 100644 --- a/i18n/include/Text.h +++ b/i18n/include/Text.h @@ -8,6 +8,8 @@ #define STRING_LENGTH 255 +auto FormatMoney(INT32) -> std::wstring; + enum { //TCTL_MSG__RANGE_TO_TARGET,