TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg2 / LoadScreen.py
blob97aac5ae718c33179403c7ff5fa3ed15e55c432a
1 # -*-python-*-
2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2004 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # LoadScreen.py - display Loading screen
22 ###################################################
24 import GemRB
25 import GUICommon
26 from GUIDefines import *
28 LoadScreen = None
29 hide = None
31 def SetLoadScreen ():
32 return
34 def StartLoadScreen ():
35 global LoadScreen
37 GemRB.LoadWindowPack ("guils", 640, 480)
38 LoadScreen = GemRB.LoadWindow (0)
39 LoadScreen.SetFrame ()
40 Middle = LoadScreen.GetControl (3)
41 LoadPic = GemRB.GetGameString (STR_LOADMOS)
42 if LoadPic == "":
43 #the addition of 1 is not an error, bg2 loadpic resrefs are GTRSK002-GTRSK006
44 LoadPic = "GTRSK00"+str(GemRB.Roll(1,5,1) )
45 Middle.SetMOS (LoadPic)
46 Progress = 0
47 GemRB.SetVar ("Progress", Progress)
48 if GUICommon.HasTOB():
49 Table = GemRB.LoadTable ("loadh25")
50 else:
51 Table = GemRB.LoadTable ("loadhint")
52 tmp = Table.GetRowCount ()
53 tmp = GemRB.Roll (1,tmp,0)
54 HintStr = Table.GetValue (tmp, 0)
55 TextArea = LoadScreen.GetControl (2)
56 TextArea.SetText (HintStr)
57 Bar = LoadScreen.GetControl (0)
58 Bar.SetVarAssoc ("Progress", Progress)
59 Bar.SetEvent (IE_GUI_PROGRESS_END_REACHED, EndLoadScreen)
60 LoadScreen.SetVisible (WINDOW_VISIBLE)
62 def EndLoadScreen ():
63 LoadScreen.SetVisible (WINDOW_VISIBLE)
64 LoadScreen.Unload()
65 return