Inventory - Improve multiple aspects (#9706)

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
johnb432 2024-01-06 22:26:46 +01:00 committed by GitHub
parent bed8844b74
commit 7f998c3234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 155 additions and 149 deletions

View File

@ -1,4 +1,3 @@
class Extended_PreStart_EventHandlers { class Extended_PreStart_EventHandlers {
class ADDON { class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
@ -20,5 +19,12 @@ class Extended_PostInit_EventHandlers {
class Extended_DisplayLoad_EventHandlers { class Extended_DisplayLoad_EventHandlers {
class RscDisplayInventory { class RscDisplayInventory {
ADDON = QUOTE(_this call FUNC(inventoryDisplayLoad)); ADDON = QUOTE(_this call FUNC(inventoryDisplayLoad));
GVAR(displayNameWeight) = QUOTE(_this call FUNC(displayNameWeight)); // separate to allow other mods to disable them individually
};
};
class Extended_DisplayUnload_EventHandlers {
class RscDisplayInventory {
ADDON = QUOTE(GVAR(unit) = ACE_player);
}; };
}; };

View File

@ -27,26 +27,26 @@ class RscCombo;
#define W_MAKEITBIGGA(num) (num * (safeZoneH / 40)) #define W_MAKEITBIGGA(num) (num * (safeZoneH / 40))
#define H_MAKEITBIGGA(num) (num * (safeZoneH / 30)) #define H_MAKEITBIGGA(num) (num * (safeZoneH / 30))
#define X_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QUOTE(QGVAR(inventoryDisplaySize)),0)]),X_BIS(num),X_MAKEITBIGGA(num))]) #define X_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QQGVAR(inventoryDisplaySize),0)]),X_BIS(num),X_MAKEITBIGGA(num))])
#define Y_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QUOTE(QGVAR(inventoryDisplaySize)),0)]),Y_BIS(num),Y_MAKEITBIGGA(num))]) #define Y_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QQGVAR(inventoryDisplaySize),0)]),Y_BIS(num),Y_MAKEITBIGGA(num))])
#define W_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QUOTE(QGVAR(inventoryDisplaySize)),0)]),W_BIS(num),W_MAKEITBIGGA(num))]) #define W_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QQGVAR(inventoryDisplaySize),0)]),W_BIS(num),W_MAKEITBIGGA(num))])
#define H_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QUOTE(QGVAR(inventoryDisplaySize)),0)]),H_BIS(num),H_MAKEITBIGGA(num))]) #define H_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QQGVAR(inventoryDisplaySize),0)]),H_BIS(num),H_MAKEITBIGGA(num))])
class RscDisplayInventory { class RscDisplayInventory {
class controls { class controls {
class CA_ContainerBackground: RscText { class CA_ContainerBackground: RscText {
//crate: GroundLoad adjust size // Crate: GroundLoad adjust size
x = X_PART(1); x = X_PART(1);
y = Y_PART(1); y = Y_PART(1);
w = W_PART(12); w = W_PART(12);
h = H_PART(22.5); //default 23 h = H_PART(22.5); // default 23
}; };
class CA_PlayerBackground: RscText { class CA_PlayerBackground: RscText {
//center player's container: decrease height because of progressbar height decrease // Center player's container: Decrease height because of progressbar height decrease
x = X_PART(14.6); x = X_PART(14.6);
y = Y_PART(2); y = Y_PART(2);
w = W_PART(24.4); w = W_PART(24.4);
h = H_PART(21.5); //default 22 h = H_PART(21.5); // default 22
}; };
class TitleBackground: RscText { class TitleBackground: RscText {
x = X_PART(14.6); x = X_PART(14.6);
@ -98,7 +98,7 @@ class RscDisplayInventory {
}; };
class BackgroundSlotPrimaryFlashlight: BackgroundSlotPrimary { class BackgroundSlotPrimaryFlashlight: BackgroundSlotPrimary {
x = X_PART(30.6); x = X_PART(30.6);
y = Y_PART(9.2); //not sure why different (double check release) y = Y_PART(9.2); // not sure why different (double check release)
w = W_PART(1.9); w = W_PART(1.9);
h = H_PART(2); h = H_PART(2);
}; };
@ -283,11 +283,11 @@ class RscDisplayInventory {
h = H_PART(1); h = H_PART(1);
}; };
class GroundLoad: RscProgress { class GroundLoad: RscProgress {
//crate: GroundLoad adjust size // Crate: GroundLoad adjust size
x = X_PART(1.5); x = X_PART(1.5);
y = Y_PART(22.5); y = Y_PART(22.5);
w = W_PART(11); w = W_PART(11);
h = H_PART(0.5); //Default 1 h = H_PART(0.5); // Default 1
}; };
class SlotPrimary: GroundTab { class SlotPrimary: GroundTab {
x = X_PART(26.6); x = X_PART(26.6);
@ -345,7 +345,7 @@ class RscDisplayInventory {
}; };
class SlotSecondaryUnderBarrel: SlotPrimary { class SlotSecondaryUnderBarrel: SlotPrimary {
x = X_PART(29); x = X_PART(29);
y = Y_PART(14.59); //Why is this different? (check release) y = Y_PART(14.59); // Why is this different? (check release)
w = W_PART(2.3); w = W_PART(2.3);
h = H_PART(2); h = H_PART(2);
}; };
@ -518,11 +518,11 @@ class RscDisplayInventory {
h = H_PART(0.5); h = H_PART(0.5);
}; };
class TotalLoad: GroundLoad { class TotalLoad: GroundLoad {
//center: progressbar height decrease // Center: progressbar height decrease
x = X_PART(15.1); x = X_PART(15.1);
y = Y_PART(22.5); y = Y_PART(22.5);
w = W_PART(23.4); w = W_PART(23.4);
h = H_PART(0.5); //Default 1 h = H_PART(0.5); // default 1
}; };
class ContainerMarker: GroundTab { class ContainerMarker: GroundTab {
x = X_PART(0); x = X_PART(0);

View File

@ -1,10 +1,6 @@
PREP(addCustomFilter); PREP(addCustomFilter);
PREP(currentItemListBox); PREP(currentItemListBox);
PREP(forceItemListUpdate); PREP(displayNameWeight);
PREP(inventoryDisplayLoad);
PREP(onLBSelChanged);
PREP(filterWeapons); PREP(filterWeapons);
PREP(filterMagazines); PREP(filterMagazines);
PREP(filterItems); PREP(filterItems);
@ -14,3 +10,6 @@ PREP(filterVests);
PREP(filterBackpacks); PREP(filterBackpacks);
PREP(filterGrenades); PREP(filterGrenades);
PREP(filterMedical); PREP(filterMedical);
PREP(forceItemListUpdate);
PREP(inventoryDisplayLoad);
PREP(onLBSelChanged);

View File

@ -2,40 +2,39 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
// cache config // If medical_treatment is loaded, get its items
// items in the inventory display can only be distinguished by their lb names and pictures if (["ace_medical_treatment"] call EFUNC(common,isModLoaded)) then {
// this can cause collisions (mainly weapons with attachments), private _medicalList = +(uiNamespace getVariable [QGVAR(medicalItemList), createHashMap]);
// but if the item has the same name and picture it at least shouldn't change the filter anyway
// luckily we don't need private items, so dummy and parent classes are out of the picture
GVAR(ItemKeyNamespace) = [] call CBA_fnc_createNamespace; _medicalList merge [uiNamespace getVariable [QEGVAR(medical_treatment,treatmentItems), createHashMap], true];
private _allItems = uiNamespace getVariable [QGVAR(ItemKeyCache), []]; //See XEH_preStart.sqf
// isEqualType is hacking protection as we cannot trust that the cache hasn't been manipulated GVAR(medicalItemList) = compileFinal _medicalList;
{ } else {
if (_x isEqualType [] && {_x isEqualTypeArray ["", configNull]}) then { GVAR(medicalItemList) = uiNamespace getVariable [QGVAR(medicalItemList), compileFinal createHashMap];
GVAR(ItemKeyNamespace) setVariable _x; };
};
} forEach ([[], _allItems] select (_allItems isEqualType []));
GVAR(customFilters) = []; GVAR(customFilters) = [];
GVAR(selectedFilterIndex) = -1; GVAR(selectedFilterIndex) = -1;
// add custom filters // Add custom filters
[LLSTRING(Grenades), QFUNC(filterGrenades)] call FUNC(addCustomFilter);
[LLSTRING(Backpacks), QFUNC(filterBackpacks)] call FUNC(addCustomFilter);
[LLSTRING(Uniforms), QFUNC(filterUniforms)] call FUNC(addCustomFilter);
[LLSTRING(Vests), QFUNC(filterVests)] call FUNC(addCustomFilter);
[LLSTRING(Headgear), QFUNC(filterHeadgear)] call FUNC(addCustomFilter);
[LLSTRING(Medical), QFUNC(filterMedical)] call FUNC(addCustomFilter);
// get list of grenades // Used for displaying the correct name when opening a subordinate's inventory
GVAR(Grenades_ItemList) = uiNamespace getVariable [QGVAR(Grenades_ItemList), []]; GVAR(unit) = ACE_player;
if (!(GVAR(Grenades_ItemList) isEqualType [])) then {GVAR(Grenades_ItemList) = []};
[localize LSTRING(Grenades), QFUNC(filterGrenades)] call FUNC(addCustomFilter); ["CAManBase", "InventoryOpened", {
params ["_unit", "_container"];
[localize LSTRING(Backpacks), QFUNC(filterBackpacks)] call FUNC(addCustomFilter); // GVAR(unit) is ACE_player by default
[localize LSTRING(Uniforms), QFUNC(filterUniforms)] call FUNC(addCustomFilter); if (_unit isEqualTo ACE_player) exitWith {};
[localize LSTRING(Vests), QFUNC(filterVests)] call FUNC(addCustomFilter);
[localize LSTRING(Headgear), QFUNC(filterHeadgear)] call FUNC(addCustomFilter);
// get list of medical items // If the player is a group leader and opens a subordinate's inventory or has a subordinate open the player's backpack, update name to correct unit
GVAR(Medical_ItemList) = uiNamespace getVariable [QGVAR(Medical_ItemList), []]; if (leader ACE_player == ACE_player && {(_unit in units ACE_player) || {(objectParent _container) isEqualTo ACE_player}}) then {
if (!(GVAR(Medical_ItemList) isEqualType [])) then {GVAR(Medical_ItemList) = []}; GVAR(unit) = _unit;
};
[localize LSTRING(Medical), QFUNC(filterMedical)] call FUNC(addCustomFilter); }] call CBA_fnc_addClassEventHandler;

View File

@ -2,18 +2,23 @@
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
//item cache, see XEH_postInit.sqf // Cache config
// Items in the inventory display can all use lb data to get their classname (exception: backpacks, handled separately)
private _allItems = ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgWeapons")); private _allItems = ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgWeapons"));
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgGlasses")); _allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgGlasses"));
_allItems append ("getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgMagazines")); _allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgMagazines"));
_allItems append ("getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'isBackpack') == 1}" configClasses (configFile >> "CfgVehicles"));
uiNamespace setVariable [QGVAR(ItemKeyCache), _allItems apply { uiNamespace setVariable [QGVAR(itemKeyCache), compileFinal ((_allItems apply {configName _x}) createHashMapFromArray _allItems)];
// Backpacks in the inventory display can only be distinguished by their lb names and pictures, lb data returns ""
_allItems = "getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'isBackpack') == 1}" configClasses (configFile >> "CfgVehicles");
uiNamespace setVariable [QGVAR(backpackKeyCache), compileFinal createHashMapFromArray (_allItems apply {
private _displayName = getText (_x >> "displayName"); private _displayName = getText (_x >> "displayName");
private _picture = getText (_x >> "picture"); private _picture = getText (_x >> "picture");
// list box seems to delete the leading backslash // List box seems to delete the leading backslash
if (_picture select [0,1] == "\") then { if (_picture select [0, 1] == "\") then {
_picture = _picture select [1]; _picture = _picture select [1];
}; };
if (count _picture > 0 && !(_picture regexMatch ".*?\.paa")) then { // handle missing file extension if (count _picture > 0 && !(_picture regexMatch ".*?\.paa")) then { // handle missing file extension
@ -21,37 +26,29 @@ uiNamespace setVariable [QGVAR(ItemKeyCache), _allItems apply {
_picture = _picture + ".paa"; _picture = _picture + ".paa";
}; };
[format ["%1:%2", _displayName, _picture], _x]; // Handle missing file extension, as inventory returns path with extension
}]; if (count _picture > 0 && !(_picture regexMatch ".*?\.paa")) then {
if (!fileExists (_picture + ".paa")) exitWith {};
_picture = _picture + ".paa";
};
// generate list of grenades // Listboxes store pictures as lowercase
private _grenades_ItemList = []; [format ["%1:%2", _displayName, toLower _picture], _x]
})];
// Generate list of grenades
private _cfgThrow = configFile >> "CfgWeapons" >> "Throw";
private _grenadeList = createHashMap;
{ {
_grenades_ItemList append getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"); _grenadeList insert [true, (getArray (_cfgThrow >> _x >> "magazines")) apply {_x call EFUNC(common,getConfigName)}, []];
} forEach getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles"); } forEach getArray (_cfgThrow >> "muzzles");
// make list case insensitive uiNamespace setVariable [QGVAR(grenadesItemList), compileFinal _grenadeList];
_grenades_ItemList = _grenades_ItemList apply {toLower _x};
// filter duplicates // Generate list of medical items
_grenades_ItemList = _grenades_ItemList arrayIntersect _grenades_ItemList; private _medicalList = QUOTE(getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'ItemInfo' >> 'type') in [ARR_2(TYPE_FIRST_AID_KIT,TYPE_MEDIKIT)]}) configClasses (configFile >> "CfgWeapons");
uiNamespace setVariable [QGVAR(Grenades_ItemList), _grenades_ItemList]; _medicalList = _medicalList apply {configName _x};
// generate list of medical items uiNamespace setVariable [QGVAR(medicalItemList), compileFinal (_medicalList createHashMapFromArray [])];
private _medical_ItemList = ["FirstAidKit", "Medikit"];
{
_medical_ItemList append getArray (_x >> "items");
} forEach ("true" configClasses (configFile >> QEGVAR(medical_treatment,Actions)));
// remove all numbers from list
_medical_ItemList = _medical_ItemList select {_x isEqualType ""};
// make list case insensitive
_medical_ItemList = _medical_ItemList apply {toLower _x};
// filter duplicates
_medical_ItemList = _medical_ItemList arrayIntersect _medical_ItemList;
uiNamespace setVariable [QGVAR(Medical_ItemList), _medical_ItemList];

View File

@ -12,11 +12,13 @@
* None * None
* *
* Example: * Example:
* ["displayname", "filter"] call ACE_inventory_fnc_addCustomFilter * ["displayname", "filter"] call ace_inventory_fnc_addCustomFilter
* *
* Public: No * Public: No
*/ */
params [["_filterName", "ERROR: No Name", [""]], ["_fncName", "", [""]]]; params [["_filterName", "", [""]], ["_fncName", "", [""]]];
if (_filterName == "") exitWith {};
GVAR(customFilters) pushBack [_filterName, _fncName]; GVAR(customFilters) pushBack [_filterName, _fncName];

View File

@ -12,7 +12,7 @@
* Currently selected item list box <CONTROL> * Currently selected item list box <CONTROL>
* *
* Example: * Example:
* [DISPLAY] call ACE_inventory_fnc_currentItemListBox * [DISPLAY] call ace_inventory_fnc_currentItemListBox
* *
* Public: No * Public: No
*/ */
@ -27,7 +27,6 @@ scopeName "main";
if (ctrlShown _control) then { if (ctrlShown _control) then {
_control breakOut "main"; _control breakOut "main";
}; };
false } forEach [IDC_ITEMLIST_GROUND, IDC_ITEMLIST_SOLDIER, IDC_ITEMLIST_UNIFORM, IDC_ITEMLIST_VEST, IDC_ITEMLIST_BACKPACK];
} count [IDC_ITEMLIST_GROUND, IDC_ITEMLIST_SOLDIER, IDC_ITEMLIST_UNIFORM, IDC_ITEMLIST_VEST, IDC_ITEMLIST_BACKPACK];
controlNull controlNull

View File

@ -10,26 +10,27 @@
* None * None
* *
* Example: * Example:
* [DISPLAY] call ACE_movement_fnc_inventoryDisplayLoad * [DISPLAY] call ace_inventory_fnc_displayNameWeight
* *
* Public: No * Public: No
*/ */
params ["_display"]; params ["_display"];
// forces player name control to display irrespective of isStreamFriendlyUIEnabled // Forces player name control to display irrespective of isStreamFriendlyUIEnabled
(_display displayCtrl 111) ctrlShow true; (_display displayCtrl 111) ctrlShow true;
private _fnc_update = { private _fnc_update = {
params ["_display"]; params ["_display"];
private _control = _display displayCtrl 111; private _control = _display displayCtrl 111;
private _format = ["%1 - %2 %3 (%4)", "%2 %3 (%4)"] select isStreamFriendlyUIEnabled; private _format = ["%1 - %2 %3 (%4)", "%2 %3 (%4)"] select isStreamFriendlyUIEnabled;
_control ctrlSetText format [_format, _control ctrlSetText format [_format,
[ACE_player, false, true] call EFUNC(common,getName), [GVAR(unit), false, true] call EFUNC(common,getName),
localize ELSTRING(common,Weight), LELSTRING(common,Weight),
[ACE_player] call EFUNC(common,getWeight), GVAR(unit) call EFUNC(common,getWeight),
[ACE_player, true] call EFUNC(common,getWeight) [GVAR(unit), true] call EFUNC(common,getWeight)
]; ];
}; };

View File

@ -10,7 +10,7 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterBackpacks * [CONFIG] call ace_inventory_fnc_filterBackpacks
* *
* Public: No * Public: No
*/ */

View File

@ -10,11 +10,11 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterGrenades * [CONFIG] call ace_inventory_fnc_filterGrenades
* *
* Public: No * Public: No
*/ */
params ["_config"]; params ["_config"];
toLower configName _config in GVAR(Grenades_ItemList) (configName _config) in (uiNamespace getVariable QGVAR(grenadesItemList))

View File

@ -10,7 +10,7 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterHeadgear * [CONFIG] call ace_inventory_fnc_filterHeadgear
* *
* Public: No * Public: No
*/ */

View File

@ -10,11 +10,14 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterItems * [CONFIG] call ace_inventory_fnc_filterItems
* *
* Public: No * Public: No
*/ */
params ["_config"]; params ["_config"];
!(getNumber (_config >> "ItemInfo" >> "type") in [TYPE_UNIFORM, TYPE_VESTS, TYPE_HEADGEAR]) && {!(_this call FUNC(filterBackpacks))} !(_this call FUNC(filterMedical)) &&
{!(_this call FUNC(filterBackpacks))} &&
{!(_this call FUNC(filterHeadgear))} &&
{!(getNumber (_config >> "ItemInfo" >> "type") in [TYPE_UNIFORM, TYPE_VEST])}

View File

@ -10,9 +10,9 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterMagazines * [CONFIG] call ace_inventory_fnc_filterMagazines
* *
* Public: No * Public: No
*/ */
!(_this call FUNC(filterBackpacks)) && {!(_this call FUNC(filterGrenades))} !(_this call FUNC(filterGrenades)) && {!(_this call FUNC(filterBackpacks))}

View File

@ -10,11 +10,11 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterMedical * [CONFIG] call ace_inventory_fnc_filterMedical
* *
* Public: No * Public: No
*/ */
params ["_config"]; params ["_config"];
toLower configName _config in GVAR(Medical_ItemList) (configName _config) in GVAR(medicalItemList)

View File

@ -10,7 +10,7 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterUniforms * [CONFIG] call ace_inventory_fnc_filterUniforms
* *
* Public: No * Public: No
*/ */

View File

@ -10,7 +10,7 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterVests * [CONFIG] call ace_inventory_fnc_filterVests
* *
* Public: No * Public: No
*/ */

View File

@ -10,7 +10,7 @@
* Item should appear in this list? <BOOL> * Item should appear in this list? <BOOL>
* *
* Example: * Example:
* [CONFIG] call ACE_inventory_fnc_filterWeapons * [CONFIG] call ace_inventory_fnc_filterWeapons
* *
* Public: No * Public: No
*/ */

View File

@ -10,23 +10,38 @@
* None * None
* *
* Example: * Example:
* [DISPLAY] call ACE_inventory_fnc_forceitemListUpdate * [DISPLAY] call ace_inventory_fnc_forceItemListUpdate
* *
* Public: No * Public: No
*/ */
disableSerialization; disableSerialization;
params ["_display"]; params ["_display"];
// Get the appropriate filter
private _filterFunction = missionNamespace getVariable [(_display displayCtrl IDC_FILTERLISTS) lbData GVAR(selectedFilterIndex), ""];
if !(_filterFunction isEqualType {}) exitWith {};
private _itemList = _display call FUNC(currentItemListBox); private _itemList = _display call FUNC(currentItemListBox);
private _filterFunction = missionNamespace getVariable ((_display displayCtrl IDC_FILTERLISTS) lbData GVAR(selectedFilterIndex)); private _itemKeyCache = uiNamespace getVariable QGVAR(itemKeyCache);
private _backpackKeyCache = uiNamespace getVariable QGVAR(backpackKeyCache);
private _config = configNull;
if (_filterFunction isEqualType {}) then { for "_i" from (lbSize _itemList) to 0 step -1 do {
for "_i" from (lbSize _itemList) - 1 to 0 step -1 do { // All items have their classnames in lbData, except backpacks
private _config = GVAR(ItemKeyNamespace) getVariable format ["%1:%2", _itemList lbText _i, _itemList lbPicture _i]; _className = _itemList lbData _i;
if (!isNil "_config" && {!(_config call _filterFunction)}) then { _config = if (_className != "") then {
_itemList lbDelete _i; _itemKeyCache get _className
}; } else {
// Backpack are gotten with their display name and inventory icon
_backpackKeyCache get format ["%1:%2", _itemList lbText _i, _itemList lbPicture _i]
};
// If item is valid and doesn't match the current filter, remove it
if (!isNil "_config" && {!(_config call _filterFunction)}) then {
_itemList lbDelete _i;
}; };
}; };

View File

@ -10,40 +10,42 @@
* None * None
* *
* Example: * Example:
* [DISPLAY] call ACE_inventory_fnc_inventoryDisplayLoad * [DISPLAY] call ace_inventory_fnc_inventoryDisplayLoad
* *
* Public: No * Public: No
*/ */
disableSerialization; disableSerialization;
params ["_display"]; params ["_display"];
private _filter = _display displayCtrl IDC_FILTERLISTS; private _filter = _display displayCtrl IDC_FILTERLISTS;
// engine defined behaviour is the following: // Engine defined behaviour is the following:
// lb value, data and text don't matter, only the index. // lb value, data and text don't matter, only the index.
// the first three indecies are hard coded: 0 - weapons , 1 - magazines, 2 - items // The first three indecies are hard coded: 0 - weapons , 1 - magazines, 2 - items
// all of them show backpacks, because BI // All of them show backpacks, because BI
// all other indecies show everything, so all we have to do is delete stuff we dont like // All other indecies show everything, so all we have to do is delete stuff we don't like
_filter ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onLBSelChanged)]; _filter ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onLBSelChanged)];
// have to add these a frame later, because this event happens before the engine adds the default filters // Have to add these a frame later, because this event happens before the engine adds the default filters
[{ [{
disableSerialization; disableSerialization;
params ["_filter"]; params ["_filter"];
// remove "All", so we can push it to the back later. // Remove "All", so we can push it to the back later
// to keep localization we can keep the lbText (displayed name). // To keep localization we keep the lbText (displayed name)
private _index = lbSize _filter - 1; private _index = lbSize _filter - 1;
private _nameAll = _filter lbText _index; private _nameAll = _filter lbText _index;
_filter lbDelete _index; _filter lbDelete _index;
// add additional filter functions to the default filters. These remove backpacks etc. // Add additional filter functions to the default filters. These remove backpacks etc.
_filter lbSetData [0, QFUNC(filterWeapons)]; _filter lbSetData [0, QFUNC(filterWeapons)];
_filter lbSetData [1, QFUNC(filterMagazines)]; _filter lbSetData [1, QFUNC(filterMagazines)];
_filter lbSetData [2, QFUNC(filterItems)]; _filter lbSetData [2, QFUNC(filterItems)];
// add our custom filters // Add our custom filters
{ {
_x params ["_name", "_fncName"]; _x params ["_name", "_fncName"];
@ -51,24 +53,17 @@ _filter ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onLBSelChanged)];
_filter lbSetData [_index, _fncName]; _filter lbSetData [_index, _fncName];
} forEach GVAR(customFilters); } forEach GVAR(customFilters);
// readd "All" filter to last position and select it // Readd "All" filter to last position and select it
_index = _filter lbAdd _nameAll; _index = _filter lbAdd _nameAll;
_filter lbSetCurSel _index; _filter lbSetCurSel _index;
}, [_filter]] call CBA_fnc_execNextFrame; }, _filter] call CBA_fnc_execNextFrame;
// monitor changes that can happen and force our update // Monitor changes that can happen and force our update
private _dummyControl = _display ctrlCreate ["RscMapControl", -1]; private _dummyControl = _display ctrlCreate ["RscMapControl", -1];
_dummyControl ctrlSetPosition [0,0,0,0]; _dummyControl ctrlSetPosition [0, 0, 0, 0];
_dummyControl ctrlCommit 0; _dummyControl ctrlCommit 0;
_dummyControl ctrlAddEventHandler ["Draw", { _dummyControl ctrlAddEventHandler ["Draw", {
disableSerialization; (ctrlParent (_this select 0)) call FUNC(forceItemListUpdate);
params ["_dummyControl"];
private _display = ctrlParent _dummyControl;
private _itemList = _display call FUNC(currentItemListBox);
_display call FUNC(forceItemListUpdate);
}]; }];

