Jump to content
fn_Quiksilver

Getting screen/ctrl position of vanilla HUD

Recommended Posts

HI lads,

 

Specifically I am trying to pull the screen position of

 

((uiNamespace getVariable 'RscUnitInfo') displayCtrl 151)

when i do something simple like

systemChat str (ctrlPosition ((uiNamespace getVariable 'RscUnitInfo') displayCtrl 151));

It returns a position like

[0.24,0.1,0.06,0.04]

Which is nowhere near the actual UI in the top corner.

 

I assume there is some controls group to access but I can't seem to figure it out.

 

Thanks!

Share this post


Link to post
Share on other sites
_grenadeCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 2302 controlsGroupCtrl 151;
_magCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 2303 controlsGroupCtrl 151;
_flareCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 151;

There are a few 151 controls within controlsGroups in RscUnitInfo.

 

Add the position of the ctrl in the controlsGroup and the position of the controlsGroup within RscUnitInfo together.

  • Like 3

Share this post


Link to post
Share on other sites
13 hours ago, Larrow said:

_grenadeCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 2302 controlsGroupCtrl 151;
_magCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 2303 controlsGroupCtrl 151;
_flareCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 151;

There are a few 151 controls within controlsGroups in RscUnitInfo.

 

Add the position of the ctrl in the controlsGroup and the position of the controlsGroup within RscUnitInfo together.

 

_grenadeCntCtrl = ((uiNamespace getVariable 'RscUnitInfo') displayCtrl 2302) controlsGroupCtrl 151;
_magCntCtrl = ((uiNamespace getVariable 'RscUnitInfo') displayCtrl 2303) controlsGroupCtrl 151;
_flareCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 151;
systemChat str (
	[
		ctrlPosition _grenadeCntCtrl,
		ctrlPosition _magCntCtrl,
		ctrlPosition _flareCntCtrl
	]
);

all positions report [0,0,0,0] when in a vehicle

 

on foot = [         [0.24,0.1,0.06,0.04],       [0,0,0,0],         [0.24,0.1,0.06,0.04]       ]

Share this post


Link to post
Share on other sites

Sorry not sure what happened there, seemed to of written some wrong idcs :shrug:

 

2302 is unit weapons info, 2303 is vehicle weapons info.

Controls under RscUnitInfo seem to be created/destroyed as needed.

 

Spoiler

h = [] spawn {
	while { true } do {
		_rscInfo = uiNamespace getVariable "RscUnitInfo";
		_ammo = 184;
		_mag = 185;
		_grenade = 151;
		
		_info = if ( vehicle player isEqualTo player ) then {
			_rscInfo = _rscInfo displayCtrl 2302;
			format[ "Ammo: %1\nMags: %2\nGrenades: %3",
				ctrlText( _rscInfo controlsGroupCtrl _ammo ) splitString "| " select 0,
				ctrlText( _rscInfo controlsGroupCtrl _mag ) splitString "| " select 0,
				ctrlText( _rscInfo controlsGroupCtrl _grenade ) splitString "x" select 0
			];
		}else{
			_rscInfo = _rscInfo displayCtrl 2303;
			format[ "Ammo: %1\nMags: %2",
				ctrlText( _rscInfo controlsGroupCtrl _ammo ) splitString "| " select 0,
				ctrlText( _rscInfo controlsGroupCtrl _mag ) splitString "| " select 0
			];
		};
		
		hint _info;
	};
};

 

 

Not even sure that is correct for all vehicles. The above works for gunner in a hunter but does not for say a gunner in a slammer hmm now seems to be working. I dont know needs playing with as I keep getting different results.

 

I presume RscInGameUI works something similar to RscTitles and each needed display is cut based on the present vehicle. If you look under RscInGameUI you will notice most child classes have an idd and reference controls from RscUnitInfo, for instance RscUnitInfoTank. If you then look at the slammer (configfile >> "CfgVehicles" >> "B_MBT_01_cannon_F" >> "unitInfoType") you will see its unitInfoType is "RscUnitInfoTank" possibly denoting what is cut and the controls it inherits from RscUnitInfo.

Share this post


Link to post
Share on other sites
44 minutes ago, Larrow said:

Sorry not sure what happened there, seemed to of written some wrong idcs :shrug:

 

2302 is unit weapons info, 2303 is vehicle weapons info.

Controls under RscUnitInfo seem to be created/destroyed as needed.

 

  Hide contents


h = [] spawn {
	while { true } do {
		_rscInfo = uiNamespace getVariable "RscUnitInfo";
		_ammo = 184;
		_mag = 185;
		_grenade = 151;
		
		_info = if ( vehicle player isEqualTo player ) then {
			_rscInfo = _rscInfo displayCtrl 2302;
			format[ "Ammo: %1\nMags: %2\nGrenades: %3",
				ctrlText( _rscInfo controlsGroupCtrl _ammo ) splitString "| " select 0,
				ctrlText( _rscInfo controlsGroupCtrl _mag ) splitString "| " select 0,
				ctrlText( _rscInfo controlsGroupCtrl _grenade ) splitString "x" select 0
			];
		}else{
			_rscInfo = _rscInfo displayCtrl 2303;
			format[ "Ammo: %1\nMags: %2",
				ctrlText( _rscInfo controlsGroupCtrl _ammo ) splitString "| " select 0,
				ctrlText( _rscInfo controlsGroupCtrl _mag ) splitString "| " select 0
			];
		};
		
		hint _info;
	};
};

 

 

