Jump to content
aimgame

AllControls check

Recommended Posts

Hi! 

Anybody knows how to get the text from an element of currently opened hud?

I.e. inventory hud has a button called "Ground" at left top corner... So how to get this text "Ground"???
Here is what i've already done in this direction - 

_arr = [];							//array of all non-empty-text elements
 {
  _y = _x;
  {   
   for "_i" from 0 to (lbSize _x) do {				//looking every element of control
    if !((_x lbText _i) isEqualTo "") then {			//if text is not empty
     _arr pushBack (_x lbText _i);				//add it to array
    };    
   };
  } forEach (allControls _y);					//looking all controls in all displays
 } forEach AllDisplays;						//looking all displays

 _res = _arr findIf {_x in ["Ground"]};				//find element with text "Ground"
 _resLoc = _arr findIf {localize _x in ["Ground"]}; 		//find element with localized text "Ground"
 
 systemchat str _arr;						//watching array
 systemchat (str _res + str _resLoc);				//watching indexes of elements (if founded)
 systemchat str (count _arr);				        //watching count of array elements

So i get somewhere around 100 elements (testing in EDEN) but not the "Ground" element! Even if my inventory hud opened...

How to find it?)))
 

Share this post


Link to post
Share on other sites

You look through the config of the display. In the case of the Inventory it is called RscDisplayInventory with an idd of 602. Next you need the idc of the control. either you can find it in the config or you can use this function: https://github.com/7erra/Terra-s-Editing-Extensions/blob/master/TER_editing/gui/scripts/fn_controlInfo.sqf with which you should find the idc of 6321. to access the control you can do:

_ctrl = findDisplay 602 displayCtrl 6321;

Your approach will not work because lbText is only for the family of list controls such as CT_LISTBOX while the control you are looking for is an CT_ACTIVETEXT type control. Also,

_resLoc = _arr findIf {localize _x in ["Ground"]};

will not work because the text _x is already localized (it should throw an error).

  • Like 1

Share this post


Link to post
Share on other sites

Thanks!

But what if i dont know the idd and the idc ? How do i find specific text in all displays and controls?

Share this post


Link to post
Share on other sites

You should look at the config of the display either in the config viewer or in a config dump. allDisplays returns an array which looks like [Display #0, Display #46, Display #602] etc. where the number behind the # is the idd. There is also this list for some IDDs. Searching the idc of a specific control might take a bit longer but usually the classnames should be rather descriptive.

  • Like 1

Share this post


Link to post
Share on other sites

No no, i mean how to do it automaticaly? Without knowing any precice IDDs and IDCs... How to make the script find it all by itself by parsing all displays etc.)

Share this post


Link to post
Share on other sites
5 hours ago, aimgame said:

No no, i mean how to do it automaticaly? Without knowing any precice IDDs and IDCs... How to make the script find it all by itself by parsing all displays etc.)

Exactly how you did it but as 7erra said, lbText does only return the text of a listbox. So you need to first get the type of the control with ctrlType and then get the text with the appropriate command e.g tvText, lbText, lnbText etc.

 

In addition to that, you need to also go deeper if ctrlType return a controlsGroup because allControls will not return these.

  • Like 1

Share this post


Link to post
Share on other sites
23 minutes ago, R3vo said:

Exactly how you did it but as 7erra said, lbText does only return the text of a listbox. So you need to first get the type of the control with ctrlType and then get the text with the appropriate command e.g tvText, lbText, lnbText etc.

 

In addition to that, you need to also go deeper if ctrlType return a controlsGroup because allControls will not return these.

 

Huge apriciate!

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

×