Jump to content
Mr H.

GUI Grouping controls under the same idc without using controls groups

Recommended Posts

Hi, In my dialogs.hpp I'd like to group several controls under one common idc (so that i can do ctrlshow [_group, true] or false to hide and show the whole group. I'm currently using rscControlsgroup as a parent to achieve that but it is not satisfying because safezone size and positions params of controls inside the controlsgroup are relative to the controlsgroup position and dimension. I have tried grouping them like this:
 


class Group1 : RscControlsGroupMRHSAT
{
	idc = 1208;
	show = false;
		class controls 
	{

class MRHMarkings: RscPictureMRHSAT
{
	idc = 1231;
	//show = false;
	text = "MRHSatellite\Paa\screenmarks.paa";
	x = 0.250625 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.49875 * safezoneW;
	h = 0.49 * safezoneH;
};
class MRHAltitudeName: RscStructuredTextMRHSAT
{
	idc = 1204;
	text = "Altitude";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.192 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHAltitudeDisplay: RscStructuredTextMRHSAT
{
	idc = 1205;
	text = "AltDisplay";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.22 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHViewModeName: RscStructuredTextMRHSAT
{
	idc = 1206;
	text = "View Mode";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.248 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHViewModeDisplay: RscStructuredTextMRHSAT
{
	idc = 1207;
	text = "ViewDisplay";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.276 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHSlider: RscSliderMRHSAT
{
	idc = 1202;
	
	 type = CT_SLIDER; 
	 style = SL_VERT;
	x = 0.716563 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.0328125 * safezoneW;
	h = 0.49 * safezoneH;
	    color[] = { 1, 1, 1, 1 }; 
        coloractive[] = { 1, 0, 0, 0.5 };
	//onLoad = "call MRH_fnc_SetSatRange;";
	onSliderPosChanged = "((findDisplay 9751) displayCtrl 1205) ctrlSetStructuredText parsetext (str (round (_this select 1))); _cam = missionNamespace getVariable ""SATCAM""; _cam setPos [(getpos _cam select 0), (getpos _cam select 1), (_this select 1)];";
};

	};
};

that is to say without assigning position/dimension settings to the controls group itself.
And surprisingly enough it seemed to work... Until I tried changing to different UI sizes and then it all got fucked up.
So basically is there a way to group controls under a same idc without using controlsgroups?

Share this post


Link to post
Share on other sites

Why not write a small script which hides the controls invidually? That's done very quickly and the user won't notice it.

Share this post


Link to post
Share on other sites

that is  my currently working fix, but i'd like to avoid that, just for the sake of clarity and for the sake of trying things out ^^

Share this post


Link to post
Share on other sites
2 hours ago, Hadrien Melville said:

that is  my currently working fix, but i'd like to avoid that, just for the sake of clarity and for the sake of trying things out ^^

 

Fair enough! I don't know of any way to do this.  I always defined the position of the whole group with safezones and the sizes inside the controls. That always works for me.

Share this post


Link to post
Share on other sites

Group your control into a display. You can do what you want (almost) with variables.

Example better than speech (from my Addon):


 

    class JDoe_profile
     {
    idd = -1;
    duration = 100000;
    fadein = 0;
    fadeout = 0;
    name="JDoe_profiler";
    onLoad = "uiNamespace setVariable ['JDoe_Identification', _this select 0]";
    controls[]= {JDoe_ident,JDoe_comment,icon_wng,icon_wng_dead};

        class JDoe_ident: RscPicture
        {
        idc = 2260;
        text = "";
        x = "uiNamespace getVariable 'ident_x'";
        y = "uiNamespace getVariable 'ident_y'";
        w = "uiNamespace getVariable 'ident_w'";
        h = "uiNamespace getVariable 'ident_h'";
        };

        class JDoe_comment: RscStructuredText
        {
        idc = 2261;
        x = 0.01 * safezoneW + safezoneX;
        y = 0.6 * safezoneH + safezoneY;
        w = 0.1625 * safezoneW;
        h = 0.08 * safezoneH;
        };

        class icon_wng: RscPicture
        {
        idc = 2262;
        x = 0.08 * safezoneW + safezoneX;
        y = 0.5 * safezoneH + safezoneY;
        w = 0.02 * safezoneW;
        h = 0.02*4/3 * safezoneH;
        };

        class icon_wng_dead: RscPicture
        {
        idc = 2263;
        x = 0.10 * safezoneW + safezoneX;
        y = 0.34 * safezoneH + safezoneY;
        w = 0.06 * safezoneW;
        h = 0.06*4/3 * safezoneH;
        };
    };

 

for idc 2260, you need to script something like:

uiNameSpace setVariable ["ident_x", pict_x * safezoneW + safezoneX];
uiNameSpace setVariable ["ident_y", pict_y * safezoneH + safezoneY];
uiNameSpace setVariable ["ident_w", pict_w * safezoneW];
uiNameSpace setVariable ["ident_h", pict_h * 4/3 *safezoneH];

 

playing with variables, pict_x,pict_y.... or what ever names you want.

and, of course your display controls like:

  _ident_JDoe = (uiNameSpace getVariable "JDoe_Identification") displayCtrl 2260;
  _ident_JDoe ctrlSetText ident_match;
  _ident_JDoe ctrlSetBackgroundColor [1, 1, 1, brit/2 ];

Share this post


Link to post
Share on other sites

yes but can't you group the controls inside another control? Like in a RcControlGroup, but without the position being taken into account? Beause the group itself would be part of a larger display group.
Here's the full hpp:
 

class MRHSatellite
{
	idd=9751;
	movingenable=false;
	
	class controls 
	{

////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT START (by Mr H., v1.063, #Giqaqu)
////////////////////////////////////////////////////////

class MRHLaptopSat: RscPictureMRHSAT
{
	idc = 1200;
	text = "MRHSatellite\Paa\laptop.paa";
	x = 0.00125001 * safezoneW + safezoneX;
	y = -0.00399999 * safezoneH + safezoneY;
	w = 1.01719 * safezoneW;
	h = 1.008 * safezoneH;
};
class MRHScreenzone: RscPictureMRHSAT
{
	idc = 1201;
	text = "MRHSatellite\Paa\welcomescreen.paa";
	onMouseButtonClick = "hint ""testé""; ";//[_this] call MRH_fnc_ConvertCoordinates;
	x = 0.250625 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.49875 * safezoneW;
	h = 0.49 * safezoneH;
};
/*
class Group1 : RscControlsGroupMRHSAT
{
	idc = 1208;
	show = false;
		class controls 
	{
*/
class MRHMarkings: RscPictureMRHSAT
{
	idc = 1231;
	show = false;
	text = "MRHSatellite\Paa\screenmarks.paa";
	
	x = 0.250625 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.49875 * safezoneW;
	h = 0.49 * safezoneH;
};
class MRHAltitudeName: RscStructuredTextMRHSAT
{
	idc = 1204;
	show = false
	text = "Altitude";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.192 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHAltitudeDisplay: RscStructuredTextMRHSAT
{
	idc = 1205;
	show = false
	text = "AltDisplay";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.22 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHViewModeName: RscStructuredTextMRHSAT
{
	idc = 1206;
	show = false
	text = "View Mode";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.248 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHViewModeDisplay: RscStructuredTextMRHSAT
{
	idc = 1207;
	show = false
	text = "ViewDisplay";
	x = 0.63125 * safezoneW + safezoneX;
	y = 0.276 * safezoneH + safezoneY;
	w = 0.0590625 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHSlider: RscSliderMRHSAT
{
	idc = 1202;
	show = false
	 type = CT_SLIDER; 
	 style = SL_VERT;
	x = 0.716563 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.0328125 * safezoneW;
	h = 0.49 * safezoneH;
	    color[] = { 1, 1, 1, 1 }; 
        coloractive[] = { 1, 0, 0, 0.5 };
	//onLoad = "call MRH_fnc_SetSatRange;";
	onSliderPosChanged = "((findDisplay 9751) displayCtrl 1205) ctrlSetStructuredText parsetext (str (round (_this select 1))); _cam = missionNamespace getVariable ""SATCAM""; _cam setPos [(getpos _cam select 0), (getpos _cam select 1), (_this select 1)];";
};
/*
	};
};
*/
class MRHMapTest : RscMapControlMRHSAT
{
	idc = 1777;
	show = false;
	onMouseButtonClick = "hint ""Nouvelle position enregistrée""; [_this] call MRH_fnc_ConvertCoordinates;";
	//onMapSingleClick = "hint ""bouhyah""";
	//text = "#(argb,8,8,3)color(1,1,1,1)";
	x = 0.250625 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.49875 * safezoneW;
	h = 0.49 * safezoneH;
};




class MRHChangeVision: RscButtonMRHSAT
{
	idc = 1600;
	show = false;
	text = "Changer le mode de vue"; //--- ToDo: Localize;
	x = 0.250625 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.118125 * safezoneW;
	h = 0.028 * safezoneH;
	action = "ctrlshow [2100, true];";
};

class MRHOpenMapButton: RscButtonMRHSAT
{
	idc = 1601;
	show = false;
	action = "ctrlshow [1777, true];";
	text = "Changer la position du satellite"; //--- ToDo: Localize;
	x = 0.36875 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.144375 * safezoneW;
	h = 0.028 * safezoneH;
};



class MRHSelectView: RscComboMRHSAT
{
	idc = 2100;
	show = false;
	text = "Default"; //--- ToDo: Localize;
	x = 0.257187 * safezoneW + safezoneX;
	y = 0.15 * safezoneH + safezoneY;
	w = 0.21 * safezoneW;
	h = 0.028 * safezoneH;
	onLBSelChanged = "_value = _this select 1; [_value] call MRH_fnc_SelectViewMode;ctrlshow [2100, false];";
	
    
};
class MRHClosebutton: RscButtonMRHSAT
{
	idc = 1602;
	text = "Fermer"; //--- ToDo: Localize;
	action = "Closedialog 0;";
	x = 0.513125 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.07875 * safezoneW;
	h = 0.028 * safezoneH;
};

class DialogBoxGroup : RscControlsGroupMRHSAT
{
idc = 5001;
show = false;

	class controls
	{
class MRHChooseInitBackGround: RscPictureMRHSAT
{
	idc = 5002;
	text = "MRHSatellite\Paa\interfacewindow.paa";

	x = 0.381875 * safezoneW + safezoneX;
	y = 0.304 * safezoneH + safezoneY;
	w = 0.223125 * safezoneW;
	h = 0.154 * safezoneH;
};
class MRHAcceptButton: RscButtonMRHSAT
{
	idc = 5003;

	text = "Accepter"; //--- ToDo: Localize;
	x = 0.408125 * safezoneW + safezoneX;
	y = 0.416 * safezoneH + safezoneY;
	w = 0.0525 * safezoneW;
	h = 0.028 * safezoneH;
};
class MRHRefuseButton: RscButtonMRHSAT
{
	idc = 5004;

	text = "Annuler"; //--- ToDo: Localize;
	action = "ctrlshow [5001, false];"                //"Closedialog ((findDisplay 9751 5001;";
	x = 0.52625 * safezoneW + safezoneX;
	y = 0.416 * safezoneH + safezoneY;
	w = 0.0525 * safezoneW;
	h = 0.028 * safezoneH;
};

class MRHWarningBoxText: RscStructuredTextMRHSAT
{
	idc = 5006;

	text = "Dummytesttext";
	x = 0.388437 * safezoneW + safezoneX;
	y = 0.318 * safezoneH + safezoneY;
	w = 0.21 * safezoneW;
	h = 0.084 * safezoneH;
};
	};
};

class MRHStaticsoverlay: RscPictureMRHSAT
{
	idc = 1333;
	text = "MRHSatellite\Paa\overlaystatics.paa";
		colorText[] = 
	{
		1,
		1,
		1,
		0.4 //transparencedeloverlay
	};
	x = 0.250625 * safezoneW + safezoneX;
	y = 0.122 * safezoneH + safezoneY;
	w = 0.49875 * safezoneW;
	h = 0.49 * safezoneH;
};

class MRHProgressBar: RscProgressMRHSAT
{
	idc = 6203;
	show =false;
	colorFrame[] = {0.5,0.5,0.5,1};
	colorBar[] = {0,1,0,1};
	//texture = "#(argb,0,8,0)color(1,1,1,1)";
	text = "test"; //#(argb,8,8,3)color(1,1,1,1)
	x = 0.292231 * safezoneW + safezoneX;
	y = 0.51512 * safezoneH + safezoneY;
	w = 0.426562 * safezoneW;
	h = 0.042 * safezoneH;
};

class MRHSatMovingTextBackground: RscPictureMRHSAT
{
	idc = 6204;
	show =false;
	text = "MRHSatellite\Paa\interfacewindow.paa";
	x = 0.618125 * safezoneW + safezoneX;
	y = 0.318 * safezoneH + safezoneY;
	w = 0.0984375 * safezoneW;
	h = 0.14 * safezoneH;
};

class MRHMovingSatTextZone: RscStructuredTextMRHSAT
{
	idc = 6205;
	show =false;
	text = "Dummytext";
	x = 0.624687 * safezoneW + safezoneX;
	y = 0.332 * safezoneH + safezoneY;
	w = 0.0853125 * safezoneW;
	h = 0.112 * safezoneH;
};

////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT END
////////////////////////////////////////////////////////

	};
};

you'll see that' I've commented out the group I'm trying to create. I call each display inside the group with a function by listing them one by one: here's the function: fn_ShowHide1208.sqf

params ["_show"];
switch (true) do {
case _show : {
ctrlshow [1231,true];
ctrlshow [1204,true];
ctrlshow [1205,true];
ctrlshow [1206,true];
ctrlshow [1207,true];
ctrlshow [1202,true];
};
case !_show : {
ctrlshow [1231,false];
ctrlshow [1204,false];
ctrlshow [1205,false];
ctrlshow [1206,false];
ctrlshow [1207,false];
ctrlshow [1202,false];
};
};

what i'd like is to figure out a simpler more elegant way of doing things.
BTW here's the current advancement of the mod

explainations are in french but you'll get the visual side at least

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, Hadrien Melville said:

BTW here's the current advancement of the mod

 

Looks amazing!

Share this post


Link to post
Share on other sites

Play with displays (grouping controls and also called resources). I didn't test with controls grouping controls but differents displays with some controls groups inside are very handy : You have a global variable to display something or not, then other variables to control everything during display (you can even animate an HUD).

See cutRsc for displaying your (grouped controls) displays

Here is an example:

 

  • Like 2

Share this post


Link to post
Share on other sites

 

9 hours ago, pierremgi said:

Play with displays (grouping controls and also called resources). I didn't test with controls grouping controls but differents displays with some controls groups inside are very handy : You have a global variable to display something or not, then other variables to control everything during display (you can even animate an HUD).

See cutRsc for displaying your (grouped controls) displays

 

 

My understanding is that RscTitles let the player keep control over his avatar (not what I'm looking for) while dialogs open an interface and show the mouse arrow, but I'm not a 100% sure I understand your point, do you have a code example that I could use as reference?
also @pierremgi 3 things:
1) I've noticed your answers and comments pretty much everywhere here, on armaholic and on BisWiki, among my  mission making friends you are an urban legend and we consider you a god of arma (along with Nou from ace and acre). ;-)
2) Your video is amazing.
3) I feel like you're the one able to answer a question I have on another problem I'm facing: I'm using PIP to display the satellite camera on a RscPicture control. I'd like to use the screentoworld command (https://community.bistudio.com/wiki/screenToWorld) on the pip view (and not the player's view) but have been unable to achieve this so far. Any ideas?

Share this post


Link to post
Share on other sites

Thanks but be sure there are plenty of more skilled people than me here. I'm hoping Larrow and other Arma masters will rescue me. Anyway, in the mean time, I can share some ideas about your topic. You already know some of them but the BIKI reference could help some other guys also.

As said in BIKI, there is no big difference between displays and controls, but commands are specific: findDisplay, ctrlSet...  Display is usually a layer on screen, as controls are elements of it. The player can act on some of them (scroll bar, pointer), usually through a User Interface Event Handler .

 

So the question about keeping control by the player is just linked to the fact you want to call a display or not via a script and the "type of" control you call. A player doesn't have the hand on hint messages, for example. This can be the same case for elaborated displays. 

BUT.....   Anyway, all you want to display is local (or should be). You can share some variables (public them), like for your satellite's position, but never ever try to broadcast a display! The shared variables are working on local display(s). Displaying or not (cutrsc for instance) is just a question of event in your scenario. You can decide something is displayable with an addAction (then local to a player, under some conditions if you want) or for all players (like a score, the score variables are public and a script runs on every pc to call a local engine display: background, hard text & colors... in which you read these scores).

As you can see, cutRsc is an EL command (that's normal) but you can script something to trigger it on all PCs you need.

 

You can define all you need in .hpp(s), included in description.ext. You don't need a mod (config.cpp) but must give attention to paths. Config.cpp and description.ext don't support the same approach for them. My comments here. See also and other topics about them.

 

Pip are something special. You can create them but you are entering on modders field of skill. You can play with existing pip (each time you find some renderTarget in the config class of an object. You can apply some effects to it but I'm not so skilled to tell you how to point at some working area inside a pip. My HUDs are all based on screen relative positions. I guess the screenToWorld is a wrong approach because world is referring to the landscape (then findDisplay 46) and it can't be applied to pip (not an affirmation, more a feeling).

 

But perhaps, someone here could tell you how to apply ctrlSetPosition in relative coord on pip control (pip seems to be a control, that's the good news).

Sorry I can't help you further.

Have a merry Christmas.

Share this post


Link to post
Share on other sites

It makes little sense to do...

params ["_show"];

switch (true) do {
	case _show : {
		ctrlShow [1231,true];
		ctrlShow [1204,true];
		ctrlShow [1205,true];
		ctrlShow [1206,true];
		ctrlShow [1207,true];
		ctrlShow [1202,true];
	};
	case !_show : {
		ctrlShow [1231,false];
		ctrlShow [1204,false];
		ctrlShow [1205,false];
		ctrlShow [1206,false];
		ctrlShow [1207,false];
		ctrlShow [1202,false];
	};
};

If _show is true/false why switch on its value? Just use _show in the ctrlShow command.

params ["_show"];

ctrlShow [1231,_show];
ctrlShow [1204,_show];
ctrlShow [1205,_show];
ctrlShow [1206,_show];
ctrlShow [1207,_show];
ctrlShow [1202,_show];

Which can be shortened to..

params ["_show"];

{
	ctrlShow [_x,_show];
}forEach [ 1231, 1204, 1205, 1206, 1207, 1202 ];

If you need to use the group in multiple places...

#define MYGROUP [ 1231, 1204, 1205, 1206, 1207, 1202 ]

params[ "_show" ];

{
	ctrlShow[ _x, _show ];
}forEach MYGROUP;

Where you could store all your group defines in their own separate file to be included where necessary.

 

I do not see what the problem is with RscControlsGroup's ctrls being positional relative to the controlGroup. For things like your modal windows I would of thought this would be a blessing as you could make them movable without having to worry about each child controls position. For instance THIS each command component I place in the design panel is a ctrlGroup consisting of multiple child controls and controlGroups, existing in the design panel which itself is a ctrlGroup in the main display, I can move them, scale them, hide them etc without much of a problem due to the fact all children are relevant to their parent ctrlGroup.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you both for your answers, @Larrow, your code is much better than mine which was a quick fix. I have used control groups before but am I correct in assuming that safezone positions are not relative to the size of the ctrl group but to the whole screen?
 @pierremgi my intent is to make this into a mod and I am aware of the issue of paths you mention. (I have passed multiple scripts into mods before). As for the issue of screentoworld on PIP I fear I'm hitting a dead end... I would like to implement some kind of target detection and tracking like the uavs do but am at my wit's end...

Share this post


Link to post
Share on other sites
16 minutes ago, Hadrien Melville said:

I have used control groups before but am I correct in assuming that safezone positions are not relative to the size of the ctrl group but to the whole screen?

If you use safeZoneX and safeZoneY on every control then yes your making your positions offset from the screens top left, inside a ctrlGroup this will make your controls wildly offset. Instead use the pixel grid system where everything is relative to a grid size based off of UI size and screen resolution. You can easily adjust your controlGroup's ctrls sizes and positions based off of the controlsGroups dimensions by using ctrlPosition if you need to manipulate them.

Maybe taking apart this could help, the main display is anchored to safezoneX/Y but everything else is inside a controlGroup using a grid system (specifically done that way so as it can be used displayed inside Eden's main display via a controlGroup). Maybe not the best but its the only thing I have released UI based since the new system and other projects are not yet ready.

  • Like 1

Share this post


Link to post
Share on other sites

thank you for your answers! My mod is almost finished I'll share it on the forum when I release it.

 

Share this post


Link to post
Share on other sites

Hey I've released the mod.
More info here:

and thanks for the help guys.

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

×