Not even sure that is correct for all vehicles. The above works for gunner in a hunter but does not for say a gunner in a slammer.

 

ahh.

 

i mean to find the onscreen position of those controls. how do I return the ctrlPosition of the controls group?

Share this post


Link to post
Share on other sites
12 minutes ago, fn_Quiksilver said:

i mean to find the onscreen position of those controls. how do I return the ctrlPosition of the controls group?

ctrlPosition like any other ctrl.

 

Adding to the above when dealing with vehicles you need to update the controls you are looking for based on the turret currently occupied.

e.g the slammer

If you are in the base of the vehicle then its unitInfoType member, being RscUnitInfoTank

Then each turret has a turretInfoType, which for the slammer MainTurret (gunner) being "RscOptics_MBT_01_gunner" for various other controls.

Share this post


Link to post
Share on other sites
34 minutes ago, Larrow said:

ctrlPosition like any other ctrl.

 

Adding to the above when dealing with vehicles you need to update the controls you are looking for based on the turret currently occupied.

e.g the slammer

If you are in the base of the vehicle then its unitInfoType member, being RscUnitInfoTank

Then each turret has a turretInfoType, which for the slammer MainTurret (gunner) being "RscOptics_MBT_01_gunner" for various other controls.

 

do you have a line for returning the position of the control group?

 

for instance

 

_grenadeCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 2302 controlsGroupCtrl 151;

 

does not return the actual screen XY position of the control. It returns the position relative to hte position of the control group. I am looking for actual screen position

Share this post


Link to post
Share on other sites
59 minutes ago, fn_Quiksilver said:

do you have a line for returning the position of the control group?

 

_grenadeCntCtrl = (uiNamespace getVariable 'RscUnitInfo') displayCtrl 2302 controlsGroupCtrl 151;

 

does not return the actual screen XY position of the control. It returns the position relative to hte position of the control group.

1 hour ago, Larrow said:
1 hour ago, fn_Quiksilver said:

i mean to find the onscreen position of those controls. how do I return the ctrlPosition of the controls group?

ctrlPosition like any other ctrl.

You are getting the position of ctrl 151 from within the controlGroup 2302, not the controls groups position.

On 6/30/2019 at 4:38 PM, Larrow said:

Add the position of the ctrl in the controlsGroup and the position of the controlsGroup within RscUnitInfo together.

_rscUnitInfo = uiNamespace getVariable "RscUnitInfo";
_ctrlsGroupPos = ctrlPosition ( _rscUnitInfo displayCtrl 2302 ) select[ 0, 2 ]; //[ x, y ]
_ctrlPos = ctrlPosition (( _rscUnitInfo displayCtrl 2302 ) controlsGroupCtrl 151 ); //[ x, y, w, h ]

//Add both x and y's together
{
	_ctrlPos set[ _forEachIndex, ( _ctrlPos select _forEachIndex ) + _x ];
}forEach _ctrlsGroupPos;

_ctrl = findDisplay 46 ctrlCreate [ "RscPicture", 100001 ];
_ctrl ctrlSetText  "#(argb,8,8,3)color(1,0,0,1)";
_ctrl ctrlSetPosition _ctrlPos;
_ctrl ctrlCommit 0;

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
12 minutes ago, Larrow said:

You are getting the position of ctrl 151 from within the controlGroup 2302, not the controls groups position.


_rscUnitInfo = uiNamespace getVariable "RscUnitInfo";
_ctrlsGroupPos = ctrlPosition ( _rscUnitInfo displayCtrl 2302 ) select[ 0, 2 ];
_ctrlPos = ctrlPosition (( _rscUnitInfo displayCtrl 2302 ) controlsGroupCtrl 151 );

{
	_ctrlPos set[ _forEachIndex, ( _ctrlPos select _forEachIndex ) + _x ];
}forEach _ctrlsGroupPos;

_ctrl = findDisplay 46 ctrlCreate [ "RscPicture", 100001 ];
_ctrl ctrlSetText  "#(argb,8,8,3)color(1,0,0,1)";
_ctrl ctrlSetPosition _ctrlPos;
_ctrl ctrlCommit 0;

 

 

hmm did not think of that, was going about it the wrong way

 

thank you good sir

Share this post


Link to post
Share on other sites

The position should be stored in some profile variable since it is custom position you can adjust via game options

  • Like 2

Share this post


Link to post
Share on other sites

Thanks lads

 

This was the end goal:

 

PVVbkKX.jpg

 

note the extra countermeasure under "Smoke Screen"

  • Like 1

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

×