Good evening everyone,
I have been working on a lightweight AddOn to perform some fairly simple modifications to the WorldMapFrame. I am running into issues with the WorldMapFrame tainting when it is opened in combat. I attempted to code my AddOn in such a way that the map won't be touched until combat is dropped, but it is still tainting. Would you guys look over my code and give me some advice?
Lua Code:
-- Local definitions
local hooksecurefunc = hooksecurefunc -- I don't know if this acctually helps, I just want to be cool =[
local mapScale = 0.60 -- Map scale for easy modification
-- Nevcariel's function for fixing the scale of dropdown menus parented to the WorldMapFrame.
local function dropdownScaleFix(self)
ToggleDropDownMenu(nil, nil, self:GetParent())
DropDownList1:SetScale(mapScale)
end
local function onShow()
WorldMapFrame:SetScale(mapScale)
end
local function sizeDown()
WorldMap_ToggleSizeUp()
end
local function sizeUp()
WorldMapFrame:SetAttribute("UIPanelLayout-area", "center")
BlackoutWorld:Hide()
WorldMapFrame:EnableKeyboard(false)
WorldMapFrame:EnableMouse(false)
end
local function modifyMap()
if eventHandler then eventHandler:UnregisterEvent("PLAYER_REGEN_ENABLED") end
WorldMap_ToggleSizeUp()
UIPanelWindows["WorldMapFrame"] = {area = "center", pushable = 9}
hooksecurefunc(WorldMapFrame, "Show", onShow)
hooksecurefunc("WorldMap_ToggleSizeDown", sizeDown)
hooksecurefunc("WorldMap_ToggleSizeUp", sizeUp)
WorldMapContinentDropDownButton:SetScript("OnClick", dropdownScaleFix)
WorldMapZoneDropDownButton:SetScript("OnClick", dropdownScaleFix)
end
-- Perhaps a workaround to players opening the map in combat? Who knows.
do
if not InCombatLockdown() then
modifyMap()
else
local eventHandler = CreateFrame("Frame")
eventHandler:SetScript("OnEvent", modifyMap)
eventHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
end
end
Also, the
Lua Code:
local eventHandler = CreateFrame("Frame")
eventHandler:SetScript("OnEvent", modifyMap)
block of code only works when I create the frame and set the script outside of the ELSE condition in the IF statement. I can't conditionally create the frame?
I am generally at a loss of what to do. The map acts so quirky, and I feel like some of the code is pretty hacked up. Any advice would be most appreciated, as usual.
Thanks so much!