OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: GameAdd1cted 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
-
Give us your example and we may fix it.
-
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:
// 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";
};
};
};
-
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?
-
Hi i0n0s,
In the mission editor I place a unit with the following line:
nullReturn = [this] ExecVM "Observador.sqf"; profesores = group this;
Here it is the Observador.sqf:
_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:
// 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.
-
And in which file do you add the entrys to the dialogue?
-
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
-
But in which file do you run this:
_index = lbAdd [99, "First item"];
-
i0n0s,
Thank you for your patience... that was the error :good:.
I was using _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 :)