Quantcast

Fixed the clock

Adrian L Lange [08-08-09 - 23:38]
Fixed the clock
Filename
Config.lua
pMinimap.lua
diff --git a/Config.lua b/Config.lua
index 66c6735..5c4f9f3 100644
--- a/Config.lua
+++ b/Config.lua
@@ -130,6 +130,11 @@ addon:SetScript('OnShow', function(self)
 		else
 			MinimapCoordinates:Hide()
 		end
+
+		if(pMinimap.db.clock) then
+			TimeManagerClockButton:ClearAllPoints()
+			TimeManagerClockButton:SetPoint(pMinimap.db.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap)
+		end
 	end)

 	local coordinatesdecimals, cdtext = slider.new(self, 'Coord Decimals: '..pMinimap.db.coordinatesdecimals, 0, 3, 'TOPRIGHT', group2, -15, -15)
@@ -140,9 +145,28 @@ addon:SetScript('OnShow', function(self)
 		cdtext:SetFormattedText('Coord Decimals: %d', value)
 	end)

-	local clock = checkbox.new(self, 22, 'Clock (Disabled)', 'TOPLEFT', coordinates, 'BOTTOMLEFT', 0, -10)
+	local clock = checkbox.new(self, 22, 'Clock', 'TOPLEFT', coordinates, 'BOTTOMLEFT', 0, -10)
 	clock:SetChecked(pMinimap.db.clock)
-	clock:Disable()
+	clock:SetScript('OnClick', function()
+		pMinimap.db.clock = not pMinimap.db.clock
+
+		if(pMinimap.db.clock) then
+			if(not pMinimap:IsEventRegistered('CALENDAR_UPDATE_PENDING_INVITES')) then
+				pMinimap:Clock()
+			else
+				TimeManagerClockButton:ClearAllPoints()
+				TimeManagerClockButton:SetPoint(pMinimap.db.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap)
+				TimeManagerClockButton:Show()
+			end
+		else
+			TimeManagerClockButton:Hide()
+		end
+
+		if(pMinimap.db.coordinates) then
+			MinimapCoordinates:ClearAllPoints()
+			MinimapCoordinates:SetPoint(pMinimap.db.clock and 'BOTTOMRIGHT' or 'BOTTOM')
+		end
+	end)

 	local mail = checkbox.new(self, 22, 'Mail', 'TOPLEFT', clock, 'BOTTOMLEFT', 0, -10)
 	mail:SetChecked(pMinimap.db.mail)
diff --git a/pMinimap.lua b/pMinimap.lua
index b4dd655..ff45516 100644
--- a/pMinimap.lua
+++ b/pMinimap.lua
@@ -32,17 +32,14 @@ local defaults = {
 	coordinates = false,
 	coordinatesdecimals = 0,
 }
---[[
-function addon:Clock()
-	if(not IsAddOnLoaded('Blizzard_TimeManager')) then
-		LoadAddOn('Blizzard_TimeManager')
-	end

+function addon:Clock()
 	TimeManagerClockButton:GetRegions():Hide()
 	TimeManagerClockButton:ClearAllPoints()
 	TimeManagerClockButton:SetPoint(self.db.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap)
 	TimeManagerClockButton:SetWidth(40)
 	TimeManagerClockButton:SetHeight(14)
+	TimeManagerClockButton:SetScript('OnShow', nil)
 	TimeManagerClockButton:Show()
 	TimeManagerClockButton:SetScript('OnClick', function(self, button)
 		if(button == 'RightButton') then
@@ -67,7 +64,7 @@ function addon:Clock()
 	self:RegisterEvent('CALENDAR_UPDATE_PENDING_INVITES')
 	self.CALENDAR_UPDATE_PENDING_INVITES()
 end
---]]
+
 function addon:OnClick(button)
 	if(button == 'RightButton') then
 		ToggleBattlefieldMinimap()
@@ -203,12 +200,6 @@ function addon:Style()
 		self:RegisterEvent('UPDATE_INVENTORY_ALERTS')
 		self:UPDATE_INVENTORY_ALERTS()
 	end
---[[
-	if(self.db.clock) then
-		self:Clock()
-	else
-		TimeManagerClockButton:Hide()
-	end --]]
 end

 function addon.Command(str)
@@ -221,20 +212,36 @@ function addon.Command(str)
 end

 function addon:ADDON_LOADED(event, name)
-	if(name ~= self:GetName()) then return end
-
-	SharedMedia:Register('font', 'Visitor TT1', [=[Interface\AddOns\pMinimap\media\font.ttf]=])
+	if(name == self:GetName()) then
+		SharedMedia:Register('font', 'Visitor TT1', [=[Interface\AddOns\pMinimap\media\font.ttf]=])
+
+		SLASH_pMinimap1 = '/pmm'
+		SLASH_pMinimap2 = '/pminimap'
+		SlashCmdList[name] = self.Command
+
+		self.unlocked = false
+		self.db = setmetatable(pMinimapDB or {}, {__index = defaults})
+		self:RegisterEvent('ZONE_CHANGED_NEW_AREA')
+		self:RegisterEvent('VARIABLES_LOADED')
+
+		self:Style()
+	elseif(name == 'Blizzard_TimeManager') then
+--		orig = TimeManagerClockButton:GetScript('OnShow')
+		TimeManagerClockButton:SetScript('OnShow', function(self) self:Hide() end)
+		TimeManagerClockButton:Hide()

-	SLASH_pMinimap1 = '/pmm'
-	SLASH_pMinimap2 = '/pminimap'
-	SlashCmdList[name] = self.Command
+		if(self.db.clock) then
+			self:Clock()
+		end

-	self.unlocked = false
-	self.db = setmetatable(pMinimapDB or {}, {__index = defaults})
-	self:UnregisterEvent(event)
-	self:RegisterEvent('ZONE_CHANGED_NEW_AREA')
+		for k, v in next, {InterfaceOptionsDisplayPanelShowClock} do
+			v:SetButtonState('DISABLED', true)
+		end
+	end
+end

-	self:Style()
+function addon:VARIABLES_LOADED(event)
+	SetCVar('showClock', '1')
 end

 function addon:CALENDAR_UPDATE_PENDING_INVITES()