Quantcast

fix: if no parameters are specified on need tab then all promted rewards

Alex Shubert [04-19-12 - 08:08]
fix: if no parameters are specified on need tab then all promted rewards
became suitable
fix: localization strings moved to locale files
added: announce that nothing suitable found if 'need' selected
added: announce that highest value item going to be chosen after empty
'need' result
Filename
AutoTurnIn.lua
RewardOptions.lua
localization_DE.lua
localization_EN.lua
localization_RU.lua
options.lua
diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index da859c8..8148383 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -3,7 +3,8 @@ local L = ptable.L
 local C = ptable.CONST

 AutoTurnIn = LibStub("AceAddon-3.0"):NewAddon("AutoTurnIn", "AceEvent-3.0", "AceConsole-3.0")
-AutoTurnIn.defaults = {enabled = true, all = false, dontloot = 1, tournament = 2, darkmoonteleport=true, togglekey=1}
+AutoTurnIn.defaults = {enabled = true, all = false, lootreward = 1, tournament = 2,
+					   darkmoonteleport=true, togglekey=2, darkmoonautostart=true, showrewardtext=true}
 AutoTurnIn.ldb, AutoTurnIn.allowed = nil, nil
 AutoTurnIn.caption = addonName ..' [%s]'
 AutoTurnIn.funcList = {[1] = function() return false end, [2]=IsAltKeyDown, [3]=IsControlKeyDown, [4]=IsShiftKeyDown}
@@ -40,14 +41,14 @@ function AutoTurnIn:OnEnable()
 	if (not AutoTurnInDB) or (not AutoTurnInDB.version or (AutoTurnInDB.version < vers)) then
 		AutoTurnInCharacterDB = nil
 		_G.AutoTurnInDB = {version = vers}
-		self:Print(INSTANCE_RESET_SUCCESS:format(GAMEOPTIONS_MENU))
+		self:Print(L["reset"])
 	end

 	if not AutoTurnInCharacterDB then
 		_G.AutoTurnInCharacterDB = CopyTable(self.defaults)
 	end
-	if (tonumber(AutoTurnInCharacterDB.dontloot) == nil) then
-		AutoTurnInCharacterDB.dontloot = 1
+	if (tonumber(AutoTurnInCharacterDB.lootreward) == nil) then
+		AutoTurnInCharacterDB.lootreward = 1
 	end
 	if (tonumber(AutoTurnInCharacterDB.togglekey) == nil) then
 		AutoTurnInCharacterDB.togglekey = 1
@@ -255,12 +256,14 @@ local function TryToLoadRewards()
 	end
 end]]--

-function AutoTurnIn:TurnInQuest(rewardIndex)
+function AutoTurnIn:TurnInQuest(rewardIndex)
 	if (AutoTurnInCharacterDB.showrewardtext) then
 		self:Print((UnitName("target") and  UnitName("target") or '')..'\n', GetRewardText())
 	end
-	print(rewardIndex)
-	--GetQuestReward(rewardIndex)
+	if  self.forceGreed then
+		self:Print(L["gogreedy"])
+	end
+	GetQuestReward(rewardIndex)
 end

 function AutoTurnIn:Greed()
@@ -283,22 +286,20 @@ function AutoTurnIn:Greed()
 end

 AutoTurnIn.found, AutoTurnIn.stattable = {}, {}
-AutoTurnIn.MSG_STOPITEM = INVTYPE_RELIC .. ' | ' .. INVTYPE_TRINKET.. ': '.. ERR_QUEST_MUST_CHOOSE..' '..TRACKER_SORT_MANUAL
-AutoTurnIn.MSG_ITEMLINKISNULL= BUTTON_LAG_LOOT_TOOLTIP.. '. '..ERR_QUEST_MUST_CHOOSE
 function AutoTurnIn:Need()
 	wipe(self.found)
 	for i=1, GetNumQuestChoices() do
 		local link = GetQuestItemLink("choice", i)

 		if ( link == nil ) then
-			self:Print(self.MSG_ITEMLINKISNULL)
+			self:Print(L["rewardlag"])
 			return true
 		end

 		local class, subclass, _, equipSlot = select(6, GetItemInfo(link))
 		--[[relics and trinkets are out of autoloot]]--
 		if  (UnitHasRelicSlot("player") and 'INVTYPE_RELIC' == equipSlot) or 'INVTYPE_TRINKET' == equipSlot then
-			self:Print(self.MSG_STOPITEM)
+			self:Print(L["stopitemfound"])
 			return true
 		end

@@ -318,14 +319,17 @@ function AutoTurnIn:Need()
 			wipe(self.stattable)
 			GetItemStats(link, self.stattable)
 			for stat, value in pairs(self.stattable) do
