View Single Post
11/24/14, 11:46 PM   #18
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Item Saver

On Item Saver I see this:
Now I didn't have tons of time to spend on this one, so forgive me if I missunderstood the code I glanced at or if theres more going on that I noticed, but...on a single click of an inventory tab I got so much spam on functions that are firing I couldn't even fit it all in the chat window and some serious lag . Thats even after I maxed out the chat window buffer MaxHistoryLines...which is at 1,000. I see what you mean now about having all 4 filters on.

I see this running over & over & over


This part here:
Lua Code:
  1. --Choose the filter type
  2. local function getSettingsIsFilterOn(p_filterId, p_filterPanel)
Looks like it is getting called a lot...a lot. I couldn't really tell where it was coming from, there's so many calls to it all over. But I saw no other function before it firing to call it, so it must be getting called from a hook somewhere? It would probably be easier for you to track down being more familiar with the code.

Either way, What does getSettingsIsFilterOn() do. It looks like it just checks to see if certain filters are turned on or not for certain bags/inventories ? Could you just store all of the filter states for each of the inventories in a table, then use it wherever needed instead of calling this function everywhere? As filter states change just update the table. It looks like that is what its trying to do, but the question is, is there a reason it gets called so many times?



I also see this spamming a lot, scrolling through the entire buffer.

Create marker control is set as part of your callback on inventory row items and is whats calling the other functions after it.
Almost all of the code I see getting called from the callback on the inventory is doing stuff like setting dimensions, anchors, texture, colors, setting the tiers, exc.... I may be wrong do they move or change colors? Even if they do those don't seem like they should be part of the callback code. The callback itself is not what changes the color/size, so just change the color/size whenever the user pushes a button or whatever causes the color/size change, not every time the callback fires. These controls could probably be created & setup 1 time, then hidden/shown & change colors/sizes ONLY as needed.

As for MyGetItemInstanceId, MyGetItemDetails, & SignItemId are getting called from that it looks like.


I've never used prehooks so I may misunderstand whats going on here, but just in case I thought I would point this out. In your CreateMarkerControl (which is called in a callback from the inventory hook, so it fires a lot), it looks like it is constantly creating more & more & more prehooks everytime the function makes it into that part of the code? If for whatever reason it only makes it into that part of the code once then it doesn't need to be in the callback code. It should be called elsewhere to create the prehook then never called again?
Lua Code:
  1. if (controlId==1 and parent:GetParent() == ZO_ListDialog1ListContents) then
  2.  
  3.             --Pre-Hook the handler for mouse button up, to show context menu at mouse button 2, but keep the normal OnMouseUp handler as well
  4.             --parent:SetHandler("OnMouseUp", function(control, button, upInside)
  5.             --PreHookHandler( "OnMouseUp", parent, function(control, button, upInside)
  6.             ZO_PreHookHandler(parent, "OnMouseUp", function(control, button, upInside)
  7.                 --d("Clicked: " ..control:GetName() .. ", MouseButton: " .. tostring(button))
  8.                 --button 1= left mouse button / 2= right mouse button
  9.                 if button == 2 and upInside then
  10.                     --Add the menu items to the popup dialog row (parent)
  11.                     ClearMenu()
  12.                     for i = 1, gFCONumFilterIcons, 1 do
  13.                         zo_callLater(function() AddMark(parent, i, false) end, 50)
  14.                     end
  15.                 end
  16.             end)
  17.         end


One other thing I noticed, I don't think this is a big problem I never even saw this function fire, but while I'm at all of this (you did say even little fixes will help) in this function there is a lot of if/elseif statements:
Lua Code:
  1. --Check the weapon type of a weapon
  2. local function checkWeaponType(p_weaponType, p_check)
  3. d(colorDrkOrange.."checkWeaponType")
  4.     if (p_check == nil or p_check == '') then
  5.         p_check = '1hd'
  6.     end
  7.     if (p_weaponType ~= nil) then
  8.  
  9.         if     (p_check == '1hd') then
  10.  
  11.             if (p_weaponType == WEAPONTYPE_AXE or
  12.                 p_weaponType == WEAPONTYPE_DAGGER or
  13.                 p_weaponType == WEAPONTYPE_HAMMER or
  14.                 p_weaponType == WEAPONTYPE_SWORD) then
  15.                 return true
  16.             end
  17. -- exc....more code, lots of elseif statements --

it looks like you could just create a local table out of all of that info and then just check the table inside your function to see what to return. It would be a lot faster.
Like:
Lua Code:
  1. local p_Check_table = {
  2.    ["1hd"] = {
  3.       [WEAPONTYPE_AXE] = true,
  4.       [WEAPONTYPE_DAGGER] = true,
  5.       [WEAPONTYPE_HAMMER] = true,
  6.       [WEAPONTYPE_SWORD] = true,
  7.    },
  8. --- exc...do this for all of the p_check types
  9.    }
  10. }
  11. -- then do something like:
  12. local function checkWeaponType(p_weaponType, p_check)
  13.    -- ... code ... --
  14.    if (p_weaponType ~= nil) then
  15.       if p_Check_table[p_check] and p_Check_table[p_check][p_weaponType] then
  16.          return true
  17.       end
  18.    end
  19. --.. was there more code? I'm getting to lazy to go back and look.. if so do it too.. --
  20.    return false
  21. end

In the function:
local function AddMark(rowControl, markId, isEquipmentSlot)
I see
Lua Code:
  1. if (    rowControl:GetParent() ~= ZO_StoreWindowListContents
  2.         and rowControl:GetParent() ~= ZO_BuyBackListContents
  3.         and rowControl:GetParent() ~= ZO_PlayerInventoryQuestContents
  4.         --and rowControl:GetParent() ~= ZO_SmithingTopLevelImprovementPanelInventoryBackpackContents
  5.         and rowControl:GetParent() ~= ZO_SmithingTopLevelImprovementPanel
  6.         and rowControl:GetParent() ~= ZO_SmithingTopLevelResearchPanelResearchLineListList
  7.         and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelPatternListList
  8.         and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelMaterialListList
  9.         and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelStyleListList
  10.         and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelTraitListList
  11.         and rowControl:GetParent() ~= ZO_AlchemyTopLevelInventoryBackpackContents
  12.         and rowControl             ~= ZO_AlchemyTopLevelSlotContainer
  13.         --and rowControl:GetParent() ~= ZO_EnchantingTopLevelInventoryBackpackContents
  14.         and rowControl             ~= ZO_EnchantingTopLevelRuneSlotContainer
  15.         and rowControl             ~= ZO_EnchantingTopLevelExtractionSlotContainer
  16.         and rowControl:GetParent() ~= ZO_MailInboxMessage
  17.         and rowControl:GetParent() ~= ZO_MailSend
  18.         and rowControl             ~= ZO_ApplyEnchantPanel
  19.         and rowControl             ~= ZO_SoulGemItemChargerPanel
  20.         and rowControl:GetParent() ~= ZO_QuickSlotListContents) then
first, there are some of them missing the :GetParent() is that correct?

Either way that should really be changed to something like this, so you only have to call rowControl:GetParent() 1 time.
Lua Code:
  1. local parent = rowControl:GetParent()
  2.     --Check if the right click menu should be updated. Only allowed panels and menus apply
  3.     if (    parent ~= ZO_StoreWindowListContents
  4.         and parent ~= ZO_BuyBackListContents
  5.         and parent ~= ZO_PlayerInventoryQuestContents
  6.         --and parent ~= ZO_SmithingTopLevelImprovementPanelInventoryBackpackContents
  7.         and parent ~= ZO_SmithingTopLevelImprovementPanel
  8.         and parent ~= ZO_SmithingTopLevelResearchPanelResearchLineListList
  9.         and parent ~= ZO_SmithingTopLevelCreationPanelPatternListList
  10.         and parent ~= ZO_SmithingTopLevelCreationPanelMaterialListList
  11.         and parent ~= ZO_SmithingTopLevelCreationPanelStyleListList
  12.         and parent ~= ZO_SmithingTopLevelCreationPanelTraitListList
  13.         and parent ~= ZO_AlchemyTopLevelInventoryBackpackContents
  14.         and rowControl             ~= ZO_AlchemyTopLevelSlotContainer
  15.         --and parent ~= ZO_EnchantingTopLevelInventoryBackpackContents
  16.         and rowControl             ~= ZO_EnchantingTopLevelRuneSlotContainer
  17.         and rowControl             ~= ZO_EnchantingTopLevelExtractionSlotContainer
  18.         and parent ~= ZO_MailInboxMessage
  19.         and parent ~= ZO_MailSend
  20.         and rowControl             ~= ZO_ApplyEnchantPanel
  21.         and rowControl             ~= ZO_SoulGemItemChargerPanel
  22.         and parent ~= ZO_QuickSlotListContents) then
Although it would be a lot better if you just made a table out of the allowed panels and menus & then just check the table to see if parent and/or rowControl is in the table, if it is then it is an allowed panel. You could do it several ways, one would be getting the control names, storing them in the table with a value of true (if they are allowed panels) then checking the table to see if the panel is allowed.

I don't really know anything about these panels or menus. I do see your saying those panels up there are NOT allowed, but I don't know any other panel names to use so i'm going to use them and pretend they are allowed in my example.
You could do :
Lua Code:
  1. local tAllowedPanels = {
  2.    ["AlchemyTopLevelInventoryBackpackContents"] = true,
  3.    ["SmithingTopLevelCreationPanelTraitListList"]     = true,
  4.    ["SmithingTopLevelResearchPanelResearchLineListList"] = true,
  5. -- exc...--
  6. }
Then grab the parents name & see if it is an allowed panel by checking your table:
Lua Code:
  1. -- instead of doing this
  2. --local parent = rowControl:GetParent()
  3. -- and that big if statement
  4.  
  5. -- you could just do this
  6. local parentName = rowControl:GetParent():GetName()
  7. if tAllowedPanels[parentName] then
  8. -- do whatever --
  9. end


I see the same thing for this below, should probably do the same thing here with rowControl:GetName()
Lua Code:
  1. if (settings.autoMarkAllWeapon == false) then
  2.    if (    rowControl:GetName() == 'ZO_CharacterEquipmentSlotsMainHand'
  3.    or rowControl:GetName() == 'ZO_CharacterEquipmentSlotsOffHand'
  4.    -- lots more rowControl:GetName()


What about this:
Lua Code:
  1. local function UpdatePlayerInventory()
  2. ---...code...---
  3. -- It calls:
  4. PLAYER_INVENTORY:UpdateList(1)
If libFilters is handling the filtering why is your code calling UpdateList ?

Last edited by circonian : 11/25/14 at 12:04 AM.
  Reply With Quote