View Single Post
12-10-12, 12:26 AM   #1
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
WorldMapFrame Tainting (Not Green Maps)

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:
  1. -- Local definitions
  2. local hooksecurefunc = hooksecurefunc -- I don't know if this acctually helps, I just want to be cool =[
  3. local mapScale = 0.60 -- Map scale for easy modification
  4.  
  5. -- Nevcariel's function for fixing the scale of dropdown menus parented to the WorldMapFrame.
  6. local function dropdownScaleFix(self)
  7.     ToggleDropDownMenu(nil, nil, self:GetParent())
  8.     DropDownList1:SetScale(mapScale)
  9. end
  10.  
  11. local function onShow()
  12.     WorldMapFrame:SetScale(mapScale)
  13. end
  14.  
  15. local function sizeDown()
  16.     WorldMap_ToggleSizeUp()
  17. end
  18.  
  19. local function sizeUp()
  20.     WorldMapFrame:SetAttribute("UIPanelLayout-area", "center")
  21.     BlackoutWorld:Hide()
  22.     WorldMapFrame:EnableKeyboard(false)
  23.     WorldMapFrame:EnableMouse(false)
  24. end
  25.  
  26. local function modifyMap()
  27.     if eventHandler then eventHandler:UnregisterEvent("PLAYER_REGEN_ENABLED") end
  28.    
  29.     WorldMap_ToggleSizeUp()
  30.    
  31.     UIPanelWindows["WorldMapFrame"] = {area = "center", pushable = 9}
  32.     hooksecurefunc(WorldMapFrame, "Show", onShow)
  33.     hooksecurefunc("WorldMap_ToggleSizeDown", sizeDown)
  34.     hooksecurefunc("WorldMap_ToggleSizeUp", sizeUp)
  35.     WorldMapContinentDropDownButton:SetScript("OnClick", dropdownScaleFix)
  36.     WorldMapZoneDropDownButton:SetScript("OnClick", dropdownScaleFix)
  37. end
  38.  
  39. -- Perhaps a workaround to players opening the map in combat?  Who knows.
  40. do
  41.     if not InCombatLockdown() then
  42.         modifyMap()
  43.     else
  44.         local eventHandler = CreateFrame("Frame")
  45.         eventHandler:SetScript("OnEvent", modifyMap)
  46.         eventHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
  47.     end
  48. end

Also, the
Lua Code:
  1. local eventHandler = CreateFrame("Frame")
  2. 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!
  Reply With Quote