Jump to content

Recommended Posts

Hello,

i wanted to code a little quiz in which two answers could be right.

I tried multi listbox but i was only able to mark one.

Then i tried checkboxes and they dont even appear right. I can click and the code is working, but im not seeing anything.

 

my defines.hpp



// CT_TYPES

#define CT_STATIC 0
#define CT_BUTTON 1
#define CT_EDIT 2
#define CT_SLIDER 3
#define CT_COMBO 4
#define CT_LISTBOX 5
#define CT_TOOLBOX 6
#define CT_CHECKBOXES 7
#define CT_PROGRESS 8
#define CT_HTML 9
#define CT_STATIC_SKEW      10
#define CT_ACTIVETEXT 11
#define CT_TREE 12
#define CT_STRUCTURED_TEXT 13
#define CT_CONTEXT_MENU 14
#define CT_CONTROLS_GROUP 15
#define CT_SHORTCUTBUTTON 16
#define CT_XKEYDESC 40
#define CT_XBUTTON          41
#define CT_XLISTBOX 42
#define CT_XSLIDER 43
#define CT_XCOMBO 44
#define CT_ANIMATED_TEXTURE 45
#define CT_MENU 46 //Arma 3 (EDEN)
#define CT_MENU_STRIP 47 //Arma 3 (EDEN)
#define CT_CHECKBOX 77 //Arma 3
#define CT_OBJECT 80
#define CT_OBJECT_ZOOM 81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK 98
#define CT_ANIMATED_USER 99
#define CT_MAP 100
#define CT_MAP_MAIN 101
#define CT_LISTNBOX 102
#define CT_ITEMSLOT         103
// 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 //tileH and tileW params required for tiled image
#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           1024

#define SL_TEXTURES       0x10

// progress bar 
#define ST_VERTICAL       0x01
#define ST_HORIZONTAL     0

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

#define FontM             "Zeppelin32" // The standard font in Arma 3 is "PuristaMedium"

// Tree styles
#define TR_SHOWROOT       1
#define TR_AUTOCOLLAPSE   2

// MessageBox styles
#define MB_BUTTON_OK      1
#define MB_BUTTON_CANCEL  2
#define MB_BUTTON_USER    4

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

class RscText
{
    access = 0;
    idc = -1;
    type = CT_STATIC;
    style = ST_CENTER;
    linespacing = 1;
    colorBackground[] = {0,0,0,0};
    colorText[] = {0.3,0.6,0.4,.8};
    text = "";
    shadow = 2;
    font = "RobotoCondensed";
    SizeEx = 0.02100;
    fixedWidth = 0;
    x = 0;
    y = 0;
    h = 0;
    w = 0;
   
};

class RscButton
{
    
    access = 0;
    idc = -1;
    type = CT_BUTTON;
    text = "";
    colorText[] = {0.5,0.3,0.9,.9};
    colorDisabled[] = {0.6,0.1,0.3,0};
    colorBackground[] = {0.35,0.55,0.15,0.9};
    colorBackgroundDisabled[] = {0,0.0,0};
    colorBackgroundActive[] = {0.15,0.35,0.55,0.7};
    colorFocused[] = {0.75,0.75,0.75,.5};
    colorShadow[] = {0.023529,0,0.0313725,1};
    colorBorder[] = {0.023529,0,0.0313725,1};
    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};
    style = 2;
    x = 0;
    y = 0;
    w = 0.055589;
    h = 0.039216;
    shadow = 2;
    font = "TahomaB";
    sizeEx = 0.02921;
    offsetX = 0.003;
    offsetY = 0.003;
    offsetPressedX = 0.002;
    offsetPressedY = 0.002;
    borderSize = 0;
};


class RscCheckBox
{
   idc = -1;
   type = CT_CHECKBOX;
   style = ST_CENTER;
   x = 0;
   y = 0;
   h = 0.04;
   w = 0.2;
   font = "puristaMedium";
   sizeEx = 0.040;
   color[] = {1,0,0,1};
   colorDisabled[] = {0.4,0.4,0.4,1};
   colorText[] = {1,1,1,1};
   colorTextSelect[] = {1,1,1,1};
   colorPressed[] = {1,1,1,1};
   colorHover[] = {1,1,1,1};
   colorFocused[] = {1,1,1,1};
   colorBackground[] = {0,1,0,0};
   colorBackgroundDisabled[] = {0,0,0,0};
   colorBackgroundPressed[] = {0,0,0,0};
   colorBackgroundHover[]= {0,0,0,0};
   colorBackgroundFocused[]= {0,0,0,0};
   textureChecked = "";
   textureUnchecked = "";
   textureDisabledChecked = "";
   textureDisabledUnchecked = "";
   texturePressedChecked = "";
   texturePressedUnchecked = "";
   textureHoverChecked = "";
   textureHoverUnchecked = "";
   textureFocusedChecked = "";
   textureFocusedUnchecked = "";
   soundEnter[] = { "", 0, 1 };
   soundPush[] = { "", 0, 1 };
   soundClick[] = { "", 0, 1 };
   soundEscape[] = { "", 0, 1 };
};
class RscCheckBoxes {
  idc = -1;
  type = CT_CHECKBOXES; // defined contant (7)
  style = ST_CENTER; // defined constat (0)
  
  x = 0.1;
  y = 0.18;
  w = 0.15;
  h = 0.15;
  
  colorText[] = {1, 0, 0, 0.5};
  color[] = {0, 1, 0, 0.5};  //seems nothing to change, but define to avaoid errors
  colorTextSelect[] = {0, 0.8, 0, 0.5};
  colorSelect[] = {1, 0, 0, 0.5};
  colorTextDisable[] = {0.4, 0.4, 0.4, 0.5};
  colorDisable[] = {0.4, 0.4, 0.4, 0.5};
  colorSelectedBg[] = {1, 1, 1, 0.5}; 
  
  font = "RobotoCondensed";
  sizeEx = 0.0208333;
  
  //rows = 3;
  //columns = 2;
  //strings[] = {"Entry 1","Entry 2","Entry 3","Entry 4","Entry 5","Entry 6"};
  
  //Simple UI event handler to show response on clicks
  onCheckBoxesSelChanged = "hint format[""Checkbox change:\n%1\nEntry#: %2\nNewState: %3"",(_this select 0),(_this select 1),(_this select 2)];"
};

 

My dialog.hpp

class quiz
	{
		idd = 5000;
		movingenable = 0;
	
	
		class controlsBackground
		{
			class background: RscText
			{
				idc = 1002;
				x = 0.288594 * safezoneW + safezoneX;
				y = 0.214 * safezoneH + safezoneY;
				w = 0.422812 * safezoneW;
				h = 0.605 * safezoneH;
				colorBackground[] = {0,0,0,0.8};
			};
		};
		class controls 
		{			
			class CheckAntwort3: RscCheckbox
			{
				idc = 2800;
				x = 0.670156 * safezoneW + safezoneX;
				y = 0.709 * safezoneH + safezoneY;
				w = 0.0360937 * safezoneW;
				h = 0.066 * safezoneH;
			};
			class CheckAntwort1: RscCheckbox
			{
				idc = 2801;
				x = 0.670156 * safezoneW + safezoneX;
				y = 0.577 * safezoneH + safezoneY;
				w = 0.0360937 * safezoneW;
				h = 0.066 * safezoneH;
			};
			class CheckAntwort2: RscCheckbox
			{
				idc = 2802;
				x = 0.670156 * safezoneW + safezoneX;
				y = 0.643 * safezoneH + safezoneY;
				w = 0.0360937 * safezoneW;
				h = 0.066 * safezoneH;
			};
			class TextAntwort3: RscText
			{
				idc = 1000;
				x = 0.29375 * safezoneW + safezoneX;
				y = 0.709 * safezoneH + safezoneY;
				w = 0.37125 * safezoneW;
				h = 0.066 * safezoneH;
			};
			class TextAntwort1: RscText
			{
				idc = 1004;
				x = 0.29375 * safezoneW + safezoneX;
				y = 0.577 * safezoneH + safezoneY;
				w = 0.37125 * safezoneW;
				h = 0.066 * safezoneH;
			};
			class TextAntwort2: RscText
			{
				idc = 1005;
				x = 0.29375 * safezoneW + safezoneX;
				y = 0.643 * safezoneH + safezoneY;
				w = 0.37125 * safezoneW;
				h = 0.066 * safezoneH;
			};
			class RscText_1001: RscText
			{
				idc = 1001;
				x = 0.325 * safezoneW + safezoneX;
				y = 0.301923 * safezoneH + safezoneY;
				w = 0.04125 * safezoneW;
				h = 0.055 * safezoneH;
			};
			class ButtonAntwortSenden: RscButton
			{
				idc = 1600;
				text = "Antwort Abgeben"; //--- ToDo: Localize;
				x = 0.597969 * safezoneW + safezoneX;
				y = 0.786 * safezoneH + safezoneY;
				w = 0.103125 * safezoneW;
				h = 0.022 * safezoneH;
			};
			class ButtonAbbrechen: RscButton
			{
				idc = 1601;
				text = "Abbrechen"; //--- ToDo: Localize;
				x = 0.304062 * safezoneW + safezoneX;
				y = 0.786 * safezoneH + safezoneY;
				w = 0.103125 * safezoneW;
				h = 0.022 * safezoneH;
				action = "closeDialog 0";
			};
				class FrageTest: RscCheckBoxes {
				idc = 200;

				x = 0.1;
				y = 0.18;
				w = 0.15;
				h = 0.15;

			  
				rows = 3;
				columns = 2;
				strings[] = {"Entry 1","Entry 2","Entry 3","Entry 4","Entry 5","Entry 6"};
			  
				//Simple UI event handler to show response on clicks
				onCheckBoxesSelChanged = "hint format[""Checkbox change:\n%1\nEntry#: %2\nNewState: %3"",(_this select 0),(_this select 1),(_this select 2)];"
			};
		};
	};

 

