Merge pull request #687 from EpochModTeam/release

merge trader menu changes to experimental
This commit is contained in:
vbawol 2016-12-14 10:21:59 -06:00 committed by GitHub
commit 46e9e557be
4 changed files with 1114 additions and 119 deletions

View File

@ -27,27 +27,28 @@ disableSerialization;
private ["_aiItems","_bpck","_config","_filterArray","_filterItems","_filterMagazines","_filterVehicle","_filterWeapons","_index","_isPlayerFilter","_item","_itemCount","_itemIcon","_itemName","_itemOfferCount","_items","_name","_offerArray","_picture","_qty","_qtys","_sizeOut","_slot","_type","_vehicles","_wpn"];
//[[[end]]]
params ["_control","_index"];
_config = 'CfgItemSort' call EPOCH_returnConfig;
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
_FilterArray = [];
if (_index != 0) then {
{
_MainCategorie = _x;
if (_index == (_MainCategorie select 0)) then {
_subcategories = _MainCategorie select 2;
{
_SubCategorieItems = getArray (_config >> "SubCatergories" >> _x);
{
_FilterArray pushback (tolower _x);
} foreach _SubCategorieItems;
} forEach _subcategories;
};
} forEach _MainCategoriearray;
};
if !(isNull EPOCH_lastNPCtradeTarget) then {
_slot = EPOCH_lastNPCtradeTarget getVariable["AI_SLOT", -1];
_isPlayerFilter = (ctrlIDC _control == 42100);
if (_slot != -1) then {
_filterArray = [
[true,true,true,true], // all
// [true,false,false,false], // weapons only
[false,true,false,false], // mags only
[false,false,true,false], // items only
[false,false,false,true] // vehicles only
];
//_filterWeapons = ((_filterArray select _index) select 0);
_filterMagazines = ((_filterArray select _index) select 1);
_filterItems = ((_filterArray select _index) select 2);
_filterVehicle = ((_filterArray select _index) select 3);
if (_isPlayerFilter) then {
_sizeOut = lbSize 41501;
_offerArray = [];
if (_sizeOut > 0) then {
@ -56,135 +57,88 @@ if !(isNull EPOCH_lastNPCtradeTarget) then {
_offerArray pushBack _item;
};
};
lbClear 41500;
_playeritems = ((items player)+(magazines player));
if (primaryWeapon player != "") then {
_playeritems pushback primaryWeapon player;
};
if (count backpackItems player == 0 && count backpackmagazines player == 0 && backpack player != "") then {
_playeritems pushback backpack player;
};
if (_filterMagazines) then {
{
// make sure this exceeds the item count already offered
_item = _x;
_itemCount = {_x == _item} count magazines player;
_itemOfferCount = {_x == _item} count _offerArray;
if (_itemCount > _itemOfferCount) then {
_offerArray pushBack _item;
_index = lbAdd [41500, _x call EPOCH_itemDisplayName];
lbSetData [41500, _index, _x];
lbSetPicture [41500, _index, _x call EPOCH_itemPicture];
{
_item = _x;
if !(_item isequalto "") then {
if (_index == 0 || (tolower _item) in _FilterArray) then {
_itemCount = {_x == _item} count ((items player)+(magazines player)+[backpack player]+[primaryweapon player]);
_itemOfferCount = {_x == _item} count _offerArray;
if (_itemCount > _itemOfferCount) then {
_offerArray pushBack _item;
_id = lbAdd [41500, _x call EPOCH_itemDisplayName];
lbSetData [41500, _id, _x];
lbSetPicture [41500, _id, _x call EPOCH_itemPicture];
};
};
} forEach magazines player;
};
/* not used currently
if (_filterWeapons) then {
};
*/
if (_filterItems) then {
{
_item = _x;
_itemCount = {_x == _item} count items player;
_itemOfferCount = {_x == _item} count _offerArray;
if (_itemCount > _itemOfferCount) then {
_offerArray pushBack _item;
_index = lbAdd [41500, _x call EPOCH_itemDisplayName];
lbSetData [41500, _index, _x];
lbSetPicture [41500, _index, _x call EPOCH_itemPicture];
};
} forEach items player;
if (primaryWeapon player != "") then {
_wpn = primaryWeapon player;
_offerArray pushback _wpn;
_index = lbAdd [41500, _wpn call EPOCH_itemDisplayName];
lbSetData [41500, _index, _wpn];
lbSetPicture [41500, _index, _wpn call EPOCH_itemPicture];
};
if (count backpackItems player == 0 && count backpackmagazines player == 0 && backpack player != "") then {
_bpck = Backpack player;
_offerArray pushback _bpck;
_index = lbAdd [41500, _bpck call EPOCH_itemDisplayName];
lbSetData [41500, _index, _bpck];
lbSetPicture [41500, _index, _bpck call EPOCH_itemPicture];
};
};
} forEach _playeritems;
if (_filterVehicle) then {
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
{
if (local _x) then {
_type = typeOf _x;
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
{
if (local _x) then {
_type = typeOf _x;
if (_index == 0 || (tolower _type) in _FilterArray) then {
_itemCount = { typeOf _x == _type } count _vehicles;
_itemOfferCount = { _x == _type } count _offerArray;
if (_itemCount > _itemOfferCount) then {
_offerArray pushBack _type;
_config = configFile >> "CfgVehicles" >> _type;
_name = getText(_config >> "displayName");
_picture = getText(_config >> "picture");
_index = lbAdd[41500, _name];
lbSetData[41500, _index, _type];
lbSetPicture[41500, _index, _picture];
_id = lbAdd[41500, _name];
lbSetData[41500, _id, _type];
lbSetPicture[41500, _id, _picture];
};
};
} forEach _vehicles;
};
} else {
};
} forEach _vehicles;
_control = (_display displayCtrl 41500);
lbsort _control;
}
else {
lbClear 41503;
_sizeOut = lbSize 41502;
_offerArray = [];
if (_sizeOut > 0) then {
for "_i" from 0 to (_sizeOut - 1) do {
_item = lbData [41502, _i];
_offerArray pushBack _item;
_id = lbData [41502, _i];
_offerArray pushBack _id;
};
};
_aiItems = EPOCH_lastNPCtradeTarget getVariable["AI_ITEMS", []];
if ((count _aiItems) == 2) then {
_items = _aiItems select 0;
_qtys = _aiItems select 1;
_sortarray = [];
{
_sortarray pushback [_x call EPOCH_itemDisplayName,_x,_qtys select _foreachindex];
} foreach _items;
_sortarray sort true;
_item = _x;
_itemName = "";
_itemIcon = "";
if ([_item, "CfgVehicles"] call EPOCH_fnc_isAny) then {
if (_filterVehicle) then {
_itemName = getText(configfile >> "CfgVehicles" >> _item >> "DisplayName");
_itemIcon = getText(configfile >> "CfgVehicles" >> _item >> "picture");
};
} else {
if ([_item, "CfgWeapons"] call EPOCH_fnc_isAny) then {
if (_filterItems) then {
_itemName = getText(configfile >> "CfgWeapons" >> _item >> "DisplayName");
_itemIcon = getText(configfile >> "CfgWeapons" >> _item >> "picture");
};
} else {
if ([_item, "CfgMagazines"] call EPOCH_fnc_isAny) then {
if (_filterMagazines) then {
_itemName = getText(configfile >> "CfgMagazines" >> _item >> "DisplayName");
_itemIcon = getText(configfile >> "CfgMagazines" >> _item >> "picture");
};
{
_item = _x select 1;
if !(_item isequalto "") then {
if (_index == 0 || (tolower _item) in _FilterArray) then {
_qty = ((_x select 2) - ({_x == _item} count _offerArray));
if (_qty > 0) then {
_id = lnbAddRow[41503, ["", str(_qty),_x select 0]];
lnbSetData [41503, [_id,0], _item];
lnbSetValue [41503, [_id,0], _qty];
lnbSetPicture [41503, [_id,0], _item call EPOCH_itemPicture];
};
};
};
if (_itemName != "") then {
_qty = ((_qtys select _forEachIndex) - ({_x == _item} count _offerArray));
if (_qty > 0) then {
// _offerArray pushBack _item;
_index = lnbAddRow[41503, ["", str(_qty), _itemName]];
lnbSetData [41503, [_index,0], _item];
lnbSetValue [41503, [_index,0], _qty];
lnbSetPicture [41503, [_index,0], _itemIcon];
};
};
} forEach _items;
} forEach _sortarray;
};
};
};

View File

@ -1,6 +1,8 @@
//[[[cog import generate_private_arrays ]]]
private ["_ok","_slot","_target"];
//[[[end]]]
_config = 'CfgItemSort' call EPOCH_returnConfig;
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
_target = cursorTarget;
if (alive _target) then {
_slot = _target getVariable ["AI_SLOT",-1];
@ -11,7 +13,11 @@ if (alive _target) then {
if (!_ok) exitWith {};
9992 cutRsc["EpochGameUI2", "PLAIN", 2, false];
((uiNamespace getVariable "EPOCH_EpochGameUI2") displayCtrl 21208) ctrlSetText format["%1", EPOCH_playerCrypto];
{lbAdd[42100,_x];lbAdd[42101,_x]} forEach ["All","Magazines","Items","Vehicles"];
{
_categorie = _x select 1;
lbAdd[42100,_categorie];
lbAdd[42101,_categorie]
} forEach _MainCategoriearray;
lbSetCurSel[42100, 0];
lbSetCurSel[42101, 0];
};

File diff suppressed because it is too large Load Diff

View File

@ -52,6 +52,7 @@ wreckRemovalMaxTime = 360;
disableRandomization[] = {"All"};
#include "Configs\CfgItemSort.hpp"
#include "Configs\CfgTraderMissions.hpp"
#include "Configs\CfgMissions.hpp"
#include "Configs\CfgMissionsTasks.hpp"