diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 98bd306c..968b98a4 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -86,7 +86,7 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.pet:Show() pfUI.bars.pet:SetFrameStrata("LOW") pfUI.bars.pet:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, 5) - pfUI.utils:loadPosition(pfUI.bars.pet) + pfUI.utils:UpdateMovable(pfUI.bars.pet) pfUI.bars.pet:SetBackdrop(pfUI.backdrop) pfUI.bars.pet:SetWidth(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 10 + pfUI_config.bars.border * 10) pfUI.bars.pet:SetHeight(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 1 + pfUI_config.bars.border) @@ -134,7 +134,7 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.shapeshift:SetFrameStrata("LOW") pfUI.bars.shapeshift:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, 5) - pfUI.utils:loadPosition(pfUI.bars.shapeshift) + pfUI.utils:UpdateMovable(pfUI.bars.shapeshift) pfUI.bars.shapeshift:SetBackdrop(pfUI.backdrop) pfUI.bars.shapeshift:SetWidth(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * shapeshiftbuttons + pfUI_config.bars.border * shapeshiftbuttons) pfUI.bars.shapeshift:SetHeight(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 1 + pfUI_config.bars.border) @@ -167,7 +167,7 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.bottomleft:Show() pfUI.bars.bottomleft:SetFrameStrata("LOW") pfUI.bars.bottomleft:SetPoint("BOTTOMRIGHT", pfUI.bars.bottom, "BOTTOMLEFT", -5, 0) - pfUI.utils:loadPosition(pfUI.bars.bottomleft) + pfUI.utils:UpdateMovable(pfUI.bars.bottomleft) pfUI.bars.bottomleft:SetBackdrop(pfUI.backdrop) pfUI.bars.bottomleft:SetWidth(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 6 + pfUI_config.bars.border * 6) pfUI.bars.bottomleft:SetHeight(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 2 + pfUI_config.bars.border * 2) @@ -209,7 +209,7 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.bottomright:Show() pfUI.bars.bottomright:SetFrameStrata("LOW") pfUI.bars.bottomright:SetPoint("BOTTOMLEFT", pfUI.bars.bottom, "BOTTOMRIGHT", 5, 0) - pfUI.utils:loadPosition(pfUI.bars.bottomright) + pfUI.utils:UpdateMovable(pfUI.bars.bottomright) pfUI.bars.bottomright:SetBackdrop(pfUI.backdrop) pfUI.bars.bottomright:SetWidth(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 6 + pfUI_config.bars.border * 6) pfUI.bars.bottomright:SetHeight(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 2 + pfUI_config.bars.border * 2) @@ -251,7 +251,7 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.vertical:Show() pfUI.bars.vertical:SetFrameStrata("LOW") pfUI.bars.vertical:SetPoint("RIGHT", -5, 0) - pfUI.utils:loadPosition(pfUI.bars.vertical) + pfUI.utils:UpdateMovable(pfUI.bars.vertical) pfUI.bars.vertical:SetBackdrop(pfUI.backdrop) pfUI.bars.vertical:SetWidth(pfUI_config.bars.border*4 + pfUI_config.bars.icon_size) pfUI.bars.vertical:SetHeight(pfUI_config.bars.border*3 + pfUI_config.bars.icon_size * 12 + pfUI_config.bars.border * 12) @@ -286,7 +286,7 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars.bottom = CreateFrame("Frame", "pfBarBottom", UIParent) pfUI.bars.bottom:SetFrameStrata("LOW") pfUI.bars.bottom:SetPoint("BOTTOM", 0, 5) - pfUI.utils:loadPosition(pfUI.bars.bottom) + pfUI.utils:UpdateMovable(pfUI.bars.bottom) pfUI.bars.bottom:SetBackdrop(pfUI.backdrop) for i=1, 12 do diff --git a/modules/chat.lua b/modules/chat.lua index d9c7c166..57da2014 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -6,7 +6,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left:SetWidth(350) pfUI.chat.left:SetHeight(pfUI_config.chat.left.height) pfUI.chat.left:SetPoint("BOTTOMLEFT", 5,5) - pfUI.utils:loadPosition(pfUI.chat.left) + pfUI.utils:UpdateMovable(pfUI.chat.left) pfUI.chat.left:SetBackdrop(pfUI.backdrop) pfUI.chat.left:SetBackdropColor(0,0,0,.75) @@ -156,7 +156,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.right:SetWidth(350) pfUI.chat.right:SetHeight(pfUI_config.chat.right.height) pfUI.chat.right:SetPoint("BOTTOMRIGHT", -5,5) - pfUI.utils:loadPosition(pfUI.chat.right) + pfUI.utils:UpdateMovable(pfUI.chat.right) pfUI.chat.right:SetBackdrop(pfUI.backdrop) pfUI.chat.right:SetBackdropColor(0,0,0,.75) @@ -468,7 +468,7 @@ pfUI:RegisterModule("chat", function () pfUI.chat.editbox:ClearAllPoints() pfUI.chat.editbox:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, 5) - pfUI.utils:loadPosition(pfUI.chat.editbox) + pfUI.utils:UpdateMovable(pfUI.chat.editbox) ChatFrameEditBox:SetParent(pfUI.chat.editbox) ChatFrameEditBox:SetBackdrop(pfUI.backdrop) diff --git a/modules/group.lua b/modules/group.lua index 957159e6..cbb4814d 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -81,7 +81,7 @@ pfUI:RegisterModule("group", function () pfUI.uf.group[i]:SetWidth(175) pfUI.uf.group[i]:SetHeight(40) pfUI.uf.group[i]:SetPoint("TOPLEFT", 5, -5 - ((i-1)*55)) - pfUI.utils:loadPosition(pfUI.uf.group[i]) + pfUI.utils:UpdateMovable(pfUI.uf.group[i]) pfUI.uf.group[i]:Hide() pfUI.uf.group[i].id = i diff --git a/modules/gui.lua b/modules/gui.lua index a04a29fd..083f90c0 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -78,23 +78,6 @@ pfUI:RegisterModule("gui", function () end) function pfUI.gui.UnlockFrames() - local movable = { pfUI.minimap, pfUI.chat.left, pfUI.chat.right, - pfUI.uf.player, pfUI.uf.target, pfUI.uf.targettarget, pfUI.uf.pet, - pfUI.bars.shapeshift, pfUI.bars.bottomleft, pfUI.bars.bottomright, - pfUI.bars.vertical, pfUI.bars.pet, pfUI.bars.bottom, - pfUI.panel.minimap, pfUI.panel.microbutton, pfUI.panel.clock.timerFrame, - pfUI.uf.group[1], pfUI.uf.group[2], pfUI.uf.group[3], pfUI.uf.group[4], - pfUI.uf.raid[1], pfUI.uf.raid[2], pfUI.uf.raid[3], pfUI.uf.raid[4], pfUI.uf.raid[5], - pfUI.uf.raid[6], pfUI.uf.raid[7], pfUI.uf.raid[8], pfUI.uf.raid[9], pfUI.uf.raid[10], - pfUI.uf.raid[11], pfUI.uf.raid[12], pfUI.uf.raid[13], pfUI.uf.raid[14], pfUI.uf.raid[15], - pfUI.uf.raid[16], pfUI.uf.raid[17], pfUI.uf.raid[18], pfUI.uf.raid[19], pfUI.uf.raid[20], - pfUI.uf.raid[21], pfUI.uf.raid[22], pfUI.uf.raid[23], pfUI.uf.raid[24], pfUI.uf.raid[25], - pfUI.uf.raid[26], pfUI.uf.raid[27], pfUI.uf.raid[28], pfUI.uf.raid[29], pfUI.uf.raid[30], - pfUI.uf.raid[31], pfUI.uf.raid[32], pfUI.uf.raid[33], pfUI.uf.raid[34], pfUI.uf.raid[35], - pfUI.uf.raid[36], pfUI.uf.raid[37], pfUI.uf.raid[38], pfUI.uf.raid[39], pfUI.uf.raid[40], - pfUI.chat.editbox, - } - if not pfUI.gitter then pfUI.gitter = CreateFrame("Button", nil, UIParent) pfUI.gitter:SetAllPoints(WorldFrame) @@ -161,79 +144,82 @@ pfUI:RegisterModule("gui", function () pfUI.gui:Hide() end - for _,frame in pairs(movable) do - local frame = frame - if not frame:IsShown() then - frame.hideLater = true - end + for _,frame in pairs(pfUI.movables) do + local frame = getglobal(frame) - if not frame.drag then - frame.drag = CreateFrame("Frame", nil, frame) - frame.drag:SetAllPoints(frame) - frame.drag:SetFrameStrata("DIALOG") - frame.drag:SetBackdrop(pfUI.backdrop_col) - frame.drag:SetBackdropBorderColor(.2, 1, .8) - frame.drag:SetBackdropColor(1,1,1,.75) - frame.drag:EnableMouseWheel(1) - frame.drag.text = frame.drag:CreateFontString("Status", "LOW", "GameFontNormal") - frame.drag.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\" .. pfUI_config.global.font_default .. ".ttf", pfUI_config.global.font_size, "OUTLINE") - frame.drag.text:ClearAllPoints() - frame.drag.text:SetAllPoints(frame.drag) - frame.drag.text:SetPoint("CENTER", 0, 0) - frame.drag.text:SetFontObject(GameFontWhite) - frame.drag.text:SetText(strsub(frame:GetName(),3)) - frame.drag:SetAlpha(1) + if frame then + if not frame:IsShown() then + frame.hideLater = true + end - frame.drag:SetScript("OnMouseWheel", function() - local scale = round(frame:GetScale() + arg1/10, 1) + if not frame.drag then + frame.drag = CreateFrame("Frame", nil, frame) + frame.drag:SetAllPoints(frame) + frame.drag:SetFrameStrata("DIALOG") + frame.drag:SetBackdrop(pfUI.backdrop_col) + frame.drag:SetBackdropBorderColor(.2, 1, .8) + frame.drag:SetBackdropColor(1,1,1,.75) + frame.drag:EnableMouseWheel(1) + frame.drag.text = frame.drag:CreateFontString("Status", "LOW", "GameFontNormal") + frame.drag.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\" .. pfUI_config.global.font_default .. ".ttf", pfUI_config.global.font_size, "OUTLINE") + frame.drag.text:ClearAllPoints() + frame.drag.text:SetAllPoints(frame.drag) + frame.drag.text:SetPoint("CENTER", 0, 0) + frame.drag.text:SetFontObject(GameFontWhite) + frame.drag.text:SetText(strsub(frame:GetName(),3)) + frame.drag:SetAlpha(1) - if IsShiftKeyDown() and strsub(frame:GetName(),0,6) == "pfRaid" then - for i=1,40 do - local frame = getglobal("pfRaid" .. i) + frame.drag:SetScript("OnMouseWheel", function() + local scale = round(frame:GetScale() + arg1/10, 1) + + if IsShiftKeyDown() and strsub(frame:GetName(),0,6) == "pfRaid" then + for i=1,40 do + local frame = getglobal("pfRaid" .. i) + pfUI.gui:SaveScale(frame, scale) + end + elseif IsShiftKeyDown() and strsub(frame:GetName(),0,7) == "pfGroup" then + for i=1,4 do + local frame = getglobal("pfGroup" .. i) + pfUI.gui:SaveScale(frame, scale) + end + else pfUI.gui:SaveScale(frame, scale) end - elseif IsShiftKeyDown() and strsub(frame:GetName(),0,7) == "pfGroup" then - for i=1,4 do - local frame = getglobal("pfGroup" .. i) - pfUI.gui:SaveScale(frame, scale) + + -- repaint hackfix for panels + pfUI.panel.left:SetScale(pfUI.chat.left:GetScale()) + pfUI.panel.right:SetScale(pfUI.chat.right:GetScale()) + end) + end + + frame.drag:SetScript("OnMouseDown",function() + frame:StartMoving() + end) + + frame.drag:SetScript("OnMouseUp",function() + frame:StopMovingOrSizing() + _, _, _, xpos, ypos = frame:GetPoint() + + if not pfUI_config.position[frame:GetName()] then + pfUI_config.position[frame:GetName()] = {} end - else - pfUI.gui:SaveScale(frame, scale) + + pfUI_config.position[frame:GetName()]["xpos"] = xpos + pfUI_config.position[frame:GetName()]["ypos"] = ypos + end) + + if pfUI.gitter:IsShown() then + frame:SetMovable(true) + frame.drag:EnableMouse(true) + frame.drag:Show() + frame:Show() + else + frame:SetMovable(false) + frame.drag:EnableMouse(false) + frame.drag:Hide() + if frame.hideLater == true then + frame:Hide() end - - -- repaint hackfix for panels - pfUI.panel.left:SetScale(pfUI.chat.left:GetScale()) - pfUI.panel.right:SetScale(pfUI.chat.right:GetScale()) - end) - end - - frame.drag:SetScript("OnMouseDown",function() - frame:StartMoving() - end) - - frame.drag:SetScript("OnMouseUp",function() - frame:StopMovingOrSizing() - _, _, _, xpos, ypos = frame:GetPoint() - - if not pfUI_config.position[frame:GetName()] then - pfUI_config.position[frame:GetName()] = {} - end - - pfUI_config.position[frame:GetName()]["xpos"] = xpos - pfUI_config.position[frame:GetName()]["ypos"] = ypos - end) - - if pfUI.gitter:IsShown() then - frame:SetMovable(true) - frame.drag:EnableMouse(true) - frame.drag:Show() - frame:Show() - else - frame:SetMovable(false) - frame.drag:EnableMouse(false) - frame.drag:Hide() - if frame.hideLater == true then - frame:Hide() end end end diff --git a/modules/minimap.lua b/modules/minimap.lua index 5da245f8..de98b3e8 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -18,7 +18,7 @@ pfUI:RegisterModule("minimap", function () pfUI.minimap:SetBackdrop(pfUI.backdrop) pfUI.minimap:SetBackdropColor(0,0,0,0) pfUI.minimap:SetPoint("TOPRIGHT", UIParent, -5, -5) - pfUI.utils:loadPosition(pfUI.minimap) + pfUI.utils:UpdateMovable(pfUI.minimap) pfUI.minimap:SetWidth(Minimap:GetWidth() + 5) pfUI.minimap:SetHeight(Minimap:GetHeight() + 5) pfUI.minimap:SetFrameStrata("BACKGROUND") diff --git a/modules/panel.lua b/modules/panel.lua index c5192540..6ceea3ff 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -46,7 +46,7 @@ pfUI:RegisterModule("panel", function () pfUI.panel.clock.timerFrame:SetWidth(120) pfUI.panel.clock.timerFrame:SetHeight(35) pfUI.panel.clock.timerFrame:SetPoint("TOP", 0, -100) - pfUI.utils:loadPosition(pfUI.panel.clock.timerFrame) + pfUI.utils:UpdateMovable(pfUI.panel.clock.timerFrame) pfUI.panel.clock.timerFrame.text = pfUI.panel.clock.timerFrame:CreateFontString("Status", "LOW", "GameFontNormal") pfUI.panel.clock.timerFrame.text:SetFontObject(GameFontWhite) @@ -474,7 +474,7 @@ pfUI:RegisterModule("panel", function () pfUI.panel.minimap = CreateFrame("Button", "pfPanelMinimap", UIParent) pfUI.panel.minimap:SetBackdrop(pfUI.backdrop) pfUI.panel.minimap:SetPoint("TOPRIGHT",UIParent, -5, -7 - Minimap:GetHeight() - 5) - pfUI.utils:loadPosition(pfUI.panel.minimap) + pfUI.utils:UpdateMovable(pfUI.panel.minimap) pfUI.panel.minimap:SetHeight(pfUI_config.global.font_size * 2) pfUI.panel.minimap:SetWidth(Minimap:GetWidth() + 5) pfUI.panel.minimap:SetFrameStrata("BACKGROUND") @@ -488,7 +488,7 @@ pfUI:RegisterModule("panel", function () if pfUI_config.panel.micro.enable == "1" then pfUI.panel.microbutton = CreateFrame("Frame", "pfPanelMicroButton", UIParent) pfUI.panel.microbutton:SetPoint("TOP", 0, 0) - pfUI.utils:loadPosition(pfUI.panel.microbutton) + pfUI.utils:UpdateMovable(pfUI.panel.microbutton) pfUI.panel.microbutton:SetHeight(23) pfUI.panel.microbutton:SetWidth(145) pfUI.panel.microbutton:SetFrameStrata("BACKGROUND") diff --git a/modules/pet.lua b/modules/pet.lua index 3c5f091c..e0c4d8ac 100644 --- a/modules/pet.lua +++ b/modules/pet.lua @@ -1,14 +1,14 @@ pfUI:RegisterModule("pet", function () -- do not go further on disabled UFs if pfUI_config.unitframes.disable == "1" then return end - + pfUI.uf.pet = CreateFrame("Button","pfPet",UIParent) pfUI.uf.pet:SetWidth(100) pfUI.uf.pet:SetHeight(23) pfUI.uf.pet:ClearAllPoints() pfUI.uf.pet:SetPoint("BOTTOM", UIParent , "BOTTOM", 0, 163) - pfUI.utils:loadPosition(pfUI.uf.pet) + pfUI.utils:UpdateMovable(pfUI.uf.pet) pfUI.uf.pet:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.pet:SetScript("OnClick", function () diff --git a/modules/player.lua b/modules/player.lua index 7dcb26f8..19290c39 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -9,7 +9,7 @@ pfUI:RegisterModule("player", function () pfUI.uf.player:SetWidth(pfUI_config.unitframes.player.width) pfUI.uf.player:SetHeight(pfUI_config.unitframes.player.height+pfUI_config.unitframes.player.pheight) pfUI.uf.player:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOM", -75, 125) - pfUI.utils:loadPosition(pfUI.uf.player) + pfUI.utils:UpdateMovable(pfUI.uf.player) pfUI.uf.player:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.player:SetScript("OnClick", function () if arg1 == "RightButton" then diff --git a/modules/raid.lua b/modules/raid.lua index 27033bd6..d27027d0 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -72,7 +72,7 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i]:SetWidth(50) pfUI.uf.raid[i]:SetHeight(35) pfUI.uf.raid[i]:SetPoint("BOTTOMLEFT", (r-1) * 52 + 5, 160 + ((g-1)*37)) - pfUI.utils:loadPosition(pfUI.uf.raid[i]) + pfUI.utils:UpdateMovable(pfUI.uf.raid[i]) pfUI.uf.raid[i]:Hide() pfUI.uf.raid[i].id = 0 diff --git a/modules/target.lua b/modules/target.lua index 6b61b751..597d16c8 100644 --- a/modules/target.lua +++ b/modules/target.lua @@ -15,8 +15,7 @@ pfUI:RegisterModule("target", function () pfUI.uf.target:SetWidth(pfUI_config.unitframes.target.width) pfUI.uf.target:SetHeight(pfUI_config.unitframes.target.height+pfUI_config.unitframes.target.pheight) pfUI.uf.target:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 75, 125) - pfUI.utils:loadPosition(pfUI.uf.target) - + pfUI.utils:UpdateMovable(pfUI.uf.target) pfUI.uf.target:RegisterForClicks('LeftButtonUp', 'RightButtonUp') pfUI.uf.target:SetScript("OnClick", function () diff --git a/modules/targettarget.lua b/modules/targettarget.lua index e7610a0d..68164175 100644 --- a/modules/targettarget.lua +++ b/modules/targettarget.lua @@ -16,7 +16,7 @@ pfUI:RegisterModule("targettarget", function () pfUI.uf.targettarget:SetWidth(100) pfUI.uf.targettarget:SetHeight(25) pfUI.uf.targettarget:SetPoint("BOTTOM", UIParent , "BOTTOM", 0, 125) - pfUI.utils:loadPosition(pfUI.uf.targettarget) + pfUI.utils:UpdateMovable(pfUI.uf.targettarget) pfUI.uf.targettarget:SetBackdrop(pfUI.backdrop) pfUI.uf.targettarget:RegisterForClicks('LeftButtonUp', 'RightButtonUp') diff --git a/pfUI.lua b/pfUI.lua index 0040ff13..eed51f07 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -26,6 +26,7 @@ pfUI.cache = {} pfUI.module = {} pfUI.modules = {} pfUI.environment = {} +pfUI.movables = {} pfLocaleClass = {} pfLocaleBagtypes = {} @@ -90,7 +91,14 @@ pfUI.backdrop_underline = { pfUI.utils = CreateFrame("Frame",nil,UIParent) -function pfUI.utils:loadPosition(frame) +function pfUI.utils:UpdateMovable(frame) + local name = frame:GetName() + + if not pfUI.movables[name] then + pfUI.movables[name] = true + table.insert(pfUI.movables, name) + end + if pfUI_config["position"][frame:GetName()] then if pfUI_config["position"][frame:GetName()]["scale"] then frame:SetScale(pfUI_config["position"][frame:GetName()].scale)