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

📄 tipbuddy_optionsframe.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 4 页
字号:
	end
--	local frame = getglobal( this:GetName() );
	--PanelTemplates_SetTab( TipBuddy_OptionsFrame_PlayersFrame, index );
	TipBuddy_OptionsFrame_General_Options:Hide();
	TipBuddy_OptionsFrame_Compact_Options:Hide();
	PlaySound("igCharacterInfoTab");
	if ( index == 1 ) then
		TipBuddy_OptionsFrame_General_Options:Show();
		TipBuddy_OptionsFrame_GeneralOptionsTitleText:SetTextColor(1.0, 1.0, 1.0);
		TipBuddy_OptionsFrame_CompactOptionsTitleText:SetTextColor(0.3, 0.3, 0.1);
	elseif ( index == 2 ) then
		TipBuddy_OptionsFrame_Compact_Options:Show();
		TipBuddy_OptionsFrame_CompactOptionsTitleText:SetTextColor(1.0, 1.0, 1.0);
		TipBuddy_OptionsFrame_GeneralOptionsTitleText:SetTextColor(0.3, 0.3, 0.1);
	end
end

--------------------------------------------------------------------------------------------------------------------------------------
-- FRAME BACKGROUND COLOR PICKER
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_Background_ColorPick_OnLoad()
	cInfo = {};
end

function TipBuddy_Background_ColorPick( button )

	local name = getglobal( button:GetName() );
	local id = name:GetID();
	cInfo.type = TipBuddy_ColorPicker_Buttons[id].type;
	cInfo.var = TipBuddy_ColorPicker_Buttons[id].var;

	local targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];	
	if (not targettype) then
		TipBuddy_SavedVars[cInfo.type][cInfo.var] = { ["r"] = 0.8, ["g"] = 0.8, ["b"] = 0.9, ["a"] = 1, };
		targettype = TipBuddy_SavedVars[value.type][value.var];	
	end
TB_AddMessage("frame: "..button:GetName());
TB_AddMessage("type: "..TEXT(cInfo.type));
	TBColorPickerFrame.func = TipBuddy_Background_SetColor;
	TBColorPickerFrame.hasOpacity = 1;
	TBColorPickerFrame.opacityFunc = TipBuddy_Background_SetOpacity;
	TBColorPickerFrame.cancelFunc = TipBuddy_Background_Cancel;

	TBColorPickerFrame:SetColorRGB( targettype.r, targettype.g, targettype.b);
	TBColorPickerFrame.opacity = (1- targettype.a);
	TBColorPickerFrame.previousValues = {r=targettype.r, g=targettype.g, b=targettype.b, opacity=targettype.a};

	ShowUIPanel(TBColorPickerFrame);
	TB_AddMessage("just passed ShowUIPanel");
end

function TipBuddy_Text_ColorPick( button )

	local name = getglobal( button:GetName() );
	local id = name:GetID();
	cInfo.type = TipBuddy_ColorPicker_Buttons_Text[id].type;
	cInfo.var = TipBuddy_ColorPicker_Buttons_Text[id].var;

	local targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];	

--TB_AddMessage("frame: "..cInfo.name);
--TB_AddMessage("type: "..type);
	TBColorPickerFrame_Text.func = TipBuddy_Background_SetColor_Text;
	--TBColorPickerFrame_Text.hasOpacity = 1;
	--TBColorPickerFrame_Text.opacityFunc = TipBuddy_Background_SetOpacity;
	TBColorPickerFrame_Text.cancelFunc = TipBuddy_Background_Cancel;

	TBColorPickerFrame_Text:SetColorRGB( targettype.r, targettype.g, targettype.b);
	--TBColorPickerFrame_Text.opacity = (1- targettype.bgcolor.a);
	TBColorPickerFrame_Text.previousValues = {r=targettype.r, g=targettype.g, b=targettype.b, opacity=targettype.a};

	ShowUIPanel(TBColorPickerFrame_Text);
	TB_AddMessage("just passed ShowUIPanel");
end

function TipBuddy_OptionsFrame_UpdateColorButtons()
	for index, value in TipBuddy_ColorPicker_Buttons do
		TB_AddMessage(getn(TipBuddy_ColorPicker_Buttons));
		TB_AddMessage(index);
		local button = getglobal( value.frame );
		local swatch = getglobal( value.frame.."NormalTexture");
		local string = getglobal( value.frame.."Text");
