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 ###################################################
26 from GUIDefines
import *
27 from ie_stats
import IE_MAXHITPOINTS
, IE_STATE_ID
, IE_HITPOINTS
, STATE_DEAD
28 from ie_modal
import *
29 from ie_action
import *
33 import InventoryCommon
35 # needed for all the Open*Window callbacks in the OptionsWindow
50 DraggedPortrait
= None
52 def SetupMenuWindowControls (Window
, Gears
, ReturnToGame
):
53 """Sets up all of the basic control windows."""
57 OptionsWindow
= Window
59 Button
= Window
.GetControl (0)
60 Button
.SetTooltip (16313)
61 Button
.SetVarAssoc ("SelectedWindow", 0)
62 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ReturnToGame
)
63 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
66 Button
= Window
.GetControl (1)
67 Button
.SetTooltip (16310)
68 Button
.SetVarAssoc ("SelectedWindow", 1)
69 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIMA
.OpenMapWindow
)
72 Button
= Window
.GetControl (2)
73 Button
.SetTooltip (16308)
74 Button
.SetVarAssoc ("SelectedWindow", 2)
75 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIJRNL
.OpenJournalWindow
)
78 Button
= Window
.GetControl (3)
79 Button
.SetTooltip (16307)
80 Button
.SetVarAssoc ("SelectedWindow", 3)
81 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIINV
.OpenInventoryWindow
)
84 Button
= Window
.GetControl (4)
85 Button
.SetTooltip (16306)
86 Button
.SetVarAssoc ("SelectedWindow", 4)
87 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIREC
.OpenRecordsWindow
)
90 Button
= Window
.GetControl (5)
91 Button
.SetTooltip (16309)
92 Button
.SetVarAssoc ("SelectedWindow", 5)
93 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIMG
.OpenMageWindow
)
96 Button
= Window
.GetControl (6)
97 Button
.SetTooltip (14930)
98 Button
.SetVarAssoc ("SelectedWindow", 6)
99 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIPR
.OpenPriestWindow
)
102 Button
= Window
.GetControl (7)
103 Button
.SetTooltip (16311)
104 Button
.SetVarAssoc ("SelectedWindow", 7)
105 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIOPT
.OpenOptionsWindow
)
107 # Multi player team setup?
108 Button
= Window
.GetControl (8)
109 Button
.SetTooltip (13902)
112 # Pendulum, gears, sun/moon dial (time)
113 # FIXME: display all animations: CPEN, CGEAR, CDIAL
114 Button
= Window
.GetControl (9)
115 Label
= Button
.CreateLabelOnButton (0x10000009, "NORMAL", 0)
117 Label
.SetAnimation ("CPEN")
118 Button
.SetAnimation ("CGEAR")
119 Button
.SetBAM ("CDIAL", 0, 0)
120 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
121 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_NORMAL
, OP_SET
)
122 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, GUICommon
.GearsClicked
)
123 GUICommon
.SetGamedaysAndHourToken()
124 Button
.SetTooltip(16041)
130 Button
= Window
.GetControl (rb
)
131 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUICommon
.RestPress
)
132 Button
.SetTooltip (11942)
135 UpdatePortraitWindow ()
137 def MarkMenuButton (WindowIndex
):
138 Pressed
= WindowIndex
.GetControl( GemRB
.GetVar ("SelectedWindow") )
140 for button
in range (9):
141 Button
= WindowIndex
.GetControl (button
)
142 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
144 if Pressed
: # don't draw the selection when returning to the game
145 Pressed
.SetState (IE_GUI_BUTTON_SELECTED
)
148 """Toggles the party AI."""
150 Button
= PortraitWindow
.GetControl (6)
151 AI
= GemRB
.GetMessageWindowSize () & GS_PARTYAI
154 GemRB
.GameSetScreenFlags (GS_PARTYAI
, OP_NAND
)
155 Button
.SetTooltip (15918)
156 GemRB
.SetVar ("AI", 0)
158 GemRB
.GameSetScreenFlags (GS_PARTYAI
, OP_OR
)
159 Button
.SetTooltip (15917)
160 GemRB
.SetVar ("AI", GS_PARTYAI
)
163 def EmptyControls ():
166 GemRB
.SetVar ("ActionLevel", 0)
167 Window
= ActionsWindow
169 Button
= Window
.GetControl (i
)
170 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
171 Button
.SetPicture ("")
174 def SelectFormationPreset ():
175 """Choose the default formation."""
176 GemRB
.GameSetFormation (GemRB
.GetVar ("Value"), GemRB
.GetVar ("Formation") )
180 def SetupFormation ():
181 """Opens the formation selection section."""
184 Window
= ActionsWindow
186 Button
= Window
.GetControl (i
)
187 Button
.SetFlags (IE_GUI_BUTTON_NORMAL
, OP_SET
)
188 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
189 Button
.SetBAM ("FORM%x"%i,0,0,-1)
190 Button
.SetVarAssoc ("Value", i
)
191 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SelectFormationPreset
)
194 def GroupControls ():
195 """Sections that control group actions."""
199 GemRB
.SetVar ("ActionLevel", 0)
200 Window
= ActionsWindow
201 Button
= Window
.GetControl (0)
202 Button
.SetActionIcon (globals(), 7)
203 Button
= Window
.GetControl (1)
204 Button
.SetActionIcon (globals(), 15)
205 Button
= Window
.GetControl (2)
206 Button
.SetActionIcon (globals(), 21)
207 Button
= Window
.GetControl (3)
208 Button
.SetActionIcon (globals(), -1)
209 Button
= Window
.GetControl (4)
210 Button
.SetActionIcon (globals(), -1)
211 Button
= Window
.GetControl (5)
212 Button
.SetActionIcon (globals(), -1)
213 Button
= Window
.GetControl (6)
214 Button
.SetActionIcon (globals(), -1)
215 GemRB
.SetVar ("Formation", GemRB
.GameGetFormation ())
217 Button
= Window
.GetControl (7+i
)
218 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
219 idx
= GemRB
.GameGetFormation (i
)
220 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NORMAL
, OP_SET
)
221 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
222 Button
.SetBAM ("FORM%x"%idx,0,0,-1)
223 Button
.SetVarAssoc ("Formation", i
)
224 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUICommon
.SelectFormation
)
225 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, SetupFormation
)
226 str = GemRB
.GetString (4935)
227 Button
.SetTooltip ("F%d - %s"%(8+i
,str) )
230 def OpenActionsWindowControls (Window
):
233 ActionsWindow
= Window
234 # Gears (time) when options pane is down
235 Button
= Window
.GetControl (62)
236 Label
= Button
.CreateLabelOnButton (0x1000003e, "NORMAL", 0)
238 # FIXME: display all animations
239 Label
.SetAnimation ("CPEN")
240 Button
.SetAnimation ("CGEAR")
241 Button
.SetBAM ("CDIAL", 0, 0)
242 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
243 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_NORMAL
, OP_SET
)
244 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, GUICommon
.GearsClicked
)
245 GUICommon
.SetGamedaysAndHourToken()
246 Button
.SetTooltip(16041)
247 UpdateActionsWindow ()
250 def SelectItemAbility():
251 pc
= GemRB
.GameGetFirstSelectedActor ()
252 slot
= GemRB
.GetVar ("Slot")
253 ability
= GemRB
.GetVar ("Ability")
254 GemRB
.SetupQuickSlot (pc
, 0, slot
, ability
, 1)
255 GemRB
.SetVar ("ActionLevel", 0)
258 def SetupItemAbilities(pc
, slot
):
259 Window
= ActionsWindow
261 slot_item
= GemRB
.GetSlotItem(pc
, slot
, 1)
262 item
= GemRB
.GetItem (slot_item
["ItemResRef"])
263 Tips
= item
["Tooltips"]
266 Button
= Window
.GetControl (i
)
267 Button
.SetPicture ("")
269 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NORMAL
, OP_SET
)
270 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
271 Button
.SetItemIcon (slot_item
['ItemResRef'], i
+6)
272 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SelectItemAbility
)
273 Button
.SetVarAssoc ("Ability", i
)
275 Button
.SetTooltip ("F%d - %s"%(i
+1,GemRB
.GetString(Tips
[i
])) )
277 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
280 def UpdateActionsWindow ():
281 """Redraws the actions section of the window."""
283 global ActionsWindow
, PortraitWindow
, OptionsWindow
284 global level
, TopIndex
286 if ActionsWindow
== -1:
289 if ActionsWindow
== None:
292 #fully redraw the side panes to cover the actions window
293 #do this only when there is no 'otherwindow'
294 if GemRB
.GetVar ("OtherWindow") == -1:
296 PortraitWindow
.Invalidate ()
298 OptionsWindow
.Invalidate ()
300 Selected
= GemRB
.GetSelectedSize()
302 #setting up the disabled button overlay (using the second border slot)
304 Button
= ActionsWindow
.GetControl (i
)
305 Button
.SetBorder (1, 0, 0, 0, 0, 50,30,10,120, 0, 1)
306 Button
.SetFont ("NUMBER")
316 #we are sure there is only one actor selected
317 pc
= GemRB
.GameGetFirstSelectedActor ()
319 level
= GemRB
.GetVar ("ActionLevel")
320 TopIndex
= GemRB
.GetVar ("TopIndex")
322 #this is based on class
323 ActionsWindow
.SetupControls (globals(), pc
, 0, 1)
325 ActionsWindow
.SetupEquipmentIcons(globals(), pc
, TopIndex
, 0, 1)
326 elif level
== 2: #spells
327 GemRB
.SetVar ("Type", 3)
328 ActionsWindow
.SetupSpellIcons(globals(), pc
, 3, TopIndex
, 0, 1)
329 elif level
== 3: #innates
330 GemRB
.SetVar ("Type", 4)
331 ActionsWindow
.SetupSpellIcons(globals(), pc
, 4, TopIndex
, 0, 1)
332 elif level
== 4: #quick weapon/item ability selection
333 SetupItemAbilities(pc
, GemRB
.GetVar("Slot") )
336 def ActionQWeaponPressed (which
):
337 """Selects the given quickslot weapon if possible."""
339 pc
= GemRB
.GameGetFirstSelectedActor ()
340 qs
= GemRB
.GetEquippedQuickSlot (pc
, 1, 1)
342 #38 is the magic slot
343 if ((qs
==which
) or (qs
==38)) and GemRB
.GameControlGetTargetMode() != TARGET_MODE_ATTACK
:
344 GemRB
.GameControlSetTargetMode (TARGET_MODE_ATTACK
, GA_NO_DEAD|GA_NO_SELF|GA_NO_HIDDEN
)
346 GemRB
.GameControlSetTargetMode (TARGET_MODE_NONE
)
347 GemRB
.SetEquippedQuickSlot (pc
, which
, -1, 1)
349 ActionsWindow
.SetupControls (globals(), pc
, 0, 1)
350 UpdateActionsWindow ()
353 def ActionQWeapon1Pressed ():
354 ActionQWeaponPressed(0)
356 def ActionQWeapon2Pressed ():
357 ActionQWeaponPressed(1)
359 def ActionQWeapon3Pressed ():
360 ActionQWeaponPressed(2)
362 def ActionQWeapon4Pressed ():
363 ActionQWeaponPressed(3)
365 #no check needed because the button wouldn't be drawn if illegal
366 def ActionLeftPressed ():
367 """Scrolls the actions window left.
369 Used primarily for spell selection."""
371 TopIndex
= GemRB
.GetVar ("TopIndex")
376 GemRB
.SetVar ("TopIndex", TopIndex
)
377 UpdateActionsWindow ()
380 #no check needed because the button wouldn't be drawn if illegal
381 def ActionRightPressed ():
382 """Scrolls the action window right.
384 Used primarily for spell selection."""
386 pc
= GemRB
.GameGetFirstSelectedActor ()
387 TopIndex
= GemRB
.GetVar ("TopIndex")
388 Type
= GemRB
.GetVar ("Type")
389 #Type is a bitfield if there is no level given
390 #This is to make sure cleric/mages get all spells listed
391 Max
= GemRB
.GetMemorizedSpellsCount(pc
, Type
, -1, 1)
393 if TopIndex
> Max
- 10:
398 GemRB
.SetVar ("TopIndex", TopIndex
)
399 UpdateActionsWindow ()
402 def ActionBardSongPressed ():
403 """Toggles the battle song."""
404 pc
= GemRB
.GameGetFirstSelectedActor ()
405 GemRB
.SetModalState (pc
, MS_BATTLESONG
, 1)
406 GemRB
.PlaySound ("act_01")
407 UpdateActionsWindow ()
410 def ActionSearchPressed ():
411 """Toggles detect traps."""
412 pc
= GemRB
.GameGetFirstSelectedActor ()
413 GemRB
.SetModalState (pc
, MS_DETECTTRAPS
, 1)
414 UpdateActionsWindow ()
417 def ActionStealthPressed ():
418 """Toggles stealth."""
419 pc
= GemRB
.GameGetFirstSelectedActor ()
420 GemRB
.SetModalState (pc
, MS_STEALTH
, 1)
421 GemRB
.PlaySound ("act_07")
422 UpdateActionsWindow ()
425 def ActionTurnPressed ():
426 """Toggles turn undead."""
427 pc
= GemRB
.GameGetFirstSelectedActor ()
428 GemRB
.SetModalState (pc
, MS_TURNUNDEAD
, 1)
429 GemRB
.PlaySound ("act_06")
430 UpdateActionsWindow ()
433 def ActionUseItemPressed ():
434 GemRB
.SetVar ("TopIndex", 0)
435 GemRB
.SetVar ("ActionLevel", 1)
436 UpdateActionsWindow ()
439 def ActionCastPressed ():
440 """Opens the spell choice scrollbar."""
441 GemRB
.SetVar ("TopIndex", 0)
442 GemRB
.SetVar ("ActionLevel", 2)
443 UpdateActionsWindow ()
446 def ActionQItemPressed (action
):
447 """Uses the given quick item."""
448 pc
= GemRB
.GameGetFirstSelectedActor ()
450 GemRB
.UseItem (pc
, -2, action
, -1, 1)
453 def ActionQItem1Pressed ():
454 ActionQItemPressed (ACT_QSLOT1
)
457 def ActionQItem2Pressed ():
458 ActionQItemPressed (ACT_QSLOT2
)
461 def ActionQItem3Pressed ():
462 ActionQItemPressed (ACT_QSLOT3
)
465 def ActionQItem4Pressed ():
466 ActionQItemPressed (ACT_QSLOT4
)
469 def ActionQItem5Pressed ():
470 ActionQItemPressed (ACT_QSLOT5
)
473 def ActionQItemRightPressed (action
):
474 """Selects the used ability of the quick item."""
475 pc
= GemRB
.GameGetFirstSelectedActor ()
476 GemRB
.SetVar ("Slot", action
)
477 GemRB
.SetVar ("ActionLevel", 4)
478 UpdateActionsWindow ()
481 def ActionQItem1RightPressed ():
482 ActionQItemRightPressed (19)
484 def ActionQItem2RightPressed ():
485 ActionQItemRightPressed (20)
487 def ActionQItem3RightPressed ():
488 ActionQItemRightPressed (21)
490 def ActionQItem4RightPressed ():
491 ActionQItemRightPressed (22)
493 def ActionQItem5RightPressed ():
494 ActionQItemRightPressed (23)
496 def ActionQWeapon1RightPressed ():
497 ActionQItemRightPressed (10)
499 def ActionQWeapon2RightPressed ():
500 ActionQItemRightPressed (11)
502 def ActionQWeapon3RightPressed ():
503 ActionQItemRightPressed (12)
505 def ActionQWeapon4RightPressed ():
506 ActionQItemRightPressed (13)
508 def ActionInnatePressed ():
509 """Opens the innate spell scrollbar."""
510 GemRB
.SetVar ("TopIndex", 0)
511 GemRB
.SetVar ("ActionLevel", 3)
512 UpdateActionsWindow ()
516 """Prepares a spell to be cast."""
518 pc
= GemRB
.GameGetFirstSelectedActor ()
520 GemRB
.GameControlSetTargetMode (TARGET_MODE_CAST
)
521 Spell
= GemRB
.GetVar ("Spell")
522 Type
= GemRB
.GetVar ("Type")
523 GemRB
.SpellCast (pc
, Type
, Spell
, 1)
524 GemRB
.SetVar ("ActionLevel", 0)
525 UpdateActionsWindow ()
528 def EquipmentPressed ():
529 pc
= GemRB
.GameGetFirstSelectedActor ()
531 GemRB
.GameControlSetTargetMode (TARGET_MODE_CAST
)
532 Item
= GemRB
.GetVar ("Equipment")
534 GemRB
.UseItem (pc
, -1, Item
, -1, 1)
535 GemRB
.SetVar ("ActionLevel", 0)
536 UpdateActionsWindow ()
539 SelectionChangeHandler
= None
541 def SetSelectionChangeHandler (handler
):
542 """Updates the selection handler."""
544 global SelectionChangeHandler
546 # Switching from walking to non-walking environment:
547 # set the first selected PC in walking env as a selected
549 #if (not SelectionChangeHandler) and handler:
550 if (not SelectionChangeHandler
) and handler
and (not GUICommon
.NextWindowFn
):
551 sel
= GemRB
.GameGetFirstSelectedPC ()
554 GemRB
.GameSelectPCSingle (sel
)
556 SelectionChangeHandler
= handler
558 # redraw selection on change main selection | single selection
562 def RunSelectionChangeHandler ():
563 if SelectionChangeHandler
:
564 SelectionChangeHandler ()
567 def OpenPortraitWindow (needcontrols
):
568 global PortraitWindow
570 PortraitWindow
= Window
= GemRB
.LoadWindow (1)
573 Button
=Window
.GetControl (8)
574 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MinimizePortraits
)
577 Button
= Window
.GetControl (6)
578 #fixing a gui bug, and while we are at it, hacking it to be easier
579 Button
.SetSprites ("GUIBTACT", 0, 48, 47, 46, 49)
580 GSFlags
= GemRB
.GetMessageWindowSize ()&GS_PARTYAI
582 GemRB
.SetVar ("AI", GSFlags
)
583 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AIPress
)
584 Button
.SetFlags (IE_GUI_BUTTON_CHECKBOX
, OP_OR
)
585 Button
.SetVarAssoc ("AI", 1)
587 Button
.SetTooltip (15917)
589 Button
.SetTooltip (15918)
592 Button
= Window
.GetControl (7)
593 Button
.SetTooltip (10485)
594 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUICommon
.SelectAllOnPress
)
596 for i
in range (PARTY_SIZE
):
597 Button
= Window
.GetControl (i
)
598 Button
.SetFont ("STATES2")
599 Button
.SetVarAssoc ("PressedPortrait", i
+1)
602 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, GUIINV
.OpenInventoryWindowClick
)
604 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, PortraitButtonOnPress
)
606 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PortraitButtonOnPress
)
607 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, PortraitButtonOnShiftPress
)
608 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, InventoryCommon
.OnDropItemToPC
)
609 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP_PORTRAIT
, OnDropPortraitToPC
)
610 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG
, PortraitButtonOnDrag
)
611 Button
.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON
, PortraitButtonOnMouseEnter
)
612 Button
.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON
, PortraitButtonOnMouseLeave
)
614 Button
.SetBorder (FRAME_PC_SELECTED
, 1, 1, 2, 2, 0, 255, 0, 255)
615 Button
.SetBorder (FRAME_PC_TARGET
, 3, 3, 4, 4, 255, 255, 0, 255)
617 UpdatePortraitWindow ()
621 def UpdatePortraitWindow ():
622 """Updates all of the portraits."""
624 Window
= PortraitWindow
626 pc
= GemRB
.GameGetSelectedPCSingle ()
627 Inventory
= GemRB
.GetVar ("Inventory")
629 for portid
in range (PARTY_SIZE
):
630 Button
= Window
.GetControl (portid
)
631 pic
= GemRB
.GetPlayerPortrait (portid
+1, 1)
632 if Inventory
and pc
!= portid
+1:
634 if pic
and GemRB
.GetPlayerStat(portid
+1, IE_STATE_ID
) & STATE_DEAD
:
636 # dead pcs are hidden in all stores but temples
637 if GUISTORE
.StoreWindow
and not GUISTORE
.StoreHealWindow
:
641 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
642 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
644 Button
.SetTooltip ("")
647 Button
.SetFlags (IE_GUI_BUTTON_PICTURE| IE_GUI_BUTTON_HORIZONTAL| \
648 IE_GUI_BUTTON_ALIGN_LEFT| IE_GUI_BUTTON_ALIGN_TOP| \
649 IE_GUI_BUTTON_DRAGGABLE|IE_GUI_BUTTON_MULTILINE
, OP_SET
)
650 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
651 Button
.SetPicture (pic
, "NOPORTSM")
652 GUICommon
.SetupDamageInfo (portid
+1, Button
)
654 #add effects on the portrait
655 effects
= GemRB
.GetPlayerStates (portid
+1)
657 for col
in range(len(effects
)):
658 states
= effects
[col
:col
+1] + states
659 if col
% 3 == 2: states
= "\n" + states
660 for x
in range(3 - (len(effects
)/3)):
661 states
= "\n" + states
662 states
= "\n" + states
665 flag
= blank
= chr(238)
669 if GemRB
.GetStore()!=None:
672 if GemRB
.GameGetSelectedPCSingle(1)==portid
+1:
675 if LUCommon
.CanLevelUp (portid
+1):
676 states
= flag
+blank
+chr(255) + states
678 states
= flag
+blank
+blank
+ states
679 Button
.SetText(states
)
682 def PortraitButtonOnDrag ():
683 global DraggedPortrait
686 DraggedPortrait
= GemRB
.GetVar ("PressedPortrait")
687 GemRB
.DragItem (DraggedPortrait
, -1, "")
690 def PortraitButtonOnPress ():
691 """Selects the portrait individually."""
693 i
= GemRB
.GetVar ("PressedPortrait")
698 if GemRB
.GameControlGetTargetMode() != TARGET_MODE_NONE
:
702 if (not SelectionChangeHandler
):
703 if GemRB
.GameIsPCSelected (i
):
704 GemRB
.GameControlSetScreenFlags (SF_CENTERONACTOR
, OP_OR
)
705 GemRB
.GameSelectPC (i
, True, SELECT_REPLACE
)
707 GemRB
.GameSelectPCSingle (i
)
709 RunSelectionChangeHandler ()
712 def PortraitButtonOnShiftPress ():
713 """Handles selecting multiple portaits with shift."""
715 i
= GemRB
.GetVar ("PressedPortrait")
720 if (not SelectionChangeHandler
):
721 sel
= GemRB
.GameIsPCSelected (i
)
723 GemRB
.GameSelectPC (i
, sel
)
725 GemRB
.GameSelectPCSingle (i
)
727 RunSelectionChangeHandler ()
730 def SelectionChanged ():
731 """Ran by the Game class when a PC selection is changed."""
733 global PortraitWindow
735 if not PortraitWindow
:
738 GemRB
.SetVar ("ActionLevel", 0)
739 if (not SelectionChangeHandler
):
740 UpdateActionsWindow ()
741 for i
in range (PARTY_SIZE
):
742 Button
= PortraitWindow
.GetControl (i
)
743 Button
.EnableBorder (FRAME_PC_SELECTED
, GemRB
.GameIsPCSelected (i
+ 1))
745 sel
= GemRB
.GameGetSelectedPCSingle ()
748 GemRB
.SetVar ("MAGESCHOOL", 0)
749 Kit
= GUICommon
.GetKitIndex (sel
)
750 if Kit
and CommonTables
.KitList
.GetValue (Kit
, 7) == 1:
751 MageTable
= GemRB
.LoadTable ("magesch")
752 GemRB
.SetVar ("MAGESCHOOL", MageTable
.FindValue (3, CommonTables
.KitList
.GetValue (Kit
, 6) ) )
754 for i
in range (PARTY_SIZE
):
755 Button
= PortraitWindow
.GetControl (i
)
756 Button
.EnableBorder (FRAME_PC_SELECTED
, i
+ 1 == sel
)
758 CommonWindow
.CloseContainerWindow()
761 def PortraitButtonOnMouseEnter ():
762 global DraggedPortrait
764 i
= GemRB
.GetVar ("PressedPortrait")
769 GemRB
.GameControlSetLastActor( i
)
770 if GemRB
.IsDraggingItem()==2:
771 if DraggedPortrait
!= None:
772 GemRB
.SwapPCs (DraggedPortrait
, i
)
773 GemRB
.SetVar ("PressedPortrait", DraggedPortrait
)
775 GemRB
.SetTimedEvent (CheckDragging
, 1)
780 if GemRB
.IsDraggingItem ():
781 Button
= PortraitWindow
.GetControl (i
-1)
782 Button
.EnableBorder (FRAME_PC_TARGET
, 1)
785 def OnDropPortraitToPC ():
786 GemRB
.SetVar ("PressedPortrait",0)
787 GemRB
.DragItem (0, -1, "")
788 DraggedPortrait
= None
792 """Contains portrait dragging in case of mouse out-of-range."""
794 global DraggedPortrait
796 i
= GemRB
.GetVar ("PressedPortrait")
798 GemRB
.DragItem (0, -1, "")
800 if GemRB
.IsDraggingItem()!=2:
801 DraggedPortrait
= None
804 def PortraitButtonOnMouseLeave ():
805 i
= GemRB
.GetVar ("PressedPortrait")
809 Button
= PortraitWindow
.GetControl (i
-1)
810 Button
.EnableBorder (FRAME_PC_TARGET
, 0)
811 GemRB
.SetVar ("PressedPortrait", 0)
812 GemRB
.SetTimedEvent (CheckDragging
, 1)
815 #FIXME: iterate over the whole selection
816 def ActionStopPressed ():
817 for i
in range (PARTY_SIZE
):
818 if GemRB
.GameIsPCSelected (i
+ 1):
819 GemRB
.ClearActions (i
+ 1)
822 def ActionTalkPressed ():
823 GemRB
.GameControlSetTargetMode (TARGET_MODE_TALK
,GA_NO_DEAD|GA_NO_ENEMY|GA_NO_HIDDEN
)
825 def ActionAttackPressed ():
826 GemRB
.GameControlSetTargetMode (TARGET_MODE_ATTACK
,GA_NO_DEAD|GA_NO_SELF|GA_NO_HIDDEN
)
828 def ActionDefendPressed ():
829 GemRB
.GameControlSetTargetMode (TARGET_MODE_DEFEND
,GA_NO_SELF|GA_NO_ENEMY|GA_NO_HIDDEN
)
831 def ActionThievingPressed ():
832 GemRB
.GameControlSetTargetMode (TARGET_MODE_PICK
, GA_NO_DEAD|GA_NO_SELF|GA_NO_ENEMY|GA_NO_HIDDEN
)
834 def MinimizePortraits():
835 GemRB
.GameSetScreenFlags(GS_PORTRAITPANE
, OP_OR
)
837 def OpenWaitForDiscWindow ():
844 GemRB
.SetVar ("OtherWindow", -1)
845 # ...LoadWindowPack()
846 EnableAnimatedWindows ()
856 GemRB
.LoadWindowPack ("GUIID")
857 DiscWindow
= Window
= GemRB
.LoadWindow (0)
858 GemRB
.SetVar ("OtherWindow", Window
.ID
)
859 label
= DiscWindow
.GetControl (0)
861 disc_num
= GemRB
.GetVar ("WaitForDisc")
862 #disc_path = GemRB.GetVar ("WaitForDiscPath")
865 text
= GemRB
.GetString (31483) + " " + str (disc_num
) + " " + GemRB
.GetString (31569) + " " + disc_path
+ "\n" + GemRB
.GetString (49152)
867 DisableAnimatedWindows ()
868 # 31483 - Please place PS:T disc number
869 # 31568 - Please place the PS:T DVD
871 # 31570 - Wrong disc in drive
872 # 31571 - There is no disc in drive
873 # 31578 - No disc could be found in drive. Please place Disc 1 in drive.
874 # 49152 - To quit the game, press Alt-F4
879 DiscWindow
.SetVisible (WINDOW_VISIBLE
)
881 def CheckLevelUp(pc
):
882 GemRB
.SetVar ("CheckLevelUp"+str(pc
), LUCommon
.CanLevelUp (pc
))