iwd: more gcw syncing with bg2 - actonpc and dragging
[gemrb.git] / gemrb / GUIScripts / bg2 / Start2.py
blobe068471192d6e193db11f24e2439230b36373d2c
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 #this is essentially Start.py from the SoA game, except for a very small change
20 import GemRB
21 import GUICommon
23 StartWindow = 0
24 TutorialWindow = 0
25 QuitWindow = 0
26 ExitButton = 0
27 SinglePlayerButton = 0
28 OptionsButton = 0
29 MultiPlayerButton = 0
30 MoviesButton = 0
32 def OnLoad():
33 global StartWindow, TutorialWindow, QuitWindow
34 global ExitButton, OptionsButton, MultiPlayerButton, MoviesButton, SinglePlayerButton
35 global SinglePlayerButton
37 skip_videos = GemRB.GetVar ("SkipIntroVideos")
39 GemRB.LoadWindowPack("START", 640, 480)
40 #tutorial subwindow
41 TutorialWindow = GemRB.LoadWindow (5)
42 TextAreaControl = TutorialWindow.GetControl (1)
43 CancelButton = TutorialWindow.GetControl (11)
44 PlayButton = TutorialWindow.GetControl (10)
45 TextAreaControl.SetText (44200)
46 CancelButton.SetText (13727)
47 PlayButton.SetText (33093)
48 PlayButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, PlayPress)
49 CancelButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, CancelTut)
50 PlayButton.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
51 CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
52 #quit subwindow
53 QuitWindow = GemRB.LoadWindow (3)
54 QuitTextArea = QuitWindow.GetControl (0)
55 CancelButton = QuitWindow.GetControl (2)
56 ConfirmButton = QuitWindow.GetControl (1)
57 QuitTextArea.SetText (19532)
58 CancelButton.SetText (13727)
59 ConfirmButton.SetText (15417)
60 ConfirmButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, ExitConfirmed)
61 CancelButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, ExitCancelled)
62 ConfirmButton.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
63 CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
64 #main window
65 StartWindow = GemRB.LoadWindow (0)
66 StartWindow.SetFrame ()
67 #this is the ToB specific part of Start.py
68 if GemRB.GetVar("oldgame")==1:
69 if GUICommon.HasTOB():
70 StartWindow.SetPicture("STARTOLD")
71 if not skip_videos:
72 GemRB.PlayMovie ("INTRO15F", 1)
73 else:
74 if not skip_videos:
75 GemRB.PlayMovie ("INTRO", 1)
77 #end ToB specific part
78 SinglePlayerButton = StartWindow.GetControl (0)
79 ExitButton = StartWindow.GetControl (3)
80 OptionsButton = StartWindow.GetControl (4)
81 MultiPlayerButton = StartWindow.GetControl (1)
82 MoviesButton = StartWindow.GetControl (2)
83 BackButton = StartWindow.GetControl (5)
84 StartWindow.CreateLabel(0x0fff0000, 0,450,640,30, "REALMS", "", 1)
85 Label=StartWindow.GetControl (0x0fff0000)
86 Label.SetText (GEMRB_VERSION)
87 if not GUICommon.HasTOB():
88 BackButton.SetState (IE_GUI_BUTTON_DISABLED)
89 BackButton.SetText ("")
90 else:
91 BackButton.SetState (IE_GUI_BUTTON_ENABLED)
92 BackButton.SetText (15416)
93 SinglePlayerButton.SetState (IE_GUI_BUTTON_ENABLED)
94 ExitButton.SetState (IE_GUI_BUTTON_ENABLED)
95 OptionsButton.SetState (IE_GUI_BUTTON_ENABLED)
96 MultiPlayerButton.SetState (IE_GUI_BUTTON_ENABLED)
97 MoviesButton.SetState (IE_GUI_BUTTON_ENABLED)
98 SinglePlayerButton.SetText (15413)
99 ExitButton.SetText (15417)
100 OptionsButton.SetText (13905)
101 MultiPlayerButton.SetText (15414)
102 MoviesButton.SetText (15415)
103 SinglePlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, SinglePlayerPress)
104 ExitButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, ExitPress)
105 OptionsButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, OptionsPress)
106 MultiPlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, MultiPlayerPress)
107 MoviesButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, MoviesPress)
108 BackButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, Restart)
109 ExitButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
110 QuitWindow.SetVisible (WINDOW_INVISIBLE)
111 TutorialWindow.SetVisible (WINDOW_INVISIBLE)
112 StartWindow.SetVisible (WINDOW_VISIBLE)
113 MusicTable = GemRB.LoadTable ("songlist")
114 # the table has useless rownames, so we can't search for BG2Theme
115 theme = MusicTable.GetValue ("33", "RESOURCE")
116 GemRB.LoadMusicPL (theme, 1)
117 return
119 def SinglePlayerPress():
121 OptionsButton.SetText ("")
122 SinglePlayerButton.SetText (13728)
123 ExitButton.SetText (15416)
124 MultiPlayerButton.SetText (13729)
125 MoviesButton.SetText (33093)
126 MultiPlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, LoadSingle)
127 SinglePlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, NewSingle)
128 MoviesButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, Tutorial)
129 ExitButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, BackToMain)
130 OptionsButton.SetState (IE_GUI_BUTTON_DISABLED)
131 return
133 def MultiPlayerPress():
135 OptionsButton.SetText ("")
136 SinglePlayerButton.SetText (20642)
137 ExitButton.SetText (15416)
138 MultiPlayerButton.SetText ("")
139 MoviesButton.SetText (11825)
140 MultiPlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, None)
141 SinglePlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, ConnectPress)
142 MoviesButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, PregenPress)
143 ExitButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, BackToMain)
144 MultiPlayerButton.SetState (IE_GUI_BUTTON_DISABLED)
145 OptionsButton.SetState (IE_GUI_BUTTON_DISABLED)
146 return
148 def ConnectPress():
149 #well...
150 #GemRB.SetVar("PlayMode",2)
151 return
153 def PregenPress():
154 if StartWindow:
155 StartWindow.Unload()
156 if QuitWindow:
157 QuitWindow.Unload()
158 if TutorialWindow:
159 TutorialWindow.Unload()
160 #do not start game after chargen
161 GemRB.SetVar("PlayMode",-1) #will allow export
162 GemRB.SetVar("Slot",0)
163 GemRB.LoadGame(None)
164 GemRB.SetNextScript ("CharGen")
165 return
167 def LoadSingle():
168 if StartWindow:
169 StartWindow.Unload()
170 if QuitWindow:
171 QuitWindow.Unload()
172 if TutorialWindow:
173 TutorialWindow.Unload()
174 if GemRB.GetVar ("oldgame") == 0:
175 GemRB.GameSetExpansion(1)
176 GemRB.SetVar ("PlayMode", 2)
177 GemRB.SetVar ("SaveDir", 1)
178 else:
179 GemRB.GameSetExpansion(0)
180 GemRB.SetVar ("PlayMode", 0)
181 GemRB.SetVar ("SaveDir", 0)
183 GemRB.SetNextScript ("GUILOAD")
184 return
186 def NewSingle():
187 if StartWindow:
188 StartWindow.Unload()
189 if QuitWindow:
190 QuitWindow.Unload()
191 if TutorialWindow:
192 TutorialWindow.Unload()
193 if GemRB.GetVar ("oldgame") == 0:
194 GemRB.GameSetExpansion(1)
195 GemRB.SetVar ("PlayMode", 2)
196 GemRB.SetVar ("SaveDir", 1)
197 else:
198 GemRB.GameSetExpansion(0)
199 GemRB.SetVar ("PlayMode", 0)
200 GemRB.SetVar ("SaveDir", 0)
201 GemRB.SetVar("Slot",1)
202 GemRB.LoadGame(None)
203 GemRB.SetNextScript ("CharGen")
204 return
206 def Tutorial():
207 StartWindow.SetVisible (WINDOW_INVISIBLE)
208 TutorialWindow.SetVisible (WINDOW_VISIBLE)
209 return
211 def PlayPress():
212 if StartWindow:
213 StartWindow.Unload()
214 if QuitWindow:
215 QuitWindow.Unload()
216 if TutorialWindow:
217 TutorialWindow.Unload()
218 GemRB.SetVar("PlayMode",1) #tutorial
219 GemRB.SetVar("SaveDir",0)
220 GemRB.GameSetExpansion(0)
221 GemRB.SetVar("Slot",1)
222 GemRB.LoadGame(None)
223 GemRB.SetNextScript ("CharGen")
224 return
226 def CancelTut():
227 TutorialWindow.SetVisible (WINDOW_INVISIBLE)
228 StartWindow.SetVisible (WINDOW_VISIBLE)
229 return
231 def ExitPress():
232 StartWindow.SetVisible (WINDOW_INVISIBLE)
233 QuitWindow.SetVisible (WINDOW_VISIBLE)
234 return
236 def ExitConfirmed():
237 GemRB.Quit()
238 return
240 def OptionsPress():
241 #apparently the order is important
242 if StartWindow:
243 StartWindow.Unload()
244 if QuitWindow:
245 QuitWindow.Unload()
246 if TutorialWindow:
247 TutorialWindow.Unload()
248 GemRB.SetNextScript ("StartOpt")
249 return
251 def MoviesPress():
252 #apparently the order is important
253 if StartWindow:
254 StartWindow.Unload()
255 if QuitWindow:
256 QuitWindow.Unload()
257 if TutorialWindow:
258 TutorialWindow.Unload()
259 GemRB.SetNextScript ("GUIMOVIE")
260 return
262 def ExitCancelled():
263 QuitWindow.SetVisible (WINDOW_INVISIBLE)
264 StartWindow.SetVisible (WINDOW_VISIBLE)
265 return
267 def BackToMain():
268 SinglePlayerButton.SetState (IE_GUI_BUTTON_ENABLED)
269 OptionsButton.SetState (IE_GUI_BUTTON_ENABLED)
270 MultiPlayerButton.SetState (IE_GUI_BUTTON_ENABLED)
271 SinglePlayerButton.SetText (15413)
272 ExitButton.SetText (15417)
273 OptionsButton.SetText (13905)
274 MultiPlayerButton.SetText (15414)
275 MoviesButton.SetText (15415)
276 SinglePlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, SinglePlayerPress)
277 ExitButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, ExitPress)
278 OptionsButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, OptionsPress)
279 MultiPlayerButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, MultiPlayerPress)
280 MoviesButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, MoviesPress)
281 QuitWindow.SetVisible (WINDOW_INVISIBLE)
282 StartWindow.SetVisible (WINDOW_VISIBLE)
283 return
285 def Restart():
286 StartWindow.Unload()
287 QuitWindow.Unload()
288 GemRB.SetNextScript ("Start")
289 return