TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg2 / GUISONGS.py
blobe75841dea54e9ef1938ec402f7d31aebd245de02
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 #instead of credits, you can listen the songs of the game :)
20 import GemRB
21 import GUICommon
23 MovieWindow = 0
24 TextAreaControl = 0
25 MoviesTable = 0
27 def OnLoad():
28 global MovieWindow, TextAreaControl, MoviesTable
30 GemRB.LoadWindowPack("GUIMOVIE", 640, 480)
31 MovieWindow = GemRB.LoadWindow(0)
32 MovieWindow.SetFrame ()
33 TextAreaControl = MovieWindow.GetControl(0)
34 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE)
35 PlayButton = MovieWindow.GetControl(2)
36 CreditsButton = MovieWindow.GetControl(3)
37 DoneButton = MovieWindow.GetControl(4)
38 MoviesTable = GemRB.LoadTable("SONGLIST")
39 for i in range(0, MoviesTable.GetRowCount() ):
40 s = MoviesTable.GetValue(i, 0)
41 TextAreaControl.Append(s,-1)
42 TextAreaControl.SetVarAssoc("MovieIndex",0)
43 PlayButton.SetText(17318)
44 CreditsButton.SetText(15591)
45 DoneButton.SetText(11973)
46 PlayButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PlayPress)
47 CreditsButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CreditsPress)
48 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonePress)
49 MovieWindow.SetVisible(WINDOW_VISIBLE)
50 return
52 def PlayPress():
53 s = GemRB.GetVar("MovieIndex")
54 t = MoviesTable.GetValue(s, 1)
55 GemRB.LoadMusicPL(t,1)
56 return
58 def CreditsPress():
59 GemRB.PlayMovie("endcrdit", 1)
60 return
62 def DonePress():
63 if MovieWindow:
64 MovieWindow.Unload()
65 if GUICommon.HasTOB():
66 GemRB.SetNextScript ("Start2")
67 else:
68 GemRB.SetNextScript ("Start")
69 return