How to script the ingame GUI

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Submitted workflow.png This article covers a submitted workflow.

Sumbitted workflows are currently under consideration to be utilized by the development department(s).

This tutorial gives some starting points how you can script the ingame GUI of PARPG.

Contents

What is pychan?

Pychan is a Python wrapper around the C++-based GUI library guichan. As pychan is the only GUI library that is supported out of the box by FIFE, PARPG will use pychan for implementing our ingame GUI.

Pychan demo

FIFE ships with a pychan demo client; this is the best starting point to get familiar with the library. We're assuming that you have already checked out a copy of FIFE's SVN trunk to run PARPG. If not, you can find more information how to do so here: Download#SVN.

Once you have checked out FIFE's trunk and built FIFE from source, you're ready to play around with the pychan_demo. To do so, cd into <FIFE>/demos/pychan_demo and run pychan_demo.py. Pychan demo shows a bunch of different example widgets, including the XML markup for them.

XML markup

While the Pychan API can be easily accessed via Python as well, most widgets can be easily created without writing a single line of Python code for them. Pychan offers support for XML-based GUI scripting; this kind of scripting is more intuitive for developers who are not coming from a programming background. PARPG's GUI will be mainly implemented via easy to read XML code.

To get an idea how pychan's XML markup looks like, cd into <FIFE>/demos/pychan_demo/gui/ and check out the XML files in there with a text editor of your choice; preferably one that offers syntax highlighting for XML. Taking a look at the different XML stylesheets will give you a good idea how pychan's XML scripting works. Play around with the XML files and run pychan_demo.py afterwards to see what kind of results your changes led to.

Supported widget types

All supported pychan widgets can be created via XML markup as well. Here's a complete list of all widgets types that are supported by pychan: http://fifedocs.boxbox.org//epydoc/fife.extensions.pychan.widgets%27-module.html

Keep in mind that this documentation was written for pychan's Python API. Nevertheless the information applies to XML-based GUI scripting as well.

Scripting process

Personal tools