Quantcast

Added more options

p3lim-52096 [10-24-08 - 14:58]
Added more options

git-svn-id: svn://svn.wowinterface.com/pMinimap-54/trunk@40 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 9c156f4..39a8b32 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')
				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
+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', 'Backdrop color',
		'description', 'Click to set a 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)

	self:MakeSlider(
		'name', 'Font size',
		'description', 'Set the font size by dragging the slider',
		'default', 13,
		'minText', '5', 'maxText', '35',
		'minValue', 5, 'maxValue', 35,
		'step', 1,
		'current', db.fontsize,
		'setFunc', function(x)
			pMinimapDB.fontsize = x
			MiniMapMailText:SetFont(db.font, x, db.fontflag == 'NONE' and nil or db.fontflag)
			if(db.clock) then
				TimeManagerClockTicker:SetFont(db.font, x, db.fontflag == 'NONE' and nil or db.fontflag)
			end
			if(db.coords) then
				MiniMapCoordText:SetFont(db.font, x, db.fontflag == 'NONE' and nil or db.fontflag)
			end
		end,
		'currentTextFunc', function(num) return num end
	):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -290)

	self:MakeDropDown(
		'name', 'Font flag',
		'description', 'Set the font flag from a dropdown',
		'values', {'OUTLINE', 'Outline', 'THICKOUTLINE', 'Thick Outline', 'MONOCHROME', 'Monochrome', 'NONE', 'None'},
		'default', 'OUTLINE',
		'current', db.fontflag,
		'setFunc', function(x)
			pMinimapDB.fontflag = x
			MiniMapMailText:SetFont(db.font, db.fontsize, x == 'NONE' and nil or x)
			if(db.clock) then
				TimeManagerClockTicker:SetFont(db.font, db.fontsize, x == 'NONE' and nil or x)
			end
			if(db.coords) then
				MiniMapCoordText:SetFont(db.font, db.fontsize, x == 'NONE' and nil or x)
			end
		end
	):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 160, -290)

	self:MakeSlider(
		'name', 'Frame level',
		'description', 'Set your Minimap\'s frame level in this slider',
		'default', 2,
		'minText', '1', 'maxText', '15',
		'minValue', 1, 'maxValue', 15,
		'step', 1,
		'current', db.level,
		'setFunc', function(x)
			pMinimapDB.level = x
			Minimap:SetFrameLevel(x)
		end,
		'currentTextFunc', function(num) return num end
	):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 0, -340)

	self:MakeDropDown(
		'name', 'Frame strata',
		'description', 'Set your Minimap\'s frame strata in this dropdown',
		'values', {'DIALOG', 'Dialog', 'HIGH', 'High', 'MEDIUM', 'Medium', 'LOW', 'Low', 'BACKGROUND', 'Background'},
		'default', 'BACKGROUND',
		'current', db.strata,
		'setFunc', function(x)
			pMinimapDB.strata = x
			Minimap:SetFrameStrata(db.strata)
		end
	):SetPoint('TOPLEFT', sub, 'BOTTOMLEFT', 160, -340)
end)
\ No newline at end of file