4 Commits

Author SHA1 Message Date
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 299 additions and 138 deletions

View File

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

View File

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

View File

@ -406,6 +406,7 @@ function MyBank:OnEnable()
end
MyBankFramePortrait:SetTexture("Interface\\Addons\\MyBags\\Skin\\MyBankPortrait")
StaticPopupDialogs["PURCHASE_BANKBAG"] = {
preferredIndex = 3;
text = TEXT(CONFIRM_BUY_BANK_SLOT),
button1 = TEXT(YES),
button2 = TEXT(NO),