⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcc_option.lua

📁 WOW的一款PVP插件
💻 LUA
📖 第 1 页 / 共 2 页
字号:
	tCC_Option:SetBackdrop( { 
		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", 
		edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = true, tileSize = 32, edgeSize = 32, 
		insets = { left = 11, right = 12, top = 12, bottom = 11 }
	});
	tCC_Option:EnableMouse(true)
	tCC_Option:RegisterForDrag("LeftButton")
	tCC_Option:SetScript("OnDragStart",function() this:StartMoving() end)
	tCC_Option:SetScript("OnDragStop",function() this:StopMovingOrSizing() end)

	tCC_Option:CreateTexture("tCC_OptionHeader", "OVERLAY")
	tCC_OptionHeader:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
	tCC_OptionHeader:SetPoint("TOP",0,12)
	tCC_OptionHeader:SetWidth(256)
	tCC_OptionHeader:SetHeight(64)

	tCC_Option:CreateFontString("tCC_OptionTitle", "OVERLAY", "GameFontNormalSmall")
	tCC_OptionTitle:SetPoint("CENTER",tCC_OptionHeader,"CENTER",0,12)
	tCC_OptionTitle:SetText(localization.text.Title)

	local tCC_Option_Buttons = {
		{name="Close", type="Button", inherits="UIPanelCloseButton",
			point="TOPRIGHT",x=-5,y=-5},
		{name="Reset", type="Button", inherits="UIPanelButtonTemplate",text=RESET,
			point="TOPLEFT", x=10, y=-10, width=50, height=20,
			func=function()
					local fonts = tCCDB.Fonts
					tCC:GetDefault()
					tCCDB.Fonts = fonts
					tCC_Option_LoadOptions(tCC_Option.index)
				end},

		{name="Action",type="Button",
			point="TOPLEFT",x=15, y=-35,
			auto={"Others","Max", "Point"},},
		{name="Pet",   type="Button",
			point="LEFT",relative="Action",rpoint="RIGHT",
			auto={"Others","Max","Point"},},
		{name="Spell", type="Button",
			point="LEFT",relative="Pet",rpoint="RIGHT",
			auto={"Others","Max","Point","Centers","Sound"}},
		{name="Item",  type="Button",
			point="LEFT",relative="Spell",rpoint="RIGHT",
			auto={"Others","Max","Point","Centers","Sound"}},
		{name="Buff",  type="Button",
			point="LEFT",relative="Item",rpoint="RIGHT",
			auto={"Others","Min","Centers","Shines","Sound"}},
		{name="Other", type="Button",
			point="LEFT",relative="Buff",rpoint="RIGHT",
			auto={"Open","Alls","Centers","Shines","Point"}},


		{name="Open", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
			point="TOPLEFT",relative="Action",rpoint="BOTTOMLEFT",y=-10, width=360,height=38},
		{name="Alls", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
			point="TOPLEFT",relative="Open",rpoint="BOTTOMLEFT",y=-10, width=175,height=110},
		{name="Centers", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
			point="TOPLEFT",relative="Alls",rpoint="BOTTOMLEFT",y=-10, width=175,height=230},
		{name="Others", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
			point="TOPLEFT",relative="Open",rpoint="BOTTOMLEFT",y=-10, width=175,height=350},
		{name="Fonts", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
			point="TOPLEFT",relative="Alls",rpoint="TOPRIGHT",x=10, width=175,height=159},
		{name="Shines", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
			point="TOPLEFT",relative="Fonts",rpoint="BOTTOMLEFT",y=-10, width=175,height=180},

--		{name="Styles", type="Frame", inherits="tCC_OptionFrameBoxTemplate",
--			point="TOPLEFT",relative="Fonts",rpoint="BOTTOMLEFT",y=-10, width=175,height=180},

		{name="Config",type="CheckButton",var="config",
			auto={"Shine","Center","HideCD","Size","Point","Min","Max","Font","Sound"},
			parent="Open",point="TOPLEFT",x=5,y=-5},
		{name="Shine",type="CheckButton",var="shine",
			auto={"Time","Scale","Style"},
			parent="Shines",point="TOPLEFT", x=5,y=-5},
		{name="Center",type="CheckButton",var="center",
			auto={"CTime","CScale","Move","CAlpha","CMode"},
			parent="Centers", point="TOPLEFT",x=5,y=-5},
		{name="HideCD",type="CheckButton",var="hide",
			parent="Alls", point="TOPLEFT",x=5,y=-5},
		{name="Sound",type="CheckButton",var="sound",
			parent="Alls",point="TOPLEFT",relative="HideCD",rpoint="BOTTOMLEFT"},
		{name="CMode",type="CheckButton",var="cmode",
			parent="Centers",point="TOPLEFT",relative="Center",rpoint="BOTTOMLEFT"},
		{name="Type",type="CheckButton",
			parent = "Others",point="TOPLEFT",x=5,y=-5,
			func=function() tCCDB.Other.type = this:GetChecked() and true or nil end},
		{name="Text",type="CheckButton",
			parent = "Others",point="TOPLEFT",relative="Type",rpoint="BOTTOMLEFT",
			func=function() tCCDB.Other.text = this:GetChecked() and true or nil end},
		{name="TextColor",type="Button",func=tCC_OptionColor_OnClick,
			parent="Others",point="TOPLEFT",relative="Text",rpoint="TOPLEFT",x=5,y=-30,
			inherits="tCC_OptionColorPickerTemplate",},


		{name="Time",type="Slider",min=0.00,max=5.00,step=0.01,var = "time",
			parent="Shines",point="TOPLEFT",relative="Shine",rpoint="BOTTOMLEFT",x=5,y=-25},
		{name="Scale",type="Slider",min=36,max=500,step=1,var = "scale",
			parent="Shines",point="TOPLEFT",relative="Time",rpoint="BOTTOMLEFT",y=-25},

		{name="CTime",type="Slider",min=0.00,max=5.00,step=0.01,var = "ctime",
			parent="Centers",point="TOPLEFT",relative="CMode",rpoint="BOTTOMLEFT",x=5,y=-25},
		{name="CScale",type="Slider",min=50,max=200,step=1,var = "cscale",
			parent="Centers",point="TOPLEFT",relative="CTime",rpoint="BOTTOMLEFT",y=-25},
		{name="CAlpha",type="Slider",min=0,max=1,step=0.01,var = "calpha",
			parent="Centers",point="TOPLEFT",relative="CScale",rpoint="BOTTOMLEFT",y=-25},

		{name="Min",type="EditBox",var="min",letter=5,numonly=true,func=function()
				local value = tonumber(this:GetText())
				if value then
					tCCDB[tCC_Option.index].min = value
				else
					this:SetValue(tostring(tCCDB[tCC_Option.index].min))
				end
				this:ClearFocus()
			end,
			parent="Alls",point="TOPLEFT",relative="Sound",rpoint="BOTTOMLEFT",y=-25,x=10},
		{name="Max",type="EditBox",height=20,var="max",letter=5,numonly=true,func=function()
				local value = tonumber(this:GetText())
				if value then
					tCCDB[tCC_Option.index].max = value
				else
					this:SetValue(tostring(tCCDB[tCC_Option.index].max))
				end
				this:ClearFocus()
			end,
			parent="Alls",point="CENTER",relative="Min",rpoint="CENTER",},


		{name="Font",type="EditBox",var="font",func=tCC_OptionSetFont,drop="FontDrop",
			parent="Fonts",point="TOPLEFT",x=15,y=-25},
		{name="Size",type="Slider",min=1,max=36,step=1,var = "size",
			parent="Fonts",point="TOPLEFT",relative="Font",rpoint="BOTTOMLEFT",x=-5,y=-25},

		{name="Move",type="Button",inherits="UIPanelButtonTemplate",
			width=100, height=20, func=tCC_CenterMove,
			parent="Centers",point="TOPLEFT",relative="CAlpha",rpoint="BOTTOMLEFT",y=-20},
		{name="Point",type="DropDown",width=130,var = "point",value = {"TOPLEFT","TOP","TOPRIGHT","LEFT","CENTER","RIGHT","BOTTOMLEFT","BOTTOM","BOTTOMRIGHT"},
			parent="Fonts",point="TOPLEFT",relative="Size",rpoint="BOTTOMLEFT",x=-20,y=-25,},
		{name="Style",type="DropDown",width=130,var = "style",value = {1,2,3,4,5},
			parent="Shines",point="TOPLEFT",relative="Scale",rpoint="BOTTOMLEFT",x=-20,y=-25,},
		{name="FontDrop",type="DropDown",width=130,var = "font",value = tCCDB.Fonts,menu="Font",
			parent="Font",},

	}
	if tdRange_GetColor then
		tinsert(tCC_Option_Buttons, {name="Range", type="Button",func=tCC_OptionColor_OnClick,parent="Others",point="TOPLEFT",relative="TextColor",rpoint="BOTTOMLEFT",inherits="tCC_OptionColorPickerTemplate",y=-20})
		tinsert(tCC_Option_Buttons, {name="Mana",  type="Button",func=tCC_OptionColor_OnClick,parent="Others",point="TOPLEFT",relative="Range",rpoint="BOTTOMLEFT",inherits="tCC_OptionColorPickerTemplate",})
		tinsert(tCC_Option_Buttons, {name="Usable",type="Button",func=tCC_OptionColor_OnClick,parent="Others",point="TOPLEFT",relative="Mana",rpoint="BOTTOMLEFT",inherits="tCC_OptionColorPickerTemplate",})
		tinsert(tCC_Option_Buttons, {name="ColorText1",type="Button",parent="Others",point="TOPLEFT",relative="Usable",rpoint="BOTTOMLEFT",inherits="UIPanelButtonTemplate",width=80,height=26, y=-40})
		tinsert(tCC_Option_Buttons, {name="ColorText2",type="Button",parent="Others",point="TOP",relative="ColorText1",rpoint="BOTTOM",inherits="UIPanelButtonTemplate",width=80,height=26})
		tinsert(tCC_Option_Buttons, {name="ColorText3",type="Button",parent="Others",point="TOP",relative="ColorText2",rpoint="BOTTOM",inherits="UIPanelButtonTemplate",width=80,height=26})
		tinsert(tCC_Option_Buttons, {name="Below1",type="Button",text="↓",func=tCC_OptionColorRangeOnClick,parent="Others",string=1,var=1,point="LEFT",relative="ColorText1",rpoint="RIGHT",inherits="UIPanelButtonTemplate",width=20,height=26,x=30})
		tinsert(tCC_Option_Buttons, {name="Below2",type="Button",text="↓",func=tCC_OptionColorRangeOnClick,parent="Others",string=1,var=2,point="LEFT",relative="ColorText2",rpoint="RIGHT",inherits="UIPanelButtonTemplate",width=20,height=26,x=30})
		tinsert(tCC_Option_Buttons, {name="Above2",type="Button",text="↑",func=tCC_OptionColorRangeOnClick,parent="Others",string=-1,var=2,point="LEFT",relative="ColorText2",rpoint="RIGHT",inherits="UIPanelButtonTemplate",width=20,height=26,x=5})
		tinsert(tCC_Option_Buttons, {name="Above3",type="Button",text="↑",func=tCC_OptionColorRangeOnClick,parent="Others",string=-1,var=3,point="LEFT",relative="ColorText3",rpoint="RIGHT",inherits="UIPanelButtonTemplate",width=20,height=26,x=5})
	end
	
	local button, text, name, value
	for _, value in ipairs(tCC_Option_Buttons) do
		if not value.inherits then
			if value.type == "CheckButton" then
				value.inherits = "tCC_OptionCheckButtonTemplate"
			elseif value.type == "Slider" then
				value.inherits = "tCC_OptionSliderTemplate"
			elseif value.type == "EditBox" then
				value.inherits = "tCC_OptionEditBoxTemplate"
			elseif value.type == "Button" then
				value.inherits = "tCC_OptionButtonTemplate"
			end
		end

		if value.type == "DropDown" then
			button = CreateFrame("Frame", "tCC_Option"..value.name, _G[value.parent and "tCC_Option"..value.parent or "tCC_Option"], "tCC_OptionDropDownTemplate")
			if value.width then
				UIDropDownMenu_SetWidth(value.width, button)
			end
			if value.buttonwidth then
				UIDropDownMenu_SetButtonWidth(value.buttonwidth, button)
			end
			UIDropDownMenu_Initialize(button, function() tCC_Option_DropDownMenu_Initialise(value) end);
			button.type = "DropDown"
		else
			button = CreateFrame(value.type, "tCC_Option"..value.name, _G[value.parent and "tCC_Option"..value.parent or "tCC_Option"], value.inherits)
			if value.width then
				button:SetWidth(value.width)
			end
			if value.height then
				button:SetHeight(value.height)
			end

			if value.type == "Slider" then
				button.text = value.text or localization.text[value.name] or ""
				_G["tCC_Option"..value.name.."Low"]:SetText(value.min)
				_G["tCC_Option"..value.name.."High"]:SetText(value.max)
				button:SetMinMaxValues(value.min, value.max)
				button:SetValueStep(value.step)
			elseif value.type == "EditBox" then
				if value.letter then button:SetMaxLetters(value.letter) end
				if value.numonly then button:SetNumeric(value.numonly) end
			end
			if value.func then
				if value.type == "CheckButton" then
					button:SetScript("OnClick", value.func)
				elseif value.type == "Slider" then
					button:SetScript("OnValueChange", value.func)
				elseif value.type == "EditBox" then
					button:SetScript("OnEnterPressed", value.func)
				elseif value.type == "Button" then
					button:SetScript("OnClick", value.func)
				end
			end
		end
		button.string = value.string or localization.string[value.name] or nil
		button.var = value.var or nil
		button.auto = value.auto or nil
		button.index = value.name or nil
		button.drop = value.drop or nil
		button.menu = value.menu or nil

		if value.point then
			if value.relative then
				value.relative = "tCC_Option"..value.relative
			end
			button:SetPoint(value.point, _G[value.relative or (value.parent and "tCC_Option"..value.parent) or "tCC_Option"], value.rpoint or value.point, value.x or 0, value.y or 0)
		end
		if value.type == "Button" then
			button:SetText(value.text or localization.text[value.name] or "")
		elseif _G[button:GetName().."Text1"] then
			_G[button:GetName().."Text1"]:SetText(value.text or localization.text[value.name] or "")
		elseif _G[button:GetName().."Text"] then
			button.font = _G[button:GetName().."Text"]
			button.font:SetText(value.text or localization.text[value.name] or "")
		end

		local title = value.title or localization.title[value.name] or nil
		if title then
			button.title = title
			button:SetScript("OnEnter",function() GameTooltip:SetOwner(this, "ANCHOR_RIGHT");GameTooltip:SetText(this.title) end)
			button:SetScript("OnLeave",function() GameTooltip:Hide() end)
		end
	end
	if tdRange_GetColor then
		tCC_OptionOthers:CreateFontString("tCC_OptionColorText", "OVERLAY", "GameFontNormalSmall")
		tCC_OptionColorText:SetText(localization.text.ColorText)
		tCC_OptionColorText:SetPoint("BOTTOMLEFT",tCC_OptionColorText1,"TOPLEFT",0,5)
	end
	tCC_Option:Show()

	_G["tCC_OptionAction"]:Disable()
	tCC_Option_LoadOptions("Action")
	tCC_Option.ready = true
