Tuesday, November 17, 2015

Creating a Listbox ARMA 3

I know it has been a long while since I've updated this but I got a job so I'm super busy. Between work and keeping my girlfriend happy there isn't much time for personal development. So lets get to it.

Listbox, what is it? what does it do? 

A listbox basically presents text in a nice little box that is organized but with extra features. For example depending on what you select it can create an event to happen. For this tutorial I'm going to show just how to create one and add something to the list. I'm not going step by step in creating one like I did in my previous post "G.U.I Button ARMA 3 Style". If you are ever lost or need a refresher refer to that post and catch up.

1. Start up ARMA 3 and select Editor and select any map it doesn't matter and create a new mission.

2. Save the mission. It can be anything you want but remember the name.

3. Once you save it, place one playable unit down and click preview.

4. Inside the game press escape and look for GUI EDITOR on the bottom and select it.

5. I'm going to skip ahead and not break it down Barney Rubble style on how I created the listbox. But I will show you what it looks like.


This is what I created using the GUI editor. I added a RscFrame, RscListBox, 2 RscButton, and RscText.

6. Now once I created this I need to save the information. Shift + Ctrl + S, paste this information into a empty text document. Hopefully you are using Notepad++. Save it any name you want and you're almost done. I named my file RangeGUI.hpp. Eventually I want to create ranges on the island of Stratis.


This is what it looks like after I made changes. Remember from my last post I had to add a couple of hings to make this work. Take a look at the comments in the picture for more information.


7. Now to get the listbox to work correctly I had to add a couple of things to this. Noticeably is the onLoad command. This basically tells ARMA 3 whenever this dialog is created load this script. rangeScript.sqf is what makes the listbox to work. Pay attention to the idd variable and the idc variable under Rex_Title.

8. Now in the description.ext I have to define the parent config and my config so ARMA can display the listbox.

9. Now I create a sqf file called "rangeScript.sqf". In this file I basically add text to the listbox. Look in the comments in the picture for more details.

10. Hopefully the picture above explains how to make the listbox works. Basically I have to find the display. I used the findDisplay command and give it the idd number 2017 which I defined. Once I have the display I need access to the control for the listbox. Using displayCtrl command I passed the idc number I defined for the listbox. Refer to the pictures in case you're confused. displayCtrl returns a control data type which gives me more access to the listbox. Now I need to add something to the listbox. lbAdd command is what I used to add a simple text to the listbox. To add further flare to the text I set the color to green. Refer to the picture above for more details.

11. Now that script is defined it is time to test it out. Load up the mission and place down a unit you can control and a pole and edit the initialization of it to this.
12. Preview the mission and run straight to the pole and activate the addAction. You should see something similar to this.

So far nothing has been added to make anything to happen, basically the box is there. I'll show you in the next tutorial how to make the magic happen.

This concludes this tutorial.

Tuesday, April 28, 2015

G.U.I Button ARMA 3 Style

I love the ARMA series for one good reason, it allows custom scripts or mods. It's a sandbox game that is based off my personal career in the National Guard. That skill is combat but enough about me let me tell you my history with this game. I started to play this game because I remember my late twin brother was playing ARMA Gold and I happen to see ARMA II Combined Ops at Wal-Mart and at that moment I decided to  pick it up. I was trying to get closer to my brother after his death in Afghanistan. Well it was the best decision I made because it gave me the desire to code and develop. I found the gift of developing and I have been increasing my development skills ever since. So my blog will basically be my personal development with Java and other languages but also ARMA 3 content. So to get back on course I want to talk about ARMA's use of G.U.I's. With ARMA I feel it is harder to learn G.U.I.'s or dialogs as the game calls it. I took me weeks to learn how to create a button and I hope by sharing my success others will fare a lot easier than me. I'm going to list the steps to get one button to write a message on screen.
1. Start up ARMA 3 and select Editor and select any map it doesn't matter and create a new mission.

2. Save the mission. It can be anything you want but remember the name.

3. Once you save it, place one playable unit down and click preview.

4. Inside the game press escape and look for GUI EDITOR on the bottom and select it.

5. Press escape and you should now be in the GUI EDITOR you should have a grid in front. A few tips, pressing 'H' brings up the help menu and it tells you all the commands needed to operate the editor.

6. Right-click anywhere and a dialog will pop up, select RscButton near the top and watch it appear on your screen.

7. Right-click on that button and another menu pops up and this menu allows you to edit the button to your liking.



8. I'll go through what I've done

  • Class: This is the variable name to refers to this button
  • Text: This will appear on the button
  • Text color: This will be the color of the button.
    • Look at Active color and to see what each value means. It's a RGB scale with Alpha
  • Tooltip: When a mouse hovers over the button a this text will appear.
  • Position type: Always put Safezone, I don't know why but all tutorials I've read say so.
9. Click okay and you're almost ready. Now you have to save your script. But first you have to export your parent classes. This is needed and you'll see why in a minute.  Press 'H' and look for export Parent Class.


As you can see it's Ctrl + P. This will copy information to your clipboard. Alt tab out of the game and open up any text editor preferably Notepad++, and paste the information inside a text document. You should see something like this.


10. Now save this file as defines.hpp Now go back in the game and look for Export to config format. It's Shift + Ctrl + S. This will ask you to name the project and you can name it anything. Once it is saved it will also copy to your clipboard. So open up a new file and paste it.


11. As you can see some of the information I posted in the game is here in the document. Now we have to add a few more lines of code. Look at the next picture and you can see what I had to add to make this button work.

12. I had to make class RJ_Example_Button: RscButton a subclass of class controls which is a subclass of class RJ47_Example. Read the comments in the picture to learn more. Make sure to add action line to the button config. It is important as nothing will happen if you don't define that.

13. Save the file as button.hpp. Now open up the mission folder which it should be in this directory
C:\Users\Ramon\Documents\Arma 3 - Other Profiles\yourusername\missions\RJ47_Example.Stratis
Now this is my file path to my mission and we need to save both defins and button.hpp in this folder.

14. After we saved these files we need to create a new file inside this directory and call it description.ext


These are the files you should have inside the directory.

15. Open up description.ext and add 2 lines of code. The ordering is important.

  1. #include "defines.hpp" 
  2. #include "button.hpp"

16. Now save this file and head back into ARMA 3 and lets spawn the button. Add a pole to the mission and edit the initialization block of the pole and add this code
  • this addAction["Spawn G.U.I.",{createDialog "RJ47_Example";}];

17. Click okay, save it, then preview the mission and head towards the pole and you should see your addAction title show up by looking at the pole. Select this and then boom your button is spawned on the screen. Now nothing will happen until you click your button. Click it and the message will spawn that was defined in the action code in the button.hpp.






This concludes this tutorial.