TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg2 / GUIMOVIE.py
blob671e2ced7baf89a72123b81f1f0d87fb1a0610c5
1 # GemRB - Infinity Engine Emulator
2 # Copyright (C) 2003 The GemRB Project
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 import GemRB
20 import GUICommon
22 MovieWindow = 0
23 TextAreaControl = 0
24 MoviesTable = 0
25 PlayButton = 0
27 def OnLoad():
28 global MovieWindow, TextAreaControl, MoviesTable, PlayButton
30 GemRB.LoadWindowPack ("GUIMOVIE", 640, 480)
31 MovieWindow = GemRB.LoadWindow (0)
32 MovieWindow.SetFrame ()
33 TextAreaControl = MovieWindow.GetControl (0)
34 PlayButton = MovieWindow.GetControl (2)
35 CreditsButton = MovieWindow.GetControl (3)
36 DoneButton = MovieWindow.GetControl (4)
37 MoviesTable = GemRB.LoadTable ("MOVIDESC")
38 for i in range( MoviesTable.GetRowCount () ):
39 t = MoviesTable.GetRowName (i)
40 if GemRB.GetVar (t)==1:
41 s = MoviesTable.GetValue (i, 0)
42 TextAreaControl.Append (s,-1)
43 TextAreaControl.SetVarAssoc ("MovieIndex",0)
44 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE, OP_NAND)
45 TextAreaControl.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE, MoviePress)
46 PlayButton.SetText (17318)
47 CreditsButton.SetText (15591)
48 DoneButton.SetText (11973)
49 PlayButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, PlayPress)
50 PlayButton.SetStatus (IE_GUI_BUTTON_DISABLED)
51 CreditsButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, CreditsPress)
52 DoneButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, DonePress)
53 MovieWindow.SetVisible (WINDOW_VISIBLE)
54 return
56 def MoviePress():
57 PlayButton.SetStatus (IE_GUI_BUTTON_ENABLED)
58 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE,OP_SET) # show selection
59 return
61 def PlayPress():
62 s = GemRB.GetVar ("MovieIndex")
63 for i in range( MoviesTable.GetRowCount () ):
64 t = MoviesTable.GetRowName (i)
65 if GemRB.GetVar (t)==1:
66 if s==0:
67 PlayButton.SetStatus (IE_GUI_BUTTON_DISABLED)
68 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE,OP_NAND) # hide selection
69 s = MoviesTable.GetRowName (i)
70 GemRB.PlayMovie (s, 1)
71 MovieWindow.Invalidate ()
72 return
73 s = s - 1
74 return
76 def CreditsPress():
77 if MovieWindow:
78 MovieWindow.Unload ()
79 GemRB.SetNextScript ("GUISONGS")
80 return
82 def DonePress():
83 if MovieWindow:
84 MovieWindow.Unload ()
85 if GUICommon.HasTOB():
86 GemRB.SetNextScript ("Start2")
87 else:
88 GemRB.SetNextScript ("Start")
89 return