Quantcast

Fixed the clock through a hack

p3lim-52096 [10-20-08 - 20:14]
Fixed the clock through a hack

git-svn-id: svn://svn.wowinterface.com/pMinimap-54/trunk@36 ae24c21f-2f0c-4c94-9256-0092abe71e0d
Filename
pMinimap_Config/pMinimap_Config.lua
diff --git a/pMinimap_Config/pMinimap_Config.lua b/pMinimap_Config/pMinimap_Config.lua
index 3921576..9c156f4 100644
--- a/pMinimap_Config/pMinimap_Config.lua
+++ b/pMinimap_Config/pMinimap_Config.lua
@@ -1 +1 @@
-local db = pMinimapDB

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()
				pMinimapDB.point[1] = p
				pMinimapDB.point[2] = r
				pMinimapDB.point[3] = x
				pMinimapDB.point[4] = 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)
			pMinimapDB.scale = x
			pMinimap:SetWidth(Minimap:GetWidth() * x)
			pMinimap:SetHeight(Minimap:GetHeight() * x)
			Minimap:SetScale(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', db.clock,
		'setFunc', function(x)
			pMinimapDB.clock = 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(db.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(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)
			pMinimapDB.coords = x
			if(x) then
				if(not IsAddOnLoaded('pMinimap_Coords')) then
					LoadAddOn('pMinimap_Coords')
				end
				MiniMapCoords:Show()
				MiniMapCoords:ClearAllPoints()
				if(db.clock) then
					TimeManagerClockButton:ClearAllPoints()
					TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap)
					MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap)
				else
					MiniMapCoords:SetPoint('BOTTOM', Minimap)
				end
			else
				MiniMapCoords:Hide()
				if(db.clock) 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', db.durability,
		'setFunc', function(x)
			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(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)
			pMinimapDB.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(pMinimapDB.colors) end,
		'setFunc', function(r, g, b, a)
			pMinimapDB.colors[1] = r
			pMinimapDB.colors[2] = g
			pMinimapDB.colors[3] = b
			pMinimapDB.colors[4] = a
			Minimap:SetBackdropColor(unpack(db.colors))
		end
	):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -156)
end)
\ No newline at end of file
+local db = pMinimapDB

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()
				pMinimapDB.point[1] = p
				pMinimapDB.point[2] = r
				pMinimapDB.point[3] = x
				pMinimapDB.point[4] = 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)
			pMinimapDB.scale = x
			pMinimap:SetWidth(Minimap:GetWidth() * x)
			pMinimap:SetHeight(Minimap:GetHeight() * x)
			Minimap:SetScale(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', db.clock,
		'setFunc', function(x)
			pMinimapDB.clock = x
			if(x) then
				if(not IsAddOnLoaded('pMinimap_Clock')) then
					LoadAddOn('pMinimap_Clock')
				end
				SetCVar('showClock', '1', 'SHOW_CLOCK')
				pMinimapToggleClock('1')
				TimeManagerClockButton:ClearAllPoints()
				if(db.coords) then
					MiniMapCoords:ClearAllPoints()
					MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap)
					TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap)
				else
					TimeManagerClockButton:SetPoint('BOTTOM', Minimap)
				end
			else
				pMinimapToggleClock('0')
				SetCVar('showClock', '0', 'SHOW_CLOCK')
				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)
			pMinimapDB.coords = x
			if(x) then
				if(not IsAddOnLoaded('pMinimap_Coords')) then
					LoadAddOn('pMinimap_Coords')
				end
				MiniMapCoords:Show()
				MiniMapCoords:ClearAllPoints()
				if(db.clock) then
					TimeManagerClockButton:ClearAllPoints()
					TimeManagerClockButton:SetPoint('BOTTOMLEFT', Minimap)
					MiniMapCoords:SetPoint('BOTTOMRIGHT', Minimap)
				else
					MiniMapCoords:SetPoint('BOTTOM', Minimap)
				end
			else
				MiniMapCoords:Hide()
				if(db.clock) 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', db.durability,
		'setFunc', function(x)
			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(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)
			pMinimapDB.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(pMinimapDB.colors) end,
		'setFunc', function(r, g, b, a)
			pMinimapDB.colors[1] = r
			pMinimapDB.colors[2] = g
			pMinimapDB.colors[3] = b
			pMinimapDB.colors[4] = a
			Minimap:SetBackdropColor(unpack(db.colors))
		end
	):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -156)
end)
\ No newline at end of file