WoWInterface SVN Ranch

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

trunk/ranch.lua
1,9 → 1,22
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local dataobj = ldb:NewDataObject("Ranch", {type = "data source", text = "Ranch"})
CreateFrame( "GameTooltip", "RanchGameTip" );
RanchGameTip:SetOwner( WorldFrame, "ANCHOR_NONE" );
RanchGameTip:AddFontStrings(
RanchGameTip:CreateFontString( "$parentTextLeft1", nil, "GameTooltipText" ),
RanchGameTip:CreateFontString( "$parentTextRight1", nil, "GameTooltipText" )
);
 
function dataobj:OnTooltipShow()
local i, j
ranch_items = {}
local ranch_items = {}
local ranch_boe = {}
local ranch_cash = 0
local ranch_uncost = false
local ranch_junk = false
if GetSellValue == nil then
ranch_uncost = true
end
for i = 0, 4 do
for j = 1, GetContainerNumSlots(i) do
local ContainerItemLink = GetContainerItemLink(i,j)
18,6 → 31,21
if ranch_items[itemSubType][itemId] == nil then
ranch_items[itemSubType][itemId] = GetItemCount(itemLink)
end
elseif itemRarity == 0 then
ranch_junk = true
if GetSellValue ~= nil then
if GetSellValue(itemLink) == nil then
ranch_uncost = true
else
ranch_cash = ranch_cash + GetSellValue(itemLink)
end
end
elseif itemRarity >=2 then
RanchGameTip:ClearLines();
RanchGameTip:SetBagItem(i,j);
if ((RanchGameTipTextLeft2:GetText() ~= "Soulbound") and (RanchGameTipTextLeft2:GetText() ~= "Quest Item") and RanchGameTipTextLeft2:GetText() ~= "Account Bound") then
ranch_boe[itemLink] = GetSellValue(itemLink)
end
end
end
end
25,6 → 53,14
 
local itemGroup, Collection, itemId, itemCount
self:AddLine("Ranch")
 
self:AddLine(" ")
self:AddLine("Items")
for itemLink, itemCount in pairs(ranch_boe) do
local _, _, _, textcash = Ranch_FormatCash(itemCount)
self:AddDoubleLine(itemLink, textcash)
end
 
for itemGroup, Collection in pairs(ranch_items) do
self:AddLine(" ")
self:AddLine(itemGroup)
33,4 → 69,33
self:AddDoubleLine(itemLink,itemCount)
end
end
end
\ No newline at end of file + + if ranch_junk then + self:AddLine(" ") + local textcash + if ranch_uncost and ranch_cost == 0 then + textcash = "??" + else + _, _, _, textcash = Ranch_FormatCash(ranch_cash) + if ranch_uncost then + textcash = textcash.."+" + end + end + self:AddDoubleLine("Junk:", textcash) + end +end + +function Ranch_FormatCash(cash) + local gold = floor(cash/10000) + local silver = floor((cash-(gold*10000))/100) + local copper = cash - (silver * 100) - (gold * 10000) + local textcash = "" + if gold > 0 then + textcash = "|cFFFFFFFF"..gold.."|r|cffffd700g|r|cFFFFFFFF, |r" + end + if silver > 0 then + textcash = textcash.."|cFFFFFFFF"..silver.."|r|cffc7c7cfs|r|cFFFFFFFF, |r" + end + textcash = textcash.."|cFFFFFFFF"..copper.."|r|cffeda55fc|r" + return gold, silver, copper, textcash +end \ No newline at end of file