📄 titanpanel.lua
字号:
TITAN_PANEL_FRAME_SPACEING = 20;
TITAN_PANEL_ICON_SPACEING = 4;
TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE = 10;
TITAN_AUTOHIDE_WAIT_TIME = 0.5;
TITAN_PANEL_INITIAL_PLUGINS = {"Coords", "Performance", "Honor", "Bag", "Money", "EmoteMenu", "ItemBonuses", "AutoHide", "Trans", "UIScale", "Clock", "AuxAutoHide"};
TITAN_PANEL_INITIAL_PLUGIN_LOCATION = {"Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "Bar", "AuxBar"};
TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = {"General"}
TITAN_PANEL_BUTTONS_ALIGN_LEFT = 1;
TITAN_PANEL_BUTTONS_ALIGN_CENTER = 2;
TITAN_PANEL_BUTTONS_ALIGN_RIGHT = 3;
TITAN_PANEL_BARS_SINGLE = 1;
TITAN_PANEL_BARS_DOUBLE = 2;
TITAN_PANEL_BUTTONS_INIT_FLAG = nil;
TITAN_PANEL_SELECTED = "Bar";
TITAN_PANEL_FROM_TOP = -25;
TITAN_PANEL_FROM_BOTTOM = 25;
TITAN_PANEL_FROM_BOTTOM_MAIN = 1;
TITAN_PANEL_FROM_TOP_MAIN = 1;
TITAN_PANEL_MOVE_ADDON = nil;
TITAN_PANEL_DROPOFF_ADDON = nil;
TITAN_PANEL_NEXT_ADDON = nil;
TITAN_PANEL_MOVING = 0;
TITAN_PANEL_SAVED_VARIABLES = {
Buttons = TITAN_PANEL_INITIAL_PLUGINS,
Location = TITAN_PANEL_INITIAL_PLUGIN_LOCATION,
Transparency = 0.7,
Scale = 1,
FontScale = 1,
ScreenAdjust = TITAN_NIL,
AutoHide = TITAN_NIL,
Position = TITAN_PANEL_PLACE_TOP,
DoubleBar = TITAN_PANEL_BARS_SINGLE,
ButtonAlign = TITAN_PANEL_BUTTONS_ALIGN_LEFT,
BothBars = TITAN_NIL,
AuxScreenAdjust = TITAN_NIL,
AuxAutoHide = TITAN_NIL,
AuxDoubleBar = TITAN_PANEL_BARS_SINGLE,
AuxButtonAlign = TITAN_PANEL_BUTTONS_ALIGN_LEFT,
VersionShown = 1,
ToolTipsShown = 1,
DisableFont = TITAN_NIL
};
function TitanPanelBarButton_OnLoad()
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("UNIT_NAME_UPDATE");
this:RegisterEvent("TIME_PLAYED_MSG");
this:RegisterEvent("PLAYER_LEVEL_UP");
this:RegisterEvent("CVAR_UPDATE");
this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
end
function TitanPanelBarButton_OnEvent(frame)
if frame == "TitanPanelBarButton" then
if (event == "VARIABLES_LOADED") then
TitanVariables_InitTitanSettings();
elseif (event == "ADDON_LOADED") then
TitanPanel_AddonLoaded(arg1);
elseif (event == "UNIT_NAME_UPDATE") then
TitanVariables_InitDetailedSettings();
elseif (event == "PLAYER_ENTERING_WORLD") then
TitanVariables_InitDetailedSettings();
-- Initial session time
if (not this.sessionTime) then
this.sessionTime = 0;
RequestTimePlayed();
end
if ( not ServerTimeOffsets ) then
ServerTimeOffsets = {};
end
local realmName = GetCVar("realmName");
if ( ServerTimeOffsets[realmName] ) then
TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", ServerTimeOffsets[realmName]);
end
elseif ( event == "PLAYER_LEAVING_WORLD" ) then
local realmName = GetCVar("realmName");
ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour");
elseif (event == "TIME_PLAYED_MSG") then
-- Remember play time
this.totalTime = arg1;
this.levelTime = arg2;
-- Move frames
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_AdjustBlizzardFrames();
-- Init panel buttons
TitanPanel_InitPanelBarButton();
TitanPanel_InitPanelButtons();
-- Set initial Panel AutoHide
if (TitanPanelGetVar("AutoHide")) then
TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
end
if (TitanPanelGetVar("AuxAutoHide")) then
TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
end
TitanPanel_SetTransparent("TitanPanelBarButtonHider", TitanPanelGetVar("Position"));
elseif (event == "PLAYER_LEVEL_UP") then
-- Reset level time
this.levelTime = 0;
elseif (event == "CVAR_UPDATE") then
if (arg1 == "USE_UISCALE" or arg1 == "WINDOWED_MODE") then
if (TitanPlayerSettings and TitanPanelGetVar("Scale")) then
TitanPanel_SetScale();
TitanPanel_RefreshPanelButtons();
-- Adjust frame positions
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_AdjustBlizzardFrames();
end
end
end
end
end
function TitanPanelBarButtonHider_OnUpdate(elapsed)
local x, y = GetCursorPosition(UIParent);
local scale = UIParent:GetEffectiveScale();
if scale ~= 1.0 then
y = y / (scale);
end
if (TitanPanelGetVar("AutoHide") or TitanPanelGetVar("AuxAutoHide")) then
if not (TitanPanelRightClickMenu_IsVisible()) then
TITAN_PANEL_SELECTED = TitanUtils_GetButtonID(this:GetName())
TitanUtils_CheckAutoHideCounting(elapsed);
if TITAN_PANEL_SELECTED == "Bar" and TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP then
if y < TitanPanelBarButtonHider:GetBottom() and TitanPanelBarButtonHider.isCounting == nil then
TitanUtils_StartAutoHideCounting("TitanPanelBarButtonHider");
end
elseif TITAN_PANEL_SELECTED == "Bar" and TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_BOTTOM then
if y > TitanPanelBarButtonHider:GetTop() and TitanPanelBarButtonHider.isCounting == nil then
TitanUtils_StartAutoHideCounting("TitanPanelBarButtonHider");
end
elseif TITAN_PANEL_SELECTED == "AuxBar" then
if y > TitanPanelAuxBarButtonHider:GetTop() and TitanPanelAuxBarButtonHider.isCounting == nil then
TitanUtils_StartAutoHideCounting("TitanPanelAuxBarButtonHider");
end
end
end
end
end
function TitanPanelBarButton_OnUpdate(elapsed)
if TITAN_PANEL_MOVING == 2 and TITAN_PANEL_DROPOFF_ADDON ~= nil then
TITAN_PANEL_MOVING = 3;
end
-- Update play time
if (this.totalTime) then
this.totalTime = this.totalTime + elapsed;
this.sessionTime = this.sessionTime + elapsed;
this.levelTime = this.levelTime + elapsed;
end
end
function TitanPanelBarButton_OnClick(button)
if (button == "LeftButton") then
TitanUtils_CloseAllControlFrames();
TitanUtils_CloseRightClickMenu();
elseif (button == "RightButton") then
TitanUtils_CloseAllControlFrames();
-- Show RightClickMenu anyway
if (TitanPanelRightClickMenu_IsVisible()) then
TitanPanelRightClickMenu_Close();
end
TitanPanelRightClickMenu_Toggle();
end
end
function TitanPanelBarButtonHider_OnEnter(frame)
if (TitanPanelGetVar("AutoHide") or TitanPanelGetVar("AuxAutoHide")) then
local frname = getglobal(frame)
if frname.isCounting ~= nil then
TitanUtils_StopAutoHideCounting(frame);
end
if (frame == "TitanPanelBarButtonHider" and TitanPanelBarButton.hide == 1) then
if (TitanPanelBarButton.hide) then
TitanPanelBarButton_Show("TitanPanelBarButton", TitanPanelGetVar("Position"));
end
else
if (TitanPanelAuxBarButton.hide and TitanPanelAuxBarButton.hide == 1) then
if TitanPanelGetVar("BothBars") then
TitanPanelBarButton_Show("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
end
end
end
end
end
function TitanPanelBarButtonHider_OnLeave(frame)
--Removed
end
function TitanPanelRightClickMenu_BarOnClick()
if (UIDropDownMenuButton_GetChecked()) then
TitanPanel_RemoveButton(this.value);
else
TitanPanel_AddButton(this.value);
end
end
function TitanPanelBarButton_ToggleAlign()
if ( TitanPanelGetVar("ButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then
TitanPanelSetVar("ButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_LEFT);
else
TitanPanelSetVar("ButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_CENTER);
end
-- Justify button position
TitanPanelButton_Justify();
end
function TitanPanelBarButton_ToggleAuxAlign()
if ( TitanPanelGetVar("AuxButtonAlign") == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then
TitanPanelSetVar("AuxButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_LEFT);
else
TitanPanelSetVar("AuxButtonAlign", TITAN_PANEL_BUTTONS_ALIGN_CENTER);
end
-- Justify button position
TitanPanelButton_Justify();
end
function TitanPanelBarButton_ToggleDoubleBar()
if ( TitanPanelGetVar("DoubleBar") == TITAN_PANEL_BARS_SINGLE ) then
TitanPanelSetVar("DoubleBar", TITAN_PANEL_BARS_DOUBLE);
TitanPanelBarButtonHider:SetHeight(48);
else
TitanPanelSetVar("DoubleBar", TITAN_PANEL_BARS_SINGLE);
TitanPanelBarButtonHider:SetHeight(24);
end
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("DoubleBar"));
TitanMovableFrame_AdjustBlizzardFrames();
TitanPanel_InitPanelBarButton();
TitanPanel_InitPanelButtons();
TitanPanel_SetTransparent("TitanPanelBarButtonHider", TitanPanelGetVar("Position"));
if (TitanPanelGetVar("AutoHide")) then
TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
end
if (TitanPanelGetVar("AuxAutoHide")) then
TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
end
end
function TitanPanelBarButton_ToggleAuxDoubleBar()
if ( TitanPanelGetVar("AuxDoubleBar") == TITAN_PANEL_BARS_SINGLE ) then
TitanPanelSetVar("AuxDoubleBar", TITAN_PANEL_BARS_DOUBLE);
TitanPanelAuxBarButtonHider:SetHeight(48);
else
TitanPanelSetVar("AuxDoubleBar", TITAN_PANEL_BARS_SINGLE);
TitanPanelAuxBarButtonHider:SetHeight(24);
end
TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_BOTTOM);
TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_BOTTOM, 1);
TitanMovableFrame_AdjustBlizzardFrames();
TitanPanel_InitPanelBarButton();
TitanPanel_InitPanelButtons();
TitanPanel_SetTransparent("TitanPanelAuxBarButtonHider", TITAN_PANEL_PLACE_BOTTOM);
if (TitanPanelGetVar("AutoHide")) then
TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
end
if (TitanPanelGetVar("AuxAutoHide")) then
TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TitanPanelGetVar("Position"));
end
end
function TitanPanelBarButton_ToggleAutoHide()
TitanPanelToggleVar("AutoHide");
if (TitanPanelGetVar("AutoHide")) then
TitanPanelBarButton_Hide("TitanPanelBarButton", TitanPanelGetVar("Position"));
else
TitanPanelBarButton_Show("TitanPanelBarButton", TitanPanelGetVar("Position"));
end
TitanPanelAutoHideButton_SetIcon();
end
function TitanPanelBarButton_ToggleAuxAutoHide()
TitanPanelToggleVar("AuxAutoHide");
if (TitanPanelGetVar("AuxAutoHide")) then
if TitanPanelGetVar("BothBars") then
TitanPanelBarButton_Hide("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
end
else
if TitanPanelGetVar("BothBars") then
TitanPanelBarButton_Show("TitanPanelAuxBarButton", TITAN_PANEL_PLACE_BOTTOM);
end
end
--Needs changing!
TitanPanelAuxAutoHideButton_SetIcon();
end
function TitanPanelBarButton_ToggleScreenAdjust()
TitanPanelToggleVar("ScreenAdjust");
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"), TitanPanelGetVar("ScreenAdjust"));
TitanMovableFrame_AdjustBlizzardFrames();
end
function TitanPanelBarButton_ToggleAuxScreenAdjust()
TitanPanelToggleVar("AuxScreenAdjust");
TitanMovableFrame_CheckFrames(TITAN_PANEL_PLACE_BOTTOM);
TitanMovableFrame_MoveFrames(TITAN_PANEL_PLACE_BOTTOM, TitanPanelGetVar("AuxScreenAdjust"));
TitanMovableFrame_AdjustBlizzardFrames();
end
function TitanPanelBarButton_TogglePosition()
if (TitanPanelGetVar("Position") == TITAN_PANEL_PLACE_TOP) then
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanPanelSetVar("Position", TITAN_PANEL_PLACE_BOTTOM);
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"));
else
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanPanelSetVar("Position", TITAN_PANEL_PLACE_TOP);
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"));
end
-- Set panel position and texture
TitanPanel_SetPosition("TitanPanelBarButton", TitanPanelGetVar("Position"));
TitanPanel_SetTexture("TitanPanelBarButton", TitanPanelGetVar("Position"));
TitanPanel_SetTransparent("TitanPanelBarButtonHider", TitanPanelGetVar("Position"));
-- Adjust frame positions
TitanMovableFrame_CheckFrames(TitanPanelGetVar("Position"));
TitanMovableFrame_MoveFrames(TitanPanelGetVar("Position"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -