Files
DayZ-Epoch/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getContainer.sqf
ebaydayz a5be49c546 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
2016-07-31 18:38:53 -04:00

85 lines
2.6 KiB
Plaintext

/**
* call Z_getContainer
*
* Switches between selling and buying and the item container (gear/vehicle/backpack) and initiates item loading.
**/
private ["_lbIndex","_canBuyInVehicle","_backpack"];
#include "defines.hpp"
if (Z_Selling) then {
call Z_clearBuyingList;
Z_BuyingArray = [];
};
call Z_clearLists;
Z_SellableArray = [];
Z_SellArray = [];
_lbIndex = _this select 0;
_backpack = unitBackpack player;
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText "";
call Z_calcPrice;
if (Z_Selling) then {
switch (_lbIndex) do {
case 0: { //backpack
if (!isNull _backpack) then {
[localize "STR_EPOCH_TRADE_SELLING_BACKPACK"] call Z_filleTradeTitle;
Z_SellingFrom = 0;
call Z_getBackpackItems;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 1: { //vehicle
_canBuyInVehicle = true call Z_checkCloseVehicle;
if (_canBuyInVehicle) then {
[localize "STR_EPOCH_TRADE_SELLING_VEHICLE"] call Z_filleTradeTitle;
Z_SellingFrom = 1;
call Z_getVehicleItems;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 2: { //gear
[localize "STR_EPOCH_TRADE_SELLING_GEAR"] call Z_filleTradeTitle;
Z_SellingFrom = 2;
call Z_getGearItems;
};
};
} else {
ctrlSetText [Z_AT_TRADERLINE2, " "];
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_SELLING_ALL"];
switch (_lbIndex) do {
case 0: { //backpack
if (!isNull _backpack) then {
Z_SellingFrom = 0;
[localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_filleTradeTitle;
[0] call Z_displayFreeSpace;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 1: { //vehicle
_canBuyInVehicle = true call Z_checkCloseVehicle;
if (_canBuyInVehicle) then {
Z_SellingFrom = 1;
[localize "STR_EPOCH_TRADE_BUYING_VEHICLE"] call Z_filleTradeTitle;
[1] call Z_displayFreeSpace;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " ";
};
};
case 2: { //gear
Z_SellingFrom = 2;
[localize "STR_EPOCH_TRADE_BUYING_GEAR"] call Z_filleTradeTitle;
[2] call Z_displayFreeSpace;
};
};
};