diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua index 4417aff..908f696 100644 --- a/ElvUI_SLE/defaults/profile.lua +++ b/ElvUI_SLE/defaults/profile.lua @@ -233,12 +233,15 @@ P['sle'] = { --Loot (Restructured) ['loot'] = { ['enable'] = false, - ['autoconfirm'] = false, - ['autode'] = false, - ['autogreed'] = false, - ['autoqlty'] = 2, - ['bylevel'] = false, - ['level'] = 1, + ['autoroll'] = { + ['enable'] = true, + ['autoconfirm'] = false, + ['autode'] = false, + ['autogreed'] = false, + ['autoqlty'] = 2, + ['bylevel'] = false, + ['level'] = 1, + }, ['announcer'] = { ['enable'] = false, ['auto'] = true, diff --git a/ElvUI_SLE/modules/loot.lua b/ElvUI_SLE/modules/loot.lua index a79465a..ce62c57 100644 --- a/ElvUI_SLE/modules/loot.lua +++ b/ElvUI_SLE/modules/loot.lua @@ -30,6 +30,43 @@ local function Check() return false end +local function ModifierCheck() + local heldModifier = E.db.sle.loot.announcer.override + local shiftDown = IsShiftKeyDown(); + local ctrlDown = IsControlKeyDown(); + local altDown = IsAltKeyDown(); + + if heldModifier == 3 and shiftDown then + return true + elseif heldModifier == 4 and ctrlDown then + return true + elseif heldModifier == 5 and altDown then + return true + elseif heldModifier == 2 then + return true + end + + return false +end + +--[[Debug Stuff +function LT:MODIFIER_STATE_CHANGED(event) + local shiftDown = IsShiftKeyDown(); + local ctrlDown = IsControlKeyDown(); + local altDown = IsAltKeyDown(); + + if shiftDown then + print("Shift") + end + if ctrlDown then + print("Control") + end + if altDown then + print("Alt") + end +end +]] + local function Merge() local p, k for i = 1, #loot do @@ -96,7 +133,8 @@ local function Announce(event) local m = 0 local q = E.db.sle.loot.announcer.quality == "EPIC" and 4 or E.db.sle.loot.announcer.quality == "RARE" and 3 or E.db.sle.loot.announcer.quality == "UNCOMMON" and 2 - if (Check() and E.db.sle.loot.announcer.auto) or (IsLeftControlKeyDown() and (IsInGroup() or IsInRaid())) then + if (Check() and E.db.sle.loot.announcer.auto) or (ModifierCheck() and (IsInGroup() or IsInRaid())) then + --if (Check() and E.db.sle.loot.announcer.auto) or (IsLeftControlKeyDown() and (IsInGroup() or IsInRaid())) then for i = 1, GetNumLootItems() do if GetLootSlotType(i) == 1 then for j = 1, t do @@ -107,7 +145,7 @@ local function Announce(event) end end - if check == false or IsLeftControlKeyDown() then + if check == false or ModifierCheck() then PopulateTable(q) if n ~= 0 then SendChatMessage(L["Loot Dropped:"], Channel()) @@ -126,8 +164,8 @@ local function Announce(event) end local function HandleRoll(event, id) - if not E.db.sle.loot.enable then return end - if not (E.db.sle.loot.autogreed or E.db.sle.loot.autode) then return end + if not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable then return end + if not (E.db.sle.loot.autoroll.autogreed or E.db.sle.loot.autoroll.autode) then return end local _, name, _, quality, _, _, _, disenchant = GetLootRollItemInfo(id) local link = GetLootRollItemLink(id) @@ -138,9 +176,9 @@ local function HandleRoll(event, id) end if IsXPUserDisabled() then MaxPlayerLevel = PlayerLevel end - if (E.db.sle.loot.bylevel and PlayerLevel < E.db.sle.loot.level) and PlayerLevel ~= MaxPlayerLevel then return end + if (E.db.sle.loot.autoroll.bylevel and PlayerLevel < E.db.sle.loot.autoroll.level) and PlayerLevel ~= MaxPlayerLevel then return end - if E.db.sle.loot.bylevel then + if E.db.sle.loot.autoroll.bylevel then if IsEquippableItem(link) then local _, _, _, ilvl, _, _, _, _, slot = GetItemInfo(link) local itemLink = GetInventoryItemLink('player', slot) @@ -149,8 +187,8 @@ local function HandleRoll(event, id) end end - if quality <= E.db.sle.loot.autoqlty then - if E.db.sle.loot.autode and disenchant then + if quality <= E.db.sle.loot.autoroll.autoqlty then + if E.db.sle.loot.autoroll.autode and disenchant then RollOnLoot(id, 3) else RollOnLoot(id, 2) @@ -165,7 +203,7 @@ local function HandleEvent(event, ...) end end - if not E.db.sle.loot.autoconfirm then return end + if not E.db.sle.loot.autoroll.autoconfirm then return end if event == "CONFIRM_LOOT_ROLL" or event == "CONFIRM_DISENCHANT_ROLL" then local arg1, arg2 = ... ConfirmLootRoll(arg1, arg2) @@ -181,57 +219,91 @@ end local function LoadConfig(event, addon) if addon ~= "ElvUI_Config" then return end - E.Options.args.general.args.general.args.autoRoll.disabled = function() return true end - + LT:Update() LT:UnregisterEvent("ADDON_LOADED") end -function LT:Update() +function LT:LoadLoot() MaxPlayerLevel = GetMaxPlayerLevel() PlayerLevel = UnitLevel('player') - if E.db.general then - E.db.general.autoRoll= false - end - --Azil made this, blame him if something fucked up UIParent:UnregisterEvent("LOOT_BIND_CONFIRM") --Solo UIParent:UnregisterEvent("CONFIRM_DISENCHANT_ROLL") --Group UIParent:UnregisterEvent("CONFIRM_LOOT_ROLL") --Group - + + if E.db.general and E.db.sle.loot.autoroll.enable then + E.db.general.autoRoll = false + end + if E.db.sle.loot.enable then - self:RegisterEvent("CONFIRM_DISENCHANT_ROLL", HandleEvent) - self:RegisterEvent("CONFIRM_LOOT_ROLL", HandleEvent) - self:RegisterEvent("LOOT_BIND_CONFIRM", HandleEvent) self:RegisterEvent("LOOT_OPENED", HandleEvent) self:RegisterEvent('PLAYER_ENTERING_WORLD', 'LootShow'); self:RegisterEvent("ADDON_LOADED", LoadConfig) else - self:UnregisterEvent("CONFIRM_DISENCHANT_ROLL") - self:UnregisterEvent("CONFIRM_LOOT_ROLL") - self:UnregisterEvent("LOOT_BIND_CONFIRM") self:UnregisterEvent("LOOT_OPENED") self:UnregisterEvent('PLAYER_ENTERING_WORLD') self:UnregisterEvent("ADDON_LOADED") end + + if E.db.sle.loot.autoroll.autoconfirm then + self:RegisterEvent("CONFIRM_DISENCHANT_ROLL", HandleEvent) + self:RegisterEvent("CONFIRM_LOOT_ROLL", HandleEvent) + self:RegisterEvent("LOOT_BIND_CONFIRM", HandleEvent) + else + self:UnregisterEvent("CONFIRM_DISENCHANT_ROLL") + self:UnregisterEvent("CONFIRM_LOOT_ROLL") + self:UnregisterEvent("LOOT_BIND_CONFIRM") + end + --if E.db.sle.loot.enable then + --self:RegisterEvent("CONFIRM_DISENCHANT_ROLL", HandleEvent) + --self:RegisterEvent("CONFIRM_LOOT_ROLL", HandleEvent) + --self:RegisterEvent("LOOT_BIND_CONFIRM", HandleEvent) + --self:RegisterEvent("LOOT_OPENED", HandleEvent) + --self:RegisterEvent('PLAYER_ENTERING_WORLD', 'LootShow'); + --self:RegisterEvent("ADDON_LOADED", LoadConfig) + --else + --self:UnregisterEvent("CONFIRM_DISENCHANT_ROLL") + --self:UnregisterEvent("CONFIRM_LOOT_ROLL") + --self:UnregisterEvent("LOOT_BIND_CONFIRM") + --self:UnregisterEvent("LOOT_OPENED") + --self:UnregisterEvent('PLAYER_ENTERING_WORLD') + --self:UnregisterEvent("ADDON_LOADED") + --end end function LT:LootShow() local instance = IsInInstance() - LootHistoryFrame:SetAlpha(E.db.sle.loot.history.alpha or 1) + --LootHistoryFrame:SetAlpha(E.db.sle.loot.history.alpha or 1) if (not instance and E.db.sle.loot.history.autohide) then LootHistoryFrame:Hide() end end +function LT:Update() + if E.db.sle.loot.autoroll.enable then + E.Options.args.general.args.general.args.autoRoll.disabled = function() return true end + else + E.Options.args.general.args.general.args.autoRoll.disabled = function() return false end + end + + LootHistoryFrame:SetAlpha(E.db.sle.loot.history.alpha or 1) +end + + function LT:PLAYER_LEVEL_UP(event, level) PlayerLevel = level end function LT:Initialize() - hooksecurefunc(M, 'START_LOOT_ROLL', function(self, event, id) HandleRoll(event, id) end) if not E.db.sle.loot.enable then return end + + --Used to debug + --self:RegisterEvent('MODIFIER_STATE_CHANGED') + + hooksecurefunc(M, 'START_LOOT_ROLL', function(self, event, id) HandleRoll(event, id) end) + LT:LoadLoot() LT:Update() end \ No newline at end of file diff --git a/ElvUI_SLE/options/loot_c.lua b/ElvUI_SLE/options/loot_c.lua index 5278bd9..7182906 100644 --- a/ElvUI_SLE/options/loot_c.lua +++ b/ElvUI_SLE/options/loot_c.lua @@ -24,70 +24,104 @@ local function configTable() type = "group", name = "Loot Auto Roll", args = { - autoconfirm = { + header = { + order = 1, + type = "header", + name = L['Loot Announcer'], + }, + info = { + order = 2, + type = "description", + name = L["LOOT_DESC"], + }, + space1 = { order = 3, + type = 'description', + name = "", + }, + enable = { + order = 4, type = "toggle", - name = "Auto Confirm", + name = L["Enable"], desc = "Automatically click OK on BOP items", disabled = function() return not E.db.sle.loot.enable end, + get = function(info) return E.db.sle.loot.autoroll.enable end, + set = function(info, value) E.db.sle.loot.autoroll.enable = value; LT:Update() end, + }, + space2 = { + order = 5, + type = 'description', + name = "", + }, + autoconfirm = { + order = 6, + type = "toggle", + name = "Auto Confirm", + desc = "Automatically click OK on BOP items", + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable end, get = function(info) return E.db.sle.loot.autoconfirm end, - set = function(info, value) E.db.sle.loot.autoconfirm = value; end, + set = function(info, value) E.db.sle.loot.autoconfirm = value end, }, autogreed = { - order = 4, + order = 7, type = "toggle", name = "Auto Greed", desc = "Automatically greed uncommon (green) quality items at max level", - disabled = function() return not E.db.sle.loot.enable end, + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable end, get = function(info) return E.db.sle.loot.autogreed end, - set = function(info, value) E.db.sle.loot.autogreed = value; end, + set = function(info, value) E.db.sle.loot.autogreed = value end, }, autode = { - order = 5, + order = 8, type = "toggle", name = "Auto Disenchant", desc = "Automatically disenchant uncommon (green) quality items at max level", - disabled = function() return not E.db.sle.loot.enable end, + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable end, get = function(info) return E.db.sle.loot.autode end, set = function(info, value) E.db.sle.loot.autode = value; end, }, + autoqlty = { + order = 9, + type = "select", + name = L["Loot Quality"], + desc = "Sets the auto greed/disenchant quality\n\nUncommon: Rolls on Uncommon only\nRare: Rolls on Rares & Uncommon", + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable end, + get = function(info) return E.db.sle.loot.autoqlty end, + set = function(info, value) E.db.sle.loot.autoqlty = value; end, + values = { + [4] = "|cffA335EE"..ITEM_QUALITY4_DESC.."|r", + [3] = "|cff0070DD"..ITEM_QUALITY3_DESC.."|r", + [2] = "|cff1EFF00"..ITEM_QUALITY2_DESC.."|r", + }, + }, + space3 = { + order = 10, + type = 'description', + name = "", + }, bylevel = { - order = 6, + order = 11, type = "toggle", name = "Roll based on level.", desc = "This will auto-roll if you are above the given level if: You cannot equip the item being rolled on, or the ilevel of your equipped item is higher than the item being rolled on or you have an heirloom equipped in that slot", - disabled = function() return not E.db.sle.loot.enable end, + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable end, get = function(info) return E.db.sle.loot.bylevel end, set = function(info, value) E.db.sle.loot.bylevel = value; end, }, level = { - order = 7, + order = 12, type = "range", name = "Level to start auto-rolling from", desc = "Automatically disenchant uncommon (green) quality items at max level", - disabled = function() return not E.db.sle.loot.enable end, + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.autoroll.enable end, min = 1, max = GetMaxPlayerLevel(), step = 1, get = function(info) return E.db.sle.loot.level end, set = function(info, value) E.db.sle.loot.level = value; end, }, - autoqlty = { - order = 9, - type = "select", - name = L["Loot Quality"], - desc = "Sets the auto greed/disenchant quality\n\nUncommon: Rolls on Uncommon only\nRare: Rolls on Rares & Uncommon", - disabled = function() return not E.db.sle.loot.enable end, - get = function(info) return E.db.sle.loot.autoqlty end, - set = function(info, value) E.db.sle.loot.autoqlty = value; end, - values = { - [4] = "|cffA335EE"..ITEM_QUALITY4_DESC.."|r", - [3] = "|cff0070DD"..ITEM_QUALITY3_DESC.."|r", - [2] = "|cff1EFF00"..ITEM_QUALITY2_DESC.."|r", - }, - }, }, }, announcer = { - order = 9, + order = 2, type = "group", name = L["Loot Announcer"], args = { @@ -101,25 +135,51 @@ local function configTable() type = "description", name = L["LOOT_DESC"], }, - enable = { + space1 = { order = 3, + type = 'description', + name = "", + }, + enable = { + order = 4, type = "toggle", name = L["Enable"], disabled = function() return not E.db.sle.loot.enable end, get = function(info) return E.db.sle.loot.announcer.enable end, - set = function(info, value) E.db.sle.loot.announcer.enable = value; E:StaticPopup_Show("CONFIG_RL") end + set = function(info, value) E.db.sle.loot.announcer.enable = value; E:StaticPopup_Show("CONFIG_RL") end, + }, + space2 = { + order = 5, + type = "description", + name = "", }, auto = { - order = 4, + order = 6, type = "toggle", name = L["Auto Announce"], desc = L["AUTOANNOUNCE_DESC"], disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end, get = function(info) return E.db.sle.loot.announcer.auto end, - set = function(info, value) E.db.sle.loot.announcer.auto = value; end + set = function(info, value) E.db.sle.loot.announcer.auto = value; end, }, - spacer = { - order = 5, + override = { + order = 7, + type = "select", + name = L["Manual Override"], + desc = L["Sets the minimum loot threshold to announce."], + disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end, + get = function(info) return E.db.sle.loot.announcer.override end, + set = function(info, value) E.db.sle.loot.announcer.override = value; end, + values = { + ['1'] = "No Override", + ['2'] = "Automatic Override", + ['3'] = "SHIFT Required", + ['4'] = "ALT Required", + ['5'] = "CTRL Required", + }, + }, + space3 = { + order = 8, type = "description", name = "", }, @@ -130,7 +190,7 @@ local function configTable() desc = L["Sets the minimum loot threshold to announce."], disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end, get = function(info) return E.db.sle.loot.announcer.quality end, - set = function(info, value) E.db.sle.loot.announcer.quality = value; end, + set = function(info, value) E.db.sle.loot.announcer.quality = value; end, values = { ['EPIC'] = "|cffA335EE"..ITEM_QUALITY4_DESC.."|r", ['RARE'] = "|cff0070DD"..ITEM_QUALITY3_DESC.."|r", @@ -144,7 +204,7 @@ local function configTable() desc = L["Select chat channel to announce loot to."], disabled = function() return not E.db.sle.loot.enable or not E.db.sle.loot.announcer.enable end, get = function(info) return E.db.sle.loot.announcer.channel end, - set = function(info, value) E.db.sle.loot.announcer.channel = value; end, + set = function(info, value) E.db.sle.loot.announcer.channel = value; end, values = { ['RAID'] = "|cffFF7F00"..RAID.."|r", ['PARTY'] = "|cffAAAAFF"..PARTY.."|r", @@ -154,7 +214,7 @@ local function configTable() }, }, history = { - order = 10, + order = 3, type = "group", name = L["Loot Roll History"], args = { @@ -175,7 +235,7 @@ local function configTable() desc = L["Automaticaly hides Loot Roll Histroy frame when leaving the instance."], disabled = function() return not E.db.sle.loot.enable end, get = function(info) return E.db.sle.loot.history.autohide end, - set = function(info, value) E.db.sle.loot.history.autohide = value; LT:LootShow() end + set = function(info, value) E.db.sle.loot.history.autohide = value; LT:LootShow() end, }, alpha = { order = 4, @@ -185,7 +245,7 @@ local function configTable() min = 0.2, max = 1, step = 0.1, disabled = function() return not E.db.sle.loot.enable end, get = function(info) return E.db.sle.loot.history.alpha end, - set = function(info, value) E.db.sle.loot.history.alpha = value; LT:LootShow() end, + set = function(info, value) E.db.sle.loot.history.alpha = value; LT:Update() end, }, }, },