9 Commits

Author SHA1 Message Date
9c84784542 line endings again 2014-10-21 18:12:30 +02:00
5775870bcd line endings 2014-10-21 18:11:43 +02:00
00683de69b TOC update 2014-10-21 18:10:14 +02:00
2b8a6af9e2 Core fixes for 6.0.2 2014-10-21 18:07:13 +02:00
232f424a6f Fix for bankslot purchase error 2014-02-13 11:34:24 +01:00
8ccff635a0 Try to avoid StaticPopupDialogs taint 2014-02-12 13:26:56 +01:00
2298e37175 Code cleanup 2014-02-12 13:16:53 +01:00
191ee4dd73 toc cleanup, add some more OptionalDeps 2014-02-12 13:16:08 +01:00
0ab9c6cff0 Fix the glowing newitem bug 2014-02-11 22:40:45 +01:00
3 changed files with 343 additions and 146 deletions

View File

@ -1,9 +1,8 @@
## Interface: 50400 ## Interface: 60200
## Author: Ramble (modified by Isharra) (updated by thegabbert) (converted to Ace3 by Takika) ## Author: Ramble (modified by Isharra) (updated by thegabbert) (converted to Ace3 by Takika)
## Version: 51
## Title: MyBags |cff007FFF -Ace3-|r ## Title: MyBags |cff007FFF -Ace3-|r
## Notes: Complete Replacement for Inventory and Bank Bags. ## Notes: Complete Replacement for Inventory and Bank Bags.
## OptionalDeps: MyBagsCache, DataStore_Containers ## OptionalDeps: MyBagsCache, DataStore, DataStore_Containers, DataStore_Characters
## SavedVariables: MyInventoryDB, MyBankDB, MyEquipmentDB ## SavedVariables: MyInventoryDB, MyBankDB, MyEquipmentDB
Embeds.xml Embeds.xml
@ -14,4 +13,3 @@ MyBagsCore\MyBags.xml
MyInventory\MyInventory.xml MyInventory\MyInventory.xml
MyBank\MyBank.xml MyBank\MyBank.xml
MyEquipment\MyEquipment.xml MyEquipment\MyEquipment.xml

View File

