Fix for removal of ZO_Dialogs_GetDisplayedDialog. Now manually updates the listing
Wobin [05-24-14 - 05:34]
Fix for removal of ZO_Dialogs_GetDisplayedDialog. Now manually updates the listing
diff --git a/ChargeSquire.lua b/ChargeSquire.lua
index 3bacc05..16d959e 100644
--- a/ChargeSquire.lua
+++ b/ChargeSquire.lua
@@ -1,3 +1,25 @@
+local function IsFilledSoulGem(bagId, slotIndex)
+ return IsItemSoulGem(SOUL_GEM_TYPE_FILLED, bagId, slotIndex)
+end
+
+local function SortComparator(left, right)
+ return GetSoulGemItemInfo(left.data.bag, left.data.index) < GetSoulGemItemInfo(right.data.bag, right.data.index)
+end
+
+local function ChargeSquireRebuildList()
+ local listDialog = ZO_InventorySlot_GetItemListDialog()
+
+ listDialog:ClearList()
+
+ local itemList = PLAYER_INVENTORY:GenerateListOfVirtualStackedItems(INVENTORY_BACKPACK, IsFilledSoulGem)
+ for itemId, itemInfo in pairs(itemList) do
+ listDialog:AddListItem(itemInfo)
+ end
+
+ listDialog:CommitList(SortComparator)
+
+end
+
local function ChargeSquireLoaded(eventCode, addOnName)
if(addOnName ~= "ChargeSquire") then return end
@@ -5,17 +27,18 @@ local function ChargeSquireLoaded(eventCode, addOnName)
local hookfunction = dialog.buttons[1].callback
local charger = SOUL_GEM_ITEM_CHARGER.chargesUnderlayBar
+
+ dialog.canQueue = true
+
-- Now we hook the 'item charge' function of the dialog
dialog.buttons[1].callback =
function()
-- Find out if we're filling the bar completely
if charger:GetValue() < charger.max then
- -- And queue up the same dialog if not
- -- This used to be just a queued dialog, but if you used up a single
- -- type of gem, it wouldn't refresh the list properly, so we just delay
- -- the call
- local data = ZO_Dialogs_GetDisplayedDialog().data
- zo_callLater(function() ZO_Dialogs_ShowDialog("CHARGE_ITEM", data) end, 1)
+ -- And queue up the same dialog if not
+ ZO_Dialogs_ShowDialog("CHARGE_ITEM", ESO_Dialogs["CHARGE_ITEM"].customControl().data)
+ -- And callback a relisting of the gems
+ zo_callLater(ChargeSquireRebuildList, 500)
end
hookfunction()
end