187 lines
5.8 KiB
Lua
Executable File
187 lines
5.8 KiB
Lua
Executable File
local _, addon = ...
|
|
local childName = addon['childName']
|
|
local child = addon[childName]
|
|
local zzLDB = LibStub:GetLibrary("zzLDB")
|
|
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
|
|
local db, dbp
|
|
local function bclick(swap)
|
|
if(not InCombatLockdown() and GarrisonLandingPage) then
|
|
if(GarrisonLandingPage:IsShown()) then
|
|
GarrisonLandingPage_Toggle()
|
|
GameMenuFrame:Hide()
|
|
if(not swap) then
|
|
return
|
|
end
|
|
end
|
|
GarrisonLandingPage.garrTypeID = child['gtypes'][child:GetGBM()]
|
|
if(not GarrisonLandingPage.garrTypeID) then
|
|
child:ResetGBM()
|
|
child:findTypes()
|
|
if(not GarrisonLandingPage.garrTypeID) then
|
|
-- print("still no garrType")
|
|
GarrisonLandingPage_Toggle()
|
|
GameMenuFrame:Hide()
|
|
return
|
|
end
|
|
end
|
|
if (C_Garrison.GetGarrisonInfo(GarrisonLandingPage.garrTypeID)) then
|
|
ShowGarrisonLandingPage(child['gtypes'][child:GetGBM()])
|
|
GarrisonLandingPageReportList_OnShow(GarrisonLandingPage)
|
|
C_Garrison.RequestLandingPageShipmentInfo()
|
|
if ( not GarrisonLandingPageReport.selectedTab ) then
|
|
GarrisonLandingPageReport.unselectedTab = GarrisonLandingPageReport.InProgress
|
|
GarrisonLandingPageReport.selectedTab = GarrisonLandingPageReport.Available
|
|
GarrisonLandingPageReport_SetTab(GarrisonLandingPageReport.unselectedTab)
|
|
else
|
|
GarrisonLandingPageReportList_UpdateItems()
|
|
end
|
|
else
|
|
child:ResetGBM()
|
|
end
|
|
end
|
|
end
|
|
local function OnClick(_, button)
|
|
local level = C_Garrison.GetGarrisonInfo(C_Garrison.GetLandingPageGarrisonType())
|
|
if(tonumber(level) and tonumber(level) < 1) then
|
|
child:ResetGBM()
|
|
end
|
|
if(button == "LeftButton") then
|
|
if(IsShiftKeyDown()) then
|
|
child:findTypes()
|
|
local k = 0
|
|
local picknext = nil
|
|
for a, b in pairs(child['gtypes']) do
|
|
local level = C_Garrison.GetGarrisonInfo(b)
|
|
if(level and level > 0) then
|
|
if(picknext) then
|
|
k = a
|
|
break
|
|
end
|
|
if(child:GetGBM() == a) then
|
|
picknext = true
|
|
end
|
|
|
|
end
|
|
end
|
|
if(k == 0) then
|
|
child:ResetGBM()
|
|
else
|
|
child:SetGBM(k)
|
|
end
|
|
bclick(true)
|
|
else
|
|
bclick()
|
|
end
|
|
elseif(button=="RightButton") then
|
|
if(not InCombatLockdown()) then
|
|
if(SettingsPanel) then
|
|
if(SettingsPanel:IsVisible()) then
|
|
HideUIPanel(SettingsPanel)
|
|
HideUIPanel(GameMenuFrame)
|
|
else
|
|
Settings.OpenToCategory(childName)
|
|
end
|
|
elseif(InterfaceOptionsFrame) then
|
|
if(InterfaceOptionsFrame:IsVisible()) then
|
|
InterfaceOptionsFrame:Hide()
|
|
else
|
|
InterfaceOptionsFrame_OpenToCategory(childName)
|
|
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
|
|
end
|
|
end
|
|
end
|
|
else
|
|
ExpansionLandingPageMinimapButton:Click()
|
|
end
|
|
end
|
|
local function tooltipsort(a, b)
|
|
local dbgbm = dbp[child:GetGBM()]
|
|
return (dbgbm[a['missionID']] or 0) < (dbgbm[b['missionID']] or 0)
|
|
end
|
|
local function OnTooltipShow(tip)
|
|
tip:AddLine(childName)
|
|
local GBM = child:GetGBM()
|
|
local num = C_Garrison.GetNumFollowers(GBM)
|
|
if(GBM and dbp[GBM]) then
|
|
local temp = C_Garrison.GetInProgressMissions(GBM)
|
|
local ti = time()
|
|
if(temp) then
|
|
dbp[GBM] = {}
|
|
local dbgbm = dbp[GBM]
|
|
for _, v in pairs(temp) do
|
|
dbgbm[v['missionID']] = v['missionEndTime']
|
|
end
|
|
sort(temp,tooltipsort)
|
|
for _, v in pairs(temp) do
|
|
tip:AddDoubleLine(v['name'], dbgbm[tonumber(v['missionID'])] > ti and v['timeLeft'] or child:colorize(L["Mission done"], "00ff00"))
|
|
num = num - v['numFollowers']
|
|
end
|
|
end
|
|
local pid = child:GetPID()
|
|
for k, v in pairs(db['missions']) do
|
|
if(k ~= pid and v[GBM]) then
|
|
for _, b in pairs(v[GBM]) do
|
|
if(b < ti) then
|
|
tip:AddDoubleLine(k, child:colorize(L["Mission done"], "00ff00"))
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
if(IsShiftKeyDown()) then
|
|
for k, v in pairs(db['missions']) do
|
|
if(v[GBM]) then
|
|
local found = 0
|
|
for _, b in pairs(v[GBM]) do
|
|
if(b >= ti) then
|
|
local r = b - ti
|
|
if(r < found or found == 0) then
|
|
found = r
|
|
end
|
|
end
|
|
end
|
|
if(found > 0) then
|
|
tip:AddDoubleLine(k, child:colorize(L['next'](found), "ffff00"))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
local nr = C_Garrison.GetInProgressMissions(GBM)
|
|
local nr2 = C_Garrison.GetAvailableMissions(GBM)
|
|
if(GBM == 123) then
|
|
if(C_ArdenwealdGardening.IsGardenAccessible()) then
|
|
local data = C_ArdenwealdGardening.GetGardenData()
|
|
if(data and data['ready'] and data['ready'] > 0) then
|
|
tip:AddLine(child:colorize(L['ArdenwealdGardening_attention'](data['ready']), '00ff00'))
|
|
end
|
|
end
|
|
end
|
|
if(num > 0) then
|
|
tip:AddDoubleLine(child:colorize(L["Follower:"], "ffffff"), format("%i/%i",num,C_Garrison.GetNumFollowers(GBM)))
|
|
end
|
|
if(nr and nr2) then
|
|
tip:AddDoubleLine(child:colorize(L["Missions:"], "ffffff"), format("%i/%i", #nr, #nr2))
|
|
end
|
|
else
|
|
tip:AddLine(L["No garrison found!"])
|
|
end
|
|
tip:AddLine(child:colorize(L["SHIFT LEFTCLICK toggles Garrison"], "00ff00"))
|
|
tip:AddLine(child:colorize(L["WHEEL toggles Dragonflight Info"], "00ff00"))
|
|
tip:AddLine(child:colorize(L["Press SHIFT for other characters info"], "00ff00"))
|
|
end
|
|
child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
|
|
['type'] = 'data source', -- required: 'data source' or 'launcher'
|
|
['text'] = GARRISON_LOCATION_TOOLTIP, -- required/optional for launcher
|
|
['icon'] = "Interface\\Icons\\Achievement_Arena_2v2_6", -- optional/required for launcher
|
|
['OnClick'] = OnClick, -- optional/required for launcher
|
|
['OnTooltipShow'] = OnTooltipShow, -- optional
|
|
}
|
|
local init = {
|
|
Setup = function()
|
|
db = child['db']
|
|
dbp = db['missions'][child:GetPID()]
|
|
child.OnText = zzLDB.DefaultOnText
|
|
child:OnText(childName, db['garrisonText'])
|
|
end
|
|
}
|
|
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName) |