Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item Rename Framework #1329

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions addons/ui/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CfgFunctions {
PATHTO_FNC(notify);
PATHTO_FNC(openLobbyManager);
PATHTO_FNC(progressBar);
PATHTO_FNC(renameInventoryItem);
};

class ItemContextMenu {
Expand Down
1 change: 1 addition & 0 deletions addons/ui/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (hasInterface) then {
}];

PREP(openItemContextMenu);
PREP(getInventoryItemData);
};

// legacy function names
Expand Down
2 changes: 2 additions & 0 deletions addons/ui/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ PREP(preload3DEN);
PREP(preloadCurator);

PREP(openItemContextMenu);

PREP(getInventoryItemData);
58 changes: 58 additions & 0 deletions addons/ui/fnc_getInventoryItemData.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Internal Function: cba_ui_fnc_getInventoryItemData

Description:
Returns item data from inventory display control

Parameters:
_control - RscDisplayInventory control <CONTROL>
_index - Item index <NUMBER>

Returns:
_classname, _container, _containerType

Examples:
(begin example)
[_groundContainer, 5] call cba_ui_fnc_getInventoryItemData;
(end)

Author:
commy2, SynixeBrett
---------------------------------------------------------------------------- */

params ["_control", "_index"];

private _unit = call CBA_fnc_currentUnit;

private _container = objNull;
private _containerType = _control getVariable QGVAR(containerType);
switch _containerType do {
case "GROUND": {
_container = GVAR(CurrentGroundItemHolder);
};
case "CARGO": {
_container = GVAR(CurrentContainer);
};
case "UNIFORM_CONTAINER": {
_container = uniformContainer _unit;
};
case "VEST_CONTAINER": {
_container = vestContainer _unit;
};
case "BACKPACK_CONTAINER": {
_container = backpackContainer _unit;
};
};

// Reports classname, but only for magazines.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I redid the inventory filtering in acemod/ACE3#9706, I found all item classnames are contained in lbData except for backpacks:
https://github.com/acemod/ACE3/blob/b714c8bce2628ff8d4795da8a7f2fc05bb82f474/addons/inventory/functions/fnc_forceItemListUpdate.sqf#L33

Workaround for backpacks is to get them using the display name and picture.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workaround for backpacks is to get them using the display name and picture.

That would likely cause ambiguities for backpacks with linked items, as I doubt they would change the picture and display name for each variant.

PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
private _classname = _control lbData _index;
if (_classname isEqualTo "") then {
// For weapons, items and glasses, use the lb index and compare with cargo item list.
private _cargoItems = weaponCargo _container + itemCargo _container + magazineCargo _container;
_cargoItems = _cargoItems arrayIntersect _cargoItems;

_classname = _cargoItems param [_index, ""];
};
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved

[_classname, _container, _containerType]
Loading