@@ -113,6 +113,11 @@ Parameters:
113113 An already existing ID will overwrite the previous settings.
114114 (optional, default: "") <STRING>
115115
116+ _allowInheritance - if true, then option will be available for all items
117+ that inherit from the given _item class.
118+ Does nothing if _item is a type or wildcard
119+ (optional, default: true) <BOOLEAN>
120+
116121Returns:
117122 ID <STRING> (or <NIL> on error)
118123
@@ -122,11 +127,11 @@ Examples:
122127 params ["_unit", "_container", "_item", "_slot", "_params"];
123128 systemChat str [name _unit, typeOf _container, _item, _slot, _params];
124129 true
125- }, false, [0,1,2]] call CBA_fnc_addItemContextMenuOption;
130+ }, false, [0,1,2], "DebugAction", false ] call CBA_fnc_addItemContextMenuOption;
126131 (end)
127132
128133Author:
129- commy2, Zorn
134+ commy2, Zorn, 10Dozen
130135---------------------------------------------------------------------------- */
131136
132137// Force unscheduled environment to prevent race conditions.
@@ -139,6 +144,7 @@ if (!hasInterface) exitWith {};
139144// Initialize system on first execution.
140145if (isNil QGVAR(ItemContextMenuOptions)) then {
141146 GVAR(ItemContextMenuOptions) = createHashMap;
147+ GVAR(ItemContextMenuUniqueOptions) = createHashMap;
142148
143149 [" CAManBase" , " InventoryOpened" , {
144150 params [" _unit" , " _container1" , " _container2" ];
@@ -163,7 +169,8 @@ params [
163169 [" _statement" , {}, [{}]],
164170 [" _consume" , false , [false ]],
165171 [" _params" , []],
166- [" _id" , " " , [" " ]]
172+ [" _id" , " " , [" " ]],
173+ [" _allowInheritance" , true , [false ]]
167174];
168175
169176if (_item isEqualTo " " ) exitWith { ERROR_1(" no item specified [%1]" ,_item ); nil };
@@ -228,11 +235,16 @@ _condition params [
228235 [" _conditionShow" , {true }, [{}]]
229236];
230237
231- private _options = GVAR(ItemContextMenuOptions) get _item ;
238+ private _contextMenuOptions = GVAR(ItemContextMenuOptions);
239+ if (! _allowInheritance ) then {
240+ _contextMenuOptions = GVAR(ItemContextMenuUniqueOptions);
241+ };
242+
243+ private _options = _contextMenuOptions get _item ;
232244
233245if (isNil " _options" ) then {
234246 _options = createHashMap;
235- GVAR(ItemContextMenuOptions) set [_item , _options ];
247+ _contextMenuOptions set [_item , _options ];
236248};
237249
238250if (_id isEqualTo " " ) then {
0 commit comments