Thread Tools Display Modes
05/06/15, 01:23 AM   #1
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
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!
  Reply With Quote
05/06/15, 09:16 AM   #2
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Figured it out...
Code:
PLAYER_INVENTORY:UpdateList(INVENTORY_BACKPACK)
PLAYER_INVENTORY:UpdateList(INVENTORY_BANK)
PLAYER_INVENTORY:UpdateList(INVENTORY_GUILD_BANK)
  Reply With Quote
05/06/15, 09:37 AM   #3
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Still looking for a simply way to refresh the guild store result listings...
  Reply With Quote
05/06/15, 11:14 AM   #4
Minceraft
 
Minceraft's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
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...

Last edited by Minceraft : 05/06/15 at 11:17 AM.
  Reply With Quote
05/06/15, 11:16 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
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
  Reply With Quote
05/06/15, 11:39 AM   #6
Minceraft
 
Minceraft's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
Originally Posted by Baertram View Post
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
  Reply With Quote
05/07/15, 12:15 AM   #7
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Originally Posted by Baertram View Post
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)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Force a full inventory update...

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off