-				print(stat, AutoTurnInCharacterDB.stat[stat])
 				if ( AutoTurnInCharacterDB.stat[stat] ) then
 					OkByStat = true
 				end
 			end
 		end

-		if (OkByType and OkByStat) then
+		-- User may not choose any options hence any item became 'ok'. That situation is undoubtly incorrect.
+		local EmptySettings = (class == C.WEAPONLABEL and (not next(AutoTurnInCharacterDB.weapon)) or (not next(AutoTurnInCharacterDB.armor))) and
+							  (not next(AutoTurnInCharacterDB.stat))
+
+		if (OkByType and OkByStat and (not EmptySettings)) then
 			tinsert(self.found, i)
 		end
 	end
@@ -341,6 +345,9 @@ function AutoTurnIn:Need()
 		self:TurnInQuest(self.found[1])
 	end

+	if  ( #self.found == 0 ) and (not AutoTurnInCharacterDB.greedifnothingfound) then
+		self:Print(L["nosuitablefound"])
+	end
 	return ( #self.found ~= 0 )
 end

@@ -354,18 +361,19 @@ function AutoTurnIn:QUEST_COMPLETE()
 	local quest = L.quests[GetTitleText()]
     if AutoTurnInCharacterDB.all or quest then
 		if GetNumQuestChoices() > 0 then
-			if AutoTurnInCharacterDB.dontloot > 1 then -- Auto Loot enabled!
+			if AutoTurnInCharacterDB.lootreward > 1 then -- Auto Loot enabled!
+				self.forceGreed = false
+
 				-- Tournament quest found
 				if (quest == "tournament") then
 					self:TurnInQuest(AutoTurnInCharacterDB.tournament)
 					return
 				end
-
-				local forceGreed = false
-				if (AutoTurnInCharacterDB.dontloot == 3) then
-					forceGreed = (not self:Need() ) and AutoTurnInCharacterDB.greedifnothingfound
+
+				if (AutoTurnInCharacterDB.lootreward == 3) then
+					self.forceGreed = (not self:Need() ) and AutoTurnInCharacterDB.greedifnothingfound
 				end
-				if (AutoTurnInCharacterDB.dontloot == 2 or forceGreed) then
+				if (AutoTurnInCharacterDB.lootreward == 2 or self.forceGreed) then
 					self:Greed()
 				end
 			end
diff --git a/RewardOptions.lua b/RewardOptions.lua
index b86277e..90c3502 100644
--- a/RewardOptions.lua
+++ b/RewardOptions.lua
@@ -140,7 +140,6 @@ RewardPanel.refresh = function()
 	end

 	GreedAfterNeed:SetChecked(ptable.TempConfig.greedifnothingfound )
-
 	-- Armor types dropdown
 	ArmorDropDown.value = nil
 	for index, armorName in ipairs(ARMORCONST) do
@@ -148,6 +147,7 @@ RewardPanel.refresh = function()
 			ArmorDropDown.value=index
 		end
 	end
+
 	ArmorDropDown.value = ArmorDropDown.value and ArmorDropDown.value or 1
 	UIDropDownMenu_SetSelectedID(ArmorDropDown, ArmorDropDown.value)
 	UIDropDownMenu_SetText(ArmorDropDown, ARMORCONST[ArmorDropDown.value])
diff --git a/localization_DE.lua b/localization_DE.lua
index 86221a0..0d89486 100644
--- a/localization_DE.lua
+++ b/localization_DE.lua
@@ -36,7 +36,12 @@ privateTable.L = setmetatable({
 	['Jewelry']="Juwelier",
 	["rewardlootoptions"]="Reward loot rules",
 	['greedifnothing']='Greed if nothing found',
-	["multiplefound"]="Wir fanden einige entsprechende Auszeichnungen. "..ERR_QUEST_MUST_CHOOSE},
+	["multiplefound"]="Wir fanden einige entsprechende Auszeichnungen. "..ERR_QUEST_MUST_CHOOSE,
+	["nosuitablefound"]="Nichts hat sich als geeignet erwiesen. "..ERR_QUEST_MUST_CHOOSE,
+	["gogreedy"]="Nichts hat sich als geeignet erwiesen. Wir nehmen uns die teuerste, was.",
+	["rewardlag"]=BUTTON_LAG_LOOT_TOOLTIP.. '. '..ERR_QUEST_MUST_CHOOSE,
+	["stopitemfound"]="gefunden " .. INVTYPE_RELIC .. ' oder ' .. INVTYPE_TRINKET.. ': '.. ERR_QUEST_MUST_CHOOSE,
+	},

 	{__index = function(table, index) return index end})

diff --git a/localization_EN.lua b/localization_EN.lua
index be8440b..0accfe9 100644
--- a/localization_EN.lua
+++ b/localization_EN.lua
@@ -32,7 +32,12 @@ privateTable.L = setmetatable({
 	['Jewelry']="Jewelry",
 	["rewardlootoptions"]="Reward loot rules",
 	['greedifnothing']='Greed if nothing found',
-	["multiplefound"]="Multiple reward candidates found. "..ERR_QUEST_MUST_CHOOSE},
+	["multiplefound"]="Multiple reward candidates found. "..ERR_QUEST_MUST_CHOOSE,
+	["nosuitablefound"]="No suitable reward found. "..ERR_QUEST_MUST_CHOOSE,
+	["gogreedy"]="No suitable reward found, choosing highest value one.",
+	["rewardlag"]=BUTTON_LAG_LOOT_TOOLTIP.. '. '..ERR_QUEST_MUST_CHOOSE,
+	["stopitemfound"]="Found " .. INVTYPE_RELIC .. ' or ' .. INVTYPE_TRINKET.. ': '.. ERR_QUEST_MUST_CHOOSE,
+	},
 	{__index = function(table, index) return index end})

 privateTable.L.quests = {
diff --git a/localization_RU.lua b/localization_RU.lua
index 153c42e..b31e290 100644
--- a/localization_RU.lua
+++ b/localization_RU.lua
@@ -36,7 +36,12 @@ privateTable.L = setmetatable({
 	['Jewelry']="Ювелирные украшения",
 	["rewardlootoptions"]="Правила выбора награды",
 	["greedifnothing"]="Взять самую дорогую, если ничего не нашлось",
-	["multiplefound"]="Найдено несколько подходящих наград. "..ERR_QUEST_MUST_CHOOSE},
+	["multiplefound"]="Найдено несколько подходящих наград. "..ERR_QUEST_MUST_CHOOSE,
+	["nosuitablefound"]="Подходящих предметов не найдено. "..ERR_QUEST_MUST_CHOOSE,
+	["gogreedy"]="Подходящих предметов не найдено. Берем самую дорогую.",
+	["rewardlag"]=BUTTON_LAG_LOOT_TOOLTIP.. '. '..ERR_QUEST_MUST_CHOOSE,
+	["stopitemfound"]="Найдено " .. INVTYPE_RELIC .. ' или ' .. INVTYPE_TRINKET.. ': '.. ERR_QUEST_MUST_CHOOSE,
+	},

 	{__index = function(table, index) return index end})

