Tweaked Trader Filters

This commit is contained in:
He-Man 2020-09-01 18:44:50 +02:00
parent 57bc71350e
commit 765065aa4a
3 changed files with 34 additions and 30 deletions

View File

@ -30,18 +30,18 @@ _LbText = _control lbText _index;
_config = 'CfgItemSort' call EPOCH_returnConfig; _config = 'CfgItemSort' call EPOCH_returnConfig;
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes"); _MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
_FilterArray = []; _FilterArray = [];
if (_index != 0) then { if !((tolower _LbText) isEqualTo "all") then {
if (!_isPlayerFilter && _LbText in if (!_isPlayerFilter && _LbText in
[ [
format ["Fits %1",(primaryweapon player) call EPOCH_itemDisplayName], format ["Fits your %1",(primaryweapon player) call EPOCH_itemDisplayName],
format ["Fits %1",(secondaryweapon player) call EPOCH_itemDisplayName], format ["Fits your %1",(secondaryweapon player) call EPOCH_itemDisplayName],
format ["Fits %1",(handgunweapon player) call EPOCH_itemDisplayName] format ["Fits your %1",(handgunweapon player) call EPOCH_itemDisplayName]
] ]
) exitwith { ) exitwith {
_CheckWpnClass = switch _LbText do { _CheckWpnClass = switch _LbText do {
case (format ["Fits %1",(primaryweapon player) call EPOCH_itemDisplayName]) : {primaryweapon player}; case (format ["Fits your %1",(primaryweapon player) call EPOCH_itemDisplayName]) : {primaryweapon player};
case (format ["Fits %1",(secondaryweapon player) call EPOCH_itemDisplayName]) : {secondaryweapon player}; case (format ["Fits your %1",(secondaryweapon player) call EPOCH_itemDisplayName]) : {secondaryweapon player};
case (format ["Fits %1",(handgunweapon player) call EPOCH_itemDisplayName]) : {handgunweapon player}; case (format ["Fits your %1",(handgunweapon player) call EPOCH_itemDisplayName]) : {handgunweapon player};
}; };
_possiblemags = getarray (configfile >> "CfgWeapons" >> _CheckWpnClass >> "magazines"); _possiblemags = getarray (configfile >> "CfgWeapons" >> _CheckWpnClass >> "magazines");
_possibleMuzzles = getarray (configfile >> "CfgWeapons" >> _CheckWpnClass >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems"); _possibleMuzzles = getarray (configfile >> "CfgWeapons" >> _CheckWpnClass >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
@ -54,8 +54,8 @@ if (_index != 0) then {
}; };
{ {
_MainCategorie = _x; _MainCategorie = _x;
if (_index == (_MainCategorie select 0)) then { _MainCategorie params ["_category","_subcategories"];
_subcategories = _MainCategorie select 2; if (_LbText isEqualTo _category) then {
{ {
_SubCategorieItems = getArray (_config >> "SubCatergories" >> _x); _SubCategorieItems = getArray (_config >> "SubCatergories" >> _x);
{ {
@ -93,7 +93,7 @@ if !(isNull EPOCH_lastNPCtradeTarget) then {
if (_qty < 1) then { if (_qty < 1) then {
_tooltip = format ["%1 rounds left in Magazine",_rounds]; _tooltip = format ["%1 rounds left in Magazine",_rounds];
}; };
if (_index == 0 || (tolower _item) in _FilterArray) then { if ((tolower _LbText) isEqualTo "all" || (tolower _item) in _FilterArray) then {
_id = lbAdd [_PlayerItemsBox, (_item call EPOCH_itemDisplayName) + (if (_onHand) then {" (in Hand)"} else {""})]; _id = lbAdd [_PlayerItemsBox, (_item call EPOCH_itemDisplayName) + (if (_onHand) then {" (in Hand)"} else {""})];
lbSetData [_PlayerItemsBox, _id, _item]; lbSetData [_PlayerItemsBox, _id, _item];
lbSetValue [_PlayerItemsBox, _id, _rounds]; lbSetValue [_PlayerItemsBox, _id, _rounds];
@ -124,7 +124,7 @@ if !(isNull EPOCH_lastNPCtradeTarget) then {
{ {
if (local _x) then { if (local _x) then {
_type = typeOf _x; _type = typeOf _x;
if (_index == 0 || (tolower _type) in _FilterArray) then { if ((tolower _LbText) isEqualTo "all" || (tolower _type) in _FilterArray) then {
_itemCount = { typeOf _x == _type } count _vehicles; _itemCount = { typeOf _x == _type } count _vehicles;
_itemOfferCount = { _x == _type } count _VehOfferArray; _itemOfferCount = { _x == _type } count _VehOfferArray;
if (_itemCount > _itemOfferCount) then { if (_itemCount > _itemOfferCount) then {
@ -155,7 +155,7 @@ if !(isNull EPOCH_lastNPCtradeTarget) then {
{ {
_x params ["_displayname","_item","_rounds"]; _x params ["_displayname","_item","_rounds"];
if !(_item isequalto "") then { if !(_item isequalto "") then {
if (_index == 0 || (tolower _item) in _FilterArray) then { if ((tolower _LbText) isEqualTo "all" || (tolower _item) in _FilterArray) then {
_maxrnd = 1; _maxrnd = 1;
_tooltip = ""; _tooltip = "";
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then { if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {

View File

@ -13,7 +13,7 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf
*/ */
private ["_config","_MainCategoriearray","_target","_slot","_index","_ok","_categorie"]; private ["_config","_MainCategoriearray","_target","_slot","_index","_ok","_categorie","_idx"];
_config = 'CfgItemSort' call EPOCH_returnConfig; _config = 'CfgItemSort' call EPOCH_returnConfig;
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes"); _MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
_target = cursorTarget; _target = cursorTarget;
@ -46,24 +46,28 @@ if (alive _target) then {
if (!_ok) exitWith {}; if (!_ok) exitWith {};
9992 cutRsc["EpochGameUI2", "PLAIN", 2, false]; 9992 cutRsc["EpochGameUI2", "PLAIN", 2, false];
((uiNamespace getVariable "EPOCH_EpochGameUI2") displayCtrl 21208) ctrlSetText format["%1", EPOCH_playerCrypto]; ((uiNamespace getVariable "EPOCH_EpochGameUI2") displayCtrl 21208) ctrlSetText format["%1", EPOCH_playerCrypto];
{ _idx = 0;
_categorie = _x select 1;
lbAdd [42100,_categorie];
lbAdd [42101,_categorie]
} forEach _MainCategoriearray;
if !(primaryweapon player isEqualTo "") then { if !(primaryweapon player isEqualTo "") then {
_idx = lbAdd [42101,format ["Fits %1",(primaryweapon player) call EPOCH_itemDisplayName]]; lbAdd [42101,format ["Fits your %1",(primaryweapon player) call EPOCH_itemDisplayName]];
lbSetColor [42101, _idx, [1, 1, 0, 1]]; lbSetColor [42101, _idx, [1, 1, 0, 1]];
_idx = _idx + 1;
}; };
if !(secondaryweapon player isEqualTo "") then { if !(secondaryweapon player isEqualTo "") then {
_idx = lbAdd [42101,format ["Fits %1",(secondaryweapon player) call EPOCH_itemDisplayName]]; lbAdd [42101,format ["Fits your %1",(secondaryweapon player) call EPOCH_itemDisplayName]];
lbSetColor [42101, _idx, [1, 1, 0, 1]]; lbSetColor [42101, _idx, [1, 1, 0, 1]];
_idx = _idx + 1;
}; };
if !(handgunweapon player isEqualTo "") then { if !(handgunweapon player isEqualTo "") then {
_idx = lbAdd [42101,format ["Fits %1",(handgunweapon player) call EPOCH_itemDisplayName]]; lbAdd [42101,format ["Fits your %1",(handgunweapon player) call EPOCH_itemDisplayName]];
lbSetColor [42101, _idx, [1, 1, 0, 1]]; lbSetColor [42101, _idx, [1, 1, 0, 1]];
_idx = _idx + 1;
}; };
{
_categorie = _x select 0;
lbAdd [42100,_categorie];
lbAdd [42101,_categorie];
} forEach _MainCategoriearray;
lbSetCurSel [42100, 0]; lbSetCurSel [42100, 0];
lbSetCurSel [42101, 0]; lbSetCurSel [42101, _idx];
}; };
}; };

View File

@ -5,14 +5,14 @@ class CfgItemSort
class MainCategories class MainCategories
{ {
classes[] = { classes[] = {
{0,"All",{}}, {"All",{}}, // Category "All" is hardcoded and do not need an array of subcategories!
{1,"Clothings / Backpacks",{"Uniforms","Vests","HeadGear","Backpacks"}}, {"Clothings / Backpacks",{"Uniforms","Vests","HeadGear","Backpacks"}},
{2,"Weapons",{"Weapons","Handweapons"}}, {"Weapons",{"Weapons","Handweapons"}},
{3,"Magazines / Attachments",{"Magazines","Attachments"}}, {"Magazines / Attachments",{"Magazines","Attachments"}},
{4,"Equipment / Explosives",{"Equipment","Explosive","Hand"}}, {"Equipment / Explosives",{"Equipment","Explosive","Hand"}},
{5,"Medical / Food",{"Medical","Food","Drink"}}, {"Medical / Food",{"Medical","Food","Drink"}},
{6,"Items / Basebuilding",{"Basebuilding","Items"}}, {"Items / Basebuilding",{"Basebuilding","Items"}},
{7,"Vehicles",{"Vehicles_Land","Vehicles_Air","Vehicles_Ship"}} {"Vehicles",{"Vehicles_Land","Vehicles_Air","Vehicles_Ship"}}
}; };
}; };
class SubCatergories class SubCatergories