Quantcast
--[[
##############################################################################
_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_       #
 ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__      #
  __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____     #
   ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____    #
    ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____   #
     _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____  #
      __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ #
       _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_#
        ___\///////////___________\///___________\/////////_____\///////////_#
##############################################################################
S U P E R - V I L L A I N - U I   By: Munglunch                              #
##############################################################################
--]]
local SuperVillain, L = unpack(select(2, ...));
local MOD = SuperVillain.Registry:Expose('SVUnit');
local _, ns = ...
local oUF_SuperVillain = ns.oUF
--[[ MUNGLUNCH's FASTER ASSERT FUNCTION ]]--
local assert = enforce;
assert(oUF_SuperVillain, "SVUI was unable to locate oUF.")
local ceil,tinsert = math.ceil,table.insert
--[[
##########################################################
BUILD FUNCTION
##########################################################
]]--
function MOD.Construct:focus()
	MOD:SetActionPanel(self, "focus")

	self.Health = MOD:CreateHealthBar(self, true, true)
	self.Health.frequentUpdates = true

	self.HealPrediction = MOD:CreateHealPrediction(self, true)
	self.Power = MOD:CreatePowerBar(self, true)

	self.Castbar = MOD:CreateCastbar(self, false, L["Focus Castbar"])
	self.Castbar.SafeZone = nil

	self.Castbar.LatencyTexture:Hide()
	self.Buffs = MOD:CreateBuffs(self, "focus")
	self.Debuffs = MOD:CreateDebuffs(self, "focus")
	self.AuraBars = MOD:CreateAuraBarHeader(self, "focus")
	tinsert(self.__elements, MOD.SmartAuraDisplay)
	self:RegisterEvent("PLAYER_FOCUS_CHANGED", MOD.SmartAuraDisplay)

	self.RaidIcon = MOD:CreateRaidIcon(self)
	self.Range = { insideAlpha = 1, outsideAlpha = 1 }
	self.XRay = MOD:CreateXRay_Closer(self)
	self.XRay:SetPoint("BOTTOMRIGHT", 20, -10)
	self:Point("BOTTOMRIGHT", SVUI_Target, "TOPRIGHT", 0, 220)
	SuperVillain:SetSVMovable(self, self:GetName().."_MOVE", L["Focus Frame"], nil, nil, nil, "ALL, SOLO")
end

function MOD.Construct:focustarget()
	MOD:SetActionPanel(self, "focustarget")
	self.Health = MOD:CreateHealthBar(self, true)
	self.Power = MOD:CreatePowerBar(self, true)
	self.Buffs = MOD:CreateBuffs(self, "focustarget")
	self.Debuffs = MOD:CreateDebuffs(self, "focustarget")
	self.RaidIcon = MOD:CreateRaidIcon(self)
	self.Range = { insideAlpha = 1, outsideAlpha = 1 }
	self:Point("BOTTOM", SVUI_Focus, "TOP", 0, 7)
	SuperVillain:SetSVMovable(self, self:GetName().."_MOVE", L["FocusTarget Frame"], nil, -7, nil, "ALL, SOLO")
end
--[[
##########################################################
UPDATE
##########################################################
]]--
function MOD.FrameUpdate:focus()
	local db = MOD.db["focus"]
	local UNIT_WIDTH = db.width;
	local UNIT_HEIGHT = db.height;
	self:RegisterForClicks(MOD.db.fastClickTarget and "AnyDown" or "AnyUp")
	self.colors = oUF_SuperVillain.colors;
	self:Size(UNIT_WIDTH, UNIT_HEIGHT)
	_G[self:GetName().."_MOVE"]:Size(self:GetSize())
	MOD:RefreshUnitLayout(self, "focus")

	if(MOD.db.xrayFocus) then
		self.XRay:Show()
	else
		self.XRay:Hide()
	end

	MOD:UpdateAuraWatch(self)
	self:UpdateAllElements()
end

function MOD.FrameUpdate:focustarget()
	local db = MOD.db["focustarget"]
	local UNIT_WIDTH = db.width;
	local UNIT_HEIGHT = db.height;
	self:RegisterForClicks(MOD.db.fastClickTarget and "AnyDown" or "AnyUp")
	self.colors = oUF_SuperVillain.colors;
	self:Size(UNIT_WIDTH, UNIT_HEIGHT)
	_G[self:GetName().."_MOVE"]:Size(self:GetSize())
	MOD:RefreshUnitLayout(self, "focustarget")
	self:UpdateAllElements()
end