Jump to content
Undeceived

Disable mouse buttons (restrict inventory manipulation)

Recommended Posts

Hi guys, I want to prevent the player from removing equipment while he's in an inventory dialogue. This normally is done by pressing the right mouse button over an inventory object or by dragging it to the left side. Exactly this is what I want to prevent.

 

It might sound a bit irrational :icon_biggrin:, but I want the player only to be able to check/see the equipment of another unit, not to change it.

 

Any ideas are welcome. Thank you!

 

 

Share this post


Link to post
Share on other sites
6 hours ago, Undeceived said:

Hi guys, I want to prevent the player from removing equipment while he's in an inventory dialogue. This normally is done by pressing the right mouse button over an inventory object or by dragging it to the left side. Exactly this is what I want to prevent.

 

It might sound a bit irrational :icon_biggrin:, but I want the player only to be able to check/see the equipment of another unit, not to change it.

 

Any ideas are welcome. Thank you!

 

 

I hope this even handlers can help:

 

https://community.bistudio.com/wiki/User_Interface_Event_Handlers#Listbox_events

  • Thanks 1

Share this post


Link to post
Share on other sites

Well this is the closest I got:

Spoiler

#include "\a3\ui_f\hpp\defineresincl.inc"
if (!isNil "TER_disableGear") then {
	TER_disableGear = false;
};

TER_fnc_disableGear = {
};

TER_disableGear = true;
while {TER_disableGear} do {
	waitUntil {sleep 0.1; !isNull (findDisplay IDD_FUTURAGEAR)};
	_gearDisplay = findDisplay IDD_FUTURAGEAR;
	{
		_control = _gearDisplay displayCtrl _x;
		_control ctrlEnable false;
	} forEach [
		IDC_FG_PRIMARY,
		IDC_FG_SECONDARY,
		IDC_FG_HANDGUN,
		IDC_FG_MAP,
		IDC_FG_COMPASS,
		IDC_FG_WATCH,
		IDC_FG_RADIO,
		IDC_FG_GPS,
		IDC_FG_GOGGLES,
		IDC_FG_HMD,
		IDC_FG_BINOC,
		IDC_FG_BACKPACK2,
		IDC_FG_HEADGEAR,
		IDC_FG_PW_MUZZLE,
		IDC_FG_PW_OPTICS,
		IDC_FG_PW_FLASHLIGHT,
		IDC_FG_PW_MAGAZINE,
		IDC_FG_SW_MUZZLE,
		IDC_FG_SW_OPTICS,
		IDC_FG_SW_FLASHLIGHT,
		IDC_FG_SW_MAGAZINE,
		IDC_FG_HG_MUZZLE,
		IDC_FG_HG_OPTICS,
		IDC_FG_HG_FLASHLIGHT,
		IDC_FG_HG_MAGAZINE,
		IDC_FG_PW_UNDERBARREL,
		IDC_FG_SW_UNDERBARREL,
		IDC_FG_HG_UNDERBARREL,
		IDC_FG_PW_MAGAZINE_GL,
		IDC_FG_VEST_CONTAINER,
		IDC_FG_UNIFORM_CONTAINER,
		IDC_FG_BACKPACK_CONTAINER,
		IDC_FG_GROUND_ITEMS,
		IDC_FG_CHOSEN_CONTAINER
	];
};

 

 

There are 2 problems though:

1. You can still drop your containers (backpack, vest, uniform)

2. You can't scroll through the items

 

Testing around with ctrlRemoveAllEventhandlers did nothing for me. I guess they are set by config or engine.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Wow, 7erra, this is pretty far reaching! 

 

Problem 2 isn't that bad as the unit's gear is shown on the right-hand side of the inventory UI too (where the item lists in the uniform, vest and backpack sections normally aren't that long).

Problem 1 is a real problem though. :icon5: It kinda makes the other mouse restrictions useless.

 

In the meanwhile I found out that the objects/items in an unit's inventory are locked / deactivated when the unit is not simulated. So far I used AI_unit action ["Gear", AI_unit]; to show the inventory menu with the unit's (AI) gear. The unit performs that inventory animation and its gear is shown. This however doesn't work when the simulation of the unit is off. No animation played, no inventory UI.

 

Now, I could also use player action ["Gear", AI_unit]; but this would show the player's gear in the right-hand side of the UI and the unit's stuff only on the left-hand side. But I want to see the unit's gear on the right-hand side no matter what.

 

So, is there a way to immediately open up an non simulated unit's inventory - apart from the "Gear" action?

 

 

Share this post


Link to post
Share on other sites

 I tried a different approach:

_invOpenEH = player addEventHandler ["InventoryOpened",{
	params ["_unit", "_container"];
	_backpackUnit = allUnits select {backpackContainer _x == _container} select 0;
	{
		_x setVariable ["_unitLoadout",getUnitLoadout _x];
	} forEach [_unit,_backpackUnit];
}];

_invCloseEH = player addEventHandler ["InventoryClosed", {
	params ["_unit", "_container"];
	_backpackUnit = allUnits select {backpackContainer _x == _container} select 0;
	{
		_setLoadout = _x getVariable ["_unitLoadout",getUnitLoadout _x];
		_x setUnitLoadout _setLoadout;
	} forEach [_unit,_backpackUnit];
}];

player setVariable ["_invOpenEH",_invOpenEH];
player setVariable ["_invCloseEH",_invCloseEH];

This will not prevent the player from opening the inventory but instead revert the loadout of both units to the state it was in before. Still there seems to be a problem with the setUnitLoadout command if you use it on an AI unit bc I couldnt access their inventory afterwards :eh:

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks a lot, 7erra!

 

I didn't have problems with the setUnitLoadout on AI. I added the EHs not to the player but to AI units and I "tell" them to open their inventory for me. After closing it, I could access it again and the original loadout was there. 

What I added myself to the InventoryClosed-EH is the deletion of dropped containers (uniform, vest or backpack) on the ground.

 

_invOpenEH = this addEventHandler ["InventoryOpened",{ 
 params ["_unit", "_container"]; 
 _backpackUnit = allUnits select {backpackContainer _x == _container} select 0; 
 { 
  _x setVariable ["_unitLoadout",getUnitLoadout _x]; 
 } forEach [_unit,_backpackUnit]; 
}]; 
 
_invCloseEH = this addEventHandler ["InventoryClosed", { 
 params ["_unit", "_container"]; 
 _backpackUnit = allUnits select {backpackContainer _x == _container} select 0; 
 { 
  _setLoadout = _x getVariable ["_unitLoadout",getUnitLoadout _x]; 
  _x setUnitLoadout _setLoadout; 
 } forEach [_unit,_backpackUnit]; 
 {deleteVehicle _x; } forEach nearestObjects [getpos _unit,["WeaponHolder","GroundWeaponHolder"],4];
}]; 
 
this setVariable ["_invOpenEH",_invOpenEH]; 
this setVariable ["_invCloseEH",_invCloseEH];

 

 

I might use both of your approaches in combination (to indicate even more that the inventory can't be manipulated). I have a further question on the first one though.

 

Is it possible to exclude the player (and/or other desired units) from this mouse button restriction? I only want to apply this to the inventory screen of certain units, but the player has to be able to change his gear as always.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×