|
|
|
@ -0,0 +1,505 @@
|
|
|
|
|
local name, addon = ...
|
|
|
|
|
local parentName = addon['parentName'] or "BrokerPack"
|
|
|
|
|
local childName = "zz_Money"
|
|
|
|
|
local defaults = {
|
|
|
|
|
['sortDir'] = true,
|
|
|
|
|
}
|
|
|
|
|
local options = {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
|
|
|
|
|
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
|
|
|
|
|
local db
|
|
|
|
|
|
|
|
|
|
local texturePath = name == "BrokerPack" and "Interface\\AddOns\\BrokerPack\\zz_Money\\in.tga" or "Interface\\AddOns\\zz_Money\\in.tga"
|
|
|
|
|
local texturePath2 = name == "BrokerPack" and "Interface\\AddOns\\BrokerPack\\zz_Money\\out.tga" or "Interface\\AddOns\\zz_Money\\out.tga"
|
|
|
|
|
|
|
|
|
|
local goldicon,silvericon,coppericon
|
|
|
|
|
local sessionStart,sessionIn,sessionOut = 0,0,0
|
|
|
|
|
local mailframes = {}
|
|
|
|
|
local lastframe
|
|
|
|
|
local mailRec,mailSum
|
|
|
|
|
local realm, faction, player
|
|
|
|
|
local checkDelay = GetTime()
|
|
|
|
|
local connectedRealms
|
|
|
|
|
local posFrame = CreateFrame("Frame")
|
|
|
|
|
posFrame:SetSize(32,1)
|
|
|
|
|
posFrame:SetPoint("TOPRIGHT",SendMailFrame,"TOPRIGHT",-10,-12)
|
|
|
|
|
posFrame:SetScript("OnEvent", function(self, event, ...)
|
|
|
|
|
self:UnregisterEvent('MAIL_FAILED')
|
|
|
|
|
self:UnregisterEvent('MAIL_SEND_SUCCESS')
|
|
|
|
|
if(event == "MAIL_SEND_SUCCESS") then
|
|
|
|
|
if(mailRec and mailSum) then
|
|
|
|
|
db[realm][mailRec]['incoming'] = (db[realm][mailRec]['incoming'] or 0) + mailSum
|
|
|
|
|
addon:Print(L['Success'](mailRec,mailSum))
|
|
|
|
|
mailframes[mailRec]:Hide()
|
|
|
|
|
end
|
|
|
|
|
elseif(event == "MAIL_FAILED") then
|
|
|
|
|
addon:Print(L['Fail'])
|
|
|
|
|
end
|
|
|
|
|
mailRec = nil
|
|
|
|
|
mailSum = nil
|
|
|
|
|
end)
|
|
|
|
|
local Helper_Tooltip_tab
|
|
|
|
|
local function getHTT()
|
|
|
|
|
Helper_Tooltip_tab = Helper_Tooltip_tab or { ['iconSize'] = addon['db']['global']['iconSize'] or 12}
|
|
|
|
|
return Helper_Tooltip_tab
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function Helper_Tooltip3(realm)
|
|
|
|
|
if(not addon['db']['global']['connectedRealms']) then return end
|
|
|
|
|
for k, v in pairs(connectedRealms) do
|
|
|
|
|
if(v == realm) then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local function cdbCheck(n,realm)
|
|
|
|
|
db[realm] = db[realm] or {}
|
|
|
|
|
db[realm][n] = db[realm][n] or { currentGold = 0 }
|
|
|
|
|
end
|
|
|
|
|
local function OnText(message)
|
|
|
|
|
addon:OnText(childName, message)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function OnText2()
|
|
|
|
|
local m = 0
|
|
|
|
|
if(addon['db']['global']['accountMoney']) then
|
|
|
|
|
local sum = 0
|
|
|
|
|
if(addon['db']['sv']['profileKeys']) then
|
|
|
|
|
for k,v in pairs(addon['db']['sv']['profileKeys']) do
|
|
|
|
|
local n,_,m = strsplit(' ',k,3)
|
|
|
|
|
if(n) then
|
|
|
|
|
local cr = Helper_Tooltip3(m)
|
|
|
|
|
if(m == realm or cr) then
|
|
|
|
|
cdbCheck(n,cr and m or realm)
|
|
|
|
|
if( faction == db[cr and m or realm][n]['faction']) then
|
|
|
|
|
sum = sum + db[cr and m or realm][n]['currentGold']
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
m = sum
|
|
|
|
|
else
|
|
|
|
|
m = GetMoney()
|
|
|
|
|
end
|
|
|
|
|
if(addon['db']['global']['shortMoney'] and m>10000)then
|
|
|
|
|
m = addon:round(m / 10000,0) * 10000
|
|
|
|
|
end
|
|
|
|
|
OnText(addon:buildMoneyString(m,false,getHTT(),addon['db']['global']['abrevK'] and L['abrK'] or nil,addon['db']['global']['abrevM'] and L['abrM'] or nil))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function GetFactionList()
|
|
|
|
|
local n,m,_
|
|
|
|
|
local l = {}
|
|
|
|
|
if(addon['db']['sv']['profileKeys']) then
|
|
|
|
|
for k,v in pairs(addon['db']['sv']['profileKeys']) do
|
|
|
|
|
n,_,m = strsplit(' ',k,3)
|
|
|
|
|
if(n) then
|
|
|
|
|
if(m == realm) then
|
|
|
|
|
if(faction == db[realm][n]['faction']) then
|
|
|
|
|
l[n] = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return l
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function getDeliver(name)
|
|
|
|
|
local sendSum,offset
|
|
|
|
|
local lim, mon
|
|
|
|
|
if(db[realm][faction]['banker'] ~= player) then
|
|
|
|
|
lim = db[realm][faction]['maxLimit'] or 100
|
|
|
|
|
mon = GetMoney()
|
|
|
|
|
sendSum = mon - lim*10000 - 30
|
|
|
|
|
offset = 0
|
|
|
|
|
else
|
|
|
|
|
lim = db[realm][faction]['minLimit'] or 100
|
|
|
|
|
mon = db[realm][name]['currentGold']
|
|
|
|
|
sendSum = lim*10000 - mon
|
|
|
|
|
offset = 30
|
|
|
|
|
end
|
|
|
|
|
if(sendSum + offset > GetMoney()) then
|
|
|
|
|
sendSum = GetMoney()
|
|
|
|
|
end
|
|
|
|
|
return sendSum - (db[realm][faction]['banker'] ~= player and 0 or (db[realm][name]['incoming'] or 0))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function Click(self,button)
|
|
|
|
|
local sendSum = getDeliver(self['destName'])
|
|
|
|
|
if(addon:IsTwink(self['destName']) and self['destName']~=player) then
|
|
|
|
|
if(sendSum>0) then
|
|
|
|
|
if(SetSendMailMoney(sendSum)) then
|
|
|
|
|
posFrame:RegisterEvent('MAIL_SEND_SUCCESS')
|
|
|
|
|
posFrame:RegisterEvent('MAIL_FAILED')
|
|
|
|
|
mailRec = self['destName']
|
|
|
|
|
mailSum = sendSum
|
|
|
|
|
SendMail(self['destName'],L['Subject'],nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function Mouse(self)
|
|
|
|
|
local tip = GameTooltip
|
|
|
|
|
tip:SetOwner(self, "ANCHOR_BOTTOM")
|
|
|
|
|
tip:ClearLines()
|
|
|
|
|
self['tooltip'] = tip
|
|
|
|
|
if(db[realm][faction]['banker'] ~= player) then
|
|
|
|
|
tip:AddLine(format("%s %s",L['Bankier'],db[realm][faction]['banker']))
|
|
|
|
|
tip:AddLine(format("%s %s",L['Goldgrenze'],db[realm][faction]['maxLimit']))
|
|
|
|
|
else
|
|
|
|
|
tip:AddLine(format("%s %s",L['Empfaenger'],self['destName']))
|
|
|
|
|
tip:AddLine(format("%s %s",L['Goldgrenze'],db[realm][faction]['minLimit']))
|
|
|
|
|
end
|
|
|
|
|
local sendSum = getDeliver(self['destName'])
|
|
|
|
|
tip:AddLine(format("%s %s",L['Sende'],addon:buildMoneyString(sendSum,false,getHTT())))
|
|
|
|
|
tip:Show()
|
|
|
|
|
end
|
|
|
|
|
local function MouseOut(self)
|
|
|
|
|
self['tooltip']:Hide()
|
|
|
|
|
end
|
|
|
|
|
local function MainFrame(name)
|
|
|
|
|
if(getDeliver(name)<0) then return nil end
|
|
|
|
|
local mailframe = mailframes[name] and mailframes[name] or CreateFrame("Button",nil,SendMailFrame,"ActionButtonTemplate SecureActionButtonTemplate")
|
|
|
|
|
mailframe:SetSize(32,32)
|
|
|
|
|
mailframe:SetPoint("TOPRIGHT",lastframe,"BOTTOMRIGHT",0,-8)
|
|
|
|
|
mailframe:EnableMouse(true)
|
|
|
|
|
mailframe:RegisterForClicks("AnyUp")
|
|
|
|
|
mailframe['destName'] = name
|
|
|
|
|
mailframe:SetScript("OnClick", Click)
|
|
|
|
|
mailframe:SetScript("OnEnter", Mouse)
|
|
|
|
|
mailframe:SetScript("OnLeave", MouseOut)
|
|
|
|
|
if(not mailframe['texture']) then
|
|
|
|
|
mailframe['texture'] = mailframe:CreateTexture(nil,"BACKGROUND")
|
|
|
|
|
mailframe['texture']:SetTexture("Interface\\Icons\\INV_Misc_Bag_10_Blue")
|
|
|
|
|
mailframe['texture']:SetAllPoints(mailframe)
|
|
|
|
|
mailframe['texture']:SetPoint("CENTER",0,0)
|
|
|
|
|
mailframe['texture']:Show()
|
|
|
|
|
end
|
|
|
|
|
return mailframe
|
|
|
|
|
end
|
|
|
|
|
local function buildMailFrames()
|
|
|
|
|
local banker = db[realm][faction]['banker']
|
|
|
|
|
if(mailframes) then
|
|
|
|
|
for k,v in pairs(mailframes) do
|
|
|
|
|
mailframes[k]:Hide()
|
|
|
|
|
mailframes[k] = nil
|
|
|
|
|
end
|
|
|
|
|
mailframes = {}
|
|
|
|
|
end
|
|
|
|
|
if(addon['db']['global']["disableBanker"]) then return end
|
|
|
|
|
posFrame:Show()
|
|
|
|
|
lastframe = posFrame
|
|
|
|
|
|
|
|
|
|
if(player == banker) then
|
|
|
|
|
local fl = GetFactionList()
|
|
|
|
|
if(fl) then
|
|
|
|
|
for k,v in pairs(fl) do
|
|
|
|
|
if(k ~= banker) then
|
|
|
|
|
if(getDeliver(k) > 0 and getDeliver(k) < GetMoney() - 10000) then
|
|
|
|
|
mailframes[k] = MainFrame(k)
|
|
|
|
|
mailframes[k]:Show()
|
|
|
|
|
lastframe = mailframes[k]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if(getDeliver(banker) > 0 and getDeliver(banker) < GetMoney() - 10000) then
|
|
|
|
|
mailframes[banker] = MainFrame(banker)
|
|
|
|
|
mailframes[banker]:Show()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function getDateString()
|
|
|
|
|
return format("%s%s",tostring(date("%Y")),tostring(1000 + date("%j")))
|
|
|
|
|
end
|
|
|
|
|
local function getSumToday(d)
|
|
|
|
|
if(faction=='Neutral') then return 0,0 end
|
|
|
|
|
local sumIn,sumOut = 0,0
|
|
|
|
|
d = d or 0
|
|
|
|
|
local day = getDateString() + d
|
|
|
|
|
for a,b in pairs(db[realm]['activity'][faction][tostring(day)] or {}) do
|
|
|
|
|
if(b < 0) then
|
|
|
|
|
sumOut = sumOut + b
|
|
|
|
|
else
|
|
|
|
|
sumIn = sumIn + b
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return sumOut,sumIn
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function getSumWeek()
|
|
|
|
|
local sumIn, sumOut = 0,0
|
|
|
|
|
local sumWeekIn, sumWeekOut = 0,0
|
|
|
|
|
for a=0,6 do
|
|
|
|
|
sumOut, sumIn = getSumToday(a * -1)
|
|
|
|
|
sumWeekIn = sumWeekIn + sumIn
|
|
|
|
|
sumWeekOut = sumWeekOut + sumOut
|
|
|
|
|
end
|
|
|
|
|
return sumWeekOut,sumWeekIn
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local ttlist = {}
|
|
|
|
|
|
|
|
|
|
local function Helper_Tooltip(str,col,sum,bol)
|
|
|
|
|
return col and addon:colorize(str,col) or str,addon:buildMoneyString(sum,bol,getHTT()),1,1,1,1,1,1
|
|
|
|
|
end
|
|
|
|
|
local function Helper_Tooltip2(tex,str,sum,bol)
|
|
|
|
|
return format("|T%s:0|t%s",tex,str),addon:buildMoneyString(sum,bol,getHTT()),1,1,1,1,1,1
|
|
|
|
|
end
|
|
|
|
|
local function OnClick(self, button)
|
|
|
|
|
if(IsShiftKeyDown() and button == "LeftButton") then
|
|
|
|
|
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
|
|
|
|
|
if(ldbicon) then
|
|
|
|
|
if(addon['db']['global']['ldbicons'][childName]['hide']) then
|
|
|
|
|
ldbicon:Hide(childName)
|
|
|
|
|
else
|
|
|
|
|
ldbicon:Show(childName)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
|
|
|
|
|
InterfaceOptionsFrame:Hide()
|
|
|
|
|
else
|
|
|
|
|
InterfaceOptionsFrame_OpenToCategory(childName)
|
|
|
|
|
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local function OnTooltip(tip)
|
|
|
|
|
tip:AddLine(childName)
|
|
|
|
|
if(faction == 'Neutral') then
|
|
|
|
|
tip:AddLine(L['neutral'])
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip(L['Sitzung'],'ffff00',db[realm][player]['currentGold'] - sessionStart,true))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath,L['Einnahmen'],sessionIn,false))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath2,L['Ausgaben'],sessionOut,false))
|
|
|
|
|
tip:AddLine(' ')
|
|
|
|
|
local sumOut,sumIn = getSumToday()
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip(L['Heute'],'ffff00',sumOut+sumIn,true))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath,L['Einnahmen'],sumIn,false))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath2,L['Ausgaben'],sumOut,false))
|
|
|
|
|
tip:AddLine(' ')
|
|
|
|
|
sumOut,sumIn = getSumToday(-1)
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip(L['Gestern'],'ffff00',sumOut+sumIn,true))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath,L['Einnahmen'],sumIn,false))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath2,L['Ausgaben'],sumOut,false))
|
|
|
|
|
tip:AddLine(' ')
|
|
|
|
|
sumOut,sumIn = getSumWeek()
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip(L['7-Tage'],'ffff00',sumIn+sumOut,true))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath,L['Einnahmen'],sumIn,false))
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip2(texturePath2,L['Ausgaben'],sumOut,false))
|
|
|
|
|
tip:AddLine(' ')
|
|
|
|
|
local sum = 0
|
|
|
|
|
wipe(ttlist)
|
|
|
|
|
if(addon['db']['sv']['profileKeys']) then
|
|
|
|
|
for k,v in pairs(addon['db']['sv']['profileKeys']) do
|
|
|
|
|
local n,_,m = strsplit(' ',k,3)
|
|
|
|
|
if(n) then
|
|
|
|
|
local cr = Helper_Tooltip3(m)
|
|
|
|
|
if(m == realm or cr) then
|
|
|
|
|
cdbCheck(n,cr and m or realm)
|
|
|
|
|
if( faction == db[cr and m or realm][n]['faction']) then
|
|
|
|
|
sum = sum + db[cr and m or realm][n]['currentGold']
|
|
|
|
|
ttlist[k] = db[cr and m or realm][n]['currentGold']
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
for _,v in pairs(addon:sortArray(ttlist,addon['db']['global']['sortDir'])) do
|
|
|
|
|
local n,_,m = strsplit(' ',v,3)
|
|
|
|
|
local cr = Helper_Tooltip3(m)
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip(addon:classcolor(n,db[cr and m or realm][n]['class']),nil,db[cr and m or realm][n]['currentGold']+(db[cr and m or realm][n]['incoming'] or 0) or 0,false))
|
|
|
|
|
end
|
|
|
|
|
tip:AddLine(' ')
|
|
|
|
|
tip:AddDoubleLine(Helper_Tooltip(L['Gesamt'],'ffff00',sum,false))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local oldMoney = 0
|
|
|
|
|
|
|
|
|
|
local function OnDataUpdate()
|
|
|
|
|
if(faction == 'Neutral') then
|
|
|
|
|
faction = UnitFactionGroup('player')
|
|
|
|
|
if(faction == 'Neutral') then
|
|
|
|
|
OnText2()
|
|
|
|
|
C_Timer.After(2, OnDataUpdate)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local m = GetMoney()
|
|
|
|
|
if(m == oldMoney) then return end
|
|
|
|
|
local stamp = time()
|
|
|
|
|
local day = getDateString()
|
|
|
|
|
db[realm][player] = db[realm][player] or { ['currentGold'] = m,['faction'] = faction }
|
|
|
|
|
db[realm][player]['incoming'] = 0
|
|
|
|
|
db[realm]['activity'] = db[realm]['activity'] or { Horde = {}, Alliance={}}
|
|
|
|
|
db[realm][faction] = db[realm][faction] or {}
|
|
|
|
|
db[realm][faction]['banker'] = db[realm][faction]['banker'] or player
|
|
|
|
|
db[realm][faction]['minLimit'] = db[realm][faction]['minLimit'] or 300
|
|
|
|
|
db[realm][faction]['maxLimit'] = db[realm][faction]['maxLimit'] or 300
|
|
|
|
|
if(db[realm][player]['currentGold'] ~= m) then
|
|
|
|
|
db[realm]['activity'][faction][day] = db[realm]['activity'][faction][day] or {}
|
|
|
|
|
while(db[realm]['activity'][faction][day][stamp]) do
|
|
|
|
|
stamp = stamp + 1
|
|
|
|
|
end
|
|
|
|
|
local d = m-db[realm][player]['currentGold']
|
|
|
|
|
if(d < 0) then
|
|
|
|
|
sessionOut = sessionOut + d
|
|
|
|
|
else
|
|
|
|
|
sessionIn = sessionIn + d
|
|
|
|
|
end
|
|
|
|
|
db[realm]['activity'][faction][day][stamp] = d
|
|
|
|
|
db[realm][player]['currentGold'] = m
|
|
|
|
|
end
|
|
|
|
|
OnText2()
|
|
|
|
|
C_Timer.After(2, OnDataUpdate)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function MAIL_SHOW()
|
|
|
|
|
OnDataUpdate()
|
|
|
|
|
buildMailFrames()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function resetSession()
|
|
|
|
|
player = UnitName('player')
|
|
|
|
|
realm = GetRealmName()
|
|
|
|
|
sessionStart = db[realm][player]['currentGold'] or 0
|
|
|
|
|
sessionIn = 0
|
|
|
|
|
sessionOut = 0
|
|
|
|
|
OnDataUpdate()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function cleanUp()
|
|
|
|
|
local ci = 7
|
|
|
|
|
local day = getDateString()
|
|
|
|
|
if(faction == 'Neutral') then return end
|
|
|
|
|
for k,v in pairs(db[realm]['activity'][faction]) do
|
|
|
|
|
if(tonumber(k) < tonumber(day)-ci) then
|
|
|
|
|
db[realm]['activity'][faction][tostring(k)] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function buildSelect()
|
|
|
|
|
local sel = {}
|
|
|
|
|
local n,m,_
|
|
|
|
|
if(addon['db']['sv']['profileKeys']) then
|
|
|
|
|
for k,v in pairs(addon['db']['sv']['profileKeys']) do
|
|
|
|
|
n,_,m = strsplit(' ',k,3)
|
|
|
|
|
if(addon:IsTwink(n)) then
|
|
|
|
|
if(faction == db[realm][n]['faction']) then
|
|
|
|
|
sel[n] = n
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return sel
|
|
|
|
|
end
|
|
|
|
|
local function buildSelectAll()
|
|
|
|
|
local sel = {}
|
|
|
|
|
local n,m,_
|
|
|
|
|
if(addon['db']['sv']['profileKeys']) then
|
|
|
|
|
for k,v in pairs(addon['db']['sv']['profileKeys']) do
|
|
|
|
|
n,_,m = strsplit(' ',k,3)
|
|
|
|
|
sel[format("%s-%s",n,m)] = format("%s-%s",n,m)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return sel
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function getPref2(info)
|
|
|
|
|
return db[realm][faction][info[#info]]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function setPref2(info,value)
|
|
|
|
|
db[realm][faction][info[#info]] = value
|
|
|
|
|
buildMailFrames()
|
|
|
|
|
OnDataUpdate()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function getPref(info)
|
|
|
|
|
return addon['db']['global'][info[#info]]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function setPref(info,value)
|
|
|
|
|
oldMoney = 0
|
|
|
|
|
addon['db']['global'][info[#info]] = value
|
|
|
|
|
Helper_Tooltip_tab = nil
|
|
|
|
|
buildMailFrames()
|
|
|
|
|
OnDataUpdate()
|
|
|
|
|
end
|
|
|
|
|
local function deleteChar()
|
|
|
|
|
if(addon['db']['global']['deleteCharOk']) then
|
|
|
|
|
local charName, charRealm = strsplit('-', addon['db']['global']['deleteChar'],2)
|
|
|
|
|
if(db[charRealm] and db[charRealm][charName]) then
|
|
|
|
|
db[charRealm][charName] = nil
|
|
|
|
|
addon['db']['sv']['profileKeys'][format("%s - %s", charName, charRealm)] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
setPref({'deleteCharOk'}, nil)
|
|
|
|
|
end
|
|
|
|
|
local function init()
|
|
|
|
|
player = UnitName('player')
|
|
|
|
|
realm = GetRealmName()
|
|
|
|
|
faction = UnitFactionGroup('player')
|
|
|
|
|
connectedRealms = GetAutoCompleteRealms()
|
|
|
|
|
options = addon:InitConfig(childName, true, {
|
|
|
|
|
['name'] = childName,
|
|
|
|
|
['type'] = "data source",
|
|
|
|
|
['OnClick'] = OnClick,
|
|
|
|
|
['OnTooltipShow'] = OnTooltip,
|
|
|
|
|
['icon'] ="Interface\\Icons\\INV_Misc_Bag_10_Blue",
|
|
|
|
|
}, getPref, setPref)
|
|
|
|
|
db = addon['db']['profile'][childName]
|
|
|
|
|
db[realm] = db[realm] or {
|
|
|
|
|
['activity'] = { Horde = {}, Alliance={}},
|
|
|
|
|
[faction] = {},
|
|
|
|
|
[player] = { currentGold = 0, ['faction'] = faction },
|
|
|
|
|
['banker'] = player,
|
|
|
|
|
}
|
|
|
|
|
db[realm][faction] = db[realm][faction] or {}
|
|
|
|
|
db[realm][player] = db[realm][player] or { currentGold = 0, ['faction'] = faction }
|
|
|
|
|
db[realm][player]['faction'] = faction
|
|
|
|
|
db[realm][player]['incoming'] = db[realm][player]['incoming'] or 0
|
|
|
|
|
local _, class, _ = UnitClass('player')
|
|
|
|
|
db[realm][player]['class'] = class
|
|
|
|
|
local menu = addon:AddConfigMenu({
|
|
|
|
|
['name'] = L['Bankier'],
|
|
|
|
|
['order'] = 2,
|
|
|
|
|
['menuGet'] = getPref2,
|
|
|
|
|
['menuSet'] = setPref2,
|
|
|
|
|
['disabled'] = function() return addon['db']['global']["disableBanker"] end,
|
|
|
|
|
}, options)
|
|
|
|
|
addon:AddConfigEntry(childName, "range","minLimit",L['Minimum Limit'],L['Desc MinL'],1,10,150000,5,false,menu)
|
|
|
|
|
addon:AddConfigEntry(childName, "range","maxLimit",L['Maximum Limit'],L['Desc MaxL'],2,10,150000,5,false,menu)
|
|
|
|
|
addon:AddConfigEntry(childName, "select","banker",L['Bankier'],nil,3,buildSelect,nil,nil,nil,menu)
|
|
|
|
|
addon:AddConfigEntry(childName, "header","deleteCharHeader",L['DeleteChar'],nil,9,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "select","deleteChar",L['DeleteChar'],L['DeleteCharDesc'],10,buildSelectAll,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","deleteCharOk",L['DeleteCharOk'],nil,11,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "execute","deleteCharExec",L['DeleteChar'],L['DeleteCharDesc'],12,deleteChar,nil,nil,nil,options['args'][childName])
|
|
|
|
|
|
|
|
|
|
addon:AddConfigEntry(childName, "range","iconSize",L['iconSize'],nil,2,5,32,1,false,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","sortDir",L['sortDir'],nil,2,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","connectedRealms",L['connectedRealms'],nil,2,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","disableBanker",L['nobanker'],nil,3,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","accountMoney",L['accountMoney'],L['accountMoneyDesc'],4,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","shortMoney",L['shortMoney'],nil,5,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","abrevK",L['abrevK'],nil,6,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
addon:AddConfigEntry(childName, "toggle","abrevM",L['abrevM'],nil,6,nil,nil,nil,nil,options['args'][childName])
|
|
|
|
|
C_Timer.After(2, OnDataUpdate)
|
|
|
|
|
addon:RegisterFunc({"PLAYER_MONEY"},"OnEvent", OnDataUpdate)
|
|
|
|
|
addon:RegisterFunc({"MAIL_SHOW"},"OnEvent", MAIL_SHOW)
|
|
|
|
|
resetSession()
|
|
|
|
|
cleanUp()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
addon:startup(name, childName, init, true, defaults)
|