Inventory - Fix filtering for items without file extension in picture property (#9696)

* fix rope filtering

* loop

* var declaration begone

* count -> forEach

* Update XEH_preStart.sqf
This commit is contained in:
Grim 2024-01-01 18:35:44 -03:00 committed by GitHub
parent 8ca5263f18
commit 7054d4bb51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 12 deletions

View File

@ -16,6 +16,10 @@ uiNamespace setVariable [QGVAR(ItemKeyCache), _allItems apply {
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 (!fileExists (_picture + ".paa")) exitWith {};
_picture = _picture + ".paa";
};
[format ["%1:%2", _displayName, _picture], _x]; [format ["%1:%2", _displayName, _picture], _x];
}]; }];

View File

@ -23,18 +23,11 @@ private _itemList = _display call FUNC(currentItemListBox);
private _filterFunction = missionNamespace getVariable ((_display displayCtrl IDC_FILTERLISTS) lbData _index); private _filterFunction = missionNamespace getVariable ((_display displayCtrl IDC_FILTERLISTS) lbData _index);
if (_filterFunction isEqualType {}) then { if (_filterFunction isEqualType {}) then {
private _i = 0; for "_i" from (lbSize _itemList) - 1 to 0 step -1 do {
while {_i < lbSize _itemList} do {
private _config = GVAR(ItemKeyNamespace) getVariable format ["%1:%2", _itemList lbText _i, _itemList lbPicture _i]; private _config = GVAR(ItemKeyNamespace) getVariable format ["%1:%2", _itemList lbText _i, _itemList lbPicture _i];
if (!isNil "_config" && {!(_config call _filterFunction)}) then { if (!isNil "_config" && {!(_config call _filterFunction)}) then {
_itemList lbDelete _i; _itemList lbDelete _i;
// in case the filter function returns nil. Otherwise could lock up the game.
_i = _i - 1;
}; };
_i = _i + 1;
}; };
}; };

View File

@ -49,9 +49,7 @@ _filter ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChanged)}];
_index = _filter lbAdd _name; _index = _filter lbAdd _name;
_filter lbSetData [_index, _fncName]; _filter lbSetData [_index, _fncName];
} forEach GVAR(customFilters);
false
} count 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;

View File

@ -3,7 +3,7 @@ class CfgWeapons {
class ACE_ItemCore; class ACE_ItemCore;
class ACE_ropeBase: ACE_ItemCore { class ACE_ropeBase: ACE_ItemCore {
scope = 1; scope = 1;
picture = QPATHTOF(data\m_rope_ca); picture = QPATHTOF(data\m_rope_ca.paa);
// model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d"; // model is Locked to Helicopter DLC // model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d"; // model is Locked to Helicopter DLC
descriptionShort = CSTRING(descriptionShort); descriptionShort = CSTRING(descriptionShort);
}; };