bw logo

Chapter 5. Client Script Changes

Customers should update their Python scripts based on the below changes:

5.1. Input Handling

5.1.1. PyKeyEvent

Keyboard, mouse button, and joystick button event information is now encapsulated within the PyKeyEvent class. Python scripts will need to be updated in the following locations:

  • The personality script event handler handleKeyEvent now takes a single parameter, which is a PyKeyEvent instance.

  • GUI.handleKeyEvent now takes a single parameter, which should be a PyKeyEvent instance.

  • The handleKeyEvent and handleMouseButtonEvent methods on SimpleGUIComponent scripts need to be adjusted in the same way so that they take a single PyKeyEvent parameter.

  • BaseCamera.handleKeyEvent now takes a PyKeyEvent .

See the Client Python API for details on the PyKeyEvent class.

5.1.2. PyMouseEvent

Mouse movement events are now encapsulated within the PyMouseEvent class. Python scripts will need to be updated in the following locations:

  • The personality script event handler handleMouseEvent now takes a single parameter, which is a PyMouseEvent instance.

  • GUI.handleMouseEvent now takes a single parameter, which should be a PyMouseEvent instance.

  • The handleMouseEvent methods on SimpleGUIComponent scripts need to be adjusted in the same way so that they take a PyKeyEvent rather than passing deltas as individual parameters.

  • BaseCamera.handleMouseEvent now takes a PyMouseEvent .

See the Python Client API documentation for details on the PyMouseEvent class.

5.1.3. PyAxisEvent

Joystick axis events are now encapsulated within the PyAxisEvent class. Python scripts will need to be updated in the following locations:

  • The personality script event handler handleAxisEvent now takes a single parameter, which is a PyAxisEvent instance.

  • GUI.handleAxisEvent now takes a single parameter, which should be a PyAxisEvent instance.

  • The handleMouseEvent methods on SimpleGUIComponent scripts need to be adjusted in the same way so that they take a PyKeyEvent rather than passing deltas as individual parameters.

  • BaseCamera.handleAxisEvent now takes a PyAxisEvent.

See the Python Client API documentation for details on the PyAxisEvent class.

5.1.4. handleCharEvent

handleCharEvent has been removed as character events are now included as part of the PyKeyEvent class. Any character input logic needs to be moved to handleKeyEvent by checking to see if the character member of PyKeyEvent is None or a valid Unicode string.

5.1.5. SimpleGUIComponent.mouseButtonFocus

The SimpleGUIComponent.mouseButtonFocus now controls a number of events related to the mouse which was previously controlled by the SimpleGUIComponent.focus property. These are:

  • SimpleGUIComponent.handleMouseButtonEvent

  • SimpleGUIComponent.handleClickEvent

In order for these events to be called on the component scripts, be sure to set the mouseButtonFocus attribute to True, either via the scripts or within the .gui XML files.

5.1.6. SimpleGUIComponent.handleMouseButtonEvent

The SimpleGUIComponent.handleMouseButtonEvent will now only be called on one component, which is the top most component located beneath the mouse that has mouseButtonFocus set to True.

Previously, mouseButtonFocus would be called on the top most component as well as each other component that the mouse is under (whether or not it was hidden by another overlapping component).

Note

Keep in mind that handleKeyEvent will still be called for mouse buttons (i.e. it is treated as if it is any other key button press), as it did in previous versions (as long as handleMouseButtonEvent returns False).

5.2. Interpretation of Pitch

Previously, the interpretation of a pitch value was inconsistent throughout the BigWorld API. This has now been made consistent. A positive pitch is now consistently interpreted as nose pointing down and a negative pitch as nose pointing up. This has affected a number of APIs.

5.2.1. Direction Cursor

The meaning of minPitch and maxPitch have been swapped. minPitch is now the most that the pitch can point upwards and maxPitch is the most that the pitch can point downwards.

If the direction cursor setting are read out of engine_config.xml, the pitch related settings in the directionCursor section may need to be updated.

5.2.2. Cursor Camera

If the pitch of the cursor camera is now queried, it will now be the inverse of what it used to be.

5.2.3. TrackerNodeInfo

The minPitch and maxPitch arguments of TrackerNodeInfo have the opposite direction than the used to.