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

📄 cooldowncount.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
						cooldownCount:Hide();
						return;
					else
						cooldownCount:Show();
					end
				end
				local newTime = CooldownCount_GetFormattedTime(remainingTime)
				if ( ( cooldownCount.flashing ) ) then
					if ( ( not cooldownCount.flashTime ) or ( (cooldownCount.flashTime + CooldownCount_TimeBetweenFlashes) < GetTime() ) ) then
						if ( cooldownCount.flashingon ) then
							local r, g, b = unpack(CooldownCountOptions.color.normal);
							cooldownCount:SetVertexColor(r, g, b);
							cooldownCount.flashingon = false;
						else
							local r, g, b = unpack(CooldownCountOptions.color.flash);
							cooldownCount:SetVertexColor(r, g, b);
							cooldownCount.flashingon = true;
						end
						cooldownCount.flashTime = GetTime();
					end
				else
					local r, g, b = unpack(CooldownCountOptions.color.normal);
					cooldownCount:SetVertexColor(r, g, b);
					newTimeString = newTime;
				end
				--Print(format("NewTime : %s", newTime));
				cooldownCount:SetAlpha(CooldownCountOptions.alpha);
				
				local oldTime = cooldownCount:GetText();
				
				if ( newTime ~= oldTime ) or ( force ) then
					cooldownCount:SetText(newTime);
					local oldScale = getglobal(cooldownName.."CountFrameScale");
					if ( not oldScale ) then
						oldScale = cooldownCountFrame:GetScale();
						setglobal(cooldownName.."CountFrameScale", oldScale);
					end
					local noAutoScale = false;
					local newScale = oldScale * CooldownCount_GetAppropriateScale(newTime, noAutoScale);
					cooldownCountFrame:SetScale(newScale);
					local oldWidth = getglobal(cooldownName.."CountFrameWidth");
					if ( not oldWidth ) then
						oldWidth = cooldownCountFrame:GetWidth();
						setglobal(cooldownName.."CountFrameWidth", oldWidth);
					end
					local newWidth = newScale * oldWidth;
					if ( newWidth < 32 ) then newWidth = 32; end
					cooldownCountFrame:SetWidth(newWidth);
					cooldownCount:SetWidth(newWidth);
					local oldHeight = getglobal(cooldownName.."CountFrameHeight");
					if ( not oldHeight ) then
						oldHeight = cooldownCountFrame:GetHeight();
						setglobal(cooldownName.."CountFrameHeight", oldHeight);
					end
					local newHeight = newScale * oldHeight;
					if ( newHeight < 10 ) then newHeight = 10; end
					cooldownCountFrame:SetHeight(newHeight);
					cooldownCount:SetHeight(newHeight);
				end
				
				if ( remainingTime <= flashTime ) then
					cooldownCount.flashing = true;
				else
					cooldownCount.flashing = false;
				end
				
				if ( ( cooldownCount.flashingQWEQWE ) ) then
					if ( not cooldownCount:IsVisible() ) then
						cooldownCount:Show();
					else
						cooldownCount:Hide();
					end
					if ( not cooldownCountFrame:IsVisible() ) then
						cooldownCountFrame:Show();
					else
						cooldownCountFrame:Hide();
					end
				else
					if ( not cooldownCount:IsVisible() ) then
						cooldownCount:Show();
					end
					if ( not cooldownCountFrame:IsVisible() ) then
						cooldownCountFrame:Show();
					end
				end
			end
		end
	else
		if ( cooldownCount ) then
			cooldownCount:Hide();
		end
		if ( cooldownCountFrame ) then
			cooldownCountFrame:Hide();
		end
	end
end

function CooldownCount_OldUpdateCooldownCount(this, start, duration, enable)
	local cooldownCount = getglobal(this:GetName().."Count");
	local cooldownCountFrame = getglobal(this:GetName().."CountFrame");
	local cooldownCountValuesName = (this:GetName().."CountValues");
	local cooldownCountValues = { start, duration, enable };
	if ( cooldownCount ) then
		setglobal(cooldownCountValuesName, cooldownCountValues);
	end
	--CooldownCount_DoUpdateCooldownCount(this:GetName());
