SystemHandler (version 1.17)

index
d:\cruisecontrol\game-client-system\game\common\scripts\systemhandler.py

 

 
Modules

      

 

fileIO

game

network

 

 

 
Classes

      

 

FileIO

GameBase

 
class FileIO

   

 

Methods defined here:

__init__(self, file, option='r')

Opens a file and appends it to the open file collection on success
if failed we return string describing error. On success we return NULL string and we added the file to the file collection
Options are 
        w: will allow write and read on a file removing current content 
        r: will allow read only on a file 
        a: will append to current file
        rw:will write into current content allowing reading as well

close(self)

Closes a file and removes it from the open file collection

read(self)

Read a file

write(self, content)

Write to a file

 

 
class GameBase

   

Is the game base framework that the main game class must extend. Must be registered using call registerGameClass(...)
 

 

Methods defined here:

destroy(self)

First thing called when game system is destroyed

intersectionCallback(self, objectName, event, sourceStateTuple)

objectName is the name of the entity who detected the instersectionevent is
what actully happened and sourceTargetTuple is an array of all the objects that
are currently intersecting this movable object. 
For instance is may get this movableObjectName -> robot_1, status -> Intersecting, 
sourceStateTuple -> ["robot_2","true"] for an intersecting robot_2 intersecting with
robot_1.

keyCallback(self, bkeyDown, strKey)

The function called when the user presses or releases keyboard buttons after the key is registered through keyEnabled(...).
When bKeyDown equals false then the user released the button. strKey is the string representation of the key in question.

networkCallback(self, event, data)

The function called when the system gets network package from an external resource. Is enabled after a call to networkConnect(...).
Event is an id (not used) and data is the a string that was receaved.

resourceCallback(self)

This callback will be called every time the system loads or unloads something (note must be notified by the system to turn up here).

setup(self)

First thing called after registration

systemCallback(self, event, message)

This callback will be called every time the system wants to say something. Messages expected are:
Event 10 means that we are loading something. Message is formated as a dictionary {'name':'Page_0_1', 'precent':51.32}
Event 11 means that we are unloading something. Message is formated as a dictionary {'name':'Page_0_1', 'precent':21}

timerCallback(self, trap, message)

The function called when a user requested a callback through funciton timerCallBack(...).
trap is the trap id sent through the timerCallBack call and message is the associated string.

 

 

   

 

 

 

 

 

 
Functions

      

 

addIntersectionDetection(movableObjectName)

Adds the movableobjectname to intersection detection. This object will be called back when ever another object
intersects it. The other object must exist in the list as well. Raises SystemHandlerError if we have not created
the base class or SystemIntersectionError if we could not add it to the system intersection list.

cleanUpAndExit()

delIntersectionDetection(movableObjectName)

Removes the movableobjectname from the list interested in intersection detection. Raises SystemHandlerError if we have not created
the base class or SystemIntersectionError if we could not remove from the system intersection list.

getGameClass()

keyEnabled(key, b=True)

Adds a key to be catched by our callback handler where key is a string. Refer to constants module for available keys. 
Raises SystemKeysError on failure.

networkConnect(port, strIp)

Connects this application to port 'port' at ip 'strIp' having the ip as string. We will get all network callbacks and messages through the class 
that extends the GameBase class. The method that receaves the call is networkCallback(...)

networkSend(str)

If networkConnect was successfull then this call sends str to connected computer. Raises SystemNetworkError on failure.

receaveMenuEvent(caller, event, param)

This will call the overrided receaveMenuEvent function made by implementer

registerGameClass(c)

Registers a class that extends the GameBase class. If no game class is registered then it will register c and call c.setup(initalizing the call.

timerCallBack(msec, trap=0, message='')

Timer request to be notified after msec with trap and message. The callback will be catched by the class that was registered using 
SystemManager.registerGameClass

(...) and the method timerCallback(...) will be called.

 

 
Data

      

 

__author__ = 'Kjartan A Jonsson'
__copyright__ = 'Copyright (c) 2007 aGameCompany'
__license__ = 'aGameCompany'
__source__ = '$Source: /cvsroot/game-client-system/scripts/SystemHandler.py,v $'
__version__ = '$Revision: 1.17 $'

 

 
Author

      

 

Kjartan A Jonsson