changeset 37:78a07841e004 Prospect Me 2

Updated Configuration for V2
author Vynn <mischivin@gmail.com>
date Thu, 10 Nov 2016 12:26:27 -0500
parents 5cbaaee1e7db
children 69c7955b75b1
files ProspectMe_Config.lua
diffstat 1 files changed, 26 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/ProspectMe_Config.lua	Thu Nov 10 12:26:14 2016 -0500
+++ b/ProspectMe_Config.lua	Thu Nov 10 12:26:27 2016 -0500
@@ -1,10 +1,5 @@
-if not PM_Config then
-	PM_Config = {}
-end
-
 local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer)
 local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge")
-local ResultsToggle = CreateFrame( "CheckButton", "ProspectMeResultsToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" )
 local EpicToggle = CreateFrame( "CheckButton", "ProspectMeEpicToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" )
 local RareToggle = CreateFrame( "CheckButton", "ProspectMeRareToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" )
 local UncommonToggle = CreateFrame( "CheckButton", "ProspectMeUncommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" )
@@ -16,22 +11,12 @@
 local ResetResults = CreateFrame( "Button", "ProspectMeResetButton", ProspectMeFrame, "UIPanelButtonTemplate" )
 local ResetText = PM_ConfigFrame:CreateFontString( "ProspectMeResetText", nil, "GameFontNormal" )
 
-local function SetDefaults()
-	PM_Config.results = true
-	PM_Config.qualities ={[0] = false,[1] = true, [2] = true, [3] = true, [4] = true}
-	PM_Config.session = false
-	PM_Config.percent = true
-	PM_Config.number = true
-	PM_Config.savedVariables = true
-end
-
 local function SpewMessage(handle, msg)
 	if handle == "loaded" then
 		print(PM_LOADMSG)
 	elseif handle == "help" then
 		print(PM_HELPMSG)
 		SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP)
-		SpewMessage(PM_RESULTS, PM_RESULTSTOOLTIP)
 		SpewMessage(PM_EPIC, PM_EPICTOOLTIP)
 		SpewMessage(PM_RARE, PM_RARETOOLTIP)
 		SpewMessage(PM_UNCOMMON, PM_UNCOMMONTOOLTIP)
@@ -46,62 +31,21 @@
 	end
 end
 
-local function ClearEntry(id)
-	if PM_ResultsTable[id] then
-		wipe(PM_ResultsTable[id])
-	end
-	if PM_SessionTable[id] then
-		wipe(PM_SessionTable[id])
-	end
-end
-
 local function ResetDatabase()
-	if PM_ResultsTable then
-		for i, v in pairs(PM_ResultsTable) do
-			ClearEntry(i)
-		end
-		wipe(PM_ResultsTable)
-	end
-	if PM_SessionTable then
-		wipe(PM_SessionTable)
+	if ProspectMe.Results then
+		ProspectMe.Results = {}
 	end
 end
 
 local function UpdateConfig()
-	
-	PM_Config.results = ProspectMeResultsToggle:GetChecked()
-	PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked()
-	PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked()
-	PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked()
-	PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked()
-	PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked()
-	PM_Config.session = ProspectMeSessionToggle:GetChecked()
-	PM_Config.percent = ProspectMePercentToggle:GetChecked()
-	PM_Config.number = ProspectMeNumberToggle:GetChecked()
-		
-	if (PM_Config.results) then
-		
-		ProspectMePoorToggle:Enable()
-		ProspectMeCommonToggle:Enable()
-		ProspectMeUncommonToggle:Enable()
-		ProspectMeRareToggle:Enable()
-		ProspectMeEpicToggle:Enable()
-
-		PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked()
-		PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked()
-		PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked()
-		PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked()
-		PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked()
-	
-	else
-	
-		ProspectMePoorToggle:Disable()
-		ProspectMeCommonToggle:Disable()
-		ProspectMeUncommonToggle:Disable()
-		ProspectMeRareToggle:Disable()
-		ProspectMeEpicToggle:Disable()
-		
-	end
+	ProspectMe.Config.ShowQualities.Junk = ProspectMePoorToggle:GetChecked()
+	ProspectMe.Config.ShowQualities.Common = ProspectMeCommonToggle:GetChecked()
+	ProspectMe.Config.ShowQualities.Uncommon = ProspectMeUncommonToggle:GetChecked()
+	ProspectMe.Config.ShowQualities.Rare = ProspectMeRareToggle:GetChecked()
+	ProspectMe.Config.ShowQualities.Epic = ProspectMeEpicToggle:GetChecked()
+	ProspectMe.Config.PerSession = ProspectMeSessionToggle:GetChecked()
+	ProspectMe.Config.ShowPercent = ProspectMePercentToggle:GetChecked()
+	ProspectMe.Config.ShowNumber = ProspectMeNumberToggle:GetChecked()
 end
 
 local function PM_ConfigInit()