I only get the hints, but i dont see any text. And when state is changing it is not keeping it selectedbackground color. is this right? i want to see the people which question they marked before the send their anwser-

 

Regards

 

Share this post


Link to post
Share on other sites

What kind of text are you not seeing?

The selectedBackgroundColor refers to the last clicked control. If you want to change the colour of a control permanently, you'd have to do something like this:

_maindDisplay = findDisplay *idd*;
_ctrl = _maindDisplay displayCtrl *idc*;

_ctrl setTextColor [1,0,0,1]; // RGBA

// Other color options: ctrlSetBackgroundColor (, tvSetPictureColor, lbSetPictureColor)

And about the problem with the checkboxes: You didn't define a texture. This is what it should look like:

Spoiler

class RscCheckbox
{
	idc = -1;
	type = CT_CHECKBOX;
	style = ST_CENTER;
	x = 0;
	y = 0;
	h = 0.04;
	w = 0.2;
	text = "";
	font = "puristaMedium";
	sizeEx = 0.040;
	color[] = {0,1,0,1};
	colorDisabled[] = {0.4,0.4,0.4,1};
	colorText[] = {0,1,0,1};
	colorTextSelect[] = {0,1,0,1};
	colorPressed[] = {0,1,0,1};
	colorHover[] = {0,1,0,0.8};
	colorFocused[] = {0,1,0,1};
	colorBackground[] = {0,0,0,0};
	colorBackgroundDisabled[] = {0,0,0,0};
	colorBackgroundPressed[] = {0,0,0,0};
	colorBackgroundHover[]= {0,0,0,0};
	colorBackgroundFocused[]= {0,0,0,0};
	textureChecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_checked_ca.paa";
	textureUnchecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_unchecked_ca.paa";
	textureDisabledChecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_checked_ca.paa";
	textureDisabledUnchecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_unchecked_ca.paa";
	texturePressedChecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_checked_ca.paa";
	texturePressedUnchecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_unchecked_ca.paa";
	textureHoverChecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_checked_ca.paa";
	textureHoverUnchecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_unchecked_ca.paa";
	textureFocusedChecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_checked_ca.paa";
	textureFocusedUnchecked = "a3\ui_f\data\GUI\RscCommon\RscCheckbox\CheckBox_unchecked_ca.paa";
	soundEnter[] = { "", 0, 1 };
	soundPush[] = { "", 0, 1 };
	soundClick[] = { "", 0, 1 };
	soundEscape[] = { "", 0, 1 };
	tooltipColorShade[] = {0,0,0,1};
	tooltipColorText[] = {0,1,0,1};
	tooltipColorBox[] = {0,1,0,1};
};

 

 I don't have much experience with RscMulti___ but in this case one checkbox next to the answer should be sufficient. Add onCheckedChanged to the checkbox control and then execute a script (see above) to change the color of the text or whatever.

 

Another option is RscActiveText. This control changes behaviour when clicked on:

Spoiler

class RscActiveText
{
	deletable = 0;
	fade = 0;
	access = 0;
	type = 11;
	style = 2;
	color[] = {0,1,0,1};
	colorActive[] = {1,1,1,1};
	colorDisabled[] = {0.4,0.4,0.4,1};
	soundEnter[] = {"",0.1,1};
	soundPush[] = {"",0.1,1};
	soundClick[] = {"",0.1,1};
	soundEscape[] = {"",0.1,1};
	text = "";
	align = "left";
	default = 0;
	idc = -1;
	x = 0;
	y = 0;
	h = 0.035;
	w = 0.035;
	font = "RobotoCondensed";
	shadow = 2;
	sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
	url = "";
	tooltipColorShade[] = {0,0,0,1};
	tooltipColorText[] = {0,1,0,1};
	tooltipColorBox[] = {0,1,0,1};
};

 

 

And one more tip: with THIS FUNCTION you can export the default ArmA3 rescources.

 

Have fun,

 

7erra

  • Like 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

×