Quantcast
--[[
##############################################################################
_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_       #
 ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__      #
  __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____     #
   ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____    #
    ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____   #
     _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____  #
      __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ #
       _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_#
        ___\///////////___________\///___________\/////////_____\///////////_#
##############################################################################
S U P E R - V I L L A I N - U I   By: Munglunch                              #
##############################################################################
--]]
local SuperVillain, L = unpack(SVUI);
local STYLE = _G.StyleVillain;
--[[
##########################################################
ALERTFRAME STYLER
##########################################################
]]--
local function Widget_OnEnter(b)
	b:SetBackdropBorderColor(unpack(SuperVillain.Media.color.highlight))
end;
local function Widget_OnLeave(b)
	b:SetBackdropBorderColor(0,0,0,1)
end;
local function Widget_ScrollStyle(e, f)
	if _G[e:GetName().."BG"]then
		_G[e:GetName().."BG"]:SetTexture(0,0,0,0)
	end;
	if _G[e:GetName().."Track"]then
		_G[e:GetName().."Track"]:SetTexture(0,0,0,0)
	end;
	if _G[e:GetName().."Top"]then
		_G[e:GetName().."Top"]:SetTexture(0,0,0,0)
		_G[e:GetName().."Bottom"]:SetTexture(0,0,0,0)
		_G[e:GetName().."Middle"]:SetTexture(0,0,0,0)
	end;
	if _G[e:GetName().."ScrollUpButton"] and _G[e:GetName().."ScrollDownButton"] then
		_G[e:GetName().."ScrollUpButton"]:Formula409()
		if not _G[e:GetName().."ScrollUpButton"].icon then
			STYLE:ApplyPaginationStyle(_G[e:GetName().."ScrollUpButton"])
			SquareButton_SetIcon(_G[e:GetName().."ScrollUpButton"], "UP")
			_G[e:GetName().."ScrollUpButton"]:Size(_G[e:GetName().."ScrollUpButton"]:GetWidth()+7, _G[e:GetName().."ScrollUpButton"]:GetHeight()+7)
		end;
		_G[e:GetName().."ScrollDownButton"]:Formula409()
		if not _G[e:GetName().."ScrollDownButton"].icon then
			STYLE:ApplyPaginationStyle(_G[e:GetName().."ScrollDownButton"])
			SquareButton_SetIcon(_G[e:GetName().."ScrollDownButton"], "DOWN")
			_G[e:GetName().."ScrollDownButton"]:Size(_G[e:GetName().."ScrollDownButton"]:GetWidth()+7, _G[e:GetName().."ScrollDownButton"]:GetHeight()+7)
		end;
		if not e.styledBackground then
			e.styledBackground = CreateFrame("Frame", nil, e)
			e.styledBackground:Point("TOPLEFT", _G[e:GetName().."ScrollUpButton"], "BOTTOMLEFT", 0, -1)
			e.styledBackground:Point("BOTTOMRIGHT", _G[e:GetName().."ScrollDownButton"], "TOPRIGHT", 0, 1)
			e.styledBackground:SetPanelTemplate("Inset", true)
		end;
		if e:GetThumbTexture()then
			if not f then
				f = 3
			end;
			e:GetThumbTexture():SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
		end
	end
end;

local function Widget_ButtonStyle(h, i, j)
	if h.Left then h.Left:SetAlpha(0)end;
	if h.Middle then h.Middle:SetAlpha(0)end;
	if h.Right then h.Right:SetAlpha(0)end;
	if h.SetNormalTexture then h:SetNormalTexture("")end;
	if h.SetHighlightTexture then h:SetHighlightTexture("")end;
	if h.SetPushedTexture then h:SetPushedTexture("")end;
	if h.SetDisabledTexture then h:SetDisabledTexture("")end;
	if i then h:Formula409()end;
	if not h.template and not j then h:SetFixedPanelTemplate("Button")end;
	h:HookScript("OnEnter", Widget_OnEnter)h:HookScript("OnLeave", Widget_OnLeave)
end;

local function Widget_PaginationStyle(...)
	STYLE:ApplyPaginationStyle(...)
end

