Wiki Revision Page "Menu Guide" Revision 33:
---+ Menu Guide
-By Cobo-


---++ Introduction
This is a guide for Digital Paint Paintball2 Menus, What are the Menus? Well, if you dont know, Launch  Digital Paintball Paintball2 and look at your screen, what do you see? everything from top to bottom is a menu, click on the Play option and again from top to bottom a Menu. But where are they? all of them, from the Main Menu to the Scores window that you get on the game are on a folder named Menus(Yes really) and you can find that on \pball\menus\.
So now you want to learn more about Menus? well read on.

---++ Headers
---+++ What are they?
A Header is just the word i use to define the words that define what kind of menu you are making. Get it? No? Yes? Well open up the main_ingame Menu(\pball\menus\main_ingame.txt). What you have here is the menu that you get when you are playing and hit the escape key. now, lets take a look at the text, shall we?
The first line: pb2menu 1. is a must have in your menu, without it when you tried to run your menu you would get an error. so always remember to put it on your menus.
keep reading, and you should find the background header, so what is the background header? its the background! when you dont specify the background (dont write it) then the background will appear like the Main menu, a solid full size backgrouns. when you set the background to none (background none) then the background will be transparent, you can also set it to any image you have in the pics folder, for example menu_bg_ingame is a picture in the pics folder, that background is the one that is a rectangle from left to right. So this pretty mcuh covers backgrounds, so lets move on...
Lets say we want to make our menu be on top of other menus then you would change the type to dialog (type dialog).
---++ Widgets
---+++ What are they?
Widets are the most important part of a Menu, they could be text, a picture, a textobox, or any other thing that is on a Menu.
To make a Widget simply write widget (lower case) and then the next things you write will specify what kind of widget it is.
---+++ Positioning Widgets
There are many ways to position a widget on a menu for example lets say we want to position our widget on 200, 400 coordinates (X, Y) then you would put...
[code]widget
     xabs 200
     yabs 400[/code]
xabs and yabs stand for x absolute and y absolute. they mean where ever you specify x or y, thats where the widget will be, at X, Y. xabs and yabs could alose be x and y.

Another way to position your widget would be by relative positioning...
[code]widget
     xabs 200
     yabs 400
widget
     xrel 100
     yrel -100[/code]
Where xrel and yrel are x relative and y relative. That means that the second Widget would be positioned at 300, 300

One more way to possition widgets is by making them relative to the center...
[code]widget
     xcent -100
     ycent 100[/code]
Where xcent and ycent are x center and y center. So if you have a 800x600 resolution it would be at 300, 400 ((800/2)-100, (600/2)+100.

After you positioned your widget you can align it to a side, for example lets say you positioned your widget to 100, 100 and want your left corner aligned to that position, then you would have to do set halign left, it could also be halign right or halign center. But what if you want it aligned to the top of the widget? then you would use valign top, or valign bottom for bottom and valign center for aligning to the center. halign ans valign stand for horisontal align and vertical align.
---+++ Cvars explained
In case you dint know what a cvar is, its jsut a variable. almost everything in Digital Paintball Paintball2 is stored in variables, from the name you use (that would be 'name') To the current scores of the game (that is 'scores') Want to see for yourself? Then open up paintball2 and type in the console name, you should see that the console returns "name is ". you can even see all the cvars in the game, just type cvarlist, that will return them all. but cvars dont end there.
you can create your own custom cvars so you can use them later, for example, go to the console and type "set test hello" now hit enter and then type test, you should see that test is hello, the variable will remain there even if you close the game, where are they stored? In the config.cfg from the config folder. In a widget when you want to make a variable you would use "cvar " if the cvar doesnt exist it creates it, if it does, it uses the existing one.
---+++ Text Widget
This is the most common widget, its just text, but can also work as a button. you specify a text widget by setting the widget type as text. and the text with, well... text (test "This is the text"). You can make it act as a button by adding command ""
Example
[code]widget
     type text
     text "Hello World"
     xcent 0
     ycent -100
     command "menu pop"[/code]
When you click on the Hello World text the menu should dissapear and go to the previous menu (that's what "menu pop" does)
---+++ Pic Widget
Another kind of Widget is the pic widget, all it does is draws a selected picture into your menu and can work as a button as well. you ddeclare a widget a pic by writing: type pic. It is almost the same as a text widget, with a few differences. Instead of writing text for declaring the text, you would use pic to declare the picture, and the picture must be on your pics folder. Lets take a look at an example...
[code]widget
     type pic
     command "menu play"
     xcent 0
     ycent 0     
     halign center
     pic "m_play1"
     hoverpic "m_play1h"
     selectedpic "m_play1s"[/code]
So there you have it, a picture on the center that when you click it takes you to the Play menu. but what about those other things? Well, all they do is when you hover above the pic (hoverpic) then the hoverpic will kick in, and when you clikc it (selectedpic), you will the the selectedpic.
You can also change the pic's width and height by using picwidth and picheight.
---+++ Textbox Widget
You can also make a textbox in your menu, when you want to make a textbox you would have to set the type to field. You can also specify the width of the textbox, by writing width . Lets say you want to make a textbox, and you want it to have a label. but you dont want to spend time making 2 different widgets. then you would add "text " and then halign the widget to the right if you want the Label on the left, and to the left if you want it to the right. if you dont halign it to the left or right then the label will appear on the middle of the textbox. Now, imagine you have your textbox, but you need to use the text you enter in your textbox somewhere, in that case you would use a cvar. Here is an example...
[code]widget
     type field
     xcent -50
     y 100
     width 10
     cvar text[/code]
That would be a textbox, and anything you put in the textbox would be stored on the text cvar, so if you went to the console and typed "text" you would get what was typed on the field.
---+++ Put it on practice
Tired of all the theory? well, now we are going to make a menu, from top to bottom. what we are going to do is make a menu named QuickName, that will consist of a a pic, a textbox, and 2 text widgets. What it will do is that it will allow you to change your game name quickly.
Lets start by making a text file on the menus folder (right click, new, text Document) and rename it to QuickName.txt.
Now open it and type pb2menu 1 so we dont get an error. after that you are going to set the background to none and the type to dialog, because we want a small rectangle in top of everything else. So far we have this...
[code]pb2menu 1
backgrouond none
type dialog
command "set menu_tempname $name"[/code]
Notice anything different? yep, its a new header, all it does is runs that command when the menu is loaded.
Now we are going to create our widgets, since we want a little rectangle for our background we will use a pic to act as the background so add the following widgtet...
[code]widget
     type pic
     pic select1bm
     picwidth 200
     picheight 100
     xcent 0
     ycent 0
     halign center
     valign center[/code]
Now that we have our background lets make the textbox...
[code]widget
     type field
     cvar menu_tempname
     text "Name: "
     width 15
     xcent 90
     ycent -20
     halign right
So now that we have our textbox, lets make the buttons...
[code]widget
     type text
     text "[Cancel]"
     command "menu pop"
     xcent -90
     ycent 10
widget
     type text
     text "[OK]"
     command "set name $menu_tempname; menu pop"
     xcent 60
     ycent 10
There you have it, save it, go play in the game and type in the console "bind  menu QuickMenu". Now exit the console and press the key (while playing). If our menu does appear then you succesfully made a new menu, if it doesnt contact me (Cobo) and we can see what is the problem.