Schlachtfeld

Der Stafflerblog von Warzone2100.de

06.12.2008

Spezialinterview #2: Neues Widget-System (betawidget)

Filed under: Deutsch,Entwicklung von Kreuvf um 14:12:23

Vor einiger Zeit hatte ich mit DevUrandom ein Spezialinterview zu 2.1 geführt. 2.1 ist so gut wie fertig, es ist also an der Zeit für ein weiteres Spezialinterview. Dieses Mal habe ich mit EvilGuru und Elio über das neue Widget-System gesprochen.

Kreuvf: Zuallererst: Was ist ein Widget und was macht ein Widget-System?
EvilGuru: Ein Widget ist etwas, mit dem der Spieler interagiert. Es könnte sich um einen Knopf, einen Schieber, Farbwähler oder eine Textbox handeln. Ein Widget-System ist für die Darstellung und Verwaltung von Widgets auf dem Bildschirm zuständig.

Kreuvf: Was sind die Hauptvorteile des neuen Widget-Systems, betawidget?
EvilGuru: Betawidget hat viele Vorteile gegenüber dem derzeitigen Widget-System, für Entwickler als auch für Benutzer.

Vorteile für Benutzer:

  • ein ansehnlicheres und helleres Interface;
  • die Fähigkeit sich an die Bildschirmauflösung anzupassen, was es einfacher macht Warzone mit höheren Auflösungen (auch Breitbild) zu spielen;
  • deutlich einfacher anpassbar als das jetzige System.

Die Hauptmotivation hinter der Entwicklung von betawidget war es jedoch es für uns (die Entwickler) einfacher zu machen dem Benutzerinterface etwas hinzuzufügen und es zu verändern. Dies ist besonders schwierig mit dem jetzigen Widget-System zu erreichen, wo selbst etwas so Einfaches wie das Hinzufügen eines Knopfes Unmengen an Code braucht.

Vorteile für Entwickler und Modder:

  • deutlich vereinfachter Umgang damit;
  • Möglichkeit das Benutzerinterface zum einen aus Skripten aufzubauen und zum anderen mit Skripten zu verändern;
  • weniger Code für die selbe Aufgabe benötigt als mit dem jetzigen Widget-System, was auch weniger Fehler bedeutet

Kreuvf: Wird das neue Widget-System auf Warzone 2100 beschränkt sein oder plant ihr es auch für andere Anwendungen anzubieten?
Elio: Betawidget hat absichtlich einen Qt-Unterbau, der die Verwendung in Qt-Anwendungen wie Warzone Studio erlaubt. Warzone Studio ist eine eierlegende Wollmilchsau, die jeden Aspekt des Moddings abdeckt:

  • Scripting
  • Bearbeitung des Technologiebaumes
  • Kartenerstellung
  • Bearbeitung des Interface

EvilGuru: Tatsächlich findet der Großteil der Entwicklung in einem externen Simulator statt. Andere Warzone-verwandte Anwendungen wie Karteneditoren und Modeditoren können Teile davon für ihre Interfaces benutzen. Selbstverständlich sind viele dieser Anwendungen noch am Reißbrett, aber es ist schön sich alle Möglichkeiten offen zu halten.

Da betawidget — wie Warzone — Open Source ist, gibt es nichts, das andere davon abhalten könnte es zu nehmen und in ihre eigenen Anwendungen einzubauen. Es ist jedoch wichtig zu verdeutlichen, dass, so flexibel betawidget auch sein möge, es als Ersatz für Warzones derzeitiges Widget-System konzipiert wurde und nicht als Mehrzweck-Werkzeugkasten.

