Quantcast

Option panel bug fied

Alex Shubert [08-23-12 - 16:25]
Option panel bug fied
Filename
AutoTurnIn.lua
ui/main_options.lua
ui/reward_options.lua
diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index 6f8c050..06eb660 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -5,7 +5,8 @@ local TOCVersion = GetAddOnMetadata(addonName, "Version")

 AutoTurnIn = LibStub("AceAddon-3.0"):NewAddon("AutoTurnIn", "AceEvent-3.0", "AceConsole-3.0")
 AutoTurnIn.defaults = {enabled = true, all = false, lootreward = 1, tournament = 2,
-					   darkmoonteleport=true, togglekey=2, darkmoonautostart=true, showrewardtext=true, version=TOCVersion, autoequip = false}
+					   darkmoonteleport=true, togglekey=2, darkmoonautostart=true, showrewardtext=true, version=TOCVersion, autoequip = false,
+					   armor = {}, weapon = {}, stat = {}, secondary = {}}
 AutoTurnIn.ldb, AutoTurnIn.allowed = nil, nil
 AutoTurnIn.caption = addonName ..' [%s]'
 AutoTurnIn.funcList = {[1] = function() return false end, [2]=IsAltKeyDown, [3]=IsControlKeyDown, [4]=IsShiftKeyDown}
@@ -66,6 +67,7 @@ function AutoTurnIn:OnEnable()

 	self:SetEnabled(AutoTurnInCharacterDB.enabled)
 	self:RegisterGossipEvents()
+	self:Print("May I ask you to tell your friends about AutoTurnIn? Maybe via facebook or tweeter? plxplx! Also, any ideas and bug reports are welcome\.")
 end

 function AutoTurnIn:RegisterGossipEvents()
diff --git a/ui/main_options.lua b/ui/main_options.lua
index 35deef0..e0884d9 100644
--- a/ui/main_options.lua
+++ b/ui/main_options.lua
@@ -20,9 +20,6 @@ local ResetButton = CreateFrame("Button", nil, OptionsPanel, "OptionsButtonTempl
 ResetButton:SetText(L["resetbutton"])
 ResetButton:SetScript("OnClick", function()
 	ptable.TempConfig = CopyTable(AutoTurnIn.defaults)
-	ptable.TempConfig.armor = {}
-	ptable.TempConfig.weapon = {}
-	ptable.TempConfig.stat = {}

 	MakeACopy=false;
 	AutoTurnIn.RewardPanel.refresh();
diff --git a/ui/reward_options.lua b/ui/reward_options.lua
index 85f9b78..09bb842 100644
--- a/ui/reward_options.lua
+++ b/ui/reward_options.lua
@@ -74,12 +74,15 @@ CreateCheckbox("Ranged", WeaponPanel, 10, -136, string.format("%s, %s, %s", weap
 -- ARMOR
 local ArmorPanel = CreatePanel("ArmorPanel", C.ARMORLABEL, 590, 70)
 local ArmorDropDown = CreateFrame("Frame", O.."ToggleKeyDropDown", ArmorPanel, "UIDropDownMenuTemplate")
-local ARMORCONST = {NONE_KEY, armor[2], armor[3], armor[4],armor[5]}
+local ARMORCONST = {NONE_KEY, armor[2], armor[3], armor[4], armor[5]}
 UIDropDownMenu_Initialize(ArmorDropDown, function (self, level)
     for k, v in ipairs(ARMORCONST) do
         local info = UIDropDownMenu_CreateInfo()
 		info.text, info.value = v, k
         info.func = function(self)
+						for k, v in pairs(ptable.TempConfig.armor) do
+							print(k, v)
+						end
 						UIDropDownMenu_SetSelectedID(ArmorDropDown, self:GetID())
 						if ArmorDropDown.value > 1 then
 							ptable.TempConfig.armor[ARMORCONST[ArmorDropDown.value]] = nil
@@ -87,7 +90,10 @@ UIDropDownMenu_Initialize(ArmorDropDown, function (self, level)
 						if self:GetID() > 1 then
 							ArmorDropDown.value = self:GetID()
 							ptable.TempConfig.armor[self:GetText()] = true
-						end
+						end
+						for k, v in pairs(ptable.TempConfig.armor) do
+							print(k, v)
+						end
 					end
         UIDropDownMenu_AddButton(info, level)
     end
@@ -118,8 +124,7 @@ CreateCheckbox('ITEM_MOD_HASTE_RATING_SHORT', SecStatPanel, 206, -40, ITEM_MOD_H
 CreateCheckbox('ITEM_MOD_HIT_RATING_SHORT', SecStatPanel, 402, -40, ITEM_MOD_HIT_RATING_SHORT)
     -- 3rd line
 CreateCheckbox('ITEM_MOD_MASTERY_RATING_SHORT', SecStatPanel, 10, -72, ITEM_MOD_MASTERY_RATING_SHORT)
-CreateCheckbox('ITEM_MOD_SPELL_PENETRATION_SHORT', SecStatPanel, 206, -72, ITEM_MOD_SPELL_PENETRATION_SHORT)
-CreateCheckbox('ITEM_MOD_SPELL_POWER_SHORT', SecStatPanel, 402, -72, ITEM_MOD_SPELL_POWER_SHORT)
+CreateCheckbox('ITEM_MOD_SPELL_POWER_SHORT', SecStatPanel, 206, -72, ITEM_MOD_SPELL_POWER_SHORT)


 -- 'Greed' CheckBox
@@ -138,12 +143,11 @@ SecStatPanel:SetPoint("TOPLEFT", StatPanel, "BOTTOMLEFT", 0, -20)
 GreedAfterNeed:SetPoint("TOPLEFT", SecStatPanel, "BOTTOMLEFT", 8, -16)

 --[[ PANEL FUNCTIONS ]]--
-local AC = {[NONE_KEY]=1, [armor[2]]=2, [armor[3]]=3, [armor[4]]=4,[armor[5]]=5}
 RewardPanel.refresh = function()
 	WeaponPanel:ClearCheckBoxes()
 	ArmorPanel:ClearCheckBoxes()
 	StatPanel:ClearCheckBoxes()
-
+	SecStatPanel:ClearCheckBoxes()
 	for k,v in pairs(ptable.TempConfig.weapon) do
 		_G[WeaponPanel:GetName()..k]:SetChecked(v)
 	end
@@ -153,15 +157,22 @@ RewardPanel.refresh = function()
 	for k,v in pairs(ptable.TempConfig.secondary) do
 		_G[SecStatPanel:GetName()..k]:SetChecked(v)
 	end
+
 	for k,v in pairs(ptable.TempConfig.armor) do
-		_G[ArmorPanel:GetName()..k]:SetChecked(v)
+		-- check is necessary: armor types and concrete subtypes held in one array. while subtypes have it's checkboxes, armor types rendered in a DropBox
+		-- -> hence, no global control exists and _G[armorType] leads to silent exception
+		local checkbox = _G[ArmorPanel:GetName()..k];
+		if (checkbox) then
+			_G[ArmorPanel:GetName()..k]:SetChecked(v)
+		end
 	end
-
+
 	GreedAfterNeed:SetChecked(ptable.TempConfig.greedifnothingfound )
 	-- Armor types dropdown
 	ArmorDropDown.value = nil
+
 	for index, armorName in ipairs(ARMORCONST) do
-		if ptable.TempConfig.armor[armorName] then
+		if ptable.TempConfig.armor[armorName] then
 			ArmorDropDown.value=index
 		end
 	end