📄 tipbuddy_optionsframe.lua
字号:
info.checked = 1;
end
info.tooltipTitle = "Color will be determined\nby the unit's difficulty\n(red, yellow, grey, etc).";
UIDropDownMenu_AddButton(info);
info = {};
info.text = TipBuddy_BDBColor[3];
info.func = TipBuddy_BDBColorDropDown_OnClick;
info.value = 2;
info.owner = this:GetParent();
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "Color is determined by th\n unit's reaction towards you.";
UIDropDownMenu_AddButton(info);
end
---------------------------------------------------------------
-- SAVING FRAME POSITION AFTER DRAGGED
---------------------------------------------------------------
-- this function is called when the frame should be dragged around
function TipBuddy_OnMouseDown(arg1)
if (arg1 == "LeftButton") then
TipBuddy_Header_Frame:StartMoving();
end
end
-- this function is called when the frame is stopped being dragged around
function TipBuddy_OnMouseUp(arg1)
if (arg1 == "LeftButton") then
TipBuddy_Header_Frame:StopMovingOrSizing();
-- save the position
TipBuddy_SavedVars["general"].framepos_L = TipBuddy_Header_Frame:GetLeft();
TipBuddy_SavedVars["general"].framepos_T = TipBuddy_Header_Frame:GetTop();
end
-- If Rightclick bring up the options menu
if ( arg1 == "RightButton" ) then
ToggleDropDownMenu(1, TipBuddy_SavedVars["general"].anchor_pos, TipBuddy_Header_FrameDropDown, this:GetName(), 0, 0);
UIDropDownMenu_SetSelectedValue(this, TipBuddy_SavedVars["general"].anchor_pos);
return;
end
-- Close all dropdowns
CloseDropDownMenus();
end
function TipBuddy_ResetAnchorPos()
TipBuddy_Header_Frame:Hide();
TipBuddy_Header_Frame:Show();
TipBuddy_Header_Frame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", 202, 400);
TipBuddy_SavedVars["general"].framepos_L = TipBuddy_Header_Frame:GetLeft();
TipBuddy_SavedVars["general"].framepos_T = TipBuddy_Header_Frame:GetTop();
end
TipBuddy_AnchorPos = {
[1] = "Top Right",
[2] = "Top Left",
[3] = "Bottom Right",
[4] = "Bottom Left",
[5] = "Top Center",
[6] = "Bottom Center",
};
function TipBuddy_Anchor_OnClick(button)
-- If Rightclick bring up the options menu
if ( button == "RightButton" ) then
ToggleDropDownMenu(0, TipBuddy_SavedVars["general"].anchor_pos, TipBuddy_Header_FrameDropDown, this:GetName(), 0, 0);
return;
end
-- Close all dropdowns
CloseDropDownMenus();
end
function TipBuddy_AnchorDropDown_OnLoad()
UIDropDownMenu_Initialize(this, TipBuddy_AnchorDropDown_Initialize, "MENU");
-- TipBuddy_SavedVars["general"]["anchor_pos"] = TipBuddy_AnchorPos[1];
-- UIDropDownMenu_SetSelectedValue(this, nil, TipBuddy_SavedVars["general"]["anchor_pos"]);
UIDropDownMenu_SetButtonWidth(50);
UIDropDownMenu_SetWidth(80);
end
-- /script TB_AddMessage( TipBuddy_SavedVars["general"]["anchor_pos"] );
function TipBuddy_AnchorDropDown_OnClick()
UIDropDownMenu_SetSelectedValue(TipBuddy_Header_FrameDropDown, this.value);
-- TB_AddMessage( UIDropDownMenu_GetSelectedValue(TipBuddy_Header_FrameDropDown) );
TipBuddy_SavedVars["general"].anchor_pos = UIDropDownMenu_GetSelectedValue(TipBuddy_Header_FrameDropDown);
TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset();
TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos();
TipBuddy_SetFrame_Anchor( TipBuddy_Main_Frame );
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
end
function TipBuddy_AnchorDropDown_Initialize()
local selectedValue = UIDropDownMenu_GetSelectedValue(TipBuddy_Header_FrameDropDown);
local info;
info = {};
info.text = "右上";
info.func = TipBuddy_AnchorDropDown_OnClick;
info.value = TipBuddy_AnchorPos[1];
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "提示位于TipBuddy定位器右上";
UIDropDownMenu_AddButton(info);
info = {};
info.text = "左上";
info.func = TipBuddy_AnchorDropDown_OnClick;
info.value = TipBuddy_AnchorPos[2];
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "提示位于TipBuddy定位器左上";
UIDropDownMenu_AddButton(info);
info = {};
info.text = "右下";
info.func = TipBuddy_AnchorDropDown_OnClick;
info.value = TipBuddy_AnchorPos[3];
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "提示位于TipBuddy定位器右下";
UIDropDownMenu_AddButton(info);
info = {};
info.text = "左下";
info.func = TipBuddy_AnchorDropDown_OnClick;
info.value = TipBuddy_AnchorPos[4];
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "提示位于TipBuddy定位器左下";
UIDropDownMenu_AddButton(info);
info = {};
info.text = "中上";
info.func = TipBuddy_AnchorDropDown_OnClick;
info.value = TipBuddy_AnchorPos[5];
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "提示位于TipBuddy定位器中上";
UIDropDownMenu_AddButton(info);
info = {};
info.text = "中下";
info.func = TipBuddy_AnchorDropDown_OnClick;
info.value = TipBuddy_AnchorPos[6];
if ( info.value == selectedValue ) then
info.checked = 1;
end
info.tooltipTitle = "提示位于TipBuddy定位器中下";
UIDropDownMenu_AddButton(info);
end
function TipBuddy_SetAnchorFrameVis()
if (TipBuddy_SavedVars["general"].anchored == 1) then
if (not TipBuddy_SavedVars["general"].anchor_vis_first or TipBuddy_SavedVars["general"].anchor_vis == 1) then
TipBuddy_SavedVars["general"].anchor_vis_first = 1;
TipBuddy_Header_Frame:Show();
else
TipBuddy_Header_Frame:Show();
TipBuddy_Header_Frame:Hide();
end
else
if (TipBuddy_Header_Frame:IsVisible()) then
TipBuddy_Header_Frame:Show();
else
TipBuddy_Header_Frame:Show();
TipBuddy_Header_Frame:Hide();
end
end
end
---------------------------------------------------------------
-- SAVING DATA AFTER 'OK'
---------------------------------------------------------------
function TipBuddy_OptionsFrame_OnSave()
-- Checkboxes
for index, value in TB_Op_Checks do
local button = getglobal( value.frame );
local but = value.frame; --debug
local tipTable = TipBuddy_SavedVars[value.type];
--tipTable.vartype = getglobal( value.var );
if ( button:GetChecked() ) then
--TB_AddMessage( "button: "..but.." is checked.");
tipTable[value.var] = 1;
--TB_AddMessage( "Setting button: "..but.." checked ("..tipTable[value.var]..").");
else
tipTable[value.var] = 0;
end
end
-- Sliders
for index, value in TipBuddy_OptionsFrame_Sliders do
local tipTable = TipBuddy_SavedVars["general"];
local slider = getglobal("TipBuddy_OptionsFrame_Slider"..index);
--if (index == 6) then
-- tipTable[value.var] = (UIParent:GetScale() * slider:GetValue());
--else
tipTable[value.var] = slider:GetValue();
--end
end
-- EditBoxes
for index, value in TB_EditBoxes do
local editbox = getglobal( value.frame );
local tipTable = TipBuddy_SavedVars[value.type];
--tipTable.vartype = getglobal( value.var );
tipTable[value.var] = editbox:GetText();
end
TipBuddy_SetAnchorFrameVis();
if (UIDropDownMenu_GetSelectedValue(TipBuddy_CursorPosDropDown)) then
TipBuddy_SavedVars["general"].cursorpos = UIDropDownMenu_GetSelectedValue(TipBuddy_CursorPosDropDown);
else
TB_AddMessage("|cff3366ffTipBuddy_CursorPosDropDown is nil");
end
if (UIDropDownMenu_GetSelectedValue(TipBuddy_NonUnitTipPosDropDown)) then
TipBuddy_SavedVars["general"].nonunit_anchor = UIDropDownMenu_GetSelectedValue(TipBuddy_NonUnitTipPosDropDown);
else
TB_AddMessage("|cff3366ffTipBuddy_NonUnitTipPosDropDown is nil");
end
if (UIDropDownMenu_GetSelectedValue(TB_PCFriend_TipStyleDropDown)) then
TipBuddy_SavedVars["pc_friend"].off = UIDropDownMenu_GetSelectedValue(TB_PCFriend_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_PCParty_TipStyleDropDown)) then
TipBuddy_SavedVars["pc_party"].off = UIDropDownMenu_GetSelectedValue(TB_PCParty_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_PCEnemy_TipStyleDropDown)) then
TipBuddy_SavedVars["pc_enemy"].off = UIDropDownMenu_GetSelectedValue(TB_PCEnemy_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_NPCFriend_TipStyleDropDown)) then
TipBuddy_SavedVars["npc_friend"].off = UIDropDownMenu_GetSelectedValue(TB_NPCFriend_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_NPCNeutral_TipStyleDropDown)) then
TipBuddy_SavedVars["npc_neutral"].off = UIDropDownMenu_GetSelectedValue(TB_NPCNeutral_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_NPCEnemy_TipStyleDropDown)) then
TipBuddy_SavedVars["npc_enemy"].off = UIDropDownMenu_GetSelectedValue(TB_NPCEnemy_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_PETFriend_TipStyleDropDown)) then
TipBuddy_SavedVars["pet_friend"].off = UIDropDownMenu_GetSelectedValue(TB_PETFriend_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_PETEnemy_TipStyleDropDown)) then
TipBuddy_SavedVars["pet_enemy"].off = UIDropDownMenu_GetSelectedValue(TB_PETEnemy_TipStyleDropDown);
end
if (UIDropDownMenu_GetSelectedValue(TB_CORPSE_TipStyleDropDown)) then
TipBuddy_SavedVars["corpse"].off = UIDropDownMenu_GetSelectedValue(TB_CORPSE_TipStyleDropDown);
end
TipBuddy_Variable_Initialize();
TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset();
TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos();
TipBuddy.uiScale = TipBuddy_GetUIScale();
local x, y = TipBuddy_PositionFrameToCursor();
x = (x / TipBuddy.uiScale);
y = (y / TipBuddy.uiScale);
if (TipBuddy_SavedVars["general"].anchored == 1) then
TipBuddy_Parent_Frame:SetPoint(TipBuddy.anchor, "TipBuddy_Header_Frame", TipBuddy.fanchor, 0, 0);
else
TipBuddy_Parent_Frame:SetPoint(TipBuddy.xpoint, "UIParent", "BOTTOMLEFT", x, y);
end
TipBuddy_SetFrame_Anchor( TipBuddy_Main_Frame );
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);
end
-------------------------
---- SAVE FRAME POSITION
-------------------------
-- this function is called when the frame should be dragged around
function TB_Options_OnMouseDown(arg1)
if (arg1 == "LeftButton") then
TipBuddy_OptionsFrame:StartMoving();
end
end
-- this function is called when the frame is stopped being dragged around
function TB_Options_OnMouseUp(arg1)
if (arg1 == "LeftButton") then
TipBuddy_OptionsFrame:StopMovingOrSizing();
-- save the position
TipBuddy_SavedVars["general"].opPos_L = TipBuddy_OptionsFrame:GetLeft();
TipBuddy_SavedVars["general"].opPos_T = TipBuddy_OptionsFrame:GetTop();
end
end
function TipBuddy_ClickResetVarsButton()
StaticPopupDialogs["TIPBUDDY_RESETVARS"] = {
text = TEXT(TB_RESETVARS_DIALOG),
button1 = TEXT(ACCEPT),
button2 = TEXT(DECLINE),
OnAccept = function()
TipBuddy_ResetAllVariables();
end,
OnCancel = function()
this:Hide();
end,
timeout = 60,
whileDead = 1
};
StaticPopup_Show("TIPBUDDY_RESETVARS");
end
function TipBuddy_ResetAllVariables()
TipBuddy_SavedVars.version = 0;
TipBuddy_SavedVars = { };
TipBuddy_Variable_Initialize();
TipBuddy_OptionsFrame_UpdateCheckboxes();
TipBuddy_OptionsFrame_UpdateSliders();
--TipBuddy_OptionsFrame_UpdateGreyed();
TipBuddy_OptionsFrame_UpdateColorButtons();
TipBuddy_OptionsFrame_UpdateColorButtons_Text();
TipBuddy_Background_ColorPick_OnLoad();
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -