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

Make items usable via the inventory screen - with menu #1545

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
24 changes: 24 additions & 0 deletions AGM_Attach/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,40 @@ class CfgWeapons {
class ItemInfo: InventoryItem_Base_F {
mass = 1;
};
class AGM_InventoryActions {
class AGM_Attach {
displayName = "$STR_AGM_Attach_Attach";
condition = "[_player, _classname] call AGM_Attach_fnc_canAttach";
statement = "[_player, _classname] call AGM_Attach_fnc_attach";
closeInventory = 0;
};
};
};
};

class CfgMagazines {
class CA_Magazine;
class B_IR_Grenade: CA_Magazine {
AGM_Attachable = 1;
class AGM_InventoryActions {
class AGM_Attach {
displayName = "$STR_AGM_Attach_Attach";
condition = "[_player, _classname] call AGM_Attach_fnc_canAttach";
statement = "[_player, _classname] call AGM_Attach_fnc_attach";
closeInventory = 0;
};
};
};
class SmokeShell;
class Chemlight_green: SmokeShell {
AGM_Attachable = 1;
class AGM_InventoryActions {
class AGM_Attach {
displayName = "$STR_AGM_Attach_Attach";
condition = "[_player, _classname] call AGM_Attach_fnc_canAttach";
statement = "[_player, _classname] call AGM_Attach_fnc_attach";
closeInventory = 0;
};
};
};
};
18 changes: 18 additions & 0 deletions AGM_Backpacks/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,22 @@ class CfgVehicles {
};
};
};

class ReammoBox;
class Bag_Base: ReammoBox {
class AGM_InventoryActions {
class AGM_LockBackpack {
displayName = "$STR_AGM_Backpacks_LockBackpack";
condition = "[backpackContainer _player] call AGM_Backpacks_fnc_isBackpack && {!((backpackContainer _player) getVariable ['AGM_LockedInventory', false])}";
statement = "(backpackContainer _player) setVariable ['AGM_LockedInventory', true, true]";
closeInventory = 0;
};
class AGM_UnlockBackpack {
displayName = "$STR_AGM_Backpacks_UnlockBackpack";
condition = "[backpackContainer _player] call AGM_Backpacks_fnc_isBackpack && {(backpackContainer _player) getVariable ['AGM_LockedInventory', false]}";
statement = "(backpackContainer _player) setVariable ['AGM_LockedInventory', false, true]";
closeInventory = 0;
};
};
};
};
24 changes: 24 additions & 0 deletions AGM_Explosives/CfgMagazines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class CfgMagazines {
digDistance = 0.1;
};
};
class AGM_InventoryActions {
class OpenTriggerSelection {
displayName = "$STR_AGM_Explosives_Place";
condition = "(vehicle _player == _player) && (getNumber(configFile >> 'CfgMagazines' >> _classname >> 'AGM_Placeable') == 1)";
statement = "[_classname] call AGM_Explosives_fnc_openTriggerSelectionUI;";
closeInventory = 1;
};
};
};
class APERSBoundingMine_Range_Mag:ATMine_Range_Mag{
AGM_SetupObject = "AGM_Explosives_Place_APERSBoundingMine";
Expand Down Expand Up @@ -49,6 +57,14 @@ class CfgMagazines {
FuseTime = 0.5;
};
};
class AGM_InventoryActions {
class OpenTriggerSelection {
displayName = "$STR_AGM_Explosives_Place";
condition = "(vehicle _player == _player) && (getNumber(configFile >> 'CfgMagazines' >> _classname >> 'AGM_Placeable') == 1)";
statement = "[_classname] call AGM_Explosives_fnc_openTriggerSelectionUI;";
closeInventory = 1;
};
};
};

class SatchelCharge_Remote_Mag:CA_Magazine{
Expand All @@ -67,6 +83,14 @@ class CfgMagazines {
class MK16_Transmitter:Command{};
class DeadmanSwitch:Command{};
};
class AGM_InventoryActions {
class OpenTriggerSelection {
displayName = "$STR_AGM_Explosives_Place";
condition = "(vehicle _player == _player) && (getNumber(configFile >> 'CfgMagazines' >> _classname >> 'AGM_Placeable') == 1)";
statement = "[_classname] call AGM_Explosives_fnc_openTriggerSelectionUI;";
closeInventory = 1;
};
};
};
class DemoCharge_Remote_Mag:SatchelCharge_Remote_Mag{
AGM_SetupObject = "AGM_Explosives_Place_DemoCharge"; // CfgVehicle class for setup object.
Expand Down
8 changes: 8 additions & 0 deletions AGM_Explosives/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class CfgWeapons {
mass = 3;
uniformModel = "\A3\weapons_F\ammo\mag_univ.p3d";
};
class AGM_InventoryActions {
class AGM_OpenClackerMenu {
displayName = "$STR_AGM_Explosives_DetonateMenu";
condition = "true";
statement = "[_player, _classname] call AGM_Explosives_fnc_openDetonateUI;";
closeInventory = 1;
};
};
};
class AGM_M26_Clacker: AGM_Clacker {
displayName = $STR_AGM_Explosives_M26_displayName;
Expand Down
8 changes: 8 additions & 0 deletions AGM_Hearing/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ class CfgWeapons {
class ItemInfo: InventoryItem_Base_F {
mass = 1;
};
class AGM_InventoryActions {
class AGM_EarbudsIn {
displayName = "$STR_AGM_Hearing_Earbuds_On";
condition = "!([_player] call AGM_Hearing_fnc_hasEarPlugsIn) && {'AGM_EarBuds' in items _player}";
statement = "[_player] call AGM_Hearing_fnc_putInEarPlugs";
closeInventory = 0;
};
};
};
};

Expand Down
105 changes: 105 additions & 0 deletions AGM_InventoryInteraction/RscDisplayInventory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
class RscText;
class RscActiveText;
class RscControlsGroupNoScrollbars;

/*
Adjust the scaling of the inventory screen
-changes it from scaling based on user's interface size to a static size
-text size and row height size are uneffected
-also tweaks the height of the two ProgressBars which looked odd scaled up so much
*/

class RscDisplayInventory {
class controls {
//resize moved to AGM_Inventory

//New Addition: ItemInfoBox
class ItemSelectedControlGroup: RscControlsGroupNoScrollbars {
idc = 800847;
x = "26.6 * (safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
y = "11.5 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2))";
w = 0;
h = 0;
class controls {
class ItemSelectedBackground: RscText {
idc = -1;
x = "0 * (safeZoneH / 40)";
y = "0 * ((safeZoneH / 1.2) / 25)";
w = "6 * (safeZoneH / 40)";
h = "6 * ((safeZoneH / 1.2) / 25)";
colorBackground[] = {0.05,0.05,0.05,1};
};
class ItemSelectedText: RscText {
idc = 800848;
x = "0 * (safeZoneH / 40)";
y = "0 * ((safeZoneH / 1.2) / 25)";
w = "6 * (safeZoneH / 40)";
h = "0.7 * ((safeZoneH / 1.2) / 25)";
SizeEx = "0.65 * ((safeZoneH / 1.2) / 25)";
colorBackground[] = {0.00,0.00,0.00,1};
};
class ItemSelectedMass: ItemSelectedText {
idc = 800849;
y = "0.7 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton0: RscActiveText {
idc = 800850;
style = 1;
x = "0 * (safeZoneH / 40)";
y = "1.4 * ((safeZoneH / 1.2) / 25)";
w = "6 * (safeZoneH / 40)";
h = "0.7 * ((safeZoneH / 1.2) / 25)";
text = "";
SizeEx = "0.65 * ((safeZoneH / 1.2) / 25)";
soundDoubleClick[] = {"",0.1,1};
color[] = {0.85,0.85,0.85,1};
colorText[] = {0.85,0.85,0.85,1};
colorActive[] = {1,1,1,1};
};
class ItemSelectedButton1: ItemSelectedButton0 {
idc = 800851;
y = "2.1 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton2: ItemSelectedButton0 {
idc = 800852;
y = "2.8 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton3: ItemSelectedButton0 {
idc = 800853;
y = "3.5 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton4: ItemSelectedButton0 {
idc = 800854;
y = "4.2 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton5: ItemSelectedButton0 {
idc = 800855;
y = "4.9 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton6: ItemSelectedButton0 {
idc = 800856;
y = "5.6 * ((safeZoneH / 1.2) / 25)";
};
class ItemSelectedButton7: ItemSelectedButton0 {
idc = 800857;
y = "6.3 * ((safeZoneH / 1.2) / 25)";
};

class ItemSelectedButtonClose: RscActiveText {
onButtonClick = "[] call AGM_InventoryInteraction_fnc_closeItemInfoBox;";
idc = -1;
style = 48;
color[] = {1,1,1,0.7};
text = "\A3\Ui_f\data\GUI\Rsc\RscDisplayArcadeMap\icon_exit_cross_ca.paa";
x = "5.5 * (safeZoneH / 40)";
y = "0 * ((safeZoneH / 1.2) / 25)";
w = "0.5 * (safeZoneH / 40)";
h = "0.5 * ((safeZoneH / 1.2) / 25)";
colorText[] = {1,1,1,0.7};
colorActive[] = {1,1,1,1};
tooltip = "Close";
};
};
};
};
};
6 changes: 6 additions & 0 deletions AGM_InventoryInteraction/clientInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// by commy2 (from AGM_Disposable)

// The Arma InventoryOpened EH fires actually before the inventory dialog is opened (findDisplay 602 => displayNull).
if (isNil "AGM_InventoryInteraction_setupInv_EHID") then {
AGM_InventoryInteraction_setupInv_EHID = [{_this call AGM_InventoryInteraction_fnc_inventoryOpened}] call AGM_Core_fnc_addInventoryDisplayLoadedEventHandler;
};
63 changes: 63 additions & 0 deletions AGM_InventoryInteraction/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class CfgPatches{
class AGM_InventoryInteraction {
units[] = {};
weapons[] = {};
requiredVersion = 0.6;
requiredAddons[] = {"AGM_Core"};

version = "0.99";
versionStr = "0.99";
versionAr[] = {0,99,0};
author[] = {"CorruptedHeart", "Pabst Mirror"};
};
};

class CfgFunctions {
class AGM_InventoryInteraction {
class AGM_InventoryInteraction {
file = "\AGM_InventoryInteraction\functions";
class actionButton;
class addItemAction;
class closeItemInfoBox;
class handleClickEquiped;
class handleClickInvList;
class handleSelChangeInvList;
class inventoryOpened;
class openItemInfoBox;
class removeItemAction;
};
};
};

class AGM_Core_Options {
class InvInteractDoubleClick {
displayName = "$STR_AGM_InventoryInteraction_UseDoubleClick";
default = 0;
};
};

class Extended_PostInit_EventHandlers {
class AGM_OpenedInventory {
clientInit = "call compile preprocessFileLineNumbers '\AGM_InventoryInteraction\clientInit.sqf'";
};
};

#include "RscDisplayInventory.hpp"


//More of an example than something anyone needs
/*
class CfgWeapons {
class ItemCore;
class ItemMap: ItemCore {
class AGM_InventoryActions {
class OpenMap {
displayName = "Open Map"; //todo localize
condition = "(_idc == 6211)"; //show only when sloted in a specifc slot (based on control's IDC)
statement = "openMap true";
closeInventory = 1; //runs after closing inv display
};
};
};
};
*/
47 changes: 47 additions & 0 deletions AGM_InventoryInteraction/functions/fn_actionButton.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Name: AGM_InventoryInteraction_fnc_actionButton

Author: Pabst Mirror

Description:
Handles clicking on an action from the ItemInfoBox

Parameters:
0: CODE - condition
1: CODE - statement
2: BOOL - close inventory display before running code
3: STRING - classname
4: NUMBER - IDC

Returns:
NONE

Example:
internal use
*/
#include "\AGM_InventoryInteraction\scriptDefines.sqf"

[] call AGM_InventoryInteraction_fnc_closeItemInfoBox;
_this spawn {
private ["_statement", "_closeInventory", "_classname", "_idc", "_exceptions", "_player", "_vehicle"];

_condition = _this select 0;
_statement = _this select 1;
_closeInventory = _this select 2;
_classname = _this select 3;
_idc = _this select 4;

_player = call AGM_Core_fnc_player;
_vehicle = vehicle _player;

if ([_classname, _idc, _player, _vehicle] call _condition) then {

if (_closeInventory) then {
DISPLAY_INVENTORY closeDisplay 1;
waitUntil {isNull DISPLAY_INVENTORY};
};

[_classname, _idc, _player, _vehicle] call _statement;
};
};

Loading