@ -1,5 +1,5 @@
local MBC = "MyBagsCore-1.0" local MBC = "MyBagsCore-1.0"
local MBC_MINOR = "2014.02.10.1" local MBC_MINOR = "2014.10.21.1"
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
@ -31,8 +31,11 @@ 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, unpack = pcall, error, pairs, unpack
local strfind = string.find local strfind, strlen, strsub, strlower, strgmatch, strupper = string.find, string.len, string.sub, string.lower, string.gmatch, string.upper
local strtrim = strtrim
local tinsert, tremove = table.insert, table.remove
local tostring, tonumber, select = tostring, tonumber, select
local mb_options = { local mb_options = {
type = "group", type = "group",
@ -52,7 +55,15 @@ local function ColorConvertHexToDigit(h)
if (strlen(h) ~= 6) then if (strlen(h) ~= 6) then
return 0, 0, 0 return 0, 0, 0
end end
local r = {a=10, b=11, c=12, d=13, e=14, f=15}
local r = {
a = 10,
b = 11,
c = 12,
d = 13,
e = 14,
f = 15
}
return ((tonumber(strsub(h,1,1)) or r[strsub(h,1,1)] or 0) * 16 + (tonumber(strsub(h,2,2)) or r[strsub(h,2,2)] or 0))/255, return ((tonumber(strsub(h,1,1)) or r[strsub(h,1,1)] or 0) * 16 + (tonumber(strsub(h,2,2)) or r[strsub(h,2,2)] or 0))/255,
((tonumber(strsub(h,3,3)) or r[strsub(h,3,3)] or 0) * 16 + (tonumber(strsub(h,4,4)) or r[strsub(h,4,4)] or 0))/255, ((tonumber(strsub(h,3,3)) or r[strsub(h,3,3)] or 0) * 16 + (tonumber(strsub(h,4,4)) or r[strsub(h,4,4)] or 0))/255,
((tonumber(strsub(h,5,5)) or r[strsub(h,5,5)] or 0) * 16 + (tonumber(strsub(h,6,6)) or r[strsub(h,6,6)] or 0))/255 ((tonumber(strsub(h,5,5)) or r[strsub(h,5,5)] or 0) * 16 + (tonumber(strsub(h,6,6)) or r[strsub(h,6,6)] or 0))/255
@ -62,25 +73,10 @@ local function GetItemInfoFromLink(l)
if (not l) then if (not l) then
return return
end end
local c, t, id, il, n = select(3, strfind(l, "|cff(%x+)|H(%l+):(%-?%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, 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
end
return n, c, id .. il, id
]]
end
local function GetBattlePetInfoFromLink(l) local function GetBattlePetInfoFromLink(l)
if (not l) then if (not l) then
@ -96,30 +92,35 @@ local function GetBattlePetInfoFromLink(l)
return tonum(id), tonum(lvl), tonum(rar), tonum(hp), tonum(pw), tonum(sp), n return tonum(id), tonum(lvl), tonum(rar), tonum(hp), tonum(pw), tonum(sp), n
end end
local function IsSpecialtyBag(itype, isubtype) local function IsSpecialtyBag(itype, isubtype)
if (strlower(itype or "") == strlower(L["ACEG_TEXT_AMMO"])) then if (strlower(itype or "") == strlower(L["ACEG_TEXT_AMMO"])) then
return 1 return 1
end end
if (strlower(itype or "") == strlower(L["ACEG_TEXT_QUIVER"])) then if (strlower(itype or "") == strlower(L["ACEG_TEXT_QUIVER"])) then
return 2 return 2
end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_SOUL"])) then if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_SOUL"])) then
return 3 return 3
end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENCHANT"])) then if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENCHANT"])) then
return 4 return 4
end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENGINEER"])) then if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_ENGINEER"])) then
return 5 return 5
end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_HERB"])) then if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_HERB"])) then
return 6 return 6
end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_GEM"])) then if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_GEM"])) then
return 7 return 7
end end
if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_MINING"])) then if (strlower(isubtype or "") == strlower(L["ACEG_TEXT_MINING"])) then
return 8 return 8
end end
@ -127,24 +128,35 @@ end
local function IsSpecialtyBagFromLink(b) local function IsSpecialtyBagFromLink(b)
local i = select(4, GetItemInfoFromLink(b)) local i = select(4, GetItemInfoFromLink(b))
if (not i) then return end if (not i) then
return
end
local c, d = select(6, GetItemInfo(i)) local c, d = select(6, GetItemInfo(i))
return IsSpecialtyBag(c, d) return IsSpecialtyBag(c, d)
end end
local function IsSpecialtyBagFromID(i) local function IsSpecialtyBagFromID(i)
if (not i) then return end if (not i) then
return
end
local c, d = select(6, GetItemInfo(i)) local c, d = select(6, GetItemInfo(i))
return IsSpecialtyBag(c, d) return IsSpecialtyBag(c, d)
end 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 = {}
local word local word
for word in string.gmatch(str, pat or "%S+") do
for word in strgmatch(str, pat or "%S+") do
tinsert(list, word) tinsert(list, word)
end end
return list return list
end end
@ -153,6 +165,7 @@ function MyBagsCore:OnEmbedInitialize(addon)
local prof = addon.db:GetCurrentProfile() local prof = addon.db:GetCurrentProfile()
return addon.db.profiles[prof][var] or false return addon.db.profiles[prof][var] or false
end end
addon.IsSet = function(var) addon.IsSet = function(var)
local prof = addon.db:GetCurrentProfile() local prof = addon.db:GetCurrentProfile()
local t = type(addon.db.profiles[prof][var]) local t = type(addon.db.profiles[prof][var])
@ -163,47 +176,59 @@ function MyBagsCore:OnEmbedInitialize(addon)
return false return false
end end
end end
if t == "boolean" then if t == "boolean" then
return addon.db.profiles[prof][var] return addon.db.profiles[prof][var]
else else
return true return true
end end
end end
addon.SetOpt = function(var,val) addon.SetOpt = function(var,val)
local prof = addon.db:GetCurrentProfile() local prof = addon.db:GetCurrentProfile()
addon.db.profiles[prof][var] = val; addon.db.profiles[prof][var] = val;
end end
addon.TogOpt = function(var) addon.TogOpt = function(var)
local prof = addon.db:GetCurrentProfile() local prof = addon.db:GetCurrentProfile()
if not addon.db.profiles[prof][var] then if not addon.db.profiles[prof][var] then
addon.db.profiles[prof][var] = true addon.db.profiles[prof][var] = true
return true return true
end end
local v_ret = addon.db.profiles[prof][var] local v_ret = addon.db.profiles[prof][var]
local t = type(v_ret) local t = type(v_ret)
if t == "boolean" then if t == "boolean" then
v_ret = not v_ret v_ret = not v_ret
end end
if t == "number" then if t == "number" then
v_ret = 1 - v_ret v_ret = 1 - v_ret
end end
addon.db.profiles[prof][var] = v_ret addon.db.profiles[prof][var] = v_ret
return v_ret return v_ret
end end
addon.Result = function(text, val, map) addon.Result = function(text, val, map)
if val == true then if val == true then
val = 1 val = 1
end end
if( map ) then val = map[val or 0] or val end if (map) then
val = map[val or 0] or val
end
AC:Printf(format(L["ACE_CMD_RESULT"], addon.name, text .. " " .. L["ACEG_TEXT_NOW_SET_TO"] .. " " .. format(L["ACEG_DISPLAY_OPTION"], val or L["ACE_CMD_REPORT_NO_VAL"]))) AC:Printf(format(L["ACE_CMD_RESULT"], addon.name, text .. " " .. L["ACEG_TEXT_NOW_SET_TO"] .. " " .. format(L["ACEG_DISPLAY_OPTION"], val or L["ACE_CMD_REPORT_NO_VAL"])))
end end
addon.TogMsg = function(var,text) addon.TogMsg = function(var,text)
addon.Result(text, addon.TogOpt(var), ACEG_MAP_ONOFF) addon.Result(text, addon.TogOpt(var), ACEG_MAP_ONOFF)
end end
addon.Error = function(...) addon.Error = function(...)
local arg = {...} local arg = {...}
AC:Printf(format(unpack(arg))) AC:Printf(format(unpack(arg)))
end end
addon.frame = _G[addon.frameName] addon.frame = _G[addon.frameName]
addon.frame.self = addon addon.frame.self = addon
local inOptions = false local inOptions = false
@ -213,10 +238,12 @@ function MyBagsCore:OnEmbedInitialize(addon)
inOptions = true inOptions = true
end end
end end
if not inOptions then if not inOptions then
LibStub("AceConfig-3.0"):RegisterOptionsTable("MyBags", mb_options) LibStub("AceConfig-3.0"):RegisterOptionsTable("MyBags", mb_options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MyBags", "MyBags") LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MyBags", "MyBags")
end end
LibStub("AceConfig-3.0"):RegisterOptionsTable(addon.name, addon.options) LibStub("AceConfig-3.0"):RegisterOptionsTable(addon.name, addon.options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addon.name, addon.name, "MyBags") LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addon.name, addon.name, "MyBags")
@ -233,19 +260,22 @@ function MyBagsCore:OnEmbedEnable(addon)
if addon.GetOpt("Scale") then if addon.GetOpt("Scale") then
addon.frame:SetScale(addon.GetOpt("Scale")) addon.frame:SetScale(addon.GetOpt("Scale"))
end end
addon:SetUISpecialFrames() addon:SetUISpecialFrames()
addon:SetFrozen() addon:SetFrozen()
addon:SetLockTexture() addon:SetLockTexture()
local point = addon.GetOpt("Anchor") local point = addon.GetOpt("Anchor")
if point then if point then
addon.frame:ClearAllPoints() addon.frame:ClearAllPoints()
addon.frame:SetPoint(string.upper(point), addon.frame:GetParent():GetName(), string.upper(point), 0, 0) addon.frame:SetPoint(strupper(point), addon.frame:GetParent():GetName(), strupper(point), 0, 0)
end end
if addon:CanSaveItems() then if addon:CanSaveItems() then
addon:LoadDropDown() addon:LoadDropDown()
else else
addon.SetOpt("Player") addon.SetOpt("Player")
end end
addon:ChkCompanion() addon:ChkCompanion()
if addon.GetOpt("Strata") then if addon.GetOpt("Strata") then
addon.frame:SetFrameStrata(addon.GetOpt("Strata")) addon.frame:SetFrameStrata(addon.GetOpt("Strata"))
@ -257,6 +287,7 @@ function MyBagsCore:RegisterEvents(obj)
if (obj) then if (obj) then
self = obj self = obj
end end
self:RegisterEvent("BAG_UPDATE"); self:RegisterEvent("BAG_UPDATE");
self:RegisterEvent("BAG_UPDATE_COOLDOWN", "LayoutFrameOnEvent") self:RegisterEvent("BAG_UPDATE_COOLDOWN", "LayoutFrameOnEvent")
-- self:RegisterEvent("UNIT_INVENTORY_CHANGED", "UNIT_INVENTORY_CHANGED"); -- self:RegisterEvent("UNIT_INVENTORY_CHANGED", "UNIT_INVENTORY_CHANGED");
@ -267,6 +298,7 @@ function MyBagsCore:HookFunctions(obj)
if (obj) then if (obj) then
self = obj self = obj
end end
self:RawHook("ToggleBag", true) self:RawHook("ToggleBag", true)
self:RawHook("OpenBag", true) self:RawHook("OpenBag", true)
self:RawHook("CloseBag", true) self:RawHook("CloseBag", true)
@ -301,11 +333,11 @@ function MyBagsCore:SetUISpecialFrames()
if self.GetOpt("NoEsc") then if self.GetOpt("NoEsc") then
for k, v in pairs(UISpecialFrames) do for k, v in pairs(UISpecialFrames) do
if v == (self.frameName) then if v == (self.frameName) then
table.remove(UISpecialFrames, k) tremove(UISpecialFrames, k)
end end
end end
else else
table.insert(UISpecialFrames, self.frameName) tinsert(UISpecialFrames, self.frameName)
end end
end end
@ -322,7 +354,9 @@ end
function MyBagsCore:SetLockTexture() function MyBagsCore:SetLockTexture()
local button = _G[self.frameName .. "ButtonsLockButtonNormalTexture"] local button = _G[self.frameName .. "ButtonsLockButtonNormalTexture"]
local texture = "Interface\\AddOns\\MyBags\\Skin\\LockButton-" local texture = "Interface\\AddOns\\MyBags\\Skin\\LockButton-"
if not self.GetOpt("Lock") then texture = texture .. "Un" end if not self.GetOpt("Lock") then
texture = texture .. "Un"
end
texture = texture .. "Locked-Up" texture = texture .. "Locked-Up"
button:SetTexture(texture) button:SetTexture(texture)
if self.GetOpt("Lock") and self.GetOpt("Graphics") == "none" then if self.GetOpt("Lock") and self.GetOpt("Graphics") == "none" then
@ -347,9 +381,14 @@ end
function MyBagsCore:IsLive() function MyBagsCore:IsLive()
local isLive = true local isLive = true
local charID = self:GetCurrentPlayer() local charID = self:GetCurrentPlayer()
if charID ~= strtrim(UnitName("player")) .. L["CHARACTER_DELIMITOR"] .. strtrim(GetRealmName()) then isLive = false end if charID ~= strtrim(UnitName("player")) .. L["CHARACTER_DELIMITOR"] .. strtrim(GetRealmName()) then
-- if charID ~= ace.char.id then isLive = false end isLive = false
if self.isBank and not MyBank.atBank then isLive = false end end
if self.isBank and not MyBank.atBank then
isLive = false
end
self.isLive = isLive self.isLive = isLive
return isLive return isLive
end end
@ -358,13 +397,17 @@ function MyBagsCore:GetCurrentPlayer()
if self and self.Player then if self and self.Player then
return self.Player return self.Player
end end
local charName = strtrim(UnitName("player")); local charName = strtrim(UnitName("player"));
local realmName = strtrim(GetRealmName()); local realmName = strtrim(GetRealmName());
return charName .. L["CHARACTER_DELIMITOR"] .. realmName return charName .. L["CHARACTER_DELIMITOR"] .. realmName
end end
function MyBagsCore:TooltipSetOwner(owner, anchor) function MyBagsCore:TooltipSetOwner(owner, anchor)
if not owner then owner = UIParent end if not owner then
owner = UIParent
end
local parent = owner:GetParent() local parent = owner:GetParent()
if parent and (parent == self.frame or parent:GetParent() == self.frame ) then if parent and (parent == self.frame or parent:GetParent() == self.frame ) then
local point = self.GetOpt("Anchor") or "bottomright" local point = self.GetOpt("Anchor") or "bottomright"
@ -376,28 +419,33 @@ function MyBagsCore:TooltipSetOwner(owner, anchor)
else else
anchor = "ANCHOR_PRESERVE" anchor = "ANCHOR_PRESERVE"
end end
GameTooltip:SetOwner(owner, anchor) GameTooltip:SetOwner(owner, anchor)
end end
function MyBagsCore:Open() function MyBagsCore:Open()
if not self.frame:IsVisible() then self.frame:Show() end if not self.frame:IsVisible() then
self.frame:Show()
end
local charName = strtrim(UnitName("player")); local charName = strtrim(UnitName("player"));
local realmName = strtrim(GetRealmName()); local realmName = strtrim(GetRealmName());
-- self.atBank = false
self.Player = charName .. L["CHARACTER_DELIMITOR"] .. realmName self.Player = charName .. L["CHARACTER_DELIMITOR"] .. realmName
if self.Player then if self.Player then
-- self.Player = ace.char.id
local dropDown = _G[self.frameName .. "CharSelectDropDown"] local dropDown = _G[self.frameName .. "CharSelectDropDown"]
if dropDown then if dropDown then
UIDropDownMenu_SetSelectedValue(dropDown, self.Player) UIDropDownMenu_SetSelectedValue(dropDown, self.Player)
end end
end end
self:LayoutFrame() self:LayoutFrame()
end end
function MyBagsCore:Close() function MyBagsCore:Close()
if self.frame:IsVisible() then self.frame:Hide() end if self.frame:IsVisible() then
self.frame:Hide()
end
end end
function MyBagsCore:Toggle() function MyBagsCore:Toggle()
@ -415,6 +463,7 @@ function MyBagsCore:GetHyperlink(ID)
else else
link = select(2, GetItemInfo("item:" .. ID)) link = select(2, GetItemInfo("item:" .. ID))
end end
return link return link
end end
@ -426,14 +475,26 @@ function MyBagsCore:GetTextLink(ID)
end end
function MyBagsCore:BagIDToInvSlotID(bag, isBank) function MyBagsCore:BagIDToInvSlotID(bag, isBank)
if bag == -1 or bag >= 5 and bag <= 11 then isBank = 1 end if bag < 1 or bag > 11 then
if bag < 1 or bag > 11 then return nil; end return nil
if isBank then return BankButtonIDToInvSlotID(bag, 1) end end
if bag == -1 or bag >= 5 and bag <= 11 then
isBank = 1
end
if isBank then
return BankButtonIDToInvSlotID(bag - 4, 1)
end
return ContainerIDToInventoryID(bag) return ContainerIDToInventoryID(bag)
end end
function MyBagsCore:IncludeBag(bag) function MyBagsCore:IncludeBag(bag)
if self.isBank and bag == BANK_CONTAINER then return true end if self.isBank and bag == BANK_CONTAINER then
return true
end
if bag < self.firstBag or bag > (self.firstBag + self.totalBags - 1) then if bag < self.firstBag or bag > (self.firstBag + self.totalBags - 1) then
return false return false
else else
@ -447,9 +508,15 @@ function MyBagsCore:IncludeBag(bag)
end end
function MyBagsCore:IsBagSlotUsable(bag) function MyBagsCore:IsBagSlotUsable(bag)
if not self.isBank then return true end if not self.isBank then
return true
end
local slots, _ = GetNumBankSlots() local slots, _ = GetNumBankSlots()
if (bag+1 - self.firstBag) <= slots then return true end if (bag + 1 - self.firstBag) <= slots then
return true
end
return false return false
end end
@ -476,6 +543,7 @@ function MyBagsCore:SplitString(s, p, n)
if (type(p) ~= "string") then if (type(p) ~= "string") then
p = L["CHARACTER_DELIMITOR"] p = L["CHARACTER_DELIMITOR"]
end end
local l, sp, ep = {}, 0 local l, sp, ep = {}, 0
while (sp) do while (sp) do
sp, ep = strfind(s, p) sp, ep = strfind(s, p)
@ -494,6 +562,7 @@ function MyBagsCore:SplitString(s, p, n)
break break
end end
end end
return unpack(l) return unpack(l)
end end
@ -522,6 +591,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, nil return nil, 0, nil, nil, nil, nil, nil, nil
end end
@ -537,6 +607,7 @@ function MyBagsCore:GetInfoLive(bag, slot)
if itemLink then if itemLink then
name, quality, _, ID, i_type = 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, i_type return texture, count, ID, locked, quality, readable, name or nil, i_type
else else
@ -560,6 +631,7 @@ function MyBagsCore:GetInfoLive(bag, slot)
texture = "Interface\\Buttons\\Button-Backpack-Up" texture = "Interface\\Buttons\\Button-Backpack-Up"
count = 16 count = 16
end end
count = tonum(count) count = tonum(count)
return texture, count, ID, locked, quality, readable, name or nil, "bag" return texture, count, ID, locked, quality, readable, name or nil, "bag"
end end
@ -625,6 +697,7 @@ function MyBagsCore:GetInfoMyBagsCache(bag,slot)
readable = IsSpecialtyBagFromID(ID) readable = IsSpecialtyBagFromID(ID)
end end
end end
count = tonum(count) count = tonum(count)
return texture, count, ID, nil, quality, readable, name, i_type return texture, count, ID, nil, quality, readable, name, i_type
end end
@ -643,9 +716,12 @@ function MyBagsCore:GetSlotCount()
displaySlots = 28 displaySlots = 28
end end
for i = 1, slots do for i = 1, slots do
if (self:GetInfo(BANK_CONTAINER, i)) then used = used + 1 end if (self:GetInfo(BANK_CONTAINER, i)) then
used = used + 1
end end
end end
end
for bagIndex = 0, self.totalBags - 1 do for bagIndex = 0, self.totalBags - 1 do
local bagFrame = _G[self.frameName .. "Bag" .. bagIndex] local bagFrame = _G[self.frameName .. "Bag" .. bagIndex]
if bagFrame and self:IncludeBag(bagFrame:GetID()) then if bagFrame and self:IncludeBag(bagFrame:GetID()) then
@ -656,13 +732,16 @@ function MyBagsCore:GetSlotCount()
slots = slots + bagSlots slots = slots + bagSlots
displaySlots = displaySlots + bagSlots displaySlots = displaySlots + bagSlots
for i = 1, bagSlots do for i = 1, bagSlots do
if self:GetInfo(bagID, i) then used = used + 1 end if self:GetInfo(bagID, i) then
used = used + 1
end
end end
else else
displaySlots = displaySlots + bagSlots displaySlots = displaySlots + bagSlots
end end
end end
end end
return slots, used, displaySlots return slots, used, displaySlots
end end
@ -676,13 +755,18 @@ end
function MyBagsCore:ItemButton_OnLeave(widget) function MyBagsCore:ItemButton_OnLeave(widget)
GameTooltip:Hide() GameTooltip:Hide()
local bagButton = _G[widget:GetParent():GetName() .. "Bag"] local bagButton = _G[widget:GetParent():GetName() .. "Bag"]
if bagButton then bagButton:UnlockHighlight() end if bagButton then
bagButton:UnlockHighlight()
end
CursorUpdate(widget) CursorUpdate(widget)
end end
function MyBagsCore:ItemButton_OnClick(widget, button) function MyBagsCore:ItemButton_OnClick(widget, button)
if self.isLive then if self.isLive then
if widget.hasItem then self.watchLock = 1 end if widget.hasItem then
self.watchLock = 1
end
if self.isBank and widget:GetParent():GetID() == BANK_CONTAINER then if self.isBank and widget:GetParent():GetID() == BANK_CONTAINER then
BankFrameItemButtonGeneric_OnClick(widget, button) BankFrameItemButtonGeneric_OnClick(widget, button)
else else
@ -710,10 +794,14 @@ function MyBagsCore:ItemButton_OnModifiedClick(widget, button)
elseif (IsShiftKeyDown()) then elseif (IsShiftKeyDown()) then
local ID = select(3, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000)) local ID = select(3, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000))
local hyperLink local hyperLink
if ID then hyperLink = self:GetHyperlink(ID) end if ID then
hyperLink = self:GetHyperlink(ID)
end
if hyperLink then if hyperLink then
ChatEdit_InsertLink(hyperLink) ChatEdit_InsertLink(hyperLink)
end end
StackSplitFrame:Hide(); StackSplitFrame:Hide();
end end
end end
@ -723,8 +811,11 @@ end
function MyBagsCore:ItemButton_OnEnter(widget) function MyBagsCore:ItemButton_OnEnter(widget)
if self.GetOpt("HlBags") then if self.GetOpt("HlBags") then
local bagButton = _G[widget:GetParent():GetName() .. "Bag"] local bagButton = _G[widget:GetParent():GetName() .. "Bag"]
if bagButton then bagButton:LockHighlight() end if bagButton then
bagButton:LockHighlight()
end end
end
self:TooltipSetOwner(widget) self:TooltipSetOwner(widget)
if self.isLive then if self.isLive then
if widget:GetParent() == MyBankFrameBank then if widget:GetParent() == MyBankFrameBank then
@ -743,7 +834,6 @@ function MyBagsCore:ItemButton_OnEnter(widget)
end 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))
local i_type = select(8, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000)) local i_type = select(8, self:GetInfo(widget:GetParent():GetID(), widget:GetID() - 1000))
if ID and i_type ~= "battlepet" then if ID and i_type ~= "battlepet" then
@ -751,6 +841,7 @@ function MyBagsCore:ItemButton_OnEnter(widget)
if hyperlink then GameTooltip:SetHyperlink(hyperlink) end if hyperlink then GameTooltip:SetHyperlink(hyperlink) end
end end
end end
if (widget.readable or (IsControlKeyDown() and widget.hasItem)) then if (widget.readable or (IsControlKeyDown() and widget.hasItem)) then
ShowInspectCursor() ShowInspectCursor()
end end
@ -783,7 +874,7 @@ function MyBagsCore:BagButton_OnEnter(widget)
if bagFrame:GetID() == 0 then if bagFrame:GetID() == 0 then
GameTooltip:SetText(BACKPACK_TOOLTIP, 1.0,1.0,1.0) GameTooltip:SetText(BACKPACK_TOOLTIP, 1.0,1.0,1.0)
elseif ID then elseif ID then
hyperlink = self:GetHyperlink(ID) local hyperlink = self:GetHyperlink(ID)
if hyperlink then if hyperlink then
GameTooltip:SetHyperlink(hyperlink) GameTooltip:SetHyperlink(hyperlink)
end end
@ -791,6 +882,7 @@ function MyBagsCore:BagButton_OnEnter(widget)
setTooltip = false setTooltip = false
end end
end end
if not setTooltip then if not setTooltip then
local keyBinding local keyBinding
if self.isBank then if self.isBank then
@ -807,12 +899,14 @@ function MyBagsCore:BagButton_OnEnter(widget)
end end
GameTooltip:Show() GameTooltip:Show()
end end
keyBinding = GetBindingKey("TOGGLEBAG" .. (4 - widget:GetID())) keyBinding = GetBindingKey("TOGGLEBAG" .. (4 - widget:GetID()))
else else
GameTooltip:SetText(BANK_BAG) GameTooltip:SetText(BANK_BAG)
end end
else else
if bagFrame:GetID() == 0 then -- SetScript("OnEnter", MainMenuBarBackpackButton:GetScript("OnEnter")) if bagFrame:GetID() == 0 then
-- SetScript("OnEnter", MainMenuBarBackpackButton:GetScript("OnEnter"))
GameTooltip:SetText(BACKPACK_TOOLTIP, 1.0,1.0,1.0) GameTooltip:SetText(BACKPACK_TOOLTIP, 1.0,1.0,1.0)
keyBinding = GetBindingKey("TOGGLEBACKPACK") keyBinding = GetBindingKey("TOGGLEBACKPACK")
else else
@ -820,7 +914,9 @@ function MyBagsCore:BagButton_OnEnter(widget)
end end
end end
end end
if self.GetOpt("HlItems") then -- Highlight
if self.GetOpt("HlItems") then
-- Highlight
local i local i
for i = 1, self.GetOpt("MAXBAGSLOTS") do for i = 1, self.GetOpt("MAXBAGSLOTS") do
local button = _G[bagFrame:GetName() .. "Item" .. i] local button = _G[bagFrame:GetName() .. "Item" .. i]
@ -837,7 +933,9 @@ function MyBagsCore:BagButton_OnLeave(widget)
local i local i
for i = 1, self.GetOpt("MAXBAGSLOTS") do for i = 1, self.GetOpt("MAXBAGSLOTS") do
local button = _G[widget:GetParent():GetName() .. "Item" .. i] local button = _G[widget:GetParent():GetName() .. "Item" .. i]
if button then button:UnlockHighlight() end if button then
button:UnlockHighlight()
end
end end
end end
@ -847,16 +945,21 @@ function MyBagsCore:BagButton_OnClick(widget, button, ignoreShift)
else else
widget:SetChecked(self:IncludeBag(widget:GetID())) widget:SetChecked(self:IncludeBag(widget:GetID()))
end end
if self.isLive then if self.isLive then
if button == "LeftButton" then if button == "LeftButton" then
if not self:IsBagSlotUsable(widget:GetParent():GetID()) then if not self:IsBagSlotUsable(widget:GetParent():GetID()) then
local cost = GetBankSlotCost() local cost = GetBankSlotCost()
if GetMoney() > cost then if GetMoney() > cost then
if not StaticPopupDialogs["PURCHASE_BANKBAG"] then return end if not StaticPopupDialogs["PURCHASE_BANKBAG"] then
StaticPopup_Show("PURCHASE_BANKBAG")
end
return return
end end
StaticPopup_Show("PURCHASE_BANKBAG")
end
return
end
if (not IsShiftKeyDown()) then if (not IsShiftKeyDown()) then
self:BagButton_OnReceiveDrag(widget) self:BagButton_OnReceiveDrag(widget)
else else
@ -1073,6 +1176,7 @@ function MyBagsCore:UpdateTitle()
title1 = 5 title1 = 5
title2 = 9 title2 = 9
end end
local columns = self.GetOpt("Columns") local columns = self.GetOpt("Columns")
local titleString local titleString
if columns > title2 then if columns > title2 then
@ -1082,9 +1186,10 @@ function MyBagsCore:UpdateTitle()
else else
titleString = L["MYBAGS_TITLE0"] titleString = L["MYBAGS_TITLE0"]
end end
titleString = titleString .. _G[string.upper(self.frameName) .. "_TITLE"]
titleString = titleString .. _G[strupper(self.frameName) .. "_TITLE"]
local title = _G[self.frameName .. "Name"] local title = _G[self.frameName .. "Name"]
local player, realm = self:SplitString(MyBagsCore:GetCurrentPlayer(self), L["CHARACTER_DELIMITOR"]) local player, realm = self:SplitString(self:GetCurrentPlayer(), L["CHARACTER_DELIMITOR"])
title:SetText(format(titleString, player, realm)) title:SetText(format(titleString, player, realm))
end end
@ -1167,8 +1272,9 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
if searchText == SEARCH then if searchText == SEARCH then
searchText = "" searchText = ""
else else
searchText = string.lower(strtrim(searchText)) searchText = strlower(strtrim(searchText))
end end
local slot local slot
local itemBase = bagFrameName .. "Item" local itemBase = bagFrameName .. "Item"
local bagButton = _G[bagFrameName .. "Bag"] local bagButton = _G[bagFrameName .. "Bag"]
@ -1188,21 +1294,27 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
if not texture then if not texture then
local bag_id, texture = GetInventorySlotInfo("Bag0Slot") local bag_id, texture = GetInventorySlotInfo("Bag0Slot")
end end
if not self.isLive or (self.isLive and self:IsBagSlotUsable(bagFrame:GetID())) then if not self.isLive or (self.isLive and self:IsBagSlotUsable(bagFrame:GetID())) then
SetItemButtonTextureVertexColor(bagButton, 1.0, 1.0, 1.0) SetItemButtonTextureVertexColor(bagButton, 1.0, 1.0, 1.0)
SetItemButtonDesaturated(bagButton, locked, 0.5, 0.5, 0.5) SetItemButtonDesaturated(bagButton, locked, 0.5, 0.5, 0.5)
else else
SetItemButtonTextureVertexColor(bagButton, 1.0, 0.1, 0.1) SetItemButtonTextureVertexColor(bagButton, 1.0, 0.1, 0.1)
end end
SetItemButtonTexture(bagButton, texture) SetItemButtonTexture(bagButton, texture)
if self.GetOpt("Bag") == "bar" then if self.GetOpt("Bag") == "bar" then
local col, row = 0, 0 local col, row = 0, 0
if self.GetOpt("Player") or self.GetOpt("Graphics") == "art" then row = 1 end if self.GetOpt("Player") or self.GetOpt("Graphics") == "art" then
row = 1
end
if self.isBank then if self.isBank then
col = (self.GetOpt("Columns") - self.totalBags) / 2 col = (self.GetOpt("Columns") - self.totalBags) / 2
else else
col = (self.GetOpt("Columns") - self.totalBags -.5)/2 col = (self.GetOpt("Columns") - self.totalBags - 0.5) / 2
end end
col = col + bagFrame:GetID() - self.firstBag col = col + bagFrame:GetID() - self.firstBag
bagButton:Show() bagButton:Show()
bagButton:ClearAllPoints() bagButton:ClearAllPoints()
@ -1212,6 +1324,7 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
self.curCol = 0 self.curCol = 0
self.curRow = self.curRow + 1 self.curRow = self.curRow + 1
end end
bagButton:Show() bagButton:Show()
bagButton:ClearAllPoints() bagButton:ClearAllPoints()
bagButton:SetPoint("TOPLEFT", self.frameName, "TOPLEFT", self:GetXY(self.curRow, self.curCol)) bagButton:SetPoint("TOPLEFT", self.frameName, "TOPLEFT", self:GetXY(self.curRow, self.curCol))
@ -1225,6 +1338,7 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
bagButton:SetChecked(1) bagButton:SetChecked(1)
end end
end end
if bagFrame.size < 1 or not self:IncludeBag(bagFrame:GetID()) then if bagFrame.size < 1 or not self:IncludeBag(bagFrame:GetID()) then
bagFrame.size = 0 bagFrame.size = 0
else else
@ -1235,10 +1349,47 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
else else
itemButton:SetID(slot + 1000); itemButton:SetID(slot + 1000);
end end
if self.curCol >= self.GetOpt("Columns") then if self.curCol >= self.GetOpt("Columns") then
self.curCol = 0 self.curCol = 0
self.curRow = self.curRow + 1 self.curRow = self.curRow + 1
end end
local newItemTexture = _G[itemBase .. slot].NewItemTexture
local flash = _G[itemBase .. slot].flashAnim;
local newItemAnim = _G[itemBase .. slot].newitemglowAnim;
local isNewItem = C_NewItems.IsNewItem(bagFrame:GetID(), itemButton:GetID())
local isBattlePayItem = IsBattlePayItem(bagFrame:GetID(), itemButton:GetID())
local battlepayItemTexture = _G[itemBase .. slot].BattlepayItemTexture;
battlepayItemTexture:Hide();
if (isNewItem) then
if (isBattlePayItem) then
newItemTexture:Hide();
battlepayItemTexture:Show();
else
if (quality and NEW_ITEM_ATLAS_BY_QUALITY[quality]) then
newItemTexture:SetAtlas(NEW_ITEM_ATLAS_BY_QUALITY[quality]);
else
newItemTexture:SetAtlas("bags-glow-white");
end
battlepayItemTexture:Hide();
newItemTexture:Show();
end
if (not flash:IsPlaying() and not newItemAnim:IsPlaying()) then
flash:Play();
newItemAnim:Play();
end
else
battlepayItemTexture:Hide();
newItemTexture:Hide();
if (flash:IsPlaying() or newItemAnim:IsPlaying()) then
flash:Stop();
newItemAnim:Stop();
end
end
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))
@ -1249,14 +1400,16 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
itemButton.hasItem = 1 itemButton.hasItem = 1
local fade = 1 local fade = 1
if searchText ~= "" then if searchText ~= "" then
if not string.find(string.lower(name), searchText) then if not strfind(strlower(name), searchText) then
fade = 0.2 fade = 0.2
end end
end end
itemButton:SetAlpha(fade) itemButton:SetAlpha(fade)
else else
quality = nil quality = nil
end end
if self.isLive then if self.isLive then
local start, duration, enable = GetContainerItemCooldown(bagFrame:GetID(), slot) local start, duration, enable = GetContainerItemCooldown(bagFrame:GetID(), slot)
local cooldown = _G[itemButton:GetName() .. "Cooldown"] local cooldown = _G[itemButton:GetName() .. "Cooldown"]
@ -1265,6 +1418,7 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4) SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4)
end end
end end
SetItemButtonTexture(itemButton, (texture or "")) SetItemButtonTexture(itemButton, (texture or ""))
SetItemButtonCount(itemButton, count) SetItemButtonCount(itemButton, count)
SetItemButtonDesaturated(itemButton, locked, 0.5, 0.5, 0.5) SetItemButtonDesaturated(itemButton, locked, 0.5, 0.5, 0.5)
@ -1274,6 +1428,7 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
else else
itemButton:UnlockHighlight() itemButton:UnlockHighlight()
end end
if quality and self.GetOpt("Border") then if quality and self.GetOpt("Border") then
SetItemButtonNormalTextureVertexColor(itemButton, ColorConvertHexToDigit(quality)) SetItemButtonNormalTextureVertexColor(itemButton, ColorConvertHexToDigit(quality))
else else
@ -1296,6 +1451,7 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
end end
end end
end end
if(bagFrame.size) then if(bagFrame.size) then
local slot = bagFrame.size + 1 local slot = bagFrame.size + 1
local itemButton = _G[itemBase .. slot] local itemButton = _G[itemBase .. slot]
@ -1308,7 +1464,10 @@ function MyBagsCore:LayoutBagFrame(bagFrame)
end end
function MyBagsCore:LayoutFrame() function MyBagsCore:LayoutFrame()
if not self.frame:IsVisible() then return end if not self.frame:IsVisible() then
return
end
self.isLive = self:IsLive() self.isLive = self:IsLive()
local bagBase = self.frameName .. "Bag" local bagBase = self.frameName .. "Bag"
local bagIndex, bagFrame, bag local bagIndex, bagFrame, bag
@ -1324,6 +1483,7 @@ function MyBagsCore:LayoutFrame()
self:LayoutBagFrame(bagFrame) self:LayoutBagFrame(bagFrame)
end end
end end
if self.isBank then if self.isBank then
bagFrame = _G[self.frameName .. "Bank"] bagFrame = _G[self.frameName .. "Bank"]
self:LayoutBagFrame(bagFrame) self:LayoutBagFrame(bagFrame)
@ -1333,6 +1493,7 @@ function MyBagsCore:LayoutFrame()
bagFrame = _G[self.frameName .. "Bank"] bagFrame = _G[self.frameName .. "Bank"]
self:LayoutBagFrame(bagFrame) self:LayoutBagFrame(bagFrame)
end end
for bag = 0, self.totalBags - 1 do for bag = 0, self.totalBags - 1 do
bagFrame = _G[bagBase .. bag] bagFrame = _G[bagBase .. bag]
if (bagFrame) then if (bagFrame) then
@ -1341,18 +1502,30 @@ function MyBagsCore:LayoutFrame()
end end
end end
end end
if self.curCol == 0 then self.curRow = self.curRow - 1 end
if self.curCol == 0 then
self.curRow = self.curRow - 1
end
self.frame:SetWidth(self.GetOpt("_LEFTOFFSET") + self.GetOpt("_RIGHTOFFSET") + self.GetOpt("Columns") * MYBAGS_COLWIDTH) self.frame:SetWidth(self.GetOpt("_LEFTOFFSET") + self.GetOpt("_RIGHTOFFSET") + self.GetOpt("Columns") * MYBAGS_COLWIDTH)
self.frame:SetHeight(self.GetOpt("_TOPOFFSET") + self.GetOpt("_BOTTOMOFFSET") + (self.curRow + 1) * MYBAGS_ROWHEIGHT) self.frame:SetHeight(self.GetOpt("_TOPOFFSET") + self.GetOpt("_BOTTOMOFFSET") + (self.curRow + 1) * MYBAGS_ROWHEIGHT)
end end
function MyBagsCore:LayoutFrameOnEvent(event, unit) function MyBagsCore:LayoutFrameOnEvent(event, unit)
if event == "UNIT_INVENTORY_CHANGED" and unit ~= "player" then return end if event == "UNIT_INVENTORY_CHANGED" and unit ~= "player" then
if event == "ITEM_LOCK_CHANGED" and not self.watchLock then return end return
if self.isLive then end
if event == "ITEM_LOCK_CHANGED" and not self.watchLock then
return
end
if event == "BAG_UPDATE_COOLDOWN" then
if unit == "player" and self.isLive then
self:LayoutFrame() self:LayoutFrame()
end end
end end
end
function MyBagsCore:LockButton_OnClick() function MyBagsCore:LockButton_OnClick()
self.TogOpt("Lock") self.TogOpt("Lock")
@ -1383,12 +1556,14 @@ function MyBagsCore:SetGraphicsDisplay(opt)
if opt ~= "default" and opt ~= "art" and opt ~= "none" then if opt ~= "default" and opt ~= "art" and opt ~= "none" then
return return
end end
self.SetOpt("Graphics", opt) self.SetOpt("Graphics", opt)
if a then if a then
self.SetOpt("BackColor", {tonum(a), tonum(r), tonum(g), tonum(b)}) self.SetOpt("BackColor", {tonum(a), tonum(r), tonum(g), tonum(b)})
else else
self.SetOpt("BackColor") self.SetOpt("BackColor")
end end
self.Result("Background", opt) self.Result("Background", opt)
self:LayoutFrame() self:LayoutFrame()
end end
@ -1403,9 +1578,18 @@ end
function MyBagsCore:SetFreeze(opt) function MyBagsCore:SetFreeze(opt)
opt = strlower(opt) opt = strlower(opt)
if opt == "freeze always" then opt = "always" end if opt == "freeze always" then
if opt == "freeze sticky" then opt = "sticky" end opt = "always"
if opt == "freeze none" then opt = "none" end end
if opt == "freeze sticky" then
opt = "sticky"
end
if opt == "freeze none" then
opt = "none"
end
self.Result("Freeze", opt) self.Result("Freeze", opt)
self.SetOpt("Freeze", opt) self.SetOpt("Freeze", opt)
self:SetFrozen() self:SetFrozen()
@ -1467,6 +1651,7 @@ function MyBagsCore:SetPlayerSel()
else else
self.SetOpt("Player") self.SetOpt("Player")
end end
self:LayoutFrame() self:LayoutFrame()
end end
@ -1515,7 +1700,10 @@ function MyBagsCore:ResetSettings()
end end
function MyBagsCore:ResetAnchor() function MyBagsCore:ResetAnchor()
if not self:SetAnchor(self.defaults["Anchor"]) then return end if not self:SetAnchor(self.defaults["Anchor"]) then
return
end
local anchorframe = self.frame:GetParent() local anchorframe = self.frame:GetParent()
anchorframe:ClearAllPoints() anchorframe:ClearAllPoints()
anchorframe:SetPoint(self.anchorPoint, self.anchorParent, self.anchorPoint, self.anchorOffsetX, self.anchorOffsetY) anchorframe:SetPoint(self.anchorPoint, self.anchorParent, self.anchorPoint, self.anchorOffsetX, self.anchorOffsetY)
@ -1533,6 +1721,7 @@ function MyBagsCore:SetAnchor(point)
self.Error("Invalid Entry for Anchor") self.Error("Invalid Entry for Anchor")
return return
end end
local anchorframe = self.frame:GetParent() local anchorframe = self.frame:GetParent()
local top = self.frame:GetTop() local top = self.frame:GetTop()
local left = self.frame:GetLeft() local left = self.frame:GetLeft()
@ -1541,24 +1730,27 @@ function MyBagsCore:SetAnchor(point)
if not top or not left or not left1 or not top1 then if not top or not left or not left1 or not top1 then
self.Error("Frame must be open to set anchor") return self.Error("Frame must be open to set anchor") return
end end
self.frame:ClearAllPoints() self.frame:ClearAllPoints()
anchorframe:ClearAllPoints() anchorframe:ClearAllPoints()
anchorframe:SetPoint(string.upper(point), self.frameName, string.upper(point), 0, 0) anchorframe:SetPoint(strupper(point), self.frameName, strupper(point), 0, 0)
top = anchorframe:GetTop() top = anchorframe:GetTop()
left = anchorframe:GetLeft() left = anchorframe:GetLeft()
if not top or not left then if not top or not left then
anchorframe:ClearAllPoints() anchorframe:ClearAllPoints()
anchorframe:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left1, top1 - 10) anchorframe:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left1, top1 - 10)
point = string.upper(self.GetOpt("Anchor") or "bottomright") point = strupper(self.GetOpt("Anchor") or "bottomright")
self.frame:SetPoint(point, anchorframe:GetName(), point, 0, 0) self.frame:SetPoint(point, anchorframe:GetName(), point, 0, 0)
self.Error("Frame must be open to set anchor") return self.Error("Frame must be open to set anchor")
return
end end
anchorframe:ClearAllPoints() anchorframe:ClearAllPoints()
anchorframe:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left, top - 10) anchorframe:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left, top - 10)
self.frame:SetPoint(string.upper(point), anchorframe:GetName(), string.upper(point), 0, 0) self.frame:SetPoint(strupper(point), anchorframe:GetName(), strupper(point), 0, 0)
self.SetOpt("Anchor", point) self.SetOpt("Anchor", point)
self.Result("Anchor", point) self.Result("Anchor", point)
self.anchorPoint = string.upper(point) self.anchorPoint = strupper(point)
return TRUE return TRUE
end end
@ -1572,6 +1764,7 @@ function MyBagsCore:SetCompanion()
self:UnregisterEvent("TRADE_CLOSED") self:UnregisterEvent("TRADE_CLOSED")
self:UnregisterEvent("TRADE_SHOW") self:UnregisterEvent("TRADE_SHOW")
end end
self.TogMsg("Companion", "Companion") self.TogMsg("Companion", "Companion")
self:ChkCompanion() self:ChkCompanion()
end end
@ -1600,11 +1793,13 @@ function MyBagsCore:BagSearch_OnTextChanged()
if (text == SEARCH) then if (text == SEARCH) then
text = ""; text = "";
end end
if (text ~= "") then if (text ~= "") then
search.clearButton:Show(); search.clearButton:Show();
else else
search.clearButton:Hide(); search.clearButton:Hide();
end end
self:LayoutFrame() self:LayoutFrame()
end end
@ -1617,6 +1812,7 @@ function MyBagsCore:BagSearch_OnEditFocusGained()
if (text == SEARCH) then if (text == SEARCH) then
text = ""; text = "";
end end
search.clearButton:Show(); search.clearButton:Show();
search:SetText(text) search:SetText(text)
self:LayoutFrame() self:LayoutFrame()
@ -1707,6 +1903,7 @@ function MyBagsCore:Embed( target )
for k, v in pairs(mixins) do for k, v in pairs(mixins) do
target[v] = self[v] target[v] = self[v]
end end
self.embeds[target] = true self.embeds[target] = true
return target return target
end end

