Jump to content
MechSlayer

Create RscButton if variable is true

Recommended Posts

class taximetro: RscButton
		{
			idc = 1600;
			onMouseButtonClick = "closeDialog 1; createDialog 'interfazTaximetro'; ctrlSetText [1001, format ['%1', Dinero]];";
			text = "Taximetro"; //--- ToDo: Localize;
			x = 0.040674 * safezoneW + safezoneX;
			y = 0.90607 * safezoneH + safezoneY;
			w = 0.0787416 * safezoneW;
			h = 0.0420073 * safezoneH;
		};

I want this to be created only if a condition is true. How can i make it?

Share this post


Link to post
Share on other sites

Two choices:

Create it using ctrlCreate command or just hide your current one until ready.

https://community.bistudio.com/wiki/ctrlCreate

https://community.bistudio.com/wiki/ctrlShow

These will get you started.

Easier to create some display init function which you have in onLoad at top. Maybe some switch case to select which display, etc... Set initial state to hidden.

https://community.bistudio.com/wiki/switch_do

Try first, if you get stuck, let me know and I'll provide further help.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks, I made it work with ctrlShow, but I have another question. How can I set layers? For example: The background behind a button

  • Like 1

Share this post


Link to post
Share on other sites

Button can have its own background. Usually priority is a little hacky. Move stuff around. Background (for me at least) usually is under everything else.

  • Thanks 1

Share this post


Link to post
Share on other sites

I mean, for example: I have 4 buttons and an image as background, the 4 buttons must be layer 1 and the image layer 0

Share this post


Link to post
Share on other sites

So the background is over the buttons? Weird. Add that to controlsBackground instead.

class controlsBackground
{
};
class controls
{
};

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Can you show me what you got already please?

  • Thanks 1

Share this post


Link to post
Share on other sites
class Taximetro {
	idd = -1;
	class controls {

		class taximetro: RscButton
		{
			idc = 1600;
			onMouseButtonClick = "closeDialog 1; createDialog 'interfazTaximetro'; ctrlSetText [1000, '0'];";
			text = "Taximetro"; //--- ToDo: Localize;
			x = 0.040674 * safezoneW + safezoneX;
			y = 0.90607 * safezoneH + safezoneY;
			w = 0.0787416 * safezoneW;
			h = 0.0420073 * safezoneH;
		};

	};
};


class interfazTaximetro {
	idd = -1;
	class controlsBackground {
		class RscPicture_1200: RscPicture
		{
			idc = 1200;
			text = "hud.paa";
			x = 0.257213 * safezoneW + safezoneX;
			y = 0.205949 * safezoneH + safezoneY;
			w = 0.492135 * safezoneW;
			h = 0.560097 * safezoneH;
		};
	};
	class controls {
		class Contador: RscText
		{
			idc = 1000;
			x = 0.270337 * safezoneW + safezoneX;
			y = 0.219951 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
			colorBackground[] = {0,0,0,0.5};
		};
		class iniciarContador: RscButton
		{
			idc = 1600;
			text = "Iniciar"; //--- ToDo: Localize;
			onMouseButtonClick = "Contando = true; call Taxi_fnc_contador;";
			x = 0.270337 * safezoneW + safezoneX;
			y = 0.373978 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
		};
		class Tarifa1: RscButton
		{
			idc = 1601;
			text = "Tarifa 1"; //--- ToDo: Localize;
			onMouseButtonClick = "Tarifa1 = true; Tarifa2 = false; Tarifa3 = false;";
			x = 0.440944 * safezoneW + safezoneX;
			y = 0.219951 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
		};
		class Tarifa2: RscButton
		{
			idc = 1602;
			text = "Tarifa 2"; //--- ToDo: Localize;
			onMouseButtonClick = "Tarifa1 = false; Tarifa2 = true; Tarifa3 = false;";
			x = 0.440944 * safezoneW + safezoneX;
			y = 0.331971 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
		};
		class Tarifa3: RscButton
		{
			idc = 1603;
			text = "Tarifa 3"; //--- ToDo: Localize;
			onMouseButtonClick = "Tarifa1 = false; Tarifa2 = false; Tarifa3 = true;";
			x = 0.440944 * safezoneW + safezoneX;
			y = 0.44399 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
		};
		class pararContador: RscButton
		{
			idc = 1604;
			text = "Parar"; //--- ToDo: Localize;
			onMouseButtonClick = "Contando = false;";
			x = 0.335955 * safezoneW + safezoneX;
			y = 0.373978 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
		};
		class contadorReiniciar: RscButton
		{
			idc = 1605;
			text = "Reiniciar"; //--- ToDo: Localize;
			onMouseButtonClick = "Dinero = 0; Inicio = 0; ctrlSetText [1000, '0'];";
			x = 0.303146 * safezoneW + safezoneX;
			y = 0.485998 * safezoneH + safezoneY;
			w = 0.0524944 * safezoneW;
			h = 0.0700121 * safezoneH;
		};
	};
};

 

Share this post


Link to post
Share on other sites
class image : RscPicture
{
	idc = 100;
	/* x y w h values, etc */
	colorText[] = {1, 1, 1, 0.5}; // 1 = fully visible and 0 = fully transparent
};

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Uhm. Does for me ? What image you using?

class image : RscPicture
{
	idc = 1200;
	x = 0.257213 * safezoneW + safezoneX;
	y = 0.205949 * safezoneH + safezoneY;
	w = 0.492135 * safezoneW;
	h = 0.560097 * safezoneH;
	text = "hud.paa";
	colorBackground[] = {1, 1, 1, 0.25};
};

Does this do nothing?

  • Thanks 1

Share this post


Link to post
Share on other sites

Nope it didn't work

This is the image: 8428111b41c3e0d0fef889c47fbeb2e3o.png

The images is visible but it's nearly invisible: 6b4b33f872207bdfd99d7c4513dd2741.png

Share this post


Link to post
Share on other sites

Review your image size.

 

Also, I meant colorText not colorBackground, my bad.

class test
{
	idd = 12345;
	movingEnable = 1;
	class controlsBackground
	{
		class image : RscPicture
		{
			idc = 1200;
			x = 0.257213 * safezoneW + safezoneX;
			y = 0.205949 * safezoneH + safezoneY;
			w = 0.492135 * safezoneW;
			h = 0.560097 * safezoneH;
			text = "image.paa";
			colorText[] = {1, 1, 1, 0.25};
		};
	};
};

Works. 0.25 opacity. Tweak that to say 1 and you see it fully. I think what you was asking about was the fact that your image wasn't fully visible to begin with, this being due to your image size.

https://community.bistudio.com/wiki/PAA_File_Format

Use this and you'll see.

https://hazjohnson.com/ArmA/image.paa

512x256

 

yecDumM.jpg

  • Thanks 1

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

×