local function SVUICoreStyle(postLoad)
	if(not postLoad) then
		for i = 1, 4 do
			local alert = _G["SVUI_SystemAlert"..i];
			if(alert) then
				for b = 1, 3 do
					alert.buttons[b]:SetButtonTemplate()
				end;
				alert:Formula409()
				STYLE:ApplyAlertStyle(alert)
				alert.input:SetEditboxTemplate()
				alert.input.Panel:Point("TOPLEFT", -2, -4)
				alert.input.Panel:Point("BOTTOMRIGHT", 2, 4)
				alert.gold:SetEditboxTemplate()
				alert.silver:SetEditboxTemplate()
				alert.copper:SetEditboxTemplate()
			end
		end
	end

	local AceGUI = LibStub("AceGUI-3.0", true)
	if not AceGUI then
		local h = CreateFrame("Frame")
		h:RegisterEvent("ADDON_LOADED")
		h:SetScript("OnEvent", function(b, M, N)
			if LibStub("AceGUI-3.0", true) then
				SVUICoreStyle(true)
				b:UnregisterEvent("ADDON_LOADED")
			end
		end)
		return
	end

	local regWidget = AceGUI.RegisterAsWidget;
	local regContainer = AceGUI.RegisterAsContainer;

	AceGUI.RegisterAsWidget = function(self, widget)
		local n = widget.type;
		if n == "MultiLineEditBox"then
			local e = widget.frame;
			e:SetFixedPanelTemplate("Pattern")
			if not widget.scrollBG.template then
				widget.scrollBG:SetFixedPanelTemplate("Inset")
			end
			Widget_ButtonStyle(widget.button)
			Widget_ScrollStyle(widget.scrollBar)
			widget.scrollBar:SetPoint("RIGHT", e, "RIGHT", 0-4)
			widget.scrollBG:SetPoint("TOPRIGHT", widget.scrollBar, "TOPLEFT", -2, 19)
			widget.scrollBG:SetPoint("BOTTOMLEFT", widget.button, "TOPLEFT")
			widget.scrollFrame:SetPoint("BOTTOMRIGHT", widget.scrollBG, "BOTTOMRIGHT", -4, 8)
		elseif n == "CheckBox"then
			widget.checkbg:MUNG()
			widget.highlight:MUNG()
			if not widget.styledCheckBG then
				widget.styledCheckBG = CreateFrame("Frame", nil, widget.frame)
				widget.styledCheckBG:FillInner(widget.check)
				widget.styledCheckBG:SetFixedPanelTemplate("Inset")
			end
			widget.check:SetParent(widget.styledCheckBG)
		elseif n == "Dropdown"then
			local e = widget.dropdown;
			local o = widget.button;
			local p = widget.text;
			e:Formula409()
			o:ClearAllPoints()
			o:Point("RIGHT", e, "RIGHT", -20, 0)
			o:SetFrameLevel(o:GetFrameLevel() + 1)
			Widget_PaginationStyle(o, true)
			if not e.Panel then
				e:SetPanelTemplate("Inset")
				e.Panel:Point("TOPLEFT", e, "TOPLEFT", 20, -2)
				e.Panel:Point("BOTTOMRIGHT", e, "BOTTOMRIGHT", -20, 2)
				local level = e:GetFrameLevel()
				if(level > 0) then
					e.Panel:SetFrameLevel(level - 1)
				else
					e.Panel:SetFrameLevel(0)
				end
			end
			o:SetParent(e.Panel)
			p:SetParent(e.Panel)
			o:HookScript("OnClick", function(s)
				local self = s.obj;
				self.pullout.frame:SetFixedPanelTemplate("Default")
			end)
		elseif n == "LSM30_Font" or n == "LSM30_Sound" or n == "LSM30_Border" or n == "LSM30_Background" or n == "LSM30_Statusbar" then
			local e = widget.frame;
			local o = e.dropButton;
			local p = e.text;
			e:Formula409()
			Widget_PaginationStyle(o, true)
			e.text:ClearAllPoints()
			e.text:Point("RIGHT", o, "LEFT", -2, 0)
			o:ClearAllPoints()
			o:Point("RIGHT", e, "RIGHT", -10, -6)
			if not e.Panel then
				e:SetFixedPanelTemplate("Inset")
				if n == "LSM30_Font"then
					e.Panel:Point("TOPLEFT", 20, -17)
				elseif n == "LSM30_Sound"then
					e.Panel:Point("TOPLEFT", 20, -17)
					widget.soundbutton:SetParent(e.Panel)
					widget.soundbutton:ClearAllPoints()
					widget.soundbutton:Point("LEFT", e.Panel, "LEFT", 2, 0)
				elseif n == "LSM30_Statusbar"then
					e.Panel:Point("TOPLEFT", 20, -17)
					widget.bar:SetParent(e.Panel)
					widget.bar:FillInner()
				elseif n == "LSM30_Border"or n == "LSM30_Background"then
					e.Panel:Point("TOPLEFT", 42, -16)
				end
				e.Panel:Point("BOTTOMRIGHT", o, "BOTTOMRIGHT", 2, -2)
			end
			o:SetParent(e.Panel)
			p:SetParent(e.Panel)
			o:HookScript("OnClick", function(s, o)
				local self = s.obj;
				if(self.dropdown and not self.dropdown.Panel) then
					local e = self.dropdown
					e:SetPanelTemplate("Inset")
					e.Panel:Point("TOPLEFT", e, "TOPLEFT", 20, -2)
					e.Panel:Point("BOTTOMRIGHT", e, "BOTTOMRIGHT", -20, 2)
					local level = e:GetFrameLevel()
					if(level > 0) then
						e.Panel:SetFrameLevel(level - 1)
					else
						e.Panel:SetFrameLevel(0)
					end
				end
			end)
		elseif n == "EditBox" then
			local e = widget.editbox;
			local o = widget.button;
			local boxName = e:GetName()
			if(_G[boxName.."Left"]) then
				_G[boxName.."Left"]:MUNG()
			end
			if(_G[boxName.."Middle"]) then
				_G[boxName.."Middle"]:MUNG()
			end
			if(_G[boxName.."Right"]) then
				_G[boxName.."Right"]:MUNG()
			end
			e:Height(17)
			e:SetFixedPanelTemplate("Inset")
			local level = e:GetFrameLevel()
			if(level > 0) then
				e.Panel:SetFrameLevel(level - 1)
			else
				e.Panel:SetFrameLevel(0)
			end
			Widget_ButtonStyle(o)
		elseif n == "Button"then
			local e = widget.frame;
			Widget_ButtonStyle(e, nil, true)
			e:Formula409()
			e:SetFixedPanelTemplate("Button", true)
			e.Panel:FillInner()
			widget.text:SetParent(e.Panel)
		elseif n == "Slider"then
			local e = widget.slider;
			local t = widget.editbox;
			local u = widget.lowtext;
			local v = widget.hightext;
			local w = 20;
			e:Formula409()
			e:SetFixedPanelTemplate("Inset")
			e:Height(w)
			e:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
			e:GetThumbTexture():SetVertexColor(0.8, 0.8, 0.8)
			t:SetFixedPanelTemplate("Inset")
			t:Height(15)
			t:Point("TOP", e, "BOTTOM", 0, -1)
			u:SetPoint("TOPLEFT", e, "BOTTOMLEFT", 2, -2)
			v:SetPoint("TOPRIGHT", e, "BOTTOMRIGHT", -2, -2)
		end
		return regWidget(self, widget)
	end

	local externaltest = false;

	AceGUI.RegisterAsContainer = function(self, widget)
		local n = widget.type;
		if n == "ScrollFrame" then
			local e = widget.scrollbar;
			Widget_ScrollStyle(e)
		elseif n == "Window" then
			local e = widget.content:GetParent()
			e:SetPanelTemplate("Halftone")
		elseif n == "InlineGroup" or n == "TreeGroup" or n == "TabGroup" or n == "SimpleGroup" or n == "Frame" or n == "DropdownGroup" then
			local e = widget.content:GetParent()
			if n == "Frame" then
				e:Formula409()
				for z = 1, e:GetNumChildren()do
					local A = select(z, e:GetChildren())
					if A:GetObjectType() == "Button"and A:GetText() then
						Widget_ButtonStyle(A)
					else
						A:Formula409()
					end
				end
			end
			if not widget.treeframe then
				if not externaltest then
					e:SetPanelTemplate("Halftone")
					e.Panel:SetFrameLevel(0)
					externaltest = true
				else
					e:SetFixedPanelTemplate("Default")
				end
			end
			if widget.treeframe then
				widget.treeframe:SetFixedPanelTemplate("Inset")
				e:Point("TOPLEFT", widget.treeframe, "TOPRIGHT", 1, 0)
				local B = widget.CreateButton;
				widget.CreateButton = function(self)
					local o = B(self)
					o.toggle:Formula409()
					o.toggle.SetNormalTexture = NOOP;
					o.toggle.SetPushedTexture = NOOP;
					o.toggleText = o.toggle:CreateFontString(nil, "OVERLAY")
					o.toggleText:SetFontTemplate(nil, 19)
					o.toggleText:SetPoint("CENTER")
					o.toggleText:SetText("+")
					return o
				end
				local C = widget.RefreshTree;
				widget.RefreshTree = function(self, D)
					C(self, D)
					if not self.tree then return end
					local E = self.status or self.localstatus;
					local F = E.groups;
					local G = self.lines;
					local H = self.buttons;
					for z, I in pairs(G)do
						local o = H[z]
						if F[I.uniquevalue]and o then
							o.toggleText:SetText("-")
						elseif o then
							o.toggleText:SetText("+")
						end
					end
				end
			end
			if n == "TabGroup" then
				local createTab = widget.CreateTab;
				widget.CreateTab = function(self, arg)
					local tab = createTab(self, arg)
					tab:Formula409()
					return tab
				end
			end
			if widget.scrollbar then Widget_ScrollStyle(widget.scrollbar) end
		end
		return regContainer(self, widget)
	end
end
--[[
##########################################################
STYLE LOADING
##########################################################
]]--
STYLE:SaveCustomStyle(SVUICoreStyle)