Created
July 20, 2018 19:07
-
-
Save dkrusky/a49ed5aff2de4b2510c1d402ed8e3007 to your computer and use it in GitHub Desktop.
Titan Panel patch to work with World of Warcraft BFA pre-patch 8.0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copy the files above to the specified locations in your warcraft/interface/addons/ folder : | |
TitanMovable.lua >> ./addons/Titan/TitanMovable.lua | |
TitanCloth.lua >> ./addons/TitanClock/TitanClock.lua | |
There may be other issues, however until an official patch has been released, I will continue to update this GIST with fixes as I find them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ************************************************************************** | |
-- * TitanClock.lua | |
-- * | |
-- * By: TitanMod, Dark Imakuni, Adsertor and the Titan Development Team | |
-- ************************************************************************** | |
-- ******************************** Constants ******************************* | |
TITAN_CLOCK_ID = "Clock"; | |
local TITAN_CLOCK_FORMAT_12H = "12H"; | |
local TITAN_CLOCK_FORMAT_24H = "24H"; | |
local TITAN_CLOCK_FRAME_SHOW_TIME = 0.5; | |
local _G = getfenv(0); | |
-- ******************************** Variables ******************************* | |
local L = LibStub("AceLocale-3.0"):GetLocale("Titan", true) | |
local AceTimer = LibStub("AceTimer-3.0") | |
local ClockTimer = nil; | |
local updateTable = {TITAN_CLOCK_ID, TITAN_PANEL_UPDATE_ALL }; | |
local realmName = GetRealmName(); | |
-- ******************************** Functions ******************************* | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockButton_OnLoad() | |
-- DESC : Registers the plugin upon it loading | |
-- ************************************************************************** | |
function TitanPanelClockButton_OnLoad(self) | |
self.registry = { | |
id = TITAN_CLOCK_ID, | |
category = "Built-ins", | |
version = TITAN_VERSION, | |
menuText = L["TITAN_CLOCK_MENU_TEXT"], | |
buttonTextFunction = "TitanPanelClockButton_GetButtonText", | |
tooltipTitle = L["TITAN_CLOCK_TOOLTIP"], | |
tooltipTextFunction = "TitanPanelClockButton_GetTooltipText", | |
controlVariables = { | |
ShowIcon = false, | |
ShowLabelText = true, | |
ShowRegularText = false, | |
ShowColoredText = true, | |
DisplayOnRightSide = true, | |
}, | |
savedVariables = { | |
OffsetHour = 0, | |
Format = TITAN_CLOCK_FORMAT_12H, | |
TimeMode = "Server", | |
ShowLabelText = false, | |
ShowColoredText = false, | |
DisplayOnRightSide = 1, | |
HideGameTimeMinimap = false, | |
HideMapTime = false, | |
} | |
}; | |
self:RegisterEvent("PLAYER_ENTERING_WORLD"); | |
end | |
local function TitanPanelClockButton_GetColored(text) | |
local label = ""; | |
if (TitanGetVar(TITAN_CLOCK_ID, "ShowColoredText")) then | |
label = TitanUtils_GetGreenText(text) | |
else | |
label = TitanUtils_GetHighlightText(text) | |
end | |
return label; | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockButton_OnShow() | |
-- DESC : Create repeating timer when plugin is visible | |
-- ************************************************************************** | |
function TitanPanelClockButton_OnShow() | |
if not ClockTimer then | |
ClockTimer = AceTimer.ScheduleRepeatingTimer("TitanPanelClock", TitanPanelPluginHandle_OnUpdate, 30, updateTable) | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockButton_OnHide() | |
-- DESC : Destroy repeating timer when plugin is hidden | |
-- ************************************************************************** | |
function TitanPanelClockButton_OnHide() | |
AceTimer.CancelTimer("TitanPanelClock", ClockTimer, true) | |
ClockTimer = nil; | |
end | |
function TitanPanelClockButton_OnEvent(self, event, ...) | |
if (event == "PLAYER_ENTERING_WORLD") then | |
-- If the user wants the minimap clock or calendar hidden then hide them | |
if TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap") then | |
if GameTimeFrame then GameTimeFrame:Hide() end | |
end | |
if TimeManagerClockButton and TimeManagerClockButton:GetName() then | |
if TitanGetVar(TITAN_CLOCK_ID, "HideMapTime") then | |
TimeManagerClockButton:Hide() | |
else | |
TimeManagerClockButton:Show() | |
end | |
end | |
end | |
end | |
function TitanPanelClockButton_OnClick(self, button) | |
if button == "LeftButton" and IsShiftKeyDown() then | |
TitanUtils_CloseAllControlFrames(); | |
if (TitanPanelRightClickMenu_IsVisible()) then | |
TitanPanelRightClickMenu_Close(); | |
end | |
ToggleCalendar() | |
else | |
TitanPanelButton_OnClick(self, button); | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockButton_GetButtonText() | |
-- DESC : Display time on button based on set variables | |
-- ************************************************************************** | |
function TitanPanelClockButton_GetButtonText() | |
local clocktime = ""; | |
local labeltext = ""; | |
local _ = nil | |
if TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Server" then | |
_,clocktime = TitanPanelClockButton_GetTime("Server", 0) | |
labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(S) ") or "" | |
elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjusted" then | |
_,clocktime = TitanPanelClockButton_GetTime ("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) | |
labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(A) ") or "" | |
elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" then | |
_,clocktime = TitanPanelClockButton_GetTime ("Local", 0) | |
labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(L) ") or "" | |
end | |
return labeltext, clocktime | |
end | |
function TitanPanelClockButton_GetTime(displaytype, offset) | |
-- Calculate the hour/minutes considering the offset | |
local hour, minute = GetGameTime(); | |
local twentyfour = ""; | |
local offsettime = string.format("%s", offset); | |
local offsethour = 0; | |
local offsetmin = 0; | |
local s, e, id = string.find(offsettime, '%.5'); | |
if displaytype == "Server" then | |
if (s ~= nil) then | |
offsethour = string.sub(offsettime, 1, s); | |
offsetmin = string.sub(offsettime, s+1); | |
if offsetmin == "" or offsetmin == nil then offsetmin = "0"; end | |
if offsethour == "" or offsethour == nil then offsethour = "0"; end | |
offsethour = tonumber(offsethour); | |
if (tonumber(offsettime) < 0) then offsetmin = tonumber("-" .. offsetmin); end | |
minute = minute + (offsetmin*6); | |
if (minute > 59) then | |
minute = minute - 60; | |
offsethour = offsethour + 1; | |
elseif (minute < 0) then | |
minute = 60 + minute; | |
offsethour = offsethour - 1; | |
end | |
else | |
offsethour = offset; | |
end | |
else | |
-- no offset for local time | |
hour, minute = tonumber(date("%H")), tonumber(date("%M")); | |
offsethour = 0; | |
end | |
hour = hour + offsethour; | |
if (hour > 23) then | |
hour = hour - 24; | |
elseif (hour < 0) then | |
hour = 24 + hour; | |
end | |
-- Calculate the display text based on format 12H/24H | |
if (TitanGetVar(TITAN_CLOCK_ID, "Format") == TITAN_CLOCK_FORMAT_12H) then | |
local isAM; | |
if (hour >= 12) then | |
isAM = false; | |
hour = hour - 12; | |
else | |
isAM = true; | |
end | |
if (hour == 0) then | |
hour = 12; | |
end | |
if (isAM) then | |
-- return nil, format(TEXT(TIME_TWELVEHOURAM), hour, minute); | |
return nil, format(TIME_TWELVEHOURAM, hour, minute); | |
else | |
-- return nil, format(TEXT(TIME_TWELVEHOURPM), hour, minute); | |
return nil, format(TIME_TWELVEHOURPM, hour, minute); | |
end | |
else | |
-- twentyfour = format(TEXT(TIME_TWENTYFOURHOURS), hour, minute); | |
twentyfour = format(TIME_TWENTYFOURHOURS, hour, minute); | |
if (hour < 10) then | |
twentyfour = "0" .. twentyfour | |
end | |
return nil, twentyfour; | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockButton_GetTooltipText() | |
-- DESC : Display tooltip text | |
-- ************************************************************************** | |
function TitanPanelClockButton_GetTooltipText() | |
local _, clockTimeLocal = TitanPanelClockButton_GetTime ("Local", 0) | |
local _, clockTimeServer = TitanPanelClockButton_GetTime ("Server", 0) | |
local _, clockTimeServerAdjusted = TitanPanelClockButton_GetTime ("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) | |
local clockTimeLocalLabel = L["TITAN_CLOCK_TOOLTIP_LOCAL_TIME"].."\t"..TitanUtils_GetHighlightText(clockTimeLocal) | |
local clockTimeServerLabel = L["TITAN_CLOCK_TOOLTIP_SERVER_TIME"].."\t"..TitanUtils_GetHighlightText(clockTimeServer) | |
local clockTimeServerAdjustedLabel = ""; | |
if TitanGetVar(TITAN_CLOCK_ID, "OffsetHour") ~= 0 then | |
clockTimeServerAdjustedLabel = L["TITAN_CLOCK_TOOLTIP_SERVER_ADJUSTED_TIME"].."\t"..TitanUtils_GetHighlightText(clockTimeServerAdjusted).."\n" | |
end | |
local clockText = TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")); | |
return "".. | |
clockTimeLocalLabel.."\n".. | |
clockTimeServerLabel.."\n".. | |
clockTimeServerAdjustedLabel.. | |
L["TITAN_CLOCK_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(clockText).."\n".. | |
TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT1"]).."\n".. | |
TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT2"]).."\n".. | |
TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT3"]); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlSlider_OnEnter() | |
-- DESC : Display slider tooltip | |
-- ************************************************************************** | |
function TitanPanelClockControlSlider_OnEnter(self) | |
self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); | |
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); | |
GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); | |
TitanUtils_StopFrameCounting(self:GetParent()); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlSlider_OnLeave() | |
-- DESC : Hide slider tooltip | |
-- ************************************************************************** | |
function TitanPanelClockControlSlider_OnLeave(self) | |
self.tooltipText = nil; | |
GameTooltip:Hide(); | |
TitanUtils_StartFrameCounting(self:GetParent(), TITAN_CLOCK_FRAME_SHOW_TIME); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlSlider_OnShow() | |
-- DESC : Display slider tooltip options | |
-- ************************************************************************** | |
function TitanPanelClockControlSlider_OnShow(self) | |
_G[self:GetName().."Text"]:SetText(TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); | |
_G[self:GetName().."High"]:SetText(L["TITAN_CLOCK_CONTROL_LOW"]); | |
_G[self:GetName().."Low"]:SetText(L["TITAN_CLOCK_CONTROL_HIGH"]); | |
self:SetMinMaxValues(-12, 12); | |
self:SetValueStep(0.5); | |
self:SetValue(0 - TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")); | |
local position = TitanUtils_GetRealPosition(TITAN_CLOCK_ID); | |
local scale = TitanPanelGetVar("Scale"); | |
--TitanPanelClockControlFrame:SetPoint("BOTTOMRIGHT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_CLOCK_ID) .."Button", "TOPRIGHT", 0, 0); | |
if (position == TITAN_PANEL_PLACE_TOP) then | |
TitanPanelClockControlFrame:ClearAllPoints(); | |
if TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide") == 1 then | |
TitanPanelClockControlFrame:SetPoint("TOPLEFT", TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(TITAN_CLOCK_ID), "BOTTOMLEFT", UIParent:GetRight() - TitanPanelClockControlFrame:GetWidth(), -4); | |
else | |
TitanPanelClockControlFrame:SetPoint("TOPLEFT", "TitanPanel" ..TITAN_CLOCK_ID.."Button", "BOTTOMLEFT", -10, -4 * scale); | |
-- Adjust frame position if it's off the screen | |
local offscreenX, offscreenY = TitanUtils_GetOffscreen(TitanPanelClockControlFrame); | |
if ( offscreenX == -1 ) then | |
TitanPanelClockControlFrame:SetPoint("TOPLEFT", "TitanPanel" ..TITAN_CLOCK_ID.."Button", "BOTTOMLEFT", 0, 0); | |
elseif ( offscreenX == 1 ) then | |
TitanPanelClockControlFrame:SetPoint("TOPRIGHT", "TitanPanel" ..TITAN_CLOCK_ID.."Button", "BOTTOMRIGHT", 0, 0); | |
end | |
end | |
else | |
TitanPanelClockControlFrame:ClearAllPoints(); | |
if TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide") == 1 then | |
TitanPanelClockControlFrame:SetPoint("BOTTOMLEFT", TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(TITAN_CLOCK_ID), "TOPLEFT", UIParent:GetRight() - TitanPanelClockControlFrame:GetWidth(), 0); | |
else | |
TitanPanelClockControlFrame:SetPoint("BOTTOMLEFT", "TitanPanel" ..TITAN_CLOCK_ID.."Button", "TOPLEFT", -10, 4 * scale); | |
-- Adjust frame position if it's off the screen | |
local offscreenX, offscreenY = TitanUtils_GetOffscreen(TitanPanelClockControlFrame); | |
if ( offscreenX == -1 ) then | |
TitanPanelClockControlFrame:SetPoint("BOTTOMLEFT", "TitanPanel" ..TITAN_CLOCK_ID.."Button", "TOPLEFT", 0, 0); | |
elseif ( offscreenX == 1 ) then | |
TitanPanelClockControlFrame:SetPoint("BOTTOMRIGHT", "TitanPanel" ..TITAN_CLOCK_ID.."Button", "TOPRIGHT", 0, 0); | |
end | |
end | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlSlider_OnValueChanged(arg1) | |
-- DESC : Display slider tooltip text | |
-- VARS : arg1 = positive or negative change to apply | |
-- ************************************************************************** | |
function TitanPanelClockControlSlider_OnValueChangedWheel(self, a1) | |
_G[self:GetName().."Text"]:SetText(TitanPanelClock_GetOffsetText(0 - self:GetValue())); | |
local tempval = self:GetValue(); | |
if a1 == -1 then | |
self:SetValue(tempval + 0.5); | |
end | |
if a1 == 1 then | |
self:SetValue(tempval - 0.5); | |
end | |
TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", 0 - self:GetValue()); | |
if ( ServerTimeOffsets[realmName] ) then | |
ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"); | |
end | |
TitanPanelButton_UpdateButton(TITAN_CLOCK_ID); | |
-- Update GameTooltip | |
if (self.tooltipText) then | |
self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); | |
GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); | |
end | |
end | |
function TitanPanelClockControlSlider_OnValueChanged(self, a1) | |
_G[self:GetName().."Text"]:SetText(TitanPanelClock_GetOffsetText(0 - self:GetValue())); | |
TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", 0 - self:GetValue()); | |
if ( ServerTimeOffsets[realmName] ) then | |
ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"); | |
end | |
TitanPanelButton_UpdateButton(TITAN_CLOCK_ID); | |
-- Update GameTooltip | |
if (self.tooltipText) then | |
self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); | |
GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlCheckButton_OnShow() | |
-- DESC : Define clock hour options | |
-- ************************************************************************** | |
function TitanPanelClockControlCheckButton_OnShow(self) | |
TitanPanelClockControlCheckButtonText:SetText(L["TITAN_CLOCK_CHECKBUTTON"]); | |
if (TitanGetVar(TITAN_CLOCK_ID, "Format") == TITAN_CLOCK_FORMAT_24H) then | |
self:SetChecked(true); | |
else | |
self:SetChecked(false); | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlCheckButton_OnClick() | |
-- DESC : Toggle clock hour option | |
-- ************************************************************************** | |
function TitanPanelClockControlCheckButton_OnClick(self, button) | |
if (self:GetChecked()) then | |
TitanSetVar(TITAN_CLOCK_ID, "Format", TITAN_CLOCK_FORMAT_24H); | |
else | |
TitanSetVar(TITAN_CLOCK_ID, "Format", TITAN_CLOCK_FORMAT_12H); | |
end | |
if ( ServerHourFormat[realmName] ) then | |
ServerHourFormat[realmName] = TitanGetVar(TITAN_CLOCK_ID, "Format"); | |
end | |
TitanPanelButton_UpdateButton(TITAN_CLOCK_ID); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlCheckButton_OnEnter() | |
-- DESC : Display clock hour option tooltip | |
-- ************************************************************************** | |
function TitanPanelClockControlCheckButton_OnEnter(self) | |
self.tooltipText = L["TITAN_CLOCK_CHECKBUTTON_TOOLTIP"]; | |
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); | |
GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); | |
TitanUtils_StopFrameCounting(self:GetParent()); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlCheckButton_OnLeave() | |
-- DESC : Hide clock hour option tooltip | |
-- ************************************************************************** | |
function TitanPanelClockControlCheckButton_OnLeave(self) | |
self.tooltipText = nil; | |
GameTooltip:Hide(); | |
TitanUtils_StartFrameCounting(self:GetParent(), TITAN_CLOCK_FRAME_SHOW_TIME); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClock_GetOffsetText(offset) | |
-- DESC : Get hour offset value and return | |
-- VARS : offset = hour offset from server time | |
-- ************************************************************************** | |
function TitanPanelClock_GetOffsetText(offset) | |
if (offset > 0) then | |
return TitanUtils_GetGreenText("+" .. tostring(offset)); | |
elseif (offset < 0) then | |
return TitanUtils_GetRedText(tostring(offset)); | |
else | |
return TitanUtils_GetHighlightText(tostring(offset)); | |
end | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlFrame_OnLoad() | |
-- DESC : Create clock option frame | |
-- ************************************************************************** | |
function TitanPanelClockControlFrame_OnLoad(self) | |
_G[self:GetName().."Title"]:SetText(L["TITAN_CLOCK_CONTROL_TITLE"]); | |
self:SetBackdropBorderColor(1, 1, 1); | |
self:SetBackdropColor(0, 0, 0, 1); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockControlFrame_OnUpdate(elapsed) | |
-- DESC : If dropdown is visible, see if its timer has expired. If so, hide frame | |
-- VARS : elapsed = <research> | |
-- ************************************************************************** | |
function TitanPanelClockControlFrame_OnUpdate(self, elapsed) | |
TitanUtils_CheckFrameCounting(self, elapsed); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelRightClickMenu_PrepareClockMenu() | |
-- DESC : Generate clock right click menu options | |
-- ************************************************************************** | |
function TitanPanelRightClickMenu_PrepareClockMenu() | |
TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_CLOCK_ID].menuText); | |
local info = {}; | |
info.text = L["TITAN_CLOCK_MENU_LOCAL_TIME"]; | |
info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "Local") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end | |
info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" end | |
L_UIDropDownMenu_AddButton(info); | |
info = {}; | |
info.text = L["TITAN_CLOCK_MENU_SERVER_TIME"]; | |
info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "Server") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end | |
info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Server" end | |
L_UIDropDownMenu_AddButton(info); | |
info = {}; | |
info.text = L["TITAN_CLOCK_MENU_SERVER_ADJUSTED_TIME"]; | |
info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerAdjusted") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end | |
info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjusted" end | |
L_UIDropDownMenu_AddButton(info); | |
TitanPanelRightClickMenu_AddSpacer(); | |
info = {}; | |
info.text = L["TITAN_CLOCK_MENU_HIDE_MAPTIME"]; | |
info.func = TitanPanelClockButton_ToggleMapTime; | |
info.checked = TitanGetVar(TITAN_CLOCK_ID, "HideMapTime"); | |
info.keepShownOnClick = 1; | |
L_UIDropDownMenu_AddButton(info); | |
info = {}; | |
info.text = L["TITAN_CLOCK_MENU_HIDE_CALENDAR"]; | |
info.func = TitanPanelClockButton_ToggleGameTimeFrameShown; | |
info.checked = TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap"); | |
info.keepShownOnClick = 1; | |
L_UIDropDownMenu_AddButton(info); | |
info = {}; | |
info.text = L["TITAN_CLOCK_MENU_DISPLAY_ON_RIGHT_SIDE"]; | |
info.func = TitanPanelClockButton_ToggleRightSideDisplay; | |
info.checked = TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide"); | |
L_UIDropDownMenu_AddButton(info); | |
TitanPanelRightClickMenu_AddToggleLabelText(TITAN_CLOCK_ID); | |
TitanPanelRightClickMenu_AddToggleColoredText(TITAN_CLOCK_ID); | |
TitanPanelRightClickMenu_AddSpacer(); | |
TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], TITAN_CLOCK_ID, TITAN_PANEL_MENU_FUNC_HIDE); | |
end | |
-- ************************************************************************** | |
-- NAME : TitanPanelClockButton_ToggleRightSideDisplay() | |
-- DESC : Add clock button to bar | |
-- ************************************************************************** | |
function TitanPanelClockButton_ToggleRightSideDisplay() | |
TitanToggleVar(TITAN_CLOCK_ID, "DisplayOnRightSide"); | |
TitanPanel_RemoveButton(TITAN_CLOCK_ID); | |
--TitanPanel_AddButton(TITAN_CLOCK_ID); | |
end | |
function TitanPanelClockButton_ToggleGameTimeFrameShown() | |
TitanToggleVar(TITAN_CLOCK_ID, "HideGameTimeMinimap"); | |
if GameTimeFrame and GameTimeFrame:GetName() then | |
if TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap") then | |
GameTimeFrame:Hide() | |
else | |
GameTimeFrame:Show() | |
end | |
end | |
end | |
function TitanPanelClockButton_ToggleMapTime() | |
TitanToggleVar(TITAN_CLOCK_ID, "HideMapTime"); | |
if TimeManagerClockButton and TimeManagerClockButton:GetName() then | |
if TitanGetVar(TITAN_CLOCK_ID, "HideMapTime") then | |
TimeManagerClockButton:Hide() | |
else | |
TimeManagerClockButton:Show() | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ File | |
NAME: TitanMovable.lua | |
DESC: Contains the routines to adjust the Blizzard frames to make room for the Titan bars the user has selected. | |
There are a select set of Blizzard frames at the top of screen and at the bottom of the screen that Titan will move. | |
Each frame adjusted has an entry in TitanMovableData. TitanMovableData is local and not directly accessible via addons. | |
However addons can tell Titan to not adjust some or all frames using TitanUtils_AddonAdjust(frame, bool). Addons that replace all or parts of the Blizzard UI use this. | |
The user can turn turn on / off the adjusting of all top frames or all bottom frames. | |
In addition the user can select to turn off / on adjusting of select top frames (minimap or ticket frame) or select bottom frames (chat / log or bags) | |
:DESC | |
--]] | |
-- Globals | |
-- Locals | |
local _G = getfenv(0); | |
local InCombatLockdown = _G.InCombatLockdown; | |
--[[ Titan | |
Declare the Ace routines | |
local AceTimer = LibStub("AceTimer-3.0") | |
i.e. TitanPanelAce.ScheduleTimer("LDBToTitanSetText", TitanLDBRefreshButton, 2); | |
or | |
i.e. TitanPanelAce:ScheduleTimer(TitanLDBRefreshButton, 2); | |
Be careful that the 'self' is proper to cancel timers!!! | |
--]] | |
local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanel", "AceHook-3.0", "AceTimer-3.0") | |
--Determines the optimal magic number based on resolution | |
--local menuBarTop = 55; | |
--local width, height = string.match((({GetScreenResolutions()})[GetCurrentResolution()] or ""), "(%d+).-(%d+)"); | |
--if ( tonumber(width) / tonumber(height ) > 4/3 ) then | |
--Widescreen resolution | |
-- menuBarTop = 75; | |
--end | |
--[[From Resike to prevent tainting stuff to override the SetPoint calls securely. | |
hooksecurefunc(FrameRef, "SetPoint", function(self) | |
if self.moving then | |
return | |
end | |
self.moving = true | |
self:SetMovable(true) | |
self:SetUserPlaced(true) | |
self:ClearAllPoints() | |
self:SetPoint("CENTER", UIParent, "CENTER", 0, 0) | |
self:SetMovable(false) | |
self.moving = nil | |
end) | |
--]] | |
--[[ Titan | |
TitanMovable is a local table that is cleared then filled with the frames Titan needs to check and adjust, if necessary, with each 'adjust frame' check. | |
--]] | |
local TitanMovable = {}; | |
--[[ Titan | |
NAME: TitanMovableData table | |
DESC: TitanMovableData is a local table that holds each frame Titan may need to adjust. It also has the anchor points and offsets needed to make room for the Titan bar(s) | |
The index is the frame name. Each record contains: | |
frameName - frame name (string) to adjust | |
frameArchor - the frame anchor point | |
xArchor - anchor relative to the frameName | |
y - any additional adjustment in the y axis | |
position - top or bottom | |
addonAdj - true if another addon is taking responsibility of adjusting this frame, if false Titan will use the user setttings to adjust or not | |
:DESC | |
--]] | |
local TitanMovableData = { | |
PlayerFrame = {frameName = "PlayerFrame", frameArchor = "TOPLEFT", xArchor = "LEFT", y = -4, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
TargetFrame = {frameName = "TargetFrame", frameArchor = "TOPLEFT", xArchor = "LEFT", y = -4, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
PartyMemberFrame1 = {frameName = "PartyMemberFrame1", frameArchor = "TOPLEFT", xArchor = "LEFT", y = -128, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
TicketStatusFrame = {frameName = "TicketStatusFrame", frameArchor = "TOPRIGHT", xArchor = "RIGHT", y = 0, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
BuffFrame = {frameName = "BuffFrame", frameArchor = "TOPRIGHT", xArchor = "RIGHT", y = -13, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
MinimapCluster = {frameName = "MinimapCluster", frameArchor = "TOPRIGHT", xArchor = "RIGHT", y = 0, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
WorldStateAlwaysUpFrame = {frameName = "WorldStateAlwaysUpFrame", frameArchor = "TOP", xArchor = "CENTER", y = -15, | |
position = TITAN_PANEL_PLACE_TOP, addonAdj = false}, | |
MainMenuBar = {frameName = "MainMenuBar", frameArchor = "BOTTOM", xArchor = "CENTER", y = 0, | |
position = TITAN_PANEL_PLACE_BOTTOM, addonAdj = false}, | |
MultiBarRight = {frameName = "MultiBarRight", frameArchor = "BOTTOMRIGHT", xArchor = "RIGHT", y = 98, | |
position = TITAN_PANEL_PLACE_BOTTOM, addonAdj = false}, | |
OverrideActionBar = {frameName = "OverrideActionBar", frameArchor = "BOTTOM", xArchor = "CENTER", y = 0, | |
position = TITAN_PANEL_PLACE_BOTTOM, addonAdj = false}, | |
} | |
--[[ local | |
NAME: TitanMovableFrame_CheckThisFrame | |
DESC: Add the given frame to the list so it will be checked. Once 'full' the table will be looped through to see if the frame must be moved or not. | |
VAR: frameName - frame to check | |
OUT: None | |
NOTE: | |
- The frame is added to TitanMovable. | |
:NOTE | |
--]] | |
local function TitanMovableFrame_CheckThisFrame(frameName) | |
-- For safety check if the frame is in the table to adjust | |
if TitanMovableData[frameName] then | |
table.insert(TitanMovable, frameName) | |
end | |
end | |
--[[ Titan | |
NAME: TitanMovable_AdjustTimer | |
DESC: Cancel then add the given timer. The timer must be in TitanTimers. | |
VAR: ttype - The timer type (string) as defined in TitanTimers | |
OUT: None | |
--]] | |
function TitanMovable_AdjustTimer(ttype) | |
local timer = TitanTimers[ttype] | |
if timer then | |
TitanPanelAce.CancelAllTimers(timer.obj) | |
TitanPanelAce.ScheduleTimer(timer.obj, timer.callback, timer.delay) | |
end | |
end | |
--[[ Titan | |
NAME: TitanMovable_AddonAdjust | |
DESC: Set the given frame to be adjusted or not by another addon. This is called from TitanUtils for a developer API. | |
VAR: frame - frame name (string) | |
VAR: bool - true (addon will adjust) or false (Titan will use its settings) | |
OUT: None | |
--]] | |
function TitanMovable_AddonAdjust(frame, bool) | |
for index, value in pairs(TitanMovableData) do | |
frameData = value | |
if frameData then | |
frameName = frameData.frameName; | |
end | |
if (frame == frameName) then | |
frameData.addonAdj = bool | |
end | |
end | |
end | |
--[[ API | |
NAME: TitanMovable_GetPanelYOffset | |
DESC: Get the Y axis offset Titan needs (1 or 2 bars) at the given position - top or bottom. | |
VAR: framePosition - TITAN_PANEL_PLACE_TOP or TITAN_PANEL_PLACE_BOTTOM | |
OUT: Y axis offset, in pixels | |
NOTE: | |
- The prefered method to determine the Y offset needed by using TitanUtils_GetBarAnchors(). | |
:NOTE | |
--]] | |
function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons | |
-- Both top & bottom are figured out but only the | |
-- requested postion is returned | |
local barnum_top = 0; | |
local barnum_bot = 0 | |
-- If user has the top adjust set then determine the | |
-- top offset | |
if not TitanPanelGetVar("ScreenAdjust") then | |
if TitanPanelGetVar("Bar_Show") then | |
barnum_top = 1 | |
end | |
if TitanPanelGetVar("Bar2_Show") then | |
barnum_top = 2 | |
end | |
end | |
-- If user has the top adjust set then determine the | |
-- bottom offset | |
if not TitanPanelGetVar("AuxScreenAdjust") then | |
if TitanPanelGetVar("AuxBar_Show") then | |
barnum_bot = 1 | |
end | |
if TitanPanelGetVar("AuxBar2_Show") then | |
barnum_bot = 2 | |
end | |
end | |
local scale = TitanPanelGetVar("Scale") | |
-- return the requested offset | |
-- 0 will be returned if the user has not bars showing | |
-- or the scale is not valid | |
if scale and framePosition then | |
if framePosition == TITAN_PANEL_PLACE_TOP then | |
return (-TITAN_PANEL_BAR_HEIGHT * scale)*(barnum_top); | |
elseif framePosition == TITAN_PANEL_PLACE_BOTTOM then | |
return (TITAN_PANEL_BAR_HEIGHT * scale)*(barnum_bot)-1; | |
-- no idea why -1 is needed... seems anchoring to bottom is off a pixel | |
end | |
end | |
return 0 | |
end | |
--[[ local | |
NAME: TitanMovableFrame_GetXOffset | |
DESC: Get the x axis offset Titan needs to adjust the given frame. | |
VAR: frame - frame object | |
VAR: point - "LEFT" / "RIGHT" / "TOP" / "BOTTOM" / "CENTER" | |
OUT: int - X axis offset, in pixels | |
--]] | |
local function TitanMovableFrame_GetXOffset(frame, point) | |
-- A valid frame and point is required | |
-- Determine a proper X offset using the given point (position) | |
local ret = 0 -- In case the inputs were invalid or the point was not relevant to the frame then return 0 | |
if frame and point then | |
if point == "LEFT" and frame:GetLeft() and UIParent:GetLeft() then | |
ret = frame:GetLeft() - UIParent:GetLeft(); | |
elseif point == "RIGHT" and frame:GetRight() and UIParent:GetRight() then | |
ret = frame:GetRight() - UIParent:GetRight(); | |
elseif point == "TOP" and frame:GetTop() and UIParent:GetTop() then | |
ret = frame:GetTop() - UIParent:GetTop(); | |
elseif point == "BOTTOM" and frame:GetBottom() and UIParent:GetBottom() then | |
ret = frame:GetBottom() - UIParent:GetBottom(); | |
elseif point == "CENTER" and frame:GetLeft() and frame:GetRight() | |
and UIParent:GetLeft() and UIParent:GetRight() then | |
local framescale = frame.GetScale and frame:GetScale() or 1; | |
ret = (frame:GetLeft()* framescale + frame:GetRight() | |
* framescale - UIParent:GetLeft() - UIParent:GetRight()) / 2; | |
end | |
end | |
return ret | |
end | |
--[[ Titan | |
NAME: TitanMovableFrame_CheckFrames | |
DESC: Determine the frames that may need to be moved at the given position. | |
VAR: position - TITAN_PANEL_PLACE_TOP / TITAN_PANEL_PLACE_BOTTOM / TITAN_PANEL_PLACE_BOTH | |
OUT: None | |
--]] | |
function TitanMovableFrame_CheckFrames(position) | |
-- reset the frames to move | |
TitanMovable = {}; | |
-- check top as requested | |
if (position == TITAN_PANEL_PLACE_TOP) | |
or position == TITAN_PANEL_PLACE_BOTH then | |
-- Move PlayerFrame | |
TitanMovableFrame_CheckThisFrame(PlayerFrame:GetName()) | |
-- Move TargetFrame | |
TitanMovableFrame_CheckThisFrame(TargetFrame:GetName()) | |
-- Move PartyMemberFrame | |
TitanMovableFrame_CheckThisFrame(PartyMemberFrame1:GetName()) | |
-- Move TicketStatusFrame | |
if TitanPanelGetVar("TicketAdjust") then | |
TitanMovableFrame_CheckThisFrame(TicketStatusFrame:GetName()) | |
end | |
-- Move MinimapCluster | |
if not CleanMinimap then | |
if not TitanPanelGetVar("MinimapAdjust") then | |
TitanMovableFrame_CheckThisFrame(MinimapCluster:GetName()) | |
end | |
end | |
-- Move BuffFrame | |
TitanMovableFrame_CheckThisFrame(BuffFrame:GetName()) | |
-- Move WorldStateAlwaysUpFrame | |
-- TitanMovableFrame_CheckThisFrame(WorldStateAlwaysUpFrame:GetName()); | |
--[[ -- Move OrderHallCommandBar | |
if OrderHallCommandBar then | |
TitanMovableFrame_CheckThisFrame(OrderHallCommandBar:GetName()); | |
end]]-- | |
end | |
-- check bottom as requested | |
if (position == TITAN_PANEL_PLACE_BOTTOM) | |
or position == TITAN_PANEL_PLACE_BOTH then | |
-- Move MainMenuBar | |
TitanMovableFrame_CheckThisFrame(MainMenuBar:GetName()); | |
-- Move OverrideActionBar | |
TitanMovableFrame_CheckThisFrame(OverrideActionBar:GetName()); | |
end | |
end | |
--[[ Titan | |
NAME: TitanMovableFrame_MoveFrames | |
DESC: Actually adjust the frames at the given position. | |
VAR: position - TITAN_PANEL_PLACE_TOP / TITAN_PANEL_PLACE_BOTTOM / TITAN_PANEL_PLACE_BOTH | |
OUT: None | |
--]] | |
function TitanMovableFrame_MoveFrames(position) | |
-- Once the frames to check have been collected, | |
-- move them as needed. | |
local frameData, frame, frameName, frameArchor, xArchor, y, xOffset, yOffset, panelYOffset; | |
-- Collect the frames we need to move | |
TitanMovableFrame_CheckFrames(position); | |
-- move them... | |
if not InCombatLockdown() then | |
local adj_frame = true | |
for index, value in pairs(TitanMovable) do | |
adj_frame = true -- assume the frame is to be adjusted | |
frameData = TitanMovableData[value]; | |
if frameData then | |
frame = _G[frameData.frameName]; | |
frameName = frameData.frameName; | |
frameArchor = frameData.frameArchor; | |
end | |
if (frame and (frame:IsUserPlaced())) | |
then | |
-- The user has positioned the frame | |
adj_frame = false | |
end | |
if frameData.addonAdj then | |
-- An addon has taken control of the frame | |
adj_frame = false | |
end | |
if adj_frame then | |
xArchor = frameData.xArchor; | |
y = frameData.y; | |
panelYOffset = TitanMovable_GetPanelYOffset(frameData.position); | |
xOffset = TitanMovableFrame_GetXOffset(frame, xArchor); | |
-- properly adjust buff frame(s) if GM Ticket is visible | |
-- Use IsShown rather than IsVisible. In some cases (after closing | |
-- full screen map) the ticket may not yet be visible. | |
if (frameName == "BuffFrame") | |
and TicketStatusFrame:IsShown() | |
and TitanPanelGetVar("TicketAdjust") then | |
yOffset = (-TicketStatusFrame:GetHeight()) | |
+ panelYOffset | |
else | |
yOffset = y + panelYOffset; | |
end | |
-- properly adjust MinimapCluster if its border is hidden | |
if frameName == "MinimapCluster" | |
and MinimapBorderTop | |
and not MinimapBorderTop:IsShown() then | |
yOffset = yOffset + (MinimapBorderTop:GetHeight() * 3/5) - 5 | |
end | |
-- adjust the MainMenuBar according to its scale | |
if frameName == "MainMenuBar" and MainMenuBar:IsVisible() then | |
local framescale = MainMenuBar:GetScale() or 1; | |
yOffset = yOffset / framescale; | |
end | |
-- account for Reputation Status Bar (doh) | |
local playerlevel = UnitLevel("player"); | |
if frameName == "MultiBarRight" | |
and ReputationWatchStatusBar:IsVisible() | |
and playerlevel < _G["MAX_PLAYER_LEVEL"] then | |
yOffset = yOffset + 8; | |
end | |
frame:ClearAllPoints(); | |
frame:SetPoint(frameArchor, "UIParent", frameArchor, | |
xOffset, yOffset); | |
else | |
--Leave frame where it is as it has been moved by a user | |
end | |
-- Move bags as needed | |
UpdateContainerFrameAnchors(); | |
end | |
else | |
-- nothing to do | |
end | |
end | |
--[[ Titan | |
NAME: TitanAdjustBottomFrames | |
DESC: Adjust the frames at TITAN_PANEL_PLACE_BOTTOM. | |
VAR: None | |
OUT: None | |
--]] | |
function TitanAdjustBottomFrames() | |
TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTTOM, true) | |
end | |
--[[ Titan | |
NAME: Titan_FCF_UpdateDockPosition | |
DESC: Secure post hook to help adjust the chat / log frame. | |
VAR: None | |
OUT: None | |
NOTE: | |
- This is required because Blizz adjusts the chat frame relative to other frames so some of the Blizz code is copied. | |
- If in combat or if the user has moved the chat frame then no action is taken. | |
- The frame is adjusted in the Y axis only. | |
:NOTE | |
--]] | |
local function Titan_FCF_UpdateDockPosition() | |
if not Titan__InitializedPEW | |
or not TitanPanelGetVar("LogAdjust") | |
or TitanPanelGetVar("AuxScreenAdjust") then | |
return | |
end | |
if not InCombatLockdown() or (InCombatLockdown() | |
and not _G["DEFAULT_CHAT_FRAME"]:IsProtected()) then | |
local panelYOffset = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM); | |
local scale = TitanPanelGetVar("Scale"); | |
if scale then | |
panelYOffset = panelYOffset + (24 * scale) -- after 3.3.5 an additional adjust was needed. why? idk | |
end | |
--[[ Blizz code | |
if _G["DEFAULT_CHAT_FRAME"]:IsUserPlaced() then | |
if _G["SIMPLE_CHAT"] ~= "1" then return end | |
end | |
local chatOffset = 85 + panelYOffset; | |
if GetNumShapeshiftForms() > 0 or HasPetUI() or PetHasActionBar() then | |
if MultiBarBottomLeft:IsVisible() then | |
chatOffset = chatOffset + 55; | |
else | |
chatOffset = chatOffset + 15; | |
end | |
elseif MultiBarBottomLeft:IsVisible() then | |
chatOffset = chatOffset + 15; | |
end | |
_G["DEFAULT_CHAT_FRAME"]:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 32, chatOffset); | |
FCF_DockUpdate(); | |
--]] | |
if ( DEFAULT_CHAT_FRAME:IsUserPlaced() ) then | |
return; | |
end | |
local chatOffset = 85 + panelYOffset; -- Titan change to adjust Y offset | |
if ( GetNumShapeshiftForms() > 0 or HasPetUI() or PetHasActionBar() ) then | |
if ( MultiBarBottomLeft:IsShown() ) then | |
chatOffset = chatOffset + 55; | |
else | |
chatOffset = chatOffset + 15; | |
end | |
elseif ( MultiBarBottomLeft:IsShown() ) then | |
chatOffset = chatOffset + 15; | |
end | |
DEFAULT_CHAT_FRAME:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", | |
32, chatOffset); | |
FCF_DockUpdate(); | |
end | |
end | |
--[[ Titan | |
NAME: Titan_ContainerFrames_Relocate | |
DESC: Secure post hook to help adjust the bag frames. | |
VAR: None | |
OUT: None | |
NOTE: | |
- The frame is adjusted in the Y axis only. | |
- The Blizz routine "ContainerFrames_Relocate" should be examined for any conditions it checks and any changes to the SetPoint. | |
If Blizz changes the anchor points the SetPoint here must change as well!! | |
The Blizz routine calculates X & Y offsets to UIParent (screen) so there is not need to store the prior offsets. | |
Like the Blizz routine we search through the visible bags. Unlike the Blizz routine we only care about the first of each column to adjust for Titan. | |
This way the Blizz code does not need to be copied here. | |
:NOTE | |
--]] | |
local function Titan_ContainerFrames_Relocate() | |
if not TitanPanelGetVar("BagAdjust") then | |
return | |
end | |
local panelYOffset = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM) | |
local off_y = 10000 -- something ridiculously high | |
local bottom_y = 0 | |
local right_x = 0 | |
for index, frameName in ipairs(ContainerFrame1.bags) do | |
frame = _G[frameName]; | |
if frame:GetBottom() then bottom_y = frame:GetBottom() end | |
if ( bottom_y < off_y ) then | |
-- Start a new column | |
right_x = frame:GetRight() | |
frame:ClearAllPoints(); | |
frame:SetPoint("BOTTOMRIGHT", frame:GetParent(), | |
"BOTTOMLEFT", -- changed because we are taking the current x value | |
right_x, -- x is not adjusted | |
bottom_y + panelYOffset -- y | |
) | |
end | |
off_y = bottom_y | |
end | |
end | |
--[[ Titan | |
NAME: TitanMovableFrame_AdjustBlizzardFrames | |
DESC: Calls the helper routines to adjust the chat / log frame and bag frames. | |
VAR: None | |
OUT: None | |
NOTE: | |
- This is required because Blizz (or addons) could adjust the chat frame outside the events that Titan registers for. | |
- If in combat or if the user has moved the chat frame then no action is taken. | |
- The frame is adjusted in the Y axis only. | |
:NOTE | |
--]] | |
local function TitanMovableFrame_AdjustBlizzardFrames() | |
if not InCombatLockdown() then | |
Titan_FCF_UpdateDockPosition(); | |
Titan_ContainerFrames_Relocate(); | |
end | |
end | |
--[[ Titan | |
NAME: Titan_AdjustUIScale | |
DESC: Adjust the scale of Titan bars and plugins to the user selected scaling. This is called by the secure post hooks to the 'Video Options Frame'. | |
VAR: None | |
OUT: None | |
--]] | |
local function Titan_AdjustUIScale() | |
Titan_AdjustScale() | |
end | |
--[[ Titan | |
NAME: Titan_Hook_Adjust_Both | |
DESC: Adjust top and bottom frames. This is called by the secure post hooks. | |
VAR: None | |
OUT: None | |
NOTE: | |
- Starts a timer () which is a callback to Titan_ManageFramesNew. | |
- These could arrive quickly. To prevent many adjusts from stacking, cancel any pending then queue this one. | |
:NOTE | |
--]] | |
local function Titan_Hook_Adjust_Both() | |
TitanMovable_AdjustTimer("Adjust") | |
end | |
--[[ Titan | |
NAME: TitanPanel_AdjustFrames | |
DESC: Adjust the frames at the given position. | |
VAR: position - TITAN_PANEL_PLACE_TOP / TITAN_PANEL_PLACE_BOTTOM / TITAN_PANEL_PLACE_BOTH | |
VAR: blizz - true or false | |
OUT: None | |
NOTE: | |
- if blizz is true then the post hook code for chat / log frame and the bag frames is run | |
:NOTE | |
--]] | |
function TitanPanel_AdjustFrames(position, blizz) | |
-- Adjust frame positions top only, bottom only, or both | |
TitanMovableFrame_MoveFrames(position) | |
-- move the Blizzard frames if requested | |
if blizz and position == (TITAN_PANEL_PLACE_BOTTOM or TITAN_PANEL_PLACE_TOP) then | |
TitanMovableFrame_AdjustBlizzardFrames() | |
end | |
end | |
--[[ Titan | |
NAME: Titan_ManageFramesNew | |
DESC: Adjust the frames at TITAN_PANEL_PLACE_BOTH. | |
VAR: None | |
OUT: None | |
--]] | |
function Titan_ManageFramesNew() | |
TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, false) | |
return | |
end | |
--[[ Titan | |
NAME: Titan_AdjustScale | |
DESC: Update the bars and plugins to the user selected scale. | |
VAR: None | |
OUT: None | |
NOTE: | |
- Ensure Titan has done its initialization before this is run. | |
:NOTE | |
--]] | |
function Titan_AdjustScale() | |
-- Only adjust if Titan is fully initialized | |
if Titan__InitializedPEW then | |
TitanPanel_SetScale(); | |
TitanPanel_ClearAllBarTextures() | |
TitanPanel_CreateBarTextures() | |
for idx,v in pairs (TitanBarData) do | |
TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name | |
, TITAN_PANEL_PLACE_TOP); | |
end | |
TitanPanelBarButton_DisplayBarsWanted() | |
TitanPanel_RefreshPanelButtons(); | |
end | |
end | |
function Titan_ManageFramesTest1() | |
if Titan__InitializedPEW then | |
-- We know the desired bars are now drawn so we can adjust | |
if InCombatLockdown() then | |
else | |
--TitanDebug ("Titan_ManageFramesTest1 ") | |
left = floor(OverrideActionBar:GetLeft() + 0.5) | |
left = GetScreenWidth() / 2 | |
bot = floor(OverrideActionBar:GetBottom() + 0.5) | |
TitanDebug("... OverrideActionBar " | |
..(bot or "?").." " | |
..(left or "?").." " | |
) | |
point, relFrame, relPoint, xOff, yOff = OverrideActionBar:GetPoint(OverrideActionBar:GetNumPoints()) | |
OverrideActionBar:ClearAllPoints() | |
OverrideActionBar:SetPoint("BOTTOM", TitanPanelBottomAnchor, "TOP", left, 0) | |
OverrideActionBar:SetPoint(point, relFrame, relPoint, xOff, TitanPanelBottomAnchor:GetTop()+0) | |
left = OverrideActionBar:GetCenter() | |
bot = OverrideActionBar:GetBottom() | |
TitanDebug("... OverrideActionBar " | |
..(bot or "?").." " | |
..(left or "?").." " | |
) | |
end | |
end | |
-- There is a chance the person stays in combat so this could | |
-- keep looping... | |
end | |
function Titan_GetFrameOrigPositions() | |
local orig = {} | |
local frameData | |
local point, relTo, relPoint, xOff, yOff = "", {}, "", 0, 0 | |
local relFrame = "" | |
for index, value in pairs(TitanMovableData) do | |
frameData = TitanMovableData[index]; | |
if frameData then | |
point, relTo, relPoint, xOff, yOff = "", {}, "", 0, 0 | |
frame = _G[frameData.frameName]; | |
point, relTo, relPoint, xOff, yOff = frame:GetPoint(frame:GetNumPoints()) | |
TitanDebug("Orig: " | |
..frameData.frameName.." " | |
..relTo:GetName() or "?".." " | |
) | |
orig = { | |
point = point, | |
relTo = relTo, | |
relPoint = relPoint, | |
xOff = xOff, | |
yOff = yOff, | |
} | |
TitanMovableOrig[frameData.frameName] = orig | |
end | |
end | |
end | |
function Titan_SetFrameOrigPositions() | |
local left = 0 | |
local bot = 0 | |
-- TESTING!!! | |
TitanDebug("TESTING!!: Setting frames to Titan anchor " | |
..(TitanPanelBottomAnchor:GetTop() or "?").." " | |
) | |
left = MainMenuBar:GetLeft() | |
left = GetScreenWidth() / 2 | |
bot = MainMenuBar:GetBottom() | |
TitanDebug("... MainMenuBar " | |
..(bot or "?").." " | |
..(left or "?").." " | |
) | |
-- local point, relFrame, relPoint, xOff, yOff = MainMenuBar:GetPoint(MainMenuBar:GetNumPoints()) | |
MainMenuBar:ClearAllPoints() | |
MainMenuBar:SetPoint("BOTTOM", TitanPanelBottomAnchor, "TOP", left, 0) | |
-- MainMenuBar:SetPoint(point, relFrame, relPoint, xOff, TitanPanelBottomAnchor:GetTop()+0) | |
left = MainMenuBar:GetLeft() | |
bot = MainMenuBar:GetBottom() | |
TitanDebug("... MainMenuBar " | |
..(bot or "?").." " | |
..(left or "?").." " | |
) | |
left = floor(OverrideActionBar:GetLeft() + 0.5) | |
left = GetScreenWidth() / 2 | |
bot = floor(OverrideActionBar:GetBottom() + 0.5) | |
TitanDebug("... OverrideActionBar " | |
..(bot or "?").." " | |
..(left or "?").." " | |
) | |
-- point, relFrame, relPoint, xOff, yOff = OverrideActionBar:GetPoint(OverrideActionBar:GetNumPoints()) | |
OverrideActionBar:ClearAllPoints() | |
OverrideActionBar:SetPoint("BOTTOM", TitanPanelBottomAnchor, "TOP", left, 0) | |
-- OverrideActionBar:SetPoint(point, relFrame, relPoint, xOff, TitanPanelBottomAnchor:GetTop()+0) | |
left = OverrideActionBar:GetCenter() | |
bot = OverrideActionBar:GetBottom() | |
TitanDebug("... OverrideActionBar " | |
..(bot or "?").." " | |
..(left or "?").." " | |
) | |
if false then | |
left = MultiBarRight:GetLeft() | |
MultiBarRight:ClearAllPoints() | |
MultiBarRight:SetPoint("BOTTOMLEFT", TitanPanelBottomAnchor, "TOP", left, 98) | |
left = TargetFrame:GetLeft() | |
TargetFrame:ClearAllPoints() | |
TargetFrame:SetPoint("TOPLEFT", TitanPanelTopAnchor, "BOTTOM", left, -4) | |
left = PlayerFrame:GetLeft() | |
PlayerFrame:ClearAllPoints() | |
PlayerFrame:SetPoint("TOPLEFT", TitanPanelTopAnchor, "BOTTOM", left, -4) | |
left = PartyMemberFrame1:GetLeft() | |
PartyMemberFrame1:ClearAllPoints() | |
PartyMemberFrame1:SetPoint("TOPLEFT", TitanPanelTopAnchor, "BOTTOM", left, -128) | |
left = TicketStatusFrame:GetLeft() | |
TicketStatusFrame:ClearAllPoints() | |
TicketStatusFrame:SetPoint("TOPLEFT", TitanPanelTopAnchor, "BOTTOM", left, 0) | |
left = BuffFrame:GetLeft() | |
BuffFrame:ClearAllPoints() | |
BuffFrame:SetPoint("TOPLEFT", TitanPanelTopAnchor, "BOTTOM", left, -13) | |
left = MinimapCluster:GetLeft() | |
MinimapCluster:ClearAllPoints() | |
MinimapCluster:SetPoint("TOPLEFT", TitanPanelTopAnchor, "BOTTOM", left, 0) | |
end | |
end | |
--[[ Titan | |
NAME: TitanMovable_SecureFrames | |
DESC: Once Titan is initialized create the post hooks we need to help adjust frames properly. | |
VAR: None | |
OUT: None | |
NOTE: | |
- The secure post hooks are required because Blizz adjusts frames Titan is interested in at times other than the events Titan registers for. | |
- This used to be inline code but was moved to a routine to avoid errors as Titan loaded. | |
:NOTE | |
--]] | |
function TitanMovable_SecureFrames() | |
if not TitanPanelAce:IsHooked("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) then | |
TitanPanelAce:SecureHook("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) -- FloatingChatFrame | |
end | |
if not TitanPanelAce:IsHooked("UIParent_ManageFramePositions", Titan_Hook_Adjust_Both) then | |
TitanPanelAce:SecureHook("UIParent_ManageFramePositions", Titan_Hook_Adjust_Both) -- UIParent.lua | |
TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTTOM, false) | |
end | |
if not TitanPanelAce:IsHooked(TicketStatusFrame, "Show", Titan_Hook_Adjust_Both) then | |
-- Titan Hooks to Blizzard Frame positioning functions | |
--TitanPanelAce:SecureHook("TicketStatusFrame_OnShow", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
--TitanPanelAce:SecureHook("TicketStatusFrame_OnHide", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
TitanPanelAce:SecureHook(TicketStatusFrame, "Show", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
TitanPanelAce:SecureHook(TicketStatusFrame, "Hide", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
TitanPanelAce:SecureHook(MainMenuBar, "Show", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
TitanPanelAce:SecureHook(MainMenuBar, "Hide", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
TitanPanelAce:SecureHook(OverrideActionBar, "Show", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
TitanPanelAce:SecureHook(OverrideActionBar, "Hide", Titan_Hook_Adjust_Both) -- HelpFrame.xml | |
-- TitanPanelAce:SecureHook(OverrideActionBar, "Show", Titan_ManageFramesTest1) -- HelpFrame.xml | |
-- TitanPanelAce:SecureHook(OverrideActionBar, "Hide", Titan_ManageFramesTest1) -- HelpFrame.xml | |
TitanPanelAce:SecureHook("UpdateContainerFrameAnchors", Titan_ContainerFrames_Relocate) -- ContainerFrame.lua | |
TitanPanelAce:SecureHook(WorldMapFrame, "Hide", Titan_Hook_Adjust_Both) -- WorldMapFrame.lua | |
TitanPanelAce:SecureHook("BuffFrame_Update", Titan_Hook_Adjust_Both) -- BuffFrame.lua | |
end | |
if not TitanPanelAce:IsHooked("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) then | |
-- Properly Adjust UI Scale if set | |
-- Note: These are the least intrusive hooks we could think of, to properly adjust the Titan Bar(s) | |
-- without having to resort to a SetCvar secure hook. Any addon using SetCvar should make sure to use the 3rd | |
-- argument in the API call and trigger the CVAR_UPDATE event with an appropriate argument so that other addons | |
-- can detect this behavior and fire their own functions (where applicable). | |
TitanPanelAce:SecureHook("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) -- VideoOptionsFrame.lua | |
TitanPanelAce:SecureHook(VideoOptionsFrame, "Hide", Titan_AdjustUIScale) -- VideoOptionsFrame.xml | |
end | |
-- TitanPanelAce:SecureHook(OverrideActionBar, "SetPoint", Titan_ManageFramesTest1) -- | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment