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

📄 monkeybuddy.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
		
		if (MonkeyBuddyConfig == nil) then
			MonkeyBuddyConfig = {};
			MonkeyBuddyConfig.m_bDismissed = false;
		end
		
		if (MonkeyBuddyConfig.m_bDismissed == true) then
			MonkeyBuddyIconButton:Hide();
		else
			MonkeyBuddyIconButton:Show();
		end
		
		-- print out a nice message letting the user know the addon loaded
		if (DEFAULT_CHAT_FRAME) then
			--DEFAULT_CHAT_FRAME:AddMessage(MONKEYBUDDY_LOADED_MSG);
		end
	end
end

function MonkeyBuddyIconButton_OnClick()
	ShowUIPanel(MonkeyBuddyFrame);
end

function MonkeyBuddy_ToggleDisplay()
	if (MonkeyBuddyFrame:IsVisible()) then
		HideUIPanel(MonkeyBuddyFrame);
	else
		ShowUIPanel(MonkeyBuddyFrame);
	end
end

function MonkeyBuddyQuestTab_OnClick()
	if (MonkeyQuest ~= nil) then
		if (MonkeyQuest.m_bLoaded == true) then
			MonkeyBuddySpeedFrame:Hide();
			MonkeyBuddyClockFrame:Hide();
	
			MonkeyBuddyQuestFrame:Show();
			PlaySound("igMainMenuOptionCheckBoxOn");
		end
	end
end

function MonkeyBuddySpeedTab_OnClick()
	if (MonkeySpeed ~= nil) then
		if (MonkeySpeed.m_bLoaded == true) then
			MonkeyBuddyQuestFrame:Hide();
			MonkeyBuddyClockFrame:Hide();
		
			MonkeyBuddySpeedFrame:Show();
			PlaySound("igMainMenuOptionCheckBoxOn");
		end
	end
end

function MonkeyBuddyClockTab_OnClick()
	if (MonkeyClock ~= nil) then
		if (MonkeyClock.m_bLoaded == true) then
			MonkeyBuddyQuestFrame:Hide();
			MonkeyBuddySpeedFrame:Hide();
			
			MonkeyBuddyClockFrame:Show();
			PlaySound("igMainMenuOptionCheckBoxOn");
		end
	end
end

function MonkeyBuddyQuestFrame_OnShow()
	if (MonkeyQuest ~= nil) then
		if (MonkeyQuest.m_bLoaded == true) then
			MonkeyBuddyQuestTabTexture:Show();
			MonkeyBuddyQuestTab:SetBackdropBorderColor(1, 1, 1, 1);
			MonkeyBuddyQuestFrame_Refresh();
		else
			MonkeyBuddyQuestTabTexture:Hide();
			MonkeyBuddyQuestFrame:Hide();
		end
	else
		MonkeyBuddyQuestTabTexture:Hide();
		MonkeyBuddyQuestFrame:Hide();
	end
end

function MonkeyBuddySpeedFrame_OnShow()
	if (MonkeySpeed ~= nil) then
		if (MonkeySpeed.m_bLoaded == true) then
			MonkeyBuddySpeedTabTexture:Show();
			MonkeyBuddySpeedTab:SetBackdropBorderColor(1, 1, 1, 1);
			MonkeyBuddySpeedFrame_Refresh();
		else
			MonkeyBuddySpeedTabTexture:Hide();
			MonkeyBuddySpeedFrame:Hide();
		end
	else
		MonkeyBuddySpeedTabTexture:Hide();
		MonkeyBuddySpeedFrame:Hide();
	end
end

function MonkeyBuddyClockFrame_OnShow()
	if (MonkeyClock ~= nil) then
		if (MonkeyClock.m_bLoaded == true) then
			MonkeyBuddyClockTabTexture:Show();
			MonkeyBuddyClockTab:SetBackdropBorderColor(1, 1, 1, 1);
			MonkeyBuddyClockFrame_Refresh();
		else
			MonkeyBuddyClockTabTexture:Hide();
			MonkeyBuddyClockFrame:Hide();
		end
	else
		MonkeyBuddyClockTabTexture:Hide();
		MonkeyBuddyClockFrame:Hide();
	end
end

function MonkeyBuddyQuestFrame_OnHide()
	MonkeyBuddyQuestTabTexture:Hide();
	MonkeyBuddyQuestTab:SetBackdropBorderColor(0.25, 0.25, 0.25, 1.0);
end

function MonkeyBuddySpeedFrame_OnHide()
	MonkeyBuddySpeedTabTexture:Hide();
	MonkeyBuddySpeedTab:SetBackdropBorderColor(0.25, 0.25, 0.25, 1.0);
end

function MonkeyBuddyClockFrame_OnHide()
	MonkeyBuddyClockTabTexture:Hide();
	MonkeyBuddyClockTab:SetBackdropBorderColor(0.25, 0.25, 0.25, 1.0);
end

