ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Force a full inventory update... (https://www.esoui.com/forums/showthread.php?t=4700)

Phinix 05/06/15 01:23 AM

Force a full inventory update...
 
Greetings fellow Moon coders!

I have recently found a need to perform a full refresh of the active inventory when performing a certain action. This is because I am adding icons to tracked recipes in the inventory and want to be able to dynamically update the appearance as you enable and disable tracking.

The in-game function to "Rescan Bag" does NOT work. It would need to work like switching tabs, which does cause the list to update properly.

I have tried several functions, PlayerInventory:RefreshAllInventorySlots(INVENTORY_BACKPACK) being the latest, but they seem to be private or otherwise do not work and throw errors.

Also, I would need this to be able to update the inventory list regardless of whether it is your backpack, the bank, guild bank, buyback, and preferable the guild stores, though that may be trickier.

Any help would be much appreciated!

Phinix 05/06/15 09:16 AM

Figured it out...
Code:

PLAYER_INVENTORY:UpdateList(INVENTORY_BACKPACK)
PLAYER_INVENTORY:UpdateList(INVENTORY_BANK)
PLAYER_INVENTORY:UpdateList(INVENTORY_GUILD_BANK)


Phinix 05/06/15 09:37 AM

Still looking for a simply way to refresh the guild store result listings...

Minceraft 05/06/15 11:14 AM

Take a look at this...



Lua Code:
  1. function ZO_SharedInventoryManager:Initialize()
  2.     local function OnInventoryItemDestroyed(eventCode, itemSoundCategory)
  3.         PlayItemSound(itemSoundCategory, ITEM_SOUND_ACTION_DESTROY)
  4.     end
  5.     EVENT_MANAGER:RegisterForEvent(namespace, EVENT_INVENTORY_ITEM_DESTROYED, OnInventoryItemDestroyed)
  6.  
  7.     local function OnInventoryItemUsed(eventCode, itemSoundCategory)
  8.         PlayItemSound(itemSoundCategory, ITEM_SOUND_ACTION_USE)
  9.     end
  10.     EVENT_MANAGER:RegisterForEvent(namespace, EVENT_INVENTORY_ITEM_USED, OnInventoryItemUsed)
  11.  
  12.     EVENT_MANAGER:RegisterForEvent(namespace, EVENT_OPEN_FENCE, function() self:RefreshInventory(BAG_BACKPACK) end)
  13.  
  14.     self.bagCache = {}
  15.     self.questCache = {}
  16.  
  17.     self.refresh = ZO_Refresh:New()
  18.  
  19.     self.refresh:AddRefreshGroup("inventory",
  20.     {
  21.         RefreshAll = function()
  22.             self:RefreshInventory(BAG_BACKPACK)
  23.             self:RefreshInventory(BAG_WORN)
  24.         end,
  25.         RefreshSingle = function(...)
  26.             self:RefreshSingleSlot(...)
  27.         end,
  28.     })
  29.  
  30.     self.refresh:AddRefreshGroup("guild_bank",
  31.     {
  32.         RefreshAll = function()
  33.             self:RefreshInventory(BAG_GUILDBANK)
  34.         end,
  35.     })
  36.  
  37.     self.refresh:AddRefreshGroup("quest_inventory",
  38.     {
  39.         RefreshAll = function()
  40.             self:RefreshAllQuests()
  41.         end,
  42.         RefreshSingle = function(questIndex)
  43.             self:RefreshSingleQuest(questIndex)
  44.         end,
  45.     })
  46.  
  47.     local function OnFullInventoryUpdated()
  48.         self.refresh:RefreshAll("inventory")
  49.     end

This is ZOs own code for the inventory refreshing functions for the destroy function and the like...

And maybe this for a few more ideas??
I find other peoples coding neat...

Lua Code:
  1. local function OnInventorySlotUpdated(eventCode, bagId, slotIndex, isNewItem, itemSoundCategory, updateReason)
  2.         if updateReason == INVENTORY_UPDATE_REASON_DURABILITY_CHANGE then
  3.             local newCondition = GetItemCondition(bagId, slotIndex)
  4.             if newCondition == 100 then
  5.                 self:FireCallbacks("ItemRepaired", bagId, slotIndex)
  6.             end
  7.         end
  8.  
  9.         self.refresh:UpdateRefreshGroups()
  10.  
  11.         self.refresh:RefreshSingle("inventory", bagId, slotIndex, isNewItem, itemSoundCategory, updateReason)
  12.  
  13.         if bagId == BAG_BACKPACK then
  14.             if isNewItem and GetCraftingInteractionType() == CRAFTING_TYPE_INVALID then
  15.                 PlayItemSound(itemSoundCategory, ITEM_SOUND_ACTION_ACQUIRE)
  16.             end
  17.         elseif GetInteractionType() == INTERACTION_BANK and bagId == BAG_BANK then
  18.             PlayItemSound(itemSoundCategory, ITEM_SOUND_ACTION_SLOT)
  19.         end
  20.  
  21.         self:FireCallbacks("SingleSlotInventoryUpdate", bagId, slotIndex)
  22.     end
  23.  
  24.     local function OnGuldBankUpdated()
  25.         self.refresh:RefreshAll("guild_bank")
  26.         self:FireCallbacks("FullInventoryUpdate", BAG_GUILDBANK)
  27.     end
  28.  
  29.     local namespace = tostring(self)
  30.     EVENT_MANAGER:RegisterForEvent(namespace, EVENT_INVENTORY_FULL_UPDATE, OnFullInventoryUpdated)
  31.     EVENT_MANAGER:RegisterForEvent(namespace, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnInventorySlotUpdated)



EDIT: You could maybe make your own refresh functions in the same manner?? Or just hook theirs... ;)

