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 # GUIINV.py - scripts to control inventory windows from GUIINV winpack
23 ###################################################
25 from GUIDefines
import *
26 from ie_stats
import *
27 from ie_slots
import *
30 import GUICommonWindows
33 InventoryWindow
= None
35 ItemAmountWindow
= None
36 ItemIdentifyWindow
= None
42 # 0 - 9 eye, rings, earrings, tattoos, etc
50 # 45 - ground scrollbar?
52 # 0x10000000 + 57 - name
53 # 0x10000000 + 58 - AC
54 # 0x10000000 + 59 - hp
55 # 0x10000000 + 60 - hp max
56 # 0x10000000 + 61 - msg
57 # 0x10000000 + 62 - party gold
58 # 0x10000000 + 63 - class
61 def OpenInventoryWindow ():
63 global InventoryWindow
65 AvSlotsTable
= GemRB
.LoadTable ('avslots')
67 if GUICommon
.CloseOtherWindow (OpenInventoryWindow
):
70 InventoryWindow
.Unload ()
71 InventoryWindow
= None
72 GemRB
.SetVar ("OtherWindow", -1)
73 GemRB
.SetVar ("MessageLabel", -1)
74 GUICommonWindows
.SetSelectionChangeHandler (None)
79 GemRB
.LoadWindowPack ("GUIINV")
80 InventoryWindow
= Window
= GemRB
.LoadWindow (3)
81 GemRB
.SetVar ("OtherWindow", InventoryWindow
.ID
)
82 GemRB
.SetVar ("MessageLabel", Window
.GetControl(0x1000003d).ID
)
86 Button
= Window
.GetControl (i
)
87 Button
.SetFlags (IE_GUI_BUTTON_ALIGN_RIGHT
, OP_OR
)
88 Button
.SetFont ("NUMBER2")
89 Button
.SetVarAssoc ("ItemButton", i
)
90 Button
.SetBorder (0,0,0,0,0,128,128,255,64,0,1)
91 Button
.SetBorder (1,0,0,0,0,255,128,128,64,0,1)
92 Button
.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON
, MouseEnterSlot
)
93 Button
.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON
, MouseLeaveSlot
)
97 Button
= Window
.GetControl (i
+47)
98 Button
.SetVarAssoc ("GroundItemButton", i
)
99 Button
.SetFlags (IE_GUI_BUTTON_ALIGN_RIGHT
, OP_OR
)
100 Button
.SetFont ("NUMBER2")
101 Button
.SetBorder (0,0,0,0,0,128,128,255,64,0,1)
102 Button
.SetBorder (1,0,0,0,0,255,128,128,64,0,1)
103 Button
.SetEvent (IE_GUI_MOUSE_ENTER_BUTTON
, MouseEnterGround
)
104 Button
.SetEvent (IE_GUI_MOUSE_LEAVE_BUTTON
, MouseLeaveGround
)
106 ScrollBar
= Window
.GetControl (45)
107 ScrollBar
.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE
, RefreshInventoryWindow
)
109 for i
in range (57, 64):
110 Label
= Window
.GetControl (0x10000000 + i
)
111 Label
.SetText (str (i
))
114 Button
= Window
.GetControl (44)
115 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
116 Button
.SetFlags(IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE
, OP_SET
)
117 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, OnAutoEquip
)
120 Button
= Window
.GetControl (46)
121 Button
.SetFont ("NUMBER")
122 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
123 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
126 Label
= Window
.GetControl (0x1000003a)
127 Label
.SetTooltip (4197)
130 Label
= Window
.GetControl (0x1000003b)
131 Label
.SetTooltip (4198)
134 Label
= Window
.GetControl (0x1000003c)
135 Label
.SetTooltip (4199)
137 # info label, game paused, etc
138 Label
= Window
.GetControl (0x1000003d)
139 Label
.SetTextColor(255, 255, 255)
141 GemRB
.SetVar ("TopIndex", 0)
142 GUICommonWindows
.SetSelectionChangeHandler (UpdateInventoryWindow
)
143 UpdateInventoryWindow ()
148 def UpdateInventoryWindow ():
152 Window
= InventoryWindow
154 GUICommonWindows
.UpdateAnimation ()
156 pc
= GemRB
.GameGetSelectedPCSingle ()
158 Container
= GemRB
.GetContainer (pc
, 1)
159 ScrollBar
= Window
.GetControl (45)
160 Count
= Container
['ItemCount']
163 ScrollBar
.SetVarAssoc ("TopIndex", Count
)
164 RefreshInventoryWindow ()
165 # And now for the items ....
169 # get a list which maps slot number to slot type/icon/tooltip
170 row
= GemRB
.GetPlayerStat (pc
, IE_SPECIFIC
)
171 slot_list
= map (int, AvSlotsTable
.GetValue (row
, 1, 0).split( ','))
173 # populate inventory slot controls
177 def RefreshInventoryWindow ():
178 Window
= InventoryWindow
179 pc
= GemRB
.GameGetSelectedPCSingle ()
182 Label
= Window
.GetControl (0x10000039)
183 Label
.SetText (GemRB
.GetPlayerName (pc
, 1))
187 Button
= Window
.GetControl (44)
188 Button
.SetPicture (GUICommonWindows
.GetActorPortrait (pc
, 'INVENTORY'))
190 GUICommon
.SetEncumbranceLabels (Window
, 46, None, pc
)
193 ac
= GemRB
.GetPlayerStat (pc
, IE_ARMORCLASS
)
194 ac
+= GemRB
.GetAbilityBonus (IE_DEX
, 2, GemRB
.GetPlayerStat (pc
, IE_DEX
) )
195 Label
= Window
.GetControl (0x1000003a)
196 Label
.SetText (str (ac
))
199 hp
= GemRB
.GetPlayerStat (pc
, IE_HITPOINTS
)
200 Label
= Window
.GetControl (0x1000003b)
201 Label
.SetText (str (hp
))
204 hpmax
= GemRB
.GetPlayerStat (pc
, IE_MAXHITPOINTS
)
205 Label
= Window
.GetControl (0x1000003c)
206 Label
.SetText (str (hpmax
))
209 Label
= Window
.GetControl (0x1000003e)
210 Label
.SetText (str (GemRB
.GameGetPartyGold ()))
213 text
= GUICommon
.ClassTable
.GetValue (GemRB
.GetPlayerStat (pc
, IE_CLASS
) - 1, 0)
215 Label
= Window
.GetControl (0x1000003f)
218 # update ground inventory slots
219 Container
= GemRB
.GetContainer(pc
, 1)
220 TopIndex
= GemRB
.GetVar ("TopIndex")
222 Button
= Window
.GetControl (i
+47)
223 if GemRB
.IsDraggingItem ():
224 Button
.SetState (IE_GUI_BUTTON_SECOND
)
226 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
227 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, OnDragItemGround
)
228 Slot
= GemRB
.GetContainerItem (pc
, i
+TopIndex
)
230 item
= GemRB
.GetItem (Slot
['ItemResRef'])
231 identified
= Slot
["Flags"] & IE_INV_ITEM_IDENTIFIED
233 Button
.SetItemIcon (Slot
['ItemResRef'])
234 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
235 if not identified
or item
["ItemNameIdentified"] == -1:
236 Button
.SetTooltip (item
["ItemName"])
237 Button
.EnableBorder (0, 1)
239 Button
.SetTooltip (item
["ItemNameIdentified"])
240 Button
.EnableBorder (0, 0)
241 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OnDragItemGround
)
242 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, OpenGroundItemInfoWindow
)
243 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, None) #TODO: implement OpenGroundItemAmountWindow
246 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
247 Button
.SetTooltip (4273)
248 Button
.EnableBorder (0, 0)
249 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, None)
250 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, None)
251 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, None)
254 def UpdateSlot (pc
, i
):
255 Window
= InventoryWindow
257 # NOTE: there are invisible items (e.g. MORTEP) in inaccessible slots
258 # used to assign powers and protections
262 SlotType
= GemRB
.GetSlotType (slot
)
265 slot
= slot_list
[i
]+1
266 SlotType
= GemRB
.GetSlotType (slot
)
267 slot_item
= GemRB
.GetSlotItem (pc
, slot
)
269 ControlID
= SlotType
["ID"]
273 if GemRB
.IsDraggingItem ():
275 drag_item
= GemRB
.GetSlotItem (0,0)
276 itemname
= drag_item
["ItemResRef"]
277 drag_item
= GemRB
.GetItem (itemname
)
281 Button
= Window
.GetControl (ControlID
)
282 ItemHash
[ControlID
] = [slot
, slot_item
]
283 Button
.SetSprites ('IVSLOT', 0, 0, 1, 2, 3)
285 item
= GemRB
.GetItem (slot_item
['ItemResRef'])
286 identified
= slot_item
['Flags'] & IE_INV_ITEM_IDENTIFIED
288 Button
.SetItemIcon (slot_item
['ItemResRef'])
289 if item
['StackAmount'] > 1:
290 Button
.SetText (str (slot_item
['Usages0']))
294 if not identified
or item
['ItemNameIdentified'] == -1:
295 Button
.SetTooltip (item
['ItemName'])
296 Button
.EnableBorder (0, 1)
298 Button
.SetTooltip (item
['ItemNameIdentified'])
299 Button
.EnableBorder (0, 0)
301 if GemRB
.CanUseItemType (SLOT_ANY
, slot_item
['ItemResRef'], pc
):
302 Button
.EnableBorder (1, 0)
304 Button
.EnableBorder (1, 1)
306 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
307 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OnDragItem
)
308 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, OpenItemInfoWindow
)
309 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, OpenItemAmountWindow
)
310 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, OnDragItem
)
312 Button
.SetItemIcon ('')
316 Button
.SetSprites (SlotType
["ResRef"], 0, 0, 1, 2, 3)
317 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
318 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, OnDragItem
)
319 Button
.SetTooltip (SlotType
["Tip"])
321 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
322 Button
.SetEvent (IE_GUI_BUTTON_ON_DRAG_DROP
, None)
323 Button
.SetTooltip ('')
326 Button
.EnableBorder (0, 0)
327 Button
.EnableBorder (1, 0)
328 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, None)
329 Button
.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS
, None)
330 Button
.SetEvent (IE_GUI_BUTTON_ON_SHIFT_PRESS
, None)
332 if OverSlot
== slot
-1:
333 if GemRB
.CanUseItemType (SlotType
["Type"], itemname
):
334 Button
.SetState (IE_GUI_BUTTON_SELECTED
)
336 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
338 if (SlotType
["Type"]&SLOT_INVENTORY
) or not GemRB
.CanUseItemType (SlotType
["Type"], itemname
):
339 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
341 Button
.SetState (IE_GUI_BUTTON_SECOND
)
343 if slot_item
and (GemRB
.GetEquippedQuickSlot (pc
)==slot
or GemRB
.GetEquippedAmmunition (pc
)==slot
):
344 Button
.SetState (IE_GUI_BUTTON_THIRD
)
347 def OnDragItemGround ():
348 pc
= GemRB
.GameGetSelectedPCSingle ()
350 slot
= GemRB
.GetVar ("GroundItemButton") + GemRB
.GetVar ("TopIndex")
351 if not GemRB
.IsDraggingItem ():
352 slot_item
= GemRB
.GetContainerItem (pc
, slot
)
353 item
= GemRB
.GetItem (slot_item
["ItemResRef"])
354 GemRB
.DragItem (pc
, slot
, item
["ItemIcon"], 0, 1) #container
355 GemRB
.PlaySound (item
["DescIcon"])
357 GemRB
.DropDraggedItem (pc
, -2) #dropping on ground
359 UpdateInventoryWindow ()
363 if not GemRB
.IsDraggingItem ():
366 pc
= GemRB
.GameGetSelectedPCSingle ()
368 item
= GemRB
.GetSlotItem (0,0)
369 ret
= GemRB
.DropDraggedItem (pc
, -1)
370 #this is exactly the same hack as the blackisle guys did it
371 #quite lame, but we should copy their efforts the best
372 if ret
== 2 and item
and (item
['ItemResRef'] == "dustrobe"):
373 GemRB
.SetGlobal("APPEARANCE","GLOBAL",2)
375 UpdateInventoryWindow ()
379 pc
= GemRB
.GameGetSelectedPCSingle ()
381 slot
, slot_item
= ItemHash
[GemRB
.GetVar ('ItemButton')]
383 if not GemRB
.IsDraggingItem ():
384 ResRef
= slot_item
['ItemResRef']
385 item
= GemRB
.GetItem (ResRef
)
386 GemRB
.DragItem (pc
, slot
, item
["ItemIcon"], 0, 0)
388 GemRB
.SetGlobal("APPEARANCE","GLOBAL",0)
390 item
= GemRB
.GetSlotItem (0,0)
391 itemdata
= GemRB
.GetItem(item
['ItemResRef'])
392 GemRB
.DropDraggedItem (pc
, slot
)
393 if slot
== 2 and item
['ItemResRef'] == 'dustrobe':
394 GemRB
.SetGlobal("APPEARANCE","GLOBAL",2)
395 elif slot
< 21 and itemdata
['AnimationType'] != '':
396 GemRB
.SetGlobal("APPEARANCE","GLOBAL",0)
398 UpdateInventoryWindow ()
401 def OnDropItemToPC ():
402 pc
= GemRB
.GetVar ("PressedPortrait") + 1
403 GemRB
.DropDraggedItem (pc
, -3)
404 UpdateInventoryWindow ()
407 def DragItemAmount ():
408 """Drag a split item."""
410 pc
= GemRB
.GameGetSelectedPCSingle ()
411 slot
, slot_item
= ItemHash
[GemRB
.GetVar ('ItemButton')]
412 Text
= ItemAmountWindow
.GetControl (6)
413 Amount
= Text
.QueryText ()
414 item
= GemRB
.GetItem (slot_item
["ItemResRef"])
415 GemRB
.DragItem (pc
, slot
, item
["ItemIcon"], int ("0"+Amount
), 0)
416 OpenItemAmountWindow ()
419 def OpenItemAmountWindow ():
420 global ItemAmountWindow
424 if ItemAmountWindow
!= None:
426 ItemAmountWindow
.Unload ()
427 ItemAmountWindow
= None
428 GemRB
.SetVar ("FloatWindow", -1)
433 ItemAmountWindow
= Window
= GemRB
.LoadWindow (4)
434 GemRB
.SetVar ("FloatWindow", ItemAmountWindow
.ID
)
436 pc
= GemRB
.GameGetSelectedPCSingle ()
437 slot
, slot_item
= ItemHash
[GemRB
.GetVar ('ItemButton')]
438 ResRef
= slot_item
['ItemResRef']
439 item
= GemRB
.GetItem (ResRef
)
442 Icon
= Window
.GetControl (0)
443 Icon
.SetFlags (IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
444 Icon
.SetItemIcon (ResRef
)
447 Text
= Window
.GetControl (6)
448 Text
.SetSize (40, 40)
450 Text
.SetStatus (IE_GUI_EDIT_NUMBER|IE_GUI_CONTROL_FOCUSED
)
453 Button
= Window
.GetControl (2)
454 Button
.SetText (1403)
455 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DragItemAmount
)
456 Button
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
459 Button
= Window
.GetControl (1)
460 Button
.SetText (4196)
461 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenItemAmountWindow
)
462 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
471 Window
.ShowModal (MODAL_SHADOW_GRAY
)
473 def LeftItemScroll ():
474 tmp
= GemRB
.GetVar ('ItemButton') - 1
478 while tmp
not in ItemHash
or not ItemHash
[tmp
][1]:
483 GemRB
.SetVar ('ItemButton', tmp
)
484 #one for close, one for reopen
485 CloseItemInfoWindow ()
486 OpenItemInfoWindow ()
489 def RightItemScroll ():
490 tmp
= GemRB
.GetVar ('ItemButton') + 1
494 while tmp
not in ItemHash
or not ItemHash
[tmp
][1]:
499 GemRB
.SetVar ('ItemButton', tmp
)
500 #one for close, one for reopen
501 CloseItemInfoWindow ()
502 OpenItemInfoWindow ()
505 def DrinkItemWindow ():
506 pc
= GemRB
.GameGetSelectedPCSingle ()
507 slot
= GemRB
.GetVar ("ItemButton")
508 # the drink item header is always the first
509 GemRB
.UseItem (pc
, slot
, 0)
511 ItemInfoWindow
.Unload ()
514 def ReadItemWindow ():
515 pc
= GemRB
.GameGetSelectedPCSingle ()
516 slot
= GemRB
.GetVar ("ItemButton")
517 # the learn scroll header is always the second
518 GemRB
.UseItem (pc
, slot
, 1)
520 ItemInfoWindow
.Unload ()
523 def OpenItemWindow ():
525 GemRB
.SetVar ("Inventory", 1)
527 ItemInfoWindow
.Unload ()
528 OpenInventoryWindow ()
529 pc
= GemRB
.GameGetSelectedPCSingle ()
530 slot
= GemRB
.GetVar ("ItemButton")
531 slot_item
= GemRB
.GetSlotItem (pc
, slot
)
532 ResRef
= slot_item
['ItemResRef']
533 #the store will have to reopen the inventory
534 GemRB
.EnterStore (ResRef
)
537 def DialogItemWindow ():
539 CloseItemInfoWindow ()
540 OpenInventoryWindow ()
541 pc
= GemRB
.GameGetSelectedPCSingle ()
542 slot
, slot_item
= ItemHash
[GemRB
.GetVar ('ItemButton')]
543 ResRef
= slot_item
['ItemResRef']
544 item
= GemRB
.GetItem (ResRef
)
545 dialog
=item
['Dialog']
546 GemRB
.ExecuteString ("StartDialog(\""+dialog
+"\",Myself)", pc
)
549 def IdentifyUseSpell ():
550 global ItemIdentifyWindow
552 pc
= GemRB
.GameGetSelectedPCSingle ()
553 slot
= GemRB
.GetVar ("ItemButton")
554 if ItemIdentifyWindow
:
555 ItemIdentifyWindow
.Unload ()
556 GemRB
.HasSpecialSpell (pc
, 1, 1)
557 GemRB
.ChangeItemFlag (pc
, slot
, IE_INV_ITEM_IDENTIFIED
, OP_OR
)
558 CloseIdentifyItemWindow()
561 def IdentifyUseScroll ():
562 global ItemIdentifyWindow
564 pc
= GemRB
.GameGetSelectedPCSingle ()
565 slot
= GemRB
.GetVar ("ItemButton")
566 if ItemIdentifyWindow
:
567 ItemIdentifyWindow
.Unload ()
568 if GemRB
.HasSpecialItem (pc
, 1, 1):
569 GemRB
.ChangeItemFlag (pc
, slot
, IE_INV_ITEM_IDENTIFIED
, OP_OR
)
570 CloseIdentifyItemWindow()
573 def CloseIdentifyItemWindow ():
574 global ItemIdentifyWindow
576 if ItemIdentifyWindow
:
577 ItemIdentifyWindow
.Unload ()
578 ItemIdentifyWindow
= None
581 def IdentifyItemWindow ():
582 global ItemIdentifyWindow
584 pc
= GemRB
.GameGetSelectedPCSingle ()
586 ItemIdentifyWindow
= Window
= GemRB
.LoadWindow (9)
588 # how would you like to identify ....
589 Text
= Window
.GetControl (3)
593 Button
= Window
.GetControl (0)
594 Button
.SetText (4259)
595 if not GemRB
.HasSpecialSpell (pc
, 1, 0):
596 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
597 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, IdentifyUseSpell
)
600 Button
= Window
.GetControl (1)
601 Button
.SetText (4260)
602 if not GemRB
.HasSpecialItem (pc
, 1, 0):
603 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
604 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, IdentifyUseScroll
)
607 Button
= Window
.GetControl (2)
608 Button
.SetText (4196)
609 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseIdentifyItemWindow
)
610 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
612 Window
.ShowModal (MODAL_SHADOW_GRAY
)
615 def CloseItemInfoWindow ():
617 ItemInfoWindow
.Unload ()
618 UpdateInventoryWindow()
621 def DisplayItem (itemresref
, type):
622 global ItemInfoWindow
624 item
= GemRB
.GetItem (itemresref
)
625 ItemInfoWindow
= Window
= GemRB
.LoadWindow (5)
628 Button
= Window
.GetControl (4)
629 Button
.SetText (1403)
630 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseItemInfoWindow
)
633 Button
= Window
.GetControl (8)
635 Button
.SetText (4256)
636 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, IdentifyItemWindow
)
638 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
639 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
642 Button
= Window
.GetControl (9)
643 drink
= (type&1) and (item
["Function"]&1)
644 read
= (type&1) and (item
["Function"]&2)
645 container
= (type&1) and (item
["Function"]&4)
646 dialog
= (type&1) and (item
["Dialog"]!="")
648 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
649 Button
.SetFlags (IE_GUI_BUTTON_NORMAL
, OP_SET
)
651 #no drink/food in PST, this is the closest strref in stock pst
652 Button
.SetText (4251)
653 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DrinkItemWindow
)
655 Button
.SetText (4252)
656 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ReadItemWindow
)
658 #no containers in PST, this is the closest strref in stock pst
659 Button
.SetText (52399)
660 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenItemWindow
)
662 Button
.SetText (4254)
663 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DialogItemWindow
)
666 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
667 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
669 Label
= Window
.GetControl (0x10000000)
671 Label
.SetText (GemRB
.GetString (item
['ItemName']).upper())
673 Label
.SetText (GemRB
.GetString (item
['ItemNameIdentified']).upper())
675 Icon
= Window
.GetControl (2)
676 Icon
.SetFlags (IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
677 Icon
.SetItemIcon (itemresref
)
679 Text
= Window
.GetControl (5)
681 Text
.SetText (item
['ItemDesc'])
683 Text
.SetText (item
['ItemDescIdentified'])
685 IdText
= Window
.GetControl (0x1000000b)
687 # 4279 - This item has not been identified
688 IdText
.SetText (4279)
692 Icon
= Window
.GetControl (7)
693 Icon
.SetFlags (IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
694 Icon
.SetItemIcon (itemresref
, 1)
697 Button
= Window
.GetControl (13)
698 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LeftItemScroll
)
701 Button
= Window
.GetControl (14)
702 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RightItemScroll
)
704 Window
.ShowModal (MODAL_SHADOW_GRAY
)
707 def OpenItemInfoWindow ():
708 pc
= GemRB
.GameGetSelectedPCSingle ()
709 slot
, slot_item
= ItemHash
[GemRB
.GetVar ('ItemButton')]
710 ResRef
= slot_item
['ItemResRef']
711 item
= GemRB
.GetItem (slot_item
["ItemResRef"])
713 #auto identify when lore is high enough
714 if item
["LoreToID"]<=GemRB
.GetPlayerStat (pc
, IE_LORE
):
715 GemRB
.ChangeItemFlag (pc
, slot
, IE_INV_ITEM_IDENTIFIED
, OP_OR
)
716 slot_item
["Flags"] |
= IE_INV_ITEM_IDENTIFIED
717 UpdateInventoryWindow ()
719 if slot_item
["Flags"] & IE_INV_ITEM_IDENTIFIED
:
723 DisplayItem (slot_item
["ItemResRef"], value
)
726 def OpenGroundItemInfoWindow ():
727 global ItemInfoWindow
729 pc
= GemRB
.GameGetSelectedPCSingle ()
730 slot
= GemRB
.GetVar ("TopIndex") + GemRB
.GetVar ("GroundItemButton")
731 slot_item
= GemRB
.GetContainerItem (pc
, slot
)
733 #the ground items are only displayable
734 if slot_item
["Flags"] & IE_INV_ITEM_IDENTIFIED
:
738 DisplayItem (slot_item
["ItemResRef"], value
)
741 def MouseEnterSlot ():
744 pc
= GemRB
.GameGetSelectedPCSingle ()
745 slot
= GemRB
.GetVar ('ItemButton')
746 if slot
not in ItemHash
:
748 OverSlot
= ItemHash
[slot
][0]-1
749 if GemRB
.IsDraggingItem ():
750 for i
in range(len(slot_list
)):
751 if slot_list
[i
]==OverSlot
:
755 def MouseLeaveSlot ():
758 pc
= GemRB
.GameGetSelectedPCSingle ()
759 slot
= GemRB
.GetVar ('ItemButton')
760 if slot
not in ItemHash
:
762 slot
= ItemHash
[slot
][0]-1
763 if slot
== OverSlot
or not GemRB
.IsDraggingItem ():
766 for i
in range(len(slot_list
)):
767 if slot_list
[i
]==slot
:
771 def MouseEnterGround ():
772 Window
= InventoryWindow
773 i
= GemRB
.GetVar ("GroundItemButton")
774 Button
= Window
.GetControl (i
+47)
775 if GemRB
.IsDraggingItem ():
776 Button
.SetState (IE_GUI_BUTTON_SELECTED
)
779 def MouseLeaveGround ():
780 Window
= InventoryWindow
781 i
= GemRB
.GetVar ("GroundItemButton")
782 Button
= Window
.GetControl (i
+47)
783 if GemRB
.IsDraggingItem ():
784 Button
.SetState (IE_GUI_BUTTON_SECOND
)
787 ###################################################
788 # End of file GUIINV.py