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:
--Choose the filter type
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:
if (controlId==1 and parent:GetParent() == ZO_ListDialog1ListContents) then
--Pre-Hook the handler for mouse button up, to show context menu at mouse button 2, but keep the normal OnMouseUp handler as well
--parent:SetHandler("OnMouseUp", function(control, button, upInside)
--PreHookHandler( "OnMouseUp", parent, function(control, button, upInside)
ZO_PreHookHandler(parent, "OnMouseUp", function(control, button, upInside)
--d("Clicked: " ..control:GetName() .. ", MouseButton: " .. tostring(button))
--button 1= left mouse button / 2= right mouse button
if button == 2 and upInside then
--Add the menu items to the popup dialog row (parent)
ClearMenu()
for i = 1, gFCONumFilterIcons, 1 do
zo_callLater(function() AddMark(parent, i, false) end, 50)
end
end
end)
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:
--Check the weapon type of a weapon
local function checkWeaponType(p_weaponType, p_check)
d(colorDrkOrange.."checkWeaponType")
if (p_check == nil or p_check == '') then
p_check = '1hd'
end
if (p_weaponType ~= nil) then
if (p_check == '1hd') then
if (p_weaponType == WEAPONTYPE_AXE or
p_weaponType == WEAPONTYPE_DAGGER or
p_weaponType == WEAPONTYPE_HAMMER or
p_weaponType == WEAPONTYPE_SWORD) then
return true
end
-- 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:
local p_Check_table = {
["1hd"] = {
[WEAPONTYPE_AXE] = true,
[WEAPONTYPE_DAGGER] = true,
[WEAPONTYPE_HAMMER] = true,
[WEAPONTYPE_SWORD] = true,
},
--- exc...do this for all of the p_check types
}
}
-- then do something like:
local function checkWeaponType(p_weaponType, p_check)
-- ... code ... --
if (p_weaponType ~= nil) then
if p_Check_table[p_check] and p_Check_table[p_check][p_weaponType] then
return true
end
end
--.. was there more code? I'm getting to lazy to go back and look.. if so do it too.. --
return false
end
In the function:
local function AddMark(rowControl, markId, isEquipmentSlot)
I see
Lua Code:
if ( rowControl:GetParent() ~= ZO_StoreWindowListContents
and rowControl:GetParent() ~= ZO_BuyBackListContents
and rowControl:GetParent() ~= ZO_PlayerInventoryQuestContents
--and rowControl:GetParent() ~= ZO_SmithingTopLevelImprovementPanelInventoryBackpackContents
and rowControl:GetParent() ~= ZO_SmithingTopLevelImprovementPanel
and rowControl:GetParent() ~= ZO_SmithingTopLevelResearchPanelResearchLineListList
and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelPatternListList
and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelMaterialListList
and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelStyleListList
and rowControl:GetParent() ~= ZO_SmithingTopLevelCreationPanelTraitListList
and rowControl:GetParent() ~= ZO_AlchemyTopLevelInventoryBackpackContents
and rowControl ~= ZO_AlchemyTopLevelSlotContainer
--and rowControl:GetParent() ~= ZO_EnchantingTopLevelInventoryBackpackContents
and rowControl ~= ZO_EnchantingTopLevelRuneSlotContainer
and rowControl ~= ZO_EnchantingTopLevelExtractionSlotContainer
and rowControl:GetParent() ~= ZO_MailInboxMessage
and rowControl:GetParent() ~= ZO_MailSend
and rowControl ~= ZO_ApplyEnchantPanel
and rowControl ~= ZO_SoulGemItemChargerPanel
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:
local parent = rowControl:GetParent()
--Check if the right click menu should be updated. Only allowed panels and menus apply
if ( parent ~= ZO_StoreWindowListContents
and parent ~= ZO_BuyBackListContents
and parent ~= ZO_PlayerInventoryQuestContents
--and parent ~= ZO_SmithingTopLevelImprovementPanelInventoryBackpackContents
and parent ~= ZO_SmithingTopLevelImprovementPanel
and parent ~= ZO_SmithingTopLevelResearchPanelResearchLineListList
and parent ~= ZO_SmithingTopLevelCreationPanelPatternListList
and parent ~= ZO_SmithingTopLevelCreationPanelMaterialListList
and parent ~= ZO_SmithingTopLevelCreationPanelStyleListList
and parent ~= ZO_SmithingTopLevelCreationPanelTraitListList
and parent ~= ZO_AlchemyTopLevelInventoryBackpackContents
and rowControl ~= ZO_AlchemyTopLevelSlotContainer
--and parent ~= ZO_EnchantingTopLevelInventoryBackpackContents
and rowControl ~= ZO_EnchantingTopLevelRuneSlotContainer
and rowControl ~= ZO_EnchantingTopLevelExtractionSlotContainer
and parent ~= ZO_MailInboxMessage
and parent ~= ZO_MailSend
and rowControl ~= ZO_ApplyEnchantPanel
and rowControl ~= ZO_SoulGemItemChargerPanel
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:
local tAllowedPanels = {
["AlchemyTopLevelInventoryBackpackContents"] = true,
["SmithingTopLevelCreationPanelTraitListList"] = true,
["SmithingTopLevelResearchPanelResearchLineListList"] = true,
-- exc...--
}
Then grab the parents name & see if it is an allowed panel by checking your table:
Lua Code:
-- instead of doing this
--local parent = rowControl:GetParent()
-- and that big if statement
-- you could just do this
local parentName = rowControl:GetParent():GetName()
if tAllowedPanels[parentName] then
-- do whatever --
end
I see the same thing for this below, should probably do the same thing here with rowControl:GetName()
Lua Code:
if (settings.autoMarkAllWeapon == false) then
if ( rowControl:GetName() == 'ZO_CharacterEquipmentSlotsMainHand'
or rowControl:GetName() == 'ZO_CharacterEquipmentSlotsOffHand'
-- lots more rowControl:GetName()
What about this:
Lua Code:
local function UpdatePlayerInventory()
---...code...---
-- It calls:
PLAYER_INVENTORY:UpdateList(1)
If libFilters is handling the filtering why is your code calling UpdateList ?