From f841efbdaa9e3c44f60db8550174b38faa7036ca Mon Sep 17 00:00:00 2001 From: MildlyInterested Date: Tue, 28 Mar 2023 19:42:36 +0200 Subject: [PATCH 1/2] - magazines and attachments are filtered - two new lists in config to define them - blacklisted magazines and attachments are not available with generatedLists on or off - auto select first entry in weapons sublist to avoid UI inconsistencies --- KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf | 23 ++++++++++++++++++-- KP-Cratefiller/KPCF_config.sqf | 15 ++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf b/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf index c5cc96b..3ac3039 100644 --- a/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf +++ b/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf @@ -2,6 +2,8 @@ Killah Potatoes Cratefiller v1.1.0 Author: Dubjunk - https://github.com/KillahPotatoes + Edited by Mildly_Interested - https://github.com/MildlyInterested + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -46,7 +48,14 @@ switch (_catIndex) do { private _glType = (getArray (configfile >> "CfgWeapons" >> _weaponType >> "muzzles")) select 1; private _magazines = [_weaponType] call CBA_fnc_compatibleMagazines; _magazines append ([configfile >> "CfgWeapons" >> _weaponType >> _glType] call CBA_fnc_compatibleMagazines); - private _sortedMagazines = [_magazines] call KPCF_fnc_sortList; + private "_filteredMagazines"; + if (!KPCF_generateLists) then { + _filteredMagazines = _magazines arrayIntersect KPCF_magazines; + } + else { + _filteredMagazines = _magazines; + }; + private _sortedMagazines = [_filteredMagazines] call KPCF_fnc_sortList; private _index = 0; @@ -63,7 +72,14 @@ switch (_catIndex) do { case 2 : { // Get compatible attachments private _attachments = [_weaponType] call BIS_fnc_compatibleItems; - private _sortedAttachments = [_attachments] call KPCF_fnc_sortList; + private "_filteredAttachments"; + if (!KPCF_generateLists) then { + _filteredAttachments = _attachments arrayIntersect KPCF_attachments; + } + else { + _filteredAttachments = _attachments; + }; + private _sortedAttachments = [_filteredAttachments] call KPCF_fnc_sortList; private _index = 0; @@ -76,3 +92,6 @@ switch (_catIndex) do { } forEach _sortedAttachments; }; }; + +// Select first entry +_ctrlEquipment lbSetCurSel 0; diff --git a/KP-Cratefiller/KPCF_config.sqf b/KP-Cratefiller/KPCF_config.sqf index 49e87b6..22a78a6 100644 --- a/KP-Cratefiller/KPCF_config.sqf +++ b/KP-Cratefiller/KPCF_config.sqf @@ -20,6 +20,7 @@ KPCF_cratefillerSpawn = "Land_HelipadCivil_F"; KPCF_canSpawnAndDelete = true; // If set to "true" the item lists will be generated from the config +// If set to "false" only items defined in KPCF_weapons and the folliwng lists will be available KPCF_generateLists = true; // These variable defines the range where inventories can be edited @@ -51,7 +52,7 @@ KPCF_whitelistedItems = [ "" ]; -// ----- These Variables will be replaced with activated generatedLists ----- +// ----- The following Variables will be replaced with activated generatedLists ----- // Defines the available weapons KPCF_weapons = [ @@ -59,6 +60,18 @@ KPCF_weapons = [ "MMG_01_tan_F" ]; +// Defines the available magazines +KPCF_magazines = [ + "Placeholder", + "Placeholder" +]; + +// Defines the available attachments +KPCF_attachments = [ + "Placeholder", + "Placeholder" +]; + // Defines the available grenades KPCF_grenades = [ "HandGrenade", From 24862b64f90d42871ff74e4dfb5ccfa9ac7b9b89 Mon Sep 17 00:00:00 2001 From: MildlyInterested Date: Thu, 30 Mar 2023 12:17:07 +0200 Subject: [PATCH 2/2] filter blacklisted magazines and attachments --- KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf b/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf index 3ac3039..0d18697 100644 --- a/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf +++ b/KP-Cratefiller/KPCF/fnc/fn_createSubList.sqf @@ -48,6 +48,7 @@ switch (_catIndex) do { private _glType = (getArray (configfile >> "CfgWeapons" >> _weaponType >> "muzzles")) select 1; private _magazines = [_weaponType] call CBA_fnc_compatibleMagazines; _magazines append ([configfile >> "CfgWeapons" >> _weaponType >> _glType] call CBA_fnc_compatibleMagazines); + _magazines = _magazines - KPCF_blacklistedItems; private "_filteredMagazines"; if (!KPCF_generateLists) then { _filteredMagazines = _magazines arrayIntersect KPCF_magazines; @@ -72,6 +73,7 @@ switch (_catIndex) do { case 2 : { // Get compatible attachments private _attachments = [_weaponType] call BIS_fnc_compatibleItems; + _attachments = _attachments - KPCF_blacklistedItems; private "_filteredAttachments"; if (!KPCF_generateLists) then { _filteredAttachments = _attachments arrayIntersect KPCF_attachments;