Table of Contents
Once the bar's GUI file has been generated, you can incorporate it to your game, both at the loading screen or during the transition due to a teleport.
Once the GUI file has been created, it is a simple task to display it in your game, and update its value.
The first step to have your game display the bar is to associate it with its GUI file, as illustrated below:
import GUI progressBar = GUI.load( "guis/progress_bar.gui" )
And display it via method
GUI.addRoot()
:
GUI.addRoot( progressBar)
If you derived your script from the class PyGUIBase, then you can also display the bar via the script's active method, as illustrated below:
progressBar.script.active(1)
Built into the client engine is a progress bar for tracking start-up. This can be used directly in your game, or just used as example code.
Place the following entry in file
<res>
/resources.xml
(where
<res>
is the first
folder specified in environment variable
BW_RES_PATH):
<system> <loadingScreenGUI> folder/loading_screen.gui </loadingScreenGUI> </system>
<res>
/resources.xml—Defining
file for the loading screen
The application will invoke your GUI script as it initialises. The loading screen/progress bar file must have the following interface:
def setProgress( self, value ): #change the progress bar here pass def addMessage( self, str ): #display a loading message on-screen pass
Loading screen/progress bar file
folder/loading_screen.gui
There is a method called spaceLoadStatus()
,
which returns the percentage of the world that has been loaded. This
feature can be used to update a progress bar when the player is
teleporting to another part of world.
The method's signature is illustrated below:
BigWorld.spaceLoadStatus( distance )
To link your progress bar up to the chunk loading, you will have to poll this method, as illustrated below:
def progressCheck( self, endTime ): finished = (endTime < BigWorld.time()) if not finished: status = BigWorld.spaceLoadStatus( self.distance ) finished = (status > 0.95) if finished: self.setProgress(1.0) self.component.fader.value = 0.0 if self.callbackFn: BigWorld.callback( self.component.fader.speed, self.callbackFn ) else: self.setProgress( status ) BigWorld.callback( self.checkRate, Functor( self.progressCheck, endTime ) )
Updating the progress bar with chunk loading status
Note
While you have a space loading loading screen displayed, it is
recommended that you disable rendering of the world by calling
BigWorld.worldDrawEnabled(False)
. You can re-enable world
rendering once the progress bar has completed by calling
BigWorld.worldDrawEnabled(True)
. Besides disabling rendering
while loading, it will also suppress warnings when files are accessed from
the main thread (which is bad during game play, but is generally
acceptable during the loading screen phase - see
How To Avoid Files Being Loaded in the Main Thread).