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 # GUIW.py - scripts to control some windows from the GUIWORLD winpack
22 # except of Actions, Portrait, Options and Dialog windows
23 #################################################################
26 from GUIDefines
import *
28 import GUICommonWindows
30 from ie_stats
import *
36 ReformPartyWindow
= None
37 OldActionsWindow
= None
38 OldMessageWindow
= None
42 def CloseContinueWindow ():
44 # don't close the actual window now to avoid flickering: we might still want it open
45 GemRB
.SetVar ("DialogChoose", GemRB
.GetVar ("DialogOption"))
47 def NextDialogState ():
48 global ContinueWindow
, OldActionsWindow
50 if ContinueWindow
== None:
53 hideflag
= GemRB
.HideGUI ()
56 ContinueWindow
.Unload ()
57 GemRB
.SetVar ("ActionsWindow", OldActionsWindow
.ID
)
59 OldActionsWindow
= None
64 def OpenEndMessageWindow ():
65 global ContinueWindow
, OldActionsWindow
67 hideflag
= GemRB
.HideGUI ()
69 if not ContinueWindow
:
70 # try to force-close anything which is open
71 GUICommon
.CloseOtherWindow(None)
73 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
74 ContinueWindow
= Window
= GemRB
.LoadWindow (9)
75 OldActionsWindow
= GUIClasses
.GWindow( GemRB
.GetVar ("ActionsWindow") )
76 GemRB
.SetVar ("ActionsWindow", Window
.ID
)
79 Button
= ContinueWindow
.GetControl (0)
81 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseContinueWindow
)
82 if GUICommonWindows
.PortraitWindow
:
83 GUICommonWindows
.UpdatePortraitWindow ()
88 def OpenContinueMessageWindow ():
89 global ContinueWindow
, OldActionsWindow
91 hideflag
= GemRB
.HideGUI ()
93 if not ContinueWindow
:
94 # try to force-close anything which is open
95 GUICommon
.CloseOtherWindow(None)
97 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
98 ContinueWindow
= Window
= GemRB
.LoadWindow (9)
99 OldActionsWindow
= GUIClasses
.GWindow( GemRB
.GetVar ("ActionsWindow") )
100 GemRB
.SetVar ("ActionsWindow", Window
.ID
)
103 Button
= ContinueWindow
.GetControl (0)
104 Button
.SetText (9372)
105 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseContinueWindow
)
109 def UpdateReformWindow ():
110 Window
= ReformPartyWindow
112 select
= GemRB
.GetVar ("Selected")
114 need_to_drop
= GemRB
.GetPartySize ()-PARTY_SIZE
118 #excess player number
119 Label
= Window
.GetControl (0x1000000f)
120 Label
.SetText (str(need_to_drop
) )
123 Button
= Window
.GetControl (8)
125 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
127 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
130 Button
= Window
.GetControl (15)
132 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
134 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
136 for i
in range (PARTY_SIZE
+1):
137 Button
= Window
.GetControl (i
)
138 if i
+1 not in removable_pcs
:
139 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
140 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
143 for i
in removable_pcs
:
144 Button
= Window
.GetControl (removable_pcs
.index(i
))
145 Button
.EnableBorder (FRAME_PC_SELECTED
, select
== i
)
146 pic
= GemRB
.GetPlayerPortrait (i
, 1)
148 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
149 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
151 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
152 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ALIGN_BOTTOM|IE_GUI_BUTTON_ALIGN_LEFT
, OP_SET
)
153 Button
.SetPicture (pic
, "NOPORTSM")
154 GUICommonWindows
.UpdatePortraitWindow ()
158 global ReformPartyWindow
160 hideflag
= GemRB
.HideGUI ()
162 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
163 if ReformPartyWindow
:
164 ReformPartyWindow
.Unload ()
165 ReformPartyWindow
= Window
= GemRB
.LoadWindow (25)
166 GemRB
.SetVar ("OtherWindow", Window
.ID
)
169 Label
= Window
.GetControl (0x0fffffff)
170 Label
.SetText (17518)
173 Button
= Window
.GetControl (1)
174 Button
.SetText (17507)
175 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RemovePlayerConfirm
)
176 Button
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
179 Button
= Window
.GetControl (2)
180 Button
.SetText (13727)
181 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RemovePlayerCancel
)
182 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
184 GemRB
.SetVar ("OtherWindow", Window
.ID
)
185 GemRB
.SetVar ("ActionsWindow", -1)
188 Window
.ShowModal (MODAL_SHADOW_GRAY
)
191 def RemovePlayerConfirm ():
192 slot
= GemRB
.GetVar ("Selected")
193 GemRB
.LeaveParty (slot
, 2)
194 OpenReformPartyWindow ()
197 def RemovePlayerCancel ():
198 #Once for getting rid of the confirmation window
199 OpenReformPartyWindow ()
200 #and once for reopening the reform party window
201 OpenReformPartyWindow ()
204 def OpenReformPartyWindow ():
205 global ReformPartyWindow
, OldActionsWindow
, OldMessageWindow
208 GemRB
.SetVar ("Selected", 0)
209 hideflag
= GemRB
.HideGUI ()
211 if ReformPartyWindow
:
212 if ReformPartyWindow
:
213 ReformPartyWindow
.Unload ()
215 GemRB
.SetVar ("ActionsWindow", OldActionsWindow
.ID
)
216 GemRB
.SetVar ("MessageWindow", OldMessageWindow
.ID
)
217 GemRB
.SetVar ("OtherWindow", -1)
219 OldActionsWindow
= None
220 OldMessageWindow
= None
221 ReformPartyWindow
= None
224 #re-enabling party size control
225 GemRB
.GameSetPartySize (PARTY_SIZE
)
226 GUICommonWindows
.UpdatePortraitWindow()
229 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
230 ReformPartyWindow
= Window
= GemRB
.LoadWindow (24)
231 GemRB
.SetVar ("OtherWindow", Window
.ID
)
233 # skip exportable party members (usually only the protagonist)
235 for i
in range (1, GemRB
.GetPartySize()+1):
236 if not GemRB
.GetPlayerStat (i
, IE_MC_FLAGS
)&MC_EXPORTABLE
:
237 removable_pcs
.append(i
)
240 for j
in range (PARTY_SIZE
+1):
241 Button
= Window
.GetControl (j
)
242 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
243 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
244 Button
.SetBorder (FRAME_PC_SELECTED
, 1, 1, 2, 2, 0, 255, 0, 255)
245 if j
< len(removable_pcs
):
246 Button
.SetVarAssoc ("Selected", removable_pcs
[j
])
247 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, UpdateReformWindow
)
250 Button
= Window
.GetControl (15)
251 Button
.SetText (17507)
252 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RemovePlayer
)
255 Button
= Window
.GetControl (8)
256 Button
.SetText (11973)
257 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenReformPartyWindow
)
259 OldActionsWindow
= GUIClasses
.GWindow( GemRB
.GetVar ("ActionsWindow") )
260 OldMessageWindow
= GUIClasses
.GWindow( GemRB
.GetVar ("MessageWindow") )
261 GemRB
.SetVar ("ActionsWindow", -1)
262 GemRB
.SetVar ("MessageWindow", -1)
264 # if nobody can be removed, just close the window
265 if not removable_pcs
:
266 OpenReformPartyWindow ()
271 UpdateReformWindow ()
274 Window
.ShowModal (MODAL_SHADOW_GRAY
)
279 GemRB
.SetTimedEvent (DeathWindowEnd
, 10)
282 def DeathWindowEnd ():
283 #playing death movie before continuing
284 GemRB
.PlayMovie ("deathand",1)
285 GemRB
.GamePause (1,1)
287 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
288 Window
= GemRB
.LoadWindow (17)
291 Label
= Window
.GetControl (0x0fffffff)
292 Label
.SetText (16498)
295 Button
= Window
.GetControl (1)
296 Button
.SetText (15590)
297 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LoadPress
)
300 Button
= Window
.GetControl (2)
301 Button
.SetText (15417)
302 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, QuitPress
)
305 GemRB
.SetVar ("MessageWindow", -1)
307 Window
.ShowModal (MODAL_SHADOW_GRAY
)
312 GemRB
.SetNextScript ("Start")
317 GemRB
.SetNextScript ("GUILOAD")