Jump to content
Sign in to follow this  
engima

Why does not button work on dialog?

Recommended Posts

Hi!

Why doesn't the Close button work on this dialog? I don't think it's disabled, but the action does not fire when pressed.

#define true 1
#define false 0

class MyHelloWorldDialog {
idd = -1;                      // set to -1, because we don't require a unique ID
movingEnable = false;           // the dialog can be moved with the mouse (see "moving" below)
enableSimulation = true;      // freeze the game
controlsBackground[] = { };    // no background controls needed
objects[] = {  };               // no objects needed
controls[] = { MyHelloText, CloseButton };  // our "Hello world" text as seen below:

class MyHelloText {
	idc = -1;              // set to -1, unneeded
	moving = 0;            // left click (and hold) this control to move the dialog
	                       // (requires "movingEnabled" to be 1, see above)
	type = CT_STATIC;      // constant
	style = ST_LEFT;       // constant
	text = "Hello world";
	font = "LucidaConsoleB";
	sizeEx = 0.023;

	colorBackground[] = { 1, 1, 1, 0.3 };
	colorText[] = { 0, 0, 0, 1 };

	x = 0.1;
	y = 0.1;
	w = 0.2;
	h = 0.1;
};

class CloseButton {
	idc = 2;
	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[] = { "", 0, 1 };  // no sound
	soundPush[] = { "buttonpushed.ogg", 0.1, 1 };
	soundClick[] = { "", 0, 1 };  // no sound
	soundEscape[] = { "", 0, 1 };  // no sound
	x = 0.7; y = 0.9;
	w = 0.2; h = 0.1;
	text = "Close";
	action = "closeDialog 0; hint ""Dialog closed. You are good to go now!""";
};
};

Share this post


Link to post
Share on other sites

I think your controls need to be in inverted commas

controls[] = { "MyHelloText", "CloseButton" };

Share this post


Link to post
Share on other sites

Ok, they still show up, but the button still behaves as a text control - unclickable.

Another question: What should be in the objects[] array?

Btw, here is the defines that I forgot to post:

// Static styles
#define ST_POS            0x0F
#define ST_HPOS           0x03
#define ST_VPOS           0x0C
#define ST_LEFT           0x00
#define ST_RIGHT          0x01
#define ST_CENTER         0x02
#define ST_DOWN           0x04
#define ST_UP             0x08
#define ST_VCENTER        0x0c

#define ST_TYPE           0xF0
#define ST_SINGLE         0
#define ST_MULTI          16
#define ST_TITLE_BAR      32
#define ST_PICTURE        48
#define ST_FRAME          64
#define ST_BACKGROUND     80
#define ST_GROUP_BOX      96
#define ST_GROUP_BOX2     112
#define ST_HUD_BACKGROUND 128
#define ST_TILE_PICTURE   144
#define ST_WITH_RECT      160
#define ST_LINE           176

#define ST_SHADOW         0x100
#define ST_NO_RECT        0x200 // this style works for CT_STATIC in conjunction with ST_MULTI
#define ST_KEEP_ASPECT_RATIO  0x800

#define ST_TITLE          ST_TITLE_BAR + ST_CENTER

// Slider styles
#define SL_DIR            0x400
#define SL_VERT           0
#define SL_HORZ           0x400

#define SL_TEXTURES       0x10

// Listbox styles
#define LB_TEXTURES       0x10
#define LB_MULTI          0x20

#define FontM             "Zeppelin32"

Share this post


Link to post
Share on other sites

Cool, I can't see these in your defines anywhere, (but the dialog refers to them):

//CTRL Defines - Types & Styles 
#define CT_STATIC           0
#define CT_BUTTON           1

Hope that helps :)

EDIT: I don't think you'll need to populate the objects array.

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Yes! That was exactly what I had missed! Thanks!

Share this post


Link to post
Share on other sites

No probs man - I love Escape Chernarus btw, it's probably my all time favourite co-op mission.

If it's helpful for you, when I make dialogs, I have a .hpp for defines and then another file where I put together the dialog.

Have a look at these if they are useful for you.

//CTRL Defines - Types & Styles 
#define CT_STATIC           0
#define CT_BUTTON           1
#define CT_COMBO            4
#define CT_STRUCTURED_TEXT  13

#define ST_LEFT           0x00
#define ST_RIGHT          0x01
#define ST_CENTER         0x02
#define ST_PICTURE        0x30
#define ST_ROUNDED1        128
#define ST_MULTI          0x10

////////////////
//Base Classes//
////////////////


class horde_RscPicture
{
   access = 0;
   type = CT_STATIC;
   style = ST_PICTURE;
   idc = -1;
   colorBackground[] = {0,0,0,1};
   colorText[] = {1,1,1,1};
   font = "Zeppelin33";
   sizeEx = 0;
   lineSpacing = 0;
   text = "";
   fixedWidth = 0;
   shadow = 0;
   x = 0;
   y = 0;
   w = 0.2;
   h = 0.15;
};

