Quantcast

Quest autosharing functionality

Alex Shubert [05-12-13 - 08:11]
Quest autosharing functionality
Filename
AutoTurnIn.lua
loc/localization_DE.lua
loc/localization_EN.lua
loc/localization_FR.lua
loc/localization_RU.lua
ui/main_options.lua
diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index 3d897d9..1af6fdb 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -14,7 +14,7 @@ AutoTurnIn = LibStub("AceAddon-3.0"):NewAddon("AutoTurnIn", "AceEvent-3.0", "Ace
 AutoTurnIn.defaults = {enabled = true, all = false, trivial = false, lootreward = 1, tournament = 2,
 					   darkmoonteleport=true, todarkmoon=true, togglekey=4, darkmoonautostart=true, showrewardtext=true,
 					   version=TOCVersion, autoequip = false, debug=false,
-					   questlevel=true, watchlevel=true,
+					   questlevel=true, watchlevel=true, questshare=false,
 					   armor = {}, weapon = {}, stat = {}, secondary = {}}

 AutoTurnIn.ldb, AutoTurnIn.allowed = nil, nil
@@ -47,7 +47,7 @@ AutoTurnIn.ldbstruct = {
 function AutoTurnIn:OnInitialize()
 	self:RegisterChatCommand("au", "ConsoleComand")
 end
-
+
 function AutoTurnIn:SetEnabled(enabled)
 	AutoTurnInCharacterDB.enabled = not not enabled
 	if self.ldb then
@@ -67,7 +67,7 @@ function AutoTurnIn:OnEnable()
 		_G.AutoTurnInCharacterDB = CopyTable(self.defaults)
 	end
 	local DB = AutoTurnInCharacterDB
-
+
 	if (tonumber(DB.lootreward) == nil) then
 		DB.lootreward = 1
 	end
@@ -79,9 +79,10 @@ function AutoTurnIn:OnEnable()
 	DB.stat = DB.stat and DB.stat or {}
 	DB.secondary = DB.secondary and DB.secondary or {}
 	DB.trivial = DB.trivial ~= nil and DB.trivial or false
-
+
 	DB.questlevel = DB.questlevel == nil and true or DB.questlevel
 	DB.watchlevel = DB.watchlevel == nil and true or DB.watchlevel
+	DB.questshare = DB.questshare == nil and false or DB.questshare

 	local LDB = LibStub:GetLibrary("LibDataBroker-1.1", true)
 	if LDB then
@@ -182,11 +183,11 @@ function AutoTurnIn:QUEST_GREETING()
 	end

 	for index=1, GetNumAvailableQuests() do
-		local isTrivial, isDaily, isRepeatable = GetAvailableQuestInfo(index)
+		local isTrivial, isDaily, isRepeatable = GetAvailableQuestInfo(index)
 		local triviaAndAllowedOrNotTrivia = (not isTrivial) or AutoTurnInCharacterDB.trivial
 		local quest = L.quests[GetAvailableTitle(index)]
 		local notBlackListed = not (quest and quest.donotaccept)
-
+
 		if isDaily then
 			self:CacheAsDaily(GetAvailableTitle(index))
 		end
@@ -208,7 +209,7 @@ end
 -- with ending `nil`. So: '#' for {1,nil, "b", nil} returns 1
 function AutoTurnIn:VarArgForActiveQuests(...)
     local MOP_INDEX_CONST = 5 -- was '4' in Cataclysm
-
+
 	for i=1, select("#", ...), MOP_INDEX_CONST do
 		local isComplete = select(i+3, ...) -- complete status
 		if ( isComplete ) then
@@ -320,6 +321,13 @@ function AutoTurnIn:QUEST_DETAIL()
 	end
 end

+function AutoTurnIn:QUEST_ACCEPTED(event, index)
+	if AutoTurnInCharacterDB.questshare and GetQuestLogPushable() and GetNumGroupMembers() >= 1 then
+		SelectQuestLogEntry(index);
+		QuestLogPushQuest();
+	end
+end
+
 function AutoTurnIn:QUEST_PROGRESS()
     if  self:AllowedToHandle() and IsQuestCompletable() and self:AllOrDaily() then
 		CompleteQuest()
diff --git a/loc/localization_DE.lua b/loc/localization_DE.lua
index 19e86bb..bc92803 100644
--- a/loc/localization_DE.lua
+++ b/loc/localization_DE.lua
@@ -16,7 +16,8 @@ privateTable.L = setmetatable({
 	["questTypeLabel"] = "quests",
 	["questTypeAll"] = "alle",
 	["TrivialQuests"]="'graue' Quests annehmen",
-	["questTypeList"] = "Tägliche Quests",
+	["questTypeList"] = "Tägliche Quests",
+	["ShareQuestsLabel"] = "teilen die Quest",

 	["lootTypeLabel"]="Jobs mit Belohnungen",
 	["lootTypeFalse"]="nicht abgeben",
diff --git a/loc/localization_EN.lua b/loc/localization_EN.lua
index a83d7fd..d3abdd3 100644
--- a/loc/localization_EN.lua
+++ b/loc/localization_EN.lua
@@ -22,7 +22,8 @@ privateTable.L = setmetatable({
 	["questTypeLabel"] = "Quests to handle",
 	["questTypeAll"] = "all",
 	["TrivialQuests"]="Accept 'grey' quests",
-	["questTypeList"] = "daily",
+	["questTypeList"] = "daily",
+	["ShareQuestsLabel"] = "Quest auto sharing",

 	["lootTypeLabel"]="Quests with rewards",
 	["lootTypeFalse"]="don't turn in",
diff --git a/loc/localization_FR.lua b/loc/localization_FR.lua
index 4b662e8..2606ded 100644
--- a/loc/localization_FR.lua
+++ b/loc/localization_FR.lua
@@ -15,6 +15,7 @@ privateTable.L = setmetatable({
     ["questTypeAll"] =  "Toutes",
     ["TrivialQuests"]= "Accepter les quêtes 'grise'",
     ["questTypeList"] = "Quêtes journalières",
+	["ShareQuestsLabel"] = "partager la quête",

     ["lootTypeLabel"]="Quêtes à récompense d'objet",
     ["lootTypeFalse"]="Ne pas rendre",
diff --git a/loc/localization_RU.lua b/loc/localization_RU.lua
index 71cf0c2..503409b 100644
--- a/loc/localization_RU.lua
+++ b/loc/localization_RU.lua
@@ -16,7 +16,8 @@ privateTable.L = setmetatable({
 	["questTypeLabel"] = "задания",
 	["questTypeAll"] = "все",
 	["TrivialQuests"]="брать 'серые' квесты",
-	["questTypeList"] = "ежедневные",
+	["questTypeList"] = "ежедневные",
+	["ShareQuestsLabel"] = "Предлагать задание группе",

 	["lootTypeLabel"]="задания с наградами",
 	["lootTypeFalse"]="не сдавать",
diff --git a/ui/main_options.lua b/ui/main_options.lua
index c1a6dc2..cdd7b08 100644
--- a/ui/main_options.lua
+++ b/ui/main_options.lua
@@ -26,6 +26,17 @@ ResetButton:SetScript("OnClick", function()
 	AutoTurnIn.OptionsPanel.refresh();
 end)

+--[[
+local function CreateCheckbox(name, marginx, marginy)
+	local cb = CreateFrame("CheckButton", O..name,  OptionsPanel, "OptionsCheckButtonTemplate")
+	_G[cb:GetName().."Text"]:SetText(L[name])
+	cb:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", marginx, marginy)
+	cb:SetScript("OnClick", function(self)
+		ptable.TempConfig[name] = self:GetChecked() == 1
+	end)
+	return cb
+end
+]]--

 -- 'Enable' CheckBox
 local Enable = CreateFrame("CheckButton", O.."Enable", OptionsPanel, "OptionsCheckButtonTemplate")
@@ -140,6 +151,12 @@ Debug:SetScript("OnClick", function(self)
 	ptable.TempConfig.debug = self:GetChecked() == 1
 end)

+local ShareQuests = CreateFrame("CheckButton", O.."ShareQuests", OptionsPanel, "OptionsCheckButtonTemplate")
+_G[ShareQuests:GetName().."Text"]:SetText(L["ShareQuestsLabel"])
+ShareQuests:SetScript("OnClick", function(self)
+	ptable.TempConfig.questshare = self:GetChecked() == 1
+end)
+
 -- Auto toggle key
 local ToggleKeyLabel = OptionsPanel:CreateFontString(nil, "ARTWORK", "GameFontNormal")
 ToggleKeyLabel:SetText(L["togglekey"])
@@ -177,24 +194,25 @@ end)
 title:SetPoint("TOPLEFT", 16, -16)
 subText:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
 ResetButton:SetPoint("TOPRIGHT", OptionsPanel, "TOPRIGHT", -10, -10)
-Enable:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16)
+Enable:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -14)
 QuestLabel:SetPoint("BOTTOMLEFT", QuestDropDown, "TOPLEFT", 18, 0)
-QuestDropDown:SetPoint("TOPLEFT", Enable, "BOTTOMLEFT", -15, -30)
+QuestDropDown:SetPoint("TOPLEFT", Enable, "BOTTOMLEFT", -15, -22)
 TrivialQuests:SetPoint("TOPLEFT", QuestDropDown, "TOPRIGHT", 30, 0)
 LootLabel:SetPoint("BOTTOMLEFT", LootDropDown, "TOPLEFT", 18, 0)
-LootDropDown:SetPoint("TOPLEFT", QuestDropDown, "BOTTOMLEFT", 0, -30)
+LootDropDown:SetPoint("TOPLEFT", QuestDropDown, "BOTTOMLEFT", 0, -22)
 TournamentDropDownLabel:SetPoint("BOTTOMLEFT", TournamentDropDown, "TOPLEFT", 18, 0)
 TournamentDropDown:SetPoint("TOPLEFT", LootDropDown, "TOPRIGHT", 17, 0)
-EquipReward:SetPoint("TOPLEFT", LootDropDown, "BOTTOMLEFT", 16, -14)
-ShowRewardText:SetPoint("TOPLEFT", EquipReward, "BOTTOMLEFT", 0, -14)
-ToDarkMoon:SetPoint("TOPLEFT", ShowRewardText, "BOTTOMLEFT", 0, -14)
-DarkMoonCannon:SetPoint("TOPLEFT", ToDarkMoon, "BOTTOMLEFT", 0, -14)
-DarkMoonAutoStart:SetPoint("TOPLEFT", DarkMoonCannon, "BOTTOMLEFT", 0, -14)
-Debug:SetPoint("TOPLEFT", ResetButton, "BOTTOMLEFT", 0, -14)
+EquipReward:SetPoint("TOPLEFT", LootDropDown, "BOTTOMLEFT", 16, -10)
+ShowRewardText:SetPoint("TOPLEFT", EquipReward, "BOTTOMLEFT", 0, -10)
+ToDarkMoon:SetPoint("TOPLEFT", ShowRewardText, "BOTTOMLEFT", 0, -10)
+DarkMoonCannon:SetPoint("TOPLEFT", ToDarkMoon, "BOTTOMLEFT", 0, -10)
+DarkMoonAutoStart:SetPoint("TOPLEFT", DarkMoonCannon, "BOTTOMLEFT", 0, -10)
+Debug:SetPoint("TOPLEFT", ResetButton, "BOTTOMLEFT", 0, -10)
 ToggleKeyLabel:SetPoint("BOTTOMLEFT", ToggleKeyDropDown, "TOPLEFT", 18, 0)
-ToggleKeyDropDown:SetPoint("TOPLEFT", DarkMoonAutoStart, "BOTTOMLEFT", -15, -30)
-ShowQuestLevel:SetPoint("TOPLEFT", ToggleKeyDropDown, "BOTTOMLEFT", 16, -14)
-ShowWatchLevel:SetPoint("TOPLEFT", ShowQuestLevel, "BOTTOMLEFT", 0, -14)
+ToggleKeyDropDown:SetPoint("TOPLEFT", DarkMoonAutoStart, "BOTTOMLEFT", -15, -22)
+ShowQuestLevel:SetPoint("TOPLEFT", ToggleKeyDropDown, "BOTTOMLEFT", 16, -10)
+ShowWatchLevel:SetPoint("TOPLEFT", ShowQuestLevel, "BOTTOMLEFT", 0, -10)
+ShareQuests:SetPoint("TOPLEFT", ShowWatchLevel, "BOTTOMLEFT", 0, -10)

 OptionsPanel.refresh = function()
 	if ( MakeACopy ) then
@@ -218,8 +236,9 @@ OptionsPanel.refresh = function()
 	EquipReward:SetChecked(ptable.TempConfig.autoequip)
 	Debug:SetChecked(ptable.TempConfig.debug)
 	TrivialQuests:SetChecked(ptable.TempConfig.trivial)
-	ShowQuestLevel:SetChecked(ptable.TempConfig.questlevel)
-	ShowWatchLevel:SetChecked(ptable.TempConfig.watchlevel)
+	ShowQuestLevel:SetChecked(ptable.TempConfig.questlevel)
+	ShowWatchLevel:SetChecked(ptable.TempConfig.watchlevel)
+	ShareQuests:SetChecked(ptable.TempConfig.questshare)

 	UIDropDownMenu_SetSelectedID(ToggleKeyDropDown, ptable.TempConfig.togglekey)
 	UIDropDownMenu_SetText(ToggleKeyDropDown,  ToggleKeyConst[ptable.TempConfig.togglekey])