diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index 7d56f67..e2bb7fb 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -50,9 +50,10 @@ function AutoTurnIn:OnEnable()
if (tonumber(AutoTurnInCharacterDB.togglekey) == nil) then
AutoTurnInCharacterDB.togglekey = 1
end
- if ( AutoTurnInCharacterDB.items == nil ) then
- AutoTurnInCharacterDB.items = {}
- end
+
+ AutoTurnInCharacterDB.items = AutoTurnInCharacterDB.items and AutoTurnInCharacterDB.items or {}
+ AutoTurnInCharacterDB.stats = AutoTurnInCharacterDB.stats and AutoTurnInCharacterDB.stats or {}
+
local LDB = LibStub:GetLibrary("LibDataBroker-1.1", true)
if LDB then
@@ -215,17 +216,16 @@ function AutoTurnIn:QUEST_PROGRESS()
end
end
-local function IsRangedWeapon(subclass)
- return (AutoTurnInCharacterDB.items['Ranged'] and (C.ITEMS['Crossbows'] == subclass or
- C.ITEMS['Guns'] == subclass or
- C.ITEMS['Bows'] == subclass))
+local function IsRangedAndRequired(subclass)
+ return (AutoTurnInCharacterDB.items['Ranged'] and
+ (C.ITEMS['Crossbows'] == subclass or C.ITEMS['Guns'] == subclass or C.ITEMS['Bows'] == subclass))
end
-local function IsJewelry(equipSlot)
+local function IsJewelryAndRequired(equipSlot)
return AutoTurnInCharacterDB.items['Jewelry'] and (C.JEWELRY[equipSlot])
end
---doesn't work. Frame appear faster than items loaded. Need rework. It is called nowhere right now
+--[[ doesn't work. Frame appear faster than items loaded. Need rework. It is called nowhere right now
local function TryToLoadRewards()
local title = GetTitleText()
numEntries = GetNumQuestLogEntries()
@@ -241,19 +241,17 @@ local function TryToLoadRewards()
end
end
end
-end
+end]]--
function AutoTurnIn:Greed()
local index, money = 0, 0;
if (AutoTurnInCharacterDB.dontloot == 2) then
for i=1, GetNumQuestChoices() do
-
local link = GetQuestItemLink("choice", i)
if ( link == nil ) then
return
end
-
local m = select(11, GetItemInfo(link))
if m > money then
money = m
@@ -266,7 +264,7 @@ function AutoTurnIn:Greed()
end
end
-local found = {}
+local found, stattable = {}, {}
function AutoTurnIn:Need()
wipe(found)
@@ -274,21 +272,26 @@ function AutoTurnIn:Need()
local link = GetQuestItemLink("choice", i)
if ( link == nil ) then
- return
+ return true
end
local class, subclass, _, equipSlot = select(6, GetItemInfo(link))
- --[[relics and trinkets are out of autoloot
- if C.STOPTOKENS[equipSlot] then
- self:Print(INVTYPE_RELIC..' or ' .. INVTYPE_TRINKET .. ' found. Choose reward manually pls.')
- return
- end]]--
- if AutoTurnInCharacterDB.items[subclass] or IsRangedWeapon(subclass) or IsJewelry(equipSlot) then
- local stattable = GetItemStats(link)
- for stat, value in pairs(stattable) do
- if ( AutoTurnInCharacterDB.items[C.STATS[stat]] ) then
- tinsert(found, i)
+ --[[relics and trinkets are out of autoloot]]--
+ if (UnitHasRelicSlot("player") and 'INVTYPE_RELIC' == equipSlot) or 'INVTYPE_TRINKET' == equipSlot then
+ self:Print(INVTYPE_RELIC .. ' or ' .. INVTYPE_TRINKET.. ' found. Choose reward manually pls.')
+ return true
+ end
+ if AutoTurnInCharacterDB.items[subclass] or IsRangedAndRequired(subclass) or IsJewelryAndRequired(equipSlot) then
+ if next(AutoTurnInCharacterDB.stats) then
+ wipe(stattable)
+ GetItemStats(link, stattable)
+ for stat, value in pairs(stattable) do
+ if ( AutoTurnInCharacterDB.stats[C.STATS[stat]] ) then
+ tinsert(found, i)
+ end
end
+ else
+ tinsert(found, i)
end
end
end
@@ -300,9 +303,15 @@ function AutoTurnIn:Need()
vars = vars..' '..GetQuestItemLink("choice", reward)
end
self:Print("Found few items. Choose manually pls" ..vars)
- elseif(#found == 1) then
+ elseif(#found == 1) then
GetQuestReward(found[1])
end
+
+ if (#found == 0) then
+ return false
+ else
+ return true
+ end
end
function AutoTurnIn:QUEST_COMPLETE()
@@ -312,7 +321,7 @@ function AutoTurnIn:QUEST_COMPLETE()
end
if (AutoTurnInCharacterDB.showrewardtext) then
- self:Print( UnitName("target") and UnitName("target") or '' .. GetRewardText())
+ self:Print((UnitName("target") and UnitName("target") or '')..'\n', GetRewardText())
end
local quest = L.quests[GetTitleText()]
@@ -324,9 +333,11 @@ function AutoTurnIn:QUEST_COMPLETE()
GetQuestReward(AutoTurnInCharacterDB.tournament)
return
end
+ local forceGreed = false
if (AutoTurnInCharacterDB.dontloot == 3) then
- self:Need()
- elseif (AutoTurnInCharacterDB.dontloot == 2) then
+ forceGreed = (not self:Need() ) and AutoTurnInCharacterDB.greedifnothingfound
+ end
+ if (AutoTurnInCharacterDB.dontloot == 2 or forceGreed) then
self:Greed()
end
end
diff --git a/RewardOptions.lua b/RewardOptions.lua
index 6e90524..e4d3cab 100644
--- a/RewardOptions.lua
+++ b/RewardOptions.lua
@@ -1,15 +1,16 @@
local addonName, ptable = ...
local C = ptable.CONST
+local L = ptable.L
local O = addonName .. "RewardPanel"
local RewardPanel = CreateFrame("Frame", O)
-RewardPanel.name= QUEST_REWARDS
+RewardPanel.name = QUEST_REWARDS
local function CreateCheckbox(name, parent, marginx, marginy, text)
local cb = CreateFrame("CheckButton", "$parent"..name, parent, "OptionsCheckButtonTemplate")
cb:SetPoint("TOPLEFT", parent, marginx, marginy)
_G[cb:GetName().."Text"]:SetText(text and text or name)
cb:SetScript("OnClick", function(self)
- ptable.TempConfig.items[name] = self:GetChecked() == 1
+ parent.GetConfig()[name] = self:GetChecked() == 1 and true or nil
end)
tinsert(parent.buttons, cb)
return cb
@@ -20,18 +21,22 @@ local function CreatePanel(name, text, w, h)
panel:SetWidth(w)
panel:SetHeight(h)
panel.buttons = {}
+ panel.config=config
function panel:ClearCheckBoxes()
for k,v in ipairs(self.buttons) do
v:SetChecked(false)
end
end
+ function panel:GetConfig()
+ return name == "StatPanel" and ptable.TempConfig.stats or ptable.TempConfig.items
+ end
_G[panel:GetName().."Title"]:SetText(text)
return panel
end
-- Description
local description = RewardPanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
-description:SetText("Reward loot options")
+description:SetText(L["rewardlootoptions"])
RewardPanel.parent = _G["AutoTurnInOptionsPanel"]
local weapon = {GetAuctionItemSubClasses(1)}
@@ -65,7 +70,7 @@ CreateCheckbox(armor[4], ArmorPanel, 292, -8)
CreateCheckbox(armor[5], ArmorPanel, 436, -8)
-- 2nd line
CreateCheckbox(armor[6], ArmorPanel, 10, -40)
-CreateCheckbox("Jewelry", ArmorPanel, 292, -40, ptable.L['Jewelry'] )
+CreateCheckbox("Jewelry", ArmorPanel, 292, -40, L['Jewelry'] )
-- ATTRIBUTES
local StatPanel = CreatePanel("StatPanel", STAT_CATEGORY_ATTRIBUTES, 590, 40)
@@ -74,34 +79,41 @@ CreateCheckbox("Agility", StatPanel, 152, -8, SPELL_STAT2_NAME)
CreateCheckbox("Intellect", StatPanel, 292, -8, SPELL_STAT4_NAME)
CreateCheckbox("Spirit", StatPanel, 436, -8, SPELL_STAT5_NAME)
+-- 'Enable' CheckBox
+local GreedAfterNeed = CreateFrame("CheckButton", O.."Enable", RewardPanel, "OptionsCheckButtonTemplate")
+_G[GreedAfterNeed:GetName().."Text"]:SetText(L["greedifnothing"])
+GreedAfterNeed:SetScript("OnClick", function(self)
+ ptable.TempConfig.greedifnothingfound = self:GetChecked() == 1
+end)
+
--[[ CONTROL PLACEMENT]]--
description:SetPoint("TOPLEFT", 16, -8)
WeaponPanel:SetPoint("TOPLEFT", description, "BOTTOMLEFT", 0, -20)
ArmorPanel:SetPoint("TOPLEFT", WeaponPanel, "BOTTOMLEFT", 0, -20)
StatPanel:SetPoint("TOPLEFT", ArmorPanel, "BOTTOMLEFT", 0, -20)
+GreedAfterNeed:SetPoint("TOPLEFT", StatPanel, "BOTTOMLEFT", 8, -16)
--[[ PANEL FINCTIONS ]]--
RewardPanel.refresh = function()
+
WeaponPanel:ClearCheckBoxes()
ArmorPanel:ClearCheckBoxes()
StatPanel:ClearCheckBoxes()
-
+
for k,v in pairs(ptable.TempConfig.items) do
local w = _G[WeaponPanel:GetName()..k]
- if not w then
- w = _G[ArmorPanel:GetName()..k]
- end
- if not w then
- w = _G[StatPanel:GetName()..k]
- end
- if w then
- w:SetChecked(v)
- end
+ w = w and w or _G[ArmorPanel:GetName()..k]
+ w:SetChecked(v)
+ end
+
+ for k,v in pairs(ptable.TempConfig.stats) do
+ _G[StatPanel:GetName()..k]:SetChecked(v)
end
+
+ GreedAfterNeed:SetChecked(ptable.TempConfig.greedifnothingfound )
end
--RewardPanel.default = function() end
--RewardPanel.okay = function()end
--[[ REGISTERING PANEL ]]--
-InterfaceOptions_AddCategory(RewardPanel)
-
+InterfaceOptions_AddCategory(RewardPanel)
\ No newline at end of file
diff --git a/localization_DE.lua b/localization_DE.lua
index d833f85..fd4b538 100644
--- a/localization_DE.lua
+++ b/localization_DE.lua
@@ -30,7 +30,10 @@ privateTable.L = setmetatable({
["rewardtext"]="Show quest reward text",
["togglekey"]="aktivieren/deaktivieren Taste",
- ['Jewelry']="Juwelier"},
+ ['Jewelry']="Juwelier",
+ ["rewardlootoptions"]="Reward loot rules",
+ ['greedifnothing']='Greed if nothing found'},
+
{__index = function(table, index) return index end})
privateTable.L.quests = {
diff --git a/localization_EN.lua b/localization_EN.lua
index 0591943..cf761cf 100644
--- a/localization_EN.lua
+++ b/localization_EN.lua
@@ -28,7 +28,9 @@ privateTable.L = setmetatable({
["rewardtext"]="Print quest reward text",
["togglekey"]="Enable/disable key",
- ['Jewelry']="Jewelry"},
+ ['Jewelry']="Jewelry",
+ ["rewardlootoptions"]="Reward loot rules",
+ ['greedifnothing']='Greed if nothing found'},
{__index = function(table, index) return index end})
privateTable.L.quests = {
diff --git a/localization_RU.lua b/localization_RU.lua
index 0f03ba4..dfb065d 100644
--- a/localization_RU.lua
+++ b/localization_RU.lua
@@ -31,7 +31,9 @@ privateTable.L = setmetatable({
["rewardtext"]="Показывать финальный текст задания",
["togglekey"]="Клавиша разового включения/отключения",
- ['Jewelry']="Ювелирные украшения"},
+ ['Jewelry']="Ювелирные украшения",
+ ["rewardlootoptions"]="Правила выбора награды",
+ ["greedifnothing"]="Взять самую дорогую, если ничего не нашлось"},
{__index = function(table, index) return index end})
diff --git a/rewards.lua b/rewards.lua
index 578a2d6..d67a43f 100644
--- a/rewards.lua
+++ b/rewards.lua
@@ -5,8 +5,8 @@ local C = ptable.CONST
local weapon = {GetAuctionItemSubClasses(1)}
local armor = {GetAuctionItemSubClasses(2)}
+-- C.STOPTOKENS = {['INVTYPE_RELIC']='', ['INVTYPE_TRINKET']=''}
C.WEAPONLABEL, C.ARMORLABEL = GetAuctionItemClasses()
-C.STOPTOKENS = {['INVTYPE_RELIC']='', ['INVTYPE_TRINKET']=''}
C.JEWELRY = {['INVTYPE_FINGER']='', ['INVTYPE_NECK']=''}
C.STATS = {
['ITEM_MOD_STRENGTH_SHORT'] = "Strength",
@@ -15,6 +15,7 @@ C.STATS = {
['ITEM_MOD_SPIRIT_SHORT'] = "Spirit"
}
+-- Most of the constants are never used but it's convinient to have them here as a reminder and shortcut
C.ITEMS = {
['One-Handed Axes'] = weapon[1],
['Two-Handed Axes'] = weapon[2],