diff --git a/pMinimap/pMinimap.lua b/pMinimap/pMinimap.lua index ea882d7..65f8bfa 100644 --- a/pMinimap/pMinimap.lua +++ b/pMinimap/pMinimap.lua @@ -44,7 +44,7 @@ function pMinimap:ADDON_LOADED() MiniMapMailFrame:SetHeight(8) MiniMapMailText = MiniMapMailFrame:CreateFontString(nil, 'OVERLAY') - MiniMapMailText:SetFont([[Interface\AddOns\pMinimap\font.ttf]], 13, 'OUTLINE') + MiniMapMailText:SetFont([=[Interface\AddOns\pMinimap\font.ttf]=], 13, 'OUTLINE') MiniMapMailText:SetPoint('BOTTOM', 0, 2) MiniMapMailText:SetText('New Mail!') MiniMapMailText:SetTextColor(1, 1, 1) @@ -59,7 +59,7 @@ function pMinimap:ADDON_LOADED() self:SetPoint(unpack(db.point)) self:SetWidth(Minimap:GetWidth() * db.scale) self:SetHeight(Minimap:GetHeight() * db.scale) - self:SetBackdrop({bgFile = [[Interface\ChatFrame\ChatFrameBackground]]}) + self:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=]}) self:SetBackdropColor(0, 1, 0, 0.5) self:SetAlpha(0) self:SetMovable(true) @@ -70,8 +70,8 @@ function pMinimap:ADDON_LOADED() Minimap:ClearAllPoints() Minimap:SetPoint('CENTER', self) Minimap:SetScale(db.scale) - Minimap:SetMaskTexture([[Interface\ChatFrame\ChatFrameBackground]]) - Minimap:SetBackdrop({bgFile = [[Interface\ChatFrame\ChatFrameBackground]], insets = {top = - db.offset, left = - db.offset, bottom = - db.offset, right = - db.offset}}) + Minimap:SetMaskTexture([=[Interface\ChatFrame\ChatFrameBackground]=]) + Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = - db.offset, left = - db.offset, bottom = - db.offset, right = - db.offset}}) Minimap:SetBackdropColor(unpack(db.colors)) if(db.durability) then diff --git a/pMinimap/pMinimap.toc b/pMinimap/pMinimap.toc index 8ce9641..b51f152 100644 --- a/pMinimap/pMinimap.toc +++ b/pMinimap/pMinimap.toc @@ -3,11 +3,11 @@ ## Version: Revision wowi:revision ## Title: |cffff6000p|rMinimap ## Notes: Yet another square minimap addon -## OptionalDeps: LibSimpleOptions-1.0 +## OptionalDeps: LibStub, LibSimpleOptions-1.0 ## SavedVariablesPerCharacter: pMinimapDB LibSimpleOptions-1.0\LibStub\LibStub.lua LibSimpleOptions-1.0\LibSimpleOptions-1.0.lua pMinimap.lua -pMinimapConfig.lua +pMinimapConfig.lua \ No newline at end of file diff --git a/pMinimap/pMinimapConfig.lua b/pMinimap/pMinimapConfig.lua index 0515f12..71ddcf6 100644 --- a/pMinimap/pMinimapConfig.lua +++ b/pMinimap/pMinimapConfig.lua @@ -1,96 +1,82 @@ -local locked = true -local LibSimpleOptions = LibStub('LibSimpleOptions-1.0') +local function CreateOptions(self, db) + local title, sub = self:MakeTitleTextAndSubText('pMinimap', 'These options allow you to customize the looks of pMinimap.') -local function Options(self, anchor, db) - local title, subText = self:MakeTitleTextAndSubText('pMinimap', 'These options allow you to change the position of pMinimap') - local lock = self:MakeToggle( - 'name', 'Toggle Minimap Locked State', + self:MakeToggle( + 'name', 'Toggle Minimap locked state', 'description', 'Set whether Minimap is locked or not', 'default', true, - 'current', locked, - 'setFunc', function(value) - locked = value - if(value) then - local p1, p, p2, x, y = anchor:GetPoint() - db.point[1] = p1 - db.point[3] = p2 - db.point[4] = x - db.point[5] = y - anchor:SetAlpha(0) - anchor:EnableMouse(false) + 'current', true, + 'setFunc', function(x) + pMinimap:EnableMouse(x) + if(x) then + local p,_,r,x,y = pMinimap:GetPoint() + db.point[1], db.point[3], db.point[4], db.point[5] = p, r, x, y + pMinimap:SetAlpha(0) else - anchor:SetAlpha(1) - anchor:EnableMouse(true) + pMinimap:SetAlpha(1) end - end) - lock:SetPoint('TOPLEFT', subText, 'BOTTOMLEFT', 0, -8) + end + ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -16) - local scale = self:MakeSlider( + self:MakeSlider( 'name', 'Minimap Scale', - 'description', 'Drag to change the Minimap scale', - 'minText', '0.4', - 'maxText', '2.4', - 'minValue', 0.4, - 'maxValue', 2.4, - 'step', 0.1, + 'description', 'Drag to change the minimap scale', 'default', 0.9, + 'minText', '0.5', 'maxText', '2.5', + 'minValue', 0.5, 'maxValue', 2.5, + 'step', 0.1, 'current', db.scale, - 'setFunc', function(value) - db.scale = value - Minimap:SetScale(value) - anchor:SetWidth(Minimap:GetWidth() * value) - anchor:SetHeight(Minimap:GetHeight() * value) + 'setFunc', function(x) + db.scale = x + Minimap:SetScale(x) + pMinimap:SetWidth(Minimap:GetWidth() * x) + pMinimap:SetHeight(Minimap:GetHeight() * x) end, 'currentTextFunc', function(num) - return ('%.1f'):format(num) - end) - scale:SetPoint('TOPLEFT', lock, 'BOTTOMLEFT', 0, -16) + return format('%.1f', num) + end + ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -56) - local dura = self:MakeToggle( - 'name', 'Toggle Durability', + self:MakeToggle( + 'name', 'Toggle durability recoloring', 'description', 'Set whether backdrop is recolored by durability or not', 'default', true, 'current', db.durability, - 'setFunc', function(value) - self:Refresh() - db.durability = value - if(db.backdrop) then - if(value) then - pMinimap:RegisterEvent('UPDATE_INVENTORY_ALERTS') - pMinimap.UPDATE_INVENTORY_ALERTS() - DurabilityFrame:SetAlpha(0) - else - pMinimap:UnregisterEvent('UPDATE_INVENTORY_ALERTS') - Minimap:SetBackdropColor(unpack(db.colors)) - DurabilityFrame:SetAlpha(1) - end + 'setFunc', function(x) + db.durability = x + if(x) then + pMinimap:RegisterEvent('UPDATE_INVENTORY_ALERTS') + pMinimap.UPDATE_INVENTORY_ALERTS() + DurabilityFrame:SetAlpha(0) + else + pMinimap:UnregisterEvent('UPDATE_INVENTORY_ALERTS') + Minimap:SetBackdropColor(unpack(db.colors)) + DurabilityFrame:SetAlpha(1) end - end) - dura:SetPoint('TOPLEFT', scale, 'BOTTOMLEFT', 0, -8) + end + ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -86) - local offset = self:MakeSlider( + self:MakeSlider( 'name', 'Backdrop offset', - 'description', 'Drag to change the bg border size', - 'minText', '-1', - 'maxText', '10', - 'minValue', -1, - 'maxValue', 10, - 'step', 1, + 'description', 'Drag to change the backdrop border size', 'default', 1, + 'minText', '0', 'maxText', '10', + 'minValue', 0, 'maxValue', 10, + 'step', 1, 'current', db.offset, - 'setFunc', function(value) - db.offset = value - Minimap:SetBackdrop({bgFile = [[Interface\ChatFrame\ChatFrameBackground]], insets = {top = - db.offset, left = - db.offset, bottom = - db.offset, right = - db.offset}}) + 'setFunc', function(x) + db.offset = x + Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = - x, left = - x, bottom = - x, right = - x}}) Minimap:SetBackdropColor(unpack(db.colors)) end, 'currentTextFunc', function(num) - return ('%.0f'):format(num) - end) - offset:SetPoint('TOPLEFT', dura, 'BOTTOMLEFT', 0, -16) + return num + end + ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -126) - local color = self:MakeColorPicker( - 'name', "Custom Color", - 'description', "Set custom bg color with a palette", + self:MakeColorPicker( + 'name', 'Custom color', + 'description', 'Click to set custom backdrop color', 'hasAlpha', true, 'defaultR', 0, 'defaultG', 0, @@ -98,20 +84,17 @@ local function Options(self, anchor, db) 'defaultA', 1, 'getFunc', function() return unpack(db.colors) end, 'setFunc', function(r, g, b, a) - db.colors[1] = r - db.colors[2] = g - db.colors[3] = b - db.colors[4] = a + db.colors[1], db.colors[2], db.colors[3], db.colors[4] = r, g, b, a Minimap:SetBackdropColor(unpack(db.colors)) - end) - color:SetPoint("TOPLEFT", offset, "BOTTOMLEFT", 0, -8) + end + ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -156) end - + function pMinimap:PLAYER_ENTERING_WORLD() local db = pMinimapDB or {point = {'TOPRIGHT', 'UIParent', 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0, 1}, durability = true} - LibSimpleOptions.AddOptionsPanel('pMinimap', function(self) Options(self, pMinimap, db) end) - LibSimpleOptions.AddSlashCommand('pMinimap', '/pminimap', '/pmm') + LibStub('LibSimpleOptions-1.0').AddOptionsPanel('pMinimap', function(self) CreateOptions(self, db) end) + LibStub('LibSimpleOptions-1.0').AddSlashCommand('pMinimap', '/pminimap', '/pmm') pMinimapDB = db end \ No newline at end of file