2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2004 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 # GUICommonWindows.py - functions to open common
22 # windows in lower part of the screen
23 ###################################################
27 from GUIDefines
import *
28 from ie_stats
import *
29 from ie_modal
import *
30 from ie_action
import *
31 from ie_slots
import *
32 from GUICommon
import *
33 from LUCommon
import *
41 DraggedPortrait
= None
43 def SetupMenuWindowControls (Window
, Gears
, ReturnToGame
):
44 """Sets up all of the basic control windows."""
48 OptionsWindow
= Window
50 Button
= Window
.GetControl (0)
51 Button
.SetTooltip (16313)
52 Button
.SetVarAssoc ("SelectedWindow", 0)
53 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ReturnToGame
)
54 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
57 Button
= Window
.GetControl (1)
58 Button
.SetTooltip (16310)
59 Button
.SetVarAssoc ("SelectedWindow", 1)
60 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenMapWindow")
63 Button
= Window
.GetControl (2)
64 Button
.SetTooltip (16308)
65 Button
.SetVarAssoc ("SelectedWindow", 2)
66 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenJournalWindow")
69 Button
= Window
.GetControl (3)
70 Button
.SetTooltip (16307)
71 Button
.SetVarAssoc ("SelectedWindow", 3)
72 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenInventoryWindow")
75 Button
= Window
.GetControl (4)
76 Button
.SetTooltip (16306)
77 Button
.SetVarAssoc ("SelectedWindow", 4)
78 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenRecordsWindow")
81 Button
= Window
.GetControl (5)
82 Button
.SetTooltip (16309)
83 Button
.SetVarAssoc ("SelectedWindow", 5)
84 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenMageWindow")
87 Button
= Window
.GetControl (6)
88 Button
.SetTooltip (14930)
89 Button
.SetVarAssoc ("SelectedWindow", 6)
90 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenPriestWindow")
93 Button
= Window
.GetControl (7)
94 Button
.SetTooltip (16311)
95 Button
.SetVarAssoc ("SelectedWindow", 7)
96 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenOptionsWindow")
98 # Multi player team setup?
99 Button
= Window
.GetControl (8)
100 Button
.SetTooltip (13902)
103 # Pendulum, gears, sun/moon dial (time)
104 # FIXME: display all animations: CPEN, CGEAR, CDIAL
105 Button
= Window
.GetControl (9)
106 Label
= Button
.CreateLabelOnButton (0x10000009, "NORMAL", 0)
108 Label
.SetAnimation ("CPEN")
109 Button
.SetAnimation ("CGEAR")
110 Button
.SetBAM ("CDIAL", 0, 0)
111 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
112 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_NORMAL
, OP_SET
)
113 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, "GearsClicked")
114 SetGamedaysAndHourToken()
115 Button
.SetTooltip(16041)
121 Button
= Window
.GetControl (rb
)
122 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "RestPress")
123 Button
.SetTooltip (11942)
126 UpdatePortraitWindow ()
128 def MarkMenuButton (WindowIndex
):
129 Pressed
= WindowIndex
.GetControl( GemRB
.GetVar ("SelectedWindow") )
131 for button
in range (9):
132 Button
= WindowIndex
.GetControl (button
)
133 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
135 if Pressed
: # don't draw the selection when returning to the game
136 Pressed
.SetState (IE_GUI_BUTTON_SELECTED
)
139 """Toggles the party AI."""
141 Button
= PortraitWindow
.GetControl (6)
142 AI
= GemRB
.GetMessageWindowSize () & GS_PARTYAI
145 GemRB
.GameSetScreenFlags (GS_PARTYAI
, OP_NAND
)
146 Button
.SetTooltip (15918)
147 GemRB
.SetVar ("AI", 0)
149 GemRB
.GameSetScreenFlags (GS_PARTYAI
, OP_OR
)
150 Button
.SetTooltip (15917)
151 GemRB
.SetVar ("AI", GS_PARTYAI
)
154 def EmptyControls ():
157 GemRB
.SetVar ("ActionLevel", 0)
158 Window
= ActionsWindow
160 Button
= Window
.GetControl (i
)
161 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
162 Button
.SetPicture ("")
165 def SelectFormationPreset ():
166 """Choose the default formation."""
167 GemRB
.GameSetFormation (GemRB
.GetVar ("Value"), GemRB
.GetVar ("Formation") )
171 def SetupFormation ():
172 """Opens the formation selection section."""
175 Window
= ActionsWindow
177 Button
= Window
.GetControl (i
)
178 Button
.SetFlags (IE_GUI_BUTTON_NORMAL
, OP_SET
)
179 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
180 Button
.SetBAM ("FORM%x"%i,0,0,-1)
181 Button
.SetVarAssoc ("Value", i
)
182 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "SelectFormationPreset")
185 def GroupControls ():
186 """Sections that control group actions."""
190 GemRB
.SetVar ("ActionLevel", 0)
191 Window
= ActionsWindow
192 Button
= Window
.GetControl (0)
193 Button
.SetActionIcon (7)
194 Button
= Window
.GetControl (1)
195 Button
.SetActionIcon (15)
196 Button
= Window
.GetControl (2)
197 Button
.SetActionIcon (21)
198 Button
= Window
.GetControl (3)
199 Button
.SetActionIcon (-1)
200 Button
= Window
.GetControl (4)
201 Button
.SetActionIcon (-1)
202 Button
= Window
.GetControl (5)
203 Button
.SetActionIcon (-1)
204 Button
= Window
.GetControl (6)
205 Button
.SetActionIcon (-1)
206 GemRB
.SetVar ("Formation", GemRB
.GameGetFormation ())
208 Button
= Window
.GetControl (7+i
)
209 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
210 idx
= GemRB
.GameGetFormation (i
)
211 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NORMAL
, OP_SET
)
212 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
213 Button
.SetBAM ("FORM%x"%idx,0,0,-1)
214 Button
.SetVarAssoc ("Formation", i
)
215 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "SelectFormation")
216 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "SetupFormation")
217 str = GemRB
.GetString (4935)
218 Button
.SetTooltip ("F%d - %s"%(8+i
,str) )
221 def OpenActionsWindowControls (Window
):
224 ActionsWindow
= Window
225 # Gears (time) when options pane is down
226 Button
= Window
.GetControl (62)
227 Label
= Button
.CreateLabelOnButton (0x1000003e, "NORMAL", 0)
229 # FIXME: display all animations
230 Label
.SetAnimation ("CPEN")
231 Button
.SetAnimation ("CGEAR")
232 Button
.SetBAM ("CDIAL", 0, 0)
233 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
234 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_NORMAL
, OP_SET
)
235 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, "GearsClicked")
236 SetGamedaysAndHourToken()
237 Button
.SetTooltip(16041)
238 UpdateActionsWindow ()
241 def UpdateActionsWindow ():
242 """Redraws the actions section of the window."""
244 global ActionsWindow
, PortraitWindow
, OptionsWindow
245 global level
, TopIndex
247 if ActionsWindow
== -1:
250 if ActionsWindow
== None:
253 #fully redraw the side panes to cover the actions window
254 #do this only when there is no 'otherwindow'
255 if GemRB
.GetVar ("OtherWindow") == -1:
257 PortraitWindow
.Invalidate ()
259 OptionsWindow
.Invalidate ()
261 Selected
= GemRB
.GetSelectedSize()
263 #setting up the disabled button overlay (using the second border slot)
265 Button
= ActionsWindow
.GetControl (i
)
266 Button
.SetBorder (1, 0, 0, 0, 0, 50,30,10,120, 0, 1)
267 Button
.SetFont ("NUMBER")
276 #this is based on class
277 #we are sure there is only one actor selected
279 for i
in range (PARTY_SIZE
):
280 if GemRB
.GameIsPCSelected (i
+1):
285 #summoned/charmed creature.
286 #TODO: some creatures have real actions window!!
290 level
= GemRB
.GetVar ("ActionLevel")
291 TopIndex
= GemRB
.GetVar ("TopIndex")
293 ActionsWindow
.SetupControls (pc
)
295 ActionsWindow
.SetupEquipmentIcons(pc
, TopIndex
)
296 elif level
== 2: #spells
297 GemRB
.SetVar ("Type", 3)
298 ActionsWindow
.SetupSpellIcons(pc
, 3, TopIndex
)
299 elif level
== 3: #innates
300 GemRB
.SetVar ("Type", 4)
301 ActionsWindow
.SetupSpellIcons(pc
, 4, TopIndex
)
304 def ActionQWeaponPressed (which
):
305 """Selects the given quickslot weapon if possible."""
307 pc
= GemRB
.GameGetFirstSelectedPC ()
308 qs
= GemRB
.GetEquippedQuickSlot (pc
,1)
310 #38 is the magic slot
311 if ((qs
==which
) or (qs
==38)) and GemRB
.GameControlGetTargetMode() != TARGET_MODE_ATTACK
:
312 GemRB
.GameControlSetTargetMode (TARGET_MODE_ATTACK
, GA_NO_DEAD|GA_NO_SELF|GA_NO_HIDDEN
)
314 GemRB
.GameControlSetTargetMode (TARGET_MODE_NONE
)
315 GemRB
.SetEquippedQuickSlot (pc
, which
)
317 ActionsWindow
.SetupControls (pc
)
318 UpdateActionsWindow ()
321 def ActionQWeapon1Pressed ():
322 ActionQWeaponPressed(0)
324 def ActionQWeapon2Pressed ():
325 ActionQWeaponPressed(1)
327 def ActionQWeapon3Pressed ():
328 ActionQWeaponPressed(2)
330 def ActionQWeapon4Pressed ():
331 ActionQWeaponPressed(3)
333 #no check needed because the button wouldn't be drawn if illegal
334 def ActionLeftPressed ():
335 """Scrolls the actions window left.
337 Used primarily for spell selection."""
339 TopIndex
= GemRB
.GetVar ("TopIndex")
344 GemRB
.SetVar ("TopIndex", TopIndex
)
345 UpdateActionsWindow ()
348 #no check needed because the button wouldn't be drawn if illegal
349 def ActionRightPressed ():
350 """Scrolls the action window right.
352 Used primarily for spell selection."""
354 pc
= GemRB
.GameGetFirstSelectedPC ()
355 TopIndex
= GemRB
.GetVar ("TopIndex")
356 Type
= GemRB
.GetVar ("Type")
357 #Type is a bitfield if there is no level given
358 #This is to make sure cleric/mages get all spells listed
359 Max
= GemRB
.GetMemorizedSpellsCount(pc
, Type
)
361 if TopIndex
> Max
- 10:
366 GemRB
.SetVar ("TopIndex", TopIndex
)
367 UpdateActionsWindow ()
370 def ActionBardSongPressed ():
371 """Toggles the battle song."""
372 pc
= GemRB
.GameGetFirstSelectedPC ()
373 GemRB
.SetModalState (pc
, MS_BATTLESONG
)
374 GemRB
.PlaySound ("act_01")
375 UpdateActionsWindow ()
378 def ActionSearchPressed ():
379 """Toggles detect traps."""
380 pc
= GemRB
.GameGetFirstSelectedPC ()
381 GemRB
.SetModalState (pc
, MS_DETECTTRAPS
)
382 UpdateActionsWindow ()
385 def ActionStealthPressed ():
386 """Toggles stealth."""
387 pc
= GemRB
.GameGetFirstSelectedPC ()
388 GemRB
.SetModalState (pc
, MS_STEALTH
)
389 GemRB
.PlaySound ("act_07")
390 UpdateActionsWindow ()
393 def ActionTurnPressed ():
394 """Toggles turn undead."""
395 pc
= GemRB
.GameGetFirstSelectedPC ()
396 GemRB
.SetModalState (pc
, MS_TURNUNDEAD
)
397 GemRB
.PlaySound ("act_06")
398 UpdateActionsWindow ()
401 def ActionUseItemPressed ():
402 GemRB
.SetVar ("TopIndex", 0)
403 GemRB
.SetVar ("ActionLevel", 1)
404 UpdateActionsWindow ()
407 def ActionCastPressed ():
408 """Opens the spell choice scrollbar."""
409 GemRB
.SetVar ("TopIndex", 0)
410 GemRB
.SetVar ("ActionLevel", 2)
411 UpdateActionsWindow ()
414 def ActionInnatePressed ():
415 """Opens the innate spell scrollbar."""
416 GemRB
.SetVar ("TopIndex", 0)
417 GemRB
.SetVar ("ActionLevel", 3)
418 UpdateActionsWindow ()
422 """Prepares a spell to be cast."""
424 pc
= GemRB
.GameGetFirstSelectedPC ()
426 GemRB
.GameControlSetTargetMode (TARGET_MODE_CAST
)
427 Spell
= GemRB
.GetVar ("Spell")
428 Type
= GemRB
.GetVar ("Type")
429 GemRB
.SpellCast (pc
, Type
, Spell
)
430 GemRB
.SetVar ("ActionLevel", 0)
431 UpdateActionsWindow ()
434 def EquipmentPressed ():
435 pc
= GemRB
.GameGetFirstSelectedPC ()
437 GemRB
.GameControlSetTargetMode (TARGET_MODE_CAST
)
438 Item
= GemRB
.GetVar ("Equipment")
440 GemRB
.UseItem (pc
, -1, Item
)
441 GemRB
.SetVar ("ActionLevel", 0)
442 UpdateActionsWindow ()
445 SelectionChangeHandler
= None
447 def SetSelectionChangeHandler (handler
):
448 """Updates the selection handler."""
450 global SelectionChangeHandler
452 # Switching from walking to non-walking environment:
453 # set the first selected PC in walking env as a selected
455 if (not SelectionChangeHandler
) and handler
:
456 sel
= GemRB
.GameGetFirstSelectedPC ()
459 GemRB
.GameSelectPCSingle (sel
)
461 SelectionChangeHandler
= handler
463 # redraw selection on change main selection | single selection
467 def RunSelectionChangeHandler ():
468 if SelectionChangeHandler
:
469 SelectionChangeHandler ()
472 def OpenPortraitWindow (needcontrols
):
473 global PortraitWindow
475 PortraitWindow
= Window
= GemRB
.LoadWindowObject (1)
478 Button
=Window
.GetControl (8)
479 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "MinimizePortraits")
482 Button
= Window
.GetControl (6)
483 #fixing a gui bug, and while we are at it, hacking it to be easier
484 Button
.SetSprites ("GUIBTACT", 0, 48, 47, 46, 49)
485 GSFlags
= GemRB
.GetMessageWindowSize ()&GS_PARTYAI
487 GemRB
.SetVar ("AI", GSFlags
)
488 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "AIPress")
489 Button
.SetFlags (IE_GUI_BUTTON_CHECKBOX
, OP_OR
)
490 Button
.SetVarAssoc ("AI", 1)
492 Button
.SetTooltip (15917)
494 Button
.SetTooltip (15918)
497 Button
= Window
.GetControl (7)
498 Button
.SetTooltip (10485)
499 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "SelectAllOnPress")
501 for i
in range (PARTY_SIZE
):
502 Button
= Window
.GetControl (i
)
503 Button
.SetFont ("STATES2")
504 Button
.SetVarAssoc ("PressedPortrait", i
+1)
507 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "OpenInventoryWindowClick")
509 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "PortraitButtonOnPress")
511 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "PortraitButtonOnPress")
512 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, "PortraitButtonOnShiftPress")
513 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, "OnDropItemToPC")
514 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP_PORTRAIT
, "OnDropPortraitToPC")
515 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG
, "PortraitButtonOnDrag")
516 Button
.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON
, "PortraitButtonOnMouseEnter")
517 Button
.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON
, "PortraitButtonOnMouseLeave")
519 Button
.SetBorder (FRAME_PC_SELECTED
, 1, 1, 2, 2, 0, 255, 0, 255)
520 Button
.SetBorder (FRAME_PC_TARGET
, 3, 3, 4, 4, 255, 255, 0, 255)
522 UpdatePortraitWindow ()
526 def UpdatePortraitWindow ():
527 """Updates all of the portraits."""
529 Window
= PortraitWindow
531 pc
= GemRB
.GameGetSelectedPCSingle ()
532 Inventory
= GemRB
.GetVar ("Inventory")
534 for portid
in range (PARTY_SIZE
):
535 Button
= Window
.GetControl (portid
)
536 pic
= GemRB
.GetPlayerPortrait (portid
+1, 1)
537 if Inventory
and pc
!= portid
+1:
541 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
542 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
544 Button
.SetTooltip ("")
547 Button
.SetFlags (IE_GUI_BUTTON_PICTURE| \
548 IE_GUI_BUTTON_HORIZONTAL| \
549 IE_GUI_BUTTON_ALIGN_LEFT| IE_GUI_BUTTON_ALIGN_TOP| \
550 IE_GUI_BUTTON_DRAGGABLE|IE_GUI_BUTTON_MULTILINE
, OP_SET
)
551 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
552 Button
.SetPicture (pic
, "NOPORTSM")
553 hp
= GemRB
.GetPlayerStat (portid
+1, IE_HITPOINTS
)
554 hp_max
= GemRB
.GetPlayerStat (portid
+1, IE_MAXHITPOINTS
)
555 state
= GemRB
.GetPlayerStat (portid
+1, IE_STATE_ID
)
560 ratio
= (hp
+0.0) / hp_max
562 if hp
<1 or (state
& STATE_DEAD
):
563 Button
.SetOverlay (0, 64,64,64,200, 64,64,64,200)
565 Button
.SetOverlay (ratio
, 255,0,0,200, 128,0,0,200)
566 Button
.SetTooltip (GemRB
.GetPlayerName (portid
+1, 1) + "\n%d/%d" %(hp
, hp_max
))
568 #add effects on the portrait
569 effects
= GemRB
.GetPlayerStates (portid
+1)
571 for col
in range(len(effects
)):
572 states
= effects
[col
:col
+1] + states
573 if col
% 3 == 2: states
= "\n" + states
574 for x
in range(3 - (len(effects
)/3)):
575 states
= "\n" + states
576 states
= "\n" + states
579 flag
= blank
= chr(238)
583 if GemRB
.GetStore()!=None:
586 if GemRB
.GameGetSelectedPCSingle(1)==portid
+1:
589 if CanLevelUp (portid
+1):
590 states
= flag
+blank
+chr(255) + states
592 states
= flag
+blank
+blank
+ states
593 Button
.SetText(states
)
596 def PortraitButtonOnDrag ():
597 global DraggedPortrait
600 DraggedPortrait
= GemRB
.GetVar ("PressedPortrait")
601 GemRB
.DragItem (DraggedPortrait
, -1, "")
604 def PortraitButtonOnPress ():
605 """Selects the portrait individually."""
607 i
= GemRB
.GetVar ("PressedPortrait")
612 if GemRB
.GameControlGetTargetMode() != TARGET_MODE_NONE
:
616 if (not SelectionChangeHandler
):
617 if GemRB
.GameIsPCSelected (i
):
618 GemRB
.GameControlSetScreenFlags (SF_CENTERONACTOR
, OP_OR
)
619 GemRB
.GameSelectPC (i
, True, SELECT_REPLACE
)
621 GemRB
.GameSelectPCSingle (i
)
623 RunSelectionChangeHandler ()
626 def PortraitButtonOnShiftPress ():
627 """Handles selecting multiple portaits with shift."""
629 i
= GemRB
.GetVar ("PressedPortrait")
634 if (not SelectionChangeHandler
):
635 sel
= GemRB
.GameIsPCSelected (i
)
637 GemRB
.GameSelectPC (i
, sel
)
639 GemRB
.GameSelectPCSingle (i
)
641 RunSelectionChangeHandler ()
644 def SelectionChanged ():
645 """Ran by the Game class when a PC selection is changed."""
647 global PortraitWindow
649 GemRB
.SetVar ("ActionLevel", 0)
650 if (not SelectionChangeHandler
):
651 UpdateActionsWindow ()
652 for i
in range (PARTY_SIZE
):
653 Button
= PortraitWindow
.GetControl (i
)
654 Button
.EnableBorder (FRAME_PC_SELECTED
, GemRB
.GameIsPCSelected (i
+ 1))
656 sel
= GemRB
.GameGetSelectedPCSingle ()
659 GemRB
.SetVar ("MAGESCHOOL", 0)
660 Kit
= GetKitIndex (sel
)
661 if Kit
and KitListTable
.GetValue (Kit
, 7) == 1:
662 MageTable
= GemRB
.LoadTableObject ("magesch")
663 GemRB
.SetVar ("MAGESCHOOL", MageTable
.FindValue (3, KitListTable
.GetValue (Kit
, 6) ) )
665 for i
in range (PARTY_SIZE
):
666 Button
= PortraitWindow
.GetControl (i
)
667 Button
.EnableBorder (FRAME_PC_SELECTED
, i
+ 1 == sel
)
670 def PortraitButtonOnMouseEnter ():
671 global DraggedPortrait
673 i
= GemRB
.GetVar ("PressedPortrait")
674 if GemRB
.IsDraggingItem()==2:
675 if DraggedPortrait
!= None:
676 GemRB
.SwapPCs (DraggedPortrait
, i
)
677 GemRB
.SetVar ("PressedPortrait", DraggedPortrait
)
679 GemRB
.SetTimedEvent ("CheckDragging",1)
684 if GemRB
.IsDraggingItem ():
685 Button
= PortraitWindow
.GetControl (i
)
686 Button
.EnableBorder (FRAME_PC_TARGET
, 1)
689 def OnDropPortraitToPC ():
690 GemRB
.SetVar ("PressedPortrait",0)
691 GemRB
.DragItem (0, -1, "")
692 DraggedPortrait
= None
696 """Contains portrait dragging in case of mouse out-of-range."""
698 global DraggedPortrait
700 i
= GemRB
.GetVar ("PressedPortrait")
702 GemRB
.DragItem (0, -1, "")
704 if GemRB
.IsDraggingItem()!=2:
705 DraggedPortrait
= None
708 def PortraitButtonOnMouseLeave ():
709 i
= GemRB
.GetVar ("PressedPortrait")
713 Button
= PortraitWindow
.GetControl (i
-1)
714 Button
.EnableBorder (FRAME_PC_TARGET
, 0)
715 GemRB
.SetVar ("PressedPortrait", 0)
716 GemRB
.SetTimedEvent ("CheckDragging",1)
719 def OpenWaitForDiscWindow ():
726 GemRB
.SetVar ("OtherWindow", -1)
727 # ...LoadWindowPack()
728 EnableAnimatedWindows ()
738 GemRB
.LoadWindowPack ("GUIID")
739 DiscWindow
= Window
= GemRB
.LoadWindowObject (0)
740 GemRB
.SetVar ("OtherWindow", Window
.ID
)
741 label
= DiscWindow
.GetControl (0)
743 disc_num
= GemRB
.GetVar ("WaitForDisc")
744 #disc_path = GemRB.GetVar ("WaitForDiscPath")
747 text
= GemRB
.GetString (31483) + " " + str (disc_num
) + " " + GemRB
.GetString (31569) + " " + disc_path
+ "\n" + GemRB
.GetString (49152)
749 DisableAnimatedWindows ()
750 # 31483 - Please place PS:T disc number
751 # 31568 - Please place the PS:T DVD
753 # 31570 - Wrong disc in drive
754 # 31571 - There is no disc in drive
755 # 31578 - No disc could be found in drive. Please place Disc 1 in drive.
756 # 49152 - To quit the game, press Alt-F4
761 DiscWindow
.SetVisible (WINDOW_VISIBLE
)
763 def CheckLevelUp(pc
):
764 GemRB
.SetVar ("CheckLevelUp"+str(pc
), CanLevelUp (pc
))