The GUIEditor allows for the creation of GUI Control Prototypes, in a WYSIWYG visual format. After a prototype has been created, a script can be written which creates nodes based on the prototype.
Starting the Editor
In older versions of HeroEngine, the GUI Editor needed to be started from the GUI Editor Toolbar.
In current versions, the GUI Editor is accessed by:
- Opening the Organizer Panel and selecting the GUI XML tab
- You may need to click on the arrows to find the tab at the far right
- It may take a moment for prototypes to load
- Choose a prototype to edit
- Double-click on the prototype to go into edit mode for it.
Create a New Prototype
- In your Organizer Panel is a tab marked GUIXML. If you do not have the Organizer visible, select it from the Panels menu.
- Click the Create New link at the bottom of the GUIXML panel. This should open a window. It will have four inputs on it:
- Prototype Name
- Inherit From
- This is where you choose what base control/window to use to create your control.
- Prototype Name
- Click the "Okay" button in the Window. The window will now be placed on the screen in its editable state.
- Whenever possible, try to coordinate with coworkers so that you are not creating a new prototype simultaneously, as only one client at a time can currently write to the XML .lst files.
- Note that the Properties Panel is now populated with the control's properties.
- If you have inherited from an existing prototype such as "_window", you might click on the "+" next to the name of your new window in the directory tree at the top section of the Properties Panel. Note that it has several child controls, some of which may have their own children. As you click on the name of each one, the Properties Panel reflects the GUIXML properties for it, and a different section of the created window is highlighted, to show which part you are dealing with.
- Only some properties may be changed on inherited children. For example, you can never change the name of an inherited control, nor can you change their order in their parent's children list. However, you can change many other useful properties, such as their layout (size, position, texture, color, et al) and script.
- Clicking on the name of the control that you created results in the entire control being highlighted in the viewport.
- Note that the selected control can be moved and resized, by dragging it around the screen.
- You can add new children to whatever control you have selected (caveat: GUILabel controls can not display children) by double-clicking the name of the desired child in the Organizer panel.
- Controls are added to whichever control is currently selected in the directory tree.
- Any children associated with the new control's prototype are added as well.
- The newly added control will be automatically selected when added, so if you are adding multiple controls to the same parent, be sure to reselect it each time (this is easily done by right-clicking in the GUI Editor area).
Appearance and Layout
Art for GUI Controls must be stored in the Repository in the form of a DirectDraw Surface (.DDS) file.
If you will not be creating your own art, you can skip this next section, or bring it to the attention of those who will.
Creating your own art
The first rule of creating your own art is: when in doubt, have an artist do it. However, should you not be an artist, and still find yourself with the need to create GUI art, read on.
I'm not going to go into a lot of detail regarding the creation of a new piece of art, and I'm going to assume you have a minimal working knowledge of Photoshop. The easiest way is to find art on Google Image Search, or use clip art or stock photography. You should avoid copyrighted images; it's possible to find royalty-free art, but this document is in no way going to address the legalities of what art may be used for what. Paste your art into Photoshop (or draw your own, if you prefer), and alter it as necessary (resizing, coloring, etc). Again, the specifics of this are way beyond the scope of this document. DDS files use the alpha channel to determine transparency, so you'll need to modify that as well.
Now switch back to the Layers tab, and make sure that the layer which contains your piece of art is selected. Using the wand and/or lasso tools, select only the portions of your art that you want to be visible. Often, the easiest way to do this is to simply click outside of the art with the Wand tool, thus selecting all of the transparent pixels, and hit Control-Shift-I, to invert the selection. Viola, only your art is selected. If your art has transparent pixels inside of it as well, you will want to make sure that the Wand tool has its Contiguous box unchecked (which means that it will select ALL qualifying pixels on the layer, instead of ignoring those which are separated from your click location by nontransparent pixels).
Now switch back to the Channels panel, and select only the Alpha 1 channel. Your selection should still be only the space taken up by your piece of art. Alpha channels work on a greyscale to determine opacity, where black is completely transparent, and white is completely opaque, so go to Edit->Fill and fill the selected area with White. You can play with making the borders somewhat darker, or using a gradient, but if you're getting into that much detail, an artist should probably have been doing it in the first place, or you should have just skipped this whole section 'cause you already know it.
Three important notes on DDS files:
- The image's dimensions should each be a power of 2 (256x256, 512x512, etc). This is to ensure compatibility with certain older display adapters. You should use the smallest size file you can get away with, and place your art in the upper left corner...this lets you expand the file's dimensions later if necessary, without the need to relocate your existing art.
- To save in the DDS format, your file must have a Background layer, and it must be visible, or the DDS plugin will report an Unsupported Format error.
- You must have a DDS plugin available to Photoshop. At the time of writing, this can be found in a utility package on nVidia's site at the bottom of this page. The plugin itself is called dds.8bi, and should be placed in the base Plugins folder, wherever Photoshop is located.
Making New Art Available
After you have your new art, you'll need to upload your new DDS file to the repository using the Repository Browser. The DDS file needs to be uploaded to your GUI art folder.
- defaultStatePresentation - how the control appears when no other state applies
- disabledStatePresentation - how the control appears when enabled=false
- hoverStatePresentation - how the control appears while the mouse is within its boundaries, and not within the boundaries of a child of the control (in which case the hover state transfers to the child). Note that the control must be receiving mouse events to activate the hover state. This includes transparency-related conditions: a control whose alpha at a given moused-over pixel is less than 10% will ignore the mouse unless specifically prohibited from doing so by means of the skipTextureAlphaTest flag.
- selectedStatePresentation - how the control appears while checked=true or selected=true. The selected flag applies to all controls, while checked applies only to controls which possess or inherit from the GUIRadioButton or GUICheckBox classes. Whichever flag has been set most recently will take precedence.
- selectedDisabledStatePresentation - a checked/selected=true control which is also enabled=false, such as an unavailable checkbox.
State presentations are complex fields with three subfields: size, position, and color. You will typically only be concerned with either size and position, or color, but will sometimes want to use all three.
Note that GUILabel class controls are treated differently by their state presentations. Changing the color of a GUILabel's state presentation will actually affect the text of the label, not provide a background color. Adding a texture to a GUILabel-based control will do nothing of interest.
Texture Mapping in a state presentation
The size and position fields of a state presentation refer to the image specified by the control's texture field. If a control has no texture field declared, size and position will do nothing. Used in conjunction, these two fields determine the placement and size of a rectangular slice of the image, to be applied to the control. While state presentations may (and frequently will) use different areas of a .dds file to determine a control's appearance, they must all use the same texture file. You cannot have your hover states in one .dds file, and your disabled states in another. The texture viewer shown to the right can be pulled up by clicking in the texture field in the GUI Editor, or on any of the state presentation fields or subfields, with the exception of color.
- Position is an xy field which determines the upper left corner of the rectangle, measured in pixels, where (0,0) is the upper left corner of the image itself.
- Size describes a rectangular portion of the texture of width (size.x) and height (size.y) to be applied to the control.
Color in a state presentation
Color, a complex field of type rgba, is most often used to set the background color of a control which has no texture applied to it. This simply fills the control with a solid color, such as the titlebar of the texture viewer to the right. If you are familiar with the 0 to 255 scale for RGB, rgba simply translates that into a float of range 0 to 1, with alpha (color.a) equating to completely transparent at 0, completely opaque at 1.
- The darker the original texture, the less it will appear to be affected by multiplication.
- Conversely, pixels which are pure white will take on the exact color they are being multiplied by
- A disabled state can often be created by simply using the texture map from the defaultStatePresentation and applying roughly a 50% grey to it. This will simply grey out the original control. You may have to play with the rgb values to get a good look, depending on your texture. Don't be fooled into lowering the alpha to increase the darkness, as that will only work on a black/dark background.
- An rgba of 1,1,1,1 will result in the texture's appearance being unchanged from the original.
- As you might guess from that, the default rgba for any given state presentation is 1,1,1,1.
- To save your changes, press the XML button on the toolbar to create the GUIXML code. The language will appear in the console window, along with a message that it has been copied to the clipboard. This is purely informational, however, as your GUIXML will have been automatically written to an .xml file in the repository.
- Exit the GUI Editor by clicking on the button in the GUI Editor Toolbar that says "Close Editor".