View File

@ -12,19 +12,16 @@
* None * None
* *
* Example: * Example:
* [CONTROL, 5] call ACE_inventory_fnc_onLBSelChanged * [CONTROL, 5] call ace_inventory_fnc_onLBSelChanged
* *
* Public: No * Public: No
*/ */
disableSerialization; disableSerialization;
params ["_filter", "_index"]; params ["_filter", "_index"];
GVAR(selectedFilterIndex) = _index; GVAR(selectedFilterIndex) = _index;
[{ // Force update
disableSerialization; [LINKFUNC(forceItemListUpdate), ctrlParent _filter] call CBA_fnc_execNextFrame;
params ["_display"];
[_display] call FUNC(forceItemListUpdate);
}, [ctrlParent _filter]] call CBA_fnc_execNextFrame;

View File

@ -2,4 +2,4 @@
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
call FUNC(scanMedicalItems) call FUNC(scanMedicalItems);

View File

@ -15,9 +15,3 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
}; };
}; };
class Extended_DisplayLoad_EventHandlers {
class RscDisplayInventory {
ADDON = QUOTE(_this call FUNC(inventoryDisplayLoad));
};
};

View File

@ -3,4 +3,3 @@ PREP(canClimb);
PREP(climb); PREP(climb);
PREP(handleClimb); PREP(handleClimb);
PREP(handleVirtualMass); PREP(handleVirtualMass);
PREP(inventoryDisplayLoad);