end

function CooldownCount_UpdateCooldownCount(this, start, duration, enable)
 	local cooldownCount = getglobal(this:GetName().."Count");
	local cooldownCountFrame = getglobal(this:GetName().."CountFrame");
	local cooldownCountValuesName = (this:GetName().."CountValues");
	if (not getglobal(cooldownCountValuesName)) then
		setglobal(cooldownCountValuesName, {});
	end
	if ( cooldownCount ) then
		getglobal(cooldownCountValuesName)[1] = start;
		getglobal(cooldownCountValuesName)[2] = duration;
		getglobal(cooldownCountValuesName)[3] = enable;
	end
end


-- Hooks/unhooks functions. If toggle is 1, hooks functions, otherwise it unhooks functions.
--  Hooking functions mean that you replace them with your own functions and then call the 
--  original function at your leisure.
function CooldownCount_Setup_Hooks(toggle)
	if ( toggle == 1 ) then
		if ( ( CooldownFrame_SetTimer ~= CooldownCount_CooldownFrame_SetTimer ) and (CooldownCount_Saved_CooldownFrame_SetTimer == nil) ) then
			CooldownCount_Saved_CooldownFrame_SetTimer = CooldownFrame_SetTimer;
			CooldownFrame_SetTimer = CooldownCount_CooldownFrame_SetTimer;
		end
	else
		if ( CooldownFrame_SetTimer == CooldownCount_CooldownFrame_SetTimer) then
			CooldownFrame_SetTimer = CooldownCount_Saved_CooldownFrame_SetTimer;
			CooldownCount_Saved_CooldownFrame_SetTimer = nil;
		end
	end
end

-- Handles events
function CooldownCount_OnEvent(event)
	if ( event == "ACTIONBAR_PAGE_CHANGED" ) then
		CooldownCount_DoUpdate();
		return;
	end
	if ( event == "VARIABLES_LOADED" ) then
		Glim_CooldownCount_Register();
		if ( CooldownCount_Cosmos_Registered == 0 ) then
			CooldownCount_LoadOptions();
		end
		if ( CooldownCount_RogueStealth == 1 ) or ( UnitClass("player") ~= COOLDOWNCOUNT_CLASS_ROGUE ) then
			table.insert(CooldownCount_ButtonNames, "ShapeshiftButton");
			CooldownCount_RegenerateList();
		end
		return;
	end
end

function CooldownCount_Toggle_UseLongTimers(toggle)
	local oldvalue = CooldownCount_UseLongTimerDescriptions;
	local newvalue = toggle;
	if ( ( toggle ~= 1 ) and ( toggle ~= 0 ) ) then
		if (oldvalue == 1) then
			newvalue = 0;
		elseif ( oldvalue == 0 ) then
			newvalue = 1;
		else
			newvalue = 0;
		end
	end
	CooldownCount_UseLongTimerDescriptions = newvalue;
	if ( newvalue ~= oldvalue ) then
		if ( newvalue == 1 ) then
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_USELONGTIMERS_ENABLED);
		else
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_USELONGTIMERS_DISABLED);
		end
	end
end

-- Toggles the enabled/disabled state of the CooldownCount
--  if toggle is 1, it's enabled
--  if toggle is 0, it's disabled
--   otherwise, it's toggled
function CooldownCount_Toggle_Enabled(toggle)
	local oldvalue = CooldownCount_Enabled;
	local newvalue = toggle;
	if ( ( toggle ~= 1 ) and ( toggle ~= 0 ) ) then
		if (oldvalue == 1) then
			newvalue = 0;
		elseif ( oldvalue == 0 ) then
			newvalue = 1;
		else
			newvalue = 0;
		end
	end
	CooldownCount_Enabled = newvalue;
	CooldownCount_Setup_Hooks(newvalue);
	if ( newvalue ~= oldvalue ) then
		if ( newvalue == 1 ) then
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_ENABLED);
		else
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_DISABLED);
		end
	end
	CooldownCount_Register_Cosmos();
