Schlachtfeld

Der Stafflerblog von Warzone2100.de

06.12.2008

Special interview #2: New widget system (betawidget)

Filed under: Development,English von Kreuvf um 14:12:01

Some time ago I had a special interview on 2.1 with devurandom. 2.1 is almost final, so it is time for another special interview. This time I talked to EvilGuru and Elio about the new widget system.

Kreuvf: First of all: What is a widget and what does a widget system do?
EvilGuru: A widget is something which the player interacts with. This could be a button, slider, colour picker or text box. A widget system is responsible for displaying these widgets on screen and managing them.

Kreuvf: What are the major advantages of the new widget system, betawidget?
EvilGuru: Betawidget has many advantages over the current widget system, both for developers and users.

For users it will

  • allow for a more attractive and lucid interface;
  • be able to adapt itself to the user’s screen resolution, making Warzone easier to play at higher resolutions, including those that are widescreen;
  • be significantly more customisable than the current system.

However, the primary motivation behind the development of betawidget was to make it easier for us (the developers) to add/change/modify the user interface. This is especially difficult using the current widget system, with even something as simple as adding a button taking a large amount of code.

For developers and modders it will

  • be significantly easier to work with;
  • allow the user-interface (UI) to be, firstly, scriptable and secondly modifiable using scripts;
  • require less code than the current widget system in order to complete the same task, resulting in fewer bugs.

Kreuvf: Will the new widget system be limited to Warzone 2100 only or do you plan to provide it for other applications as well?
Elio: Betawidget is intended to have a Qt-backend allowing the use in Qt-applications, such as Warzone Studio. An all-in-one solution covering every aspect of modding:

  • scripting
  • editing the tech tree
  • map making
  • editing the interface

EvilGuru: In fact, most of the development happens in an external simulator. Other Warzone-related applications such as map editors and mod editors may make use of it for parts of their interfaces. Of course, these applications are still very much on the drawing board, but it is nice to keep all avenues open.

Since betawidget is — like Warzone — open source there is nothing to stop others from taking it and integrating it into their own applications. However, it is important to stress that, as flexible as betawidget may be, it has been designed as a replacement for Warzone’s current widget system and not as a general-purpose toolkit.

Kreuvf: How can the UI be changed with the new widget system?
Elio: The whole UI is created from Lua scripts. This enables modders to include a UI without touching the source. Its class-like architecture is easy to understand and the API supports animations, too. So the new UI will be more dynamic and user-friendly.
EvilGuru: It will be possible to modify the UI in one of two ways. Firstly by using a Lua script to change an existing interface on-the-fly. So a mod developer might use a script to change the image/logo shown on the main title menu. This might look something like this:
widgetGetById(„warzoneLogo“):setImage(„myOwnLogo.svg“).

Although a trivial example (a modder could just override the current logo by placing a file with the same name in their mod) it does illustrate what is possible.

Secondly, since a large amount of the UI is planned to be implemented in Lua — as opposed to compiled C code — it will be possible for modders to simply open up and modify the script files (in the same way they would for unit/structure stats). By placing the modified script file in their mod they have the capability to customise the UI at a more fundamental level. Thus changing the interface will be only slightly more difficult than changing stats.

It is not just the modding community who benefit from having large portions of the UI written in Lua — developers do as well. This is because it is significantly easier to write and debug high-level Lua code as opposed to low-level C code.

Kreuvf: What are the advantages of having scalable vector graphics (SVG) and are there any pictures of a possible new UI?
Elio: There are some pictures of the new UI.New GUI and Twin Gauss Fortress

As you can see the base colour of the new UI is more blue-grayish, this gives it a modest and elegant appearance and brings gameplay into focus. There are also further sketches of possible new UI elements.New GUI and Commander interface

Additionally it looks sharp and nice on every screen resolution, because the UI adapts to it. So you can expect a wonderful, sexy UI no matter if it’s 640×480 (4:3) or 1280×720 (16:9). We can’t do this with the old raster graphics, which is why we need to get scalable vector graphics (SVG). In order to get those we need to ‚convert‘ the existing raster graphics into scalable vector graphics by hand and I have done most of this work already.New GUI and Unit design and comparison of two units
EvilGuru: Currently support for SVGs is done by way of the Cairo vector graphics library, which is also used by Firefox 3. Thanks, primarily to Elio, many of the games icons have been converted to SVGs. SVG is a vector graphics format which has good support by both Cairo and other 3rd party applications. (Inkscape and Adobe Illustrator are probably the most famous.) This will again aid customisability — as anyone can open up the icons and modify them in a way just not possible with bitmaps. This could allow for modders to create high-quality icon packs without having to start from scratch or pixel-edit pre-existing icons.

German translation available.

Comment on this (requires board account)