- Clear some leaked globals

- CS fixes
This commit is contained in:
2016-09-22 17:39:49 +02:00
parent 35023a61c1
commit 0cb3708671

View File

@ -43,6 +43,24 @@ local MB_Core = LibStub("MyBagsCore-1.1")
local L = LibStub("AceLocale-3.0"):GetLocale("MyBags")
-- Lua APIs
local pairs = pairs
local strtrim = strtrim
-- WoW APIs
local _G = _G
local CloseBackpack = CloseBackpack
local IsBagOpen = IsBagOpen
local MoneyFrame_Update = MoneyFrame_Update
local OpenBackpack = OpenBackpack
local PlaySound = PlaySound
local SetPortraitTexture = SetPortraitTexture
local SortBankBags = SortBankBags
local ToggleBackpack = ToggleBackpack
--Global variables that we don't cache, list them here for the mikk's Find Globals script
-- GLOBALS:
function MyBank:OnInitialize()
self.name = "MyBank"
self.frameName = "MyBankFrame"
@ -56,12 +74,13 @@ function MyBank:OnInitialize()
self.anchorParent = "UIParent"
self.anchorOffsetX = 5
self.anchorOffsetY = 100
self.db = LibStub("AceDB-3.0"):New("MyBankDB");
self.db = LibStub("AceDB-3.0"):New("MyBankDB")
local prof = self.db:GetCurrentProfile()
if self.db.profiles[prof] and self.db.profiles[prof]["Columns"] and self.db.profiles[prof]["Columns"] > 0 then
else
self.db.profiles[prof] = self.defaults
end
self:RegisterChatCommand("mb", "MB_ChatCommand")
self:RegisterChatCommand("mybank", "MB_ChatCommand")
self.options = {
@ -401,7 +420,7 @@ function MyBank:OnInitialize()
end
function MyBank:OnEnable()
-- MyBagsCore:Enable(self);
-- MyBagsCore:Enable(self)
MyBankFrameBank.maxIndex = 28
MyBankFrameBank:SetID(BANK_CONTAINER)
MyBankFrameBag0:SetID(5)
@ -443,9 +462,10 @@ function MyBank:OnEnable()
end
function MyBank:MB_ChatCommand(input)
if not input or input:trim() == "" then
if not input or strtrim(input) == "" then
MB_Dialog:Open(self.name)
else
input = strtrim(input)
MB_Cmd.HandleCommand(MyBank, "mybank", self.name, input)
end
end
@ -459,7 +479,10 @@ end
function MyBank:LoadDropDown()
local dropDown = _G[self.frameName .. "CharSelectDropDown"]
local dropDownButton = _G[self.frameName .. "CharSelectDropDownButton"]
if not dropDown then return end
if not dropDown then
return
end
local last_this = _G["this"]
_G["this"] = dropDownButton
UIDropDownMenu_Initialize(dropDown, self.UserDropDown_Initialize)
@ -472,11 +495,12 @@ function MyBank:UserDropDown_Initialize()
local this = self or _G.this
local chars, char_num
chars = MyBank:GetSortedCharList(MyBank.GetOpt("Sort"))
char_num = getn(chars)
char_num = #chars
if (char_num == 0) then
MyBank.GetOpt("Player")
-- MyBank.GetOpt("Player")
return
end
local frame = this:GetParent():GetParent()
local selectedValue = UIDropDownMenu_GetSelectedValue(this)
@ -488,7 +512,10 @@ function MyBank:UserDropDown_Initialize()
["owner"] = frame.self,
["checked"] = nil,
}
if selectedValue == info.value then info.checked = 1 end
if selectedValue == info.value then
info.checked = 1
end
UIDropDownMenu_AddButton(info)
end
end
@ -526,6 +553,7 @@ function MyBank:ToggleAllBags(forceopen)
else
ToggleBackpack()
end
local action
if (IsBagOpen(0) or MyInventory.frame:IsVisible()) then
action = "OpenBag"
@ -547,15 +575,15 @@ function MyBank:ToggleAllBags(forceopen)
end
function MyBank:CloseAllBags()
local i
MyInventory:Close()
CloseBackpack() -- just in case backpack is not contolled by MyInventory
for i=1, 4, 1 do
for i = 1, 4, 1 do
if not MyInventory.GetOpt("Replace") or not MyInventory:IncludeBag(i) then
self.hooks.CloseBag(i)
end
end
for i=5, 11, 1 do
for i = 5, 11, 1 do
if not MyBank.GetOpt("Replace") or not MyBank:IncludeBag(i) then
self.hooks.CloseBag(i)
end
@ -577,6 +605,7 @@ function MyBank:BANKFRAME_OPENED()
else
self.holdOpen = false
end
if self.GetOpt("Replace") then
self:Open()
else
@ -593,8 +622,11 @@ function MyBank:BANKFRAME_CLOSED()
end -- calling self:close() would trigger the bank closing twice
else
self.holdOpen = false
if self.isLive then self:LayoutFrame() end
if self.isLive then
self:LayoutFrame()
end
end
self:UnregisterEvents()
end
@ -602,6 +634,7 @@ function MyBank:GetInfoFunc()
if self.isLive then
return self.GetInfoLive
end
if IsAddOnLoaded("DataStore_Containers") then
return self.GetInfoDataStore
end
@ -610,6 +643,8 @@ function MyBank:GetInfoFunc()
end
function MyBank:GetSortedCharList(sorttype, realm)
local result = {}
if IsAddOnLoaded("DataStore_Containers") then
local realmlist = {}
local realmcount = 0
@ -622,7 +657,7 @@ function MyBank:GetSortedCharList(sorttype, realm)
realmcount = 1
realmlist[1] = realm
end
local result = {}
local idx = 0
for i = 1, realmcount do
for charname, charkey in pairs(DataStore:GetCharacters(realmlist[i])) do
@ -633,36 +668,40 @@ function MyBank:GetSortedCharList(sorttype, realm)
end
end
end
local swapped
local q, w
local x_time, y_time;
local x_time, y_time
local charName, realmName
repeat
swapped = 0
for i = 1, idx-1 do
for i = 1, idx - 1 do
q = result[i]
w = result[i+1]
w = result[i + 1]
charName, realmName = self:SplitString(q)
if (not DataStore:GetModuleLastUpdate(DataStore_Containers, charName, realmName)) then
x_time = 0
else
x_time = DataStore:GetModuleLastUpdate(DataStore_Containers, charName, realmName)
end
charName, realmName = self:SplitString(w)
if (not DataStore:GetModuleLastUpdate(DataStore_Containers, charName, realmName)) then
y_time = 0
else
y_time = DataStore:GetModuleLastUpdate(DataStore_Containers, charName, realmName)
end
if self:SortChars(q, w, x_time, y_time, sorttype) then
result[i] = w
result[i+1] = q
result[i + 1] = q
swapped = 1
end
end
until swapped == 0
return result
end
return result
end
function MyBank:SetReplace()