diff --git a/pMinimap.lua b/pMinimap.lua
index f359a98..7bd8546 100644
--- a/pMinimap.lua
+++ b/pMinimap.lua
@@ -9,53 +9,42 @@
--]]
-pMinimap = CreateFrame('Frame', 'pMinimap', UIParent)
-pMinimap:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end)
-pMinimap:RegisterEvent('ADDON_LOADED')
+local addon = CreateFrame('Frame', 'pMinimap', Minimap)
+addon:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end)
+addon:RegisterEvent('ADDON_LOADED')
-local LSM = LibStub('LibSharedMedia-3.0')
-
-local onUpdate, onClickClock, onClickCoord, onMouseWheel
+local SharedMedia = LibStub('LibSharedMedia-3.0')
local defaults = {
- coords = false,
- coordsDecimals = 0,
- clock = true,
- dura = true,
- mail = true,
- subzone = false,
- unlocked = false,
- scale = 0.9,
- offset = 1,
- level = 2,
- strata = 'BACKGROUND',
- smfont = 'Visitor TT1',
+ font = 'Visitor TT1',
fontsize = 13,
fontflag = 'OUTLINE',
- colors = {0, 0, 0, 1},
zone = false,
- zonePoint = 'TOP',
- zoneOffset = 8,
+ zonepoint = 'TOP',
+ zoneoffset = 8,
+ scale = 0.9,
+ level = 2,
+ strata = 'BACKGROUND',
+ borderoffset = 1,
+ bordercolors = {0, 0, 0, 1},
+ mail = true,
+ clock = true,
+ durabilty = true,
+ coordinates = false,
+ coordinatesdecimals = 0,
}
-
-do
- local total = 0.25
- function onUpdate(self, elapsed)
- if(total) then
- total = total - elapsed
- if(total <= 0) then
- total = 0.25
-
- local x, y = GetPlayerMapPosition('player')
- if(x ~= 0 and y ~= 0) then
- self.Text:SetFormattedText('%.'..pMinimapDB.coordsDecimals..'f,%.'..pMinimapDB.coordsDecimals..'f', x * 100, y * 100)
- else
- self.Text:SetText()
- end
- end
- end
+--[[
+function addon:Clock()
+ if(not IsAddOnLoaded('Blizzard_TimeManager')) then
+ LoadAddOn('Blizzard_TimeManager')
end
- function onClickClock(self, button)
+ TimeManagerClockButton:GetRegions():Hide()
+ TimeManagerClockButton:ClearAllPoints()
+ TimeManagerClockButton:SetPoint(self.db.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap)
+ TimeManagerClockButton:SetWidth(40)
+ TimeManagerClockButton:SetHeight(14)
+ TimeManagerClockButton:Show()
+ TimeManagerClockButton:SetScript('OnClick', function(self, button)
if(button == 'RightButton') then
ToggleCalendar()
else
@@ -66,213 +55,197 @@ do
ToggleTimeManager()
end
end
- end
+ end)
- function onClickCoord(self, button)
- if(button == 'RightButton') then
- ToggleBattlefieldMinimap()
- else
- ToggleFrame(WorldMapFrame)
- end
- end
-
- function onMouseWheel(self, dir)
- if(dir > 0) then
- MinimapZoomIn:Click()
- else
- MinimapZoomOut:Click()
- end
- end
-end
+ TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton)
+ TimeManagerClockTicker:SetFont(SharedMedia:Fetch('font', self.db.font), self.db.fontsize, self.db.fontflag)
+ TimeManagerClockTicker:SetShadowOffset(0, 0)
+ TimeManagerAlarmFiredTexture.Show = function() TimeManagerClockTicker:SetTextColor(1, 0, 0) end
+ TimeManagerAlarmFiredTexture.Hide = function() TimeManagerClockTicker:SetTextColor(1, 1, 1) end
-local function slashHandler(str)
- if(str == 'reset') then
- pMinimapDB = {}
- print('|cffff8080pMinimap:|r Savedvariables is now reset. You should reload/relog to affect changes.')
- elseif(str == 'refresh') then
- Minimap:SetMaskTexture([=[Interface\ChatFrame\ChatFrameBackground]=])
- print('|cffff8080pMinimap:|r Minimap mask is now refreshed.')
+ self:RegisterEvent('CALENDAR_UPDATE_PENDING_INVITES')
+ self.CALENDAR_UPDATE_PENDING_INVITES()
+end
+--]]
+function addon:OnClick(button)
+ if(button == 'RightButton') then
+ ToggleBattlefieldMinimap()
else
- if(not IsAddOnLoaded('pMinimap_Config')) then
- LoadAddOn('pMinimap_Config')
- end
- InterfaceOptionsFrame_OpenToCategory('pMinimap')
+ ToggleFrame(WorldMapFrame)
end
end
-local function optionsPanel(self)
- if(not IsAddOnLoaded('pMinimap_Config')) then
- LoadAddOn('pMinimap_Config')
- end
- self:SetScript('OnShow', nil)
+function addon:OnUpdate(elapsed)
+ if(total <= 0) then
+ local x, y = GetPlayerMapPosition('player')
+ if(x ~= 0 and y ~= 0) then
+ MinimapCoordinatesText:SetFormattedText('%.' .. addon.db.coordinatesdecimals .. 'f,%.' .. addon.db.coordinatesdecimals .. 'f', x * 100, y * 100)
+ else
+ MinimapCoordinatesText:SetText()
+ end
- InterfaceOptionsDisplayPanelShowClock:Disable()
- InterfaceOptionsDisplayPanelShowClock:Hide()
+ self.total = 0.25
+ else
+ self.total = self.total - elapsed
+ end
end
-local function Initialize(self)
- Minimap:EnableMouseWheel()
- Minimap:SetScript('OnMouseWheel', onMouseWheel)
+function addon:Style()
+ -- Mousewheel zoom
MinimapZoomIn:Hide()
MinimapZoomOut:Hide()
+ Minimap:EnableMouseWheel()
+ Minimap:SetScript('OnMouseWheel', function(self, direction)
+ if(direction > 0) then
+ MinimapZoomIn:Click()
+ else
+ MinimapZoomOut:Click()
+ end
+ end)
- MiniMapTrackingBackground:Hide()
- MiniMapTrackingButton:SetHighlightTexture('')
- MiniMapTrackingButtonBorder:SetTexture('')
- MiniMapTrackingIcon:SetTexCoord(0.065, 0.935, 0.065, 0.935)
- MiniMapTrackingIconOverlay:SetTexture('')
- MiniMapTracking:SetParent(Minimap)
+ -- Tracking icon
MiniMapTracking:ClearAllPoints()
+ MiniMapTracking:SetParent(Minimap)
MiniMapTracking:SetPoint('TOPLEFT', -2, 2)
+ MiniMapTrackingBackground:Hide()
+ MiniMapTrackingButtonBorder:SetTexture(nil)
+ MiniMapTrackingButton:SetHighlightTexture(nil)
+ MiniMapTrackingIconOverlay:SetTexture(nil)
+ MiniMapTrackingIcon:SetTexCoord(0.065, 0.935, 0.065, 0.935)
- BattlegroundShine:Hide()
- MiniMapBattlefieldBorder:SetTexture('')
- MiniMapBattlefieldFrame:SetParent(Minimap)
+ -- Battlefield icon
MiniMapBattlefieldFrame:ClearAllPoints()
+ MiniMapBattlefieldFrame:SetParent(Minimap)
MiniMapBattlefieldFrame:SetPoint('TOPRIGHT', -2, -2)
+ MiniMapBattlefieldBorder:SetTexture(nil)
+ BattlegroundShine:Hide()
- MiniMapMailBorder:SetTexture('')
- MiniMapMailFrame:SetParent(Minimap)
+ -- Mail text
MiniMapMailFrame:ClearAllPoints()
+ MiniMapMailFrame:SetParent(Minimap)
MiniMapMailFrame:SetPoint('TOP', 0, -4)
MiniMapMailFrame:SetHeight(8)
+ MiniMapMailBorder:SetTexture(nil)
MiniMapMailText = MiniMapMailFrame:CreateFontString(nil, 'OVERLAY')
- MiniMapMailText:SetFont(LSM:Fetch('font', self.db.smfont), self.db.fontsize, self.db.fontflag)
MiniMapMailText:SetPoint('BOTTOM', 0, 2)
- MiniMapMailText:SetText('New Mail!')
+ MiniMapMailText:SetFont(SharedMedia:Fetch('font', self.db.font), self.db.fontsize, self.db.fontflag)
MiniMapMailText:SetTextColor(1, 1, 1)
+ MiniMapMailText:SetText('New Mail!')
- MinimapZoneTextButton:SetParent(Minimap)
- MinimapZoneTextButton:ClearAllPoints()
- MinimapZoneTextButton:SetPoint(self.db.zonePoint == 'BOTTOM' and 'TOP' or 'BOTTOM', Minimap, self.db.zonePoint, 0, self.db.zoneOffset)
- MinimapZoneTextButton:SetWidth(Minimap:GetWidth() * 1.5)
+ if(self.db.mail) then
+ MiniMapMailIcon:Hide()
+ else
+ MiniMapMailText:Hide()
+ end
+
+ -- Coordinates
+ MinimapCoordinates = CreateFrame('Button', nil, Minimap)
+ MinimapCoordinates:SetPoint(self.db.clock and 'BOTTOMRIGHT' or 'BOTTOM')
+ MinimapCoordinates:SetWidth(40)
+ MinimapCoordinates:SetHeight(14)
+ MinimapCoordinates:RegisterForClicks('AnyUp')
+ MinimapCoordinates:SetScript('OnClick', self.OnClick)
+ MinimapCoordinates:SetScript('OnUpdate', self.OnUpdate)
+ MinimapCoordinates.total = 0.25
+
+ MinimapCoordinatesText = MinimapCoordinates:CreateFontString(nil, 'OVERLAY')
+ MinimapCoordinatesText:SetPoint('BOTTOMRIGHT', MinimapCoordinates)
+ MinimapCoordinatesText:SetFont(SharedMedia:Fetch('font', self.db.font), self.db.fontsize, self.db.fontflag)
+ MinimapCoordinatesText:SetTextColor(1, 1, 1)
+
+ if(not self.db.coordinates) then
+ MinimapCoordinates:Hide()
+ end
- MinimapZoneText:ClearAllPoints()
+ -- Zone text
MinimapZoneText:SetAllPoints(MinimapZoneTextButton)
- MinimapZoneText:SetFont(LSM:Fetch('font', self.db.smfont), self.db.fontsize, self.db.fontflag)
+ MinimapZoneText:SetFont(SharedMedia:Fetch('font', self.db.font), self.db.fontsize, self.db.fontflag)
MinimapZoneText:SetShadowOffset(0, 0)
- MinimapBorder:SetTexture('')
+ MinimapZoneTextButton:ClearAllPoints()
+ MinimapZoneTextButton:SetParent(Minimap)
+ MinimapZoneTextButton:SetPoint(self.db.zonepoint == 'BOTTOM' and 'TOP' or 'BOTTOM', Minimap, self.db.zonepoint, 0, self.db.zoneoffset)
+ MinimapZoneTextButton:SetWidth(Minimap:GetWidth() * 1.5)
+
+ if(not self.db.zone) then
+ MinimapZoneTextButton:Hide()
+ end
+
+ -- Misc textures/icons/texts
+ MinimapBorder:SetTexture(nil)
MinimapBorderTop:Hide()
MinimapToggleButton:Hide()
-
- GameTimeFrame:Hide()
- MiniMapWorldMapButton:Hide()
- MiniMapMeetingStoneFrame:SetAlpha(0)
- MiniMapVoiceChatFrame:Hide()
- MiniMapVoiceChatFrame.Show = MiniMapVoiceChatFrame.Hide
MinimapNorthTag:SetAlpha(0)
+ MiniMapMeetingStoneFrame:SetAlpha(0)
+ MiniMapWorldMapButton:Hide()
+ GameTimeFrame:Hide()
+ -- Inject settings
Minimap:SetScale(self.db.scale)
Minimap:SetFrameLevel(self.db.level)
Minimap:SetFrameStrata(self.db.strata)
Minimap:SetMaskTexture([=[Interface\ChatFrame\ChatFrameBackground]=])
- Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = - self.db.offset, left = - self.db.offset, bottom = - self.db.offset, right = - self.db.offset}})
- Minimap:SetBackdropColor(unpack(self.db.colors))
+ Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = - self.db.borderoffset, bottom = - self.db.borderoffset, left = - self.db.borderoffset, right = - self.db.borderoffset}})
+ Minimap:SetBackdropColor(unpack(self.db.bordercolors))
- MinimapCluster:EnableMouse(false)
- Minimap:SetMovable(true)
Minimap:RegisterForDrag('LeftButton')
- Minimap:SetScript('OnDragStop', function() if(pMinimapDB.unlocked) then Minimap:StopMovingOrSizing() end end)
- Minimap:SetScript('OnDragStart', function() if(pMinimapDB.unlocked) then Minimap:StartMoving() end end)
-
- if(not self.db.zone) then
- MinimapZoneTextButton:Hide()
- end
+ Minimap:SetMovable(true)
+ Minimap:SetScript('OnDragStop', function() if(self.unlocked) then Minimap:StopMovingOrSizing() end end)
+ Minimap:SetScript('OnDragStart', function() if(self.unlocked) then Minimap:StartMoving() end end)
+ MinimapCluster:EnableMouse(false)
- if(self.db.dura) then
+ -- Modules
+ if(self.db.durability) then
DurabilityFrame:SetAlpha(0)
self:RegisterEvent('UPDATE_INVENTORY_ALERTS')
self.UPDATE_INVENTORY_ALERTS()
end
- if(self.db.coords) then
- self:CreateCoords()
+ if(self.db.coordinates) then
+ self:Coordinates()
end
-
+--[[
if(self.db.clock) then
- self:CreateClock()
+ self:Clock()
else
TimeManagerClockButton:Hide()
- end
+ end --]]
+end
- if(self.db.mail) then
- MiniMapMailIcon:Hide()
+function addon.Command(str)
+ if(str == 'reset') then
+ addon.db = {}
+ print('|cffff8080pMinimap:|r Settings reset. You should reload/relog to affect changes.')
else
- MiniMapMailText:Hide()
+ InterfaceOptionsFrame_OpenToCategory(addon:GetName())
end
end
+function addon:ADDON_LOADED(event, name)
+ if(name ~= self:GetName()) then return end
-function pMinimap:CreateClock()
- TimeManager_LoadUI()
+ SharedMedia:Register('font', 'Visitor TT1', [=[Interface\AddOns\pMinimap\media\font.ttf]=])
- TimeManagerClockButton:SetWidth(40)
- TimeManagerClockButton:SetHeight(14)
- TimeManagerClockButton:ClearAllPoints()
- TimeManagerClockButton:SetPoint(self.db.coords and 'BOTTOMLEFT' or 'BOTTOM', Minimap)
- TimeManagerClockButton:GetRegions():Hide()
- TimeManagerClockButton:Show()
- TimeManagerClockButton:SetScript('OnClick', onClickClock)
-
- TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton)
- TimeManagerClockTicker:SetFont(LSM:Fetch('font', self.db.smfont), self.db.fontsize, self.db.fontflag)
- TimeManagerClockTicker:SetShadowOffset(0, 0)
-
- TimeManagerAlarmFiredTexture.Show = function() TimeManagerClockTicker:SetTextColor(1, 0, 0) end
- TimeManagerAlarmFiredTexture.Hide = function() TimeManagerClockTicker:SetTextColor(1, 1, 1) end
-
- self:RegisterEvent('CALENDAR_UPDATE_PENDING_INVITES')
- self.CALENDAR_UPDATE_PENDING_INVITES()
-
- self.RunClock = true
-end
-
-function pMinimap:CreateCoords()
- self.Coord = CreateFrame('Button', nil, Minimap)
- self.Coord:SetPoint(self.db.clock and 'BOTTOMRIGHT' or 'BOTTOM', Minimap)
- self.Coord:SetWidth(40)
- self.Coord:SetHeight(14)
- self.Coord:RegisterForClicks('AnyUp')
-
- self.Coord.Text = self.Coord:CreateFontString(nil, 'OVERLAY')
- self.Coord.Text:SetPoint('BOTTOMRIGHT', self.Coord)
- self.Coord.Text:SetFont(LSM:Fetch('font', self.db.smfont), self.db.fontsize, self.db.fontflag)
- self.Coord.Text:SetTextColor(1, 1, 1)
+ SLASH_pMinimap1 = '/pmm'
+ SLASH_pMinimap2 = '/pminimap'
+ SlashCmdList[name] = self.Command
- self.Coord:SetScript('OnClick', onClickCoord)
- self.Coord:SetScript('OnUpdate', onUpdate)
-
- self:RegisterEvent('ZONE_CHANGED_NEW_AREA')
-end
-
-
-function pMinimap:ADDON_LOADED(event, addon)
- if(addon ~= 'pMinimap') then return end
-
- CreateFrame('Frame', nil, InterfaceOptionsFrame):SetScript('OnShow', optionsPanel)
- LSM:Register('font', 'Visitor TT1', [=[Interface\AddOns\pMinimap\font.ttf]=])
-
- SLASH_PMINIMAP1 = '/pmm'
- SLASH_PMINIMAP2 = '/pminimap'
- SlashCmdList.PMINIMAP = slashHandler
-
- pMinimapDB = setmetatable(pMinimapDB or {}, {__index = defaults})
- pMinimapDB.unlocked = false
-
- self.db = pMinimapDB
+ self.db = setmetatable(pMinimapDB or {}, {__index = defaults})
self:UnregisterEvent(event)
+ self:RegisterEvent('ZONE_CHANGED_NEW_AREA')
+-- self:RegisterEvent('PLAYER_LOGOUT')
- InterfaceOptionsDisplayPanelShowClock.setFunc('1')
- InterfaceOptionsDisplayPanelShowClock.setFunc = function() end
-
- Initialize(self)
+ self:Style()
end
-function pMinimap:CALENDAR_UPDATE_PENDING_INVITES()
+--function addon:PLAYER_LOGOUT()
+-- pMinimapDB = self.db
+--end
+
+function addon:CALENDAR_UPDATE_PENDING_INVITES()
if(CalendarGetNumPendingInvites() ~= 0) then
TimeManagerClockTicker:SetTextColor(0, 1, 0)
else
@@ -280,27 +253,24 @@ function pMinimap:CALENDAR_UPDATE_PENDING_INVITES()
end
end
-function pMinimap:ZONE_CHANGED_NEW_AREA()
- SetMapToCurrentZone()
-end
-
-function pMinimap:UPDATE_INVENTORY_ALERTS()
+function addon:UPDATE_INVENTORY_ALERTS()
local highstatus = 0
- for i in next, INVENTORY_ALERT_STATUS_SLOTS do
- local status = GetInventoryAlertStatus(i)
- if(status > highstatus) then
- highstatus = status
- end
+ for index = 1, #INVENTORY_ALERT_STATUS_SLOTS do
+ local status = GetInventoryAlertStatus(INVENTORY_ALERT_STATUS_SLOTS[index])
+ highstatus = status > highstatus and status
end
local color = INVENTORY_ALERT_COLORS[highstatus]
if(color) then
Minimap:SetBackdropColor(color.r, color.g, color.b)
else
- Minimap:SetBackdropColor(unpack(pMinimapDB.colors))
+ Minimap:SetBackdropColor(unpack(self.db.bordercolors))
end
end
+function addon:ZONE_CHANGED_NEW_AREA()
+ SetMapToCurrentZone()
+end
-- http://www.wowwiki.com/GetMinimapShape
-function GetMinimapShape() return 'SQUARE' end
\ No newline at end of file
+function GetMinimapShape() return 'SQUARE' end