@@ -125,65 +69,51 @@
    	
 	ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 )
 	ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeSessionToggle:SetChecked(PM_Config.session)
+	ProspectMeSessionToggle:SetChecked(ProspectMe.Config.PerSession)
 	ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE)
 	ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP
 	
 	ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 )
 	ProspectMePercentToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMePercentToggle:SetChecked(PM_Config.percent)
+	ProspectMePercentToggle:SetChecked(ProspectMe.Config.ShowPercent)
 	ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE)
 	ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP
   
 	ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 )
 	ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeNumberToggle:SetChecked(PM_Config.number)
+	ProspectMeNumberToggle:SetChecked(ProspectMe.Config.ShowNumber)
 	ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE)
 	ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP
-	
-	ProspectMeResultsToggle:SetPoint( "TOPLEFT", 32, -118 )
-	ProspectMeResultsToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeResultsToggle:SetChecked(PM_Config.results)
-	ProspectMeResultsToggleText:SetText(PM_RESULTSTOGGLE)
-	ProspectMeResultsToggle.tooltipText = PM_RESULTSTOOLTIP
 
-	ProspectMeEpicToggle:SetPoint( "TOPLEFT", 60, -142 )
+	ProspectMeEpicToggle:SetPoint( "TOPLEFT", 32, -118 )
 	ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeEpicToggle:SetChecked(PM_Config.qualities[4])
+	ProspectMeEpicToggle:SetChecked(ProspectMe.Config.ShowQualities.Epic)
 	ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE)
 	ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP
 	
-	ProspectMeRareToggle:SetPoint( "TOPLEFT", 60, -166 )
+	ProspectMeRareToggle:SetPoint( "TOPLEFT", 32, -142 )
 	ProspectMeRareToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeRareToggle:SetChecked(PM_Config.qualities[3])
+	ProspectMeRareToggle:SetChecked(ProspectMe.Config.ShowQualities.Rare)
 	ProspectMeRareToggleText:SetText(PM_RARETOGGLE)
 	ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP
 		
-	ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 60, -190 )
+	ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 32, -166 )
 	ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeUncommonToggle:SetChecked(PM_Config.qualities[2])
+	ProspectMeUncommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Uncommon)
 	ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE)
 	ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP
 	
-	ProspectMeCommonToggle:SetPoint( "TOPLEFT", 60, -214 )
+	ProspectMeCommonToggle:SetPoint( "TOPLEFT", 32, -190 )
 	ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMeCommonToggle:SetChecked(PM_Config.qualities[1])
+	ProspectMeCommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Common)
 	ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE)
 	ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP
 	
-	ProspectMePoorToggle:SetPoint( "TOPLEFT", 60, -238 )
+	ProspectMePoorToggle:SetPoint( "TOPLEFT", 32, -214 )
 	ProspectMePoorToggle:SetScript("OnClick", UpdateConfig)
-	ProspectMePoorToggle:SetChecked(PM_Config.qualities[0])
+	ProspectMePoorToggle:SetChecked(ProspectMe.Config.ShowQualities.Poor)
 	ProspectMePoorToggleText:SetText(PM_POORTOGGLE)
 	ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP
-	
-	if (PM_Config.results == false) then
-		ProspectMePoorToggle:Disable()
-		ProspectMeCommonToggle:Disable()
-		ProspectMeUncommonToggle:Disable()
-		ProspectMeRareToggle:Disable()
-		ProspectMeEpicToggle:Disable()
-	end
 
 	ProspectMeResetButton:SetPoint("TOP", 0, -310 )
 	ProspectMeResetButton:SetScript("OnClick", 	function(self) StaticPopup_Show("PM_ConfirmReset") end)
@@ -197,11 +127,8 @@
 
 end
 
-function ProspectMeEventHandler(event, arg1)
-	if (PM_Config.savedVariables) then
-		PM_ConfigInit()
-	else
-		SetDefaults()
+local function EventHandler(event, arg1)
+	if (ProspectMe.Config) then
 		PM_ConfigInit()
 	end
 	SpewMessage("loaded")
@@ -245,4 +172,4 @@
 end
 
 ProspectMeFrame:RegisterEvent("VARIABLES_LOADED")
-ProspectMeFrame:SetScript("OnEvent", ProspectMeEventHandler)
\ No newline at end of file
+ProspectMeFrame:SetScript("OnEvent", EventHandler)
\ No newline at end of file