ACE3/addons/inventory/functions/fnc_inventoryDisplayLoad.sqf

70 lines
2.0 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-12-11 12:14:58 +00:00
/*
* Author: commy2
* Executed every time an inventory display is opened.
*
* Arguments:
* 0: Inventory display <DISPLAY>
*
* Return Value:
* None
*
* Example:
* [DISPLAY] call ace_inventory_fnc_inventoryDisplayLoad
*
2015-12-11 12:14:58 +00:00
* Public: No
*/
2015-12-11 00:02:15 +00:00
disableSerialization;
2015-12-11 00:02:15 +00:00
params ["_display"];
2015-12-11 12:14:58 +00:00
private _filter = _display displayCtrl IDC_FILTERLISTS;
2015-12-11 00:02:15 +00:00
// Engine defined behaviour is the following:
2015-12-11 00:02:15 +00:00
// lb value, data and text don't matter, only the index.
// The first three indecies are hard coded: 0 - weapons , 1 - magazines, 2 - items
// All of them show backpacks, because BI
// All other indecies show everything, so all we have to do is delete stuff we don't like
_filter ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onLBSelChanged)];
2015-12-11 00:02:15 +00:00
// Have to add these a frame later, because this event happens before the engine adds the default filters
2015-12-11 00:02:15 +00:00
[{
disableSerialization;
2015-12-11 00:02:15 +00:00
params ["_filter"];
2016-05-03 00:32:44 +00:00
// Remove "All", so we can push it to the back later
// To keep localization we keep the lbText (displayed name)
2015-12-11 00:02:15 +00:00
private _index = lbSize _filter - 1;
private _nameAll = _filter lbText _index;
_filter lbDelete _index;
// Add additional filter functions to the default filters. These remove backpacks etc.
2015-12-11 13:18:11 +00:00
_filter lbSetData [0, QFUNC(filterWeapons)];
_filter lbSetData [1, QFUNC(filterMagazines)];
_filter lbSetData [2, QFUNC(filterItems)];
// Add our custom filters
2015-12-11 00:02:15 +00:00
{
_x params ["_name", "_fncName"];
_index = _filter lbAdd _name;
_filter lbSetData [_index, _fncName];
} forEach GVAR(customFilters);
2015-12-11 00:02:15 +00:00
// Readd "All" filter to last position and select it
2015-12-11 00:02:15 +00:00
_index = _filter lbAdd _nameAll;
_filter lbSetCurSel _index;
}, _filter] call CBA_fnc_execNextFrame;
2015-12-11 00:02:15 +00:00
// Monitor changes that can happen and force our update
2015-12-11 00:02:15 +00:00
private _dummyControl = _display ctrlCreate ["RscMapControl", -1];
_dummyControl ctrlSetPosition [0, 0, 0, 0];
2015-12-11 00:02:15 +00:00
_dummyControl ctrlCommit 0;
_dummyControl ctrlAddEventHandler ["Draw", {
(ctrlParent (_this select 0)) call FUNC(forceItemListUpdate);
2015-12-11 00:02:15 +00:00
}];