diff --git a/options.lua b/options.lua
index b4653a1..4ebb91e 100644
--- a/options.lua
+++ b/options.lua
@@ -68,8 +68,8 @@ UIDropDownMenu_Initialize(LootDropDown, function (self, level)
 		info.text, info.value = v, k
         info.func = function(self)
 						UIDropDownMenu_SetSelectedID(LootDropDown, self:GetID())
-						ptable.TempConfig.dontloot = self:GetID()
-						if ptable.TempConfig.dontloot == 1 then
+						ptable.TempConfig.lootreward = self:GetID()
+						if ptable.TempConfig.lootreward == 1 then
 							UIDropDownMenu_DisableDropDown(TournamentDropDown)
 						else
 							UIDropDownMenu_EnableDropDown(TournamentDropDown)
@@ -147,12 +147,12 @@ OptionsPanel.refresh = function()
 	UIDropDownMenu_SetSelectedID(QuestDropDown, ptable.TempConfig.all and 1 or 2)
 	UIDropDownMenu_SetText(QuestDropDown, ptable.TempConfig.all and L["questTypeAll"] or L["questTypeList"]  )

-	UIDropDownMenu_SetSelectedID(LootDropDown, ptable.TempConfig.dontloot)
-	UIDropDownMenu_SetText(LootDropDown, LootConst[ptable.TempConfig.dontloot])
+	UIDropDownMenu_SetSelectedID(LootDropDown, ptable.TempConfig.lootreward)
+	UIDropDownMenu_SetText(LootDropDown, LootConst[ptable.TempConfig.lootreward])

 	UIDropDownMenu_SetSelectedID(TournamentDropDown, ptable.TempConfig.tournament)
 	UIDropDownMenu_SetText(TournamentDropDown,TournamentConst[ptable.TempConfig.tournament])
-	if (ptable.TempConfig.dontloot == 1) then
+	if (ptable.TempConfig.lootreward == 1) then
 		UIDropDownMenu_DisableDropDown(TournamentDropDown)
 	end
 	DarkMoonCannon:SetChecked(ptable.TempConfig.darkmoonteleport)