Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Azurah = _G['Azurah'] -- grab addon table from global
- local L = Azurah:GetLocale()
- -- UPVALUES --
- local strformat = string.format
- local uiFrames = {
- ['ZO_PlayerAttributeHealth'] = {1, L.Health},
- ['ZO_PlayerAttributeSiegeHealth'] = {2, L.HealthSiege},
- ['ZO_PlayerAttributeMagicka'] = {1, L.Magicka},
- ['ZO_PlayerAttributeWerewolf'] = {2, L.Werewolf},
- ['ZO_PlayerAttributeStamina'] = {1, L.Stamina},
- ['ZO_PlayerAttributeMountStamina'] = {2, L.StaminaMount},
- ['ZO_PlayerProgressBar'] = {1, L.Experience},
- ['ZO_SynergyTopLevelContainer'] = {1, L.Synergy},
- ['ZO_CompassFrame'] = {1, L.Compass},
- ['ZO_TargetUnitFramereticleover'] = {1, L.ReticleOver},
- ['ZO_ActionBar1'] = {1, L.ActionBar},
- ['ZO_SmallGroupAnchorFrame'] = {1, L.Group},
- ['ZO_LargeGroupAnchorFrame1'] = {1, L.Raid1},
- ['ZO_LargeGroupAnchorFrame2'] = {1, L.Raid2},
- ['ZO_LargeGroupAnchorFrame3'] = {1, L.Raid3},
- ['ZO_LargeGroupAnchorFrame4'] = {1, L.Raid4},
- ['ZO_LargeGroupAnchorFrame5'] = {1, L.Raid5},
- ['ZO_LargeGroupAnchorFrame6'] = {1, L.Raid6},
- ['ZO_FocusedQuestTrackerPanel'] = {1, L.FocusedQuest},
- ['ZO_PlayerToPlayerAreaPromptContainer'] = {1, L.PlayerPrompt},
- ['ZO_AlertTextNotification'] = {1, L.AlertText},
- }
- local defaultUIData = {}
- local uiPanel
- -- --------------------------------------------
- -- DEFAULT ------------------------------------
- -- --------------------------------------------
- function Azurah:RecordDefaultData()
- for frame in pairs(uiFrames) do -- record default position data
- local _, point, rel, relPoint, x, y = _G[frame]:GetAnchor()
- defaultUIData[frame] = {
- ['point'] = point,
- ['rel'] = rel,
- ['relPoint'] = relPoint,
- ['x'] = x,
- ['y'] = y,
- ['scale'] = _G[frame]:GetScale()
- }
- end
- end
- function Azurah:RestoreDefaultData() -- reset all frames to default positions
- local data, obj
- for frame in pairs(uiFrames) do
- obj, data = _G[frame], defaultUIData[frame]
- if (self.db.uiData[frame]) then
- self.db.uiData[frame] = nil -- cleanse user data
- end
- obj:ClearAnchors()
- obj:SetAnchor(data.point, data.rel, data.relPoint, data.x, data.y)
- obj:SetScale(data.scale)
- self.movers[obj]:Sync() -- reset attachments to new frame positions
- end
- AZ_MOVED_COMPASS = false -- GLOBALS FOR WYKKYD
- AZ_MOVED_TARGET = false -- GLOBALS FOR WYKKYD
- end
- -- --------------------------------------------
- -- USER ---------------------------------------
- -- --------------------------------------------
- function Azurah:RecordUserData(frame, point, x, y, scale)
- if (not self.db.uiData[frame]) then
- self.db.uiData[frame] = {}
- end
- self.db.uiData[frame].point = point
- self.db.uiData[frame].x = x
- self.db.uiData[frame].y = y
- self.db.uiData[frame].scale = scale
- -- special cases
- if (frame == 'ZO_CompassframeName') then
- AZ_MOVED_COMPASS = true -- GLOBALS FOR WYKKYD
- end
- if (frame == 'ZO_TargetUnitFramereticleover') then
- AZ_MOVED_TARGET = true -- GLOBALS FOR WYKKYD
- end
- if (frame == 'ZO_PlayerAttributeHealth') then -- scale attached bar
- ZO_PlayerAttributeSiegeHealth:SetScale(scale)
- end
- if (frame == 'ZO_PlayerAttributeMagicka') then -- scale attached bar
- ZO_PlayerAttributeWerewolf:SetScale(scale)
- end
- if (frame == 'ZO_PlayerAttributeStamina') then -- scale attached bar
- ZO_PlayerAttributeMountStamina:SetScale(scale)
- end
- end
- function Azurah:RestoreUserData()
- local obj
- for frame, data in pairs(self.db.uiData) do
- if frame == "ZO_ExperienceBar" then
- self.db.uiData["ZO_PlayerProgressBar"] = data
- self.db.uiData["ZO_ExperienceBar"] = nil
- frame = "ZO_PlayerProgressBar"
- end
- obj = _G[frame]
- -- special casse
- if (frame == 'ZO_CompassFrame') then
- AZ_MOVED_COMPASS = true -- GLOBALS FOR WYKKYD
- end
- if (frame == 'ZO_TargetUnitFramereticleover') then
- AZ_MOVED_TARGET = true -- GLOBALS FOR WYKKYD
- end
- if (frame == 'ZO_AlertTextNotification') then -- set an actual size for positioning
- ZO_AlertTextNotification:SetDimensions(600, 56)
- end
- if (frame == 'ZO_PlayerToPlayerAreaPromptContainer') then -- special case, has no height
- ZO_PlayerToPlayerAreaPromptContainer:SetHeight(100)
- end
- if (frame == 'ZO_FocusedQuestTrackerPanel') then
- ZO_FocusedQuestTrackerPanel:SetHeight(200)
- end
- if (frame == 'ZO_PlayerAttributeHealth') then -- scale attached bar
- ZO_PlayerAttributeSiegeHealth:SetScale(data.scale)
- end
- if (frame == 'ZO_PlayerAttributeMagicka') then -- scale attached bar
- ZO_PlayerAttributeWerewolf:SetScale(data.scale)
- end
- if (frame == 'ZO_PlayerAttributeStamina') then -- scale attached bar
- ZO_PlayerAttributeMountStamina:SetScale(data.scale)
- end
- obj:ClearAnchors()
- obj:SetAnchor(data.point, GuiRoot, data.point, data.x, data.y)
- obj:SetScale(data.scale)
- end
- end
- -- --------------------------------------------
- -- UNLOCK PANEL -------------------------------
- -- --------------------------------------------
- local function CreateButton(text, anchor, yOffset)
- local btn = WINDOW_MANAGER:CreateControlFromVirtual(nil, uiPanel, 'ZO_DefaultButton')
- btn:SetAnchor(TOP, anchor, BOTTOM, 0, yOffset)
- btn:SetWidth(180)
- btn:SetHeight(24)
- btn:SetFont('ZoFontAnnounceSmall')
- btn:SetText(text)
- return btn
- end
- local function BuildUnlockPanel()
- -- base frame setup
- uiPanel = WINDOW_MANAGER:CreateControl(nil, GuiRoot, CT_TOPLEVELCONTROL)
- uiPanel:SetDimensions(180, 130)
- uiPanel:SetAnchor(CENTER)
- uiPanel:SetMouseEnabled(true)
- uiPanel:SetMovable(true)
- uiPanel:SetClampedToScreen(true)
- -- background
- uiPanel.bg = WINDOW_MANAGER:CreateControl(nil, uiPanel, CT_BACKDROP)
- uiPanel.bg:SetAnchorFill(uiPanel)
- uiPanel.bg:SetCenterColor(0, 0, 0, 0.5)
- uiPanel.bg:SetEdgeColor(0,0,0,1)
- uiPanel.bg:SetEdgeTexture('', 8, 8, 1, 0)
- uiPanel.bg:SetInsets(3,3,-3,-3)
- -- header
- uiPanel.header = WINDOW_MANAGER:CreateControl(nil, uiPanel, CT_LABEL)
- uiPanel.header:SetAnchor(TOP, uiPanel, TOP, 0, 4)
- uiPanel.header:SetFont('ZoFontWinH4')
- uiPanel.header:SetText(L.Azurah .. ' - ' .. L.UnlockHeader)
- -- snap button
- uiPanel.snap = CreateButton(L.UnlockGridDisable, uiPanel.header, 2)
- uiPanel.snap:SetHandler('OnClicked', function()
- Azurah.snapToGrid = not Azurah.snapToGrid
- uiPanel.snap:SetText(Azurah.snapToGrid and L.UnlockGridDisable or L.UnlockGridEnable)
- end)
- -- lock button
- uiPanel.lock = CreateButton(L.UnlockLockFrames, uiPanel.snap, 6)
- uiPanel.lock:SetHandler('OnClicked', function()
- Azurah:LockUI()
- end)
- -- reset to defaults button
- uiPanel.reset = CreateButton(L.UnlockReset, uiPanel.lock, 16)
- uiPanel.reset:SetHandler('OnClicked', function()
- uiPanel.confirm:SetHidden(false)
- uiPanel.reset:SetHidden(true)
- end)
- -- reset to defaults confirm button
- uiPanel.confirm = CreateButton(L.UnlockResetConfirm, uiPanel.lock, 16)
- uiPanel.confirm:SetHandler('OnClicked', function()
- Azurah:RestoreDefaultData()
- uiPanel.reset:SetHidden(false)
- uiPanel.confirm:SetHidden(true)
- end)
- uiPanel.confirm:SetHidden(true)
- -- handlers
- uiPanel:SetHandler('OnShow', function()
- uiPanel.confirm:SetHidden(true)
- uiPanel.reset:SetHidden(false)
- for _, mover in pairs(Azurah.movers) do
- mover:Show()
- end
- end)
- uiPanel:SetHandler('OnHide', function()
- for _, mover in pairs(Azurah.movers) do
- mover:Hide()
- end
- end)
- uiPanel:SetHandler('OnMouseUp', function()
- uiPanel:StopMovingOrResizing()
- end)
- Azurah.uiPanel = uiPanel
- end
- function Azurah:LockUI()
- self.uiUnlocked = false
- if (uiPanel) then
- uiPanel:SetHidden(true)
- end
- end
- function Azurah:UnlockUI()
- if (not uiPanel) then -- first time using the overlays, register!
- BuildUnlockPanel() -- build ui panel to
- local mover
- for frame, data in pairs(uiFrames) do
- if (frame == 'ZO_AlertTextNotification') then -- special case, has no dimensions
- ZO_AlertTextNotification:SetDimensions(600, 56)
- end
- if (frame == 'ZO_PlayerToPlayerAreaPromptContainer') then -- special case, has no height
- ZO_PlayerToPlayerAreaPromptContainer:SetHeight(100)
- end
- if (frame == 'ZO_FocusedQuestTrackerPanel') then
- ZO_FocusedQuestTrackerPanel:SetHeight(200)
- end
- mover = self.Mover:New(_G[frame], data[2])
- if (data[1] == 2) then -- anchored frame, show but disallow drag
- mover:SetMouseEnabled(false)
- mover.overlay:SetCenterColor(0.6, 0.6, 0.6, 0.32)
- mover.overlay:SetEdgeColor(0.6, 0.6, 0.6, 1)
- mover.label:SetColor(0.6, 0.6, 0.6, 1)
- end
- end
- end
- uiPanel:SetHidden(false)
- self.uiUnlocked = true
- end
- -- --------------------------------------------
- -- COMPASS PINS -------------------------------
- -- --------------------------------------------
- local compassPinScaleRef
- local function OnPinAreaChanged()
- for k, v in pairs(COMPASS.areaAnimationPool:GetActiveObjects()) do
- v.areaTexture:SetScale(1 / compassPinScaleRef)
- end
- end
- function Azurah:ConfigureCompass()
- ZO_Compass:SetScale(self.db.compassPinScale)
- compassPinScaleRef = self.db.compassPinScale
- if (self.db.compassPinScale == 1) then -- default size
- EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_PLAYER_IN_PIN_AREA_CHANGED) -- unregister check event
- EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_QUEST_POSITION_REQUEST_COMPLETE) -- unregister check event
- else -- non-default size
- EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_IN_PIN_AREA_CHANGED, OnPinAreaChanged)
- EVENT_MANAGER:RegisterForEvent(self.name, EVENT_QUEST_POSITION_REQUEST_COMPLETE, OnPinAreaChanged)
- end
- OnPinAreaChanged()
- if (self.db.compassHidePinLabel) then
- ZO_CompassCenterOverPinLabel:SetHidden(true)
- ZO_CompassCenterOverPinLabel:SetAlpha(0)
- else
- ZO_CompassCenterOverPinLabel:SetHidden(false)
- ZO_CompassCenterOverPinLabel:SetAlpha(1)
- end
- end
- function Azurah:InitializeUnlock()
- self:RecordDefaultData()
- self:RestoreUserData()
- ZO_PreHookHandler(ZO_ActionBar1, 'OnShow', function()
- if (self.db.uiData['ZO_ActionBar1']) then -- user has moved the action bar
- if (ZO_Skills:IsHidden()) then -- restore to user location on skill window close
- local data = self.db.uiData['ZO_ActionBar1']
- ZO_ActionBar1:ClearAnchors()
- ZO_ActionBar1:SetAnchor(data.point, GuiRoot, data.point, data.x, data.y)
- ZO_ActionBar1:SetScale(data.scale)
- else -- skill window is open, restore default scale (window is moved by stock code)
- ZO_ActionBar1:SetScale(1)
- end
- end
- end)
- ZO_PreHookHandler(ZO_Skills, 'OnShow', function()
- if (self.db.uiData['ZO_ActionBar1']) then -- user moved the action bar, make sure to move it to its proper place when skill window is open
- ZO_ActionBar1:SetScale(1)
- ZO_ActionBar1:ClearAnchors()
- ZO_ActionBar1:SetAnchor(BOTTOM, ZO_Skills, BOTTOM, -40, 40)
- end
- end)
- self:ConfigureCompass()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement