Jump to content
Sign in to follow this  
d3nn16

does ctrlSetStructuredText work in ArmA 2 OA ?

Recommended Posts

Hi,

I tested ctrlSetStructuredText command on a Structured text type of control and it didn't work :

description.ext declaration:

...
	class DEX_0_STX_STXEXAMPLE : OPT_TEMPL_STX
	{
		idc = _IDC_DEX_0_STX_STXEXAMPLE_;
		x = _BODY_X_;
		y = _BODY_Y_ + 11 * _H_;
		w = 3 * _W_ - _DW_;
		h = 4 * _H_ - _DH_;

		text = "structured <br/><t color='#ffff00' shadow='2' shadowColor='#ff0000' underline='true' align='center' valign='bottom' font='LucidaConsoleB' size='1.5'>text</t><br/><img size='1.5' image='\ca\ui\data\iconmotorbike_ca.paa'/>";
		colorBackground[] = {_COLHPP_STA_BG_, 0};

		class Attributes
		{
			color = "#00FF00";
			align = "left";
			valign = "middle";
		};
	};
...

The above code display text formatted as expected. But when I use ctrlSetStructuredText it does not even change the control's text.

The following piece of SQF code doesn't do anything :

...
ctrlSetText [_IDC_DEX_0_STX_STXEXAMPLE_, "hello"];
...

or

...
findDisplay _IDD_DIAG_OPTIONS_ displayCtrl _IDC_DEX_0_STX_STXEXAMPLE_ ctrlSetStructuredText parseText "hello";
...

Is this a bug or did I miss anything ?

Thanks

Share this post


Link to post
Share on other sites

This works for me:

[] spawn {
waitUntil {player == player};
cutRsc ["MyRscTitle","PLAIN"];
disableSerialization;
_disp = uiNamespace getVariable "d_MyRscTitle";
while {true} do {
	_msg = "<t color='#00ff00'>" + "Welcome "+"</t>";
	_msg = _msg + "<t color='#ffff00'>" + format["%1",name player]+ "</t>" + "<br/>";
	_msg = _msg + "<t color='#000000'>" + "Time left:"+"</t>";
	_msg = _msg + "<t color='#ff0000'>" + format ["%1",100 - floor time max 0];
	(_disp displayCtrl 301) ctrlSetStructuredText parseText _msg;
//... lots of stuff not needed to show here...
	sleep 0.123;
};
};

So yeah, the command works at least.

Note that I was never lucky trying to use the ctrlSetText [idc, text] format. Only idc ctrlSetText text works. Also note that every time I try to use structuredText, I end up messing around for ages before it actually works, and I never understand what the problem was. Finally, try obtaining idd from onLoad code rather than messing with findDisplay and static idds. Something I remember from earlier is that I could never get variables to work with idds, I had to use hardcoded numbers rather than variables, and it never made sense to me why. Not sure if this is fixed, I quit using static idds long time ago.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

Thanks CarlGustaffa

What do you mean by onLoad code ?

I am creating a set of control examples that I will be able to copy/paste later. I am trying to create a rectangle with scrollable text so I am using a "control group" control that has inside a "text" control.

The reason I need structured text is because I noticed (1 year ago) that it wrapped around inside the "control group" while "text" control doesn't. At that time I could set the text using ctrlSetStructuredText, findDisplay and displayCtrl commands.

Maybe I should look into the uinamespace thing

Share this post


Link to post
Share on other sites

I found the solution :

When defining the dialog in description.ext do this :

class OPT_DIAG_OPTIONS
{
idd = _IDD_OPTIONS_;
movingEnable = true;
onLoad = "uiNamespace setVariable ['myDisplay', (_this select 0)]";
...

now use this to retrieve the dialog object in SQF script:

uiNamespace getVariable "myDisplay" displayCtrl _IDC_DEX_0_TXT_CGPEXAMPLE_CONTENT_ ctrlSetStructuredText parseText "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

Share this post


Link to post
Share on other sites

Now that I can set the text value for my structured text control I am encountering another problem:

I have a structured text control with a black background. The background is 3 times higher than the font size defined for this control. Although the valign attribute is set to "middle" I cannot make the text be vertically centered relative to the background.

Anyone succeeded having a vertically centered structured text ?

Share this post


Link to post
Share on other sites

I can't get this to work. I need to define some structured text outside of the description file, then show the text inside a dialog box. I have tried that onLoad method and nothing shows up. Can anyone explain how it is done?

Share this post


Link to post
Share on other sites

UpUp, I also don't know how to use ctrlSetStructuredText, don't know how to cite right control

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
Sign in to follow this  

×