--Called when option page loads
function MonkeyBuddyQuestFrame_Refresh()
	-- Initial Values
	local button, string, checked, swatch, border, iAlpha, iRed, iGreen, iBlue;
	
	-- Setup check buttons
	for key, value in MonkeyBuddyQuest_CheckButtons do
		button = getglobal("MonkeyBuddyQuestCheck" .. value.id);
		string = getglobal("MonkeyBuddyQuestCheck" .. value.id .. "Text");
		checked = nil;
		button.disabled = nil;
		
		--Check Box
		if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer][value.strVar] == true) then
			checked = 1;
		else
			checked = 0;
		end
		
		button:SetChecked(checked);
		string:SetText(key);
		button.pSlashCommand = value.pSlashCommand;
		button.strModName = "MonkeyQuest";
	end
	
	-- Setup colour buttons
	for key, value in MonkeyBuddyQuest_ColourButtons do
		button = getglobal("MonkeyBuddyQuestColour" .. value.id);
		swatch = getglobal("MonkeyBuddyQuestColour" .. value.id .. "_SwatchTexture");
		border = getglobal("MonkeyBuddyQuestColour" .. value.id .. "_BorderTexture");
		string = getglobal("MonkeyBuddyQuestColour" .. value.id .. "Text");
		
		button.disabled = nil;
		
		--Color Swatch
		iAlpha, iRed, iGreen, iBlue = MonkeyLib_ColourStrToARGB(MonkeyQuestConfig[MonkeyQuest.m_strPlayer][value.strVar]);
		
		button.a = iAlpha;
		button.r = iRed;
		button.g = iGreen;
		button.b = iBlue;
		button.swatchFunc = MonkeyBuddyQuest_ColourCallback[value.id];
		button.cancelFunc = MonkeyBuddyQuest_ColourCancleCallback[value.id];
		
		swatch:SetVertexColor(iRed, iGreen, iBlue);
		border:SetVertexColor(iRed, iGreen, iBlue);
		
		button.id = value.id;
		button.strVar = value.strVar;
		string:SetText(key);
		
		button.strModName = "MonkeyQuest";
	end
	
	local slider, string, low, high;

	-- Setup Sliders
	for key, value in MonkeyBuddyQuest_Sliders do
		slider = getglobal("MonkeyBuddyQuestSlider"..value.id);
		string = getglobal("MonkeyBuddyQuestSlider"..value.id.."Text");
		low = getglobal("MonkeyBuddyQuestSlider"..value.id.."Low");
		high = getglobal("MonkeyBuddyQuestSlider"..value.id.."High");
		
		slider.id = value.id;
		slider.strVar = value.strVar;
		slider.pSlashCommand = value.pSlashCommand;
		
		--OptionsFrame_EnableSlider(slider);
		slider:SetMinMaxValues(value.minValue, value.maxValue);
		slider:SetValueStep(value.valueStep);
		slider:SetValue(MonkeyQuestConfig[MonkeyQuest.m_strPlayer][value.strVar]);
		string:SetText(key);
		low:SetText(value.minText);
		high:SetText(value.maxText);
		
		slider.strModName = "MonkeyQuest";
	end
end

function MonkeyBuddySpeedFrame_Refresh()
	
	-- Initial Values
	local button, string, checked;
	
	-- Setup check buttons
	for key, value in MonkeyBuddySpeed_CheckButtons do
		button = getglobal("MonkeyBuddySpeedCheck" .. value.id);
		string = getglobal("MonkeyBuddySpeedCheck" .. value.id .. "Text");
		checked = nil;
		button.disabled = nil;
		
		--Check Box
		if (MonkeySpeedConfig[MonkeySpeed.m_strPlayer][value.strVar] == true) then
			checked = 1;
		else
			checked = 0;
		end
		
		button:SetChecked(checked);
		string:SetText(key);
		button.pSlashCommand = value.pSlashCommand;
		button.strModName = "MonkeySpeed";
	end

	local slider, string, low, high;

	-- Setup Sliders
	for key, value in MonkeyBuddySpeed_Sliders do
		slider = getglobal("MonkeyBuddySpeedSlider"..value.id);
		string = getglobal("MonkeyBuddySpeedSlider"..value.id.."Text");
		low = getglobal("MonkeyBuddySpeedSlider"..value.id.."Low");
		high = getglobal("MonkeyBuddySpeedSlider"..value.id.."High");
		
		slider.id = value.id;
		slider.strVar = value.strVar;
		slider.pSlashCommand = value.pSlashCommand;
		
		--OptionsFrame_EnableSlider(slider);
		slider:SetMinMaxValues(value.minValue, value.maxValue);
		slider:SetValueStep(value.valueStep);
		slider:SetValue(MonkeySpeedConfig[MonkeySpeed.m_strPlayer][value.strVar]);
		string:SetText(key);
		low:SetText(value.minText);
		high:SetText(value.maxText);
		
		slider.strModName = "MonkeySpeed";
	end
end

function MonkeyBuddyClockFrame_Refresh()
	
	-- Initial Values
	local button, string, checked;
	
	-- Setup check buttons
	for key, value in MonkeyBuddyClock_CheckButtons do
		button = getglobal("MonkeyBuddyClockCheck" .. value.id);
		string = getglobal("MonkeyBuddyClockCheck" .. value.id .. "Text");
		checked = nil;
		button.disabled = nil;
		
		--Check Box
		if (MonkeyClockConfig[MonkeyClock.m_strPlayer][value.strVar] == true) then
			checked = 1;
		else
			checked = 0;
		end
		
		button:SetChecked(checked);
		string:SetText(key);
		button.pSlashCommand = value.pSlashCommand;
		button.strModName = "MonkeyClock";
	end
	
	-- Setup Sliders
	for key, value in MonkeyBuddyClock_Sliders do
		slider = getglobal("MonkeyBuddyClockSlider"..value.id);
		string = getglobal("MonkeyBuddyClockSlider"..value.id.."Text");
		low = getglobal("MonkeyBuddyClockSlider"..value.id.."Low");
		high = getglobal("MonkeyBuddyClockSlider"..value.id.."High");
		
		slider.id = value.id;
		slider.strVar = value.strVar;
		slider.pSlashCommand = value.pSlashCommand;
		
		--OptionsFrame_EnableSlider(slider);
		slider:SetMinMaxValues(value.minValue, value.maxValue);
		slider:SetValueStep(value.valueStep);
		slider:SetValue(MonkeyClockConfig[MonkeyClock.m_strPlayer][value.strVar]);
		string:SetText(key);
		low:SetText(value.minText);
		high:SetText(value.maxText);
		
		slider.strModName = "MonkeyClock";
	end
end

function MonkeyBuddyCheckButton_OnClick()
	local	bChecked;
	
	if (this:GetChecked()) then
		bChecked = true;
	else
		bChecked = false;
	end
	
	this.pSlashCommand(bChecked);
end

function MonkeyBuddyQuest_SetColour(id)
	local iRed, iGreen, iBlue = ColorPickerFrame:GetColorRGB();
	local swatch, button, border;
	
	
	button = getglobal("MonkeyBuddyQuestColour" .. id);
	swatch = getglobal("MonkeyBuddyQuestColour" .. id .. "_SwatchTexture");
	border = getglobal("MonkeyBuddyQuestColour" .. id .. "_BorderTexture");
	
	swatch:SetVertexColor(iRed, iGreen, iBlue);
	border:SetVertexColor(iRed, iGreen, iBlue);
	button.r = iRed;
	button.g = iGreen;
	button.b = iBlue;
	
	-- update MonkeyQuest
	MonkeyQuestConfig[MonkeyQuest.m_strPlayer][button.strVar] = MonkeyLib_ARGBToColourStr(1.0, iRed, iGreen, iBlue);
	
	MonkeyQuest_Refresh();
end

function MonkeyBuddyQuest_CancleColour(id)
	local iRed = ColorPickerFrame.previousValues.r;
	local iGreen = ColorPickerFrame.previousValues.g;
	local iBlue = ColorPickerFrame.previousValues.b;
	
	local swatch, button, border;
	
	
	button = getglobal("MonkeyBuddyQuestColour" .. id);
	swatch = getglobal("MonkeyBuddyQuestColour" .. id .. "_SwatchTexture");
	border = getglobal("MonkeyBuddyQuestColour" .. id .. "_BorderTexture");
	
	swatch:SetVertexColor(iRed, iGreen, iBlue);
	border:SetVertexColor(iRed, iGreen, iBlue);
	button.r = iRed;
	button.g = iGreen;
	button.b = iBlue;
	
	-- update MonkeyQuest
	MonkeyQuestConfig[MonkeyQuest.m_strPlayer][button.strVar] = MonkeyLib_ARGBToColourStr(1.0, iRed, iGreen, iBlue);
	
	MonkeyQuest_Refresh();
end

function MonkeyBuddySlider_OnValueChanged()

	-- update MonkeyMod
	if (this.strModName == "MonkeyQuest") then
		MonkeyQuestConfig[MonkeyQuest.m_strPlayer][this.strVar] = this:GetValue();
	end
	if (this.strModName == "MonkeySpeed") then
		MonkeySpeedConfig[MonkeySpeed.m_strPlayer][this.strVar] = this:GetValue();
	end
	if (this.strModName == "MonkeyClock") then
		MonkeyClockConfig[MonkeyClock.m_strPlayer][this.strVar] = this:GetValue();
	end
	
	this.pSlashCommand(this:GetValue());
	
	-- set the tool tip text
	if (this:GetValue() == floor(this:GetValue())) then
		GameTooltip:SetText(format("%d", this:GetValue()));
	else
		GameTooltip:SetText(format("%.2f", this:GetValue()));
	end
end

function MonkeyBuddySlider_OnEnter()
	-- put the tool tip in the default position
	GameTooltip:SetOwner(this, "ANCHOR_CURSOR");
	
	-- set the tool tip text
	if (this:GetValue() == floor(this:GetValue())) then
		GameTooltip:SetText(format("%d", this:GetValue()));
	else
		GameTooltip:SetText(format("%.2f", this:GetValue()));
	end
	
	GameTooltip:Show();
end

function MonkeyBuddySlider_OnLeave()
	GameTooltip:Hide();
end

⌨️ 快捷键说明

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