Jump to content
Sign in to follow this  
iceman77

Passing a string of text to a dialog class

Recommended Posts

I would like to pass a string of text to a dialog class (or w/e its called). I see that 0 = ["some text"] createdialog "RscIceDialog" isn't even an option apparently.

Description.ext Snippet

   class ICE_ObjDesc: RscText
               {
                    idc = 1000;
                    [color=#ff0000]text = "some text"; // Would like to be _this select 0[/color]
                    x = 0.40238 * safezoneW + safezoneX;
                    y = 0.430476 * safezoneH + safezoneY;
                    w = 0.191666 * safezoneW;
                    h = 0.0280952 * safezoneH;
               };

---------- Post added at 18:32 ---------- Previous post was at 17:52 ----------

Here's my full description.ext. You can call the dialog like 0 = createdialog "RscIceDialog"

//////////
//Styles//
//////////

// 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_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_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_LISTNBOX         102

// 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         0x00
#define ST_MULTI          0x10
#define ST_TITLE_BAR      0x20
#define ST_PICTURE        0x30
#define ST_FRAME          0x40
#define ST_BACKGROUND     0x50
#define ST_GROUP_BOX      0x60
#define ST_GROUP_BOX2     0x70
#define ST_HUD_BACKGROUND 0x80
#define ST_TILE_PICTURE   0x90
#define ST_WITH_RECT      0xA0
#define ST_LINE           0xB0

#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

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

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

// 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;
   type = CT_STATIC;
   linespacing = 1;
   idc = -1;
   colorBackground[] = {0,0,0,0};
   colorText[] = {0.8784,0.8471,0.651,1};
   text = "";
   fixedWidth = 0;
   x = 0;
   y = 0;
   h = 0.037;
   w = 0.3;
   style = ST_MULTI;
   shadow = 2;
   font = "Zeppelin32";
   SizeEx = 0.02300;
};
class RscStructuredText
{
   access = 0;
   type = 13;
   idc = -1;
   style = 0;
   colorText[] = {0.8784,0.8471,0.651,1};
   class Attributes
   {
       font = "Zeppelin32";
       color = "#e0d8a6";
       align = "Left";
       shadow = 1;
   };
   x = 0;
   y = 0;
   h = 0.035;
   w = 0.1;
   text = "";
   size = 0.01921;
   shadow = 2;
};
class RscPicture
{
   access = 0;
   type = 0;
   idc = -1;
   style = ST_PICTURE;
   colorBackground[] = {0,0,0,0};
   colorText[] = {1,1,1,1};
   font = "TahomaB";
   sizeEx = 0;
   lineSpacing = 0;
   text = "";
   fixedWidth = 0;
   shadow = 0;
   x = 0;
   y = 0;
   w = 0.2;
   h = 0.15;
};

class RscButton
{
   access = 0;
   type = 1;
   text = "";
   colorText[] = {0.8784,0.8471,0.651,1};
   colorDisabled[] = {0.4,0.4,0.4,0};
   colorBackground[] = {0.75,0.75,0.75,0.8};
   colorBackgroundDisabled[] = {0,0.0,0};
   colorBackgroundActive[] = {0.75,0.75,0.75,1};
   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 = "Zeppelin32";
   sizeEx = 0.03921;
   offsetX = 0.003;
   offsetY = 0.003;
   offsetPressedX = 0.002;
   offsetPressedY = 0.002;
   borderSize = 0;
};


class RscFrame
{
   type = 0;
   idc = -1;
   style = 64;
   shadow = 2;
   colorBackground[] = {0,0,0,0};
   colorText[] = {1,1,1,1};
   font = "Zeppelin32";
   sizeEx = 0.03;
   text = "";
};
class BOX
{ 
   type = 0;
   idc = -1;
   style = ST_CENTER;
   shadow = 2;
   colorText[] = {1,1,1,1};
   font = "";
   sizeEx = 0.02;
   colorBackground[] = { 0.2,0.2,0.2, 0.9 }; 
   text = ""; 

};


class RscIceDialog
{
   idd = 3000;
   movingenable = true;

   class Controls
   {

              class Ice_BOX: BOX

               {
               idc = -1;
               text = "";
               x = 0.348572 * safezoneW + safezoneX;
           y = 0.209525 * safezoneH + safezoneY;
           w = 0.302857 * safezoneW;
           h = 0.588571 * safezoneH;
               };

              class ICE_FRAME: RscFrame

               {
           idc = 1800;
           text = "Secondary Ops";
           x = 0.353572 * safezoneW + safezoneX;
           y = 0.209525 * safezoneH + safezoneY;
           w = 0.292857 * safezoneW;
           h = 0.578571 * safezoneH;
               };

               class ICE_YESBUTTON: RscButton

               {
           idc = 1600;
           text = "Accept";
           x = 0.367856 * safezoneW + safezoneX;
           y = 0.724762 * safezoneH + safezoneY;
           w = 0.0595237 * safezoneW;
           h = 0.0490476 * safezoneH;
               action = "closeDialog 0;_nil=[]ExecVM ""objective.sqf""";
               };

              class ICE_NOBUTTON: RscButton

               {
           idc = 1601;
           text = "Decline";
           x = 0.441666 * safezoneW + safezoneX;
           y = 0.724762 * safezoneH + safezoneY;
           w = 0.0595237 * safezoneW;
           h = 0.0490476 * safezoneH;
               action = "closeDialog 0";
               };

             class ICE_PICTURE: RscPicture

               {
           idc = 1200;
           text = "shilka.paa";
           x = 0.37262 * safezoneW + safezoneX;
           y = 0.247619 * safezoneH + safezoneY;
           w = 0.254167 * safezoneW;
           h = 0.276667 * safezoneH;
               };

            class ICE_STEXT: RscStructuredText

               {
           idc = 1100;
           text = "Recon has spotted mobile AA, along with a small platoon of TKA in your area. They're nested up pretty high, on a hill, you'll Flank around and get behind the platoon to minimize casualties. If you can neutralize the shilka so we can send air support your way to deal with remaining hostiles. ";
           x = 0.372619 * safezoneW + safezoneX;
           y = 0.567619 * safezoneH + safezoneY;
           w = 0.254762 * safezoneW;
           h = 0.152858 * safezoneH;
               };

           class ICE_STEXT1: RscStructuredText

               {
           idc = 1101;
           text = "OverView:";
           x = 0.372619 * safezoneW + safezoneX;
           y = 0.554619 * safezoneH + safezoneY;
           w = 0.254762 * safezoneW;
           h = 0.152858 * safezoneH;
               };

           class ICE_TEXT: RscText
               {
           idc = 1000;
           text = "Objective: Neutralize The Shilka";
           x = 0.367999 * safezoneW + safezoneX;
           y = 0.531429 * safezoneH + safezoneY;
           w = 0.25 * safezoneW;
           h = 0.03 * safezoneH;
               };



   };




};

Edited by Iceman77

Share this post


Link to post
Share on other sites

Thanks Deadfast. I've seen that wiki link about ctrlSetText. I'm not understanding what to do. I'll be using another method to display dynamic text on my dialog until I do understand. Appreciate your concern though.

Share this post


Link to post
Share on other sites

    class ICE_ObjDesc: RscText
               {
                    idc = 1000;
                    type = CT_EDIT;
                    x = 0.40238 * safezoneW + safezoneX;
                    y = 0.430476 * safezoneH + safezoneY;
                    w = 0.191666 * safezoneW;
                    h = 0.0280952 * safezoneH;
                    default = true;
                    autocomplete = false;
               };

and

class EnterText: RscText
{
   idc = chooseanumber;
   text = "Select";
   x = number;
   y = number;
   w = number;
   h = number;
   onButtonClick = "myVar = call compile format [""%1"", ctrltext 1000]; [] ExecVM/spawn/call somethingelse; closeDialog 0;"; 
};

SHould work

Share this post


Link to post
Share on other sites

Thanks, I'm going to have a look as soon as I get back home. Looking at it though, I'm not so sure I understand. I basically want to pass some text to the dialog when I call the dialog. So that, the text on the dialog changes to what I've passed to the dialog. For example, since it pops up to accept or decline a side objective, I want to be able to call the dialog as many times as a I like from different triggers, each time passing different text to the dialog. ie; destroy the shilka or neutralize the officer etc etc.

Share this post


Link to post
Share on other sites

I may have derped there. Thought you wanted to pass some text input in the dialog to something else.

Share this post


Link to post
Share on other sites

I can achieve something like what you want by making a listbox like this

class RscListBox 
{
   type = 5;
   style = LB_TEXTURES;
   font = "Zeppelin32";
   sizeEx = 0.03921;
   color[] = {1, 1, 1, 1};
   colorText[] = {0.95, 0.95, 0.95, 1};
   colorScrollbar[] = {0.95, 0.95, 0.95, 1};
   colorSelect[] = {0.023529, 0, 0.0313725, 1};
   colorSelect2[] = {0.023529, 0, 0.0313725, 1};
   colorSelectBackground[] = {0.58, 0.1147, 0.1108, 1};
   colorSelectBackground2[] = {0.58, 0.1147, 0.1108, 1};
   period = 1;
   colorBackground[] = {0, 0, 0, 1};
   maxHistoryDelay = 1.0;
   autoScrollSpeed = -1;
   autoScrollDelay = 5;
   autoScrollRewind = 0;
   soundSelect[] = {"",0.1,1};
   rowHeight = 0;

   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";
   };
};

