Quantcast

Fixed savedvariables

p3lim-52096 [10-20-08 - 15:28]
Fixed savedvariables
Fixed config

git-svn-id: svn://svn.wowinterface.com/pMinimap-54/trunk@33 ae24c21f-2f0c-4c94-9256-0092abe71e0d
Filename
pMinimap/pMinimap.lua
pMinimap_Clock/pMinimap_Clock.lua
pMinimap_Clock/pMinimap_Clock.toc
pMinimap_Config/pMinimap_Config.lua
pMinimap_Config/pMinimap_Config.toc
pMinimap_Durability/pMinimap_Durability.toc
diff --git a/pMinimap/pMinimap.lua b/pMinimap/pMinimap.lua
index b74ac14..f68d284 100644
--- a/pMinimap/pMinimap.lua
+++ b/pMinimap/pMinimap.lua
@@ -4,7 +4,7 @@ pMinimap:RegisterEvent('ADDON_LOADED')

 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}
+	local db = pMinimapDB or {point = {'TOPRIGHT', 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0, 1}, durability = true, coords = false, clock = true}

 	MinimapBorder:SetTexture()
 	MinimapBorderTop:Hide()
@@ -58,7 +58,7 @@ function pMinimap.ADDON_LOADED(self, event, name)
 	MiniMapMeetingStoneFrame:SetAlpha(0)
 	MinimapNorthTag:SetAlpha(0)

-	self:SetPoint(unpack(db.point))
+	self:SetPoint(db.point[1], UIParent, db.point[2], db.point[3], db.point[4])
 	self:SetWidth(Minimap:GetWidth() * db.scale)
 	self:SetHeight(Minimap:GetHeight() * db.scale)
 	self:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=]})
@@ -88,13 +88,15 @@ function pMinimap.ADDON_LOADED(self, event, name)
 		end
 	end

-	if(GetCVar('showClock') == '1') then
+	if(db.clock) then
 		if(not IsAddOnLoaded('pMinimap_Clock')) then
 			LoadAddOn('pMinimap_Clock')
 		end
 	end

 	self:UnregisterEvent(event)
+
+	pMinimapDB = db
 end

 SlashCmdList['PMMC'] = function()
diff --git a/pMinimap_Clock/pMinimap_Clock.lua b/pMinimap_Clock/pMinimap_Clock.lua
index 075ad84..ccc961f 100644
--- a/pMinimap_Clock/pMinimap_Clock.lua
+++ b/pMinimap_Clock/pMinimap_Clock.lua
@@ -1 +1 @@
-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
+local db = _G.pMinimapDB or {point = {'TOPRIGHT', UIParent, 'TOPRIGHT', -15, -15}, scale = 0.9, offset = 1, colors = {0, 0, 0}, durability = true, coords = false, clock = true}

for _, check in pairs{InterfaceOptionsDisplayPanelShowClock} do
	check:Disable()
	check.Enable = function() end
end

if(not IsAddOnLoaded('Blizzard_TimeManager')) then
	LoadAddOn('Blizzard_TimeManager')
end

SetCVar('showClock', '1', 'SHOW_CLOCK')
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 cbab408..d490a12 100644
--- a/pMinimap_Clock/pMinimap_Clock.toc
+++ b/pMinimap_Clock/pMinimap_Clock.toc
@@ -3,7 +3,6 @@
 ## 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 e15e870..3921576 100644
--- a/pMinimap_Config/pMinimap_Config.lua
+++ b/pMinimap_Config/pMinimap_Config.lua
@@ -1 +1 @@
-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
+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
diff --git a/pMinimap_Config/pMinimap_Config.toc b/pMinimap_Config/pMinimap_Config.toc
index a2de320..fb29d10 100644
--- a/pMinimap_Config/pMinimap_Config.toc
+++ b/pMinimap_Config/pMinimap_Config.toc
@@ -3,7 +3,6 @@
 ## Version: 30000.wowi:revision
 ## Title: |cffff6000p|rMinimap_Config
 ## Notes: Options module for pMinimap
-## SavedVariablesPerCharacter: pMinimapDB
 ## RequiredDeps: pMinimap
 ## LoadOnDemand: 1

diff --git a/pMinimap_Durability/pMinimap_Durability.toc b/pMinimap_Durability/pMinimap_Durability.toc
index 56ee6f0..ad235dc 100644
--- a/pMinimap_Durability/pMinimap_Durability.toc
+++ b/pMinimap_Durability/pMinimap_Durability.toc
@@ -3,7 +3,6 @@
 ## Version: 30000.wowi:revision
 ## Title: |cffff6000p|rMinimap_Durability
 ## Notes: Durability module for pMinimap
-## SavedVariablesPerCharacter: pMinimapDB
 ## RequiredDeps: pMinimap
 ## LoadOnDemand: 1