📄 tipbuddy_optionsframe.lua
字号:
--[[
TipBuddy: ---------
copyright 2005 by Chester
]]
--------------------------------------------------------------------------------------------------------------------------------------
-- OPTIONS FRAME
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_ToggleOptionsFrame()
if ( TipBuddy_OptionsFrame:IsVisible() ) then
HideUIPanel(TipBuddy_OptionsFrame);
PlaySound("gsTitleOptionExit");
-- Check if the options frame was opened by myAddOns
--[[ if (MYADDONS_ACTIVE_OPTIONSFRAME == this) then
ShowUIPanel(myAddOnsFrame);
else
ShowUIPanel(GameMenuFrame);
end]]
else
TipBuddy_OptionsFrame_UpdateCheckboxes();
TipBuddy_OptionsFrame_UpdateSliders();
TipBuddy_OptionsFrame_UpdateColorButtons();
TipBuddy_OptionsFrame_UpdateColorButtons_Text();
TipBuddy_OptionsFrame_UpdateEditBoxes();
TipBuddy_Background_ColorPick_OnLoad();
HideUIPanel(GameMenuFrame);
ShowUIPanel(TipBuddy_OptionsFrame);
PlaySound("igMainMenuQuit");
end
end
function TipBuddy_OptionsFrame_OnLoad()
TipBuddy_OptionsFrameHeaderText:SetText("TipBuddy選項");
TipBuddy_UpdateTabs_Initialize();
PanelTemplates_SetNumTabs(TipBuddy_OptionsFrame_PlayersFrame, 3);
PanelTemplates_SetNumTabs(TipBuddy_OptionsFrame_NPCsFrame, 3);
PanelTemplates_SetNumTabs(TipBuddy_OptionsFrame_PetsFrame, 2);
TipBuddy_HideOptionPanels();
TipBuddy_OptionsFrame_PlayersFrame:Show();
end
function LoadTipBuddyButtonTextures(name)
this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
this:RegisterEvent("UPDATE_BINDINGS");
local prefix = "Interface\\AddOns\\TipBuddy\\gfx\\UI-MicroButton-";
this:SetNormalTexture(prefix..name.."-Up");
this:SetPushedTexture(prefix..name.."-Down");
this:SetDisabledTexture(prefix..name.."-Disabled");
this:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight");
end
function TipBuddy_HideOptionPanels()
TipBuddy_OptionsFrame_PlayersFrame:Hide();
TipBuddy_OptionsFrame_NPCsFrame:Hide();
TipBuddy_OptionsFrame_PetsFrame:Hide();
TipBuddy_OptionsFrame_CORPSEFrame:Hide();
TipBuddy_OptionsFrame_General_Options:Hide();
TipBuddy_OptionsFrame_Anchoring_Options:Hide();
TipBuddy_OptionsFrame_Compact_Options:Hide();
end
---------------------------------------------------------------
-- UPDATING DUE TO CHECKBOXES
---------------------------------------------------------------
function TipBuddy_OptionsFrame_UpdateGreyed()
--[[
if ( TB_Op_Check1:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check1 );
end
if ( TB_Op_Check9:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check9 );
end
if ( TB_Op_Check17:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check17 );
end
if ( TB_Op_Check25:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check25 );
end
if ( TB_Op_Check33:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check33 );
end
if ( TB_Op_Check41:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check41 );
end
if ( TB_Op_Check49:GetChecked() ) then
TipBuddy_ToggleCheckboxFrame( TB_Op_Check49 );
end]]
if ( TB_Op_Check57:GetChecked() ) then
TB_Op_Check61:Disable();
getglobal("TB_Op_Check61Text"):SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
else
TB_Op_Check61:Enable();
getglobal("TB_Op_Check61Text"):SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
end
end
function TipBuddy_OptionsFrame_UpdateCheckboxes()
for index, value in TB_Op_Checks do
local button = getglobal( value.frame );
local string = getglobal( value.frame.."Text");
if (not button) then
return;
end
local tipTable = TipBuddy_SavedVars[value.type];
--TB_AddMessage(value.type);
button:SetChecked( tipTable[value.var] );
string:SetText( TEXT(value.text) );
button.tooltipText = value.tooltipText;
button.tooltipRequirement = value.tooltipRequirement;
button.gxRestart = value.gxRestart;
button.restartClient = value.restartClient;
if ( button.disabled ) then
button:Disable();
string:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
else
button:Enable();
string:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
end
end
end
function TipBuddy_OptionsFrame_UpdateSliders()
for index, value in TipBuddy_OptionsFrame_Sliders do
local slider = getglobal("TipBuddy_OptionsFrame_Slider"..index);
local string = getglobal("TipBuddy_OptionsFrame_Slider"..index.."Text");
local high = getglobal("TipBuddy_OptionsFrame_Slider"..index.."High");
local low = getglobal("TipBuddy_OptionsFrame_Slider"..index.."Low");
TipBuddy_OptionsFrame_SliderCalcEnabled( slider );
if (index == 1) then
low:SetText( "小" );
high:SetText( "大" );
else
low:SetText( value.minValue );
high:SetText( value.maxValue );
end
local tipTable = TipBuddy_SavedVars["general"];
slider:SetMinMaxValues(value.minValue, value.maxValue);
slider:SetValueStep(value.valueStep);
--if (index == 6) then
-- slider:SetValue( tipTable[value.var] / UIParent:GetScale() );
--else
slider:SetValue( tipTable[value.var] );
--end
string:SetText(TEXT(value.text));
slider.tooltipText = value.tooltipText;
slider.tooltipRequirement = value.tooltipRequirement;
slider.gxRestart = value.gxRestart;
slider.restartClient = value.restartClient;
end
end
function TipBuddy_OptionsFrame_SliderCalcEnabled( slider )
local thumb = getglobal(slider:GetName().."Thumb");
local string = getglobal(slider:GetName().."Text");
local updatetext = getglobal(slider:GetName().."TextUpdate");
local high = getglobal(slider:GetName().."High");
local low = getglobal(slider:GetName().."Low");
if ( slider.disabled ) then
slider:EnableMouse(0);
thumb:Hide();
string:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
updatetext:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
low:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
high:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
else
slider:EnableMouse(1);
thumb:Show();
string:SetVertexColor(NORMAL_FONT_COLOR.r , NORMAL_FONT_COLOR.g , NORMAL_FONT_COLOR.b);
updatetext:SetVertexColor(NORMAL_FONT_COLOR.r , NORMAL_FONT_COLOR.g , NORMAL_FONT_COLOR.b);
low:SetVertexColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
high:SetVertexColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
end
end
function TipBuddy_OptionsFrame_UpdateEditBoxes()
for index, value in TB_EditBoxes do
local editbox = getglobal( value.frame );
--local string = getglobal( value.frame.."Text");
if (not editbox) then
return;
end
local tipTable = TipBuddy_SavedVars[value.type];
--TB_AddMessage(value.type);
if (not tipTable[value.var]) then
--DEFAULT_CHAT_FRAME:AddMessage("|cff3366ffSETTING BLANK VAR with: "..TEXT(value.type));
tipTable[value.var] = "";
end
editbox:SetText( tipTable[value.var] );
end
end
function TipBuddy_OptionsFrame_UpdateDropDowns()
OptionsFrame_EnableDropDown(UIOptionsFrameClickCameraDropDown);
end
---------------------------------------------------------------
-- TOGGLING ALL CHECKBOXES WHEN DISABLE ALL
---------------------------------------------------------------
function TipBuddy_ToggleCheckboxFrame( checkBox )
local button = getglobal( checkBox:GetName() );
local boxId = button:GetID();
-- TB_AddMessage(button:GetID());
if ( button:GetChecked() ) then
for i=1, 7, 1 do
local boxName = getglobal( "TB_Op_Check"..(boxId + i) );
if (boxName == 0) then
return;
end
TipBuddy_DisableCheckBox(boxName);
end
else
for i=1, 7, 1 do
local boxName = getglobal( "TB_Op_Check"..(boxId + i) );
if (boxName == 0) then
return;
end
TipBuddy_EnableCheckBox(boxName);
end
end
end
function TipBuddy_DisableCheckBox(checkBox)
-- checkBox:SetChecked(0);
checkBox:Disable();
getglobal(checkBox:GetName().."Text"):SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
end
function TipBuddy_EnableCheckBox(checkBox, checked)
-- if ( checkBox:GetChecked() ) then
-- return;
-- end
-- checkBox:SetChecked(checked);
checkBox:Enable();
getglobal(checkBox:GetName().."Text"):SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
end
function TipBuddy_UpdateTabs_Initialize()
-- local frame = getglobal( this:GetName() );
-- PanelTemplates_SetTab( TipBuddy_OptionsFrame_PlayersFrame, 1 );
TipBuddy_OptionsFrame_PCFriend_Options:Show();
TipBuddy_OptionsFrame_PCEnemy_Options:Hide();
TipBuddy_OptionsFrame_PCParty_Options:Hide();
TipBuddy_OptionsFrame_NPCFriend_Options:Show();
TipBuddy_OptionsFrame_NPCNeutral_Options:Hide();
TipBuddy_OptionsFrame_NPCEnemy_Options:Hide();
TipBuddy_OptionsFrame_PETFriend_Options:Show();
TipBuddy_OptionsFrame_PETEnemy_Options:Hide();
TipBuddy_OptionsFrame_CORPSE_Options:Show();
end
function TipBuddy_PlayersFrameTab_OnClick(index)
if ( not index ) then
index = this:GetID();
end
-- local frame = getglobal( this:GetName() );
PanelTemplates_SetTab( TipBuddy_OptionsFrame_PlayersFrame, index );
TipBuddy_OptionsFrame_PCFriend_Options:Hide();
TipBuddy_OptionsFrame_PCEnemy_Options:Hide();
TipBuddy_OptionsFrame_PCParty_Options:Hide();
PlaySound("igCharacterInfoTab");
if ( index == 1 ) then
-- Friendly
TipBuddy_OptionsFrame_PCFriend_Options:Show();
elseif ( index == 2 ) then
-- Enemy
TipBuddy_OptionsFrame_PCParty_Options:Show();
elseif ( index == 3 ) then
-- InParty
TipBuddy_OptionsFrame_PCEnemy_Options:Show();
end
end
function TipBuddy_NPCsFrameTab_OnClick(index)
if ( not index ) then
index = this:GetID();
end
-- local frame = getglobal( this:GetName() );
PanelTemplates_SetTab( TipBuddy_OptionsFrame_NPCsFrame, index );
TipBuddy_OptionsFrame_NPCFriend_Options:Hide();
TipBuddy_OptionsFrame_NPCNeutral_Options:Hide();
TipBuddy_OptionsFrame_NPCEnemy_Options:Hide();
PlaySound("igCharacterInfoTab");
if ( index == 1 ) then
-- Friendly
TipBuddy_OptionsFrame_NPCFriend_Options:Show();
elseif ( index == 2 ) then
-- Neutral
TipBuddy_OptionsFrame_NPCNeutral_Options:Show();
elseif ( index == 3 ) then
-- Enemy
TipBuddy_OptionsFrame_NPCEnemy_Options:Show();
end
end
function TipBuddy_PetsFrameTab_OnClick(index)
if ( not index ) then
index = this:GetID();
end
-- local frame = getglobal( this:GetName() );
PanelTemplates_SetTab( TipBuddy_OptionsFrame_PetsFrame, index );
TipBuddy_OptionsFrame_PETFriend_Options:Hide();
TipBuddy_OptionsFrame_PETEnemy_Options:Hide();
PlaySound("igCharacterInfoTab");
if ( index == 1 ) then
-- Friendly
TipBuddy_OptionsFrame_PETFriend_Options:Show();
elseif ( index == 2 ) then
-- InParty
TipBuddy_OptionsFrame_PETEnemy_Options:Show();
end
end
function TipBuddy_OptionsFrameTab_OnClick(index)
if ( not index ) then
index = this:GetID();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -