GUI Dialog

Revision as of 18:56, 23 August 2009 by Dʹlanor (Talk | contribs)

Recently basic GUI support has been added to PyPRP. And when we say basic we really mean it. All you can make for now are static image GUIs.

Creating the GUI Dialog

First you need to create a plane for the GUI Dialog. Next you add a camera to the scene. Position the camera so that it points at the plane. Once you've got the camera situated right, you rotate it so that it points in the opposite direction of the plane.

Now go into edit mode. Open a UV editor window and choose UVs > Mirror > X Axis.


Then add this AlcScript:

<Camera>:
    type: guicamera
    name: <Camera>
    camera:
        hither: 0.5
        yon: 1000
    dialog:
        name: <plane object>
        camera: posteffectmod:<Camera>
        modal: true
        transparent: 0

The name of the plane object should be the name you want the GUI to be.

Cyan usually places GUIs in their own pages so you may want to do that as well.

Activating the GUI Dialog

You also need a clickable to activate the GUI. This clickable must be a different object than the GUI plane. You have two options here.

  1. Duplicate the GUI plane and use this duplicate as your clickable. If you gave the GUI its own page make sure the clickable is NOT in that page by removing its page_num text property. Hide the original GUI plane plus its camera somewhere the player cannot see it. Make sure to keep the relative positions of the plane and its camera or you'll be back at step one! The duplication method has the advantage that you can make the GUI object larger and more detailed than the clickable model.
  2. Or create an invisible clickable at the location of the GUI plane. Making an object invisible can be done with the following AlcScript:
<clickable object>:
    visual:
        render: false

Regardless of which method you followed you now need to add the this AlcScript to the clickable:

<clickable object>:
    logic:
        modifiers:
          - tag: ModDialog
            cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: <click region>
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: pythonfile
                ref: $PythDialog
        actions:
          - type: pythonfile
            tag: PythDialog
            pythonfile:
                file: xDialogToggle
                parameters:
                  - type: activator
                    ref: logicmod:$ModDialog
                  - type: skip
                  - type: skip
                  - type: string
                    value: <plane object>

Exiting the GUI Dialog

For now we can only exit the GUI dialog by pressing Escape or Backspace.


The normal method to exit a GUI dialog is by mouse click. This requires a clickoff plane which is in fact a large invisible GUI button encompassing the entire GUI camera view. Unfortunately GUI buttons are not yet implemented. Those of you familiar with libPlasma may be able to hack a pfGUIButtonMod into a GUI dialog from scratch (or rather from a Cyan example). If you are going to try this the hard way be sure to give your button the id 99 for this is the id that Python needs to exit the GUI.