--		local type = getglobal( value.type );
		TB_AddMessage("Color: ["..value.type.."]["..value.var.."]");
		
		if (not button) then
			return;
		end
			
		local targettype = TipBuddy_SavedVars[value.type][value.var];

		if (not targettype) then
			TipBuddy_SavedVars[value.type][value.var] = { ["r"] = 0.8, ["g"] = 0.8, ["b"] = 0.9, ["a"] = 1, };
			targettype = TipBuddy_SavedVars[value.type][value.var];	
		end

		string:SetText(TEXT(value.text));
		if (value.text) then
			--TB_AddMessage("frame:"..TEXT(value.frame).."colorbutton text: "..value.text);	
		end
		button.tooltipText = value.tooltipText;
		button.tooltipRequirement = value.tooltipRequirement;
		swatch:SetVertexColor( targettype.r, targettype.g, targettype.b );
		if (index < 10 or index == 21) then
			if (button:IsVisible()) then
				button:GetParent():SetBackdropColor( targettype.r, targettype.g, targettype.b, TB_NoNegative(targettype.a-0.2) );				
			else
				button:GetParent():SetBackdropColor( 0.2, 0.2, 0.2, 1 );								
			end
		elseif (index > 10 and index < 20 or index == 22) then
			if (button:IsVisible()) then
				button:GetParent():SetBackdropBorderColor( targettype.r, targettype.g, targettype.b, TB_NoNegative(targettype.a-0.2) );
			else
				button:GetParent():SetBackdropBorderColor( 0.8, 0.8, 0.9, 1 );
			end
		end

	end
end

function TipBuddy_OptionsFrame_UpdateColorButtons_Text()
	for index, value in TipBuddy_ColorPicker_Buttons_Text do
		local button = getglobal( value.frame );
		local swatch = getglobal( value.frame.."NormalTexture");
		local string = getglobal( value.frame.."Text");
--		local type = getglobal( value.type );
		--TB_AddMessage("Color: ["..value.type.."]["..value.var.."]");
		
		if (not button) then
			return;
		end
			
		local targettype = TipBuddy_SavedVars[value.type][value.var];

		string:SetText(TEXT(value.text));
		button.tooltipText = value.tooltipText;
		button.tooltipRequirement = value.tooltipRequirement;
		swatch:SetVertexColor( targettype.r, targettype.g, targettype.b );
		string:SetTextColor(targettype.r, targettype.g, targettype.b);
	end
end


function TipBuddy_Background_SetColor()
	local targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];

	local r,g,b = TBColorPickerFrame:GetColorRGB();
--	TipBuddy_Main_Frame:SetBackdropColor(r, g, b);

	if (not targettype) then
		TipBuddy_SavedVars[cInfo.type][cInfo.var] = {};
		targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];
	end
	targettype.r = r;
	targettype.g = g;
	targettype.b = b;		
end

function TipBuddy_Background_SetColor_Text()
	local targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];

	local r,g,b = TBColorPickerFrame_Text:GetColorRGB();
--	TipBuddy_Main_Frame:SetBackdropColor(r, g, b);

	targettype.r = r;
	targettype.g = g;
	targettype.b = b;		
end

function TipBuddy_Background_SetOpacity()
	local targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];

	local alpha = 1.0 - TBOpacitySliderFrame:GetValue();
	if (not targettype) then
		targettype = {};
	end
	targettype.a = (1- TBOpacitySliderFrame:GetValue());
end

function TipBuddy_Background_Cancel(previousValues)
	local targettype = TipBuddy_SavedVars[cInfo.type][cInfo.var];

	if (not targettype) then
		targettype = {};
	end
	if (previousValues.r and previousValues.g and previousValues.b) then
		targettype.r = previousValues.r;
		targettype.g = previousValues.g;
		targettype.b = previousValues.b;
	end
	if (previousValues.opacity) then
		local alpha = 1.0 - previousValues.opacity;
		targettype.a = previousValues.opacity;
	end
end


TipBuddy_CursorPos = {
	[1] = "上",
	[2] = "右",
	[3] = "左",
	[4] = "下", 
};

function TipBuddy_CursorPosDropDown_OnLoad()
	UIDropDownMenu_Initialize(this, TipBuddy_CursorPosDropDown_Initialize);
	UIDropDownMenu_SetSelectedValue(this, TipBuddy_SavedVars["general"].cursorpos);
	UIDropDownMenu_SetWidth(120, TipBuddy_CursorPosDropDown);
end

