diff --git a/pMinimap/pMinimap.lua b/pMinimap/pMinimap.lua index 0323c13..b74ac14 100644 --- a/pMinimap/pMinimap.lua +++ b/pMinimap/pMinimap.lua @@ -2,12 +2,9 @@ pMinimap = CreateFrame('Frame', 'pMinimap', UIParent) pMinimap:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end) pMinimap:RegisterEvent('ADDON_LOADED') -function pMinimap.ADDON_LOADED(self) - if(not IsAddOnLoaded('Blizzard_TimeManager')) then - LoadAddOn('Blizzard_TimeManager') - end - - local db = pMinimapDB or {point = {'TOPRIGHT', UIParent, 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0}, durability = true} +function pMinimap.ADDON_LOADED(self, event, name) + if(name ~= 'pMinimap') then return end + local db = _G.pMinimapDB or {point = {'TOPRIGHT', UIParent, 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0}, durability = true, coords = false} MinimapBorder:SetTexture() MinimapBorderTop:Hide() @@ -54,31 +51,6 @@ function pMinimap.ADDON_LOADED(self) MiniMapMailText:SetText('New Mail!') MiniMapMailText:SetTextColor(1, 1, 1) - TimeManagerClockButton:ClearAllPoints() - TimeManagerClockButton:SetPoint('BOTTOM', Minimap) - TimeManagerClockButton:SetWidth(40) - TimeManagerClockButton:SetHeight(14) - TimeManagerClockButton:GetRegions():Hide() - TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton) - TimeManagerClockTicker:SetFont([=[Interface\AddOns\pMinimap\font.ttf]=], 13, 'OUTLINE') - TimeManagerAlarmFiredTexture.Show = function() TimeManagerClockTicker:SetTextColor(1, 0, 0) end - TimeManagerAlarmFiredTexture.Hide = function() TimeManagerClockTicker:SetTextColor(1, 1, 1) end - TimeManagerClockButton:SetScript('OnClick', function(self, button) - if(self.alarmFiring) then - PlaySound('igMainMenuQuit') - TimeManager_TurnOffAlarm() - else - if(button == 'RightButton') then - if(not IsAddOnLoaded('Blizzard_Calendar')) then - LoadAddOn('Blizzard_Calendar') - end - ToggleCalendar() - else - ToggleTimeManager() - end - end - end) - GameTimeFrame:Hide() MiniMapWorldMapButton:Hide() MiniMapVoiceChatFrame:Hide() @@ -105,31 +77,34 @@ function pMinimap.ADDON_LOADED(self) Minimap:SetBackdropColor(unpack(db.colors)) if(db.durability) then - self:RegisterEvent('UPDATE_INVENTORY_ALERTS') - DurabilityFrame:SetAlpha(0) + if(not IsAddOnLoaded('pMinimap_Durability')) then + LoadAddOn('pMinimap_Durability') + end end - self:RegisterEvent('PLAYER_ENTERING_WORLD') - self:UnregisterEvent('ADDON_LOADED') -end + if(db.coords) then + if(not IsAddOnLoaded('pMinimap_Coords')) then + LoadAddOn('pMinimap_Coords') + end + end -function pMinimap.UPDATE_INVENTORY_ALERTS() - local db = pMinimapDB or {colors = {0, 0, 0, 1}} - local maxStatus = 0 - for id in pairs(INVENTORY_ALERT_STATUS_SLOTS) do - local status = GetInventoryAlertStatus(id) - if(status > maxStatus) then - maxStatus = status + if(GetCVar('showClock') == '1') then + if(not IsAddOnLoaded('pMinimap_Clock')) then + LoadAddOn('pMinimap_Clock') end end - local color = INVENTORY_ALERT_COLORS[maxStatus] - if(color) then - Minimap:SetBackdropColor(color.r, color.g, color.b) - else - Minimap:SetBackdropColor(unpack(db.colors)) + self:UnregisterEvent(event) +end + +SlashCmdList['PMMC'] = function() + if(not IsAddOnLoaded('pMinimap_Config')) then + LoadAddOn('pMinimap_Config') end + InterfaceOptionsFrame_OpenToCategory('pMinimap') end +SLASH_PMMC1 = '/pminimap' +SLASH_PMMC2 = '/pmm' -- http://www.wowwiki.com/GetMinimapShape function GetMinimapShape() return 'SQUARE' end \ No newline at end of file diff --git a/pMinimap_Clock/pMinimap_Clock.lua b/pMinimap_Clock/pMinimap_Clock.lua index 4fde667..075ad84 100644 --- a/pMinimap_Clock/pMinimap_Clock.lua +++ b/pMinimap_Clock/pMinimap_Clock.lua @@ -1 +1 @@ -if(not IsAddOnLoaded('Blizzard_TimeManager')) then LoadAddOn('Blizzard_TimeManager') end TimeManagerClockButton:ClearAllPoints() if(pMinimapDB.coords) then TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap) else TimeManagerClockButton:SetPoint('BOTTOM', Minimap) end TimeManagerClockButton:SetWidth(40) TimeManagerClockButton:SetHeight(14) TimeManagerClockButton:GetRegions():Hide() TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton) TimeManagerClockTicker:SetFont([=[Interface\AddOns\pMinimap\font.ttf]=], 13, 'OUTLINE') TimeManagerAlarmFiredTexture.Show = function() TimeManagerClockTicker:SetTextColor(1, 0, 0) end TimeManagerAlarmFiredTexture.Hide = function() TimeManagerClockTicker:SetTextColor(1, 1, 1) end TimeManagerClockButton:SetScript('OnClick', function(self, button) if(self.alarmFiring) then PlaySound('igMainMenuQuit') TimeManager_TurnOffAlarm() else if(button == 'RightButton') then if(not IsAddOnLoaded('Blizzard_Calendar')) then LoadAddOn('Blizzard_Calendar') end ToggleCalendar() else ToggleTimeManager() end end end) \ No newline at end of file +local db = _G.pMinimapDB or {point = {'TOPRIGHT', UIParent, 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0}, durability = true, coords = false} for _, check in pairs{InterfaceOptionsDisplayPanelShowClock} do check:Disable() check.Enable = function() end end if(not IsAddOnLoaded('Blizzard_TimeManager')) then LoadAddOn('Blizzard_TimeManager') end InterfaceOptionsDisplayPanelShowClock_SetFunc('1') TimeManagerClockButton:ClearAllPoints() if(db.coords) then TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap) else TimeManagerClockButton:SetPoint('BOTTOM', Minimap) end TimeManagerClockButton:SetWidth(40) TimeManagerClockButton:SetHeight(14) TimeManagerClockButton:GetRegions():Hide() TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton) TimeManagerClockTicker:SetFont([=[Interface\AddOns\pMinimap\font.ttf]=], 13, 'OUTLINE') TimeManagerAlarmFiredTexture.Show = function() TimeManagerClockTicker:SetTextColor(1, 0, 0) end TimeManagerAlarmFiredTexture.Hide = function() TimeManagerClockTicker:SetTextColor(1, 1, 1) end TimeManagerClockButton:SetScript('OnClick', function(self, button) if(self.alarmFiring) then PlaySound('igMainMenuQuit') TimeManager_TurnOffAlarm() else if(button == 'RightButton') then if(not IsAddOnLoaded('Blizzard_Calendar')) then LoadAddOn('Blizzard_Calendar') end ToggleCalendar() else ToggleTimeManager() end end end) \ No newline at end of file diff --git a/pMinimap_Clock/pMinimap_Clock.toc b/pMinimap_Clock/pMinimap_Clock.toc index d490a12..cbab408 100644 --- a/pMinimap_Clock/pMinimap_Clock.toc +++ b/pMinimap_Clock/pMinimap_Clock.toc @@ -3,6 +3,7 @@ ## Version: 30000.wowi:revision ## Title: |cffff6000p|rMinimap_Clock ## Notes: Clock module for pMinimap +## SavedVariablesPerCharacter: pMinimapDB ## RequiredDeps: pMinimap ## LoadOnDemand: 1 diff --git a/pMinimap_Config/pMinimap_Config.lua b/pMinimap_Config/pMinimap_Config.lua index 004057b..e15e870 100644 --- a/pMinimap_Config/pMinimap_Config.lua +++ b/pMinimap_Config/pMinimap_Config.lua @@ -1 +1 @@ -local function CreateOptions(self, db) local title, sub = self:MakeTitleTextAndSubText('pMinimap', 'These options allow you to customize the looks of pMinimap.') self:MakeToggle( 'name', 'Toggle Minimap locked state', 'description', 'Set whether Minimap is locked or not', 'default', true, 'current', true, 'setFunc', function(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:EnableMouse(false) pMinimap:SetAlpha(0) else pMinimap:EnableMouse(true) pMinimap:SetAlpha(1) end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -16) self:MakeSlider( 'name', 'Minimap Scale', 'description', 'Drag to change the minimap scale', 'default', 0.9, 'minText', '0.75', 'maxText', '2.50', 'minValue', 0.75, 'maxValue', 2.50, 'step', 0.01, 'current', db.scale, 'setFunc', function(x) db.scale = x Minimap:SetScale(x) pMinimap:SetWidth(Minimap:GetWidth() * x) pMinimap:SetHeight(Minimap:GetHeight() * x) end, 'currentTextFunc', function(num) return format('%.2f', num) end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -56) self:MakeToggle( 'name', 'Show Clock' 'description', 'Check to enable the clock module', 'default', true, 'current', function() local c = GetCVar('showClock'); return c == '1' and true or false end, 'setFunc', function(x) SetCVar('showClock', x) if(x) then if(not AddOnIsLoaded('pMinimap_Clock')) then LoadAddOn('pMinimap_Clock') end TimeManagerClockButton:ClearAllPoints() if(db.coords) then TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap) else TimeManagerClockButton:SetPoint('BOTTOM', Minimap) end else if(db.coords) then MiniMapCoords:ClearAllPoints() MiniMapCoords:SetPoint('BOTTOM', Minimap) end end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -180) self:MakeToggle( 'name', 'Show Coords', 'description', 'Check to enable the coords module', 'default', false, 'current', db.coords, 'setFunc', function(x) db.coords = x if(x) then if(not AddOnIsLoaded('pMinimap_Coords')) then LoadAddOn('pMinimap_Coords') end MiniMapCoords:Show() MiniMapCoords:ClearAllPoints() if(GetCVar('showClock') == '1') then MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap) else MiniMapCoords:SetPoint('BOTTOM', Minimap) end else MiniMapCoords:Hide() if(GetCVar('showClock') == '1') then TimeManagerClockButton:ClearAllPoints() TimeManagerClockButton:SetPoint('BOTTOM', Minimap) end end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -200) self:MakeToggle( 'name', 'Check to enable durability module', 'description', 'Set whether backdrop is recolored by durability or not', 'default', true, 'current', db.durability, 'setFunc', function(x) db.durability = x if(x) then if(not AddOnIsLoaded('pMinimap_Durability')) then LoadAddOn('pMinimap_Durability') else pMinimap:RegisterEvent('UPDATE_INVENTORY_ALERTS') pMinimap.UPDATE_INVENTORY_ALERTS() DurabilityFrame:SetAlpha(0) end else pMinimap:UnregisterEvent('UPDATE_INVENTORY_ALERTS') Minimap:SetBackdropColor(unpack(db.colors)) DurabilityFrame:SetAlpha(1) end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -86) self:MakeSlider( 'name', 'Backdrop offset', '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(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 num end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -126) self:MakeColorPicker( 'name', 'Custom color', 'description', 'Click to set custom backdrop color', 'hasAlpha', true, 'defaultR', 0, 'defaultG', 0, 'defaultB', 0, 'defaultA', 1, 'getFunc', function() return unpack(db.colors) end, 'setFunc', function(r, g, b, a) db.colors[1], db.colors[2], db.colors[3], db.colors[4] = r, g, b, a Minimap:SetBackdropColor(unpack(db.colors)) end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -156) end local db = pMinimapDB or {point = {'TOPRIGHT', 'UIParent', 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0, 1}, durability = true, coords = false} LibStub('LibSimpleOptions-1.0').AddOptionsPanel('pMinimap', function(self) CreateOptions(self, db) end) pMinimapDB = db \ No newline at end of file +LibStub('LibSimpleOptions-1.0').AddOptionsPanel('pMinimap', function(self) local title, sub = self:MakeTitleTextAndSubText('pMinimap', 'These options allow you to customize the looks of pMinimap.') self:MakeToggle( 'name', 'Toggle Minimap locked state', 'description', 'Set whether Minimap is locked or not', 'default', true, 'current', true, 'setFunc', function(x) if(x) then local p,_,r,x,y = pMinimap:GetPoint() _G.pMinimapDB.point[1] = p _G.pMinimapDB.point[3] = r _G.pMinimapDB.point[4] = x _G.pMinimapDB.point[5] = y pMinimap:EnableMouse(false) pMinimap:SetAlpha(0) else pMinimap:EnableMouse(true) pMinimap:SetAlpha(1) end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -16) self:MakeSlider( 'name', 'Minimap Scale', 'description', 'Drag to change the minimap scale', 'default', 0.9, 'minText', '0.75', 'maxText', '2.50', 'minValue', 0.75, 'maxValue', 2.50, 'step', 0.01, 'current', _G.pMinimapDB.scale, 'setFunc', function(x) _G.pMinimapDB.scale = x Minimap:SetScale(x) pMinimap:SetWidth(Minimap:GetWidth() * x) pMinimap:SetHeight(Minimap:GetHeight() * x) end, 'currentTextFunc', function(num) return format('%.2f', num) end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -56) self:MakeToggle( 'name', 'Show Clock', 'description', 'Check to enable the clock module', 'default', true, 'current', (GetCVar('showClock') == '1' and true or false), 'setFunc', function(x) if(x) then if(not IsAddOnLoaded('pMinimap_Clock')) then LoadAddOn('pMinimap_Clock') end SetCVar('showClock', '1', 'SHOW_CLOCK') InterfaceOptionsDisplayPanelShowClock_SetFunc('1') TimeManagerClockButton:ClearAllPoints() if(_G.pMinimapDB.coords) then MiniMapCoords:ClearAllPoints() MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap) TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap) else TimeManagerClockButton:SetPoint('BOTTOM', Minimap) end else InterfaceOptionsDisplayPanelShowClock_SetFunc('0') SetCVar('showClock', '0', 'SHOW_CLOCK') if(_G.pMinimapDB.coords) then MiniMapCoords:ClearAllPoints() MiniMapCoords:SetPoint('BOTTOM', Minimap) end end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -180) self:MakeToggle( 'name', 'Show Coords', 'description', 'Check to enable the coords module', 'default', false, 'current', _G.pMinimapDB.coords, 'setFunc', function(x) _G.pMinimapDB.coords = x if(x) then if(not IsAddOnLoaded('pMinimap_Coords')) then LoadAddOn('pMinimap_Coords') end MiniMapCoords:Show() MiniMapCoords:ClearAllPoints() if(GetCVar('showClock') == '1') then TimeManagerClockButton:ClearAllPoints() TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap) MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap) else MiniMapCoords:SetPoint('BOTTOM', Minimap) end else MiniMapCoords:Hide() if(GetCVar('showClock') == '1') then TimeManagerClockButton:ClearAllPoints() TimeManagerClockButton:SetPoint('BOTTOM', Minimap) end end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -200) self:MakeToggle( 'name', 'Enable durabilty coloring', 'description', 'Check to enable durability module', 'default', true, 'current', _G.pMinimapDB.durability, 'setFunc', function(x) _G.pMinimapDB.durability = x if(x) then if(not IsAddOnLoaded('pMinimap_Durability')) then LoadAddOn('pMinimap_Durability') else pMinimap:RegisterEvent('UPDATE_INVENTORY_ALERTS') pMinimap.UPDATE_INVENTORY_ALERTS() DurabilityFrame:SetAlpha(0) end else pMinimap:UnregisterEvent('UPDATE_INVENTORY_ALERTS') Minimap:SetBackdropColor(unpack(_G.pMinimapDB.colors)) DurabilityFrame:SetAlpha(1) end end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -86) self:MakeSlider( 'name', 'Backdrop offset', 'description', 'Drag to change the backdrop border size', 'default', 1, 'minText', '0', 'maxText', '10', 'minValue', 0, 'maxValue', 10, 'step', 1, 'current', _G.pMinimapDB.offset, 'setFunc', function(x) _G.pMinimapDB.offset = x Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = - x, left = - x, bottom = - x, right = - x}}) Minimap:SetBackdropColor(unpack(_G.pMinimapDB.colors)) end, 'currentTextFunc', function(num) return num end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -126) self:MakeColorPicker( 'name', 'Custom color', 'description', 'Click to set custom backdrop color', 'hasAlpha', true, 'defaultR', 0, 'defaultG', 0, 'defaultB', 0, 'defaultA', 1, 'getFunc', function() return unpack(_G.pMinimapDB.colors) end, 'setFunc', function(r, g, b, a) _G.pMinimapDB.colors[1] = r _G.pMinimapDB.colors[2] = g _G.pMinimapDB.colors[3] = b _G.pMinimapDB.colors[4] = a Minimap:SetBackdropColor(unpack(_G.pMinimapDB.colors)) end ):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -156) end) \ No newline at end of file diff --git a/pMinimap_Config/pMinimap_Config.toc b/pMinimap_Config/pMinimap_Config.toc index fb29d10..a2de320 100644 --- a/pMinimap_Config/pMinimap_Config.toc +++ b/pMinimap_Config/pMinimap_Config.toc @@ -3,6 +3,7 @@ ## Version: 30000.wowi:revision ## Title: |cffff6000p|rMinimap_Config ## Notes: Options module for pMinimap +## SavedVariablesPerCharacter: pMinimapDB ## RequiredDeps: pMinimap ## LoadOnDemand: 1 diff --git a/pMinimap_Coords/pMinimap_Coords.lua b/pMinimap_Coords/pMinimap_Coords.lua index 7af620b..affabbb 100644 --- a/pMinimap_Coords/pMinimap_Coords.lua +++ b/pMinimap_Coords/pMinimap_Coords.lua @@ -1 +1 @@ -local total, font, size = 0, MiniMapMailText:GetFont() MiniMapCoord = CreateFrame('Frame', 'MiniMapCoord', Minimap) MiniMapCoord:SetWidth(40) MiniMapCoord:SetHeight(14) MiniMapCoord:Show() if(GetCVar('showClock') == '1') then MiniMapCoord:SetPoint('BOTTOMRIGHT', Minimap) else MiniMapCoord:SetPoint('BOTTOM', Minimap) end MiniMapCoordText = MiniMapCoord:CreateFontString('MiniMapCoordText', 'OVERLAY') MiniMapCoordText:SetPoint('CENTER', MiniMapCoord) MiniMapCoordText:SetFont(font, size, 'OUTLINE') MiniMapCoordText:SetTextColor(1, 1, 1) MiniMapCoord:SetScript('OnUpdate', function(self, elapsed) total = total + elapsed if(total > 0.25) then if(IsInInstance()) then MiniMapCoordText:SetText() else local x, y = GetPlayerMapPosition('player') MiniMapCoordText:SetFormattedText('%.0f,%.0f', x*100, y*100) end total = 0 end end) TimeManagerClockButton:ClearAllPoints() TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap) TimeManagerClockButton.SetPoint = function() end local handler = CreateFrame('Frame') handler:RegisterEvent('ZONE_CHANGED_NEW_AREA') handler:SetScript('OnEvent', function() SetMapToCurrentZone() end) \ No newline at end of file +local total, font, size = 0, MiniMapMailText:GetFont() MiniMapCoords = CreateFrame('Frame', 'MiniMapCoord', Minimap) MiniMapCoords:SetWidth(40) MiniMapCoords:SetHeight(14) MiniMapCoords:Show() if(GetCVar('showClock') == '1') then MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap) else MiniMapCoords:SetPoint('BOTTOM', Minimap) end MiniMapCoordText = MiniMapCoords:CreateFontString('MiniMapCoordText', 'OVERLAY') MiniMapCoordText:SetPoint('CENTER', MiniMapCoords) MiniMapCoordText:SetFont(font, size, 'OUTLINE') MiniMapCoordText:SetTextColor(1, 1, 1) MiniMapCoord:SetScript('OnUpdate', function(self, elapsed) total = total + elapsed if(total > 0.25) then if(IsInInstance()) then MiniMapCoordText:SetText() else local x, y = GetPlayerMapPosition('player') MiniMapCoordText:SetFormattedText('%.0f,%.0f', x*100, y*100) end total = 0 end end) local handler = CreateFrame('Frame') handler:RegisterEvent('ZONE_CHANGED_NEW_AREA') handler:SetScript('OnEvent', function() SetMapToCurrentZone() end) \ No newline at end of file diff --git a/pMinimap_Durability/pMinimap_Durability.toc b/pMinimap_Durability/pMinimap_Durability.toc index ad235dc..56ee6f0 100644 --- a/pMinimap_Durability/pMinimap_Durability.toc +++ b/pMinimap_Durability/pMinimap_Durability.toc @@ -3,6 +3,7 @@ ## Version: 30000.wowi:revision ## Title: |cffff6000p|rMinimap_Durability ## Notes: Durability module for pMinimap +## SavedVariablesPerCharacter: pMinimapDB ## RequiredDeps: pMinimap ## LoadOnDemand: 1