end

function CooldownCount_Toggle_RogueStealth(toggle)
	local oldvalue = CooldownCount_RogueStealth;
	local newvalue = toggle;
	if ( ( toggle ~= 1 ) and ( toggle ~= 0 ) ) then
		if (oldvalue == 1) then
			newvalue = 0;
		elseif ( oldvalue == 0 ) then
			newvalue = 1;
		else
			newvalue = 0;
		end
	end
	CooldownCount_RogueStealth = newvalue;
	if ( newvalue ~= oldvalue ) then
		if ( newvalue == 1 ) then
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_ROGUE_STEALTH_ENABLED);
		else
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_ROGUE_STEALTH_DISABLED);
		end
	end
	local index = nil;
	local value = "ShapeshiftButton";
	for k, v in CooldownCount_ButtonNames do
		if ( v == value ) then
			index = k;
			break;
		end
	end
	if ( CooldownCount_RogueStealth == 1 ) then
		if ( not index ) then
			table.insert(CooldownCount_ButtonNames, value);
			CooldownCount_RegenerateList();
		end
	else
		if ( index ) then
			table.remove(CooldownCount_ButtonNames, index);
			CooldownCount_RegenerateList();
		end
	end
	CooldownCount_Register_Cosmos();
end

function CooldownCount_Toggle_NoSpaces(toggle)
	local oldvalue = CooldownCount_NoSpaces;
	local newvalue = toggle;
	if ( ( toggle ~= 1 ) and ( toggle ~= 0 ) ) then
		if (oldvalue == 1) then
			newvalue = 0;
		elseif ( oldvalue == 0 ) then
			newvalue = 1;
		else
			newvalue = 0;
		end
	end
	CooldownCount_NoSpaces = newvalue;
	if ( newvalue ~= oldvalue ) then
		if ( newvalue == 1 ) then
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_NOSPACES_ENABLED);
		else
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_NOSPACES_DISABLED);
		end
		CooldownCount_DoUpdate();
	end
	CooldownCount_Register_Cosmos();
end

function CooldownCount_Set_Alpha(value, quiet)
	local oldvalue = CooldownCountOptions.alpha;
	local newvalue = value;
	CooldownCountOptions.alpha = newvalue;
	if ( newvalue ~= oldvalue ) then
		if ( not quiet ) then
			CooldownCount_Print(string.format(COOLDOWNCOUNT_CHAT_ALPHA_FORMAT), newvalue);
		end
		CooldownCount_DoUpdate(true);
	end
	CooldownCount_Register_Cosmos();
end

function CooldownCount_Set_NormalColor(r, g, b, quiet)
	local arr = nil;
	if ( type(r) == "table" ) then
		arr = r;
		quiet = g;
	else
		arr = { r, g, b };
	end
	local changed = false;
	for k, v in CooldownCountOptions.color.normal do
		if ( arr[k] ~= v ) then
			changed = true;
			break;
		end
	end
	if ( changed ) then
		CooldownCountOptions.color.normal = arr;
		if ( not quiet ) then
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_NORMAL_COLOR_SET);
		end
		CooldownCount_DoUpdate(true);
	end
	CooldownCount_Register_Cosmos();
end

function CooldownCount_Set_FlashColor(r, g, b, quiet)
	local arr = nil;
	if ( type(r) == "table" ) then
		arr = r;
		quiet = g;
	else
		arr = { r, g, b };
	end
	local changed = false;
	for k, v in CooldownCountOptions.color.flash do
		if ( arr[k] ~= v ) then
			changed = true;
			break;
		end
	end
	if ( changed ) then
		CooldownCountOptions.color.flash = arr;
		if ( not quiet ) then
			CooldownCount_Print(COOLDOWNCOUNT_CHAT_FLASH_COLOR_SET);
		end
		CooldownCount_DoUpdate(true);
	end
	CooldownCount_Register_Cosmos();
