Jump to content
lawman_actual

Difficulty Setting Up 'Tree' GUI control

Recommended Posts

Hey you wonderful people

 

I'm trying to set up a GUI that includes a 'tree' type control, but I can't seem to figure it out on my own.

Here's what I've set up thus far:

 

 

description.ext:

#include "defines.hpp"
#include "dialogs.hpp"

defines.hpp (extracts from):

#define CT_TREE 12
//Experimental
class _CT_TREE
		{
			access = 0; // Control access (0 - ReadAndWrite, 1 - ReadAndCreate, 2 - ReadOnly, 3 - ReadOnlyVerified)
			idc = CT_TREE; // Control identification (without it, the control won't be displayed)
			type = CT_TREE; // Type is 12
			style = ST_LEFT; // Style
			default = 0; // Control selected by default (only one within a display can be used)
			blinkingPeriod = 0; // Time in which control will fade out and back in. Use 0 to disable the effect.

			x = 12 * GUI_GRID_CENTER_W + GUI_GRID_CENTER_X; // Horizontal coordinates
			y = 3 * GUI_GRID_CENTER_H + GUI_GRID_CENTER_Y; // Vertical coordinates
			w = 10 * GUI_GRID_CENTER_W; // Width
			h = 3 * GUI_GRID_CENTER_H; // Height

			colorBorder[] = {0,0,0,1}; // Frame color

			colorBackground[] = {0.2,0.2,0.2,1}; // Fill color
			colorSelect[] = {1,0.5,0,1}; // Selected item fill color (when multiselectEnabled is 0)
			colorMarked[] = {1,0.5,0,0.5}; // Marked item fill color (when multiselectEnabled is 1)
			colorMarkedSelected[] = {1,0.5,0,1}; // Selected item fill color (when multiselectEnabled is 1)

			sizeEx = GUI_GRID_CENTER_H; // Text size
			font = GUI_FONT_NORMAL; // Font from CfgFontFamilies
			shadow = 1; // Shadow (0 - none, 1 - N/A, 2 - black outline)
			colorText[] = {1,1,1,1}; // Text color
			colorSelectText[] = {1,1,1,1}; // Selected text color (when multiselectEnabled is 0)
			colorMarkedText[] = {1,1,1,1}; // Selected text color (when multiselectEnabled is 1)

			tooltip = "CT_TREE"; // Tooltip text
			tooltipColorShade[] = {0,0,0,1}; // Tooltip background color
			tooltipColorText[] = {1,1,1,1}; // Tooltip text color
			tooltipColorBox[] = {1,1,1,1}; // Tooltip frame color

			multiselectEnabled = 0; // Allow selecting multiple items while holding Ctrl or Shift
			expandOnDoubleclick = 0; // Expand/collapse item upon double-click
			//hiddenTexture = "A3\ui_f\data\gui\rsccommon\rsctree\hiddenTexture_ca.paa"; // Expand icon
			//expandedTexture = "A3\ui_f\data\gui\rsccommon\rsctree\expandedTexture_ca.paa"; // Collapse icon
			maxHistoryDelay = 1; // Time since last keyboard type search to reset it

			// Scrollbar configuration
			class ScrollBar
			{
				width = 0; // width of ScrollBar
				height = 0; // height of ScrollBar
				scrollSpeed = 0.01; // scroll speed of ScrollBar

				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)

				color[] = {1,1,1,1}; // Scrollbar color
			};

			colorDisabled[] = {0,0,0,0}; // Does nothing, but must be present, otherwise an error is shown
			colorArrow[] = {0,0,0,0}; // Does nothing, but must be present, otherwise an error is shown

			//onCanDestroy = "systemChat str ['onCanDestroy',_this]; true";
			//onDestroy = "systemChat str ['onDestroy',_this]; false";
			//onMouseEnter = "systemChat str ['onMouseEnter',_this]; false";
			//onMouseExit = "systemChat str ['onMouseExit',_this]; false";
			//onSetFocus = "systemChat str ['onSetFocus',_this]; false";
			//onKillFocus = "systemChat str ['onKillFocus',_this]; false";
			//onKeyDown = "systemChat str ['onKeyDown',_this]; false";
			//onKeyUp = "systemChat str ['onKeyUp',_this]; false";
			//onMouseButtonDown = "systemChat str ['onMouseButtonDown',_this]; false";
			//onMouseButtonUp = "systemChat str ['onMouseButtonUp',_this]; false";
			//onMouseButtonClick = "systemChat str ['onMouseButtonClick',_this]; false";
			//onMouseButtonDblClick = "systemChat str ['onMouseButtonDblClick',_this]; false";
			//onMouseZChanged = "systemChat str ['onMouseZChanged',_this]; false";
			//onMouseMoving = "";
			//onMouseHolding = "";

			//onTreeSelChanged = "systemChat str ['onTreeSelChanged',_this]; false";
			//onTreeLButtonDown = "systemChat str ['onTreeLButtonDown',_this]; false";
			//onTreeDblClick = "systemChat str ['onTreeDblClick',_this]; false";
			//onTreeExpanded = "systemChat str ['onTreeExpanded',_this]; false";
			//onTreeCollapsed = "systemChat str ['onTreeCollapsed',_this]; false";
			//onTreeMouseMove = "systemChat str ['onTreeMouseMove',_this]; false"; // Causing CTD
			//onTreeMouseHold = "systemChat str ['onTreeMouseHold',_this]; false"; // Causing CTD
			//onTreeMouseExit = "systemChat str ['onTreeMouseExit',_this]; false";
		};

