GUI Architecture

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Submitted code proposal.png This article features an submitted code proposal.

Submitted code proposals are currently under consideration for implementation.


The current GUI code in PARPG is rather sketchy at best. There is no real consistent way to do things and Hud is becoming a conglomeration of doing all the GUI interactions. This article is an attempt to reorganize how our GUI code is made and standardize the future process for implementing new GUI widgets to the game.

If you are not familiar yet on how the GUI code works in the game you can check out several files within PARPG itself, but also check out the following links to get a grasp on how PyChan works.

  • PyChan Overview - Good information on the general construction of a typical PyChan GUI construction
  • FIFE Documentation - This further explains the syntax of using PyChan

To see PARPG's GUI code just look in the <parpg>/scripts/gui/ directory in your project or via trac. Discussion on this proposal can be found on the forums via this link. There is currently a branch in svn for all the GUI changes that will be made. Odds are that it may end up being more up to date than this article (though I will try in earnest to keep it current!). The link of which is: [1]


This section went through a major overhaul to accommodate the coding specs. Most everything has been translated over just more concisely.


There are a few basic concepts that are going to be important in the GUI redesign. The biggest is modularity. It will be nice to be able to load and unload whatever graphical interfaces on the fly when we need to and without them being co-dependent on other completely unrelated interface objects. Thus we are going to be breaking down the structure into a single GUIManager and the components of the gui, GUIModule. These two will function as classes and have been named so that their purpose is rather obvious but here is several things that we will be keeping in mind when implementing new objects.

  • The GUIManager is going to act as the state holder for our graphical interface. This means that it will track when the game needs to be paused. What GUIModule are displaying, and it will also call the show/hide method of the GUIModule.
  • The GUIModules are the modules of the UI. Each instance of the GUI should have its own widget. So for instance, the heads up display should be one widget, while the quest log should be another, and the dialog widget yet another.
  • GUIModules is intended to be used as an extended class. This will allow us to follow the guidelines of the GUIModule, and tailor each one to its specific needs as well.

The coding requirements specify the precise needs of each class.

Specific Coding Requirements


  • Dictionary of module names to the module objects that are currently loaded in the game.
  • Pausing method that allows us to track when the game is (un)paused.
  • A "current_widget" which allows us to track which widget we are currently performing an action on.
  • Show/Hiding methods for the current widget. This will call the show/hide method of GUIModule but also do all of the checking to make sure the widget displays properly and also hides any other widgets that needs to be hidden as well as manage the pausing state.


  • Blocking boolean which defines whether or not the widget should be displayed with other widgets or if it should be hidden
  • Blockable boolean which defines whether or not the widget should be blocked by another widget being called with Blocking set to true.
  • Pausing object which determines whether or not the widget should pause the game when shown.
  • Show/Hide methods which make sure the widget specific needs are met before calling pychan's show/hide methods.
  • Locking boolean which will determine if the current_widget should cause all other widgets to be unusable until current_widget is closed or it causes a new widget to open. (For example main menu locking all widgets, but then opening a dialog box that is also locking)

Personal tools