Jump to content
IndeedPete

RscStructuredText with ScrollBar

Recommended Posts

Hi,

since it hasn't been answered in the top search results yet I would like to ask the same. How can I / is it possible to automatically add a ScrollBar to a RscStructuredText once the structured text exceeds the given window size?

I assume this is possible since e.g. briefings are usually structured text and the game automatically adds scrollbars to briefings if the text / pictures are long / big enough. Maybe even a Dev could throw in some words?

Any help is appreciated!

Share this post


Link to post
Share on other sites

Bump. It's not really a pressing matter, more like a basic question. Maybe others are interested as well?

Share this post


Link to post
Share on other sites

I think you need to just define them:

class VScrollbar 	
       {	
               color[] = {1, 1, 1, 0.6};	
               width = 0.021;	
               autoScrollSpeed = -1;	
               autoScrollDelay = 5;	
               autoScrollRewind = 0;	
               shadow = 0;	
       };	

       class HScrollbar 	
       {	
               color[] = {1, 1, 1, 0.6};	
               height = 0.028;	
               shadow = 0;	
       };	

       class ScrollBar {	
               color[] = {1, 1, 1, 0.6};	
               colorActive[] = {1, 1, 1, 1};	
               colorDisabled[] = {1, 1, 1, 0.3};	
               thumb = "\A3\ui_f\data\gui\cfg\scrollbar\thumb_ca.paa";	
               arrowFull = "\A3\ui_f\data\gui\cfg\scrollbar\arrowFull_ca.paa";	
               arrowEmpty = "\A3\ui_f\data\gui\cfg\scrollbar\arrowEmpty_ca.paa";	
               border = "\A3\ui_f\data\gui\cfg\scrollbar\border_ca.paa";	
       };

Then add them:

class RscDisplayTest
{
idd = 3000;
       type = CT_COMBO;
movingenable = false;


class Controls
{  
               class MyTextBox: RscStructuredText
	{
                       type = CT_STRUCTURED_TEXT
                       style = ST_MULTI;
                       lineSpacing = 1;
		idc = 1235;
                       size = 0.09;                      
	        text = " ";   
		x = 0.32815 * safezoneW + safezoneX;
		y = 0.4575 * safezoneH + safezoneY;
		w = 0.343 * safezoneW;
		h = 0.315 * safezoneH;
		class MyTextBoxScroll: ScrollBar 
		{
		};
	};


};
};

I don't know if this will work or not, but defining the scroll bar in the control would seem to be the way to get it included if RscStructuredText can support a scroll bar.

Oh and all of the code I quoted can't be used without SA-MATRA's direct permission if you care what he thinks LOL. :D

Share this post


Link to post
Share on other sites

Hey, thanks for the reply, but that doesn't seem to work for me. :/

Share this post


Link to post
Share on other sites

Bump on the main topic.

And a second question I hopefully get solved: Is it possible to change the colour of the structured text in a RscStructuredText by using tags? In my defines.hpp the text is defined as simple white. But I'd like to change that from the calling script depending on what I pass to the script.

So I've tried it like this:

_text = "<t color='0000ff'>" + _groupID + ": " + _sentence + "</t>";
cutRsc ["IP_DLG_SIMPLESENTENCE", "PLAIN"]; 
((uiNamespace getVariable "DLG_SimpleSentence") displayCtrl 1100) ctrlSetStructuredText (parseText _text);

But of course, that didn't work. :/

Share this post


Link to post
Share on other sites

I think you need to add # in front of the color code. So color="#ff0000". Wondering about the scrollbar as well

Sent from my MI 2 using Tapatalk

Share this post


Link to post
Share on other sites

Silly me, I was messing around with variables and #define for the colour problem but somehow built the string wrong. If I do it hard-coded it's working perfectly, thank you!

As for the scrollbar: still no luck.

Share this post


Link to post
Share on other sites

None that I know - maybe it's something for the feedback tracker?

Share this post


Link to post
Share on other sites

Have you tried putting it into an RscControlsGroup?

RscControlsGroup puts on the scrollbar if one of its control doesn't fit.

Of course you'll need to make the structured text size bigger as well.

I've had similiar issue with my Gear Panel:

