mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Inventory - Improve multiple aspects (#9706)
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
parent
bed8844b74
commit
7f998c3234
@ -1,4 +1,3 @@
|
||||
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
|
||||
@ -20,5 +19,12 @@ class Extended_PostInit_EventHandlers {
|
||||
class Extended_DisplayLoad_EventHandlers {
|
||||
class RscDisplayInventory {
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
@ -27,26 +27,26 @@ class RscCombo;
|
||||
#define W_MAKEITBIGGA(num) (num * (safeZoneH / 40))
|
||||
#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 Y_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QUOTE(QGVAR(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 H_PART(num) QUOTE(linearConversion [ARR_5(0,2,(missionNamespace getVariable [ARR_2(QUOTE(QGVAR(inventoryDisplaySize)),0)]),H_BIS(num),H_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(QQGVAR(inventoryDisplaySize),0)]),Y_BIS(num),Y_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(QQGVAR(inventoryDisplaySize),0)]),H_BIS(num),H_MAKEITBIGGA(num))])
|
||||
|
||||
class RscDisplayInventory {
|
||||
class controls {
|
||||
class CA_ContainerBackground: RscText {
|
||||
//crate: GroundLoad adjust size
|
||||
// Crate: GroundLoad adjust size
|
||||
x = X_PART(1);
|
||||
y = Y_PART(1);
|
||||
w = W_PART(12);
|
||||
h = H_PART(22.5); //default 23
|
||||
h = H_PART(22.5); // default 23
|
||||
};
|
||||
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);
|
||||
y = Y_PART(2);
|
||||
w = W_PART(24.4);
|
||||
h = H_PART(21.5); //default 22
|
||||
h = H_PART(21.5); // default 22
|
||||
};
|
||||
class TitleBackground: RscText {
|
||||
x = X_PART(14.6);
|
||||
@ -98,7 +98,7 @@ class RscDisplayInventory {
|
||||
};
|
||||
class BackgroundSlotPrimaryFlashlight: BackgroundSlotPrimary {
|
||||
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);
|
||||
h = H_PART(2);
|
||||
};
|
||||
@ -283,11 +283,11 @@ class RscDisplayInventory {
|
||||
h = H_PART(1);
|
||||
};
|
||||
class GroundLoad: RscProgress {
|
||||
//crate: GroundLoad adjust size
|
||||
// Crate: GroundLoad adjust size
|
||||
x = X_PART(1.5);
|
||||
y = Y_PART(22.5);
|
||||
w = W_PART(11);
|
||||
h = H_PART(0.5); //Default 1
|
||||
h = H_PART(0.5); // Default 1
|
||||
};
|
||||
class SlotPrimary: GroundTab {
|
||||
x = X_PART(26.6);
|
||||
@ -345,7 +345,7 @@ class RscDisplayInventory {
|
||||
};
|
||||
class SlotSecondaryUnderBarrel: SlotPrimary {
|
||||
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);
|
||||
h = H_PART(2);
|
||||
};
|
||||
@ -518,11 +518,11 @@ class RscDisplayInventory {
|
||||
h = H_PART(0.5);
|
||||
};
|
||||
class TotalLoad: GroundLoad {
|
||||
//center: progressbar height decrease
|
||||
// Center: progressbar height decrease
|
||||
x = X_PART(15.1);
|
||||
y = Y_PART(22.5);
|
||||
w = W_PART(23.4);
|
||||
h = H_PART(0.5); //Default 1
|
||||
h = H_PART(0.5); // default 1
|
||||
};
|
||||
class ContainerMarker: GroundTab {
|
||||
x = X_PART(0);
|
||||
|
@ -1,10 +1,6 @@
|
||||
|
||||
PREP(addCustomFilter);
|
||||
PREP(currentItemListBox);
|
||||
PREP(forceItemListUpdate);
|
||||
PREP(inventoryDisplayLoad);
|
||||
PREP(onLBSelChanged);
|
||||
|
||||
PREP(displayNameWeight);
|
||||
PREP(filterWeapons);
|
||||
PREP(filterMagazines);
|
||||
PREP(filterItems);
|
||||
@ -14,3 +10,6 @@ PREP(filterVests);
|
||||
PREP(filterBackpacks);
|
||||
PREP(filterGrenades);
|
||||
PREP(filterMedical);
|
||||
PREP(forceItemListUpdate);
|
||||
PREP(inventoryDisplayLoad);
|
||||
PREP(onLBSelChanged);
|
||||
|
@ -2,40 +2,39 @@
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
// cache config
|
||||
// items in the inventory display can only be distinguished by their lb names and pictures
|
||||
// this can cause collisions (mainly weapons with attachments),
|
||||
// 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
|
||||
// If medical_treatment is loaded, get its items
|
||||
if (["ace_medical_treatment"] call EFUNC(common,isModLoaded)) then {
|
||||
private _medicalList = +(uiNamespace getVariable [QGVAR(medicalItemList), createHashMap]);
|
||||
|
||||
GVAR(ItemKeyNamespace) = [] call CBA_fnc_createNamespace;
|
||||
private _allItems = uiNamespace getVariable [QGVAR(ItemKeyCache), []]; //See XEH_preStart.sqf
|
||||
_medicalList merge [uiNamespace getVariable [QEGVAR(medical_treatment,treatmentItems), createHashMap], true];
|
||||
|
||||
// isEqualType is hacking protection as we cannot trust that the cache hasn't been manipulated
|
||||
{
|
||||
if (_x isEqualType [] && {_x isEqualTypeArray ["", configNull]}) then {
|
||||
GVAR(ItemKeyNamespace) setVariable _x;
|
||||
};
|
||||
} forEach ([[], _allItems] select (_allItems isEqualType []));
|
||||
GVAR(medicalItemList) = compileFinal _medicalList;
|
||||
} else {
|
||||
GVAR(medicalItemList) = uiNamespace getVariable [QGVAR(medicalItemList), compileFinal createHashMap];
|
||||
};
|
||||
|
||||
GVAR(customFilters) = [];
|
||||
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
|
||||
GVAR(Grenades_ItemList) = uiNamespace getVariable [QGVAR(Grenades_ItemList), []];
|
||||
if (!(GVAR(Grenades_ItemList) isEqualType [])) then {GVAR(Grenades_ItemList) = []};
|
||||
// Used for displaying the correct name when opening a subordinate's inventory
|
||||
GVAR(unit) = ACE_player;
|
||||
|
||||
[localize LSTRING(Grenades), QFUNC(filterGrenades)] call FUNC(addCustomFilter);
|
||||
["CAManBase", "InventoryOpened", {
|
||||
params ["_unit", "_container"];
|
||||
|
||||
[localize LSTRING(Backpacks), QFUNC(filterBackpacks)] call FUNC(addCustomFilter);
|
||||
[localize LSTRING(Uniforms), QFUNC(filterUniforms)] call FUNC(addCustomFilter);
|
||||
[localize LSTRING(Vests), QFUNC(filterVests)] call FUNC(addCustomFilter);
|
||||
[localize LSTRING(Headgear), QFUNC(filterHeadgear)] call FUNC(addCustomFilter);
|
||||
// GVAR(unit) is ACE_player by default
|
||||
if (_unit isEqualTo ACE_player) exitWith {};
|
||||
|
||||
// get list of medical items
|
||||
GVAR(Medical_ItemList) = uiNamespace getVariable [QGVAR(Medical_ItemList), []];
|
||||
if (!(GVAR(Medical_ItemList) isEqualType [])) then {GVAR(Medical_ItemList) = []};
|
||||
|
||||
[localize LSTRING(Medical), QFUNC(filterMedical)] call FUNC(addCustomFilter);
|
||||
// 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
|
||||
if (leader ACE_player == ACE_player && {(_unit in units ACE_player) || {(objectParent _container) isEqualTo ACE_player}}) then {
|
||||
GVAR(unit) = _unit;
|
||||
};
|
||||
}] call CBA_fnc_addClassEventHandler;
|
||||
|
@ -2,18 +2,23 @@
|
||||
|
||||
#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"));
|
||||
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgGlasses"));
|
||||
_allItems append ("getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgMagazines"));
|
||||
_allItems append ("getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'isBackpack') == 1}" configClasses (configFile >> "CfgVehicles"));
|
||||
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgMagazines"));
|
||||
|
||||
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 _picture = getText (_x >> "picture");
|
||||
|
||||
// list box seems to delete the leading backslash
|
||||
if (_picture select [0,1] == "\") then {
|
||||
// List box seems to delete the leading backslash
|
||||
if (_picture select [0, 1] == "\") then {
|
||||
_picture = _picture select [1];
|
||||
};
|
||||
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";
|
||||
};
|
||||
|
||||
[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
|
||||
private _grenades_ItemList = [];
|
||||
// Listboxes store pictures as lowercase
|
||||
[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");
|
||||
} forEach getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");
|
||||
_grenadeList insert [true, (getArray (_cfgThrow >> _x >> "magazines")) apply {_x call EFUNC(common,getConfigName)}, []];
|
||||
} forEach getArray (_cfgThrow >> "muzzles");
|
||||
|
||||
// make list case insensitive
|
||||
_grenades_ItemList = _grenades_ItemList apply {toLower _x};
|
||||
uiNamespace setVariable [QGVAR(grenadesItemList), compileFinal _grenadeList];
|
||||
|
||||
// filter duplicates
|
||||
_grenades_ItemList = _grenades_ItemList arrayIntersect _grenades_ItemList;
|
||||
// Generate list of medical items
|
||||
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
|
||||
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];
|
||||
uiNamespace setVariable [QGVAR(medicalItemList), compileFinal (_medicalList createHashMapFromArray [])];
|
||||
|
@ -12,11 +12,13 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* ["displayname", "filter"] call ACE_inventory_fnc_addCustomFilter
|
||||
* ["displayname", "filter"] call ace_inventory_fnc_addCustomFilter
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params [["_filterName", "ERROR: No Name", [""]], ["_fncName", "", [""]]];
|
||||
params [["_filterName", "", [""]], ["_fncName", "", [""]]];
|
||||
|
||||
if (_filterName == "") exitWith {};
|
||||
|
||||
GVAR(customFilters) pushBack [_filterName, _fncName];
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Currently selected item list box <CONTROL>
|
||||
*
|
||||
* Example:
|
||||
* [DISPLAY] call ACE_inventory_fnc_currentItemListBox
|
||||
* [DISPLAY] call ace_inventory_fnc_currentItemListBox
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -27,7 +27,6 @@ scopeName "main";
|
||||
if (ctrlShown _control) then {
|
||||
_control breakOut "main";
|
||||
};
|
||||
false
|
||||
} count [IDC_ITEMLIST_GROUND, IDC_ITEMLIST_SOLDIER, IDC_ITEMLIST_UNIFORM, IDC_ITEMLIST_VEST, IDC_ITEMLIST_BACKPACK];
|
||||
} forEach [IDC_ITEMLIST_GROUND, IDC_ITEMLIST_SOLDIER, IDC_ITEMLIST_UNIFORM, IDC_ITEMLIST_VEST, IDC_ITEMLIST_BACKPACK];
|
||||
|
||||
controlNull
|
||||
|
@ -10,26 +10,27 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [DISPLAY] call ACE_movement_fnc_inventoryDisplayLoad
|
||||
* [DISPLAY] call ace_inventory_fnc_displayNameWeight
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
private _fnc_update = {
|
||||
params ["_display"];
|
||||
|
||||
private _control = _display displayCtrl 111;
|
||||
private _format = ["%1 - %2 %3 (%4)", "%2 %3 (%4)"] select isStreamFriendlyUIEnabled;
|
||||
|
||||
_control ctrlSetText format [_format,
|
||||
[ACE_player, false, true] call EFUNC(common,getName),
|
||||
localize ELSTRING(common,Weight),
|
||||
[ACE_player] call EFUNC(common,getWeight),
|
||||
[ACE_player, true] call EFUNC(common,getWeight)
|
||||
[GVAR(unit), false, true] call EFUNC(common,getName),
|
||||
LELSTRING(common,Weight),
|
||||
GVAR(unit) call EFUNC(common,getWeight),
|
||||
[GVAR(unit), true] call EFUNC(common,getWeight)
|
||||
];
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterBackpacks
|
||||
* [CONFIG] call ace_inventory_fnc_filterBackpacks
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -10,11 +10,11 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterGrenades
|
||||
* [CONFIG] call ace_inventory_fnc_filterGrenades
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_config"];
|
||||
|
||||
toLower configName _config in GVAR(Grenades_ItemList)
|
||||
(configName _config) in (uiNamespace getVariable QGVAR(grenadesItemList))
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterHeadgear
|
||||
* [CONFIG] call ace_inventory_fnc_filterHeadgear
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -10,11 +10,14 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterItems
|
||||
* [CONFIG] call ace_inventory_fnc_filterItems
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
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])}
|
||||
|
@ -10,9 +10,9 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterMagazines
|
||||
* [CONFIG] call ace_inventory_fnc_filterMagazines
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
!(_this call FUNC(filterBackpacks)) && {!(_this call FUNC(filterGrenades))}
|
||||
!(_this call FUNC(filterGrenades)) && {!(_this call FUNC(filterBackpacks))}
|
||||
|
@ -10,11 +10,11 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterMedical
|
||||
* [CONFIG] call ace_inventory_fnc_filterMedical
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_config"];
|
||||
|
||||
toLower configName _config in GVAR(Medical_ItemList)
|
||||
(configName _config) in GVAR(medicalItemList)
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterUniforms
|
||||
* [CONFIG] call ace_inventory_fnc_filterUniforms
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterVests
|
||||
* [CONFIG] call ace_inventory_fnc_filterVests
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Item should appear in this list? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [CONFIG] call ACE_inventory_fnc_filterWeapons
|
||||
* [CONFIG] call ace_inventory_fnc_filterWeapons
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -10,23 +10,38 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [DISPLAY] call ACE_inventory_fnc_forceitemListUpdate
|
||||
* [DISPLAY] call ace_inventory_fnc_forceItemListUpdate
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
disableSerialization;
|
||||
|
||||
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 _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) - 1 to 0 step -1 do {
|
||||
private _config = GVAR(ItemKeyNamespace) getVariable format ["%1:%2", _itemList lbText _i, _itemList lbPicture _i];
|
||||
for "_i" from (lbSize _itemList) to 0 step -1 do {
|
||||
// All items have their classnames in lbData, except backpacks
|
||||
_className = _itemList lbData _i;
|
||||
|
||||
if (!isNil "_config" && {!(_config call _filterFunction)}) then {
|
||||
_itemList lbDelete _i;
|
||||
};
|
||||
_config = if (_className != "") then {
|
||||
_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;
|
||||
};
|
||||
};
|
||||
|
@ -10,40 +10,42 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [DISPLAY] call ACE_inventory_fnc_inventoryDisplayLoad
|
||||
* [DISPLAY] call ace_inventory_fnc_inventoryDisplayLoad
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
disableSerialization;
|
||||
|
||||
params ["_display"];
|
||||
|
||||
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.
|
||||
// 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 dont like
|
||||
// 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)];
|
||||
|
||||
// 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;
|
||||
|
||||
params ["_filter"];
|
||||
|
||||
// remove "All", so we can push it to the back later.
|
||||
// to keep localization we can keep the lbText (displayed name).
|
||||
// Remove "All", so we can push it to the back later
|
||||
// To keep localization we keep the lbText (displayed name)
|
||||
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.
|
||||
// Add additional filter functions to the default filters. These remove backpacks etc.
|
||||
_filter lbSetData [0, QFUNC(filterWeapons)];
|
||||
_filter lbSetData [1, QFUNC(filterMagazines)];
|
||||
_filter lbSetData [2, QFUNC(filterItems)];
|
||||
|
||||
// add our custom filters
|
||||
// Add our custom filters
|
||||
{
|
||||
_x params ["_name", "_fncName"];
|
||||
|
||||
@ -51,24 +53,17 @@ _filter ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onLBSelChanged)];
|
||||
_filter lbSetData [_index, _fncName];
|
||||
} 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;
|
||||
_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];
|
||||
|
||||
_dummyControl ctrlSetPosition [0,0,0,0];
|
||||
_dummyControl ctrlSetPosition [0, 0, 0, 0];
|
||||
_dummyControl ctrlCommit 0;
|
||||
|
||||
_dummyControl ctrlAddEventHandler ["Draw", {
|
||||
disableSerialization;
|
||||
params ["_dummyControl"];
|
||||
|
||||
private _display = ctrlParent _dummyControl;
|
||||
|
||||
private _itemList = _display call FUNC(currentItemListBox);
|
||||
|
||||
_display call FUNC(forceItemListUpdate);
|
||||
(ctrlParent (_this select 0)) call FUNC(forceItemListUpdate);
|
||||
}];
|
||||
|
@ -12,19 +12,16 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [CONTROL, 5] call ACE_inventory_fnc_onLBSelChanged
|
||||
* [CONTROL, 5] call ace_inventory_fnc_onLBSelChanged
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
disableSerialization;
|
||||
|
||||
params ["_filter", "_index"];
|
||||
|
||||
GVAR(selectedFilterIndex) = _index;
|
||||
|
||||
[{
|
||||
disableSerialization;
|
||||
params ["_display"];
|
||||
|
||||
[_display] call FUNC(forceItemListUpdate);
|
||||
}, [ctrlParent _filter]] call CBA_fnc_execNextFrame;
|
||||
// Force update
|
||||
[LINKFUNC(forceItemListUpdate), ctrlParent _filter] call CBA_fnc_execNextFrame;
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
|
||||
call FUNC(scanMedicalItems)
|
||||
call FUNC(scanMedicalItems);
|
||||
|
@ -15,9 +15,3 @@ class Extended_PostInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_DisplayLoad_EventHandlers {
|
||||
class RscDisplayInventory {
|
||||
ADDON = QUOTE(_this call FUNC(inventoryDisplayLoad));
|
||||
};
|
||||
};
|
||||
|
@ -3,4 +3,3 @@ PREP(canClimb);
|
||||
PREP(climb);
|
||||
PREP(handleClimb);
|
||||
PREP(handleVirtualMass);
|
||||
PREP(inventoryDisplayLoad);
|
||||
|
Loading…
Reference in New Issue
Block a user