106 lines
3.2 KiB
Lua
Executable File
106 lines
3.2 KiB
Lua
Executable File
local addonName, addon = ...
|
|
local childName = addon['childName']
|
|
local child = addon[childName]
|
|
local zzLDB = LibStub:GetLibrary("zzLDB")
|
|
local function OnClick(self, button)
|
|
zzLDB:DefaultOnClick(self, button, addon, childName)
|
|
end
|
|
local function getQuestlist(mapid)
|
|
local mapid = mapid or C_Map.GetBestMapForUnit("player")
|
|
local info = C_Map.GetMapInfo(mapid)
|
|
local numShownEntries, numQuests = C_QuestLog.GetNumQuestLogEntries()
|
|
local header = ""
|
|
local mapName = info['name']
|
|
local idlist = {}
|
|
for i = 1, numShownEntries do
|
|
local info = C_QuestLog.GetInfo(i)
|
|
if(info) then
|
|
if(not info['isHeader']) then
|
|
if(header == mapName) then
|
|
idlist[#idlist + 1] = info['questID']
|
|
-- print(info['title'], header, info['isOnMap'])
|
|
end
|
|
else
|
|
header = info['title']
|
|
end
|
|
end
|
|
end
|
|
return idlist
|
|
end
|
|
local function getMapID()
|
|
local mapid = C_Map.GetBestMapForUnit("player")
|
|
local quests = getQuestlist(mapid)
|
|
if(#quests>0) then
|
|
return mapid
|
|
end
|
|
local info = C_Map.GetMapInfo(mapid)
|
|
if(info) then
|
|
while(info['mapType'] == 6 and type(info['parentMapID']) == 'number') do
|
|
mapid = info['parentMapID']
|
|
info = C_Map.GetMapInfo(mapid)
|
|
end
|
|
while(info['mapType'] == 4) do
|
|
local quests = C_QuestLog.GetQuestsOnMap(mapid)
|
|
if(#quests > 0) then
|
|
break
|
|
else
|
|
if(type(info['parentMapID']) == 'number') then
|
|
mapid = info['parentMapID']
|
|
info = C_Map.GetMapInfo(mapid)
|
|
else
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return mapid or C_Map.GetBestMapForUnit("player")
|
|
end
|
|
local function OnTooltipShow(tip)
|
|
local mapid = getMapID()
|
|
local info = C_Map.GetMapInfo(mapid)
|
|
if(info) then
|
|
if(info['name']) then
|
|
tip:AddLine(child:colorize(info['name'], 'ffff00'))
|
|
end
|
|
else
|
|
tip:AddLine(childName)
|
|
end
|
|
-- local quests = C_QuestLog.GetQuestsOnMap(mapid)
|
|
local quests = getQuestlist(mapid)
|
|
local header = {}
|
|
for num, questID in ipairs(quests) do
|
|
local objectives = C_QuestLog.GetQuestObjectives(questID)
|
|
if(#objectives>0) then
|
|
for num, objective in ipairs(objectives) do
|
|
if(not objective['finished']) then
|
|
if(not header[questID]) then
|
|
header[questID] = true
|
|
if(C_QuestLog.GetTitleForQuestID) then
|
|
tip:AddLine(C_QuestLog.GetTitleForQuestID(questID))
|
|
else
|
|
tip:AddLine(C_QuestLog.GetQuestInfo(questID))
|
|
end
|
|
end
|
|
tip:AddLine(child:colorize(format(" %s", objective['text']),'ffffff'))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
|
|
['type'] = 'data source', -- required: 'data source' or 'launcher'
|
|
['text'] = childName, -- required/optional for launcher
|
|
['icon'] = 'Interface\\Icons\\INV_Misc_Bag_10_Blue', -- optional/required for launcher
|
|
['OnClick'] = OnClick, -- optional/required for launcher
|
|
['OnTooltipShow'] = OnTooltipShow, -- optional
|
|
}
|
|
local init = {
|
|
Setup = function(self, childName, event)
|
|
-- print("setup ldb", childName, event)
|
|
if(child['ldb']['type'] == 'data source') then
|
|
child.OnText = zzLDB.DefaultOnText
|
|
end
|
|
|
|
end
|
|
}
|
|
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName) |