From 3f3f1a32ed169e1fba674bcd17ff3c51793f8a92 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Tue, 16 Aug 2016 16:28:06 -0400 Subject: [PATCH] Use BIS_fnc_numberText for SC number displays See: https://github.com/EpochModTeam/DayZ-Epoch/issues/1712#issuecomment-239647854 That should be all of them @ndavalos let me know if I missed any. --- .../functions/z_at_buyItems.sqf | 4 +- .../functions/z_at_calcPrice.sqf | 4 +- .../functions/z_at_checkArrayInConfig.sqf | 2 +- .../functions/z_at_sellItems.sqf | 2 +- SQF/dayz_code/compile/fn_numberDigits.sqf | 53 +++++++++++++++++++ SQF/dayz_code/compile/fn_numberText.sqf | 35 ++++++++++++ SQF/dayz_code/init/compiles.sqf | 2 + 7 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 SQF/dayz_code/compile/fn_numberDigits.sqf create mode 100644 SQF/dayz_code/compile/fn_numberText.sqf diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf index 3358049b3..ac7e23de4 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf @@ -251,7 +251,7 @@ if (_enoughMoney) then { } else { _success = [player,_priceToBuy] call SC_fnc_removeCoins; if (_success) then { - systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS", _priceToBuy, CurrencyName]; + systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName]; } else { systemChat localize "STR_EPOCH_TRADE_DEBUG"; }; @@ -259,7 +259,7 @@ if (_enoughMoney) then { _itemsToLog call Z_logTrade; } else { if (Z_SingleCurrency) then { - systemChat format[localize "STR_EPOCH_TRADE_NEED_COINS",_priceToBuy,CurrencyName]; + systemChat format[localize "STR_EPOCH_TRADE_NEED_COINS",[_priceToBuy] call BIS_fnc_numberText,CurrencyName]; } else { systemChat localize "STR_EPOCH_TRADE_NEED_MONEY"; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf index 55998e3a6..d997a2bd3 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcPrice.sqf @@ -15,14 +15,14 @@ if (Z_SingleCurrency) then { { _sellPrice = _sellPrice + (_x select 2); } count Z_SellArray; - _ctrlText = format["%1 %2", _sellPrice , CurrencyName]; + _ctrlText = format["%1 %2",[_sellPrice] call BIS_fnc_numberText,CurrencyName]; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_SELLING", count Z_SellArray]; } else { { _sellPrice = _sellPrice + ((_x select 2) * (_x select 9)); _bTotal = _bTotal + (_x select 9); } count Z_BuyingArray; - _ctrlText = format["%1 %2", _sellPrice , CurrencyName]; + _ctrlText = format["%1 %2",[_sellPrice] call BIS_fnc_numberText,CurrencyName]; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_BUYING", _bTotal]; }; ctrlSetText [Z_AT_PRICEDISPLAY, _ctrlText]; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf index 9837a42f7..5a8fe8307 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf @@ -115,7 +115,7 @@ if (Z_SellingFrom != 2) then { _extraText = getText (configFile >> 'CfgVehicles' if (isNil '_extraText') then { _extraText = _backUpText; }; if (Z_SingleCurrency) then { - ctrlSetText [Z_AT_TRADERLINE2, format[localize "STR_EPOCH_TRADE_OFFER", _totalPrice,CurrencyName]]; + ctrlSetText [Z_AT_TRADERLINE2, format[localize "STR_EPOCH_TRADE_OFFER",[_totalPrice] call BIS_fnc_numberText,CurrencyName]]; } else { ctrlSetText [Z_AT_TRADERLINE2, '']; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf index 77d724072..90509deee 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -223,7 +223,7 @@ if (Z_SingleCurrency) then { if (typeName _money == "SCALAR") then { if (Z_SingleCurrency) then { _success = [player,_money] call SC_fnc_addCoins; - systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE", _money , CurrencyName]; + systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE",[_money] call BIS_fnc_numberText,CurrencyName]; } else { _success = [_money,0,false,0,[],[]] call Z_returnChange; _tCost = ""; diff --git a/SQF/dayz_code/compile/fn_numberDigits.sqf b/SQF/dayz_code/compile/fn_numberDigits.sqf new file mode 100644 index 000000000..e35e84c7e --- /dev/null +++ b/SQF/dayz_code/compile/fn_numberDigits.sqf @@ -0,0 +1,53 @@ +/* + + Description: + Break number into array of digits + + Example: + 123456 > [1,2,3,4,5,6] + + Parameter(s): + _this: NUMBER + + Returns: + ARRAY +*/ + +private ["_number","_step","_stepLocal","_result","_numberLocal","_add"]; + +_number = [_this,0,0,[0]] call bis_fnc_param; + +if (_number < 10) then { + + [_number] + +} else { + + _step = 10; + _stepLocal = _step; + _result = [0]; + _add = false; + + while {_stepLocal < (_number * _step)} do { + + _numberLocal = _number % (_stepLocal); + + { + _numberLocal = _numberLocal - _x; + } foreach _result; + + _numberLocal = floor (_numberLocal / _stepLocal * _step); + + if (_numberLocal < 0) then {_numberLocal = 9}; + + _result = [_numberLocal] + _result; + _stepLocal = _stepLocal * (_step); + + }; + + if ((_result select 0) == 0) then {_result = [1] + _result;}; + + _result resize (count _result - 1); + _result + +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_numberText.sqf b/SQF/dayz_code/compile/fn_numberText.sqf new file mode 100644 index 000000000..cb2fd7357 --- /dev/null +++ b/SQF/dayz_code/compile/fn_numberText.sqf @@ -0,0 +1,35 @@ +/* + + Description: + Convert a number into string (avoiding scientific notation) + + Parameter(s): + _this: ARRAY containing single NUMBER + + Returns: + STRING + + Example: + [scalarNumber] call BIS_fnc_numberText +*/ + +private ["_number","_mod","_digots","_digitsCount","_modBase","_numberText"]; + +_number = [_this,0,0,[0, ""]] call bis_fnc_param; +_mod = [_this,1,3,[0]] call bis_fnc_param; + +if (typeName _number == "STRING") then { + _number = parseNumber _number; +}; + +_digits = _number call BIS_fnc_numberDigits; +_digitsCount = count _digits - 1; +_modBase = _digitsCount % _mod; +_numberText = ""; + +{ + _numberText = _numberText + str _x; + if ((_foreachindex - _modBase) % (_mod) == 0 && _foreachindex != _digitsCount) then {_numberText = _numberText + ",";}; +} foreach _digits; + +_numberText \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 413f07043..3303be1c9 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -627,6 +627,8 @@ call compile preprocessFileLineNumbers "\z\addons\dayz_code\traps\init.sqf"; call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\psrnd.sqf"; // pseudo random for plantSpanwer // EPOCH ADDITIONS +BIS_fnc_numberDigits = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_numberDigits.sqf"; +BIS_fnc_numberText = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_numberText.sqf"; local_lockUnlock = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_lockUnlock.sqf"; //When vehicle is local to unit perform locking vehicle local_gutObjectZ = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_gutObjectZ.sqf"; //Generated on the server (or local to unit) when gutting an object local_spawnObjects = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_spawnObjects.sqf";