Quantcast

http://wowprogramming.com/docs/widgets/CheckButton changed to 'true'/'false' instead of nil/1

Alex Shubert [10-14-14 - 21:01]
http://wowprogramming.com/docs/widgets/CheckButton  changed to 'true'/'false' instead of nil/1
Filename
AutoTurnIn.lua
ui/main_options.lua
ui/reward_options.lua
diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index 5bea4ea..b90e3b5 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -13,6 +13,7 @@ local Q_ALL, Q_DAILY, Q_EXCEPTDAILY = 1, 2, 3


 AutoTurnIn = LibStub("AceAddon-3.0"):NewAddon("AutoTurnIn", "AceEvent-3.0", "AceConsole-3.0")
+AutoTurnIn.TOC = select(4, GetBuildInfo())
 AutoTurnIn.defaults = {enabled = true, all = 2, trivial = false, completeonly = false,
                        lootreward = 1, tournament = 2,
 					   darkmoonteleport=true, todarkmoon=true, togglekey=4, darkmoonautostart=true, showrewardtext=true,
@@ -92,7 +93,7 @@ function AutoTurnIn:OnEnable()

 	self:SetEnabled(DB.enabled)
 	self:RegisterGossipEvents()
-	if select(4, GetBuildInfo()) < 60000 then
+	if self.TOC < 60000 then
 		hooksecurefunc("QuestLog_Update", AutoTurnIn.ShowQuestLevelInLog)
 		hooksecurefunc(QuestLogScrollFrame, "update", AutoTurnIn.ShowQuestLevelInLog)
 		hooksecurefunc("WatchFrame_Update", AutoTurnIn.ShowQuestLevelInWatchFrame)
diff --git a/ui/main_options.lua b/ui/main_options.lua
index 5119f37..d6eb2ab 100644
--- a/ui/main_options.lua
+++ b/ui/main_options.lua
@@ -30,7 +30,11 @@ local function newCheckbox(name, caption, config)
     local cb = CreateFrame("CheckButton", "$parent"..name, OptionsPanel, "OptionsCheckButtonTemplate")
     _G[cb:GetName().."Text"]:SetText(caption and caption or name)
     cb:SetScript("OnClick", function(self)
-        ptable.TempConfig[config] = self:GetChecked() == 1
+		if (AutoTurnIn.TOC < 60000) then
+			ptable.TempConfig[config] = (self:GetChecked() == 1)
+		else
+			ptable.TempConfig[config] = self:GetChecked()
+		end
     end)
     return cb
 end
@@ -121,7 +125,6 @@ OptionsPanel.refresh = function()
 	if ( MakeACopy ) then
 		ptable.TempConfig = CopyTable(AutoTurnInCharacterDB)
 	end
-
 	Enable:SetChecked(ptable.TempConfig.enabled)

 	UIDropDownMenu_SetSelectedID(QuestDropDown, ptable.TempConfig.all)
@@ -156,8 +159,10 @@ end
 OptionsPanel.okay = function()
 	AutoTurnInCharacterDB = CopyTable(ptable.TempConfig)
 	AutoTurnIn:SetEnabled(AutoTurnInCharacterDB.enabled)
-	QuestLog_Update()
-	WatchFrame_Update(WatchFrame)
+	if AutoTurnIn.TOC < 60000 then
+		QuestLog_Update()
+		WatchFrame_Update(WatchFrame)
+	end
 end

 InterfaceOptions_AddCategory(OptionsPanel)
\ No newline at end of file
diff --git a/ui/reward_options.lua b/ui/reward_options.lua
index cf36874..00bfd12 100644
--- a/ui/reward_options.lua
+++ b/ui/reward_options.lua
@@ -11,7 +11,11 @@ local function CreateCheckbox(name, parent, marginx, marginy, text)
 	cb:SetPoint("TOPLEFT", parent, marginx, marginy)
 	_G[cb:GetName().."Text"]:SetText(text and text or name)
 	cb:SetScript("OnClick", function(self)
-		parent.GetConfig()[name] = self:GetChecked() == 1 and true or nil
+		if (AutoTurnIn.TOC < 60000) then
+			parent.GetConfig()[name] = (self:GetChecked() == 1 and true or nil)
+		else
+			parent.GetConfig()[name] = (self:GetChecked() or nil)
+		end
 	end)
 	tinsert(parent.buttons, cb)
 	return cb