Basic knowledge of coding menus
Prior Knowledge Requirements: Creating/Modifying/Opening .Pk3s
Tools: PakScape, a good text editor like EditPlus.
Coding menus in Jedi Knight is not hard at all and can be compared to markup languages like HTML.
Calling it "coding" is actually not completly correct but since everyone does so, I'm gonna do so as well.
My goal with this tutorial is just to give you some small overview. I will go more into detail in future tutorials.
Your first step is to open PakScape and to extract all the ui-files (located in assets1.pk3) to your hard drive.
Now open the file main.menu with your text editor.
As you can see a menu consists of several different parts.
The assetGlobalDef affects all menu files and can only be found in the main.menu.
The menuDef is the header of every menu and sets stuff like the resolution, the name of the menu, etc.
The itemDefs are the actual elements of a menu. Text, images, buttons or videos are all itemDefs.
To go more into detail:
assetGlobalDef:
For beginners there is actually not much that is important to alter (there is also a lot hardcoded). I will explain in a future tutorial how you can change the fonts though.
menuDef:
name - sets the name of the menu. Attention! The name of the menu file (e.g. main.menu) can differ from the actual name of the menu that is set in the menuDef. I will explain later why this is important.
fullScreen - The main menu has to be fullscreen, other menus can open as a small window.
rect - sets the position and the resolution of the menu. If fullScreen is set to 1, it should be always set to 0 0 640 480.
visible - defines the visibility of the menu. Better set it to 1.
focusColor - sets the color of the item that is in focus (= in contact with the mouse).
desc... - the description-text that appears when you hover over the buttons (usually located at the bottom of the menu).
descX, descY - the positioning of the desc-text.
descScale - the size of the desc-text.
descColor - the color of the desc-text.
descAlignment - the alignment of the desc-text.
Itemdef
The Background (for example the Star Wars-logo on the top):
name - sets the name of the item. Can be important if you want to open or focus items.
group - can be useful if you want to centralize several items in one group.
style - defines the style of the item.
WINDOW_STYLE_EMPTY no background
WINDOW_STYLE_FILLED filled with background color
WINDOW_STYLE_GRADIENT gradient bar based on background color
WINDOW_STYLE_SHADER gradient bar based on background color
WINDOW_STYLE_TEAMCOLOR team color
WINDOW_STYLE_CINEMATIC cinematic
rect - the position and the resolution of the item. (Explanation in the end of the tutorial.)
background - the path of the background-image. Can also be a path to a shader-file.
forecolor - the fore color used in the item. Only useful if you use a color instead of an image as a background.
visible - defines the visibility of the item.
decoration - makes you not touching and picking the item with the mouse.
The Button (for example the Loadgame-button)
Pretty similar to the background-items. You can actually also use an image to be a button. But in JK:JA there are only text-buttons used.
text - the path to the text-string (I will explain that in a future tutorial).
descText - the path to the description text-string.
font - the font used for the text (1-4).
textscale - the size of the text.
textaligny, textalignx - changes the position of the text.
textalign - the alignment of the text.
textstyle - there are different textstyles, like shadowed text.
type - important command that can be used to implement listboxes, checkboxes, etc.
ITEM_TYPE_TEXT simple text
ITEM_TYPE_BUTTON button, basically text with a border
ITEM_TYPE_RADIOBUTTON toggle button, may be grouped
ITEM_TYPE_CHECKBOX check box
ITEM_TYPE_EDITFIELD editable text, associated with a cvar
ITEM_TYPE_COMBO drop down list
ITEM_TYPE_LISTBOX scrollable list
ITEM_TYPE_MODEL model
ITEM_TYPE_OWNERDRAW owner draw, name specs what it is
ITEM_TYPE_NUMERICFIELD editable text, associated with a cvar
ITEM_TYPE_SLIDER mouse speed, volume, etc.
ITEM_TYPE_YESNO yes no cvar setting
ITEM_TYPE_MULTI multiple list setting, enumerated
ITEM_TYPE_BIND multiple list setting, enumerated
ITEM_TYPE_TEXTSCROLL scrolls text
ITEM_TYPE_INTSLIDER mouse speed, volume, etc.
The "on"-commands
Only used in the menuDef:
onOpen - stuff that happens when the menu gets opened
onEsc - stuff that happens when the menu gets closed
Used in the itemDefs:
Action - gets executed when you click on the item. For example a new menu opens.
mouseEnter - gets executed when you touch the item with the mouse.
mouseExit - gets exectued when tou leave the item with the mouse.
doubleclick - gets executed when you doubleclick the item.
Rect
The rect-command works like this:
rect X Y W H
X = horizontal position
Y = vertical position
W = width
H = height
Colors
The colors work like this:
color R G B T
R = red
G = green
B = blue
T = transparency
All values can go from 0 to 1.
Loading menu files.
There are textfiles which are responsible for loading the actual menu files. For example the file that loads the singleplayer menus is called menus.txt.
Please note that the engine loads the menus by their actual filename not their "menu-name" that is defined in the menuDef.
This concludes my tutorial about basic menu coding.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now