TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / iwd / GUIMOVIE.py
blobf69e772855c1e18c978c5e30dc228fdf2160c9a7
1 # -*-python-*-
2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003 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.
21 # GUIMOVIE.py - Play Movies window
23 ###################################################
25 import GemRB
26 from GUIDefines import *
28 MovieWindow = 0
29 TextAreaControl = 0
30 MoviesTable = 0
32 def OnLoad ():
33 global MovieWindow, TextAreaControl, MoviesTable
35 GemRB.LoadWindowPack ("GUIMOVIE", 640, 480)
36 MovieWindow = GemRB.LoadWindow (0)
37 MovieWindow.SetFrame ()
38 TextAreaControl = MovieWindow.GetControl (0)
39 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE)
40 PlayButton = MovieWindow.GetControl (2)
41 CreditsButton = MovieWindow.GetControl (3)
42 DoneButton = MovieWindow.GetControl (4)
43 MoviesTable = GemRB.LoadTable ("MOVIDESC")
44 for i in range (0, MoviesTable.GetRowCount () ):
45 t = MoviesTable.GetRowName (i)
46 if GemRB.GetVar(t)==1:
47 s = MoviesTable.GetValue (i, 0)
48 TextAreaControl.Append (s,-1)
49 TextAreaControl.SetVarAssoc ("MovieIndex",0)
50 PlayButton.SetText (17318)
51 CreditsButton.SetText (15591)
52 DoneButton.SetText (11973)
53 PlayButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, PlayPress)
54 CreditsButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, CreditsPress)
55 DoneButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, DonePress)
56 DoneButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
57 MovieWindow.SetVisible (WINDOW_VISIBLE)
58 return
60 def PlayPress ():
61 s = GemRB.GetVar("MovieIndex")
62 for i in range (0, MoviesTable.GetRowCount () ):
63 t = MoviesTable.GetRowName (i)
64 if GemRB.GetVar(t)==1:
65 if s==0:
66 s = MoviesTable.GetRowName (i)
67 MovieWindow.SetVisible (WINDOW_INVISIBLE)
68 GemRB.PlayMovie (s, 1)
69 MovieWindow.SetVisible (WINDOW_VISIBLE)
70 return
72 s = s - 1
75 def CreditsPress ():
76 MovieWindow.SetVisible (WINDOW_INVISIBLE)
77 GemRB.PlayMovie ("CREDITS", 1)
78 MovieWindow.SetVisible (WINDOW_VISIBLE)
81 def DonePress ():
82 if MovieWindow:
83 MovieWindow.Unload ()
84 GemRB.SetNextScript ("Start")