From e067ce0b4155fa1d1d58e116cc337281150bada0 Mon Sep 17 00:00:00 2001 From: p3lim Date: Thu, 23 Sep 2010 21:45:36 +0200 Subject: [PATCH] Add positioning --- config/configuration.lua | 17 +++++++++++++++++ pMinimap.lua | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/config/configuration.lua b/config/configuration.lua index 881b676..67f9e60 100644 --- a/config/configuration.lua +++ b/config/configuration.lua @@ -46,6 +46,16 @@ function ns.UpdateFont() TimeManagerClockTicker:SetFont(font, size, flag) end +function ns.UpdatePosition(save) + if(save) then + local point, _, _, x, y = Minimap:GetPoint() + pMinimapDB.minimap.position = string.format('%s\031%d\031%d', point, x, y) + else + local point, x, y = string.split('\031', pMinimapDB.minimap.position) + Minimap:ClearAllPoints() + Minimap:SetPoint(point, UIParent, point, x, y) + end +end local function AddConfig(name, func) local group = CreateFrame('Frame', nil, InterfaceOptionsFramePanelContainer) @@ -68,6 +78,13 @@ AddConfig('pMinimap', function(self) ns.UpdateCore() end) + local unlock = ns.checkbox(self, 'Unlocked', 'TOPLEFT', 30, -80) + unlock:SetChecked(ns.UNLOCKED) + unlock:SetScript('OnClick', function() + ns.UNLOCKED = not ns.UNLOCKED + unlock:SetChecked(ns.UNLOCKED) + end) + local level = ns.slider(self, 'Frame Level', '%d', pMinimapDB.minimap.level, 0, 10, 1, 'TOPRIGHT', -30, -30) level:HookScript('OnValueChanged', function(frame, value) pMinimapDB.minimap.level = value diff --git a/pMinimap.lua b/pMinimap.lua index dcbe5ec..c2de826 100644 --- a/pMinimap.lua +++ b/pMinimap.lua @@ -11,6 +11,7 @@ local DEFAULTS = { strata = 'BACKGROUND', borderSize = 1, borderColors = {0, 0, 0, 1}, + position = 'TOPRIGHT\031-15\031-15', }, objects = { Zone = {point = 'TOP', shown = false}, @@ -43,7 +44,20 @@ function pMinimap:PLAYER_LOGIN() end end) + Minimap:SetMovable(true) + Minimap:SetClampedToScreen() + Minimap:RegisterForDrag('LeftButton') Minimap:SetMaskTexture([=[Interface\ChatFrame\ChatFrameBackground]=]) + Minimap:SetScript('OnDragStart', function(self) + if(not ns.UNLOCKED) then return end + self:StartMoving() + end) + Minimap:SetScript('OnDragStop', function(self) + if(not ns.UNLOCKED) then return end + self:StopMovingOrSizing() + ns.UpdatePosition(true) + end) + MinimapCluster:EnableMouse(false) MinimapBorder:SetTexture(nil) MinimapBorderTop:Hide() @@ -79,6 +93,8 @@ function pMinimap:PLAYER_LOGIN() TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton) TimeManagerClockTicker:SetShadowOffset(0, 0) + ns.UNLOCKED = false + ns.UpdatePosition() ns.UpdateObjects() ns.UpdateCore() ns.UpdateFont() -- 1.7.9.5