fix: DragonSoul Timer
This commit is contained in:
@@ -206,10 +206,12 @@ class DragonSoulWindow(ui.ScriptWindow):
|
|||||||
self.inventoryTab[(page+3)%5].SetUp()
|
self.inventoryTab[(page+3)%5].SetUp()
|
||||||
self.inventoryTab[(page+4)%5].SetUp()
|
self.inventoryTab[(page+4)%5].SetUp()
|
||||||
self.RefreshBagSlotWindow()
|
self.RefreshBagSlotWindow()
|
||||||
|
|
||||||
def SetItemToolTip(self, tooltipItem):
|
def SetItemToolTip(self, tooltipItem):
|
||||||
self.tooltipItem = tooltipItem
|
self.tooltipItem = tooltipItem
|
||||||
|
if tooltipItem:
|
||||||
|
tooltipItem.SetDragonSoulWindow(self)
|
||||||
|
|
||||||
def RefreshItemSlot(self):
|
def RefreshItemSlot(self):
|
||||||
self.RefreshBagSlotWindow()
|
self.RefreshBagSlotWindow()
|
||||||
self.RefreshEquipSlotWindow()
|
self.RefreshEquipSlotWindow()
|
||||||
|
|||||||
@@ -499,10 +499,18 @@ class ItemToolTip(ToolTip):
|
|||||||
# When displaying item tooltip, if the current character cannot equip the item, force it to use Disable Color (already works this way but needed ability to turn it off)
|
# When displaying item tooltip, if the current character cannot equip the item, force it to use Disable Color (already works this way but needed ability to turn it off)
|
||||||
self.bCannotUseItemForceSetDisableColor = True
|
self.bCannotUseItemForceSetDisableColor = True
|
||||||
|
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = -1
|
||||||
|
self._wearTimerCache = {}
|
||||||
|
self._dragonSoulWindow = None
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
ToolTip.__del__(self)
|
ToolTip.__del__(self)
|
||||||
self.metinSlot = None
|
self.metinSlot = None
|
||||||
|
|
||||||
|
def SetDragonSoulWindow(self, wnd):
|
||||||
|
self._dragonSoulWindow = wnd
|
||||||
|
|
||||||
def SetCannotUseItemForceSetDisableColor(self, enable):
|
def SetCannotUseItemForceSetDisableColor(self, enable):
|
||||||
self.bCannotUseItemForceSetDisableColor = enable
|
self.bCannotUseItemForceSetDisableColor = enable
|
||||||
|
|
||||||
@@ -568,6 +576,10 @@ class ItemToolTip(ToolTip):
|
|||||||
def ClearToolTip(self):
|
def ClearToolTip(self):
|
||||||
self.isShopItem = False
|
self.isShopItem = False
|
||||||
self.toolTipWidth = self.TOOL_TIP_WIDTH
|
self.toolTipWidth = self.TOOL_TIP_WIDTH
|
||||||
|
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = -1
|
||||||
|
|
||||||
ToolTip.ClearToolTip(self)
|
ToolTip.ClearToolTip(self)
|
||||||
|
|
||||||
def SetInventoryItem(self, slotIndex, window_type = player.INVENTORY):
|
def SetInventoryItem(self, slotIndex, window_type = player.INVENTORY):
|
||||||
@@ -584,6 +596,8 @@ class ItemToolTip(ToolTip):
|
|||||||
metinSlot = [player.GetItemMetinSocket(window_type, slotIndex, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
|
metinSlot = [player.GetItemMetinSocket(window_type, slotIndex, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
|
||||||
attrSlot = [player.GetItemAttribute(window_type, slotIndex, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
|
attrSlot = [player.GetItemAttribute(window_type, slotIndex, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
|
||||||
|
|
||||||
|
self._curItemWindowType = window_type
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
self.AddItemData(itemVnum, metinSlot, attrSlot)
|
self.AddItemData(itemVnum, metinSlot, attrSlot)
|
||||||
|
|
||||||
def SetShopItem(self, slotIndex):
|
def SetShopItem(self, slotIndex):
|
||||||
@@ -593,6 +607,8 @@ class ItemToolTip(ToolTip):
|
|||||||
|
|
||||||
price = shop.GetItemPrice(slotIndex)
|
price = shop.GetItemPrice(slotIndex)
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
self.isShopItem = True
|
self.isShopItem = True
|
||||||
|
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
@@ -612,6 +628,8 @@ class ItemToolTip(ToolTip):
|
|||||||
|
|
||||||
price = shop.GetItemPrice(slotIndex)
|
price = shop.GetItemPrice(slotIndex)
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
self.isShopItem = True
|
self.isShopItem = True
|
||||||
|
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
@@ -630,6 +648,8 @@ class ItemToolTip(ToolTip):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
|
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
||||||
@@ -645,6 +665,8 @@ class ItemToolTip(ToolTip):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
|
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
||||||
@@ -661,6 +683,8 @@ class ItemToolTip(ToolTip):
|
|||||||
|
|
||||||
item.SelectItem(itemVnum)
|
item.SelectItem(itemVnum)
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = privateShopSlotIndex
|
||||||
self.AppendSellingPrice(shop.GetPrivateShopItemPrice(invenType, invenPos))
|
self.AppendSellingPrice(shop.GetPrivateShopItemPrice(invenType, invenPos))
|
||||||
|
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
@@ -678,6 +702,8 @@ class ItemToolTip(ToolTip):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
||||||
metinSlot.append(safebox.GetItemMetinSocket(slotIndex, i))
|
metinSlot.append(safebox.GetItemMetinSocket(slotIndex, i))
|
||||||
@@ -693,6 +719,8 @@ class ItemToolTip(ToolTip):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.ClearToolTip()
|
self.ClearToolTip()
|
||||||
|
self._curItemWindowType = None
|
||||||
|
self._curItemSlotIndex = slotIndex
|
||||||
metinSlot = []
|
metinSlot = []
|
||||||
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
for i in xrange(player.METIN_SOCKET_MAX_NUM):
|
||||||
metinSlot.append(safebox.GetMallItemMetinSocket(slotIndex, i))
|
metinSlot.append(safebox.GetMallItemMetinSocket(slotIndex, i))
|
||||||
@@ -1263,7 +1291,7 @@ class ItemToolTip(ToolTip):
|
|||||||
self.AppendRealTimeStartFirstUseLastTime(item, metinSlot, i, limitValue2)
|
self.AppendRealTimeStartFirstUseLastTime(item, metinSlot, i, limitValue2)
|
||||||
|
|
||||||
elif item.LIMIT_TIMER_BASED_ON_WEAR == limitType:
|
elif item.LIMIT_TIMER_BASED_ON_WEAR == limitType:
|
||||||
self.AppendTimerBasedOnWearLastTime(metinSlot)
|
self.AppendTimerBasedOnWearLastTime(metinSlot, limitValue2)
|
||||||
|
|
||||||
self.ShowToolTip()
|
self.ShowToolTip()
|
||||||
|
|
||||||
@@ -1886,13 +1914,53 @@ class ItemToolTip(ToolTip):
|
|||||||
|
|
||||||
return timeTextLine
|
return timeTextLine
|
||||||
|
|
||||||
def AppendTimerBasedOnWearLastTime(self, metinSlot):
|
def AppendTimerBasedOnWearLastTime(self, metinSlot, getLimit):
|
||||||
if 0 == metinSlot[0]:
|
remainSec = metinSlot[0]
|
||||||
|
|
||||||
|
if 0 == remainSec:
|
||||||
self.AppendSpace(5)
|
self.AppendSpace(5)
|
||||||
self.AppendTextLine(localeInfo.CANNOT_USE, self.DISABLE_COLOR)
|
self.AppendTextLine(localeInfo.CANNOT_USE, self.DISABLE_COLOR)
|
||||||
|
return
|
||||||
|
|
||||||
|
# For Dragon Soul items, the timer only ticks when:
|
||||||
|
# 1. The item is EQUIPPED on a deck (window_type == player.INVENTORY for DS equip slots)
|
||||||
|
# 2. AND the deck is ACTIVATED
|
||||||
|
# Items in DS inventory bag (window_type == player.DRAGON_SOUL_INVENTORY) never tick.
|
||||||
|
item.SelectItem(self.itemVnum)
|
||||||
|
isDragonSoulItem = item.GetItemType() == item.ITEM_TYPE_DS
|
||||||
|
|
||||||
|
if isDragonSoulItem:
|
||||||
|
isTimerActive = False
|
||||||
|
windowType = getattr(self, "_curItemWindowType", None)
|
||||||
|
# Only equipped DS items (in INVENTORY window, not DRAGON_SOUL_INVENTORY) can have active timers
|
||||||
|
isEquippedOnDeck = (windowType == player.INVENTORY)
|
||||||
|
if isEquippedOnDeck and self._dragonSoulWindow and getattr(self._dragonSoulWindow, "isActivated", False):
|
||||||
|
isTimerActive = True
|
||||||
else:
|
else:
|
||||||
endTime = app.GetGlobalTimeStamp() + metinSlot[0]
|
# Non-dragon soul items with LIMIT_TIMER_BASED_ON_WEAR
|
||||||
self.AppendMallItemLastTime(endTime, getLimit)
|
# Timer is active when equipped (this function is only called for such items)
|
||||||
|
isTimerActive = True
|
||||||
|
|
||||||
|
# Not active -> show STATIC remaining time (no ticking)
|
||||||
|
if not isTimerActive:
|
||||||
|
self.AppendSpace(5)
|
||||||
|
self.AppendTextLine(localeInfo.LEFT_TIME + ": " + localeInfo.RTSecondToDHMS(remainSec), self.NORMAL_COLOR)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Active -> show real-time countdown
|
||||||
|
# Cache maintains stable display across re-hovers (server updates remainSec periodically)
|
||||||
|
now = app.GetGlobalTimeStamp()
|
||||||
|
slotIndex = getattr(self, "_curItemSlotIndex", -1)
|
||||||
|
key = (self.itemVnum, slotIndex)
|
||||||
|
|
||||||
|
cache = self._wearTimerCache.get(key)
|
||||||
|
if cache and cache.get("remainSec") == remainSec:
|
||||||
|
endTime = cache["endTime"]
|
||||||
|
else:
|
||||||
|
endTime = now + remainSec
|
||||||
|
self._wearTimerCache[key] = {"remainSec": remainSec, "endTime": endTime}
|
||||||
|
|
||||||
|
self.AppendMallItemLastTime(endTime, getLimit)
|
||||||
|
|
||||||
def AppendRealTimeStartFirstUseLastTime(self, item, metinSlot, limitIndex, getLimit):
|
def AppendRealTimeStartFirstUseLastTime(self, item, metinSlot, limitIndex, getLimit):
|
||||||
useCount = metinSlot[1]
|
useCount = metinSlot[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user