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 GUIWORLD winpack
22 # except of Actions, Portrait, Options and Dialog windows
23 #################################################################
26 from GUIDefines
import *
27 from ie_restype
import *
29 import GUICommonWindows
36 ReformPartyWindow
= None
37 OldActionsWindow
= None
38 OldMessageWindow
= None
40 def CloseContinueWindow ():
42 # don't close the actual window now to avoid flickering: we might still want it open
43 GemRB
.SetVar ("DialogChoose", GemRB
.GetVar ("DialogOption"))
45 def NextDialogState ():
46 global ContinueWindow
, OldActionsWindow
48 if ContinueWindow
== None:
51 hideflag
= GemRB
.HideGUI ()
54 ContinueWindow
.Unload ()
55 GemRB
.SetVar ("ActionsWindow", OldActionsWindow
.ID
)
57 OldActionsWindow
= None
62 def OpenEndMessageWindow ():
63 global ContinueWindow
, OldActionsWindow
65 hideflag
= GemRB
.HideGUI ()
67 if not ContinueWindow
:
68 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
69 ContinueWindow
= Window
= GemRB
.LoadWindow (9)
70 OldActionsWindow
= GUIClasses
.GWindow( GemRB
.GetVar ("ActionsWindow") )
71 GemRB
.SetVar ("ActionsWindow", Window
.ID
)
74 Button
= ContinueWindow
.GetControl (0)
76 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseContinueWindow
)
77 if GUICommonWindows
.PortraitWindow
:
78 GUICommonWindows
.UpdatePortraitWindow ()
83 def OpenContinueMessageWindow ():
84 global ContinueWindow
, OldActionsWindow
86 hideflag
= GemRB
.HideGUI ()
88 if not ContinueWindow
:
89 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
90 ContinueWindow
= Window
= GemRB
.LoadWindow (9)
91 OldActionsWindow
= GUIClasses
.GWindow( GemRB
.GetVar ("ActionsWindow") )
92 GemRB
.SetVar ("ActionsWindow", Window
.ID
)
95 Button
= ContinueWindow
.GetControl (0)
97 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseContinueWindow
)
101 def UpdateReformWindow ():
102 Window
= ReformPartyWindow
104 select
= GemRB
.GetVar ("Selected")
106 need_to_drop
= GemRB
.GetPartySize ()-PARTY_SIZE
110 #excess player number
111 Label
= Window
.GetControl (0x1000000f)
112 Label
.SetText (str(need_to_drop
) )
115 Button
= Window
.GetControl (8)
117 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
119 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
122 Button
= Window
.GetControl (15)
124 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
126 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
128 for i
in range (PARTY_SIZE
+1):
129 Button
= Window
.GetControl (i
)
130 Button
.EnableBorder (FRAME_PC_SELECTED
, select
== i
+2 )
131 #+2 because protagonist is skipped
132 pic
= GemRB
.GetPlayerPortrait (i
+2,1)
134 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
135 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
138 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
139 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ALIGN_BOTTOM|IE_GUI_BUTTON_ALIGN_LEFT
, OP_SET
)
140 Button
.SetPicture (pic
, "NOPORTSM")
141 GUICommonWindows
.UpdatePortraitWindow ()
145 global ReformPartyWindow
147 hideflag
= GemRB
.HideGUI ()
149 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
150 if ReformPartyWindow
:
151 ReformPartyWindow
.Unload ()
152 ReformPartyWindow
= Window
= GemRB
.LoadWindow (25)
153 GemRB
.SetVar ("OtherWindow", Window
.ID
)
156 Label
= Window
.GetControl (0x0fffffff)
157 Label
.SetText (17518)
160 Button
= Window
.GetControl (1)
161 Button
.SetText (17507)
162 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RemovePlayerConfirm
)
163 Button
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
166 Button
= Window
.GetControl (2)
167 Button
.SetText (13727)
168 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RemovePlayerCancel
)
169 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
171 def RemovePlayerConfirm ():
172 global ReformPartyWindow
174 hideflag
= GemRB
.HideGUI ()
175 if ReformPartyWindow
:
176 ReformPartyWindow
.Unload ()
177 GemRB
.SetVar ("OtherWindow", -1)
178 #removing selected player
179 ReformPartyWindow
= None
182 GemRB
.LeaveParty (GemRB
.GetVar("Selected") )
183 OpenReformPartyWindow ()
186 def RemovePlayerCancel ():
187 global ReformPartyWindow
189 hideflag
= GemRB
.HideGUI ()
190 if ReformPartyWindow
:
191 ReformPartyWindow
.Unload ()
192 GemRB
.SetVar ("OtherWindow", -1)
193 ReformPartyWindow
= None
196 OpenReformPartyWindow ()
199 def OpenReformPartyWindow ():
200 global ReformPartyWindow
202 GemRB
.SetVar ("Selected", 0)
203 hideflag
= GemRB
.HideGUI ()
205 if ReformPartyWindow
:
206 if ReformPartyWindow
:
207 ReformPartyWindow
.Unload ()
208 ReformPartyWindow
= None
210 GemRB
.SetVar ("OtherWindow", -1)
211 #GemRB.LoadWindowPack ("GUIREC")
214 #re-enabling party size control
215 GemRB
.GameSetPartySize (PARTY_SIZE
)
218 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
219 ReformPartyWindow
= Window
= GemRB
.LoadWindow (24)
220 GemRB
.SetVar ("OtherWindow", Window
.ID
)
223 for j
in range (PARTY_SIZE
+1):
224 Button
= Window
.GetControl (j
)
225 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
226 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
227 Button
.SetBorder (FRAME_PC_SELECTED
, 1, 1, 2, 2, 0, 255, 0, 255)
228 #protagonist is skipped
230 Button
.SetVarAssoc ("Selected", index
)
231 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, UpdateReformWindow
)
234 Button
= Window
.GetControl (15)
235 Button
.SetText (17507)
236 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RemovePlayer
)
239 Button
= Window
.GetControl (8)
240 Button
.SetText (11973)
241 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenReformPartyWindow
)
242 GemRB
.SetVar ("ActionsWindow", -1)
243 UpdateReformWindow ()
246 Window
.ShowModal (MODAL_SHADOW_GRAY
)
250 #no death movie, but music is changed
251 GemRB
.LoadMusicPL ("Theme.mus",1)
253 GemRB
.SetTimedEvent (DeathWindowEnd
, 10)
256 def DeathWindowEnd ():
257 GemRB
.GamePause (1,1)
259 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
260 Window
= GemRB
.LoadWindow (17)
263 Label
= Window
.GetControl (0x0fffffff)
264 Label
.SetText (16498)
267 Button
= Window
.GetControl (1)
268 Button
.SetText (15590)
269 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LoadPress
)
272 Button
= Window
.GetControl (2)
273 Button
.SetText (15417)
274 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, QuitPress
)
277 GemRB
.SetVar ("MessageWindow", -1)
279 Window
.ShowModal (MODAL_SHADOW_GRAY
)
284 GemRB
.SetNextScript ("Start")
289 GemRB
.SetNextScript ("GUILOAD")