Skip to content

Make items usable via the inventory screen #1441

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions AGM_Explosives/CfgMagazines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class CfgMagazines {
digDistance = 0.1;
};
};
class AGM_Action {
condition = "true";
statement = "[_this select 2] call AGM_Explosives_fnc_openTriggerSelectionUI;";
};
};
class APERSBoundingMine_Range_Mag:ATMine_Range_Mag{
AGM_SetupObject = "AGM_Explosives_Place_APERSBoundingMine";
Expand Down Expand Up @@ -49,6 +53,10 @@ class CfgMagazines {
FuseTime = 0.5;
};
};
class AGM_Action {
condition = "true";
statement = "[_this select 2] call AGM_Explosives_fnc_openTriggerSelectionUI;";
};
};

class SatchelCharge_Remote_Mag:CA_Magazine{
Expand All @@ -67,6 +75,10 @@ class CfgMagazines {
class MK16_Transmitter:Command{};
class DeadmanSwitch:Command{};
};
class AGM_Action {
condition = "true";
statement = "[_this select 2] call AGM_Explosives_fnc_openTriggerSelectionUI;";
};
};
class DemoCharge_Remote_Mag:SatchelCharge_Remote_Mag{
AGM_SetupObject = "AGM_Explosives_Place_DemoCharge"; // CfgVehicle class for setup object.
Expand Down
10 changes: 6 additions & 4 deletions AGM_Explosives/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class CfgWeapons {
model = "\A3\weapons_F\ammo\mag_univ.p3d";
AGM_range = 250;
AGM_Detonator = 1;
class AGM_Action {
condition = "true";
statement = "[_this select 0, _this select 2] call AGM_Explosives_fnc_openDetonateUI;";
};

class ItemInfo: AGM_ExplosiveItem {
mass = 3;
Expand All @@ -38,12 +42,10 @@ class CfgWeapons {
uniformModel = "\A3\Structures_F\Items\Tools\Pliers_F.p3d";
};
};
class AGM_DeadManSwitch: AGM_ItemCore {
scope = 2;
class AGM_DeadManSwitch: AGM_Clacker {
displayName = $STR_AGM_Explosives_DeadManSwitch_displayName;
descriptionShort = $STR_AGM_Explosives_DeadManSwitch_description;
picture = "\AGM_Explosives\Data\UI\DeadmanSwitch.paa";
model = "\A3\weapons_F\ammo\mag_univ.p3d";
AGM_range = 100;
AGM_Detonator = 1;

Expand All @@ -52,4 +54,4 @@ class CfgWeapons {
uniformModel = "\A3\weapons_F\ammo\mag_univ.p3d";
};
};
};
};
8 changes: 8 additions & 0 deletions AGM_Interaction/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CfgFunctions {
class getDoor;
class getDown;
class getSelectedButton;
class handleInventoryClick;
class hideMenu;
class hideMouseHint;
class initialiseInteraction;
Expand Down Expand Up @@ -88,6 +89,13 @@ class Extended_GetIn_EventHandlers {
};
};
};
class Extended_InventoryOpened_EventHandlers {
class CAManBase {
class AGM_OpenedInventory {
clientInventoryOpened = "if((_this select 0) == (call AGM_Core_fnc_player))then{[] spawn {waitUntil {sleep 0.1;!(isNull (findDisplay 602))};disableSerialization;private ['_display'];_display = (findDisplay 602);(_display displayCtrl 633) ctrlAddEventHandler ['LBDblClick', '_this call AGM_Interaction_fnc_HandleInventoryClick;'];(_display displayCtrl 619) ctrlAddEventHandler ['LBDblClick', '_this call AGM_Interaction_fnc_HandleInventoryClick;'];(_display displayCtrl 638) ctrlAddEventHandler ['LBDblClick', '_this call AGM_Interaction_fnc_HandleInventoryClick;'];};};false";
};
};
};

class AGM_Core_Default_Keys {
class openInteractionMenuNew {
Expand Down
68 changes: 68 additions & 0 deletions AGM_Interaction/functions/fn_handleInventoryClick.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Name: AGM_Interaction_fnc_HandleInventoryClick

Author:
Garth de Wet (LH)

Description:
Handles when the player double clicks in the inventory, checks the object and calls AGM_Action class on the object.

Parameters:
0: NUMBER - Clicked IDC
1: NUMBER - Index selected in the IDC

Returns:
BOOLEAN - Handled by the object.

Example:
((findDisplay 602) displayCtrl 633) ctrlAddEventHandler ["LBDblClick", "_this call AGM_Interaction_fnc_HandleInventoryClick;"];
*/
private ["_class", "_idc", "_selectedIndex", "_player", "_item"];
_player = call AGM_Core_fnc_player;
_idc = ctrlIDC (_this select 0);
_selectedIndex = _this select 1;
_item = (lbData [_idc, _selectedIndex]);
_class = configFile >> "CfgMagazines" >> _item >> "AGM_Action";
_result = false;

if ((lbData [_idc, _selectedIndex]) == "") then {
private ["_fncSort"];
_fncSort = {
private ["_newArray"];
_newArray = [];
{
if !(_x in _newArray) then {
_newArray pushBack _x;
};
false
} count _this;
_newArray
};
_item = "";
switch (_idc) do {
// Uniform
case 633:{
_item = ((uniformItems _player) call _fncSort) select _selectedIndex;
};
// Backpack
case 619:{
_item = ((backpackItems _player) call _fncSort) select _selectedIndex;
};
// Vest
case 638:{
_item = ((vestItems _player) call _fncSort) select _selectedIndex;
};
};
_class = ConfigFile >> "CfgWeapons" >> _item >> "AGM_Action";
};
if (isClass(_class)) exitWith {
// Not sure how this is supposed to integrate yet.
//_exceptions = getArray (_action >> "exceptions");
if ([_player, vehicle _player, _item] call (compile getText(_class >> "condition"))) then {
[_player, vehicle _player, _item] call (compile getText(_class >> "statement"));
true
} else {
false
};
};
false