View File

@ -399,6 +399,7 @@ function MyBank:OnEnable()
MyBankFrameBag4:SetID(9) MyBankFrameBag4:SetID(9)
MyBankFrameBag5:SetID(10) MyBankFrameBag5:SetID(10)
MyBankFrameBag6:SetID(11) MyBankFrameBag6:SetID(11)
if self.GetOpt("Replace") then if self.GetOpt("Replace") then
BankFrame:UnregisterEvent("BANKFRAME_OPENED") BankFrame:UnregisterEvent("BANKFRAME_OPENED")
BankFrame:UnregisterEvent("BANKFRAME_CLOSED") BankFrame:UnregisterEvent("BANKFRAME_CLOSED")
@ -406,18 +407,19 @@ function MyBank:OnEnable()
end end
MyBankFramePortrait:SetTexture("Interface\\Addons\\MyBags\\Skin\\MyBankPortrait") MyBankFramePortrait:SetTexture("Interface\\Addons\\MyBags\\Skin\\MyBankPortrait")
StaticPopupDialogs["PURCHASE_BANKBAG"] = { StaticPopupDialogs["PURCHASE_BANKBAG"] = {
preferredIndex = STATICPOPUPS_NUMDIALOGS,
text = TEXT(CONFIRM_BUY_BANK_SLOT), text = TEXT(CONFIRM_BUY_BANK_SLOT),
button1 = TEXT(YES), button1 = TEXT(YES),
button2 = TEXT(NO), button2 = TEXT(NO),
OnAccept = function() OnAccept = function(self)
if CT_oldPurchaseSlot then if CT_oldPurchaseSlot then
CT_oldPurchaseSlot() CT_oldPurchaseSlot()
else else
PurchaseSlot() PurchaseSlot()
end; end;
end, end,
OnShow = function() OnShow = function(self)
MoneyFrame_Update(this:GetName().."MoneyFrame", GetBankSlotCost()); MoneyFrame_Update(self:GetName() .. "MoneyFrame", GetBankSlotCost());
end, end,
showAlert = 1, showAlert = 1,
hasMoneyFrame = 1, hasMoneyFrame = 1,