Game Development Reference
In-Depth Information
they required creating a system that heavily relied on scripting languages and text-
based data.
Thetwomaincomponents ofaUImodin World of Warcraft arethelayoutandthe
behavior. The layout of interfaces, such as placement of images, controls, buttons,
and so on, is stored in XML. The behavior of the UI is then implemented using the
Lua scripting language. Let's look at both aspects in more detail.
Layout and Events
The layout of the interface is entirely XML driven. It's set up with base widgets
such as frames, buttons, sliders, and check boxes that the UI developer can use.
So if you want a menu that looks like a built-in window, it's very much possible
to declare an interface that uses the appropriate elements. The system goes a step
further in that one can inherit from a particular widget and overwrite certain prop-
erties. Therefore, it would be possible to have a custom button XML layout that
derives from the base one and maybe modifies only certain parameters.
It's also in the XML file where the add-on specifies whether there are any partic-
ular events to register. In a WoW add-on, many different events can be registered,
some specific to widgets and some specific to the game as a whole. Widget-based
events include clicking a button, opening a frame, and sliding a slider. But the real
power of the event system is the plethora of game events. Whenever your char-
acter deals or takes damage or you chat with another player, check an item on an
auction house, or perform one of many different actions, a game event is gener-
ated. It is possible for a UI add-on to register to any of these events. For example,
a UI add-on that determines your DPS (damage per second) can be implemented
by tracking the combat damage events.
Behavior
The behavior of each interface add-on is implemented in Lua. This allows for
quick prototyping of behavior, and it's further possible to reload the UI while the
game is running. Because they utilize a table-based inheritance system, mods can
implement member functions that override parent systems. The bulk of the code
formostadd-onsisfocusedonprocessingtheeventsanddoingsomethingtangible
with that information. Every event that is registered must have corresponding Lua
code to handle it.
Search WWH ::




Custom Search