Quantcast

-- oUF_Simple: templates/raid
-- zork, 2016

-----------------------------
-- Variables
-----------------------------

local A, L = ...

-----------------------------
-- CreateRaidStyle
-----------------------------

if not L.C.raid or not L.C.raid.enabled then return end

local Hider = CreateFrame("Frame", nil, UIParent)
Hider:Hide()

local function DisableBlizzard()
	if CompactRaidFrameManager then
		-- Disable Blizzard Raid Frames.
		CompactRaidFrameManager:SetParent(Hider)
		CompactRaidFrameManager:UnregisterAllEvents()
		CompactRaidFrameManager:Hide()

		CompactRaidFrameContainer:SetParent(Hider)
		CompactRaidFrameContainer:UnregisterAllEvents()
		CompactRaidFrameContainer:Hide()

		-- Hide Raid Interface Options.
		InterfaceOptionsFrameCategoriesButton10:SetHeight(0.00001)
		InterfaceOptionsFrameCategoriesButton10:SetAlpha(0)
	end
end

function UpdateRaidDebuffIndicator()
	local ORD = L.oUF_RaidDebuffs or oUF_RaidDebuffs

	if (ORD) then
		local _, InstanceType = IsInInstance()

		ORD:ResetDebuffData()

		if (InstanceType == "party" or InstanceType == "raid") then
			ORD:RegisterDebuffs(L.C.debuffs.PvE.spells)
		else
			ORD:RegisterDebuffs(L.C.debuffs.PvP.spells)
		end
	end
end

local function SetupRaidDebuffs()
  local ORD = L.oUF_RaidDebuffs or oUF_RaidDebuffs
  local RaidDebuffs = CreateFrame("Frame")

  RaidDebuffs:RegisterEvent("PLAYER_ENTERING_WORLD")
  RaidDebuffs:SetScript("OnEvent", UpdateRaidDebuffIndicator)

  if (ORD) then
    ORD.ShowDispellableDebuff = L.C.raid.debuffwatch.dispellable
    ORD.FilterDispellableDebuff = L.C.raid.debuffwatch.filterOnly
    ORD.MatchBySpellName = L.C.raid.debuffwatch.matchByName
  end
end

local function CreateRaidStyle(self)
  --disable blizzard
  DisableBlizzard()
  --config
  self.cfg = L.C.raid
  --settings
  self.settings = {}
  self.settings.template = "raid"
  self.settings.setupFrame = false
  self.settings.setupHeader = true
  self.settings.createDrag = false
  --style
  L.F.CreateStyle(self)
  --setup debuffs
  if L.C.raid.debuffwatch and L.C.raid.debuffwatch.enabled then
    SetupRaidDebuffs()
  end
end
L.F.CreateRaidStyle = CreateRaidStyle