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

📄 tcc_option.lua

📁 WOW的一款PVP插件
💻 LUA
📖 第 1 页 / 共 2 页
字号:

local _G = getfenv(0)
local localization = {}

if GetLocale() == "zhCN" then
	localization.text = {
		Title = "tCC 设置",
		Config = "开启",
		Shine = "开启闪光效果",
		Sound = "开启声音效果",
		HideCD = "隐藏系统动画",
		Center = "开启中部提示",
		CMode = "中部加亮",
		Time = "闪光时间:",
		Scale = "闪光大小:",
		Style = "闪光材质",
		CTime = "中部时间:",
		CScale = "中部大小:",
		CAlpha = "中部透明:",
		Size = "字体大小:",
		Point = "计时位置",
		Font = "字体文件",
		Min = "时间下限",
		Max = "时间上限",
		Move = "移动中部",
		Action = "动作条",
		Pet = "宠物条",
		Spell = "技能书",
		Item = "背包",
		Buff = "Buff",
		Font1 = "|cff7fff7fTCC|r--|cff7fff7f太多|r冷却:字体未设置,%s为无效字体,请检查拼写!",
		Range = "超出距离",
		Mana = "法力不足",
		Usable = "不可用",
		Other = "其它",
		Type = "精确时间",
		ColorText = "优先级",
		TextColor = "技能名称颜色",
		Text = "中部文字",
	}
	localization.title = {
		HideCD = "隐藏系统的转圈效果",
		Time = "闪光效果持续时间(单位:秒)",
		CTime = "中部提示的持续时间",
		CAlpha = "中部提示的初始透明度",
		Min = "低于此值的冷却时间不显示(单位:秒)",
		Max = "Buff计时剩余时间低于此值才开始显示\n设为 0 时不设上限(单位:秒)",
		Type = "1分钟到10分钟之间的时间显示为X:XX的形式"
	}
	localization.string = {
		Style = {"技能图标","系统","圆形","爆炸","心型"},
		Point = {"左上","上","右上","左","中","右","左下","下","右下"},
	}
	
elseif GetLocale() == "zhTW" then
	localization.text = { 
		Title = "tCC設置", 
		Config = "開啟", 
		Shine = "開啟閃光效果", 
		Sound = "開啟聲音效果", 
		HideCD = "隱藏系統動畫", 
		Center = "開啟中部提示", 
		CMode = "中部加亮", 
		Time = "閃光時間:", 
		Scale = "閃光大小:", 
		Style = "閃光材質", 
		CTime = "中部時間:", 
		CScale = "中部大小:", 
		CAlpha = "中部透明:", 
		Size = "字體大小:", 
		Point = "計時位置", 
		Font = "字體文件", 
		Min = "時間下限", 
		Max = "時間上限", 
		Move = "移動中部", 
		Action = "動作條", 
		Pet = "寵物條", 
		Spell = "技能書", 
		Item = "背包", 
		Buff = "Buff", 
		Font1 = "|cff7fff7fTCC|r--|cff7fff7f太多|r冷卻:字體未設置,%s為無效字體,請檢查拼寫!",
		Range = "超出距離", 
		Mana = "法力不足", 
		Usable = "不可用", 
		Other = "其它", 
		Type = "精確時間",
		ColorText = "優先級", 
		TextColor = "技能名稱顏色", 
		Text = "中部文字",
	} 
	localization.title = { 
		HideCD = "隱藏系統的轉圈效果", 
		Time = "閃光效果持續時間(單位:秒)", 
		CTime = "中部提示的持續時間", 
		CAlpha = "中部提示的初始透明度", 
		Min = "低於此值的冷卻時間不顯示(單位:秒)", 
		Max = "Buff計時剩餘時間低於此值才開始顯示\n設為0時不設上限(單位:秒)", 
		Type = "1分鐘到10分鐘之間的時間顯示為X:XX的形式" 
	} 
	localization.string = { 
		Style = {"技能圖標","系統","圓形","爆炸","心型"}, 
		Point = {"左上","上","右上","左","中","右","左下","下","右下"}, 
	}
