From 130e8050fb79f6a25318080320a1dcdc3c710581 Mon Sep 17 00:00:00 2001 From: Repooc Date: Wed, 13 Mar 2013 06:45:34 -0400 Subject: [PATCH] Add autotrack reputation --- ElvUI_SLE/config/sle_private.lua | 6 ++++- ElvUI_SLE/modules/exprepbar/exprepbar.lua | 35 ++++++++++++++++++++++++++++- ElvUI_SLE/modules/exprepbar/options.lua | 8 +++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/ElvUI_SLE/config/sle_private.lua b/ElvUI_SLE/config/sle_private.lua index 0e91423..0e4073b 100644 --- a/ElvUI_SLE/config/sle_private.lua +++ b/ElvUI_SLE/config/sle_private.lua @@ -22,7 +22,11 @@ V['sle'] = { ["bottomhide"] = false, ["dp6hide"] = false, }, - + + ['exprep'] = { + ['autotrack'] = false, + }, + ['farm'] = { ['enable'] = false, ['seedtrash'] = false, diff --git a/ElvUI_SLE/modules/exprepbar/exprepbar.lua b/ElvUI_SLE/modules/exprepbar/exprepbar.lua index 9b01bf8..bfbbd3d 100644 --- a/ElvUI_SLE/modules/exprepbar/exprepbar.lua +++ b/ElvUI_SLE/modules/exprepbar/exprepbar.lua @@ -118,4 +118,37 @@ function M:UpdateReputation(event) end self:UpdateExpRepAnchors() -end \ No newline at end of file +end + +function M:AutoTrackRep(event, msg) + if not E.private.sle.exprep.autotrack then return end + + local find, gsub, format = string.find, string.gsub, string.format + local factionIncreased = gsub(gsub(FACTION_STANDING_INCREASED, "(%%s)", "(.+)"), "(%%d)", "(.+)") + local factionChanged = gsub(gsub(FACTION_STANDING_CHANGED, "(%%s)", "(.+)"), "(%%d)", "(.+)") + local factionDecreased = gsub(gsub(FACTION_STANDING_DECREASED, "(%%s)", "(.+)"), "(%%d)", "(.+)") + local standing = ('%s:'):format(STANDING) + local reputation = ('%s:'):format(REPUTATION) + + local _, _, faction, amount = find(msg, factionIncreased) + if not faction then _, _, faction, amount = find(msg, factionChanged) or find(msg, factionDecreased) end + if faction then + if faction == GUILD_REPUTATION then + faction = GetGuildInfo("player") + end + + local active = GetWatchedFactionInfo() + for factionIndex = 1, GetNumFactions() do + local name = GetFactionInfo(factionIndex) + if name == faction and name ~= active then + -- check if watch has been disabled by user + local inactive = IsFactionInactive(factionIndex) or SetWatchedFactionIndex(factionIndex) + break + end + end + end +end + +hooksecurefunc(M, "Initialize", function(self,...) + M:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE", 'AutoTrackRep') +end) \ No newline at end of file diff --git a/ElvUI_SLE/modules/exprepbar/options.lua b/ElvUI_SLE/modules/exprepbar/options.lua index a51fac1..4304ead 100644 --- a/ElvUI_SLE/modules/exprepbar/options.lua +++ b/ElvUI_SLE/modules/exprepbar/options.lua @@ -25,6 +25,14 @@ E.Options.args.sle.args.exprep = { get = function(info) return E.db.sle.exprep.replong end, set = function(info, value) E.db.sle.exprep.replong = value; M:UpdateReputation() end }, + autotrackrep = { + order = 3, + type = "toggle", + name = L["Auto Track Reputation"], + desc = L["Automatically changes reputation bar to most recent reputation changed."], + get = function(info) return E.private.sle.exprep.autotrack end, + set = function(info, value) E.private.sle.exprep.autotrack = value; end + }, }, } end -- 1.7.9.5