dialogs.hpp: (extracts from)

class providerTree: _CT_Tree
{
	idc = 1500;
	text = "" //--- ToDo: Localize;
	x = 0.25;
	y = -0.02;
	w = 0.4;
	h = 0.18;
};

The rest of the dialog works fine (so far), and although the background of the tree is displayed I get the following message displayed upon opening the GUI:

 

 

"No entry 'C:\Users...     *Mission Name*\description.ext\fireMissionPage1\controls\providerTree.colorPicture'.

 

So my guess is it's looking in the description.ext (which includes defines.hpp) for a line that defines a picture to be displayed for the tree?

What I can't figure out is what to write in so as to say "no picture" or flat colour or something.

 

As you can see there's nothing under the 'text' field, which i think I'm saying is where you would include an image file path?

 

 

 

 

Anyway, help please :D

Share this post


Link to post
Share on other sites

*Mission Name*\description.ext\fireMissionPage1\controls\providerTree.colorPicture
You can see it's the path to your class `providerTree`, it's looking for a property `colorPicture` within that class which isn't defined.

So try adding that property like so:

colorPicture[] = {1,1,1,1};

Share this post


Link to post
Share on other sites

Thanks Spike; success.

 

FYI for future readers, the same also occured for a bunch of other picture-based parameters.

Here's the additional fields to need to add on top of the recommended class given by the biki:

	colorPicture[] = {1,1,1,0};
	colorPictureSelected[] = {1,1,1,0};
	colorPictureDisabled[] = {1,1,1,0};
	colorPictureRight[] = {1,1,1,0}; 	
	colorPictureRightSelected[] = {1,1,1,0}; 
	colorPictureRightDisabled[] = {1,1,1,0}; 

Now all I have to do is work out how to add information to the tree at the different levels...

Share this post


Link to post
Share on other sites

Aye, thanks Hover.

 

I did manage to find that in the end, but was surprised the tv command family wasn't mentioned in the ct_tree biki page

Share this post


Link to post
Share on other sites

Hey all. I have some issue with this script. I have experiance with scripts and i make my own scripts is well, but this one! Oh gosh, i fight with this about 7 hours and i give up, so i ask about help please. I doo all the same like in this guide but i have next error after activate the script 

3OPp0VV.png

 

if some body know please help me =)

Share this post


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

Can you show your defines.hpp ? 

Hi! Thanks for answer.

There is

defines.hpp

#define CT_TREE 12
#define MyTag_ST_LEFT           		0x00	//left aligned text

//Experimental
class Tree_buRusskiy
		{
			access = 0; // Control access (0 - ReadAndWrite, 1 - ReadAndCreate, 2 - ReadOnly, 3 - ReadOnlyVerified)
			idc = 890500; // Control identification (without it, the control won't be displayed)
			type = 12; // Type is 12
			style = ST_LEFT; // Style
			default = 0; // Control selected by default (only one within a display can be used)
			blinkingPeriod = 0; // Time in which control will fade out and back in. Use 0 to disable the effect.

			x = 12 * GUI_GRID_CENTER_W + GUI_GRID_CENTER_X; // Horizontal coordinates
			y = 3 * GUI_GRID_CENTER_H + GUI_GRID_CENTER_Y; // Vertical coordinates
			w = 10 * GUI_GRID_CENTER_W; // Width
			h = 3 * GUI_GRID_CENTER_H; // Height

			colorBorder[] = {0,0,0,1}; // Frame color

			colorBackground[] = {0.2,0.2,0.2,1}; // Fill color
			colorSelect[] = {1,0.5,0,1}; // Selected item fill color (when multiselectEnabled is 0)
			colorMarked[] = {1,0.5,0,0.5}; // Marked item fill color (when multiselectEnabled is 1)
			colorMarkedSelected[] = {1,0.5,0,1}; // Selected item fill color (when multiselectEnabled is 1)

			sizeEx = GUI_GRID_CENTER_H; // Text size
			font = GUI_FONT_NORMAL; // Font from CfgFontFamilies
			shadow = 1; // Shadow (0 - none, 1 - N/A, 2 - black outline)
			colorText[] = {1,1,1,1}; // Text color
			colorSelectText[] = {1,1,1,1}; // Selected text color (when multiselectEnabled is 0)
			colorMarkedText[] = {1,1,1,1}; // Selected text color (when multiselectEnabled is 1)

			tooltip = "CT_TREE"; // Tooltip text
			tooltipColorShade[] = {0,0,0,1}; // Tooltip background color
			tooltipColorText[] = {1,1,1,1}; // Tooltip text color
			tooltipColorBox[] = {1,1,1,1}; // Tooltip frame color

			multiselectEnabled = 0; // Allow selecting multiple items while holding Ctrl or Shift
			expandOnDoubleclick = 0; // Expand/collapse item upon double-click
			//hiddenTexture = "A3\ui_f\data\gui\rsccommon\rsctree\hiddenTexture_ca.paa"; // Expand icon
			//expandedTexture = "A3\ui_f\data\gui\rsccommon\rsctree\expandedTexture_ca.paa"; // Collapse icon
			maxHistoryDelay = 1; // Time since last keyboard type search to reset it

			// Scrollbar configuration
			class ScrollBar
			{
				width = 0; // width of ScrollBar
				height = 0; // height of ScrollBar
				scrollSpeed = 0.01; // scroll speed of ScrollBar

				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)

				color[] = {1,1,1,1}; // Scrollbar color
			};

			colorDisabled[] = {0,0,0,0}; // Does nothing, but must be present, otherwise an error is shown
			colorArrow[] = {0,0,0,0}; // Does nothing, but must be present, otherwise an error is shown


			//onCanDestroy = "systemChat str ['onCanDestroy',_this]; true";
			//onDestroy = "systemChat str ['onDestroy',_this]; false";
			//onMouseEnter = "systemChat str ['onMouseEnter',_this]; false";
			//onMouseExit = "systemChat str ['onMouseExit',_this]; false";
			//onSetFocus = "systemChat str ['onSetFocus',_this]; false";
			//onKillFocus = "systemChat str ['onKillFocus',_this]; false";
			//onKeyDown = "systemChat str ['onKeyDown',_this]; false";
			//onKeyUp = "systemChat str ['onKeyUp',_this]; false";
			//onMouseButtonDown = "systemChat str ['onMouseButtonDown',_this]; false";
			//onMouseButtonUp = "systemChat str ['onMouseButtonUp',_this]; false";
			//onMouseButtonClick = "systemChat str ['onMouseButtonClick',_this]; false";
			//onMouseButtonDblClick = "systemChat str ['onMouseButtonDblClick',_this]; false";
			//onMouseZChanged = "systemChat str ['onMouseZChanged',_this]; false";
			//onMouseMoving = "";
			//onMouseHolding = "";

			//onTreeSelChanged = "systemChat str ['onTreeSelChanged',_this]; false";
			//onTreeLButtonDown = "systemChat str ['onTreeLButtonDown',_this]; false";
			//onTreeDblClick = "systemChat str ['onTreeDblClick',_this]; false";
			//onTreeExpanded = "systemChat str ['onTreeExpanded',_this]; false";
			//onTreeCollapsed = "systemChat str ['onTreeCollapsed',_this]; false";
			//onTreeMouseMove = "systemChat str ['onTreeMouseMove',_this]; false"; // Causing CTD
			//onTreeMouseHold = "systemChat str ['onTreeMouseHold',_this]; false"; // Causing CTD
			//onTreeMouseExit = "systemChat str ['onTreeMouseExit',_this]; false";
		};

 

dialogs.hpp

class providerTree: Tree_buRusskiy
{
	idc = 859550;
	text = "" //--- ToDo: Localize;
	x = 0.25;
	y = -0.02;
	w = 0.4;
	h = 0.18;
};

 

Share this post


Link to post
Share on other sites

Hi again. I find the problem!

There vas main class

was "adc = somethink" should be "idd = somethink"

so now is fine but i still have nothink))) I can understand to dialog is opened cause i can see the mouse icon come-out and standart controls stop working only working if i press ESC

so dialog work but now i need some support if is possible how to make bacground and all thinks.

If you could help please =)

Share this post


Link to post
Share on other sites
10 minutes ago, xjoker_ said:

Ok and your description.ext ?

 

Hi again. I find the problem!

There vas main class

was "adc = somethink" should be "idd = somethink"

so now is fine but i still have nothink))) I can understand to dialog is opened cause i can see the mouse icon come-out and standart controls stop working only working if i press ESC

so dialog work but now i need some support if is possible how to make bacground and all thinks.

If you could help please =)

Share this post


Link to post
Share on other sites

Hi all!

 

I'm trying to give to each tree child a command, but unfortunately till here I just made some finite list of errors...

Now, this part of the below code working, but I've little experience on UI scripting and I really have no idea to how assign a command on each child, thanks in advance.

tvClear 456;
[] spawn
{
	disableSerialization;
	_display = findDisplay 1500;
	{
		tvAdd [456,[], _x];
	} forEach ["PARENT 1","PARENT 2"];
	{
		tvAdd [456,[0], _x];
	} forEach ["CHILD 1","CHILD 2"];
	{
		tvAdd [456,[1], _x];
	} forEach ["CHILD 3","CHILD 4"];
};

 

Share this post


Link to post
Share on other sites

Hello @Fr3eMan

 

As an example:

private["_tree","_parentIndex","_childIndex","_grandChildIndex"];

disableSerialization;

_tree = (findDisplay 1500) displayCtrl 456;

// Clear tree
tvClear _tree;

// Create parent
_parentIndex = _tree tvAdd [[],"PARENT"];

// Create child
_childIndex = _tree tvAdd [[_parentIndex],"CHILD"];

// Create grand child
_grandChildIndex = _tree tvAdd [[_parentIndex,_childIndex],"GRAND CHILD"];

Check the Notes part here https://community.bistudio.com/wiki/tvAdd

  • Thanks 1

Share this post


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

have no idea to how assign a command on each child,

What do you mean by command? Make something happen when an item is selected? If so you need to use an eventHandler on the tree of "TreeSelChanged", "TreeLButtonDown" or "TreeDblClick" depending on the type of interaction you want, see this Biki link for available tree EH's.

 

Little example to hint back the path of the item selected, just run from the debugConsole in mission preview.

h = [] spawn {
	disableSerialization;
	
	_display = findDisplay 46 createDisplay "RscDisplayEmpty";
	_tree = _display ctrlCreate [ "ctrlTree", 100 ];
	_tree ctrlSetPosition[ 0, 0, 1, 1 ];
	_tree ctrlCommit 0;
	
	tvClear _tree;

	{
		_tree tvAdd [ [], _x ];
	} forEach ["PARENT 1","PARENT 2"];
	{
		_tree tvAdd [ [0], _x ];
	} forEach ["CHILD 1","CHILD 2"];
	{
		_tree tvAdd [ [1], _x ];
	} forEach ["CHILD 3","CHILD 4"];

	_tree ctrlAddEventHandler [ "TreeSelChanged", {
		params[ "_tree", "_path" ];
		
		_selected = "";
		{
			_selected = format[ "%1 %2 %3",
				_selected, //Any previous text
				[ "", ">>" ]select( _forEachIndex > 0 ), //Add >> only after first path item
				( _tree tvText ( _path select [ 0, _forEachIndex + 1 ] )) //tree items displayed text
			];
		}forEach _path;
		
		hint format[ "You Selected\n%1", _selected ]; //eg "PARENT 1 >> CHILD 2"
	}];
};

 

  • Thanks 1
  • Haha 1

Share this post


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

What do you mean by command? Make something happen when an item is selected?

 

Yes, I tried to use onTreeDblClick but probably i make some mistakes.

Anyway also this information are very helpful, for what I saw there aren't much sample about this kind of UI, I will try rewrite the script better.

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

×