add more filters to ammo boxes

This commit is contained in:
commy2 2015-12-11 14:18:11 +01:00
parent 2b63b2efa8
commit 5d9a057165
6 changed files with 68 additions and 8 deletions

View File

@ -16,36 +16,44 @@ PREP(onLBSelChanged);
if !(uiNamespace getVariable [QGVAR(configCached), false]) then {
private _fnc_addToCache = {
private _displayName = getText (_x >> "displayName");
private _picture = getText (_x >> "picture");
private _displayName = getText (_this >> "displayName");
private _picture = getText (_this >> "picture");
// list box seems to delete the leading backslash
if (_picture select [0,1] == "\") then {
_picture = _picture select [1];
};
uiNamespace setVariable [format [QGVAR(ItemKey:%1:%2), _displayName, _picture], _x];
uiNamespace setVariable [format [QGVAR(ItemKey:%1:%2), _displayName, _picture], _this];
};
// weapons, magazines, items
// weapons and items
{
if (getNumber (_x >> "scope") > 0) then _fnc_addToCache;
if (getNumber (_x >> "scope") > 0) then {_x call _fnc_addToCache};
false
} count (
("true" configClasses (configFile >> "CfgWeapons")) +
("true" configClasses (configFile >> "CfgMagazines")) +
("true" configClasses (configFile >> "CfgGlasses"))
);
// magazines
{
if (getNumber (_x >> "scope") == 2) then {_x call _fnc_addToCache};
false
} count ("true" configClasses (configFile >> "CfgMagazines"));
// backpacks
{
if (getNumber (_x >> "scope") > 0 && {getNumber (_x >> "isBackpack") == 1}) then _fnc_addToCache;
if (getNumber (_x >> "scope") > 0 && {getNumber (_x >> "isBackpack") == 1}) then {_x call _fnc_addToCache};
false
} count ("true" configClasses (configFile >> "CfgVehicles"));
uiNamespace setVariable [QGVAR(configCached), true];
};
PREP(filterWeapons);
PREP(filterMagazines);
PREP(filterItems);
PREP(filterHeadgear);
PREP(filterUniforms);
PREP(filterVests);

View File

@ -0,0 +1,17 @@
/*
* Author: commy2
* Remove uniforms, vests and backpacks from Items filter.
*
* Arguments:
* 0: Item config entry <CONFIG>
*
* Return Value:
* Item should appear in this list? <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
params ["_config"];
!(_this call FUNC(filterUniforms)) && {!(_this call FUNC(filterVests))} && {!(_this call FUNC(filterBackpacks))}

View File

@ -0,0 +1,15 @@
/*
* Author: commy2
* Remove backpacks and grenades from Magazines filter.
*
* Arguments:
* 0: Item config entry <CONFIG>
*
* Return Value:
* Item should appear in this list? <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
!(_this call FUNC(filterBackpacks)) && {!(_this call FUNC(filterGrenades))}

View File

@ -0,0 +1,15 @@
/*
* Author: commy2
* Remove backpacks from Weapons filter.
*
* Arguments:
* 0: Item config entry <CONFIG>
*
* Return Value:
* Item should appear in this list? <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
!(_this call FUNC(filterBackpacks))

View File

@ -27,7 +27,7 @@ if (_filterFunction isEqualType {}) then {
format [QGVAR(ItemKey:%1:%2), _itemList lbText _i, _itemList lbPicture _i],
configNull
];
diag_log text format [QGVAR(ItemKey:%1:%2), _itemList lbText _i, _itemList lbPicture _i];
if (!isNull _config && {!(_config call _filterFunction)}) then {
_itemList lbDelete _i;

View File

@ -35,6 +35,11 @@ _filter ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChanged)}];
private _nameAll = _filter lbText _index;
_filter lbDelete _index;
// add additional filter functions to the default filters. These remove backpacks etc.
_filter lbSetData [0, QFUNC(filterWeapons)];
_filter lbSetData [1, QFUNC(filterMagazines)];
_filter lbSetData [2, QFUNC(filterItems)];
// add our custom filters
{
_x params ["_name", "_fncName"];