Originally Posted by bsrealm
Post it! If you don't have the time to wrap it up as an addon, I can help you with that if you like! I was going to do something like this coz I really want to know the styles of some of the armor I like
|
Sure thing. I don't want to fiddle with maintaining an add-on this small, so I'll just post it here. Keep in mind I just started learning lua and writing add-ons 2 days ago, so this is just me experimenting.
Also, it's from 2 different add on files (a library and a mercantile addon) that I am writing so it may need some tweaking. The globals for the item styles came from esoui globals section, but the higher level armor styles are missing. Basically I have itemStyles 1-10 and 34(Imperial). There should be a ton more that are 11 to 33.
Lastly, I learned how to modify the tooltips by looking at Vicster's Inventory Insight addon.
Let me know how it turns out!
Lua Code:
ToolTipEnhancement = {};
function FM_Initialized(eventCode, addonName)
if (addonName == "FizensMercantile") then
local toolTip = ItemTooltip;
local popupTip = PopupTooltip;
toolTip:SetHandler("OnAddGameData", TooltipShow);
popupTip:SetHandler("OnAddGameData", TooltipShow);
toolTip:SetHandler("OnShow", TooltipShow);
popupTip:SetHandler("OnShow", TooltipShow);
toolTip:SetHandler("OnUpdate", TooltipUpdate);
popupTip:SetHandler("OnUpdate", TooltipUpdate);\
end
end
function TooltipUpdate(control, ...)
if (not control.Modified) then
curLink = nil;
if (control == PopupTooltip) then
curLink = control.lastLink;
elseif (control == ItemTooltip) then
mouseOverControl = moc();
if (mouseOverControl ~= nil and mouseOverControl.dataEntry ~= nil) then
bag = mouseOverControl.dataEntry.data.bagId;
index = mouseOverControl.dataEntry.data.slotIndex;
else
bag = bagId;
index = itemIndex;
end
curLink = GetItemLink(bag, index);
end
icon, sellPrice, meetsUsageRequirement, equipType, itemStyle = GetItemLinkInfo(curLink);
FizensFramework.AddToolTipInformation(control, AddItemToToolTipTable(curLink, FizensFramework.ItemStyle[itemStyle]));
control.Modified = true;
end
end
--Adds additional data items to the table containing tooltip enhancements
function AddItemToToolTipTable(itemLink, stuffToAdd)
if (ToolTipEnhancement[itemLink] == nil) then
table.insert(ToolTipEnhancement, itemLink);
end
ToolTipEnhancement[itemLink] = {};
table.insert(ToolTipEnhancement[itemLink], FizensFramework.SetTextColor(stuffToAdd, "3399FF"));
return ToolTipEnhancement[itemLink];
end
function TooltipShow(control, ...)
control.Modified = false;
end
--Loops through the info table and adds new
--lines to the tooltip control for each entry.
local function AddToolTipInformation(tooltip, info)
if (tooltip ~= nil and info ~= nil and #info > 0) then
tooltip:AddLine();
ZO_Tooltip_AddDivider(tooltip);
for i=1, #info do
tooltip:AddLine(info[i]);
end
end
end
local ItemStyle = {
[-1] = "",
[ITEMSTYLE_NONE] = "None",
[ITEMSTYLE_RACIAL_ARGONIAN] = "Argonian",
[ITEMSTYLE_RACIAL_BRETON] = "Breton",
[ITEMSTYLE_RACIAL_DARK_ELF] = "Dark Elf",
[ITEMSTYLE_RACIAL_HIGH_ELF] = "High Elf",
[ITEMSTYLE_RACIAL_KHAJIIT] = "Khajit",
[ITEMSTYLE_RACIAL_NORD] = "Orc",
[ITEMSTYLE_RACIAL_ORC] = "Redguard",
[ITEMSTYLE_RACIAL_REDGUARD] = "Nord",
[ITEMSTYLE_RACIAL_WOOD_ELF] = "Wood Elf",
[ITEMSTYLE_RACIAL_IMPERIAL] = "Imperial"
}
FizensFramework = {}
FizensFramework.SetTextColor = SetTextColor;
FizensFramework.AddToolTipInformation = AddToolTipInformation;
FizensFramework.ItemStyle = ItemStyle;
EVENT_MANAGER:RegisterForEvent("FizMercantile", EVENT_ADD_ON_LOADED, FM_Initialized)