Home   Help Search Login Register  

Author Topic: Simple comboBox sample  (Read 2808 times)

0 Members and 1 Guest are viewing this topic.

Offline GameAdd1cted

  • Members
  • *
Simple comboBox sample
« on: 11 Jan 2010, 23:27:08 »
Hi guys,

I've searched everywhere for it... I understand that dialogues are hard (for a novice programmer), but...

I am trying to script a mission where a specific player can spawn enemy units by clicking on the map (onMapSingleClick)
I managed to do this via action and radio command.

Now I want to be able to select which unit to be spawned.
I read the Dialog Control Article on http://community.bistudio.com/wiki/Dialog_Control and now I am able to create dialogues with buttons and text.

I can't manage to create the combo. I even ventured to look on Loki's scripts (Lost Key mod), but it's too much for me.
Also, I had a look on Doolittle's sample code but no combobox there.

So, anyone happens to know / have a sample combobox where you can select a unit?
I've made it so far reading on forums, but I'm stuck now :(

I hope I made myself clear.

Thank you  
« Last Edit: 11 Jan 2010, 23:32:21 by GameAdd1cted »

Offline i0n0s

  • Moderator
  • *****
Re: Simple comboBox sample
« Reply #1 on: 12 Jan 2010, 00:10:20 »
Give us your example and we may fix it.

Offline GameAdd1cted

  • Members
  • *
Re: Simple comboBox sample
« Reply #2 on: 12 Jan 2010, 20:17:30 »
OK, thanks a lot... That's even better :)
Basically I have 2 problems:
1. I cannot populate the combobox list
2. Therefore I cannot select the unit to be respawned.

Here it goes:

Code: [Select]
// Control 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_SHORTCUT_BUTTON  16 // Arma 2 - textured button

#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_OBJECT           80
#define CT_OBJECT_ZOOM      81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK        98
#define CT_USER             99
#define CT_MAP              100
#define CT_MAP_MAIN         101
#define CT_List_N_Box       102 // Arma 2 - N columns list box


// 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
#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"



//-------------------------------------------------

#define true 1
#define false 0

class MyHelloWorldDialog {
idd = -1; // set to -1, because we don't require a unique ID
movingEnable = false;    // no movement while the dialog is shown
controlsBackground[] = { };    // no background controls needed
objects[] = { };    // no objects needed
controls[] = { // el que está más arriba, más al fondo queda
MyRscCombo
};

class MyRscCombo {
idc = 99;
type = CT_COMBO;
style = ST_LEFT;

x = 0.1;
y = 0.1;
w = 0.4;
h = 0.03;
   
font = "TahomaB";
sizeEx = 0.025;
 
rowHeight = 0.025;
wholeHeight = 4 * 0.025; // 3 lines to display + 1 line of the unelapsed control
 
color[] = {1,1,1,1};
colorText[] = {0,0,0,1};
colorBackground[] = {1,1,1,1};
colorSelect[] = {1,0,0,1};
colorSelectBackground[] = {0,1,0,1};

soundSelect[] = {"", 0.0, 1};
soundExpand[] = {"", 0.0, 1};
soundCollapse[] = {"", 0.0, 1};

//No funciona _index = lbAdd [99, "First item"];
//No funciona _index = MyRscCombo lbAdd "First item";

maxHistoryDelay = 10;
autoScrollSpeed = -1;
autoScrollDelay = 5;
autoScrollRewind = 0;


colorScrollbar[] = {0.95, 0.95, 0.95, 1};
period = 1;
thumb = "\ca\ui\data\ui_scrollbar_thumb_ca.paa";

arrowFull = "\ca\ui\data\ui_arrow_top_active_ca.paa";
arrowEmpty = "\ca\ui\data\ui_arrow_top_ca.paa";

border = "\ca\ui\data\ui_border_scroll_ca.paa";



class ScrollBar
{

color[] = {1, 1, 1, 0.6};
colorActive[] = {1, 1, 1, 1};

colorDisabled[] = {1, 1, 1, 0.3};
thumb = "\ca\ui\data\ui_scrollbar_thumb_ca.paa";

arrowFull = "\ca\ui\data\ui_arrow_top_active_ca.paa";

arrowEmpty = "\ca\ui\data\ui_arrow_top_ca.paa";

border = "\ca\ui\data\ui_border_scroll_ca.paa";

};


};

};

Offline i0n0s

  • Moderator
  • *****
Re: Simple comboBox sample
« Reply #3 on: 13 Jan 2010, 00:58:10 »
The definition seems to be all right.
And the first script command should work.
The second can't work.

Where do you call the script and is the dialogue already open at that time?

Offline GameAdd1cted

  • Members
  • *
Re: Simple comboBox sample
« Reply #4 on: 13 Jan 2010, 21:44:23 »
Hi i0n0s,

In the mission editor I place a unit with the following line:

Code: [Select]
nullReturn = [this] ExecVM "Observador.sqf"; profesores =  group this;
Here it is the Observador.sqf:

Code: [Select]
_u = _this select 0;
_u addWeapon "Binocular";
_id1 = _u addAction ["Hello", "OBS_1_Act_1.sqs",[],1,false,true,"",""];
_id2 = _u addAction ["Clear", "OBS_1_Act_2.sqf",[],1,false,true,"",""];
_id3 = _u addAction ["Display Units", "OBS_1_Act_3.sqf",[],1,false,true,"",""];
_id4 = _u addAction ["Spawn ally unit", "OBS_1_Act_4.sqf",[],1,false,true,"",""];
_id5 = _u addAction ["Spawn enemy unit", "OBS_1_Act_5.sqf",[],1,false,true,"",""];
_id6 = _u addAction ["Pruebas dialogos", "OBS_1_Act_6.sqf",[],1,false,true,"",""];


Here it is the OBS_1_Act_6.sqf:

Code: [Select]
// Filename OBS_1_Act_6
// Script for learning dialogues

_ok = createDialog "MyHelloWorldDialog";
waitUntil { !dialog };
hint "Dialog closed.";

exit;

The definition I posted previously corresponds to Dialogos.hpp.

I think the dialogue is open at the time the combobox is on the screen. Just in case I am missing something or I am doing something wrong, here it is the complete mission:
http://rapidshare.com/files/334835873/A2_Entrenamiento_A.utes.rar.html

Thank you for your help.

Edited: I mixed things up; the first code I posted corresponds to the dialogue definition. I added the code in the file that actually creates the dialogue.
« Last Edit: 14 Jan 2010, 09:00:07 by GameAdd1cted »

Offline i0n0s

  • Moderator
  • *****
Re: Simple comboBox sample
« Reply #5 on: 14 Jan 2010, 01:28:25 »
And in which file do you add the entrys to the dialogue?

Offline GameAdd1cted

  • Members
  • *
Re: Simple comboBox sample
« Reply #6 on: 14 Jan 2010, 08:50:52 »
Hi i0n0s,

In the previous post I mixed thins up; I'll try to clarify:

Files:
Dialogos.hpp
- it is called via via #include "Dialogos.hpp" in the Description.ext
- it defines the dialogue and it is the first code I posted
- I think one of my errors is that I try to add items to the dialogue in this file (via lbadd)

Observador.sqf
- the script that is added in the init line of the unit
- it adds actions for the unit

OBS_1_Act_6.sqf
- it is called when the player selects the 6th action defined in Observador.sqf
- it creates the dialogue

I even modified the previous post accordingly (displaying the code for OBS_1_Act_6.sqf).

Thank you
« Last Edit: 14 Jan 2010, 09:09:35 by GameAdd1cted »

Offline i0n0s

  • Moderator
  • *****
Re: Simple comboBox sample
« Reply #7 on: 14 Jan 2010, 12:28:48 »
But in which file do you run this:
Code: [Select]
_index = lbAdd [99, "First item"];

Offline GameAdd1cted

  • Members
  • *
Re: Simple comboBox sample
« Reply #8 on: 15 Jan 2010, 18:28:09 »
 i0n0s,

Thank you for your patience... that was the error  :good:.
I was using
Code: [Select]
_index = lbAdd [99, "First item"]; in the same place where dialogues were defined.

I put this now in OBS_1_Act_6.sqf (right after the createDialog) and it is working!

I am currently fighting now with adding actions and scripts to the combobox items, but I am far from being stuck (at least for the moment).

Thanks again :)