function TipBuddy_CursorPosDropDown_OnClick()
	UIDropDownMenu_SetSelectedValue(TipBuddy_CursorPosDropDown, this.value);
	TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset();
	TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos();
	if (TipBuddy_SavedVars["general"].anchored == 1) then
		TipBuddy_Parent_Frame:SetPoint(TipBuddy.anchor, "TipBuddy_Header_Frame", TipBuddy.fanchor, 0, 0);
	end
	TipBuddy_SetFrame_Anchor( TipBuddy_Main_Frame );
	GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
end

function TipBuddy_CursorPosDropDown_Initialize()
	local selectedValue = UIDropDownMenu_GetSelectedValue(TipBuddy_CursorPosDropDown);
	local info;

	info = {};
	info.text = TipBuddy_CursorPos[1];
	info.func = TipBuddy_CursorPosDropDown_OnClick;
	info.value = "Top";
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "提示將位于你的鼠標上方";
	UIDropDownMenu_AddButton(info);

	info = {};
	info.text = TipBuddy_CursorPos[2];
	info.func = TipBuddy_CursorPosDropDown_OnClick;
	info.value = "Right";
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "提示將位于你的鼠標右方";
	UIDropDownMenu_AddButton(info);

	info = {};
	info.text = TipBuddy_CursorPos[3];
	info.func = TipBuddy_CursorPosDropDown_OnClick;
	info.value = "Left";
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "提示將位于你的鼠標左方";
	UIDropDownMenu_AddButton(info);

	info = {};
	info.text = TipBuddy_CursorPos[4];
	info.func = TipBuddy_CursorPosDropDown_OnClick;
	info.value = "Bottom";
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "提示將位于你的鼠標下方";
	UIDropDownMenu_AddButton(info);
end

--non-unit tips
TipBuddy_NonUnitTipPos = {
	[1] = "跟隨鼠標",
	[2] = "TipBuddy定位器",
	[3] = "智能定位", 
};

function TipBuddy_NonUnitTipPosDropDown_OnLoad()
	UIDropDownMenu_Initialize(this, TipBuddy_NonUnitTipPosDropDown_Initialize);
	UIDropDownMenu_SetSelectedValue(this, TipBuddy_SavedVars["general"].nonunit_anchor);
	UIDropDownMenu_SetWidth(120, TipBuddy_NonUnitTipPosDropDown);
end

function TipBuddy_NonUnitTipPosDropDown_OnClick()
	UIDropDownMenu_SetSelectedValue(TipBuddy_NonUnitTipPosDropDown, this.value);
	TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset();
	TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos();
	GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
	--if (UIDropDownMenu_GetSelectedValue(TipBuddy_NonUnitTipPosDropDown)) then
		TipBuddy_SavedVars["general"].nonunit_anchor = this.value;	
	--end
	--/script DEFAULT_CHAT_FRAME:AddMessage(UIDropDownMenu_GetSelectedValue(TipBuddy_NonUnitTipPosDropDown));
	--/script DEFAULT_CHAT_FRAME:AddMessage(TipBuddy_SavedVars["general"].nonunit_anchor);
end

function TipBuddy_NonUnitTipPosDropDown_Initialize()
	local selectedValue = UIDropDownMenu_GetSelectedValue(TipBuddy_NonUnitTipPosDropDown);
	local info;

	info = {};
	info.text = TipBuddy_NonUnitTipPos[1];
	info.func = TipBuddy_NonUnitTipPosDropDown_OnClick;
	info.value = 0;
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "非單位目標提示\n將會跟隨你的鼠標";
	UIDropDownMenu_AddButton(info);

	info = {};
	info.text = TipBuddy_NonUnitTipPos[2];
	info.func = TipBuddy_NonUnitTipPosDropDown_OnClick;
	info.value = 1;
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "非單位目標提示將會\n吸附于TipBuddy定位器";
	UIDropDownMenu_AddButton(info);

	info = {};
	info.text = TipBuddy_NonUnitTipPos[3];
	info.func = TipBuddy_NonUnitTipPosDropDown_OnClick;
	info.value = 2;
	if ( info.value == selectedValue ) then
		info.checked = 1;
	end
	info.tooltipTitle = "非單位目標提示將會\n嘗試智能吸附于你鼠標\n懸停按鈕或物體上";
	UIDropDownMenu_AddButton(info);

end

--Tooltip Style (Compact, Default, Advanced)
TipBuddy_TipStyle = {
	[1] = "默認模式",
	[2] = "簡潔模式",
	[3] = "編輯模式", 
};

⌨️ 快捷键说明

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