/Tukui/modules/addonskins/combat_toggle.lua

http://github.com/Asphyxia/Tukui · Lua · 61 lines · 54 code · 2 blank · 5 comment · 27 complexity · ef0042e08bc0f3b0021e0f7c61e706d8 MD5 · raw file

  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. if C.Addon_Skins.background then
  3. -- Addons Background (same size as right chat background)
  4. local bg = CreateFrame("Frame", "AddonBGPanel", UIParent)
  5. bg:CreatePanel("Default", TukuiChatBackgroundRight:GetWidth(), TukuiChatBackgroundRight:GetHeight(), "BOTTOMRIGHT", TukuiChatBackgroundRight, "BOTTOMRIGHT", 0, 0)
  6. bg:SetFrameStrata("MEDIUM")
  7. -- toggle in-/outfight (NOTE: This will only toggle ChatFrameX (chat config))
  8. bg:RegisterEvent("PLAYER_ENTERING_WORLD")
  9. bg:RegisterEvent("PLAYER_LOGIN")
  10. if C.Addon_Skins.combat_toggle then
  11. bg:RegisterEvent("PLAYER_REGEN_ENABLED")
  12. bg:RegisterEvent("PLAYER_REGEN_DISABLED")
  13. end
  14. bg:SetScript("OnEvent", function(self, event)
  15. if C.chat.rightchatbackground or C.Addon_Skins.combat_toggle then
  16. if event == "PLAYER_LOGIN" then
  17. -- Hide
  18. bg:Hide()
  19. if IsAddOnLoaded("Recount") then Recount_MainWindow:Hide() end
  20. if IsAddOnLoaded("Omen") then OmenAnchor:Hide() end
  21. if IsAddOnLoaded("Skada") then Skada:SetActive(false) end
  22. if IsAddOnLoaded("TinyDPS") then tdpsFrame:Hide() end
  23. if ChatBG2 then ChatBG2:Show() end
  24. _G["ChatFrame"..C.chat.rightchatnumber]:Show()
  25. _G["ChatFrame"..C.chat.rightchatnumber.."Tab"]:Show()
  26. elseif event == "PLAYER_ENTERING_WORLD" then
  27. -- yeah set all chats for ChatFrameX again cause we lose them after /rl when chat is hidden ..dunno how to prevent this atm
  28. -- ChatFrame_RemoveAllMessageGroups(_G["ChatFrame"..C.chat.rightchatnumber])
  29. ChatFrame_AddChannel(_G["ChatFrame"..C.chat.rightchatnumber], L.chat_trade)
  30. ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "COMBAT_XP_GAIN")
  31. ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "COMBAT_HONOR_GAIN")
  32. ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "COMBAT_FACTION_CHANGE")
  33. ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "LOOT")
  34. ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "MONEY")
  35. ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "SKILL")
  36. end
  37. end
  38. if C.Addon_Skins.combat_toggle then
  39. if event == "PLAYER_REGEN_ENABLED" then
  40. self:Hide()
  41. if ChatBG2 then ChatBG2:Show() end
  42. _G["ChatFrame"..C.chat.rightchatnumber]:Show()
  43. _G["ChatFrame"..C.chat.rightchatnumber.."Tab"]:Show()
  44. if IsAddOnLoaded("Recount") then Recount_MainWindow:Hide() end
  45. if IsAddOnLoaded("Omen") then OmenAnchor:Hide() end
  46. if IsAddOnLoaded("Skada") then Skada:SetActive(false) end
  47. if IsAddOnLoaded("TinyDPS") then tdpsFrame:Hide() end
  48. elseif event == "PLAYER_REGEN_DISABLED" then
  49. self:Show()
  50. if ChatBG2 then ChatBG2:Hide() end
  51. _G["ChatFrame"..C.chat.rightchatnumber]:Hide()
  52. _G["ChatFrame"..C.chat.rightchatnumber.."Tab"]:Hide()
  53. if IsAddOnLoaded("Recount") then Recount_MainWindow:Show() end
  54. if IsAddOnLoaded("Omen") then OmenAnchor:Show() end
  55. if IsAddOnLoaded("Skada") then Skada:SetActive(true) end
  56. end
  57. end
  58. end)
  59. end