GUI Dialog

Revision as of 00:49, 10 October 2014 by Doobes (Talk | contribs) (Activating the GUI Dialog)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 and correctly uv map your GUI's texture onto it.

Next you add a camera to the scene. Position the camera so that it points towards the plane and occupies the amount of screen that you want it to (by looking through your camera in the Blender 3D window to make your final positioning of the plane and camera).Keep your plane within the inner dotted line of the camera view.

Once you've got the camera situated right, you then rotate it 180 degrees so that it points away from of the plane.

This will have the effect of "mirroring" your texture in game, so, to correct this, we now select your plane, go into edit mode and open a UV editor window, select all the plane's uvs and choose from the menu: UVs > Mirror > X Axis. In Blender, your texture will now look mirrored, but once in Uru it will be the correct way around. This is particularly important if your GUI contains writing of any kind.


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>

As you can see we are using the global Python file xDialogToggle for this. Note that in a multiplayer environment this file allows only one player at the time to view the GUI (you can test that with the D'ni note in the classroom).

When setting collision for the clickable, for offline URU, use Triangle Mesh or it won't work. For MOUL-based shards, use Convex Hull for best results.

Exiting the GUI Dialog

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

The usual 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 in PyPRP.


Hacking the GUI Button

This section shows how to hack a pfGUIButtonMod into a GUI dialog from scratch. The following assumes that you are already familiar with libPlasma and editing page (prp) files.

  • In Blender create a plane for the clickoff button, slightly below the GUI dialog plane. It should be larger than the GUI dialog plane. Since you do not want this button to be visible you must give it a fully transparent texture (other methods to disable drawing do not seem to work on GUI buttons).
  • Export.
  • Open the GUI prp file in your preferred libPlasma page editing tool.
  • Add the pfGUIButtonMod [00A1] as a new object to the page file. The libPlasma prc format for a pfGUIButtonMod is shown below.
<?xml version="1.0" encoding="utf-8"?>

<pfGUIButtonMod>
	<plKey Name="GUIClickOff" Type="pfGUIButtonMod" Location="[sequence prefix];[page number]" LocFlag="0x0000" />
	<SynchParams flags="0x00000000">
		<ExcludePersistentStates></ExcludePersistentStates>
		<VolatileStates></VolatileStates>
	</SynchParams>
	<ModFlags>
		<hsBitVector>kWantsInterest kInheritProcFromDlg </hsBitVector>
	</ModFlags>
	<ControlParams TagID="99" Visible="True" />
	<Handler>
		<pfGUICtrlProcObject NULL="True" />
	</Handler>
	<DynTextLayer>
		<plKey NULL="True" />
	</DynTextLayer>
	<DynTextMap>
		<plKey NULL="True" />
	</DynTextMap>
	<pfGUIColorScheme NULL="True" />
	<SoundIndices>
	</SoundIndices>
	<Skin>
		<plKey NULL="True" />
	</Skin>
	<Animation Name="">
	</Animation>
	<MouseOverAnimation Name="">
	</MouseOverAnimation>
	<NotifyType value="0" />
	<Draggable>
		<plKey NULL="True" />
	</Draggable>
</pfGUIButtonMod>
  • Match [sequence prefix];[page number] to your prp file.
  • The name of the object in this example is GUIClickOff. You can change the name but it is recommended to keep the other settings as they are. Also be sure to keep TagID 99 because that is the ID which Python needs to exit the GUI.


Now you need to edit two existing prp objects.

  • Open the plSceneObject [0001] of your clickoff plane and find its modifiers, which should be empty at this point. Add your pfGUIButtonMod here as the modifier.
	<Modifiers>
		<plKey Name="GUIClickOff" Type="pfGUIButtonMod" Location="[sequence prefix];[page number]" LocFlag="0x0000" />
	</Modifiers>
  • Match [sequence prefix];[page number] to your prp file.
  • Finally open the pfGUIDialogMod [0098] and find its controls, which should be empty at this point. Add your pfGUIButtonMod here as the control.
	<Controls>
		<plKey Name="GUIClickOff" Type="pfGUIButtonMod" Location="[sequence prefix];[page number]" LocFlag="0x0000" />
	</Controls>
  • Again match [sequence prefix];[page number] to your prp file.