The wide scrollbar on the left is the lnb scrollbar (left panel is pure long lnb list), the narrow one in the middle panel uses what I talked about above, the RscControlsGroup scrollbar: because the contents wouldn't fit otherwise.

Share this post


Link to post
Share on other sites

I got this code from a site(http://ru.armacomref.wikia.com/wiki/Dialog_Control) however I can't get it to work :S

class My_RscControlsgroup  
{
	type = 15;
	idc = -1;
	style = 0;
	x = (safeZoneX + (SafezoneW * 0.0363));  // scalability code which resizes correctly no matter what gui size or screen dimensions is used
	y = (safeZoneY + (SafezoneH * 0.132));   // scalability code which resizes correctly no matter what gui size or screen dimensions is used
	w = (SafezoneW  * 0.31);                 // scalability code which resizes correctly no matter what gui size or screen dimensions is used
	h = (SafezoneH  * 0.752);                // scalability code which resizes correctly no matter what gui size or screen dimensions is used

	class VScrollbar 
	{
		color[] = {1, 1, 1, 1};
		width = 0.021;
		autoScrollSpeed = -1;
		autoScrollDelay = 5;
		autoScrollRewind = 0;
	};

	class HScrollbar 
	{
		color[] = {1, 1, 1, 1};
		height = 0.028;
	};

	class ScrollBar
	{
		color[] = {1,1,1,0.6};
		colorActive[] = {1,1,1,1};
		colorDisabled[] = {1,1,1,0.3};
		thumb = "#(argb,8,8,3)color(1,1,1,1)";
		arrowEmpty = "#(argb,8,8,3)color(1,1,1,1)";
		arrowFull = "#(argb,8,8,3)color(1,1,1,1)";
		border = "#(argb,8,8,3)color(1,1,1,1)";
	};

	class Controls 
	{
		class My_RscStructuredText  
		{
			idc = 55;
			colorBackground[] = {1,1,1,0.3}; 
			x = 0;
			y = 0;
			w = (SafezoneW  * 0.3);
			h = (SafezoneH  * 3);
			text	= "";
			size = 0.02; 
			class Attributes 
			{ 
				font = "TahomaB"; 
				color = "#106A1A"; 
				align = "center"; 
				valign = "middle"; 
				shadow = false; 
				shadowColor = "#ff0000"; 
				size = "1";
			}; 
		}; 
	};
};

Share this post


Link to post
Share on other sites

So... anybody know how to do this yet? I first tried to make a structured text control with a scrollbar in Arma 2 about 4 years ago and gave up because I couldn't find any info on how to do it. Now I want to give it another shot but I'm still not finding anyone who knows how.

EDIT

Ok, after zapat mentioned RscControlsGroup (never heard of that before), I found the answer after reading this and using this as an example.

To be clear for anyone having trouble with this, here's how it should be laid out in the description.ext :

First define your RscControlsGroup, outwith your dialog as if you're defining RscStructuredText or something:

    class RscControlsgroup  
    {
    	type = CT_CONTROLS_GROUP;
    	idc = -1;
    	style = ST_MULTI;
    	x = (safeZoneX + (SafezoneW * 0.0163));  // scalability code which resizes correctly no matter what gui size or screen dimensions is used
    	y = (safeZoneY + (SafezoneH * 0.132));   
    	w = (SafezoneW  * 0.31);                 
    	h = (SafezoneH  * 0.752);              

    	class VScrollbar 
    	{
    		color[] = {0.5, 0.5, 0.5, 1};
    		width = 0.015;
    		autoScrollSpeed = -1;
    		autoScrollDelay = 0;
    		autoScrollRewind = 0;
	     arrowEmpty = "\A3\ui_f\data\gui\cfg\scrollbar\arrowEmpty_ca.paa"; // Arrow 
	     arrowFull = "\A3\ui_f\data\gui\cfg\scrollbar\arrowFull_ca.paa"; // Arrow when clicked on 
	     border = "\A3\ui_f\data\gui\cfg\scrollbar\border_ca.paa"; // Slider background (stretched vertically) 
	     thumb = "\A3\ui_f\data\gui\cfg\scrollbar\thumb_ca.paa"; // Dragging element (stretched vertically) 
    	};

    	class HScrollbar 
    	{
    		color[] = {1, 1, 1, 1};
    		height = 0.028;
    	};

    	class ScrollBar
    	{
    		color[] = {1,1,1,0.6};
    		colorActive[] = {1,1,1,1};
    		colorDisabled[] = {1,1,1,0.3};
	     arrowEmpty = "\A3\ui_f\data\gui\cfg\scrollbar\arrowEmpty_ca.paa"; // Arrow 
	     arrowFull = "\A3\ui_f\data\gui\cfg\scrollbar\arrowFull_ca.paa"; // Arrow when clicked on 
	     border = "\A3\ui_f\data\gui\cfg\scrollbar\border_ca.paa"; // Slider background (stretched vertically) 
	     thumb = "\A3\ui_f\data\gui\cfg\scrollbar\thumb_ca.paa"; // Dragging element (stretched vertically) 
    	};

    	class Controls {};
    };

Then this is what your structured text control looks like in your dialog, obviously with your own size data and idcs, etc:

class myDialog 
{
       //stuff
   class controls
   {
	class myControl: RscControlsGroup {    //--- inherits from RscControlsGroup already defined
		idc = 200908;
		x = 0.365; 
		y = 0.2475; 
		w = 0.48; 
		h = 0.592;
		sizeEx = 0.03;
		class Controls
		{
			class myControl_a: RscStructuredText
			{
				idc = 2009081;
				x = 0;//0.65;
				y = 0;//0.2;
				w = 0.45;
				h = 1;
				size = 0.05;
				colorBackground[] = {1,0.4,0.2,0};    //--- this background is transparent, increase alpha value so you can see the control area while tweaking it
			};
		};
	};
   };
};

The height value (h) in the structured text control has to be higher than the one in the parent control in order for the scrollbar to appear. If you can't see a scrollbar, it's probably because your control is too wide.

Edited by 2nd Ranger
Added UI elements for nicer scroll bar
  • Like 1

Share this post


Link to post
Share on other sites

1. Have RscStructuredText inside RscControlsGroup

2. Save RscStructuredText height with ctrlPosition command (old text height)

3. Set text to RscStructuredText

4. Get text height with https://community.bistudio.com/wiki/ctrlTextHeight command (new text height)

5. Increase RscControlsGroup size according to new height (new text height - old text height) with ctrlSetPosition command.

Edited by SaMatra
  • Like 3

Share this post


Link to post
Share on other sites

Ah, that's some great intel, thanks guys! Finally, a solution to this problem.

Share this post


Link to post
Share on other sites

Thanks for the help guys! I followed this topic instructions to get a horizontal scroll bar on a estructured text frame at my dialog. Just for feedback, this was the code that worked for me, following the Samatra´s last post steps:

 

_control = findDisplay 10 displayCtrl 1100; // use your idd and idcs for the structured text control as defined in your dialog.
_myControlPos = ctrlPosition _control; // array with control position and heigth of the control [x,y,z,h];
_oldH = _myControlPos select 3; // saves old heigth (point 2 at Samatra´s post)

 

/// Modify your text (point 3 at Samatra post)

_control ctrlSetStructuredText parsetext _Text;

...

/// End of text modifications

 

_newH = ctrlTextHeight _control; //save new Height of the text modified. (Point 4 at Samatra´s post)

 

_x = _myControlPos select 0;

_y = _myControlPos select 1;
_z = _myControlPos select 2;
 

_control ctrlSetPosition [_x,_y,_z,_newH]; // Set new heigth. (Point 5 at Samatra´s post). In my case,  I just applied the new Heigh, not the diference between new and old ones. (It worked for my in that way. Not sure why, but I finally not used the _oldH variable)

 

_control ctrlCommit 0; //Mandatory for 2D controls to commit changes.

 

Hope it helps!

 

Regards,
Spikeslf.

 

 

  • Like 2

Share this post


Link to post
Share on other sites
18 hours ago, spikeslf said:

 

_control ctrlSetPosition [_x,_y,_z,_newH]; // Set new heigth. (Point 5 at Samatra´s post). In my case,  I just applied the new Heigh, not the diference between new and old ones. (It worked for my in that way. Not sure why, but I finally not used the _oldH variable)

Great that it worked for you. My post assumed that you had other controls inside controls group or structured text had margin inside the group, my method takes all these possibilities into account. If you have nothing but structured text right inside the group, you can directly set new height to ctrlTextHeight result, just like you did.

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

×