mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Magazine Repack - Add inventory context menu action (#7631)
This commit is contained in:
parent
ee3a721429
commit
a7260c6974
@ -1,4 +1,3 @@
|
||||
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preStart));
|
||||
@ -10,3 +9,9 @@ class Extended_PreInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
PREP(canRepackMagazine);
|
||||
PREP(getMagazineChildren);
|
||||
PREP(magazineRepackFinish);
|
||||
PREP(magazineRepackProgress);
|
||||
|
23
addons/magazinerepack/XEH_postInit.sqf
Normal file
23
addons/magazinerepack/XEH_postInit.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
// Inventory context menu action to repack magazines
|
||||
[
|
||||
"#Magazine",
|
||||
["CONTAINER", "MAGAZINE"],
|
||||
LSTRING(RepackMagazines),
|
||||
[],
|
||||
QPATHTOEF(common,UI\repack_ca.paa),
|
||||
[
|
||||
{true},
|
||||
{
|
||||
params ["_unit", "", "_magazine"];
|
||||
|
||||
[_unit, _magazine] call FUNC(canRepackMagazine)
|
||||
}
|
||||
],
|
||||
{
|
||||
params ["_unit", "", "_magazine"];
|
||||
|
||||
[_unit, _unit, _magazine] call FUNC(startRepackingMagazine);
|
||||
}
|
||||
] call CBA_fnc_addItemContextMenuOption;
|
29
addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
Normal file
29
addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
Normal file
@ -0,0 +1,29 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: mharis001
|
||||
* Checks if the given unit can repack magazines of the given type.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Magazine <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Can Repack Magazine <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [_unit, _magazine] call ace_magazinerepack_fnc_canRepackMagazine
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_magazine"];
|
||||
|
||||
private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
|
||||
|
||||
{
|
||||
_x params ["_magazineType", "_ammoCount", "_isLoaded"];
|
||||
|
||||
_magazineType == _magazine // Magazine is of given type
|
||||
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
|
||||
&& {!_isLoaded || {_unit canAdd _magazineType}} // In inventory or can be moved into it
|
||||
} count magazinesAmmoFull _unit > 1
|
Loading…
Reference in New Issue
Block a user