From 32f3b15990e3c8d4ac8762158e954366baae0012 Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 18 Nov 2016 20:28:47 +0100 Subject: [PATCH] gui: use cluster move on shift key down --- modules/group.lua | 6 ++-- modules/gui.lua | 73 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/modules/group.lua b/modules/group.lua index cbb4814d..4c22d708 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -3,7 +3,7 @@ pfUI:RegisterModule("group", function () if pfUI_config.unitframes.disable == "1" then return end -- hide blizzard group frames - for i=1, 5 do + for i=1, 4 do if getglobal("PartyMemberFrame" .. i) then getglobal("PartyMemberFrame" .. i):Hide() getglobal("PartyMemberFrame" .. i).Show = function () return end @@ -27,7 +27,7 @@ pfUI:RegisterModule("group", function () pfUI.uf.group:SetScript("OnEvent", function() PartyMemberBackground:Hide() - for i=1, 5 do + for i=1, 4 do if pfUI_config.unitframes.group.hide_in_raid == "1" and UnitInRaid("player") then pfUI.uf.group[i]:Hide() return @@ -75,7 +75,7 @@ pfUI:RegisterModule("group", function () end end) - for i=1, 5 do + for i=1, 4 do pfUI.uf.group[i] = CreateFrame("Button","pfGroup" .. i,UIParent) pfUI.uf.group[i]:SetWidth(175) diff --git a/modules/gui.lua b/modules/gui.lua index 083f90c0..c7b74cfa 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -193,12 +193,79 @@ pfUI:RegisterModule("gui", function () end frame.drag:SetScript("OnMouseDown",function() - frame:StartMoving() - end) + if IsShiftKeyDown() then + if strsub(frame:GetName(),0,6) == "pfRaid" then + for i=1,40 do + local cframe = getglobal("pfRaid" .. i) + cframe:StartMoving() + cframe:StopMovingOrSizing() + cframe.drag:SetBackdropBorderColor(1,1,1,1) + end + end + if strsub(frame:GetName(),0,7) == "pfGroup" then + for i=1,4 do + local cframe = getglobal("pfGroup" .. i) + cframe:StartMoving() + cframe:StopMovingOrSizing() + cframe.drag:SetBackdropBorderColor(1,1,1,1) + end + end + _, _, _, xpos, ypos = frame:GetPoint() + frame.oldPos = { xpos, ypos } + else + frame.oldPos = nil + end + frame.drag:SetBackdropBorderColor(1,1,1,1) + frame:StartMoving() + end) frame.drag:SetScript("OnMouseUp",function() frame:StopMovingOrSizing() _, _, _, xpos, ypos = frame:GetPoint() + frame.drag:SetBackdropBorderColor(.2,1,.8,1) + + if frame.oldPos then + local diffxpos = frame.oldPos[1] - xpos + local diffypos = frame.oldPos[2] - ypos + + if strsub(frame:GetName(),0,6) == "pfRaid" then + for i=1,40 do + local cframe = getglobal("pfRaid" .. i) + cframe.drag:SetBackdropBorderColor(.2,1,.8,1) + if cframe:GetName() ~= frame:GetName() then + local _, _, _, xpos, ypos = cframe:GetPoint() + cframe:SetPoint("TOPLEFT", xpos - diffxpos, ypos - diffypos) + + local _, _, _, xpos, ypos = cframe:GetPoint() + + if not pfUI_config.position[cframe:GetName()] then + pfUI_config.position[cframe:GetName()] = {} + end + + pfUI_config.position[cframe:GetName()]["xpos"] = xpos + pfUI_config.position[cframe:GetName()]["ypos"] = ypos + end + end + elseif strsub(frame:GetName(),0,7) == "pfGroup" then + for i=1,4 do + local cframe = getglobal("pfGroup" .. i) + cframe.drag:SetBackdropBorderColor(.2,1,.8,1) + if cframe:GetName() ~= frame:GetName() then + local _, _, _, xpos, ypos = cframe:GetPoint() + cframe:SetPoint("TOPLEFT", xpos - diffxpos, ypos - diffypos) + + local _, _, _, xpos, ypos = cframe:GetPoint() + + if not pfUI_config.position[cframe:GetName()] then + pfUI_config.position[cframe:GetName()] = {} + end + + pfUI_config.position[cframe:GetName()]["xpos"] = xpos + pfUI_config.position[cframe:GetName()]["ypos"] = ypos + end + end + end + end if not pfUI_config.position[frame:GetName()] then pfUI_config.position[frame:GetName()] = {} @@ -206,7 +273,7 @@ pfUI:RegisterModule("gui", function () pfUI_config.position[frame:GetName()]["xpos"] = xpos pfUI_config.position[frame:GetName()]["ypos"] = ypos - end) + end) if pfUI.gitter:IsShown() then frame:SetMovable(true)