2015-03-17 19:43:50 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
2015-08-09 03:18:26 +00:00
|
|
|
*
|
2015-03-17 19:43:50 +00:00
|
|
|
* Opens the disarm dialog (allowing a person to remove items)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Caller (player) <OBJECT>
|
|
|
|
* 1: Target <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, bob] call ace_disarming_fnc_openDisarmDialog
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-02-27 21:23:46 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-09 03:18:26 +00:00
|
|
|
params ["_caller", "_target"];
|
2015-04-16 17:36:12 +00:00
|
|
|
private "_display";
|
2015-08-09 03:18:26 +00:00
|
|
|
#define DEFUALTPATH "\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa"
|
2015-02-27 21:23:46 +00:00
|
|
|
//Sanity Checks
|
|
|
|
if (_caller != ACE_player) exitwith {ERROR("Player isn't caller?");};
|
2015-03-21 01:17:49 +00:00
|
|
|
if (!([_player, _target] call FUNC(canPlayerDisarmUnit))) exitWith {ERROR("Can't Disarm Unit");};
|
|
|
|
if (dialog) then {ERROR("Dialog open when trying to open disarm dialog"); closeDialog 0;};
|
2015-02-27 21:23:46 +00:00
|
|
|
|
|
|
|
disableSerialization;
|
|
|
|
|
2015-03-21 01:17:49 +00:00
|
|
|
createDialog QGVAR(remoteInventory);
|
|
|
|
|
2015-02-28 00:50:08 +00:00
|
|
|
_display = uiNamespace getVariable ["ACE_remoteInventory", displayNull];
|
2015-02-27 21:23:46 +00:00
|
|
|
if (isNull _display) exitWith {ERROR("Display is Null");};
|
|
|
|
|
|
|
|
GVAR(disarmTarget) = _target;
|
|
|
|
|
|
|
|
//Setup Drop Event (on right pannel)
|
|
|
|
(_display displayCtrl 632) ctrlAddEventHandler ["LBDrop", {
|
|
|
|
if (isNull GVAR(disarmTarget)) exitWith {};
|
2015-08-09 03:18:26 +00:00
|
|
|
params ["_ctrl", "_xPos", "_yPos", "_idc", "_itemInfo"];
|
|
|
|
(_itemInfo select 0) params ["_displayText", "_value", "_data"];
|
2015-02-27 21:23:46 +00:00
|
|
|
|
2015-02-28 00:38:23 +00:00
|
|
|
if (isNull GVAR(disarmTarget)) exitWith {ERROR("disarmTarget is null");};
|
2015-03-17 19:43:50 +00:00
|
|
|
|
2015-04-04 05:52:21 +00:00
|
|
|
TRACE_2("Debug: Droping %1 from %2",_data,GVAR(disarmTarget));
|
2015-02-28 00:38:23 +00:00
|
|
|
["DisarmDropItems", [GVAR(disarmTarget)], [ACE_player, GVAR(disarmTarget), [_data]]] call EFUNC(common,targetEvent);
|
2015-03-17 19:43:50 +00:00
|
|
|
|
2015-02-28 00:38:23 +00:00
|
|
|
false //not sure what this does
|
2015-02-27 21:23:46 +00:00
|
|
|
}];
|
|
|
|
|
|
|
|
//Setup PFEH
|
|
|
|
[{
|
2015-08-09 03:18:26 +00:00
|
|
|
private ["_groundContainer", "_targetContainer", "_playerName", "_icon", "_rankPicture", "_targetUniqueItems", "_holderUniqueItems", "_holder"];
|
2015-02-27 21:23:46 +00:00
|
|
|
disableSerialization;
|
2015-08-09 03:18:26 +00:00
|
|
|
params ["_args", "_idPFH"];
|
|
|
|
_args params ["_player", "_target", "_display"];
|
2015-02-27 21:23:46 +00:00
|
|
|
|
2015-03-21 01:17:49 +00:00
|
|
|
if ((!([_player, _target] call FUNC(canPlayerDisarmUnit))) ||
|
2015-02-27 21:23:46 +00:00
|
|
|
{isNull _display} ||
|
2015-03-21 01:17:49 +00:00
|
|
|
{_player != ACE_player}) then {
|
|
|
|
|
2015-08-09 03:18:26 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-02-27 21:23:46 +00:00
|
|
|
GVAR(disarmTarget) = objNull;
|
2015-08-09 03:18:26 +00:00
|
|
|
if (!isNull _display) then { closeDialog 0; }; //close dialog if still open
|
2015-02-27 21:23:46 +00:00
|
|
|
} else {
|
2015-04-16 17:36:12 +00:00
|
|
|
|
2015-02-27 21:23:46 +00:00
|
|
|
_groundContainer = _display displayCtrl 632;
|
|
|
|
_targetContainer = _display displayCtrl 633;
|
|
|
|
_playerName = _display displayCtrl 111;
|
|
|
|
_rankPicture = _display displayCtrl 1203;
|
|
|
|
|
2015-03-21 01:17:49 +00:00
|
|
|
//Show rank and name (just like BIS's inventory)
|
2015-08-09 03:18:26 +00:00
|
|
|
_icon = format [DEFUALTPATH, toLower (rank _target)];
|
|
|
|
if (_icon isEqualTo DEFUALTPATH) then {_icon = ""};
|
|
|
|
_rankPicture ctrlSetText _icon;
|
2015-02-27 21:23:46 +00:00
|
|
|
_playerName ctrlSetText ([GVAR(disarmTarget)] call EFUNC(common,getName));
|
|
|
|
|
2015-03-21 01:17:49 +00:00
|
|
|
//Clear both inventory lists:
|
2015-02-27 21:23:46 +00:00
|
|
|
lbClear _groundContainer;
|
|
|
|
lbClear _targetContainer;
|
|
|
|
|
2015-03-17 19:43:50 +00:00
|
|
|
//Show the items in the ground disarmTarget's inventory
|
2015-02-27 21:23:46 +00:00
|
|
|
_targetUniqueItems = [GVAR(disarmTarget)] call FUNC(getAllGearUnit);
|
|
|
|
[_targetContainer, _targetUniqueItems] call FUNC(showItemsInListbox);
|
|
|
|
|
2015-03-21 01:17:49 +00:00
|
|
|
//Try to find a holder that the target is using to drop items into:
|
2015-02-27 21:23:46 +00:00
|
|
|
_holder = objNull;
|
|
|
|
{
|
|
|
|
if ((_x getVariable [QGVAR(disarmUnit), objNull]) == _target) exitWith {
|
|
|
|
_holder = _x;
|
|
|
|
};
|
2015-08-09 03:18:26 +00:00
|
|
|
} count ((getpos _target) nearObjects [DISARM_CONTAINER, 3]);
|
2015-02-27 21:23:46 +00:00
|
|
|
|
2015-03-21 01:17:49 +00:00
|
|
|
//If a holder exists, show it's inventory
|
2015-02-27 21:23:46 +00:00
|
|
|
if (!isNull _holder) then {
|
2015-02-27 22:16:35 +00:00
|
|
|
_holderUniqueItems = [_holder] call FUNC(getAllGearContainer);
|
|
|
|
[_groundContainer, _holderUniqueItems] call FUNC(showItemsInListbox);
|
2015-02-27 21:23:46 +00:00
|
|
|
};
|
|
|
|
};
|
2015-03-21 01:17:49 +00:00
|
|
|
}, 0, [_caller, _target, _display]] call CBA_fnc_addPerFrameHandler;
|