5 Commits

Author SHA1 Message Date
0ab9c6cff0 Fix the glowing newitem bug 2014-02-11 22:40:45 +01:00
9ae32b36d1 Remove some unused code, line endings 2014-02-10 23:47:06 +01:00
3a0eef76dc Fix for battlepet cages 2014-02-10 23:45:47 +01:00
6c519840ca Change line endings, codingstyle 2014-02-10 17:52:05 +01:00
0501487428 Forgot to remove SVN revisions 2014-02-10 17:46:21 +01:00
2 changed files with 104 additions and 36 deletions

View File

@ -11,7 +11,10 @@ local function GetItemInfoFromLink(l)
if (not l) then if (not l) then
return return
end end
local c, id, il, n = select(3, strfind(l, "|cff(%x+)|Hitem:(%-?%d+)([^|]+)|h%[(.-)%]|h|r"))
local c, t, id, il, n = select(3, strfind(l, "|cff(%x+)|H(%l+):(%-?%d+)([^|]+)|h%[(.-)%]|h|r"))
-- return n, c, id .. il, id, t
return n, c, id .. il, id return n, c, id .. il, id
end end

View File

@ -1,5 +1,5 @@
local MBC = "MyBagsCore-1.0" local MBC = "MyBagsCore-1.0"
local MBC_MINOR = tonumber(("$Rev$"):match("(%d+)")) local MBC_MINOR = "2014.02.11.3"
if not LibStub then error(MBC .. " requires LibStub.") end if not LibStub then error(MBC .. " requires LibStub.") end
local MyBagsCore = LibStub:NewLibrary(MBC, MBC_MINOR) local MyBagsCore = LibStub:NewLibrary(MBC, MBC_MINOR)
if not MyBagsCore then return end if not MyBagsCore then return end
@ -32,6 +32,7 @@ local ACEG_MAP_ONOFF = {[0]="|cffff5050Off|r",[1]="|cff00ff00On|r"}
local L = LibStub("AceLocale-3.0"):GetLocale("MyBags") local L = LibStub("AceLocale-3.0"):GetLocale("MyBags")
local pcall, error, pairs = pcall, error, pairs local pcall, error, pairs = pcall, error, pairs
local strfind = string.find
local mb_options = { local mb_options = {
type = "group", type = "group",
@ -39,6 +40,14 @@ local mb_options = {
}, },
} }
local function tostr(str)
return tostring(str or "")
end
local function tonum(val)
return tonumber(val or 0)
end
local function ColorConvertHexToDigit(h) local function ColorConvertHexToDigit(h)
if (strlen(h) ~= 6) then if (strlen(h) ~= 6) then
return 0, 0, 0 return 0, 0, 0
@ -50,20 +59,70 @@ local function ColorConvertHexToDigit(h)
end end
local function GetItemInfoFromLink(l) local function GetItemInfoFromLink(l)
if (not l) then return end if (not l) then
local _, _, c, id ,il, n=strfind(l, "|cff(%x+)|Hitem:(%-?%d+)([^|]+)|h%[(.-)%]|h|r") return
end
local c, t, id, il, n = select(3, strfind(l, "|cff(%x+)|H(%l+):(%-?%d+)([^|]+)|h%[(.-)%]|h|r"))
return n, c, id .. il, id, t
--[[
print("c: " .. c .. ", t: " .. t .. ", id: " .. id .. ", il: " .. il .. ", n: " .. n)
if (strfind(l, "Hitem")) then
c, id ,il, n = select(3, strfind(l, "|cff(%x+)|Hitem:(%-?%d+)([^|]+)|h%[(.-)%]|h|r"))
t = "item"
else
if (strfind(l, "Hbattlepet")) then
c, id ,il, n = select(3, strfind(l, "|cff(%x+)|Hbattlepet:(%-?%d+)([^|]+)|h%[(.-)%]|h|r"))
t = "battlepet"
end
end
return n, c, id .. il, id return n, c, id .. il, id
]]
end end
local function GetBattlePetInfoFromLink(l)
if (not l) then
return
end
local c, id, lvl, num, hp, pw, sp, u, n
if (strfind(l, "Hbattlepet")) then
-- "|cff0070dd|Hbattlepet:1178:1:3:152:13:10:0x0000000000000000|h[Sunreaver Micro-Sentry]|h|r"
c, id, lvl, rar, hp, pw, sp, u, n = select(3, strfind(l, "|cff(%x+)|Hbattlepet:(%-?%d+):(%d+):(%d+):(%d+):(%d+):(%d+):([^|]+)|h%[(.-)%]|h|r"))
end
return tonum(id), tonum(lvl), tonum(rar), tonum(hp), tonum(pw), tonum(sp), n
end
local function IsSpecialtyBag(itype, isubtype) local function IsSpecialtyBag(itype, isubtype)
if (strlower(itype or "") == strlower(L["ACEG_TEXT_AMMO"])) then return 1 end if (strlower(itype or "") == strlower(L["ACEG_TEXT_AMMO"])) then
if (strlower(itype or "") == strlower(L["ACEG_TEXT_QUIVER"])) then return 2 end return 1
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_SOUL"])) then return 3 end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENCHANT"])) then return 4 end if (strlower(itype or "") == strlower(L["ACEG_TEXT_QUIVER"])) then
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENGINEER"])) then return 5 end return 2
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_HERB"])) then return 6 end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_GEM"])) then return 7 end if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_SOUL"])) then
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_MINING"])) then return 8 end return 3
end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENCHANT"])) then
return 4
end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENGINEER"])) then
return 5
end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_HERB"])) then
return 6
end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_GEM"])) then
return 7
end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_MINING"])) then
return 8
end
end end
local function IsSpecialtyBagFromLink(b) local function IsSpecialtyBagFromLink(b)
@ -79,14 +138,6 @@ local function IsSpecialtyBagFromID(i)
return IsSpecialtyBag(c, d) return IsSpecialtyBag(c, d)
end end
local function tostr(str)
return tostring(str or "")
end
local function tonum(val)
return tonumber(val or 0)
end
local function ParseWords(str, pat) local function ParseWords(str, pat)
if (tostr(str) == "") then return {} end if (tostr(str) == "") then return {} end
local list = {} local list = {}
@ -471,7 +522,7 @@ function MyBagsCore:GetInfo(bag, slot)
if infofunc then if infofunc then
return infofunc(self, bag, slot) return infofunc(self, bag, slot)
end end
return nil, 0, nil, nil, nil, nil, nil return nil, 0, nil, nil, nil, nil, nil, nil
end end
function MyBagsCore:GetInfoLive(bag, slot) function MyBagsCore:GetInfoLive(bag, slot)
@ -482,12 +533,12 @@ function MyBagsCore:GetInfoLive(bag, slot)
-- it's an item -- it's an item
local texture, count, locked, _ , readable = GetContainerItemInfo(bag, slot) local texture, count, locked, _ , readable = GetContainerItemInfo(bag, slot)
local itemLink = GetContainerItemLink(bag, slot) local itemLink = GetContainerItemLink(bag, slot)
local name, quality, _, ID local name, quality, _, ID, i_type
if itemLink then if itemLink then
name, quality, _, ID = GetItemInfoFromLink(itemLink) name, quality, _, ID, i_type = GetItemInfoFromLink(itemLink)
end end
count = tonum(count) count = tonum(count)
return texture, count, ID, locked, quality, readable, name or nil return texture, count, ID, locked, quality, readable, name or nil, i_type
else else
-- it's a bag -- it's a bag
local count = GetContainerNumSlots(bag) local count = GetContainerNumSlots(bag)
@ -510,7 +561,7 @@ function MyBagsCore:GetInfoLive(bag, slot)
count = 16 count = 16
end end
count = tonum(count) count = tonum(count)
return texture, count, ID, locked, quality, readable, name or nil return texture, count, ID, locked, quality, readable, name or nil, "bag"
end end
end end
@ -547,39 +598,39 @@ function MyBagsCore:GetInfoDataStore(bag, slot)
return texture, count, ID, nil, quality, readable, name return texture, count, ID, nil, quality, readable, name
else else
local ID, slotLink, count = DS:GetSlotInfo(container, slot) local ID, slotLink, count = DS:GetSlotInfo(container, slot)
local name, itemLink, texture, quality local name, itemLink, texture, quality, i_type
if ID then if ID then
name, itemLink = GetItemInfo(ID) name, itemLink = GetItemInfo(ID)
texture = GetItemIcon(ID) texture = GetItemIcon(ID)
if itemLink then if itemLink then
quality = select(3, strfind(itemLink, "|cff(%x+)|.*|h|r")) quality, i_type = select(3, strfind(itemLink, "|cff(%x+)|H(%l+):.*|h|r"))
end end
end end
if slotLink then if slotLink then
ID = slotLink ID = slotLink
end end
return texture, count, ID, nil, quality, readable, name return texture, count, ID, nil, quality, readable, name, i_type
end end
end end
end end
function MyBagsCore:GetInfoMyBagsCache(bag,slot) function MyBagsCore:GetInfoMyBagsCache(bag,slot)
local charID = self:GetCurrentPlayer() local charID = self:GetCurrentPlayer()
local texture, count, ID, locked, quality, readable, name local texture, count, ID, locked, quality, readable, name, i_type
if self.isEquipment then if self.isEquipment then
texture, count, ID, quality, name = MyBagsCache:GetInfo("equipment", bag, charID) texture, count, ID, quality, name, i_type = MyBagsCache:GetInfo("equipment", bag, charID)
else else
texture, count, ID, quality, name = MyBagsCache:GetInfo(bag, slot, charID) texture, count, ID, quality, name, i_type = MyBagsCache:GetInfo(bag, slot, charID)
if not slot and ID then if not slot and ID then
readable = IsSpecialtyBagFromID(ID) readable = IsSpecialtyBagFromID(ID)
end end
end end
count = tonum(count) count = tonum(count)
return texture, count, ID, nil, quality, readable, name return texture, count, ID, nil, quality, readable, name, i_type
end end
function MyBagsCore:GetInfoNone(bag, slot) function MyBagsCore:GetInfoNone(bag, slot)
return nil, 0, nil, nil, nil, nil, nil return nil, 0, nil, nil, nil, nil, nil, nil
end end
function MyBagsCore:GetSlotCount() function MyBagsCore:GetSlotCount()
@ -679,11 +730,23 @@ function MyBagsCore:ItemButton_OnEnter(widget)
if widget:GetParent() == MyBankFrameBank then if widget:GetParent() == MyBankFrameBank then
GameTooltip:SetInventoryItem("player", BankButtonIDToInvSlotID(widget:GetID())) GameTooltip:SetInventoryItem("player", BankButtonIDToInvSlotID(widget:GetID()))
else else
local hasCooldown, repairCost, speciesID, level, breedQuality, maxHealth, power, speed, name = GameTooltip:SetBagItem(widget:GetParent():GetID(), widget:GetID())
if (speciesID and speciesID > 0) then
local link = GetContainerItemLink(widget:GetParent():GetID(), widget:GetID())
local id, lvl, rar, hp, pw, sp, n = GetBattlePetInfoFromLink(link)
BattlePetToolTip_Show(id, lvl, rar, hp, pw, sp, n)
else
if (BattlePetTooltip) then
BattlePetTooltip:Hide()
end
ContainerFrameItemButton_OnEnter(widget) ContainerFrameItemButton_OnEnter(widget)
end end
end
else else
-- print("self.isLive = false");
local ID = select(3, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000)) local ID = select(3, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000))
if ID then local i_type = select(8, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000))
if ID and i_type ~= "battlepet" then
local hyperlink = self:GetHyperlink(ID) local hyperlink = self:GetHyperlink(ID)
if hyperlink then GameTooltip:SetHyperlink(hyperlink) end if hyperlink then GameTooltip:SetHyperlink(hyperlink) end
end end
@ -1176,6 +1239,8 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
self.curCol = 0 self.curCol = 0
self.curRow = self.curRow + 1 self.curRow = self.curRow + 1
end end
local newItemTexture = _G[itemBase .. slot .. "NewItemTexture"]
newItemTexture:Hide()
itemButton:Show() itemButton:Show()
itemButton:ClearAllPoints() itemButton:ClearAllPoints()
itemButton:SetPoint("TOPLEFT", self.frame:GetName(), "TOPLEFT", self:GetXY(self.curRow, self.curCol)) itemButton:SetPoint("TOPLEFT", self.frame:GetName(), "TOPLEFT", self:GetXY(self.curRow, self.curCol))