forked from brues/pfUI
The built-in pages moved to gui_pages.lua as build functions that add settings (p:Checkbox, p:Dropdown and so on) instead of making frames. All of them share one ScrollBox list, which keeps rows from the row templates only for the settings in view. Each page keeps its scroll position. A tree replaces the two columns of tabs: a category opens its first page and shows its pages, and the other categories close. Pages have ids, and pfUI.gui:OpenPage(id) opens one. Unlock mode opens a frame's page by its id. Its "Group Frames" links had opened nothing and the stance bar link the wrong page; the castbars now open their own pages. Plugin pages from CreateGUIEntry stay frame pages. Their populate runs on the first show with `this` as the content, and CreateConfig stacks its rows there as before. The About page is a frame page too, and reads its values when it shows instead of every second. Search goes through the settings of the list pages without building them, and through the rows of the frame pages, which it builds on the first search. A result opens its page and marks its row. Focusing the search box no longer opens an empty result page. A change refreshes the other rows in view, so the uneven orientation dropdown follows a new bar layout without keeping a reference to its row.
746 lines
25 KiB
Lua
746 lines
25 KiB
Lua
pfUI:RegisterModule("unlock", function ()
|
|
local rawborder, default_border = GetBorderSize()
|
|
|
|
-- grouped frames
|
|
local clusters = {
|
|
-- Name Shift Ctrl
|
|
{ "pfCombo", 5 },
|
|
{ "pfRaid", 40, 5 },
|
|
{ "pfRaidPet", 40, 5 },
|
|
{ "pfGroup", 4 },
|
|
{ "pfLootRollFrame", 4 },
|
|
}
|
|
|
|
local anchors = {
|
|
"TOPLEFT", "TOP", "TOPRIGHT", "RIGHT", "BOTTOMRIGHT", "BOTTOM", "BOTTOMLEFT", "LEFT", "CENTER"
|
|
}
|
|
|
|
|
|
local spanframe = CreateFrame("Frame", "pfUnlockSelector", UIParent)
|
|
spanframe:Hide()
|
|
|
|
-- the config page of each frame label (the page ids of gui_pages.lua)
|
|
local frame_configs = {
|
|
-- unitframes
|
|
["Player"] = "unitframes.player",
|
|
["Target"] = "unitframes.target",
|
|
["TargetTarget"] = "unitframes.ttarget",
|
|
["TargetTargetTarget"] = "unitframes.tttarget",
|
|
["Pet"] = "unitframes.pet",
|
|
["PetTarget"] = "unitframes.ptarget",
|
|
["Focus"] = "unitframes.focus",
|
|
|
|
-- combopoints
|
|
["Combo%d"] = "unitframes.general",
|
|
|
|
-- groupframes
|
|
["Raid%d"] = "unitframes.raid",
|
|
["Raid%d%d"] = "unitframes.raid",
|
|
["RaidPet%d"] = "unitframes.raidpet",
|
|
["RaidPet%d%d"] = "unitframes.raidpet",
|
|
["Group%d"] = "unitframes.group",
|
|
["Party%dTarget"] = "unitframes.grouptarget",
|
|
["PartyPet%d"] = "unitframes.grouppet",
|
|
|
|
-- chat
|
|
["ChatLeft"] = "chat",
|
|
["ChatRight"] = "chat",
|
|
["ChatInputBox"] = "chat",
|
|
|
|
-- loot
|
|
["LootRollFrame%d"] = "loot",
|
|
|
|
-- panel
|
|
["PanelLeft"] = "panel",
|
|
["PanelRight"] = "panel",
|
|
["PanelMinimap"] = "panel",
|
|
["PanelMicroButton"] = "panel",
|
|
|
|
-- actionbar
|
|
["ActionBarMain"] = "actionbar.bar1",
|
|
["ActionBarPaging"] = "actionbar.bar2",
|
|
["ActionBarRight"] = "actionbar.bar3",
|
|
["ActionBarVertical"] = "actionbar.bar4",
|
|
["ActionBarLeft"] = "actionbar.bar5",
|
|
["ActionBarTop"] = "actionbar.bar6",
|
|
["ActionBarStanceBar1"] = "actionbar.bar7",
|
|
["ActionBarStanceBar2"] = "actionbar.bar8",
|
|
["ActionBarStanceBar3"] = "actionbar.bar9",
|
|
["ActionBarStanceBar4"] = "actionbar.bar10",
|
|
["ActionBarStances"] = "actionbar.bar11",
|
|
["ActionBarPet"] = "actionbar.bar12",
|
|
|
|
-- castbar
|
|
["TargetCastbar"] = "castbar.target",
|
|
["PlayerCastbar"] = "castbar.player",
|
|
["FocusCastbar"] = "castbar.focus",
|
|
|
|
-- minimap
|
|
["Minimap"] = "minimap.minimap",
|
|
["UITracking"] = "minimap.minimap",
|
|
|
|
-- buffs
|
|
["BuffFrame"] = "buffs.icons",
|
|
["DebuffFrame"] = "buffs.icons",
|
|
|
|
-- buffbars
|
|
["PlayerBuffBar"] = "buffs.pbuff",
|
|
["PlayerDebuffBar"] = "buffs.pdebuff",
|
|
["TargetDebuffBar"] = "buffs.tdebuff",
|
|
}
|
|
|
|
local function GetFrames()
|
|
-- Return frames based on Ctrl and Shift state
|
|
-- 'this' [frame] the base frame
|
|
-- return [list] all frames that should be selected
|
|
|
|
local frame = this.frame
|
|
local frames = { frame }
|
|
|
|
if IsShiftKeyDown() or IsControlKeyDown() then
|
|
-- search and add clustered frames
|
|
for id, cluster in pairs(clusters) do
|
|
local len = strlen(cluster[1])
|
|
local fid = tonumber(strsub(frame:GetName(),len+1,len+2))
|
|
if fid and strsub(frame:GetName(),0,len) == cluster[1] then
|
|
if IsShiftKeyDown() and cluster[2] then
|
|
for i = 1, cluster[2] do
|
|
if _G[cluster[1] .. i] ~= frame then
|
|
table.insert(frames, _G[cluster[1] .. i])
|
|
end
|
|
end
|
|
elseif IsControlKeyDown() and cluster[3] then
|
|
local id = fid
|
|
|
|
local b = 1
|
|
for i = cluster[3]+1, cluster[2], cluster[3] do
|
|
b = ( id >= i ) and i or b
|
|
end
|
|
|
|
for i = b, b + cluster[3] - 1 do
|
|
if _G[cluster[1] .. i] ~= frame then
|
|
table.insert(frames, _G[cluster[1] .. i])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return frames
|
|
end
|
|
|
|
local function SaveScale(frame, scale)
|
|
frame:SetScale(scale)
|
|
|
|
if not C.position[frame:GetName()] then
|
|
C.position[frame:GetName()] = {}
|
|
end
|
|
C.position[frame:GetName()]["scale"] = scale
|
|
|
|
frame.drag.text:SetText(T["Scale"] .. ": " .. scale)
|
|
frame.drag.fade:Stop()
|
|
frame.drag.fade:Play()
|
|
end
|
|
|
|
local function SavePosition(frame)
|
|
SaveMovable(frame)
|
|
UpdateMovable(frame)
|
|
end
|
|
|
|
local function DrawGrid()
|
|
local grid = CreateFrame("Frame", this:GetName() .. "Grid", pfUI.unlock)
|
|
grid:SetAllPoints(this)
|
|
|
|
local size = 1
|
|
local line = {}
|
|
|
|
local width = GetScreenWidth()
|
|
local height = GetScreenHeight()
|
|
|
|
local ratio = width / GetScreenHeight()
|
|
local rheight = GetScreenHeight() * ratio
|
|
|
|
local wStep = width / 128
|
|
local hStep = rheight / 128
|
|
|
|
-- vertical lines
|
|
for i = 0, 128 do
|
|
if i == 128 / 2 then
|
|
line = grid:CreateTexture(nil, 'BORDER')
|
|
line:SetColorTexture(.1, .5, .4)
|
|
else
|
|
line = grid:CreateTexture(nil, 'BACKGROUND')
|
|
line:SetColorTexture(0, 0, 0, .5)
|
|
end
|
|
line:SetPoint("TOPLEFT", grid, "TOPLEFT", i*wStep - (size/2), 0)
|
|
line:SetPoint('BOTTOMRIGHT', grid, 'BOTTOMLEFT', i*wStep + (size/2), 0)
|
|
end
|
|
|
|
-- horizontal lines
|
|
for i = 1, floor(height/hStep) do
|
|
if i == floor(height/hStep / 2) then
|
|
line = grid:CreateTexture(nil, 'BORDER')
|
|
line:SetColorTexture(.1, .5, .4)
|
|
else
|
|
line = grid:CreateTexture(nil, 'BACKGROUND')
|
|
line:SetColorTexture(0, 0, 0)
|
|
end
|
|
|
|
line:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(i*hStep) + (size/2))
|
|
line:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(i*hStep + size/2))
|
|
end
|
|
|
|
return grid
|
|
end
|
|
|
|
-- the id of the config page of a frame label
|
|
local function GetConfigPage(dlabel)
|
|
local page
|
|
for label, id in pairs(frame_configs) do
|
|
if string.gsub(dlabel, label, "") == "" then
|
|
page = id
|
|
end
|
|
end
|
|
|
|
return page
|
|
end
|
|
|
|
local function UpdateDockValues()
|
|
if not pfUI.unlock.dock:IsShown() then return end
|
|
|
|
local dock = pfUI.unlock.dock
|
|
local drag = dock.parent
|
|
local frame = drag.frame
|
|
|
|
-- update dock position
|
|
SetAutoPoint(dock, drag, default_border*2+2)
|
|
|
|
-- update dock entries
|
|
dock.title:SetText(drag.label)
|
|
if pfUI_config["position"] and pfUI_config["position"][drag.fname] and pfUI_config["position"][drag.fname]["xpos"] then
|
|
dock.xcoord:SetText(pfUI_config["position"][drag.fname]["xpos"])
|
|
dock.ycoord:SetText(pfUI_config["position"][drag.fname]["ypos"])
|
|
dock.reset:SetText(RESET)
|
|
|
|
dock.up:Enable()
|
|
dock.down:Enable()
|
|
dock.left:Enable()
|
|
dock.right:Enable()
|
|
|
|
dock.up.texture:SetVertexColor(1,.8,0)
|
|
dock.down.texture:SetVertexColor(1,.8,0)
|
|
dock.left.texture:SetVertexColor(1,.8,0)
|
|
dock.right.texture:SetVertexColor(1,.8,0)
|
|
else
|
|
dock.reset:SetText(T["Unlock"])
|
|
dock.xcoord:SetText(NOT_APPLICABLE)
|
|
dock.ycoord:SetText(NOT_APPLICABLE)
|
|
|
|
dock.up:Disable()
|
|
dock.down:Disable()
|
|
dock.left:Disable()
|
|
dock.right:Disable()
|
|
|
|
dock.up.texture:SetVertexColor(.4,.4,.4)
|
|
dock.down.texture:SetVertexColor(.4,.4,.4)
|
|
dock.left.texture:SetVertexColor(.4,.4,.4)
|
|
dock.right.texture:SetVertexColor(.4,.4,.4)
|
|
end
|
|
|
|
-- show the saved anchor, or none for a frame without a saved position
|
|
dock.anchor:GenerateMenu()
|
|
|
|
-- update config button
|
|
if GetConfigPage(drag.label) then
|
|
dock.config:Enable()
|
|
else
|
|
dock.config:Disable()
|
|
end
|
|
end
|
|
|
|
local function SetDockToFrame(frame)
|
|
if pfUI.unlock.dock.parent then
|
|
-- reset previous border color
|
|
CreateBackdrop(pfUI.unlock.dock.parent, nil, nil, .8)
|
|
end
|
|
|
|
-- add the new frame
|
|
pfUI.unlock.dock.parent = frame
|
|
|
|
if frame then
|
|
pfUI.unlock.dock.parent.backdrop:SetBackdropBorderColor(.2,1,.8,1)
|
|
pfUI.unlock.dock:Show()
|
|
UpdateDockValues()
|
|
else
|
|
pfUI.unlock.dock:Hide()
|
|
end
|
|
end
|
|
|
|
local function DraggerOnMouseWheel()
|
|
local frame = this.frame
|
|
local scale = round(frame:GetScale() + arg1/10, 1)
|
|
|
|
pfUI.unlock.selection = GetFrames()
|
|
for id, frame in pairs(pfUI.unlock.selection) do
|
|
SaveScale(frame, scale)
|
|
end
|
|
|
|
-- repaint hackfix for panels
|
|
if pfUI.panel and pfUI.chat then
|
|
pfUI.panel.left:SetScale(pfUI.chat.left:GetScale())
|
|
pfUI.panel.right:SetScale(pfUI.chat.right:GetScale())
|
|
end
|
|
|
|
if frame.OnMove then frame:OnMove() end
|
|
RunNextFrame(UpdateDockValues)
|
|
end
|
|
|
|
local function DraggerOnDragStart()
|
|
local frame = this.frame
|
|
|
|
pfUI.unlock.selection = GetFrames()
|
|
|
|
for id, frame in pairs(pfUI.unlock.selection) do
|
|
frame:StartMoving()
|
|
frame:StopMovingOrSizing()
|
|
frame.drag.backdrop:SetBackdropBorderColor(.2,1,.8,1)
|
|
end
|
|
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame.oldPos = { xpos, ypos, anchor }
|
|
frame:StartMoving()
|
|
|
|
if frame.OnMove then frame:OnMove() end
|
|
end
|
|
|
|
local function DraggerOnDragStop()
|
|
local frame = this.frame
|
|
local name = this.fname
|
|
|
|
frame:StopMovingOrSizing()
|
|
|
|
-- calculate and move selection offsets
|
|
local anchor, xpos, ypos = ConvertFrameAnchor(frame, frame.oldPos[3])
|
|
local diffxpos = frame.oldPos[1] - xpos
|
|
local diffypos = frame.oldPos[2] - ypos
|
|
|
|
for id, frame in pairs(pfUI.unlock.selection) do
|
|
frame:SetParent("UIParent")
|
|
if frame:GetName() ~= name then
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor or "TOPLEFT", xpos - diffxpos, ypos - diffypos)
|
|
end
|
|
end
|
|
|
|
-- detect best anchor
|
|
local bestanchor = "TOPLEFT"
|
|
local left, top, right, bottom
|
|
spanframe:ClearAllPoints()
|
|
|
|
for id, frame in pairs(pfUI.unlock.selection) do
|
|
if not left or frame:GetLeft() < left then
|
|
spanframe:SetPoint("LEFT", frame, "LEFT", 0, 0)
|
|
left = frame:GetLeft()
|
|
end
|
|
if not top or frame:GetTop() > top then
|
|
top = frame:GetTop()
|
|
spanframe:SetPoint("TOP", frame, "TOP", 0, 0)
|
|
end
|
|
if not right or frame:GetRight() > right then
|
|
right = frame:GetRight()
|
|
spanframe:SetPoint("RIGHT", frame, "RIGHT", 0, 0)
|
|
end
|
|
if not bottom or frame:GetBottom() < bottom then
|
|
bottom = frame:GetBottom()
|
|
spanframe:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
|
|
end
|
|
end
|
|
bestanchor = GetBestAnchor(spanframe)
|
|
|
|
-- save all frame positions
|
|
for id, frame in pairs(pfUI.unlock.selection) do
|
|
CreateBackdrop(frame.drag, nil, nil, .8)
|
|
local anchor, x, y = ConvertFrameAnchor(frame, bestanchor)
|
|
frame:ClearAllPoints()
|
|
frame:SetPoint(anchor, UIParent, anchor, x, y)
|
|
SavePosition(frame)
|
|
end
|
|
|
|
this.backdrop:SetBackdropBorderColor(1,1,1,1)
|
|
UpdateDockValues()
|
|
end
|
|
|
|
local function DraggerOnClick()
|
|
if arg1 == "RightButton" then
|
|
-- add dockframe to the dragger to show advanced options
|
|
if pfUI.unlock.dock.parent == this and pfUI.unlock.dock:IsShown() then
|
|
SetDockToFrame(nil)
|
|
else
|
|
SetDockToFrame(this)
|
|
end
|
|
return
|
|
elseif arg1 == "MiddleButton" then
|
|
-- reset positions of dragger and all connected frames
|
|
pfUI.unlock.selection = GetFrames()
|
|
for id, frame in pairs(pfUI.unlock.selection) do
|
|
pfUI_config["position"][frame:GetName()] = nil
|
|
UpdateMovable(frame)
|
|
|
|
if frame.OnMove then frame:OnMove() end
|
|
end
|
|
UpdateDockValues()
|
|
end
|
|
end
|
|
|
|
local function DraggerOnEnter()
|
|
if pfUI.unlock.dock.parent ~= this then
|
|
this.backdrop:SetBackdropBorderColor(1,1,1,1)
|
|
end
|
|
end
|
|
|
|
local function DraggerOnLeave()
|
|
if pfUI.unlock.dock.parent ~= this then
|
|
CreateBackdrop(this, nil, nil, .8)
|
|
end
|
|
end
|
|
|
|
local function CreateDragger(f)
|
|
local fname = f:GetName()
|
|
local label = string.sub(fname, 1, 2) == "pf" and strsub(fname,3) or fname
|
|
|
|
local d = CreateFrame("Button", fname .. "Drag", f)
|
|
d:RegisterForClicks("MiddleButtonUp", "RightButtonUp")
|
|
d:RegisterForDrag("LeftButton")
|
|
d:SetAllPoints(f)
|
|
d:SetAlpha(1)
|
|
d:EnableMouseWheel(1)
|
|
|
|
d:SetFrameLevel(128)
|
|
|
|
d.text = d:CreateFontString("Status", "LOW", "GameFontNormal")
|
|
d.text:SetFont(pfUI.font_default, C.global.font_size, "OUTLINE")
|
|
d.text:ClearAllPoints()
|
|
d.text:SetAllPoints(d)
|
|
d.text:SetPoint("CENTER", 0, 0)
|
|
d.text:SetFontObject(GameFontWhite)
|
|
|
|
-- Fades out the scale readout, then puts the frame name back
|
|
d.fade = d.text:CreateAnimationGroup()
|
|
local fade = d.fade:CreateAnimation("Alpha")
|
|
fade:SetChange(-1)
|
|
fade:SetDuration(.3)
|
|
d.fade:SetScript("OnFinished", function()
|
|
d.text:SetText(strsub(f:GetName(),3))
|
|
end)
|
|
|
|
d.frame = f
|
|
d.fname = fname
|
|
d.label = label
|
|
|
|
if d:GetHeight() > (2 * d:GetWidth()) then
|
|
label = strvertical(label)
|
|
end
|
|
|
|
d.text:SetText(label)
|
|
|
|
d:SetScript("OnMouseWheel", DraggerOnMouseWheel)
|
|
d:SetScript("OnDragStart", DraggerOnDragStart)
|
|
d:SetScript("OnDragStop", DraggerOnDragStop)
|
|
d:SetScript("OnClick", DraggerOnClick)
|
|
d:SetScript("OnEnter", DraggerOnEnter)
|
|
d:SetScript("OnLeave", DraggerOnLeave)
|
|
|
|
CreateBackdrop(d, nil, nil, .8)
|
|
return d
|
|
end
|
|
|
|
table.insert(UISpecialFrames, "pfUnlock")
|
|
pfUI.unlock = CreateFrame("Button", "pfUnlock", UIParent)
|
|
pfUI.unlock.selection = {}
|
|
pfUI.unlock:Hide()
|
|
pfUI.unlock:SetAllPoints(WorldFrame)
|
|
pfUI.unlock:SetFrameStrata("BACKGROUND")
|
|
pfUI.unlock:SetScript("OnClick", function()
|
|
this:Hide()
|
|
end)
|
|
|
|
pfUI.unlock:SetScript("OnShow", function()
|
|
if this.skip then this.skip = nil return end
|
|
|
|
this.grid = this.grid or DrawGrid()
|
|
|
|
for name, frame in pairs(pfUI.movables) do
|
|
local frame = frame or _G[name]
|
|
|
|
if not frame:IsShown() then frame.hideLater = true end
|
|
frame.drag = frame.drag or CreateDragger(frame)
|
|
frame:SetMovable(true)
|
|
frame.drag:Show()
|
|
frame:Show()
|
|
end
|
|
|
|
-- lift the range and offline fade while unlocked
|
|
pfUI.uf:UpdateAllVisibility()
|
|
|
|
local txt = T["Unlock Mode allows you to move, scale and reset frames:\n\n|cff33ffcc[Left Click]|r Drag Frame\n|cff33ffcc[Middle Click]|r Reset Frame\n|cff33ffcc[Right Click]|r Option Box\n\nHold |cff33ffcc[Shift]|r to select all frames of the same kind\nHold |cff33ffcc[Ctrl]|r to select all frames of the same group\n\n|cff33ffcc[Scroll]|r to change the scale of a frame\n\n|cff33ffcc[Click]|r on an empty area or press |cff33ffcc[Esc]|r to exit\n"]
|
|
CreateInfoBox(txt, 15, pfUI.unlock, 180)
|
|
pfUI.gui:Hide()
|
|
end)
|
|
|
|
pfUI.unlock:SetScript("OnHide", function()
|
|
if this.skip then this.skip = nil return end
|
|
|
|
for name, frame in pairs(pfUI.movables) do
|
|
local frame = frame or _G[name]
|
|
|
|
if frame.hideLater == true then frame:Hide() end
|
|
frame:StopMovingOrSizing()
|
|
frame:SetMovable(false)
|
|
frame.drag:Hide()
|
|
UpdateMovable(frame)
|
|
end
|
|
|
|
-- show the unit frames whose unit came and hide the ones whose unit went
|
|
-- while unlocked
|
|
pfUI.uf:UpdateAllVisibility()
|
|
|
|
SetDockToFrame(nil)
|
|
pfUI.unlock:Hide()
|
|
pfUI.gui:Show()
|
|
end)
|
|
|
|
-- dock frame
|
|
pfUI.unlock.dock = CreateFrame("Button", "pfUnlockDock", pfUI.unlock)
|
|
pfUI.unlock.dock:SetWidth(150)
|
|
pfUI.unlock.dock:SetHeight(160)
|
|
pfUI.unlock.dock:SetFrameStrata("FULLSCREEN_DIALOG")
|
|
pfUI.unlock.dock:Hide()
|
|
CreateBackdrop(pfUI.unlock.dock)
|
|
|
|
-- title
|
|
pfUI.unlock.dock.title = pfUI.unlock.dock:CreateFontString("Status", "DIALOG", "GameFontNormal")
|
|
pfUI.unlock.dock.title:SetTextColor(1,1,1,1)
|
|
pfUI.unlock.dock.title:SetFont(pfUI.font_default, C.global.font_size + 2, "OUTLINE")
|
|
pfUI.unlock.dock.title:SetJustifyH("left")
|
|
pfUI.unlock.dock.title:SetPoint("TOP", 0, -5)
|
|
|
|
-- anchor
|
|
-- SetupMenu reads the selection at once, before any frame is docked
|
|
local function IsDockAnchor(anchor)
|
|
local drag = pfUI.unlock.dock.parent
|
|
local position = drag and pfUI_config["position"] and pfUI_config["position"][drag.fname]
|
|
return position and position["xpos"] and (position["anchor"] or "TOPLEFT") == anchor
|
|
end
|
|
|
|
-- moves the frame's saved position to count from another point of the screen
|
|
local function SetDockAnchor(anchor)
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local point, x, y = ConvertFrameAnchor(frame, anchor)
|
|
frame:ClearAllPoints()
|
|
frame:SetPoint(point, UIParent, point, x, y)
|
|
|
|
SavePosition(frame)
|
|
UpdateDockValues()
|
|
end
|
|
|
|
pfUI.unlock.dock.anchor = CreateFrame("DropdownButton", nil, pfUI.unlock.dock, "pfUIDropdownTemplate")
|
|
pfUI.unlock.dock.anchor:SetPoint("TOP", 0, -28)
|
|
pfUI.unlock.dock.anchor:SetWidth(140)
|
|
pfUI.unlock.dock.anchor:SetDefaultText(NOT_APPLICABLE)
|
|
CreateBackdrop(pfUI.unlock.dock.anchor, nil, true)
|
|
pfUI.unlock.dock.anchor:SetupMenu(function(dropdown, rootDescription)
|
|
for _, anchor in ipairs(anchors) do
|
|
rootDescription:CreateRadio(anchor, IsDockAnchor, SetDockAnchor, anchor)
|
|
end
|
|
end)
|
|
|
|
-- x coordinates
|
|
pfUI.unlock.dock.xcoordcap = pfUI.unlock.dock:CreateFontString("Status", "DIALOG", "GameFontNormal")
|
|
pfUI.unlock.dock.xcoordcap:SetFont(pfUI.font_default, C.global.font_size, "OUTLINE")
|
|
pfUI.unlock.dock.xcoordcap:SetJustifyH("LEFT")
|
|
pfUI.unlock.dock.xcoordcap:SetPoint("TOPLEFT", 5, -63)
|
|
pfUI.unlock.dock.xcoordcap:SetText("X:")
|
|
pfUI.unlock.dock.xcoord = CreateFrame("EditBox", nil, pfUI.unlock.dock)
|
|
pfUI.unlock.dock.xcoord:SetTextInsets(5, 5, 5, 5)
|
|
pfUI.unlock.dock.xcoord:SetJustifyH("CENTER")
|
|
pfUI.unlock.dock.xcoord:SetWidth(45)
|
|
pfUI.unlock.dock.xcoord:SetHeight(18)
|
|
pfUI.unlock.dock.xcoord:SetPoint("TOPLEFT", pfUI.unlock.dock, "TOPLEFT", 20, -60)
|
|
pfUI.unlock.dock.xcoord:SetFontObject(GameFontNormal)
|
|
pfUI.unlock.dock.xcoord:SetAutoFocus(false)
|
|
|
|
pfUI.unlock.dock.xcoord:SetScript("OnEnterPressed", function(self)
|
|
local newXPos = tonumber(this:GetText())
|
|
if newXPos then
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor, newXPos, ypos)
|
|
SavePosition(frame)
|
|
else
|
|
UpdateDockValues()
|
|
end
|
|
this:ClearFocus()
|
|
end)
|
|
|
|
pfUI.unlock.dock.xcoord:SetScript("OnTextChanged", function(self)
|
|
if tonumber(this:GetText()) then
|
|
this:SetTextColor(1,1,1,1)
|
|
else
|
|
this:SetTextColor(1,.3,.3,1)
|
|
end
|
|
end)
|
|
|
|
CreateBackdrop(pfUI.unlock.dock.xcoord, nil, true)
|
|
|
|
-- y coordinates
|
|
pfUI.unlock.dock.ycoordcap = pfUI.unlock.dock:CreateFontString("Status", "DIALOG", "GameFontNormal")
|
|
pfUI.unlock.dock.ycoordcap:SetFont(pfUI.font_default, C.global.font_size, "OUTLINE")
|
|
pfUI.unlock.dock.ycoordcap:SetText("Y:")
|
|
pfUI.unlock.dock.ycoordcap:SetJustifyH("LEFT")
|
|
pfUI.unlock.dock.ycoordcap:SetPoint("TOPLEFT", 75, -63)
|
|
pfUI.unlock.dock.ycoord = CreateFrame("EditBox", nil, pfUI.unlock.dock)
|
|
pfUI.unlock.dock.ycoord:SetTextInsets(5, 5, 5, 5)
|
|
pfUI.unlock.dock.ycoord:SetJustifyH("CENTER")
|
|
pfUI.unlock.dock.ycoord:SetWidth(45)
|
|
pfUI.unlock.dock.ycoord:SetHeight(18)
|
|
pfUI.unlock.dock.ycoord:SetPoint("TOPLEFT", pfUI.unlock.dock, "TOPLEFT", 90, -60)
|
|
pfUI.unlock.dock.ycoord:SetFontObject(GameFontNormal)
|
|
pfUI.unlock.dock.ycoord:SetAutoFocus(false)
|
|
|
|
pfUI.unlock.dock.ycoord:SetScript("OnEnterPressed", function(self)
|
|
local newYPos = tonumber(this:GetText())
|
|
if newYPos then
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor, xpos, newYPos)
|
|
SavePosition(frame)
|
|
else
|
|
UpdateDockValues()
|
|
end
|
|
this:ClearFocus()
|
|
end)
|
|
|
|
pfUI.unlock.dock.ycoord:SetScript("OnTextChanged", function(self)
|
|
if tonumber(this:GetText()) then
|
|
this:SetTextColor(1,1,1,1)
|
|
else
|
|
this:SetTextColor(1,.3,.3,1)
|
|
end
|
|
end)
|
|
|
|
CreateBackdrop(pfUI.unlock.dock.ycoord, nil, true)
|
|
|
|
-- reset button
|
|
pfUI.unlock.dock.reset = CreateFrame("Button", "pfDragDockReset", pfUI.unlock.dock, "UIPanelButtonTemplate")
|
|
pfUI.unlock.dock.reset:SetHeight(18)
|
|
pfUI.unlock.dock.reset:SetPoint("TOPLEFT", 5, -85)
|
|
pfUI.unlock.dock.reset:SetPoint("TOPRIGHT", -5, -85)
|
|
pfUI.unlock.dock.reset:SetScript("OnClick", function()
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
|
|
if this:GetText() == RESET then
|
|
pfUI_config["position"][frame:GetName()] = nil
|
|
frame:ClearAllPoints()
|
|
UpdateMovable(frame)
|
|
else
|
|
frame:StartMoving()
|
|
frame:StopMovingOrSizing()
|
|
SavePosition(frame)
|
|
end
|
|
|
|
if frame.OnMove then frame:OnMove() end
|
|
|
|
RunNextFrame(function() SetDockToFrame(pfUI.unlock.dock.parent) end)
|
|
end)
|
|
SkinButton(pfUI.unlock.dock.reset,.2,1,.8)
|
|
|
|
-- move left
|
|
pfUI.unlock.dock.left = CreateFrame("Button", "pfDragDockPosUp", pfUI.unlock.dock, "UIPanelButtonTemplate")
|
|
pfUI.unlock.dock.left:SetHeight(18)
|
|
pfUI.unlock.dock.left:SetWidth(18)
|
|
pfUI.unlock.dock.left:SetPoint("TOP", -50, -110)
|
|
pfUI.unlock.dock.left.texture = pfUI.unlock.dock.left:CreateTexture("arrow")
|
|
pfUI.unlock.dock.left.texture:SetTexture(pfUI.media["img:left"])
|
|
pfUI.unlock.dock.left.texture:ClearAllPoints()
|
|
pfUI.unlock.dock.left.texture:SetPoint("TOPLEFT", pfUI.unlock.dock.left, "TOPLEFT", 4, -2)
|
|
pfUI.unlock.dock.left.texture:SetPoint("BOTTOMRIGHT", pfUI.unlock.dock.left, "BOTTOMRIGHT", -4, 2)
|
|
pfUI.unlock.dock.left:SetScript("OnClick", function()
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor or "TOPLEFT", xpos - 1, ypos)
|
|
SavePosition(frame)
|
|
UpdateDockValues()
|
|
end)
|
|
SkinButton(pfUI.unlock.dock.left,.2,1,.8)
|
|
|
|
-- move right
|
|
pfUI.unlock.dock.right = CreateFrame("Button", "pfDragDockPosUp", pfUI.unlock.dock, "UIPanelButtonTemplate")
|
|
pfUI.unlock.dock.right:SetHeight(18)
|
|
pfUI.unlock.dock.right:SetWidth(18)
|
|
pfUI.unlock.dock.right:SetPoint("TOP", -25, -110)
|
|
pfUI.unlock.dock.right.texture = pfUI.unlock.dock.right:CreateTexture("arrow")
|
|
pfUI.unlock.dock.right.texture:SetTexture(pfUI.media["img:right"])
|
|
pfUI.unlock.dock.right.texture:ClearAllPoints()
|
|
pfUI.unlock.dock.right.texture:SetPoint("TOPLEFT", pfUI.unlock.dock.right, "TOPLEFT", 4, -2)
|
|
pfUI.unlock.dock.right.texture:SetPoint("BOTTOMRIGHT", pfUI.unlock.dock.right, "BOTTOMRIGHT", -4, 2)
|
|
pfUI.unlock.dock.right:SetScript("OnClick", function()
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor or "TOPLEFT", xpos + 1, ypos)
|
|
SavePosition(frame)
|
|
UpdateDockValues()
|
|
end)
|
|
SkinButton(pfUI.unlock.dock.right,.2,1,.8)
|
|
|
|
-- move up
|
|
pfUI.unlock.dock.up = CreateFrame("Button", "pfDragDockPosUp", pfUI.unlock.dock, "UIPanelButtonTemplate")
|
|
pfUI.unlock.dock.up:SetHeight(18)
|
|
pfUI.unlock.dock.up:SetWidth(18)
|
|
pfUI.unlock.dock.up:SetPoint("TOP", 25, -110)
|
|
pfUI.unlock.dock.up.texture = pfUI.unlock.dock.up:CreateTexture("arrow")
|
|
pfUI.unlock.dock.up.texture:SetTexture(pfUI.media["img:up"])
|
|
pfUI.unlock.dock.up.texture:ClearAllPoints()
|
|
pfUI.unlock.dock.up.texture:SetPoint("TOPLEFT", pfUI.unlock.dock.up, "TOPLEFT", 4, -2)
|
|
pfUI.unlock.dock.up.texture:SetPoint("BOTTOMRIGHT", pfUI.unlock.dock.up, "BOTTOMRIGHT", -4, 2)
|
|
pfUI.unlock.dock.up:SetScript("OnClick", function()
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor or "TOPLEFT", xpos, ypos + 1)
|
|
SavePosition(frame)
|
|
UpdateDockValues()
|
|
end)
|
|
SkinButton(pfUI.unlock.dock.up,.2,1,.8)
|
|
|
|
-- move down
|
|
pfUI.unlock.dock.down = CreateFrame("Button", "pfDragDockPosUp", pfUI.unlock.dock, "UIPanelButtonTemplate")
|
|
pfUI.unlock.dock.down:SetHeight(18)
|
|
pfUI.unlock.dock.down:SetWidth(18)
|
|
pfUI.unlock.dock.down:SetPoint("TOP", 50, -110)
|
|
pfUI.unlock.dock.down.texture = pfUI.unlock.dock.down:CreateTexture("arrow")
|
|
pfUI.unlock.dock.down.texture:SetTexture(pfUI.media["img:down"])
|
|
pfUI.unlock.dock.down.texture:ClearAllPoints()
|
|
pfUI.unlock.dock.down.texture:SetPoint("TOPLEFT", pfUI.unlock.dock.down, "TOPLEFT", 4, -2)
|
|
pfUI.unlock.dock.down.texture:SetPoint("BOTTOMRIGHT", pfUI.unlock.dock.down, "BOTTOMRIGHT", -4, 2)
|
|
pfUI.unlock.dock.down:SetScript("OnClick", function()
|
|
local frame = pfUI.unlock.dock.parent.frame
|
|
local anchor, _, _, xpos, ypos = frame:GetPoint()
|
|
frame:SetPoint(anchor or "TOPLEFT", xpos, ypos - 1)
|
|
SavePosition(frame)
|
|
UpdateDockValues()
|
|
end)
|
|
SkinButton(pfUI.unlock.dock.down,.2,1,.8)
|
|
|
|
-- open config
|
|
pfUI.unlock.dock.config = CreateFrame("Button", "pfDragDockConfigOpen", pfUI.unlock.dock, "UIPanelButtonTemplate")
|
|
pfUI.unlock.dock.config:SetHeight(18)
|
|
pfUI.unlock.dock.config:SetPoint("BOTTOMLEFT", 5, 5)
|
|
pfUI.unlock.dock.config:SetPoint("BOTTOMRIGHT", -5, 5)
|
|
pfUI.unlock.dock.config:SetText(T["Configure"])
|
|
pfUI.unlock.dock.config:SetScript("OnClick", function()
|
|
local page = GetConfigPage(pfUI.unlock.dock.parent.label)
|
|
if page then pfUI.gui:OpenPage(page) end
|
|
end)
|
|
SkinButton(pfUI.unlock.dock.config,.2,1,.8)
|
|
end)
|