class RscDialog
{
   idd = 3000;
   movingenable = true;

   class Controls
   {
       class L86RscListboxMain: RscListbox
       {
           idc = 1500;
           x = 0.450214 * safezoneW + safezoneX;
           y = 0.378879 * safezoneH + safezoneY;
           w = 0.265375 * safezoneW;
           h = 0.21979 * safezoneH;
           color[] = {1, 1, 1, 1};
           colorText[] = {0, 0, 0, 0.75};
           colorScrollbar[] = {0.95, 0.95, 0.95, 1};
           colorSelect[] = {0, 0, 0, 1};
           colorSelect2[] = {0.0, 0, 0, 1};
           colorSelectBackground[] = {0.6, 0.839, 0.47, 0.3};
           colorSelectBackground2[] = {0.6, 0.839, 0.47, 1};
           period = 0;
           colorBackground[] = {0, 0, 0, 1};
           sizeEx = 0.035;
           class ScrollBar 
           {
               color[] = {1, 1, 1, 0.6};
               colorActive[] = {1, 1, 1, 1};
               colorDisabled[] = {1, 1, 1, 0.3};
               thumb = "\ca\ui\data\igui_scrollbar_thumb_ca.paa";
               arrowFull = "\ca\ui\data\igui_arrow_top_active_ca.paa";
               arrowEmpty = "\ca\ui\data\igui_arrow_top_ca.paa";
               border = "\ca\ui\data\igui_border_scroll_ca.paa";
           };
       };
   };
};

then when you create the dialog

createdialog "RscDialog";
_index1 = lbAdd [idc, "your text here"];    //idc is the idc of the list box

EDIT: just looked at ctrlSetText. this might be easier to use.

Edited by Lifted86

Share this post


Link to post
Share on other sites

Nice. Please do let me know how it goes with ctrlSetText

Share this post


Link to post
Share on other sites

in the edited version i sent you - to the gamlogic containing

_handle = CreateDialog "RscIceDialog";

add GUI = []spawn testing;

that'll change the text upon opening with out anything being clicked on -

Share this post


Link to post
Share on other sites

   class ICE_ObjDesc: RscText
               {
                    [color="#FF0000"]idc = 1000;[/color]
                    text = "some text";
                    x = 0.40238 * safezoneW + safezoneX;
                    y = 0.430476 * safezoneH + safezoneY;
                    w = 0.191666 * safezoneW;
                    h = 0.0280952 * safezoneH;
               };

CreateDialog "RscIceDialog";
ctrlSetText [[color="#FF0000"]1000[/color], "Hello world"];

Share this post


Link to post
Share on other sites

@neo, that did the trick. I knew it had to be as simple. Thanks.

---------- Post added at 05:27 ---------- Previous post was at 04:37 ----------

Thanks to neo,JW Custom and myself, I can now pass text, structured text,pictures & actions to the dialog very simply.

DisableSerialization;
_handle = CreateDialog "IceAntennaDialog";
_display = uiNamespace getVariable "myDisplay";
_control = _display displayCtrl 1100;
_control ctrlSetStructuredText parseText format["BLABLABLABLABLA"]; 
ctrlSetText [1000, "Objective: Neutralize The Communications Tower"];
ctrlSetText [1200, "pictures\antenna.paa"];
buttonSetAction [1100,"closeDialog 0;_nil=[]ExecVM ""objectives\antenna.sqf"""];

Edited by Iceman77

Share this post


Link to post
Share on other sites

Just put closedialog 0. And precompile the script u r going to use and change the execv bit to [] spawn objectives.

Share this post


Link to post
Share on other sites
Just put closedialog 0. And precompile the script u r going to use and change the execv bit to [] spawn objectives.

I'll never need/execVM that antenna.sqf more than once. Is there any reason to precompile it? I'm still getting my head around all of this shit so bare with me lol

Share this post


Link to post
Share on other sites

well if you dont want to place all the text in the hpp file - you place it as i have done in the sqf file. then you can have conditions in that which dictate what gets called and change the text line accordingly.

if players are < 100 metres away from tower that needs destroying you can then change the pic and the text from that file, then if they are < 100 metres away from a town, you can change the pic again and the text and set objective accordingly.

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  

×