class horde_RscText
{
 type = CT_STATIC;
 text = "";
 idc = -1;
 style = ST_LEFT;
 h = 0.04;
 colorBackground[] = {0, 0, 0, 0};
 colorText[] = {0.1, 0.1, 0.1, 1};
 font = "Zeppelin33";
 sizeEx = 0.1;
};

class horde_RscStructuredText
{
   access = 0;
   type = CT_STRUCTURED_TEXT;
   style = ST_LEFT;
   idc = -1;
   colorBackground[] = {0,0,0,0};
   colorText[] = {0,0,0,1};
   x = 0;
   y = 0;
   h = 0;
   w = 0;
   text = "";
   size = 0.022;
   shadow = 2;
};

class horde_RscButton
{
 access = 0;
 type = CT_BUTTON;
 style = ST_LEFT;
 x = 0;
 y = 0;
 w = 0;
 h = 0;
 text = "";
 font = "Zeppelin33";
 sizeEx = 0.04;
 colorText[] = {0,0,0,1};
 colorDisabled[] = {0.3,0.3,0.3,1};
 colorBackground[] = {0.6,0.6,0.6,1};
 colorBackgroundDisabled[] = {0.6,0.6,0.6,1};
 colorBackgroundActive[] = {1,0.5,0,1};
 offsetX = 0.004;
 offsetY = 0.004;
 offsetPressedX = 0.002;
 offsetPressedY = 0.002;
 colorFocused[] = {0,0,0,1};
 colorShadow[] = {0,0,0,1};
 shadow = 0;
 colorBorder[] = {0,0,0,1};
 borderSize = 0.008;
 soundEnter[] = {"",0.1,1};
 soundPush[] = {"",0.1,1};
 soundClick[] = {"",0.1,1};
 soundEscape[] = {"",0.1,1};
};

class horde_RscShortcutButton
{
type = 16;
x = 0.1;
y = 0.1;
class HitZone
{
	left = 0.004;
	top = 0.029;
	right = 0.004;
	bottom = 0.029;
};
class ShortcutPos
{
	left = 0.0145;
	top = 0.026;
	w = 0.0392157;
	h = 0.0522876;
};
class TextPos
{
	left = 0.05;
	top = 0.034;
	right = 0.005;
	bottom = 0.005;
};
shortcuts[] = {};
textureNoShortcut = "#(argb,8,8,3)color(0,0,0,0)";
color[] = {0.8784,0.8471,0.651,1};
color2[] = {0.95,0.95,0.95,1};
colorDisabled[] = {1,1,1,0.25};
colorBackground[] = {1,1,1,1};
colorBackground2[] = {1,1,1,0.4};
class Attributes
{
	font = "Zeppelin33";
	color = "#E5E5E5";
	align = "left";
	shadow = "true";
};
idc = -1;
style = 0;
default = 0;
shadow = 2;
w = 0.183825;
h = 0.104575;
periodFocus = 1.2;
periodOver = 0.8;
animTextureNormal = "\ca\ui\data\ui_button_normal_ca.paa";
animTextureDisabled = "\ca\ui\data\ui_button_disabled_ca.paa";
animTextureOver = "\ca\ui\data\ui_button_over_ca.paa";
animTextureFocused = "\ca\ui\data\ui_button_focus_ca.paa";
animTexturePressed = "\ca\ui\data\ui_button_down_ca.paa";
animTextureDefault = "\ca\ui\data\ui_button_default_ca.paa";
period = 0.4;
font = "Zeppelin33";
size = 0.03921;
sizeEx = 0.03921;
text = "";
soundEnter[] = {"\ca\ui\data\sound\onover",0.09,1};
soundPush[] = {"\ca\ui\data\sound\new1",0,0};
soundClick[] = {"\ca\ui\data\sound\onclick",0.07,1};
soundEscape[] = {"\ca\ui\data\sound\onescape",0.09,1};
action = "";
class AttributesImage
{
	font = "Zeppelin33";
	color = "#E5E5E5";
	align = "left";
};
};

And:

/********************************************************************************************************************/
// Config file for [DayZ]
// Created by: [Horde]
//********************************************************************************************************************/

/********************************************************************************************************************/
//  Set up dialog
/********************************************************************************************************************/