else
	localization.text = {
                Title = "tCC Options",
                Config = "Enabled",
                Shine = "Enable Shining",
                Sound = "Play Sound on Cooldown Completed",
                HideCD = "Hide default Effect",
                Center = "Show HoT Icon on Screen",
                CMode = "Highlight HoT Icon",
                Time = "Duration:",
                Scale = "Size:",
                Style = "Style",
                CTime = "Time:",
                CScale = "Size:",
                CAlpha = "Alpha Val:",
                Size = "Font Size:",
                Point = "Anchor offset",
                Font = "Font File",
                Min = "Min Displayable Cooldown Duration",
                Max = "Max Displayable Cooldown Duration",
                Move = "Effect Test (on|off)",
                Action = "Action",
                Pet = "Pet",
                Spell = "Spell",
                Item = "Item",
                Buff = "Buff",
                Font1 = "|cff7fff7fTCC|r-|cff7fff7fTaiDuo|rCoolDown:Fonts not set,%s is invalid fonts, check the spelling!",
                Range = "OutOfRange", 
                Mana = "NotEnoughMana",
                Usable = "SpellNotUsable", 
                Other = "Other", 
                Type = "Show Precise Duration",
                ColorText = "Priority",
                TextColor = "Color of Spells' Name",
                Text = "Text in center",
        }
        localization.title = {
                Time = "Duration of shining effect (second/s).",
                CTime = "Duration of onScreen hot icon (second/s).",
                CAlpha = "Initial transparency of onScreen hot icon.",
                Min = "Not displayable less than this cooldown duration (second/s).",
                Max = "Not displayable more than this cooldown duartion \n Set 0 no limit (second/s).",
                Type = "Time between 0 to 10 mins will be displayed as the format of X:XX",
        }
        localization.string = {
                Style = {"Icon", "System", "Round", "Explosive", "Heart"},
        }

end

tCC_Option = CreateFrame("Frame",nil,UIParent)
tCC_Option:Hide()
tCC_Option.index = "Action"

local function tCC_Option_Enable(frame)
	local type = frame:GetObjectType()
	if type == "Button" then
		frame:Enable()
		if _G[frame:GetName() .. "Text"] then
			_G[frame:GetName() .. "Text"]:SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
		end
	elseif type == "Slider" then
		OptionsFrame_EnableSlider(frame)
		frame.disable = nil
	elseif type == "CheckButton" then
		OptionsFrame_EnableCheckBox(frame)
	elseif type == "EditBox" then
		frame:ClearFocus()
		frame.disable = nil
		_G[frame:GetName() .. "Text"]:SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
	elseif type == "Frame" and frame.type == "DropDown" then
		UIDropDownMenu_EnableDropDown(frame)
		_G[frame:GetName() .. "Text1"]:SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
	end
end

local function tCC_Option_Disable(frame)
	local type = frame:GetObjectType()
	if type == "Button" then
		frame:Disable()
		if _G[frame:GetName() .. "Text"] then
			_G[frame:GetName() .. "Text"]:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
		end
	elseif type == "Slider" then
		OptionsFrame_DisableSlider(frame)
		frame.disable = true
	elseif type == "CheckButton" then
		OptionsFrame_DisableCheckBox(frame)
	elseif type == "EditBox" then
		frame:ClearFocus()
		frame.disable = true
		_G[frame:GetName() .. "Text"]:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
	elseif type == "Frame" and frame.type == "DropDown" then
		UIDropDownMenu_DisableDropDown(frame)
		_G[frame:GetName() .. "Text1"]:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
	end
end

function tCC_Option_UpdateEnOrDis(auto, check)
	if auto then
		local set
		if check  then
			set = tCC_Option_Enable
		else
			set = tCC_Option_Disable
		end
		for _, frame in ipairs(auto) do
			local button = _G["tCC_Option"..frame]
			set(button)
			if button.auto and button.GetChecked then
				local seccheck = check and button:GetChecked() and true
				tCC_Option_UpdateEnOrDis(button.auto, seccheck)
			end
		end
	end
end

local function tCC_OptionSliderSetValue(frame, value)
	if frame:IsVisible() and value and frame:GetValue() ~= value then
		local disable = frame.disable
		frame.disable = true
		frame:SetValue(value)
		frame.font:SetText(frame.text..(frame.string and frame.string[value] or value))
		frame.disable = disable
	end
end

local function tCC_Option_CheckButtonSetChecked(frame, check, notdo)
	local value = frame:GetChecked() and true
	if frame:IsVisible() and value ~= check then
		frame:SetChecked(check)
		if not notdo then
			tCC_Option_UpdateEnOrDis(frame.auto, check)
		end
	end
end

local function tCC_Option_DropDownSetSelect(frame, value)
	if frame and frame:IsVisible() and value then
		ToggleDropDownMenu(1, nil, frame)
		UIDropDownMenu_SetSelectedValue(frame, value)
		ToggleDropDownMenu(1, nil, frame)
	end
end

local function tCC_Option_EditBoxSetText(frame, text)
	if frame:IsVisible() and text and text ~= frame:GetText() then
		local disable = frame.disable
		frame.disable = true
		frame:SetText(text)
		frame.disable = disable
	end
end

function tCC_OptionColor_OnClick()
	if ColorPickerFrame:IsShown() then
		ColorPickerFrame:Hide()
	else
		ColorPickerFrame.index = this.index
		ColorPickerFrame.hasOpacity = nil
		ColorPickerFrame.previousValues = {r = tCCDB.Color[this.index].r, g = tCCDB.Color[this.index].g, b = tCCDB.Color[this.index].b}

		ColorPickerFrame.func = tCC_OptionColor_OnColorChange
		ColorPickerFrame.cancelFunc = function() tCC_OptionColor_OnColorChange(ColorPickerFrame.previousValues, ColorPickerFrame.index) end

		ColorPickerFrame:SetColorRGB(tCCDB.Color[this.index].r, tCCDB.Color[this.index].g, tCCDB.Color[this.index].b)
		
		ShowUIPanel(ColorPickerFrame)
	end
