Add handling of magazine overflow in AdvTrade and free slot icons

- Added proper handling of pistol mags and regular mags in gear to
prevent magazine overflow
- Added pre-check if return change will overflow gear + backpack free
space. If change will not fit in gear + backpack free space then buy is
prevented with a message notifying the player. In the case of a sale it
proceeds anyway, but notifies player if overflow occurs (see comments in
returnChange)
- Consolidated duplicate code for calculating free space and returning
cargo of an object into new calcFreeSpace
- Old calculateFreeSpace renamed to displayFreeSpace
- Added Weps/Mags/Bags icons to free slot numbers display
This commit is contained in:
ebaydayz
2016-07-31 18:38:39 -04:00
parent d7cb2b446e
commit a5be49c546
20 changed files with 359 additions and 422 deletions

View File

@@ -3,7 +3,7 @@
*
* Gets all your items stored in your backpack and innitiates the selling list.
**/
private ["_backpack","_pic","_formattedText","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_amounts","_amounts2"];
private ["_backpack","_pic","_formattedText","_normalMags","_normalWeaps","_freeSpace"];
#include "defines.hpp"
call Z_clearLists;
@@ -20,30 +20,10 @@ if (!isNull _backpack) then {
];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
_mags = getMagazineCargo _backpack;
_weaps = getWeaponCargo _backpack;
_normalMags = [];
_normalWeaps = [];
_kinds = _mags select 0;
_amounts = _mags select 1;
{
_counter = 0 ;
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
};
} forEach _kinds;
_kinds2 = _weaps select 0;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
} forEach _kinds2;
_freeSpace = [_backpack,0,0,0,0] call Z_calcFreeSpace;
_normalMags = _freeSpace select 5;
_normalWeaps = _freeSpace select 6;
[_normalMags,_normalWeaps, typeOf _backpack,[]] call Z_checkArrayInConfig;
};