Kreuvf: Wie kann die GUI mit dem neuen Widget-System verändert werden?
Elio: Die komplette GUI ist aus Lua-Skripten erstellt. Dies erlaubt Moddern eine GUI mitzuliefern ohne den Quelltext anfassen zu müssen. Die klassenmäßige Architektur ist einfach zu verstehen und die API unterstützt auch Animationen. Deswegen wird die neue GUI dynamischer und nutzerfreundlicher sein.
EvilGuru: Es wird möglich sein die UI auf eine von zwei Arten zu ändern. Zuerst durch die Verwendung eines Lua-Skripts zum fliegenden Ändern eines bestehenden Interface. Ein Modentwickler könnte also ein Skript verwenden, um das Bild/Logo im Hauptmenü zu verändern. Dies sähe dann in etwa so aus:
widgetGetById(„warzoneLogo“):setImage(„myOwnLogo.svg“).

Obwohl dies ein triviales Beispiel ist (ein Modder könnte das derzeitige Logo einfach mit einer Datei im Mod, die den gleichen Namen trägt, überschreiben), zeigt es, was möglich ist.

Zweitens, da geplant ist einen großen Anteil der UI in Lua zu implementieren — im Gegensatz zu kompiliertem C-Code — wird es für Modder möglich einfach Skriptdateien zu öffnen und zu bearbeiten (auf die gleiche Art und Weise wie sie es jetzt für Einheiten/Gebäude-Eigenschaften tun würden). Durch das Ausliefern des Mods mit der veränderten Skriptdatei haben sie die Möglichkeit die UI auf eine viel fundamentalere Art zu verändern. Daher wird es nur ein wenig schwerer das Interface zu verändern als Eigenschaften (von Einheiten, Waffen, Forschungsthemen) zu verändern.

Aber nicht nur die Modding-Community wird von einer zum Großteil in Lua geschriebenen UI profitieren — auch Entwickler profitieren. Das liegt daran, dass es sehr viel einfacher ist Lua-Code (high-level) zu schreiben und zu warten als C-Code (low-level).

Kreuvf: Was sind die Vorteile skalierbarer Vektorgrafiken (SVG) und gibt es schon Bilder der neuen GUI?
Elio: Es gibt da einige Bilder der neuen GUI.Neue GUI und Zwillings-Gauss-Festung

Wie du sehen kannst ist die Grundfarbe der neuen GUI mehr bläulich-gräulich, das gibt dem Spiel einen maßvollen und eleganten Look und bringt das Gameplay in den Vordergrund. Es gibt auch weitere Skizzen möglicher neuer GUI-Elemente.Neue GUI und Commander-Interface

Zusätzlich dazu sieht es unter jeder Auflösung scharf und schön aus, weil die GUI sich anpasst. Du kannst also eine wundervolle, sexy GUI erwarten, egal, ob es unter 640×480 (4:3) oder 1280×720 (16:9) ist. Mit den alten Rastergrafiken können wir dies nicht tun, weshalb wir skalierbare Vektorgrafiken brauchen. Um diese zu erhalten, müssen wir die bestehenden Rastergrafiken von Hand in skalierbare Vektorgrafiken „umwandeln“ und die meiste Arbeit habe ich bereits erledigt.Neue GUI und Einheitenentwurf und Vergleich zweier Einheiten
EvilGuru: Derzeit wird die SVG-Unterstützung durch die Cairo-Vektorgrafikbibliothek gestellt, die auch in Firefox 3 verwendet wird. Dank Elio hauptsächlich sind viele der Symbole im Spiel bereits konvertiert. SVG ist ein Vektorgrafikformat, das gute Unterstützung durch Cairo und andere Anwendungen Dritter erfährt. (Inkscape und Adobe Illustrator sind wohl die bekanntesten.) Auch das wird wieder der Anpassbarkeit helfen — da jeder die Symbole öffnen und ändern kann auf eine Art und Weise, die mit Bitmaps einfach nicht möglich ist. Dies könnte es Moddern ermöglichen hochqualitative Symbolpakete zu erstellen ohne von 0 anfangen zu müssen oder bestehende Symbole pixelweise zu verändern.

Dieses Interview ist eine Übersetzung des englischen Originals.

Kommentare zu diesem Artikel abgeben (benötigt Boardaccount)

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)