Jump to content
Sign in to follow this  
gc8

Controls in dialog

Recommended Posts

Hey

how do you make dialog that has controls in it?

my controls are now across the main screen, i hope u know what i mean?

Basically im trying to create movable window with controls.

PS:

why doesnt this make a button that can be pressed?: (its looks like flat control and nothing happens when u click it)

  class CloseButton : RscButton {

		x = 0.80;
		y = 0.90;
 			w = 0.1;
		h = 0.05;

text = "Close";
action = "closeDialog 0";
};

Edited by rrr44

Share this post


Link to post
Share on other sites

Here is an example from one of my dialogs:

class TOUR_DMC_MENU_CREATEUNIT
{	
idd = 897898;
movingEnable = true;
onLoad = "TOUR_DMC_createUnitMenuActive = true; [] spawn TOUR_DMC_fnc_createUnitOnLoad;";
onUnload = "TOUR_DMC_createUnitMenuActive = false; [] spawn TOUR_DMC_fnc_createUnitCancel";

class controlsBackground
{
	class TOUR_DMC_CREATEUNIT_BACKGROUND : RscBackground 
	{
		idc = 0;
		colorBackground[] = TOUR_DMC_COLOR_BACKGROUND;
		x = "safeZoneX + (safeZoneW / 5)";
		y = "safeZoneY + (safeZoneH / 7)";
		w = "safeZoneW / 2";
		h = "safeZoneH / 1.5";
		moving = true;
	};
};

class objects 
{

};

class controls 
{
	class TOUR_DMC_CREATEUNIT_SIDECOMBO : RscCombo
	{
		idc = 1;
		x = "safeZoneX + (safeZoneW / 4.5)";
		y = "safeZoneY + (safeZoneH / 4.5)";
		w = "safeZoneW / 5";
		h = "safeZoneH / 40";
		sizeEx = 0.025;
		size = 0.025;
		onLBSelChanged  = "[] call TOUR_DMC_fnc_fillFactionCombo";
	};
};
};

As you can see the controls are created inside of the display (the first class bit), this also means the controls can be moved around by clicking and dragging the background with them. As for the problem with the button, have you got an RscButton class defined in your description.ext? This is because it isnt loaded as a resource by default, you have to manually create it in a mission and load it before you can inherit from that class.

Hope that helped at least a little bit, even if it was just example code :P

Share this post


Link to post
Share on other sites

Well I finally got around trying it but managed only to make dialog with one label and button that cannot be clicked.

For some reason the background doesnt appear either.

can any one tell whats wrong?

#define true 1
#define false 0

#define FontM             "Zeppelin32"

class RscBackground
{
idc = -1;
default = false;
font = FontM;
sizeEx = 0.03;
colorText[] = { 0, 0, 0, 1 };
colorFocused[] = { 1, 0, 0, 1 };   // border color for focused state
colorDisabled[] = { 0, 0, 1, 0.7 };   // text color for disabled state
colorBackground[] = { 0, 0, 1, 0.8 };
colorBackgroundDisabled[] = { 1, 1, 1, 0.5 };   // background color for disabled state
colorBackgroundActive[] = { 1, 1, 1, 1 };   // background color for active state
offsetX = 0.003;
offsetY = 0.003;
offsetPressedX = 0.002;
offsetPressedY = 0.002;
colorShadow[] = { 0, 0, 0, 0.5 };
colorBorder[] = { 0, 0, 0, 1 };
borderSize = 0;
soundEnter[] = { "", 0, 1 };  // no sound
soundPush[] = { "buttonpushed.ogg", 0.1, 1 };
soundClick[] = { "", 0, 1 };  // no sound
soundEscape[] = { "", 0, 1 };  // no sound
 x = 0.0;
 y = 0.0;
 w = 1.0;
 h = 1.0;

};

class RscCombo;

class RscText
{
 type = CT_STATIC;
 idc = -1;
 style = ST_LEFT;

 x = 0.0;
 y = 0.0;
 w = 0.3;
 h = 20;
 sizeEx = 0.03;

 colorBackground[] = {1,0,0, 1};
 colorText[] = {1,0,2, 1};
 font = FontM;

 text = "";
};

class RscButton {
idc = -1;
type = CT_BUTTON;
style = ST_LEFT;
default = false;
font = FontM;
sizeEx = 0.03;
colorText[] = { 0, 0, 0, 1 };
colorFocused[] = { 1, 0, 0, 1 };   // border color for focused state
colorDisabled[] = { 0, 0, 1, 0.7 };   // text color for disabled state
colorBackground[] = { 1, 1, 1, 0.8 };
colorBackgroundDisabled[] = { 1, 1, 1, 0.5 };   // background color for disabled state
colorBackgroundActive[] = { 1, 1, 1, 1 };   // background color for active state
offsetX = 0.003;
offsetY = 0.003;
offsetPressedX = 0.002;
offsetPressedY = 0.002;
colorShadow[] = { 0, 0, 0, 0.5 };
colorBorder[] = { 0, 0, 0, 1 };
borderSize = 0;


 soundEnter[] = {"\ca\ui\data\sound\mouse2", 0.2, 1};
 soundPush[] = {"\ca\ui\data\sound\new1", 0.2, 1};
 soundClick[] = {"\ca\ui\data\sound\mouse3", 0.2, 1};
 soundEscape[] = {"\ca\ui\data\sound\mouse1", 0.2, 1};

x = 0.4; y = 0.475;
w = 0.2; h = 0.05;
text = "Close";
action = "closeDialog 0; hint ""Dialog closed. You are good to go now!""";
};


class UNIT_CONTROL
{
idd=777777;
movingEnable = true;

class controlsBackground
{
	class backgroundAkg : RscBackground 
	{
		idc = 0;
		//colorBackground[] = { 0, 0, 1, 0.8 };
		borderSize = 1;
		moving = true;
	};
};


class objects 
{

};

class controls 
{
 class ButtonControl : RscButton {
   idc = -1;
  // type = 1;
   style = ST_LEFT;
 //  moving = false;
   x = 0.45;
   y = 0.4;
   h = 0.05;
   w = 0.1;

text = "Test";
type = CT_BUTTON;

   font = "Zeppelin32";
   sizeEx = 0.025;

action = "hint ""test""";
 };


class AttrLabel : RscText {
 type = CT_STATIC;
 idc = -1;
 style = ST_LEFT;
 colorBackground[] = {0, 0, 0, 1};
 colorText[] = {1, 1, 1, 1};
 font = FontM;
 sizeEx = 0.04;
 h = 0.04;
 text = "Label:";

 x = 0.3;
 w = 0.3;
};

};
};

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  

×