annotate Modules/Tooltip.lua @ 35:aaa716c93fb2 v0.1.1

Added the ability to change the price of an item. You can click the Total Invested or the Invested Each to change the value.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sun, 18 Jul 2010 16:43:03 -0700
parents d21d202f3b3d
children 003de902ae64
rev   line source
Asa@3 1 local addonName, addonTable = ...;
Asa@3 2 local addon = _G[addonName]
Asa@3 3
Asa@3 4 local utils = addonTable.utils
Asa@3 5
Asa@3 6 local function ShowTipWithPricing(tip, link, num)
Asa@3 7 if (link == nil) then
Asa@3 8 return;
Asa@3 9 end
Asa@3 10
Asa@8 11 -- local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, _, _, _, _, itemVendorPrice = GetItemInfo (link);
Asa@3 12 -- local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(link, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
Asa@3 13
Asa@8 14 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
Asa@3 15
Asa@13 16 local keep = 1 - addon:GetAHCut()
Asa@12 17 local show = false
Asa@3 18
Asa@3 19 if investedTotal > 0 then
Asa@34 20 local suggestColor
Asa@34 21 local ap = addon:GetAuctionPrice(link)
Asa@34 22 if ap == nil then
Asa@34 23 suggestColor = nil
Asa@34 24 elseif ap > ceil(investedPerItem/keep) then
Asa@34 25 suggestColor = "|cFF00FF00" -- green
Asa@34 26 else
Asa@34 27 suggestColor = "|cFFFF0000" -- red
Asa@34 28 end
Asa@34 29
Asa@34 30
Asa@15 31 tip:AddDoubleLine("\124cffffffffIA: Total Invested", addon:FormatMoney(investedTotal));
Asa@17 32 tip:AddDoubleLine("\124cffffffffIA: Invested per Item (own: " .. count .. ")", addon:FormatMoney(ceil(investedPerItem)));
Asa@34 33 tip:AddDoubleLine("\124cffffffffIA: Minimum " .. addon:GetAHFaction() .. " AH Price: ", addon:FormatMoney(ceil(investedPerItem/keep), suggestColor))
Asa@12 34 show = true
Asa@12 35
Asa@12 36 end
Asa@13 37
Asa@13 38 if addon:IsQAEnabled() then
Asa@13 39 local groupName = QAAPI:GetItemGroup(link)
Asa@13 40 if groupName then
Asa@13 41 local threshold = QAAPI:GetGroupThreshold(groupName)
Asa@15 42 tip:AddDoubleLine("\124cffffffffIA: QA Threshold: ", addon:FormatMoney(threshold))
Asa@13 43 show = true
Asa@13 44 end
Asa@12 45 end
Asa@12 46
Asa@12 47 if show then
Asa@3 48 tip:Show()
Asa@3 49 end
Asa@3 50 end
Asa@3 51
Asa@3 52 hooksecurefunc (GameTooltip, "SetBagItem",
Asa@3 53 function(tip, bag, slot)
Asa@3 54 local _, num = GetContainerItemInfo(bag, slot);
Asa@3 55 ShowTipWithPricing (tip, GetContainerItemLink(bag, slot), num);
Asa@3 56 end
Asa@3 57 );
Asa@3 58
Asa@3 59 hooksecurefunc (GameTooltip, "SetAuctionItem",
Asa@3 60 function (tip, type, index)
Asa@3 61 ShowTipWithPricing (tip, GetAuctionItemLink(type, index));
Asa@3 62 end
Asa@3 63 );
Asa@3 64
Asa@3 65 hooksecurefunc (GameTooltip, "SetAuctionSellItem",
Asa@3 66 function (tip)
Asa@3 67 local name, _, count = GetAuctionSellItemInfo();
Asa@3 68 local __, link = GetItemInfo(name);
Asa@3 69 ShowTipWithPricing (tip, link, num);
Asa@3 70 end
Asa@3 71 );
Asa@3 72
Asa@3 73
Asa@3 74 hooksecurefunc (GameTooltip, "SetLootItem",
Asa@3 75 function (tip, slot)
Asa@3 76 if LootSlotIsItem(slot) then
Asa@3 77 local link, _, num = GetLootSlotLink(slot);
Asa@3 78 ShowTipWithPricing (tip, link, num);
Asa@3 79 end
Asa@3 80 end
Asa@3 81 );
Asa@3 82
Asa@3 83 hooksecurefunc (GameTooltip, "SetLootRollItem",
Asa@3 84 function (tip, slot)
Asa@3 85 local _, _, num = GetLootRollItemInfo(slot);
Asa@3 86 ShowTipWithPricing (tip, GetLootRollItemLink(slot), num);
Asa@3 87 end
Asa@3 88 );
Asa@3 89
Asa@3 90
Asa@3 91 hooksecurefunc (GameTooltip, "SetInventoryItem",
Asa@3 92 function (tip, unit, slot)
Asa@3 93 ShowTipWithPricing (tip, GetInventoryItemLink(unit, slot), GetInventoryItemCount(unit, slot));
Asa@3 94 end
Asa@3 95 );
Asa@3 96
Asa@3 97 hooksecurefunc (GameTooltip, "SetGuildBankItem",
Asa@3 98 function (tip, tab, slot)
Asa@3 99 local _, num = GetGuildBankItemInfo(tab, slot);
Asa@3 100 ShowTipWithPricing (tip, GetGuildBankItemLink(tab, slot), num);
Asa@3 101 end
Asa@3 102 );
Asa@3 103
Asa@3 104 hooksecurefunc (GameTooltip, "SetTradeSkillItem",
Asa@3 105 function (tip, skill, id)
Asa@3 106 local link = GetTradeSkillItemLink(skill);
Asa@3 107 local num = GetTradeSkillNumMade(skill);
Asa@3 108 if id then
Asa@3 109 link = GetTradeSkillReagentItemLink(skill, id);
Asa@3 110 num = select (3, GetTradeSkillReagentInfo(skill, id));
Asa@3 111 end
Asa@3 112
Asa@3 113 ShowTipWithPricing (tip, link, num);
Asa@3 114 end
Asa@3 115 );
Asa@3 116
Asa@3 117 hooksecurefunc (GameTooltip, "SetTradePlayerItem",
Asa@3 118 function (tip, id)
Asa@3 119 local _, _, num = GetTradePlayerItemInfo(id);
Asa@3 120 ShowTipWithPricing (tip, GetTradePlayerItemLink(id), num);
Asa@3 121 end
Asa@3 122 );
Asa@3 123
Asa@3 124 hooksecurefunc (GameTooltip, "SetTradeTargetItem",
Asa@3 125 function (tip, id)
Asa@3 126 local _, _, num = GetTradeTargetItemInfo(id);
Asa@3 127 ShowTipWithPricing (tip, GetTradeTargetItemLink(id), num);
Asa@3 128 end
Asa@3 129 );
Asa@3 130
Asa@3 131 hooksecurefunc (GameTooltip, "SetQuestItem",
Asa@3 132 function (tip, type, index)
Asa@3 133 local _, _, num = GetQuestItemInfo(type, index);
Asa@3 134 ShowTipWithPricing (tip, GetQuestItemLink(type, index), num);
Asa@3 135 end
Asa@3 136 );
Asa@3 137
Asa@3 138 hooksecurefunc (GameTooltip, "SetQuestLogItem",
Asa@3 139 function (tip, type, index)
Asa@3 140 local num, _;
Asa@3 141 if type == "choice" then
Asa@3 142 _, _, num = GetQuestLogChoiceInfo(index);
Asa@3 143 else
Asa@3 144 _, _, num = GetQuestLogRewardInfo(index)
Asa@3 145 end
Asa@3 146
Asa@3 147 ShowTipWithPricing (tip, GetQuestLogItemLink(type, index), num);
Asa@3 148 end
Asa@3 149 );
Asa@3 150
Asa@3 151 hooksecurefunc (GameTooltip, "SetInboxItem",
Asa@3 152 function (tip, index, attachIndex)
Asa@3 153 local _, _, num = GetInboxItem(index, attachIndex);
Asa@3 154 ShowTipWithPricing (tip, GetInboxItemLink(index, attachIndex), num);
Asa@3 155 end
Asa@3 156 );
Asa@3 157
Asa@3 158 hooksecurefunc (GameTooltip, "SetSendMailItem",
Asa@3 159 function (tip, id)
Asa@3 160 local name, _, num = GetSendMailItem(id)
Asa@3 161 local name, link = GetItemInfo(name);
Asa@3 162 ShowTipWithPricing (tip, link, num);
Asa@3 163 end
Asa@3 164 );
Asa@3 165
Asa@3 166 hooksecurefunc (GameTooltip, "SetHyperlink",
Asa@3 167 function (tip, itemstring, num)
Asa@3 168 local name, link = GetItemInfo (itemstring);
Asa@3 169 ShowTipWithPricing (tip, link, num);
Asa@3 170 end
Asa@3 171 );
Asa@3 172
Asa@3 173 hooksecurefunc (ItemRefTooltip, "SetHyperlink",
Asa@3 174 function (tip, itemstring)
Asa@3 175 local name, link = GetItemInfo (itemstring);
Asa@3 176 ShowTipWithPricing (tip, link);
Asa@3 177 end
Asa@3 178 );