Originally Posted by sezz
I see, sounds like something that should be in the UI by default but ToggleEncounterJournal() doesn't work in combat anymore or did you find a way around it?
|
Yeah, I do it like this now:
Code:
hooksecurefunc(WorldMapFrame, "SetMapID",
function(self, mapID)
-- During combat, the OnClick functions of the dungeon/boss pins do not manage
-- to bring up EncounterJournal and hide WorldMapFrame.
if WorldMapFrame.ScrollContainer.Child then
local kids = { WorldMapFrame.ScrollContainer.Child:GetChildren() };
for _, v in ipairs(kids) do
if v.pinTemplate and (v.pinTemplate == "EncounterJournalPinTemplate" or v.pinTemplate == "DungeonEntrancePinTemplate") then
local OriginalOnClick = v.OnClick
v.OnClick = function(...)
if InCombatLockdown() then
if not EncounterJournal:IsShown() then
EncounterJournal:Show()
end
-- WorldMapFrame:Hide() will lead to ToggleGameMenu() not working any more
-- because WorldMapFrame will still be listed in UIParent's FramePositionDelegate.
-- So we only hide it, if WorldMapFrame is not in UIPanelWindows (e.g. Mapster).
if WorldMapFrame:IsShown() and not UIPanelWindows["WorldMapFrame"] then
WorldMapFrame:Hide()
end
end
OriginalOnClick(...)
end
end
end
end
end
)
local startupFrame = CreateFrame("Frame")
startupFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
startupFrame:SetScript("OnEvent", function()
-- Needed for the boss pins to work in combat lockdown.
if not IsAddOnLoaded("Blizzard_EncounterJournal") then
EncounterJournal_LoadUI()
end
-- Got to call this once to bring the frames into the right position.
-- Otherwise it will be misplaced when Show() is the first called function.
ShowUIPanel(EncounterJournal)
HideUIPanel(EncounterJournal)
ShowUIPanel(WorldMapFrame)
HideUIPanel(WorldMapFrame)
-- Otherwise closing with ESC may not work during combat.
tinsert(UISpecialFrames, "EncounterJournal")
tinsert(UISpecialFrames, "WorldMapFrame")
end)