class horde_read_book
{
idd = -1;
movingEnable = false;
onLoad = "uiNamespace setVariable ['horde_myDisplay', (_this select 0)]; [0] call horde_book_check_page_num_fnc;";
enableSimulation = true;
controlsBackground[] = {};
objects[] = {};
controls[] =
{
	"horde_background",
	"horde_pages",
	"horde_left_text",
	"horde_right_text",
	"horde_left_page_num",
	"horde_right_page_num",
	"horde_left_page_prevpage",
	"horde_right_page_nextpage",
	"PrevPage",
	"NextPage",
	"GearMenu",
	"GotoGame"
};

// unused

class horde_background: horde_RscText
{
	idc = 1000;
	x = 0.208333 * safezoneW + safezoneX;
	y = 0.15 * safezoneH + safezoneY;
	w = 0.583333 * safezoneW;
	h = 0.7 * safezoneH;
};

// picture of blank book pages

class horde_pages: horde_RscPicture
{
	idc = 1200;
	text = "pictures\pages.paa";
	x = 0.217448 * safezoneW + safezoneX;
	y = 0.1675 * safezoneH + safezoneY;
	w = 0.565104 * safezoneW;
	h = 0.63 * safezoneH;
};

// text on left page

class horde_left_text: horde_RscStructuredText
{
	idc = 1201;
	text = "";
	x = 0.272135 * safezoneW + safezoneX;
	y = 0.24 * safezoneH + safezoneY; // 0.185
	w = 0.21875 * safezoneW;
	h = 0.475 * safezoneH;  // 0.5425
};

// text on right page

class horde_right_text: horde_RscStructuredText
{
	idc = 1202;
	text = "";
	x = 0.518229 * safezoneW + safezoneX;
	y = 0.24 * safezoneH + safezoneY;
	w = 0.21875 * safezoneW;
	h = 0.475 * safezoneH;
};

// page number left page

class horde_left_page_num: horde_RscStructuredText
{
	idc = 1203;
	text = "";
	x = 0.363281 * safezoneW + safezoneX;
	y = 0.745 * safezoneH + safezoneY;
	w = 0.0455729 * safezoneW;
	h = 0.035 * safezoneH;

};

// page number right page

class horde_right_page_num: horde_RscStructuredText
{
	idc = 1204;
	text = "";
	x = 0.609375 * safezoneW + safezoneX;
	y = 0.745 * safezoneH + safezoneY;
	w = 0.0455729 * safezoneW;
	h = 0.035 * safezoneH;
};

// invisible button to turn back a page

class horde_left_page_prevpage: horde_RscButton
{
	idc = 2100;
	text = "";
	colorText[] = {0,0,0,0};
	colorDisabled[] = {0,0,0,0};
	colorBackground[] = {0,0,0,0};
	colorBackgroundDisabled[] = {0,0,0,0};
	colorBackgroundActive[] = {0,0,0,0};
	offsetX = 0;
	offsetY = 0;
	offsetPressedX = 0;
	offsetPressedY = 0;
	colorFocused[] = {0,0,0,0};
	colorShadow[] = {0,0,0,0};
	shadow = 0;
	colorBorder[] = {0,0,0,0};
	borderSize = 0;
	x = 0.208333 * safezoneW + safezoneX;
	y = 0.15 * safezoneH + safezoneY;
	w = 0.291667 * safezoneW;
	h = 0.63 * safezoneH;
	action = "[-1] call horde_book_check_page_num_fnc;";
};

// invisible button to turn forward a page

class horde_right_page_nextpage: horde_RscButton
{
	idc = 2101;
	text = "";
	colorText[] = {0,0,0,0};
	colorDisabled[] = {0,0,0,0};
	colorBackground[] = {0,0,0,0};
	colorBackgroundDisabled[] = {0,0,0,0};
	colorBackgroundActive[] = {0,0,0,0};
	offsetX = 0;
	offsetY = 0;
	offsetPressedX = 0;
	offsetPressedY = 0;
	colorFocused[] = {0,0,0,0};
	colorShadow[] = {0,0,0,0};
	shadow = 0;
	colorBorder[] = {0,0,0,0};
	borderSize = 0;
	x = 0.509115 * safezoneW + safezoneX;
	y = 0.15 * safezoneH + safezoneY;
	w = 0.282552 * safezoneW;
	h = 0.63 * safezoneH;
	action = "[1] call horde_book_check_page_num_fnc;";
};

// menu buttons down the bottom

class PrevPage: horde_RscShortcutButton
{
	idc = 1700;
	text = "Prev Page";
	x = 0.217448 * safezoneW + safezoneX;
	y = 0.78 * safezoneH + safezoneY;
	w = 0.11849 * safezoneW;
	h = 0.0875 * safezoneH;
	action = "[-1] call horde_book_check_page_num_fnc;";
};

class NextPage: horde_RscShortcutButton
{
	idc = 1701;
	text = "Next Page";
	x = 0.372396 * safezoneW + safezoneX;
	y = 0.78 * safezoneH + safezoneY;
	w = 0.11849 * safezoneW;
	h = 0.0875 * safezoneH;
	action = "[1] call horde_book_check_page_num_fnc;";
};

class GearMenu: horde_RscShortcutButton
{
	idc = 1702;
	text = "Gear Menu";
	x = 0.518229 * safezoneW + safezoneX;
	y = 0.78 * safezoneH + safezoneY;
	w = 0.11849 * safezoneW;
	h = 0.0875 * safezoneH;
	action = "closeDialog 0; createGearDialog [player,'RscDisplayGear']; playSound 'horde_sound_close_book'";
};

class GotoGame: horde_RscShortcutButton
{
	idc = 1703;
	text = "Close Book";
	x = 0.664063 * safezoneW + safezoneX;
	y = 0.78 * safezoneH + safezoneY;
	w = 0.11849 * safezoneW;
	h = 0.0875 * safezoneH;
	action = "closeDialog 0; playSound 'horde_sound_close_book'";
};
};

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  

×