2023-09-12 18:58:10 +00:00
|
|
|
#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
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2024-01-06 21:26:46 +00:00
|
|
|
* [DISPLAY] call ace_inventory_fnc_inventoryDisplayLoad
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2015-12-11 12:14:58 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
2015-12-11 00:02:15 +00:00
|
|
|
|
|
|
|
disableSerialization;
|
2024-01-06 21:26:46 +00:00
|
|
|
|
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
|
|
|
|
2024-01-06 21:26:46 +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.
|
2024-01-06 21:26:46 +00:00
|
|
|
// 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
|
2024-01-01 21:36:45 +00:00
|
|
|
_filter ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onLBSelChanged)];
|
2015-12-11 00:02:15 +00:00
|
|
|
|
2024-01-06 21:26:46 +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;
|
2024-01-06 21:26:46 +00:00
|
|
|
|
2015-12-11 00:02:15 +00:00
|
|
|
params ["_filter"];
|
2016-05-03 00:32:44 +00:00
|
|
|
|
2024-01-06 21:26:46 +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;
|
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// 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)];
|
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// Add our custom filters
|
2015-12-11 00:02:15 +00:00
|
|
|
{
|
|
|
|
_x params ["_name", "_fncName"];
|
|
|
|
|
|
|
|
_index = _filter lbAdd _name;
|
|
|
|
_filter lbSetData [_index, _fncName];
|
2024-01-01 21:35:44 +00:00
|
|
|
} forEach GVAR(customFilters);
|
2015-12-11 00:02:15 +00:00
|
|
|
|
2024-01-06 21:26:46 +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;
|
2024-01-06 21:26:46 +00:00
|
|
|
}, _filter] call CBA_fnc_execNextFrame;
|
2015-12-11 00:02:15 +00:00
|
|
|
|
2024-01-06 21:26:46 +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];
|
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
_dummyControl ctrlSetPosition [0, 0, 0, 0];
|
2015-12-11 00:02:15 +00:00
|
|
|
_dummyControl ctrlCommit 0;
|
|
|
|
|
|
|
|
_dummyControl ctrlAddEventHandler ["Draw", {
|
2024-01-06 21:26:46 +00:00
|
|
|
(ctrlParent (_this select 0)) call FUNC(forceItemListUpdate);
|
2015-12-11 00:02:15 +00:00
|
|
|
}];
|