Jump to content
Sign in to follow this  
Baldman

Custom resource with a close button? - Dialog question

Recommended Posts

Hi guys, I'm about a quarter of the way through a making a campaign and I've hit a snag. I've done alot of advanced scripting but I have never used dialogs before since I've had no need for them.

How would I go about displaying a custom picture on screen with a simple close button?

Lets say for example I want to add an action to the action menu that, when activated, will display a picture of a puppy on the screen with a close button at the bottom right, is that possible?

I obviously know how to add actions to the action menu, call the script that corresponds to it and defining it in the description.ext shouldn't be too difficult I just need to know how to display the resource and add a close button, its quite a simple task but all of the dialog tut's I read go into way too much depth on dialogs for me to bother with since I rarely, if ever, have any need for them. Anyone have a concise explanation or even an old script laying around with a similar aim that I could take a look at?

Edited by Baldman

Share this post


Link to post
Share on other sites

You can find how UI works here :

http://community.bistudio.com/wiki/Dialog_Control

And you can find a complete Arma scripting commands list here (that I think you already know of)

http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA

You need to write a dialog class declaration (must contain a member called idd among other necessary members) which represents "the box" (invisible). Then declare, inside the dialog declaration body, control classes (must contain a member called idc among other necessary members) which represent the visible and invisible things you put in "the box" : text, picture, button, list box ... inside the dialog declaration.

The visibility of controls in "a box" is set statically (at dialog definition) by 2 dialog members called controls[] and controlsBackground[] (it can also be set dynamically using scripting commands).

Schematic view :

class MyDialog
{
    idd = -1; // I think you can have more than one "box" displayed on the screen at a time this helps choose one of them using findDisplay command
    controls[] = {MyControl}; // your picture/button is invisible if not mentioned here
    ...

    class MyControl
    {
         idc = -1; //this number is useful when you want to dyanmically change by script the text or picture in the control for instance
         type = CT_XXXXX;
         style = ST_XXXXX; // these 2 members define what the control is (text, picture, button ...) and how it looks (for text it can be the left right or center position)
         ...
    }

    class MySecondControl // which is not visible
    {
         ...
    }
}

So to show the dialog you need to call createDialog "MyDialog" command from anywhere you want in a script. The dialog must contain 2 controls one of type CT_STATIC (picture) and the other of type CT_BUTTON.

The member called "action" of the button control must have a string value : "closeDialog 0".

You have some examples here http://community.bistudio.com/wiki/Dialog_Control

Share this post


Link to post
Share on other sites

Exactly the kind of explanation I was after. Thanks mate.

Share this post


Link to post
Share on other sites

OK, I've been tooling with the explanation given above but I still can't get it working. I just can't get my head around the way it works which is probably why I never bothered with dialogs before :).

I even ran through a tut which includes a whole lot of features I have no use for and couldn't figure out which parts I needed to remove to have only a resource display with a simple close button.

Any help anyone could give on the subject to get me moving in the right direction again?

I'm not even really sure I'm on the right track but so far for defining the button I have:

[size=2]
class MyButton {
idc = -1;
type = CT_BUTTON;
style = ST_LEFT;
[/size][size=2][color=#ff0000][size=2][color=#ff0000]default[/color][/size][/color][/size][size=2] = [/size][size=2][color=#0000ff][size=2][color=#0000ff]false[/color][/size][/color][/size][size=2];
font = FontM;
sizeEx = 0.03;
colorText[] = { 0, 0, 0, 1 };
colorFocused[] = { 1, 0, 0, 1 }; // border color [/size][size=2][color=#0000ff][size=2][color=#0000ff]for[/color][/size][/color][/size][size=2] focused state
colorDisabled[] = { 0, 0, 1, 0.7 }; // [/size][size=2][color=#ff0000][size=2][color=#ff0000]text[/color][/size][/color][/size][size=2] color [/size][size=2][color=#0000ff][size=2][color=#0000ff]for[/color][/size][/color][/size][size=2] disabled state
colorBackground[] = { 1, 1, 1, 0.8 };
colorBackgroundDisabled[] = { 1, 1, 1, 0.5 }; // background color [/size][size=2][color=#0000ff][size=2][color=#0000ff]for[/color][/size][/color][/size][size=2] disabled state
colorBackgroundActive[] = { 1, 1, 1, 1 }; // background color [/size][size=2][color=#0000ff][size=2][color=#0000ff]for[/color][/size][/color][/size][size=2] 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.4; y = 0.475;
w = 0.2; h = 0.05;
[/size][size=2][color=#ff0000][size=2][color=#ff0000]text[/color][/size][/color][/size][size=2] = "Close";
[/size][size=2][color=#ff0000][size=2][color=#ff0000]action[/color][/size][/color][/size][size=2] = "closeDialog 0;
}
[/size]

And for the picture:

[size=2]
class MyPicture {
/* ... same as the [/size][size=2][color=#ff0000][size=2][color=#ff0000]text[/color][/size][/color][/size][size=2] example, except [/size][size=2][color=#0000ff][size=2][color=#0000ff]for[/color][/size][/color][/size][size=2] */
idc = -1;
type = CT_STATIC; // defined constant
style = ST_PICTURE;
colorText[] = { 0, 0, 0, 1 };
colorBackground[] = { 1, 1, 1, 0.75 };
font = FontM; // defined constant
sizeEx = 0.023;
x = 0.3; y = 0.1;
w = 0.4; h = 0.03;
[/size][size=2][color=#ff0000][size=2][color=#ff0000]text[/color][/size][/color][/size][size=2] = "mypicture.paa";
};
[/size]

Basically right now I'm just trying to get something to display so I can play with sizes etc once I have it functioning.

Edited by Baldman

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  

×