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 # needed for all the Open*Window callbacks in the OptionsWindow
48 DraggedPortrait
= None
50 def SetupMenuWindowControls (Window
, Gears
, ReturnToGame
):
51 """Sets up all of the basic control windows."""
55 OptionsWindow
= Window
57 Button
= Window
.GetControl (0)
58 Button
.SetTooltip (16313)
59 Button
.SetVarAssoc ("SelectedWindow", 0)
60 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ReturnToGame
)
61 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
64 Button
= Window
.GetControl (1)
65 Button
.SetTooltip (16310)
66 Button
.SetVarAssoc ("SelectedWindow", 1)
67 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIMA
.OpenMapWindow
)
70 Button
= Window
.GetControl (2)
71 Button
.SetTooltip (16308)
72 Button
.SetVarAssoc ("SelectedWindow", 2)
73 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIJRNL
.OpenJournalWindow
)
76 Button
= Window
.GetControl (3)
77 Button
.SetTooltip (16307)
78 Button
.SetVarAssoc ("SelectedWindow", 3)
79 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIINV
.OpenInventoryWindow
)
82 Button
= Window
.GetControl (4)
83 Button
.SetTooltip (16306)
84 Button
.SetVarAssoc ("SelectedWindow", 4)
85 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIREC
.OpenRecordsWindow
)
88 Button
= Window
.GetControl (5)
89 Button
.SetTooltip (16309)
90 Button
.SetVarAssoc ("SelectedWindow", 5)
91 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIMG
.OpenMageWindow
)
94 Button
= Window
.GetControl (6)
95 Button
.SetTooltip (14930)
96 Button
.SetVarAssoc ("SelectedWindow", 6)
97 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIPR
.OpenPriestWindow
)
100 Button
= Window
.GetControl (7)
101 Button
.SetTooltip (16311)
102 Button
.SetVarAssoc ("SelectedWindow", 7)
103 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUIOPT
.OpenOptionsWindow
)
105 # Multi player team setup?
106 Button
= Window
.GetControl (8)
107 Button
.SetTooltip (13902)
110 # Pendulum, gears, sun/moon dial (time)
111 # FIXME: display all animations: CPEN, CGEAR, CDIAL
112 Button
= Window
.GetControl (9)
113 Label
= Button
.CreateLabelOnButton (0x10000009, "NORMAL", 0)
115 Label
.SetAnimation ("CPEN")
116 Button
.SetAnimation ("CGEAR")
117 Button
.SetBAM ("CDIAL", 0, 0)
118 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
119 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_NORMAL
, OP_SET
)
120 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, GUICommon
.GearsClicked
)
121 GUICommon
.SetGamedaysAndHourToken()
122 Button
.SetTooltip(16041)
128 Button
= Window
.GetControl (rb
)
129 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUICommon
.RestPress
)
130 Button
.SetTooltip (11942)
133 UpdatePortraitWindow ()
135 def MarkMenuButton (WindowIndex
):
136 Pressed
= WindowIndex
.GetControl( GemRB
.GetVar ("SelectedWindow") )
138 for button
in range (9):
139 Button
= WindowIndex
.GetControl (button
)
140 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
142 if Pressed
: # don't draw the selection when returning to the game
143 Pressed
.SetState (IE_GUI_BUTTON_SELECTED
)
146 """Toggles the party AI."""
148 Button
= PortraitWindow
.GetControl (6)
149 AI
= GemRB
.GetMessageWindowSize () & GS_PARTYAI
152 GemRB
.GameSetScreenFlags (GS_PARTYAI
, OP_NAND
)
153 Button
.SetTooltip (15918)
154 GemRB
.SetVar ("AI", 0)
156 GemRB
.GameSetScreenFlags (GS_PARTYAI
, OP_OR
)
157 Button
.SetTooltip (15917)
158 GemRB
.SetVar ("AI", GS_PARTYAI
)
161 def EmptyControls ():
164 GemRB
.SetVar ("ActionLevel", 0)
165 Window
= ActionsWindow
167 Button
= Window
.GetControl (i
)
168 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
169 Button
.SetPicture ("")
172 def SelectFormationPreset ():
173 """Choose the default formation."""
174 GemRB
.GameSetFormation (GemRB
.GetVar ("Value"), GemRB
.GetVar ("Formation") )
178 def SetupFormation ():
179 """Opens the formation selection section."""
182 Window
= ActionsWindow
184 Button
= Window
.GetControl (i
)
185 Button
.SetFlags (IE_GUI_BUTTON_NORMAL
, OP_SET
)
186 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
187 Button
.SetBAM ("FORM%x"%i,0,0,-1)
188 Button
.SetVarAssoc ("Value", i
)
189 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SelectFormationPreset
)
192 def GroupControls ():
193 """Sections that control group actions."""
197 GemRB
.SetVar ("ActionLevel", 0)
198 Window
= ActionsWindow
199 Button
= Window
.GetControl (0)
200 Button
.SetActionIcon (globals(), 7)
201 Button
= Window
.GetControl (1)
202 Button
.SetActionIcon (globals(), 15)
203 Button
= Window
.GetControl (2)
204 Button
.SetActionIcon (globals(), 21)
205 Button
= Window
.GetControl (3)
206 Button
.SetActionIcon (globals(), -1)
207 Button
= Window
.GetControl (4)
208 Button
.SetActionIcon (globals(), -1)
209 Button
= Window
.GetControl (5)
210 Button
.SetActionIcon (globals(), -1)
211 Button
= Window
.GetControl (6)
212 Button
.SetActionIcon (globals(), -1)
213 GemRB
.SetVar ("Formation", GemRB
.GameGetFormation ())
215 Button
= Window
.GetControl (7+i
)
216 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
217 idx
= GemRB
.GameGetFormation (i
)
218 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON|IE_GUI_BUTTON_NORMAL
, OP_SET
)
219 Button
.SetSprites ("GUIBTBUT",0,0,1,2,3)
220 Button
.SetBAM ("FORM%x"%idx,0,0,-1)
221 Button
.SetVarAssoc ("Formation", i
)
222 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUICommon
.SelectFormation
)
223 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, SetupFormation
)
224 str = GemRB
.GetString (4935)
225 Button
.SetTooltip ("F%d - %s"%(8+i
,str) )
228 def OpenActionsWindowControls (Window
):
231 ActionsWindow
= Window
232 # Gears (time) when options pane is down
233 Button
= Window
.GetControl (62)
234 Label
= Button
.CreateLabelOnButton (0x1000003e, "NORMAL", 0)
236 # FIXME: display all animations
237 Label
.SetAnimation ("CPEN")
238 Button
.SetAnimation ("CGEAR")
239 Button
.SetBAM ("CDIAL", 0, 0)
240 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
241 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_NORMAL
, OP_SET
)
242 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, GUICommon
.GearsClicked
)
243 GUICommon
.SetGamedaysAndHourToken()
244 Button
.SetTooltip(16041)
245 UpdateActionsWindow ()
248 def UpdateActionsWindow ():
249 """Redraws the actions section of the window."""
251 global ActionsWindow
, PortraitWindow
, OptionsWindow
252 global level
, TopIndex
254 if ActionsWindow
== -1:
257 if ActionsWindow
== None:
260 #fully redraw the side panes to cover the actions window
261 #do this only when there is no 'otherwindow'
262 if GemRB
.GetVar ("OtherWindow") == -1:
264 PortraitWindow
.Invalidate ()
266 OptionsWindow
.Invalidate ()
268 Selected
= GemRB
.GetSelectedSize()
270 #setting up the disabled button overlay (using the second border slot)
272 Button
= ActionsWindow
.GetControl (i
)
273 Button
.SetBorder (1, 0, 0, 0, 0, 50,30,10,120, 0, 1)
274 Button
.SetFont ("NUMBER")
283 #this is based on class
284 #we are sure there is only one actor selected
286 for i
in range (PARTY_SIZE
):
287 if GemRB
.GameIsPCSelected (i
+1):
292 #summoned/charmed creature.
293 #TODO: some creatures have real actions window!!
297 level
= GemRB
.GetVar ("ActionLevel")
298 TopIndex
= GemRB
.GetVar ("TopIndex")
300 ActionsWindow
.SetupControls (globals(), pc
)
302 ActionsWindow
.SetupEquipmentIcons(globals(), pc
, TopIndex
)
303 elif level
== 2: #spells
304 GemRB
.SetVar ("Type", 3)
305 ActionsWindow
.SetupSpellIcons(globals(), pc
, 3, TopIndex
)
306 elif level
== 3: #innates
307 GemRB
.SetVar ("Type", 4)
308 ActionsWindow
.SetupSpellIcons(globals(), pc
, 4, TopIndex
)
311 def ActionQWeaponPressed (which
):
312 """Selects the given quickslot weapon if possible."""
314 pc
= GemRB
.GameGetFirstSelectedPC ()
315 qs
= GemRB
.GetEquippedQuickSlot (pc
,1)
317 #38 is the magic slot
318 if ((qs
==which
) or (qs
==38)) and GemRB
.GameControlGetTargetMode() != TARGET_MODE_ATTACK
:
319 GemRB
.GameControlSetTargetMode (TARGET_MODE_ATTACK
, GA_NO_DEAD|GA_NO_SELF|GA_NO_HIDDEN
)
321 GemRB
.GameControlSetTargetMode (TARGET_MODE_NONE
)
322 GemRB
.SetEquippedQuickSlot (pc
, which
)
324 ActionsWindow
.SetupControls (globals(), pc
)
325 UpdateActionsWindow ()
328 def ActionQWeapon1Pressed ():
329 ActionQWeaponPressed(0)
331 def ActionQWeapon2Pressed ():
332 ActionQWeaponPressed(1)
334 def ActionQWeapon3Pressed ():
335 ActionQWeaponPressed(2)
337 def ActionQWeapon4Pressed ():
338 ActionQWeaponPressed(3)
340 #no check needed because the button wouldn't be drawn if illegal
341 def ActionLeftPressed ():
342 """Scrolls the actions window left.
344 Used primarily for spell selection."""
346 TopIndex
= GemRB
.GetVar ("TopIndex")
351 GemRB
.SetVar ("TopIndex", TopIndex
)
352 UpdateActionsWindow ()
355 #no check needed because the button wouldn't be drawn if illegal
356 def ActionRightPressed ():
357 """Scrolls the action window right.
359 Used primarily for spell selection."""
361 pc
= GemRB
.GameGetFirstSelectedPC ()
362 TopIndex
= GemRB
.GetVar ("TopIndex")
363 Type
= GemRB
.GetVar ("Type")
364 #Type is a bitfield if there is no level given
365 #This is to make sure cleric/mages get all spells listed
366 Max
= GemRB
.GetMemorizedSpellsCount(pc
, Type
)
368 if TopIndex
> Max
- 10:
373 GemRB
.SetVar ("TopIndex", TopIndex
)
374 UpdateActionsWindow ()
377 def ActionBardSongPressed ():
378 """Toggles the battle song."""
379 pc
= GemRB
.GameGetFirstSelectedPC ()
380 GemRB
.SetModalState (pc
, MS_BATTLESONG
)
381 GemRB
.PlaySound ("act_01")
382 UpdateActionsWindow ()
385 def ActionSearchPressed ():
386 """Toggles detect traps."""
387 pc
= GemRB
.GameGetFirstSelectedPC ()
388 GemRB
.SetModalState (pc
, MS_DETECTTRAPS
)
389 UpdateActionsWindow ()
392 def ActionStealthPressed ():
393 """Toggles stealth."""
394 pc
= GemRB
.GameGetFirstSelectedPC ()
395 GemRB
.SetModalState (pc
, MS_STEALTH
)
396 GemRB
.PlaySound ("act_07")
397 UpdateActionsWindow ()
400 def ActionTurnPressed ():
401 """Toggles turn undead."""
402 pc
= GemRB
.GameGetFirstSelectedPC ()
403 GemRB
.SetModalState (pc
, MS_TURNUNDEAD
)
404 GemRB
.PlaySound ("act_06")
405 UpdateActionsWindow ()
408 def ActionUseItemPressed ():
409 GemRB
.SetVar ("TopIndex", 0)
410 GemRB
.SetVar ("ActionLevel", 1)
411 UpdateActionsWindow ()
414 def ActionCastPressed ():
415 """Opens the spell choice scrollbar."""
416 GemRB
.SetVar ("TopIndex", 0)
417 GemRB
.SetVar ("ActionLevel", 2)
418 UpdateActionsWindow ()
421 def ActionQItemPressed (action
):
422 """Uses the given quick item."""
423 pc
= GemRB
.GameGetFirstSelectedPC ()
425 GemRB
.UseItem (pc
, -2, action
)
428 def ActionQItem1Pressed ():
429 ActionQItemPressed (ACT_QSLOT1
)
432 def ActionQItem2Pressed ():
433 ActionQItemPressed (ACT_QSLOT2
)
436 def ActionQItem3Pressed ():
437 ActionQItemPressed (ACT_QSLOT3
)
440 def ActionQItem4Pressed ():
441 ActionQItemPressed (ACT_QSLOT4
)
444 def ActionQItem5Pressed ():
445 ActionQItemPressed (ACT_QSLOT5
)
448 def ActionInnatePressed ():
449 """Opens the innate spell scrollbar."""
450 GemRB
.SetVar ("TopIndex", 0)
451 GemRB
.SetVar ("ActionLevel", 3)
452 UpdateActionsWindow ()
456 """Prepares a spell to be cast."""
458 pc
= GemRB
.GameGetFirstSelectedPC ()
460 GemRB
.GameControlSetTargetMode (TARGET_MODE_CAST
)
461 Spell
= GemRB
.GetVar ("Spell")
462 Type
= GemRB
.GetVar ("Type")
463 GemRB
.SpellCast (pc
, Type
, Spell
)
464 GemRB
.SetVar ("ActionLevel", 0)
465 UpdateActionsWindow ()
468 def EquipmentPressed ():
469 pc
= GemRB
.GameGetFirstSelectedPC ()
471 GemRB
.GameControlSetTargetMode (TARGET_MODE_CAST
)
472 Item
= GemRB
.GetVar ("Equipment")
474 GemRB
.UseItem (pc
, -1, Item
)
475 GemRB
.SetVar ("ActionLevel", 0)
476 UpdateActionsWindow ()
479 SelectionChangeHandler
= None
481 def SetSelectionChangeHandler (handler
):
482 """Updates the selection handler."""
484 global SelectionChangeHandler
486 # Switching from walking to non-walking environment:
487 # set the first selected PC in walking env as a selected
489 if (not SelectionChangeHandler
) and handler
:
490 sel
= GemRB
.GameGetFirstSelectedPC ()
493 GemRB
.GameSelectPCSingle (sel
)
495 SelectionChangeHandler
= handler
497 # redraw selection on change main selection | single selection
501 def RunSelectionChangeHandler ():
502 if SelectionChangeHandler
:
503 SelectionChangeHandler ()
506 def OpenPortraitWindow (needcontrols
):
507 global PortraitWindow
509 PortraitWindow
= Window
= GemRB
.LoadWindow (1)
512 Button
=Window
.GetControl (8)
513 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MinimizePortraits
)
516 Button
= Window
.GetControl (6)
517 #fixing a gui bug, and while we are at it, hacking it to be easier
518 Button
.SetSprites ("GUIBTACT", 0, 48, 47, 46, 49)
519 GSFlags
= GemRB
.GetMessageWindowSize ()&GS_PARTYAI
521 GemRB
.SetVar ("AI", GSFlags
)
522 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AIPress
)
523 Button
.SetFlags (IE_GUI_BUTTON_CHECKBOX
, OP_OR
)
524 Button
.SetVarAssoc ("AI", 1)
526 Button
.SetTooltip (15917)
528 Button
.SetTooltip (15918)
531 Button
= Window
.GetControl (7)
532 Button
.SetTooltip (10485)
533 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GUICommon
.SelectAllOnPress
)
535 for i
in range (PARTY_SIZE
):
536 Button
= Window
.GetControl (i
)
537 Button
.SetFont ("STATES2")
538 Button
.SetVarAssoc ("PressedPortrait", i
+1)
541 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, GUIINV
.OpenInventoryWindowClick
)
543 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, PortraitButtonOnPress
)
545 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PortraitButtonOnPress
)
546 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, PortraitButtonOnShiftPress
)
547 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, GUIINV
.OnDropItemToPC
)
548 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP_PORTRAIT
, OnDropPortraitToPC
)
549 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG
, PortraitButtonOnDrag
)
550 Button
.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON
, PortraitButtonOnMouseEnter
)
551 Button
.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON
, PortraitButtonOnMouseLeave
)
553 Button
.SetBorder (FRAME_PC_SELECTED
, 1, 1, 2, 2, 0, 255, 0, 255)
554 Button
.SetBorder (FRAME_PC_TARGET
, 3, 3, 4, 4, 255, 255, 0, 255)
556 UpdatePortraitWindow ()
560 def UpdatePortraitWindow ():
561 """Updates all of the portraits."""
563 Window
= PortraitWindow
565 pc
= GemRB
.GameGetSelectedPCSingle ()
566 Inventory
= GemRB
.GetVar ("Inventory")
568 for portid
in range (PARTY_SIZE
):
569 Button
= Window
.GetControl (portid
)
570 pic
= GemRB
.GetPlayerPortrait (portid
+1, 1)
571 if Inventory
and pc
!= portid
+1:
575 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
576 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
578 Button
.SetTooltip ("")
581 Button
.SetFlags (IE_GUI_BUTTON_PICTURE| \
582 IE_GUI_BUTTON_HORIZONTAL| \
583 IE_GUI_BUTTON_ALIGN_LEFT| IE_GUI_BUTTON_ALIGN_TOP| \
584 IE_GUI_BUTTON_DRAGGABLE|IE_GUI_BUTTON_MULTILINE
, OP_SET
)
585 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
586 Button
.SetPicture (pic
, "NOPORTSM")
587 hp
= GemRB
.GetPlayerStat (portid
+1, IE_HITPOINTS
)
588 hp_max
= GemRB
.GetPlayerStat (portid
+1, IE_MAXHITPOINTS
)
589 state
= GemRB
.GetPlayerStat (portid
+1, IE_STATE_ID
)
594 ratio
= (hp
+0.0) / hp_max
596 if hp
<1 or (state
& STATE_DEAD
):
597 Button
.SetOverlay (0, 64,64,64,200, 64,64,64,200)
599 Button
.SetOverlay (ratio
, 255,0,0,200, 128,0,0,200)
600 Button
.SetTooltip (GemRB
.GetPlayerName (portid
+1, 1) + "\n%d/%d" %(hp
, hp_max
))
602 #add effects on the portrait
603 effects
= GemRB
.GetPlayerStates (portid
+1)
605 for col
in range(len(effects
)):
606 states
= effects
[col
:col
+1] + states
607 if col
% 3 == 2: states
= "\n" + states
608 for x
in range(3 - (len(effects
)/3)):
609 states
= "\n" + states
610 states
= "\n" + states
613 flag
= blank
= chr(238)
617 if GemRB
.GetStore()!=None:
620 if GemRB
.GameGetSelectedPCSingle(1)==portid
+1:
623 if LUCommon
.CanLevelUp (portid
+1):
624 states
= flag
+blank
+chr(255) + states
626 states
= flag
+blank
+blank
+ states
627 Button
.SetText(states
)
630 def PortraitButtonOnDrag ():
631 global DraggedPortrait
634 DraggedPortrait
= GemRB
.GetVar ("PressedPortrait")
635 GemRB
.DragItem (DraggedPortrait
, -1, "")
638 def PortraitButtonOnPress ():
639 """Selects the portrait individually."""
641 i
= GemRB
.GetVar ("PressedPortrait")
646 if GemRB
.GameControlGetTargetMode() != TARGET_MODE_NONE
:
650 if (not SelectionChangeHandler
):
651 if GemRB
.GameIsPCSelected (i
):
652 GemRB
.GameControlSetScreenFlags (SF_CENTERONACTOR
, OP_OR
)
653 GemRB
.GameSelectPC (i
, True, SELECT_REPLACE
)
655 GemRB
.GameSelectPCSingle (i
)
657 RunSelectionChangeHandler ()
660 def PortraitButtonOnShiftPress ():
661 """Handles selecting multiple portaits with shift."""
663 i
= GemRB
.GetVar ("PressedPortrait")
668 if (not SelectionChangeHandler
):
669 sel
= GemRB
.GameIsPCSelected (i
)
671 GemRB
.GameSelectPC (i
, sel
)
673 GemRB
.GameSelectPCSingle (i
)
675 RunSelectionChangeHandler ()
678 def SelectionChanged ():
679 """Ran by the Game class when a PC selection is changed."""
681 global PortraitWindow
683 if not PortraitWindow
:
686 GemRB
.SetVar ("ActionLevel", 0)
687 if (not SelectionChangeHandler
):
688 UpdateActionsWindow ()
689 for i
in range (PARTY_SIZE
):
690 Button
= PortraitWindow
.GetControl (i
)
691 Button
.EnableBorder (FRAME_PC_SELECTED
, GemRB
.GameIsPCSelected (i
+ 1))
693 sel
= GemRB
.GameGetSelectedPCSingle ()
696 GemRB
.SetVar ("MAGESCHOOL", 0)
697 Kit
= GUICommon
.GetKitIndex (sel
)
698 if Kit
and GUICommon
.KitListTable
.GetValue (Kit
, 7) == 1:
699 MageTable
= GemRB
.LoadTable ("magesch")
700 GemRB
.SetVar ("MAGESCHOOL", MageTable
.FindValue (3, GUICommon
.KitListTable
.GetValue (Kit
, 6) ) )
702 for i
in range (PARTY_SIZE
):
703 Button
= PortraitWindow
.GetControl (i
)
704 Button
.EnableBorder (FRAME_PC_SELECTED
, i
+ 1 == sel
)
707 def PortraitButtonOnMouseEnter ():
708 global DraggedPortrait
710 i
= GemRB
.GetVar ("PressedPortrait")
712 GemRB
.GameControlSetLastActor( i
)
713 if GemRB
.IsDraggingItem()==2:
714 if DraggedPortrait
!= None:
715 GemRB
.SwapPCs (DraggedPortrait
, i
)
716 GemRB
.SetVar ("PressedPortrait", DraggedPortrait
)
718 GemRB
.SetTimedEvent (CheckDragging
, 1)
723 if GemRB
.IsDraggingItem ():
724 Button
= PortraitWindow
.GetControl (i
)
725 Button
.EnableBorder (FRAME_PC_TARGET
, 1)
728 def OnDropPortraitToPC ():
729 GemRB
.SetVar ("PressedPortrait",0)
730 GemRB
.DragItem (0, -1, "")
731 DraggedPortrait
= None
735 """Contains portrait dragging in case of mouse out-of-range."""
737 global DraggedPortrait
739 i
= GemRB
.GetVar ("PressedPortrait")
741 GemRB
.DragItem (0, -1, "")
743 if GemRB
.IsDraggingItem()!=2:
744 DraggedPortrait
= None
747 def PortraitButtonOnMouseLeave ():
748 i
= GemRB
.GetVar ("PressedPortrait")
752 Button
= PortraitWindow
.GetControl (i
-1)
753 Button
.EnableBorder (FRAME_PC_TARGET
, 0)
754 GemRB
.SetVar ("PressedPortrait", 0)
755 GemRB
.SetTimedEvent (CheckDragging
, 1)
758 def ActionStopPressed ():
759 for i
in range (PARTY_SIZE
):
760 if GemRB
.GameIsPCSelected (i
+ 1):
761 GemRB
.ClearActions (i
+ 1)
764 def ActionTalkPressed ():
765 GemRB
.GameControlSetTargetMode (TARGET_MODE_TALK
,GA_NO_DEAD|GA_NO_ENEMY|GA_NO_HIDDEN
)
767 def ActionAttackPressed ():
768 GemRB
.GameControlSetTargetMode (TARGET_MODE_ATTACK
,GA_NO_DEAD|GA_NO_SELF|GA_NO_HIDDEN
)
770 def ActionDefendPressed ():
771 GemRB
.GameControlSetTargetMode (TARGET_MODE_DEFEND
,GA_NO_SELF|GA_NO_ENEMY|GA_NO_HIDDEN
)
773 def ActionThievingPressed ():
774 GemRB
.GameControlSetTargetMode (TARGET_MODE_PICK
, GA_NO_DEAD|GA_NO_SELF|GA_NO_ENEMY|GA_NO_HIDDEN
)
776 def MinimizePortraits():
777 GemRB
.GameSetScreenFlags(GS_PORTRAITPANE
, OP_OR
)
779 def OpenWaitForDiscWindow ():
786 GemRB
.SetVar ("OtherWindow", -1)
787 # ...LoadWindowPack()
788 EnableAnimatedWindows ()
798 GemRB
.LoadWindowPack ("GUIID")
799 DiscWindow
= Window
= GemRB
.LoadWindow (0)
800 GemRB
.SetVar ("OtherWindow", Window
.ID
)
801 label
= DiscWindow
.GetControl (0)
803 disc_num
= GemRB
.GetVar ("WaitForDisc")
804 #disc_path = GemRB.GetVar ("WaitForDiscPath")
807 text
= GemRB
.GetString (31483) + " " + str (disc_num
) + " " + GemRB
.GetString (31569) + " " + disc_path
+ "\n" + GemRB
.GetString (49152)
809 DisableAnimatedWindows ()
810 # 31483 - Please place PS:T disc number
811 # 31568 - Please place the PS:T DVD
813 # 31570 - Wrong disc in drive
814 # 31571 - There is no disc in drive
815 # 31578 - No disc could be found in drive. Please place Disc 1 in drive.
816 # 49152 - To quit the game, press Alt-F4
821 DiscWindow
.SetVisible (WINDOW_VISIBLE
)
823 def CheckLevelUp(pc
):
824 GemRB
.SetVar ("CheckLevelUp"+str(pc
), LUCommon
.CanLevelUp (pc
))