end

-- Prints out text to a chat box.
function CooldownCount_Print(msg,r,g,b,frame,id,unknown4th)
	if(unknown4th) then
		local temp = id;
		id = unknown4th;
		unknown4th = id;
	end
				
	if (not r) then r = 1.0; end
	if (not g) then g = 1.0; end
	if (not b) then b = 1.0; end
	if ( frame ) then 
		frame:AddMessage(msg,r,g,b,id,unknown4th);
	else
		if ( DEFAULT_CHAT_FRAME ) then 
			DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b,id,unknown4th);
		end
	end
end


function CooldownCount_CosmosColorNilFunc(u,b,c)
	if (gLimConfigSubFrame) then
		gLimConfigSubFrame:Show();
	end
end

function CooldownCount_CosmosOpacity()
	local alpha = OpacitySliderFrame:GetValue();
	CooldownCount_Set_Alpha(alpha);
end

function CooldownCount_NormalColorSetButton(notCosmos)
	ColorPickerFrame.func = CooldownCount_CosmosNormalColorSet;
	ColorPickerFrame.cancelFunc = CooldownCount_CosmosColorNilFunc;
	ColorPickerFrame.hasOpacity = false;
	--ColorPickerFrame.opacityFunc = CooldownCount_CosmosOpacity;
	local red, green, blue = unpack(CooldownCountOptions.color.normal);
	ColorPickerFrame:SetColorRGB(red, green, blue);
	ColorPickerFrame.previousValues = {r = red, g = green, b = blue, opacity = 1};
	if ( CosmosMasterFrame ) then
		CosmosMasterFrame:Hide();
	end
	ColorPickerFrame:Show();
end
function CooldownCount_NormalColorResetButton()
	local r, g, b = unpack(CooldownCountColorDefaultNormal);
	CooldownCountOptions.color.normal = { r, g, b};
end

function CooldownCount_NormalColorSet()
	local r,g,b = ColorPickerFrame:GetColorRGB();
	CooldownCountOptions.color.normal = { r, g, b};
end

function CooldownCount_CosmosNormalColorSet()
	CooldownCount_NormalColorSet();
	if(not ColorPickerFrame:IsVisible()) then
		if (gLimConfigSubFrame) then
			gLimConfigSubFrame:Show();
		end
	end
end

function CooldownCount_FlashColorSetButton()
	ColorPickerFrame.func = CooldownCount_CosmosFlashColorSet;
	ColorPickerFrame.cancelFunc = CooldownCount_CosmosColorNilFunc;
	ColorPickerFrame.hasOpacity = false;
	local red, green, blue = unpack(CooldownCountOptions.color.flash);
	ColorPickerFrame:SetColorRGB(red, green, blue);
	ColorPickerFrame.previousValues = {r = red, g = green, b = blue, opacity = 1};
	if ( CosmosMasterFrame ) then
		CosmosMasterFrame:Hide();
	end
	ColorPickerFrame:Show();
end

function CooldownCount_FlashColorResetButton()
	local r, g, b = unpack(CooldownCountColorDefaultFlash);
	CooldownCountOptions.color.flash = { r, g, b};
end

function CooldownCount_FlashColorSet()
	local r,g,b = ColorPickerFrame:GetColorRGB();
	CooldownCountOptions.color.flash = { r, g, b};
end

function CooldownCount_CosmosFlashColorSet()
	CooldownCount_FlashColorSet();
	if(not ColorPickerFrame:IsVisible()) then
		if ( CosmosMasterFrame ) then
			CosmosMasterFrame:Show();
		end
	end
end

⌨️ 快捷键说明

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