end

function tCC_OptionColorRangeOnClick()
	local i, j = this.var, this.var + this.string
	local k, l = _G["tCC_OptionColorText"..i], _G["tCC_OptionColorText"..j]
	local o, p = tCCDB.Other.Color[i], tCCDB.Other.Color[j]
	k:SetText(localization.text[p])
	l:SetText(localization.text[o])
	tCCDB.Other.Color[i] = p
	tCCDB.Other.Color[j] = o
end

function tCC_CenterMove()
	if tCC_Move and tCC_Move:IsVisible() then
		tCC_Move:Hide()
	else
		if not tCC_Move then
			tCC_Move = CreateFrame("Frame",nil,UIParent)
			tCC_Move:SetClampedToScreen(true)
			tCC_Move:EnableMouse(true)
			tCC_Move:SetMovable(true)
			tCC_Move:RegisterForDrag("LeftButton")
			tCC_Move:SetScript("OnDragStart",function() this:StartMoving() end)
			tCC_Move:SetScript("OnDragStop",function()
				this:StopMovingOrSizing();
				local p,_,s,x,y = this:GetPoint()
				tCCDB[tCC_Option.index].x = x
				tCCDB[tCC_Option.index].y = y
				tCCDB[tCC_Option.index].p = p
				tCCDB[tCC_Option.index].s = s
			end)
			tCC_Move.texture = tCC_Move:CreateTexture(nil,"ARTWORK")
			tCC_Move.texture:SetAllPoints(tCC_Move)
			tCC_Move.texture:SetTexture("Interface\\Icons\\INV_Misc_Head_Dragon_01")
		end

		tCC_Move:SetWidth(tCCDB[tCC_Option.index].cscale);
		tCC_Move:SetHeight(tCCDB[tCC_Option.index].cscale);
		tCC_Move:ClearAllPoints()
		if tCCDB[tCC_Option.index].p then
			tCC_Move:SetPoint(tCCDB[tCC_Option.index].p,UIParent,tCCDB[tCC_Option.index].s,tCCDB[tCC_Option.index].x,tCCDB[tCC_Option.index].y)
		else
			tCC_Move:SetPoint("CENTER",UIParent,"CENTER",0,0)
		end
		tCC_Move:Show()
	end
end

function tCC_OptionSetFont()
	if(not tCCTestFont) then
		CreateFont("tCCTestFont")
	end
	local font = string.lower(this:GetText())
	if( tCCTestFont:SetFont(font, tCCDB[tCC_Option.index].size) ) then
		tCCDB[tCC_Option.index].font = font
		local ishave, i
		for i = 1, #(tCCDB.Fonts) do
			if tCCDB.Fonts[i] == font then
				ishave = true
				break
			end
		end
		if not ishave then
			tinsert(tCCDB.Fonts, font)
			local info = {}
			info.value = font
			info.text = font
			info.func = tCC_Option_DropDownMenu_OnClick
			info.owner = tCC_OptionFont
			info.checked = nil
			info.icon = nil
			UIDropDownMenu_AddButton(info, 1)
		end
		this:SetText(font)
		tCC_Option_DropDownSetSelect(tCC_OptionFontDrop, font)
	else
		DEFAULT_CHAT_FRAME:AddMessage(format(localization.text.Font1, font))
		this:SetText(tCCDB[tCC_Option.index].font)
	end
	this:ClearFocus()
end

function tCC_Option_DropDownMenu_Initialise(v) 
	local info = UIDropDownMenu_CreateInfo();
	for i = 1, #(v.value) do
		info.value = v.value[i]
		info.text = (v.string and v.string[i]) or
			(localization.string[v.name] and localization.string[v.name][i]) or
			v.value[i] 
		info.func = tCC_Option_DropDownMenu_OnClick
		info.owner = _G["tCC_Option"..v.name]
		info.checked = nil
		info.icon = nil
		UIDropDownMenu_AddButton(info, 1)
	end
end

function tCC_Option_DropDownMenu_OnClick()
	tCC_Option_DropDownSetSelect(this.owner, this.value)
	tCCDB[tCC_Option.index][this.owner.var] = this.value
	if this.owner.menu then
		_G["tCC_Option"..this.owner.menu]:SetText(this.value)
		_G["tCC_Option"..this.owner.menu]:ClearFocus()
	end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -