Jump to content
Sign in to follow this  
dr_eyeball

Dialog Template, plus Standard Dialogs

Recommended Posts

The project is 100% MP compatible, because all dialogs are executed client side only. The server plays no role in it. There is no MP dependent code in this.

The only side-effect you may be causing is if you create a dialog from a broadcast script execution and don't check the caller.

Eg: If you create a dialog from a Alpha radio command (which is broadcast), it will create & display the dialog on all clients simultaneously.

So you need to pass in something like a _caller param's to know who instigated the call and exit if the player is not the caller.

In your case, you would further check whether the caller is a leader too. These are just normal MP techniques. Send me PM if you need specific advice.

Share this post


Link to post
Share on other sites

Dy_eyeball.. im having some trouble still

im trying to execute code when the player clicks on item 1, 2, 3, 4, 5, etc but i can not find where to add this execution in.

Can you please help me?

*edit

I also am looking for a way to display a variable somewhere.. like for example player1money...

i am making a multiplayer mission which has purchasing of weapons.

Share this post


Link to post
Share on other sites

1. The code to execute gets added to a "<span style='color:red'>Action</span>" type array. See red code in example below.

2. Displaying a <span style='color:blue'>variable</span> (presumably while the menu is open).

A simple trick to display a variable called 'player1money', would be to format the variable into the menu's title. See blue code in example below.

(To properly display a variable in a custom dialog would require a fair bit of effort and would probably require my updated popup menu dialog, which allows you to embed the PUM into other dialogs, plus other changes.)

Quote[/b] ]_MenuStructureArray =

[

["MainMenu",

[

["Caption", <span style='color:blue'>format["My Menu: $%1", player1money]]</span>,

["Items",

[

[ ["Item", "Buy item 1"], <span style='color:red'>["Action", "nul=[1] execVM 'BuyItem.sqf';"]</span> ],

[ ["Item", "Buy item 2"], <span style='color:red'>["Action", "nul=[2] execVM 'BuyItem.sqf';"]</span> ]

]

]

]

]

//add other menus...

];

nul=_MenuStructureArray execVM "Dialogs\Common\PopupMenu.sqf";

Feel free to PM me or send me a pbo file to check, if you have further problems.

Share this post


Link to post
Share on other sites

I need to execute a script that requires params that are not the global ones you have defined in your template. I'd like to use a format command to create the script call but I can't seem to get the format correct in the dialog array. Would it be possible to give me an example of what that would look like?

Thanks!!

Share this post


Link to post
Share on other sites
I need to execute a script that requires params that are not the global ones you have defined in your template. I'd like to use a format command to create the script call but I can't seem to get the format correct in the dialog array.

Note: this problem applies to ArmA in general, not just for these menus. (Eg: setVehicleInit and 'call compile format' require these techniques too)

You forgot to mention what type your variable is and it's purpose.

All global variables will work without problem.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [ ["Item", "Option 1"], ["Action", "nul=[globalVar] execVM 'script.sqf';"] ],

Objects, however, will require special handling.

With player objects, the simplest solution is to set a variable name of each player. (Eg: soldierWest1, etc)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [ ["Item", "Option 1"], ["Action", "nul=[soldierWest1] execVM 'script.sqf';"] ],

The same with group objects. The simplest solution is to name the group, which is essentially assigning it to a global variable.

The other more complicated option is to actually pass any object as a quoted string parameter, then the script can compare the string parameter against a list or trigger list to determine the object.

(Warning: However you need to be really careful here and know when certain objects are named differently on clients than on other clients. (Eg: JIP players sometimes have 'REMOTE' in their variable name.) )

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [ ["Item", "Option 1"], ["Action", format["nul=['%1'] execVM 'script.sqf';", soldierWest1]] ],

Safe way: If you're dealing with a fixed list of objects (eg: player list or groups) then you could simply pass an index/ID number (which represents the object) as a parameter to the script, then let the script determine which object it is from it's index/ID.

Share this post


Link to post
Share on other sites

Thanks Dr Eyeball that helped immensely. I'm actually integrating your dialog framework into a custom kit selection system. This is now coded to use action menus and has become somewhat cumbersome because of the number of kits now in use. I essentially had to have the popup dialog mimic the params passed in to the kit selection script from the action menu call.

Thanks to your help I've got the prototype working!! yay.gif

Keep up the good work!!

Share this post


Link to post
Share on other sites

Dr. Eyeball I love you man. I really like where your going with this. I am a little confused about how to implement this into my missions and customize the options and titles to what I want. I wish you could explain more about the individual options in lists and where to change them at. Perhapse a sample code (calling in atrillery, supply drop etc). I have a pretty basic understanding of scripting and can usually read through most scripts and get an idea of what's going on. Thanks again.

Share this post


Link to post
Share on other sites

A few comments about these dialogs.