Baertram 05/06/15 11:16 AM

If you just want to update the srcoll lists so the icons are shown, and no other stuff needs to be updated to the itemData, you could try:

Lua Code:
  1. ZO_ScrollList_RefreshVisible(inventoryType)

"inventoryType" can be the control name of an ZO scrollist like
Player inventory: ZO_PlayerInventoryBackpack
Bank: ZO_PlayerBankBackpack
Guild Bank: ZO_GuildBankBackpack

Perhaps there is also a ZO_TradingHouseBackpack
or even one for the results list int he trading house. Check the trading house with ZGOO addon or try to check ZO_TradingHouse with ZGOO and look at the children, parent controls if you find a list to update.

Could be: ZO_TradingHouseItemPaneSearchResults

Minceraft 05/06/15 11:39 AM

Quote:

Originally Posted by Baertram (Post 21115)
If you just want to update the srcoll lists so the icons are shown, and no other stuff needs to be updated to the itemData, you could try:

Lua Code:
  1. ZO_ScrollList_RefreshVisible(inventoryType)

NICE!!!! I keep forgetting that it's a scroll list...LOL ;) I HATE scroll lists! Hehe

Phinix 05/07/15 12:15 AM

Quote:

Originally Posted by Baertram (Post 21115)
If you just want to update the srcoll lists so the icons are shown, and no other stuff needs to be updated to the itemData, you could try:

Lua Code:
  1. ZO_ScrollList_RefreshVisible(inventoryType)

"inventoryType" can be the control name of an ZO scrollist like
Player inventory: ZO_PlayerInventoryBackpack
Bank: ZO_PlayerBankBackpack
Guild Bank: ZO_GuildBankBackpack

Perhaps there is also a ZO_TradingHouseBackpack
or even one for the results list int he trading house. Check the trading house with ZGOO addon or try to check ZO_TradingHouse with ZGOO and look at the children, parent controls if you find a list to update.

Could be: ZO_TradingHouseItemPaneSearchResults

Thanks very much, this did what I was looking for:

Code:

ZO_ScrollList_RefreshVisible(ZO_TradingHouseItemPaneSearchResults)


All times are GMT -6. The time now is 04:28 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI