Quantcast

a loot of work with tournament quests

Alex Shubert [02-09-12 - 22:23]
a loot of work with tournament quests
Filename
AutoTurnIn.lua
AutoTurnIn.toc
localization_DE.lua
localization_EN.lua
localization_RU.lua
options.lua
diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index 95bba10..bd57e4e 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -1,17 +1,25 @@
 local addonName, ptable = ...
 local L = ptable.L
-local AutoTurnInCharacterDB
+local AutoTurnInCharacterDB, AutoTurnInDB
 AutoTurnIn = LibStub("AceAddon-3.0"):NewAddon("AutoTurnIn", "AceEvent-3.0", "AceConsole-3.0")

-local defaults = {enabled = true, all = false, lootMostExpensive = false}
+AutoTurnIn.defaults = {enabled = true, all = false, dontloot = false, tournament = 2}

 -- quest autocomplete handlers and functions
 function AutoTurnIn:OnEnable()
+	AutoTurnInDB = _G.AutoTurnInDB
 	AutoTurnInCharacterDB = _G.AutoTurnInCharacterDB
+	local vers = GetAddOnMetadata(addonName, "Version")
+
+	if not AutoTurnInDB or AutoTurnInDB.version < vers then
+		AutoTurnInCharacterDB = nil
+		AutoTurnInDB = {version = vers}
+		self:Print(L["reset"])
+	end
 	if not AutoTurnInCharacterDB then
-		_G.AutoTurnInCharacterDB = CopyTable(defaults)
+		_G.AutoTurnInCharacterDB = CopyTable(AutoTurnIn.defaults)
 		AutoTurnInCharacterDB = _G.AutoTurnInCharacterDB
-	end
+	end
 	if AutoTurnInCharacterDB.enabled then
 		self:RegisterGossipEvents()
 	end
@@ -44,7 +52,7 @@ local p2 = {

 function AutoTurnIn:ConsoleComand(arg)
 	if (#arg == 0) then
-		InterfaceOptionsFrame_OpenToCategory(_G[addonName.."OptionsPanel"])
+		InterfaceOptionsFrame_OpenToCategory(_G["AutoTurnInOptionsPanel"])
 	elseif arg == "on" then
 		if (not AutoTurnInCharacterDB.enabled) then
 			AutoTurnInCharacterDB.enabled = true
@@ -64,12 +72,12 @@ function AutoTurnIn:ConsoleComand(arg)
 		AutoTurnInCharacterDB.all = false
 		self:Print(L["list"])
 	elseif arg == "loot" then
-		AutoTurnInCharacterDB.lootMostExpensive = not AutoTurnInCharacterDB.lootMostExpensive
-		self:Print(L["loot"..tostring(AutoTurnInCharacterDB.lootMostExpensive)])
+		AutoTurnInCharacterDB.dontloot = not AutoTurnInCharacterDB.dontloot
+		self:Print(L["dontloot"..tostring(AutoTurnInCharacterDB.dontloot)])
 	elseif arg == "help" then
-		self:Print(L["usage1"] .. " | " .. p1[AutoTurnInCharacterDB.enabled])
-		self:Print(L["usage2"] .. " | " .. p2[AutoTurnInCharacterDB.all])
-		self:Print(L["usage3"] .. " | " .. L["loot"..tostring(AutoTurnInCharacterDB.lootMostExpensive)])
+		self:Print(p1[AutoTurnInCharacterDB.enabled])
+		self:Print(p2[AutoTurnInCharacterDB.all])
+		self:Print(L["dontloot"..tostring(AutoTurnInCharacterDB.dontloot)])
 	end
 end

@@ -130,10 +138,14 @@ function AutoTurnIn:QUEST_PROGRESS()
 end

 function AutoTurnIn:QUEST_COMPLETE()
-    if AutoTurnInCharacterDB.all or L.quests[GetTitleText()] then
+	local quest = L.quests[GetTitleText()]
+    if AutoTurnInCharacterDB.all or quest then
 		local index, money = 0, 0;
 		if GetNumQuestChoices() > 0 then
-			if AutoTurnInCharacterDB.lootMostExpensive then
+			if not AutoTurnInCharacterDB.dontloot then
+				if (quest == "tournament") then
+					GetQuestReward(AutoTurnInCharacterDB.tournament)
+				end
 				for i=1, GetNumQuestChoices() do
 					local m = select(11, GetItemInfo(GetQuestItemLink("choice", i)))
 					if m > money then
diff --git a/AutoTurnIn.toc b/AutoTurnIn.toc
index a139569..7a50fdd 100644
--- a/AutoTurnIn.toc
+++ b/AutoTurnIn.toc
@@ -1,6 +1,6 @@
 ## Interface: 40300
 ## Title: AutoTurnIn
-## Version: 1.0
+## Version: 2.0
 ## Author: Lur
 ## Notes: Auto accept and complete daily (or all) quests
 ## Notes-ruRU: Автоматически принимает и сдает ежедневные (либо все) задания
@@ -17,5 +17,5 @@ embeds.xml
 localization_RU.lua
 localization_EN.lua
 localization_DE.lua
-options.lua
 AutoTurnIn.lua
+options.lua
diff --git a/localization_DE.lua b/localization_DE.lua
index 6e9c46b..de89b40 100644
--- a/localization_DE.lua
+++ b/localization_DE.lua
@@ -1,15 +1,28 @@
 local addonName, privateTable = ...
 if (GetLocale() == "deDE") then
 privateTable.L = setmetatable({
+	["reset"]="zurücksetzen",
 	["usage1"]="'on' / 'off' zu aktivieren oder deaktivieren Addon",
-	["usage2"]="'all'/'list' um alle Aufgaben bewältigen oder Liste",
+	["usage2"]="'all'/'list' um alle Aufgaben bewältigen oder Täglich",
 	["usage3"]="'loot' do not complete quests with a list of rewards or complete it and choose most expensive one of rewards",
 	["enabled"]="einschalten",
 	["disabled"]="abschalten",
 	["all"]="bedient alle Quests",
 	["list"]="diente nur die ausgewählten Quests",
-	["loottrue"]="Addon übergibt den Job, und wählen Sie die teuerste Belohnung",
-	["lootfalse"]="Quests mit Belohnungen werden nicht von Addon fertig sein"},
+	["dontlootfalse"]="Addon übergibt den Job, und wählen Sie die teuerste Belohnung",
+	["dontloottrue"]="Quests mit Belohnungen werden nicht von Addon fertig sein",
+
+	["questTypeLabel"] = "quests",
+	["questTypeAll"] = "alle",
+	["questTypeList"] = "Täglich",
+
+	["lootTypeLabel"]="Jobs mit Auszeichnungen",
+	["lootTypeFalse"]="nicht abgeschlossen",
+	["lootTypeTrue"]="nehmen Sie die teuerste, was",
+
+	["tournamentLabel"]="Turnier",
+	["tournamentWrit"]="Verfügung des Champions", -- 46114
+	["tournamentPurse"]="Geldbeutel des Champions"},  -- 45724
 	{__index = function(table, index) return index end})

 privateTable.L.quests = {
@@ -162,12 +175,12 @@ privateTable.L.quests = {
 ['Setzt ein Zeichen']="",
 --Tournament
 ['Auf Winters Schneide']="",
-['Bedrohung von oben']="",
+['Bedrohung von oben']="tournament",
 ['Todesritter']="",
 ['Das Schicksal der Gefallenen']="",
 ['Der große Arenakampf']="",
 ['Die Barmherzigkeit des Lichts']="",
-['Die Schlacht zum Gegner tragen']="",
+['Die Schlacht zum Gegner tragen']="tournament",
 ['Die Überreste identifizieren']="",
 ['Diesmal habt Ihr Euch wirklich selbst übertroffen, Kul']="",
 ['Drottinn Hrothgar']="",
@@ -185,9 +198,9 @@ privateTable.L.quests = {
 ['Ornolf der Vernarbte']="",
 ['Reitgrundlagen']="",
 ['Rettungseinsatz auf See']="",
-['Schlacht vor der Zitadelle']="",
+['Schlacht vor der Zitadelle']="tournament",
 ['Todessprecher Kharos']="",
-['Unter Champions']="",
+['Unter Champions']="tournament",
 ['Vor den Toren des Feindes']="",
 ['Vor den Toren des Feindes']="",
 ['Was fressen eigentlich Yetis?']="",
diff --git a/localization_EN.lua b/localization_EN.lua
index 131fde4..579d78c 100644
--- a/localization_EN.lua
+++ b/localization_EN.lua
@@ -5,9 +5,21 @@ privateTable.L = setmetatable({
 	["usage2"]="'all'/'list' to handle any quest or just specified in a list",
 	["usage3"]="'loot' do not complete quests with a list of rewards or complete it and choose most expensive one of rewards",
 	["all"]="ready to handle every quest",
-	["list"]="only specified quests will be handled",
-	["loottrue"]="addon automatically loots most expensive reward",
-	["lootfalse"]="quest with item rewards will not be finished by addon"},
+	["list"]="only daily quests will be handled",
+	["dontlootfalse"]="loot most expensive reward",
+	["dontloottrue"]="do not complete quests with rewards",
+
+	["questTypeLabel"] = "quests",
+	["questTypeAll"] = "all",
+	["questTypeList"] = "daily",
+
+	["lootTypeLabel"]="quests with rewards",
+	["lootTypeFalse"]="don't turn in",
+	["lootTypeTrue"]="loot most expensive reward",
+
+	["tournamentLabel"]="tournament",
+	["tournamentWrit"]="Champion's Writ", -- 46114
+	["tournamentPurse"]="Champion's Purse"},  -- 45724
 	{__index = function(table, index) return index end})

 privateTable.L.quests = {
@@ -164,9 +176,9 @@ privateTable.L.quests = {
 ["A Leg Up"]="",
 ["A Valiant's Field Training"]="",
 ["A Worthy Weapon"]="",
-["Among the Champions"]="",
+["Among the Champions"]="tournament",
 ["At The Enemy's Gates"]="",
-["Battle Before The Citadel"]="",
+["Battle Before The Citadel"]="tournament",
 ["Breakfast Of Champions"]="",
 ["Contributin' To The Cause"]="",
 ["Deathspeaker Kharos"]="",
@@ -180,12 +192,12 @@ privateTable.L.quests = {
 ["Ornolf The Scarred"]="",
 ["Rescue at Sea"]="",
 ["Stop The Aggressors"]="",
-["Taking Battle To The Enemy"]="",
+["Taking Battle To The Enemy"]="tournament",
 ["The Edge Of Winter"]="",
 ["The Fate Of The Fallen"]="",
 ["The Grand Melee"]="",
 ["The Light's Mercy"]="",
-["Threat From Above"]="",
+["Threat From Above"]="tournament",
 ["Training In The Field"]="",
 ["What Do You Feed a Yeti, Anyway?"]="",
 ["You've Really Done It This Time, Kul"]="",
diff --git a/localization_RU.lua b/localization_RU.lua
index 4fdf9e1..1b7c774 100644
--- a/localization_RU.lua
+++ b/localization_RU.lua
@@ -1,6 +1,7 @@
 local addonName, privateTable = ...
 if (GetLocale() == "ruRU")  then
 privateTable.L = setmetatable({
+	["reset"]="настройки были сброшены",
 	["usage1"]="'on'/'off' включает или отключает аддон",
 	["usage2"]="'all'/'list' принимать и сдавать все задания или только внесенные в список",
 	["usage3"]="'loot' не завершать задания, где есть список наград либо завершать и выбирать самую дорогую",
@@ -8,8 +9,20 @@ privateTable.L = setmetatable({
 	["disabled"]="отключен",
 	["all"]="принимать и сдавать любое задание",
 	["list"]="принимать и сдавать только внесенные в список задания",
-	["loottrue"]="при завершении заданий с выбором наград автоматически взять самую дорогую из них",
-	["lootfalse"]="не завершать задания, где есть выбор наград"},
+	["dontlootfalse"]="при завершении заданий с выбором наград автоматически взять самую дорогую из них",
+	["dontloottrue"]="не завершать задания, где есть выбор наград",
+
+	["questTypeLabel"] = "задания",
+	["questTypeAll"] = "все",
+	["questTypeList"] = "ежедневные",
+
+	["lootTypeLabel"]="задания с наградами",
+	["lootTypeFalse"]="не сдавать",
+	["lootTypeTrue"]="выбирать самую дорогую",
+
+	["tournamentLabel"]="серебряный турнир",
+	["tournamentWrit"]="Удостоверение чемпиона", -- 46114
+	["tournamentPurse"]="Кошелек чемпиона"},  -- 45724
 	{__index = function(table, index) return index end})

 privateTable.L.quests = {
@@ -171,9 +184,9 @@ privateTable.L.quests = {
 ["Пристрели их"]="",
 ["Сбор информации"]="",
 --турнир
-["Атака с воздуха"]="",
-["Битва на вражеской территории"]="",
-["Битва у Цитадели"]="",
+["Атака с воздуха"]="tournament",
+["Битва на вражеской территории"]="tournament",
+["Битва у Цитадели"]="tournament",
 ["Большая тренировка"]="",
 ["Великая битва"]="",
 ["Вестник смерти Карос"]="",
@@ -188,7 +201,7 @@ privateTable.L.quests = {
 ["Кстати, чем питаются йети?"]="",
 ["Лапами кверху"]="",
 ["Милосердие Света"]="",
-["На равных с чемпионами"]="",
+["На равных с чемпионами"]="tournament",
 ["На этот раз ты нарвался, Кул"]="",
 ["Обломки стен Ульдуара"]="",
 ["Опознание останков"]="",
diff --git a/options.lua b/options.lua
index 691a6b6..d886690 100644
--- a/options.lua
+++ b/options.lua
@@ -12,85 +12,107 @@ OptionsPanel.name=addonName
 local title = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
 title:SetText(addonName)
 -- Description
-local subText = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
 local notes = GetAddOnMetadata(addonName, "Notes-" .. GetLocale())
-if not notes then
-	notes = GetAddOnMetadata(addonName, "Notes")
-end
+notes = notes or GetAddOnMetadata(addonName, "Notes")
+local subText = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
 subText:SetText(notes)

--- Enable CheckBox
+-- 'Enable' CheckBox
 local Enable = CreateFrame("CheckButton", O.."Enable", OptionsPanel, "OptionsCheckButtonTemplate")
 _G[O.."EnableText"]:SetText(L["enabled"])
 Enable:SetScript("OnClick", function(self) AutoTurnInCharacterDB.enabled = self:GetChecked() end)

 -- Quest types to handle
-
-local QuestType = CreateFrame("Frame", O.."QuestTypes", OptionsPanel, "UIDropDownMenuTemplate")
-UIDropDownMenu_Initialize(QuestType, function (self, level)
-    local info
-    for k, v in pairs({["all"] = L["all"],["list"] = L["list"]}) do
-        info = UIDropDownMenu_CreateInfo()
-        info.text = v
-        info.value = k
+local QuestLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
+QuestLabel:SetText(L["questTypeLabel"])
+local QuestConst = {L["questTypeAll"], L["questTypeList"]}
+local QuestDropDown = CreateFrame("Frame", O.."QuestDropDown", OptionsPanel, "UIDropDownMenuTemplate")
+UIDropDownMenu_Initialize(QuestDropDown, function (self, level)
+    for k, v in ipairs(QuestConst) do
+        local info = UIDropDownMenu_CreateInfo()
+        info.text, info.value = v, k
         info.func = function(self)
-						UIDropDownMenu_SetSelectedID(QuestType, self:GetID())
-						AutoTurnInCharacterDB.all = (self:GetID() == 2)
+						UIDropDownMenu_SetSelectedID(QuestDropDown, self:GetID())
+						AutoTurnInCharacterDB.all = (self:GetID() == 1)
 					end
         UIDropDownMenu_AddButton(info, level)
     end
 end)
-UIDropDownMenu_SetWidth(QuestType,400 );
-UIDropDownMenu_JustifyText(QuestType, "LEFT")
+UIDropDownMenu_SetWidth(QuestDropDown, 200);
+UIDropDownMenu_JustifyText(QuestDropDown, "LEFT")

--- Loot type
-local LootType = CreateFrame("Frame", O.."LootTypes", OptionsPanel, "UIDropDownMenuTemplate")
-UIDropDownMenu_Initialize(LootType, function (self, level)
-    local info
-    for k, v in pairs({["loottrue"] = L["loottrue"],["lootfalse"] = L["lootfalse"]}) do
-        info = UIDropDownMenu_CreateInfo()
-        info.text = v
-        info.value = k
-        info.func = function(self)
-						UIDropDownMenu_SetSelectedID(LootType, self:GetID())
-						AutoTurnInCharacterDB.lootMostExpensive = (self:GetID() == 2)
+-- Tournament loot type
+local TournamentDropDownLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
+TournamentDropDownLabel:SetText(L["tournamentLabel"])
+local TournamentConst = {L["tournamentWrit"], L["tournamentPurse"]};
+local TournamentDropDown = CreateFrame("Frame", O.."TournamentDropDown", OptionsPanel, "UIDropDownMenuTemplate")
+function TournamentDropDown:initialize ()
+    for k, v in ipairs(TournamentConst) do
+        local info = UIDropDownMenu_CreateInfo()
+        info.text, info.value = v, k
+        info.func = function(self)
+						UIDropDownMenu_SetSelectedID(TournamentDropDown, self:GetID())
+						AutoTurnInCharacterDB.tournament = self:GetID()
+					end
+        UIDropDownMenu_AddButton(info, level)
+    end
+end
+UIDropDownMenu_SetWidth(TournamentDropDown, 200);
+UIDropDownMenu_JustifyText(TournamentDropDown, "LEFT")
+
+-- How to loot
+local LootLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
+LootLabel:SetText(L["lootTypeLabel"])
+local LootConst = {L["lootTypeFalse"], L["lootTypeTrue"]}
+local LootDropDown = CreateFrame("Frame", O.."LootDropDown", OptionsPanel, "UIDropDownMenuTemplate")
+UIDropDownMenu_Initialize(LootDropDown, function (self, level)
+    for k, v in ipairs(LootConst) do
+        local info = UIDropDownMenu_CreateInfo()
+		info.text, info.value = v, k
+        info.func = function(self)
+						UIDropDownMenu_SetSelectedID(LootDropDown, self:GetID())
+						AutoTurnInCharacterDB.dontloot = (self:GetID() == 1)
+						if AutoTurnInCharacterDB.dontloot then
+							UIDropDownMenu_DisableDropDown(TournamentDropDown)
+						else
+							UIDropDownMenu_EnableDropDown(TournamentDropDown)
+						end
 					end
         UIDropDownMenu_AddButton(info, level)
     end
 end)
-UIDropDownMenu_SetWidth(LootType,400 );
-UIDropDownMenu_JustifyText(LootType, "LEFT")
+UIDropDownMenu_SetWidth(LootDropDown, 200);
+UIDropDownMenu_JustifyText(LootDropDown, "LEFT")

 -- Control placement
 title:SetPoint("TOPLEFT", 16, -16)
 subText:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
 Enable:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16)
-QuestType:SetPoint("TOPLEFT", Enable, "BOTTOMLEFT", -15, -16)
-LootType:SetPoint("TOPLEFT", QuestType, "BOTTOMLEFT", 0, -16)
+QuestLabel:SetPoint("BOTTOMLEFT", QuestDropDown, "TOPLEFT", 18, 0)
+QuestDropDown:SetPoint("TOPLEFT", Enable, "BOTTOMLEFT", -15, -35)
+LootLabel:SetPoint("BOTTOMLEFT", LootDropDown, "TOPLEFT", 18, 0)
+LootDropDown:SetPoint("TOPLEFT", QuestDropDown, "BOTTOMLEFT", 0, -35)
+TournamentDropDownLabel:SetPoint("BOTTOMLEFT", TournamentDropDown, "TOPLEFT", 18, 0)
+TournamentDropDown:SetPoint("TOPLEFT", LootDropDown, "TOPRIGHT", 17, 0)

 OptionsPanel.refresh = function()
 	Enable:SetChecked(AutoTurnInCharacterDB.enabled)

-	if AutoTurnInCharacterDB.all then
-		UIDropDownMenu_SetSelectedID(QuestType, 2)
-		UIDropDownMenu_SetText(QuestType, L["all"])
-	else
-		UIDropDownMenu_SetSelectedID(QuestType, 1)
-		UIDropDownMenu_SetText(QuestType, L["list"])
-	end
+	UIDropDownMenu_SetSelectedID(QuestDropDown, AutoTurnInCharacterDB.all and 1 or 2)
+	UIDropDownMenu_SetText(QuestDropDown, AutoTurnInCharacterDB.all and L["questTypeAll"] or L["questTypeList"]  )

-	if AutoTurnInCharacterDB.lootMostExpensive then
-		UIDropDownMenu_SetSelectedID(LootType, 2)
-		UIDropDownMenu_SetText(LootType, L["loottrue"])
-	else
-		UIDropDownMenu_SetSelectedID(LootType, 1)
-		UIDropDownMenu_SetText(LootType, L["lootfalse"])
+	UIDropDownMenu_SetSelectedID(LootDropDown, AutoTurnInCharacterDB.dontloot and 1 or 2)
+	UIDropDownMenu_SetText(LootDropDown, AutoTurnInCharacterDB.dontloot and L["lootTypeFalse"] or L["lootTypeTrue"])
+
+	UIDropDownMenu_SetSelectedID(TournamentDropDown, AutoTurnInCharacterDB.tournament)
+	UIDropDownMenu_SetText(TournamentDropDown,TournamentConst[AutoTurnInCharacterDB.tournament])
+	if (AutoTurnInCharacterDB.dontloot) then
+		UIDropDownMenu_DisableDropDown(TournamentDropDown)
 	end
 end

 OptionsPanel.default = function()
-	AutoTurnInCharacterDB.enabled = true
-	AutoTurnInCharacterDB.all = false
-	AutoTurnInCharacterDB.lootMostExpensive = false
+	AutoTurnInCharacterDB = CopyTable(AutoTurnIn.defaults)
 end
+
 InterfaceOptions_AddCategory(OptionsPanel)
\ No newline at end of file