While I was integrating these inside an Addon, I noticed you seem to have not just inherited from base classes like rscButton etc, but also overwritten values inside them, like colors etc. This is not a big problem when you run these dialogs from description.ext (Altough some other dialogs might expect other values), but when they are inside an addon, it will affect a lot of things smile_o.gif

To get around this I changed all base classes to simply inherit from their originals: class rscButton;  etc. and some classes are setup so that we can inherit from their sub-classes, e.g:

class rscMap

{

 class Building;

 class Tree;

};

(etc, whatever)

I would suggest not overwriting values in the original classes but simply create your own: eye_rscMap: rscMap, eye_rscButton: rscButton etc classes in which you make the changes you need for your dialog template system smile_o.gif

If im all wrong here or you have really valid reasons as to changing default values inside base classes, please excuse me smile_o.gif

Share this post


Link to post
Share on other sites

@GeneralCarver: & note to all

I've added some basic usage instructions to the SECOND post in this thread titled:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Mission Developer Usage - Incorporating the PopUp menus into a mission.

Mission Developer Usage - Creating a new dialog for a mission.

Hopefully that may assist with the queries people had with starting off.

For popup menus, the big part to note is that I now suggest you replace the huge file CreatePopupMenu.sqf with the tiny code extract suggested there.

I think my mistake was to provide the most comprehensive example I had at the time in CreatePopupMenu.sqf, but failed to realise that it probably just confused most people with excessive code to browse thinking it was all relevant and required. Apologies for this.

Bug - Missing private variable declarations:

Also note that this public version is quite old now and has a major issue with personally calling functions, due to a lack of Private variable declarations. This is corrected and tidied in my current personal version. I'll try and rerelease it soon with corrections to the "private declarations" issues, plus a few enhancements.

@Sickboy:

Yes, that was a tough call to make with the design early on. Given that all base classes are generally not usable without setting all of their required attributes, I had to decide whether to:

<ul>[*]use standard/common class naming (like rscButton) and allow an easy to use colour scheme and which allowed the classes to be substituted into other projects with similar class naming, without excessive changes, plus simplify usage for beginners wanting to do simple dialogs.

[*]use a personalised class naming (eg: DrE_rscButton) - didn't like that idea, since it wasn't thorough enough

[*]use a 2 levels of inheritence - thought it was overkill at the time, but now it seems reasonable to do, given the side-effects you've discovered

I'll have to reevaluate it all, but hopefully the colours and items referenced by constants were the only default values changed in most of the base classes. If that's the case, a partial workaround may be to just set the constants (eg: text height) and colour scheme to match their defaults, to allow it to work with addons.

Share this post


Link to post
Share on other sites

Dr_Eyeball-

I would like to pile on the praise and say that your framework is a massive resource for new mission makers like me. It has made utilizing dialogs exponentially easier!

***ADDED IN EDIT***

I self-solved the problem below in red by putting the required lines of code to load the html file into the html control in "Start" as opposed to "Select". Sorry for the post but it was a good learning experience

***END OF EDIT***

I do have a question about my very first dialog that I am creating using the framework. Because it is my first dialog please pardon any beginner's oversight.

Following your "Mission Developer Usage - Creating a new dialog for a mission" instructions I was able to reload succesfully and begin customizing without a problem. I want to create a multi-purpose "viewer" dialog for large HTML files such as extensive background/briefing material, server rules & regs, and other similar large file viewing needs. My dialog is very simply constructed. The only controls that I am using from your framework are the HTML caption, HTML Control (enlarged to fit the full screen), and the close button. I removed the unwanted controls by commenting them in the dialog's .hpp file. I chose to use HTML and not text because I eventually want to be able to use links/anchors to jump around in the file.

<span style='color:red'>My problem is that I cannot get the HTML file to load/appear in the HTML control. I noticed in the dialog's .sqf file that the htmlload command is within "Select". So, when the file didn't load, I assumed that meant that since I have no list box and nothing gets "selected" by default, that my html control doesn't get populated. If that is correct, what is another method to load the html file (until I have it worked out, I am still using the sample_1.html file provided by the framework). Do I need to place all the relevant code in "Start" or under "Init"?

Again, please excuse me if this is a noobish question! Thanks!</span>

Share this post


Link to post
Share on other sites

thx for pointing me this way dr. eyeball.

any way to release a version as sickboy has fixed the addon issue?

edit: thx for the reply on ofpec.. i will wait.

Share this post


Link to post
Share on other sites

Dr_Eyeball,

Could you release a small update that contains some more comments? Specifically, could you include a comment for each function that says what it does? e.g. fn_GetParamByName

Thanks for your time.

-hellop

Share this post


Link to post
Share on other sites

Is this still uploaded somewhere? Armaholic is down and the other download links in the first post do not work anymore.

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  

×