GUIScript: Use None instead if "", for null event handler.
[gemrb.git] / gemrb / GUIScripts / bg1 / Start.py
bloba3248eaccbee43d248128589c254e29916bbce4b
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
21 StartWindow = 0
22 QuitWindow = 0
23 ExitButton = 0
24 SinglePlayerButton = 0
25 MultiPlayerButton = 0
26 MoviesButton = 0
28 def OnLoad():
29 global StartWindow, QuitWindow
30 global ExitButton, MultiPlayerButton, MoviesButton, SinglePlayerButton
32 skip_videos = GemRB.GetVar ("SkipIntroVideos")
33 if not skip_videos:
34 GemRB.PlayMovie ('BG4LOGO',1)
35 GemRB.PlayMovie ('TSRLOGO',1)
36 GemRB.PlayMovie ('BILOGO',1)
37 GemRB.PlayMovie ('INFELOGO',1)
38 GemRB.PlayMovie ('INTRO',1)
39 GemRB.SetVar ("SkipIntroVideos", 1)
41 GemRB.LoadWindowPack("START")
43 #quit subwindow
44 QuitWindow = GemRB.LoadWindow(3)
45 QuitTextArea = QuitWindow.GetControl(0)
46 CancelButton = QuitWindow.GetControl(2)
47 ConfirmButton = QuitWindow.GetControl(1)
48 QuitTextArea.SetText(19532)
49 CancelButton.SetText(13727)
50 ConfirmButton.SetText(15417)
51 ConfirmButton.SetEventByName(0, "ExitConfirmed")
52 CancelButton.SetEventByName(0, "ExitCancelled")
53 ConfirmButton.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
54 CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
56 #main window
57 StartWindow = GemRB.LoadWindow(0)
58 SinglePlayerButton = StartWindow.GetControl(0)
59 MultiPlayerButton = StartWindow.GetControl(1)
60 MoviesButton = StartWindow.GetControl(2)
61 ExitButton = StartWindow.GetControl(3)
63 BackToMain()
65 GemRB.LoadMusicPL("Theme.mus")
66 return
68 def SinglePlayerPress():
70 SinglePlayerButton.SetText(13728)
71 MultiPlayerButton.SetText(13729)
72 MoviesButton.SetText(24110)
73 ExitButton.SetText(15416)
74 MultiPlayerButton.SetEventByName(0, "LoadSingle")
75 SinglePlayerButton.SetEventByName(0, "NewSingle")
76 MoviesButton.SetEventByName(0, "MissionPack")
77 ExitButton.SetEventByName(0, "BackToMain")
78 ExitButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)
79 if GemRB.GetString(24110) == "": # TODO: better way to detect lack of mission pack?
80 MoviesButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
81 return
83 def MultiPlayerPress():
85 SinglePlayerButton.SetText(11825)
86 MultiPlayerButton.SetText(20642)
87 MoviesButton.SetText(15416)
88 ExitButton.SetText("")
89 SinglePlayerButton.SetEventByName(0, "PregenPress")
90 MultiPlayerButton.SetEventByName(0, "ConnectPress")
91 MoviesButton.SetEventByName(0, "BackToMain")
92 MoviesButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)
93 ExitButton.SetEvent(0, None)
94 ExitButton.SetStatus(IE_GUI_BUTTON_DISABLED)
95 ExitButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
96 return
98 def ConnectPress():
99 #well...
100 return
102 def PregenPress():
103 if StartWindow:
104 StartWindow.Unload()
105 if QuitWindow:
106 QuitWindow.Unload()
107 GemRB.SetVar("PlayMode",0) #loadgame needs this hack
108 GemRB.GameSetExpansion(0)
109 GemRB.LoadGame(None)
110 GemRB.SetVar("PlayMode",-1)
111 GemRB.SetNextScript("GUIMP")
112 return
114 def LoadSingle():
115 if StartWindow:
116 StartWindow.Unload()
117 if QuitWindow:
118 QuitWindow.Unload()
119 GemRB.SetVar("PlayMode",0)
120 GemRB.GameSetExpansion(0)
121 GemRB.SetNextScript("GUILOAD")
122 return
124 def MissionPack():
125 if StartWindow:
126 StartWindow.Unload()
127 if QuitWindow:
128 QuitWindow.Unload()
129 GemRB.SetVar("PlayMode",3) #use mpsave for saved games
130 GemRB.GameSetExpansion(1)
131 GemRB.SetNextScript("GUILOAD")
132 return
134 def NewSingle():
135 if StartWindow:
136 StartWindow.Unload()
137 if QuitWindow:
138 QuitWindow.Unload()
139 GemRB.SetVar("PlayMode",0)
140 GemRB.GameSetExpansion(0)
141 GemRB.SetVar("Slot",1)
142 GemRB.LoadGame(None)
143 GemRB.SetNextScript("CharGen") #temporarily
144 return
146 def ExitPress():
147 StartWindow.SetVisible(WINDOW_INVISIBLE)
148 QuitWindow.SetVisible(WINDOW_VISIBLE)
149 return
151 def ExitConfirmed():
152 GemRB.Quit()
153 return
155 def MoviesPress():
156 #apparently the order is important
157 if StartWindow:
158 StartWindow.Unload()
159 if QuitWindow:
160 QuitWindow.Unload()
161 GemRB.SetNextScript("GUIMOVIE")
162 return
164 def ExitCancelled():
165 QuitWindow.SetVisible(WINDOW_INVISIBLE)
166 StartWindow.SetVisible(WINDOW_VISIBLE)
167 return
169 def BackToMain():
170 SinglePlayerButton.SetStatus(IE_GUI_BUTTON_ENABLED)
171 MultiPlayerButton.SetStatus(IE_GUI_BUTTON_ENABLED)
172 MoviesButton.SetStatus(IE_GUI_BUTTON_ENABLED)
173 ExitButton.SetStatus(IE_GUI_BUTTON_ENABLED)
174 SinglePlayerButton.SetText(15413)
175 MultiPlayerButton.SetText(15414)
176 MoviesButton.SetText(15415)
177 ExitButton.SetText(15417)
178 SinglePlayerButton.SetEventByName(IE_GUI_BUTTON_ON_PRESS, "SinglePlayerPress")
179 MultiPlayerButton.SetEventByName(IE_GUI_BUTTON_ON_PRESS, "MultiPlayerPress")
180 MoviesButton.SetEventByName(IE_GUI_BUTTON_ON_PRESS, "MoviesPress")
181 ExitButton.SetEventByName(IE_GUI_BUTTON_ON_PRESS, "ExitPress")
182 MoviesButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
183 ExitButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
184 ExitButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
186 QuitWindow.SetVisible(WINDOW_INVISIBLE)
187 StartWindow.SetVisible(WINDOW_VISIBLE)
188 return