end

function tCC_OptionColor_OnColorChange(rgb, index)
	local r, g, b
	if rgb then
		r = rgb.r; g = rgb.g; b = rgb.b
	else
		r, g, b = ColorPickerFrame:GetColorRGB()
		index = ColorPickerFrame.index
	end
	
	tCCDB.Color[index].r = r
	tCCDB.Color[index].g = g
	tCCDB.Color[index].b = b

	getglobal("tCC_Option"..index.."NormalTexture"):SetVertexColor(r, g, b)
end

function tCC_Option_LoadOptions(index)
	local show, frame = {"Alls","Others","Max","Min","Open","Point","Sound","Centers","Shines"}
	for _, frame in ipairs(show) do
		frame = _G["tCC_Option" .. frame]
		if frame and not frame:IsVisible() then
			frame:Show()
		end
	end
	local button = _G["tCC_Option"..index]
	for _, frame in ipairs(button.auto) do
		frame = _G["tCC_Option"..frame]
		if frame and frame:IsVisible() then
			frame:Hide()
		end
	end

	if index ~= "Other" then
		local value = tCCDB[index]

		tCC_OptionSliderSetValue(tCC_OptionTime,   value.time)
		tCC_OptionSliderSetValue(tCC_OptionScale,  value.scale)
		tCC_OptionSliderSetValue(tCC_OptionCTime,  value.ctime)
		tCC_OptionSliderSetValue(tCC_OptionCScale, value.cscale)
		tCC_OptionSliderSetValue(tCC_OptionCAlpha, value.calpha)
		tCC_OptionSliderSetValue(tCC_OptionSize,   value.size)

		tCC_Option_EditBoxSetText(tCC_OptionMin,  value.min)
		tCC_Option_EditBoxSetText(tCC_OptionMax,  value.max)
		tCC_Option_EditBoxSetText(tCC_OptionFont, value.font)

		tCC_Option_DropDownSetSelect(tCC_OptionFontDrop, value.font)
		tCC_Option_DropDownSetSelect(tCC_OptionStyle, value.style)
		tCC_Option_DropDownSetSelect(tCC_OptionPoint, value.point)

		tCC_Option_CheckButtonSetChecked(tCC_OptionShine,  value.shine, true)
		tCC_Option_CheckButtonSetChecked(tCC_OptionCenter, value.center, true)
		tCC_Option_CheckButtonSetChecked(tCC_OptionHideCD, value.hide, true)
		tCC_Option_CheckButtonSetChecked(tCC_OptionConfig, value.config, true)
		tCC_Option_CheckButtonSetChecked(tCC_OptionCMode,  value.cmode, true)
		tCC_Option_CheckButtonSetChecked(tCC_OptionSound,  value.sound, true)

		tCC_Option_UpdateEnOrDis(tCC_OptionConfig.auto, value.config)
	else
		if tdRange_GetColor then
			tCC_OptionColor_OnColorChange(tCCDB.Color.Range, "Range")
			tCC_OptionColor_OnColorChange(tCCDB.Color.Mana, "Mana")
			tCC_OptionColor_OnColorChange(tCCDB.Color.Usable, "Usable")
			for i = 1, 3 do
				_G["tCC_OptionColorText"..i]:SetText(localization.text[tCCDB.Other.Color[i]])
			end
		end
		tCC_Option_Enable(tCC_OptionFont)
		tCC_Option_Enable(tCC_OptionSize)
		tCC_Option_CheckButtonSetChecked(tCC_OptionType,  tCCDB.Other.type)
		tCC_Option_CheckButtonSetChecked(tCC_OptionText,  tCCDB.Other.text)
		tCC_OptionColor_OnColorChange(tCCDB.Color.TextColor, "TextColor")
		tCC_OptionSliderSetValue(tCC_OptionSize, tCCDB.Other.size)
		tCC_Option_EditBoxSetText(tCC_OptionFont, tCCDB.Other.font)
		tCC_Option_DropDownSetSelect(tCC_OptionFontDrop, tCCDB.Other.font)
	end
	if tCC_Move and tCC_Move:IsVisible() then tCC_Move:Hide() end
end

function tCC_Option_Init()
	tCC_Option:SetWidth(390); tCC_Option:SetHeight(490);
	tCC_Option:SetPoint("CENTER")
	tCC_Option:SetFrameStrata("LOW")
	tCC_Option:SetToplevel(false)
	tCC_Option:SetMovable(true)

⌨️ 快捷键说明

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