vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local locals = KC_ITEMS_LOCALS.modules.sellvalue
2  
3 KC_SellValue = KC_ItemsModule:new({
4 type = "sellvalue",
5 name = locals.name,
6 desc = locals.description,
7 cmdOptions = locals.chat,
8 dependencies = {"common"},
9 optPath = {"sellvalue", "options"},
10 })
11  
12 KC_Items:Register(KC_SellValue)
13  
14 function KC_SellValue:Enable()
15 self:RegisterEvent("MERCHANT_SHOW", "MerchantOpen")
16 if (self.app.tooltip) then
17 self.app.tooltip:RegisterFunc(self, "Tooltip")
18 end
19 end
20  
21 function KC_SellValue:Disable()
22 KC_ItemsModule.Disable(self)
23 if (self.app.tooltip) then
24 self.app.tooltip:UnregisterFunc(self, "Tooltip")
25 end
26 end
27  
28 function KC_SellValue:MerchantOpen()
29 self:GetSellPrices();
30 self:GetBuyPrices();
31 end
32  
33 function KC_SellValue:GetSellPrices()
34 self:Hook("SetTooltipMoney")
35 self._itemPrice = nil
36  
37 for bag = 0, 4 do
38 for slot = 1, GetContainerNumSlots(bag) do
39 GameTooltip:SetBagItem(bag, slot)
40 if(self._itemPrice) then
41 local _, qty = GetContainerItemInfo(bag, slot)
42 self.common:SetItemPrices(GetContainerItemLink(bag, slot), self._itemPrice/qty, nil)
43 self._itemPrice = nil
44 end
45 end
46 end
47 self:Unhook("SetTooltipMoney")
48 end
49  
50 function KC_SellValue:SetTooltipMoney(obj, money)
51 self._itemPrice = money
52 self:CallHook("SetTooltipMoney", obj, money)
53 end
54  
55 function KC_SellValue:GetBuyPrices()
56 for item = 1, GetMerchantNumItems() do
57 local name, texture, price, qty, numAvailable, isUsable = GetMerchantItemInfo(item);
58 self.common:SetItemPrices(GetMerchantItemLink(item), nil, price/qty);
59 end
60 end
61  
62 function KC_SellValue:Tooltip(tooltip, code, lcode, qty, hooker)
63 local sell, buy = self.common:GetItemPrices(code)
64  
65 local short = self:GetOpt(self.optPath, "short")
66 local single = self:GetOpt(self.optPath, "single")
67  
68 local sLabel = format(short and locals.labels.sell.short or locals.labels.sell.long, qty, single and qty > 1)
69 local bLabel = format(short and locals.labels.buy.short or locals.labels.buy.long, qty, single and qty > 1)
70  
71 _ = (sell and sell > 0) and hooker:AddPriceLine(tooltip, sell * qty, sLabel, locals.sep, locals.sepcolor);
72 _ = (buy and buy > 0) and hooker:AddPriceLine(tooltip, buy * qty, bLabel, locals.sep, locals.sepcolor);
73 end