factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / bg1 / Start.py
blobe0ddf277a0c46c9ee9f896fe326a026ebd2769fa
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 from GUIDefines import *
22 StartWindow = 0
23 QuitWindow = 0
24 ExitButton = 0
25 SinglePlayerButton = 0
26 MultiPlayerButton = 0
27 MoviesButton = 0
29 def OnLoad():
30 global StartWindow, QuitWindow
31 global ExitButton, MultiPlayerButton, MoviesButton, SinglePlayerButton
33 skip_videos = GemRB.GetVar ("SkipIntroVideos")
34 if not skip_videos:
35 GemRB.PlayMovie ('BG4LOGO',1)
36 GemRB.PlayMovie ('TSRLOGO',1)
37 GemRB.PlayMovie ('BILOGO',1)
38 GemRB.PlayMovie ('INFELOGO',1)
39 GemRB.PlayMovie ('INTRO',1)
40 GemRB.SetVar ("SkipIntroVideos", 1)
42 GemRB.LoadWindowPack("START")
44 #quit subwindow
45 QuitWindow = GemRB.LoadWindow(3)
46 QuitTextArea = QuitWindow.GetControl(0)
47 CancelButton = QuitWindow.GetControl(2)
48 ConfirmButton = QuitWindow.GetControl(1)
49 QuitTextArea.SetText(19532)
50 CancelButton.SetText(13727)
51 ConfirmButton.SetText(15417)
52 ConfirmButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ExitConfirmed)
53 CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ExitCancelled)
54 ConfirmButton.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
55 CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
57 #main window
58 StartWindow = GemRB.LoadWindow(0)
59 SinglePlayerButton = StartWindow.GetControl(0)
60 MultiPlayerButton = StartWindow.GetControl(1)
61 MoviesButton = StartWindow.GetControl(2)
62 ExitButton = StartWindow.GetControl(3)
64 BackToMain()
66 GemRB.LoadMusicPL("Theme.mus")
67 return
69 def SinglePlayerPress():
71 SinglePlayerButton.SetText(13728)
72 MultiPlayerButton.SetText(13729)
73 MoviesButton.SetText(24110)
74 ExitButton.SetText(15416)
75 MultiPlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, LoadSingle)
76 SinglePlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NewSingle)
77 MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MissionPack)
78 ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackToMain)
79 ExitButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)
80 if GemRB.GetString(24110) == "": # TODO: better way to detect lack of mission pack?
81 MoviesButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_OR)
82 return
84 def MultiPlayerPress():
86 SinglePlayerButton.SetText(11825)
87 MultiPlayerButton.SetText(20642)
88 MoviesButton.SetText(15416)
89 ExitButton.SetText("")
90 SinglePlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PregenPress)
91 MultiPlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ConnectPress)
92 MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackToMain)
93 MoviesButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR)
94 ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, None)
95 ExitButton.SetStatus(IE_GUI_BUTTON_DISABLED)
96 ExitButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
97 return
99 def ConnectPress():
100 #well...
101 return
103 def PregenPress():
104 if StartWindow:
105 StartWindow.Unload()
106 if QuitWindow:
107 QuitWindow.Unload()
108 GemRB.SetVar("PlayMode",0) #loadgame needs this hack
109 GemRB.SetVar("Slot",1)
110 GemRB.LoadGame(None)
111 GemRB.SetVar("PlayMode",-1)
112 GemRB.SetNextScript("CharGen")
113 return
115 def LoadSingle():
116 if StartWindow:
117 StartWindow.Unload()
118 if QuitWindow:
119 QuitWindow.Unload()
120 GemRB.SetVar("PlayMode",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.SetNextScript("GUILOAD")
131 return
133 def NewSingle():
134 if StartWindow:
135 StartWindow.Unload()
136 if QuitWindow:
137 QuitWindow.Unload()
138 GemRB.SetVar("PlayMode",0)
139 GemRB.SetVar("Slot",1)
140 GemRB.LoadGame(None)
141 GemRB.SetNextScript("CharGen") #temporarily
142 return
144 def ExitPress():
145 StartWindow.SetVisible(WINDOW_INVISIBLE)
146 QuitWindow.SetVisible(WINDOW_VISIBLE)
147 return
149 def ExitConfirmed():
150 GemRB.Quit()
151 return
153 def MoviesPress():
154 #apparently the order is important
155 if StartWindow:
156 StartWindow.Unload()
157 if QuitWindow:
158 QuitWindow.Unload()
159 GemRB.SetNextScript("GUIMOVIE")
160 return
162 def ExitCancelled():
163 QuitWindow.SetVisible(WINDOW_INVISIBLE)
164 StartWindow.SetVisible(WINDOW_VISIBLE)
165 return
167 def BackToMain():
168 SinglePlayerButton.SetStatus(IE_GUI_BUTTON_ENABLED)
169 MultiPlayerButton.SetStatus(IE_GUI_BUTTON_ENABLED)
170 MoviesButton.SetStatus(IE_GUI_BUTTON_ENABLED)
171 ExitButton.SetStatus(IE_GUI_BUTTON_ENABLED)
172 SinglePlayerButton.SetText(15413)
173 MultiPlayerButton.SetText(15414)
174 MoviesButton.SetText(15415)
175 ExitButton.SetText(15417)
176 SinglePlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SinglePlayerPress)
177 MultiPlayerButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MultiPlayerPress)
178 MoviesButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MoviesPress)
179 ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ExitPress)
180 MoviesButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
181 ExitButton.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_NAND)
182 ExitButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
184 QuitWindow.SetVisible(WINDOW_INVISIBLE)
185 StartWindow.SetVisible(WINDOW_VISIBLE)
186 return