Skip to content

Commit

Permalink
directly pass the slot number to OpenItemWindow where possible
Browse files Browse the repository at this point in the history
This prevents problems with "ItemButton" changing in between due to
window focus changes.
  • Loading branch information
fizzet committed Apr 16, 2013
1 parent 1cea90e commit 596bcde
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions gemrb/GUIScripts/InventoryCommon.py
Expand Up @@ -358,13 +358,18 @@ def DisplayItem (itemresref, type):
ItemInfoWindow.ShowModal(MODAL_SHADOW_GRAY)
return

def OpenItemInfoWindow ():
def OpenItemInfoWindow (slot = None):
pc = GemRB.GameGetSelectedPCSingle ()
if GUICommon.GameIsPST():
slot, slot_item = GUIINV.ItemHash[GemRB.GetVar ('ItemButton')]

if slot == None:
if GUICommon.GameIsPST():
slot, slot_item = GUIINV.ItemHash[GemRB.GetVar ('ItemButton')]
else:
slot = GemRB.GetVar ("ItemButton")
slot_item = GemRB.GetSlotItem (pc, slot)
else:
slot = GemRB.GetVar ("ItemButton")
slot_item = GemRB.GetSlotItem (pc, slot)

item = GemRB.GetItem (slot_item["ItemResRef"])

if TryAutoIdentification(pc, item, slot, slot_item, True):
Expand Down Expand Up @@ -790,7 +795,7 @@ def IdentifyUseSpell ():
ItemInfoWindow.Unload ()
GemRB.ChangeItemFlag (pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
GemRB.PlaySound(DEF_IDENTIFY)
OpenItemInfoWindow()
OpenItemInfoWindow(slot)
return

def IdentifyUseScroll ():
Expand All @@ -807,7 +812,7 @@ def IdentifyUseScroll ():
if GemRB.HasSpecialItem (pc, 1, 1):
GemRB.ChangeItemFlag (pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
GemRB.PlaySound(DEF_IDENTIFY)
OpenItemInfoWindow()
OpenItemInfoWindow(slot)
return

def CloseIdentifyItemWindow ():
Expand Down

0 comments on commit 596bcde

Please sign in to comment.