From c86f3cc8b42e5e59b5c58cb5b9dd0681ee43205f Mon Sep 17 00:00:00 2001 From: "Erik L. Vonderscheer" Date: Fri, 10 Jul 2009 07:51:29 +0000 Subject: [PATCH] Typo causing reset buttons to error out fixed Added all strings to locale Keys are no longer necessary when adding filter or list patterns Cleaned up debugging output, will now show what pattern that was matched to allow it to not be filtered --- Docs/main.txt | 2 +- TradeFilter3.lua | 34 +++++++++------- TradeFilter3.toc | 8 ++-- TradeFilter3Options.lua | 102 +++++++++++++++++++++-------------------------- 4 files changed, 69 insertions(+), 77 deletions(-) diff --git a/Docs/main.txt b/Docs/main.txt index 9e9b944..68cf57f 100644 --- a/Docs/main.txt +++ b/Docs/main.txt @@ -40,7 +40,7 @@ Adding a set, ie [xXyY], will attempt to find a match for any character given in Nothing planned ==== ChangeLog -*r130 +*r131 **++Repeat filtration++\\ **++Configurable number of repeats before filtered++\\ **++Configurable time required between repeats in seconds++\\ diff --git a/TradeFilter3.lua b/TradeFilter3.lua index 0eed3db..3282da7 100644 --- a/TradeFilter3.lua +++ b/TradeFilter3.lua @@ -38,9 +38,9 @@ local friends = LibStub("LibFriends-1.0") local TF3 = TradeFilter3 local MAJOR_VERSION = "3.0" -local MINOR_VERSION = 000 + tonumber(("$Revision: 120 $"):match("%d+")) +local MINOR_VERSION = 000 + tonumber(("$Revision: @project-revision@ $"):match("%d+")) TF3.version = MAJOR_VERSION .. "." .. MINOR_VERSION -TF3.date = string.sub("$Date: 2009-07-03T15:59:07Z $", 8, 17) +TF3.date = string.sub("$Date: @file-date-iso@ $", 8, 17) --[[ Locals ]]-- local _G = _G @@ -52,8 +52,8 @@ local formatIt = _G.string.format local friendCache = {} local repeatdata = {} local currentFriend -local redirectFrame = "SPAM" -local debugFrame = "DEBUG" +local redirectFrame = L["redirectFrame"] +local debugFrame = L["debugFrame"] local lastmsg local lastuserID @@ -95,7 +95,7 @@ function TF3:OnInitialize() local AC = LibStub("AceConsole-3.0") AC:RegisterChatCommand("tf", function() TF3:OpenOptions() end) AC:RegisterChatCommand("filter", function() TF3:OpenOptions() end) - AC:Print("|cFF33FF99TradeFilter3|r: " .. MAJOR_VERSION .. "." .. MINOR_VERSION .. " |cff00ff00Loaded!|r") + AC:Print(L.TOC.Title .. " " .. MAJOR_VERSION .. "." .. MINOR_VERSION .. " " .. L["LOADED"]) local ACR = LibStub("AceConfigRegistry-3.0") ACR:RegisterOptionsTable("TradeFilter3", options) @@ -135,6 +135,7 @@ function TF3:IsLoggedIn() friends.RegisterCallback(self, "Added") friends.RegisterCallback(self, "Removed") self:UnregisterEvent("PLAYER_LOGIN") + self:UnregisterEvent("FRIENDLIST_UPDATE") end --[[ Friends Functions - Stolen from AuldLangSyne Sync module ]]-- @@ -146,6 +147,7 @@ function TF3:GetFriends() local name = GetFriendInfo(i) if name then friends[name] = true + print(name .. " " .. L["FADD"]) end end end @@ -162,6 +164,7 @@ end function TF3:Added(event, name) if name ~= UnitName("player") then self.db.profile.friendslist[name] = true + print(name .. " " .. L["FADD"]) end if currentFriend then self:GetFriends() @@ -171,6 +174,7 @@ end function TF3:Removed(event, name) if self.db.profile.friendslist[name] ~= nil then self.db.profile.friendslist[name] = nil + print(name .. " " .. L["FREM"]) end if currentFriend then self:GetFriends() @@ -363,32 +367,32 @@ function TF3:FilterFunc(...) local chanID = arg8 or select(8, ...) local msg = lower(msg) if (chanID == 1) then - chan = "1. General" + chan = "1. " .. L["General"] elseif (zoneID == 2) then - chan = "2. Trade" + chan = "2. " .. L["Trade"] elseif (zoneID == 26) then - chan = "26. LFG" + chan = "26. " .. L["LFG"] else - chan = "0. Say/Yell" + chan = "0. " .. L["Say/Yell"] end if (filterFuncList and TF3.db.profile.turnOn) then filtered = true --@alpha@ if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, "arg1: " .. msg .. " userID: " .. userID) + TF3:FindFrame(debugFrame, "|cFFC08080[" .. chan .. "]|r |cFFD9D9D9[" .. userID .. "]:|r |cFFC08080" .. msg .. "|r") end --@end-alpha@ if (zoneID == 2) then for i,v in pairs(TF3.db.profile.filters.TRADE) do --@alpha@ if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, "Checking for Match with " .. v) + TF3:FindFrame(debugFrame, L["CFM"] .. " " .. v) end --@end-alpha@ if (find(msg,v)) then --@alpha@ if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, "|cff00ff00**** Matched ***|r") + TF3:FindFrame(debugFrame, L["MATCHED"] .. " |cffff8080" .. v .. "|r") end --@end-alpha@ filtered = false @@ -398,13 +402,13 @@ function TF3:FilterFunc(...) for i,v in pairs(TF3.db.profile.filters.BASE) do --@alpha@ if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, "Checking for Match with " .. v) + TF3:FindFrame(debugFrame, L["CFM"] .. " " .. v) end --@end-alpha@ if (find(msg,v)) then --@alpha@ if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, "|cff00ff00**** Matched ***|r") + TF3:FindFrame(debugFrame, L["MATCHED"] .. " |cffff8080" .. v .. "|r") end --@end-alpha@ filtered = false @@ -415,7 +419,7 @@ function TF3:FilterFunc(...) if (lastmsg ~= msg or lastuserID ~= userID) then --@alpha@ if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, "|cff00ff00*** NO Match - Redirected ***|r") + TF3:FindFrame(debugFrame, L["NOMATCH"]) end --@end-alpha@ if (TF3.db.profile.redirect) then diff --git a/TradeFilter3.toc b/TradeFilter3.toc index c5b7a5f..d18caca 100644 --- a/TradeFilter3.toc +++ b/TradeFilter3.toc @@ -3,10 +3,10 @@ ## Title: Trade|cffffffffFilter|r3 SVN: @project-revision@ #@end-alpha@ ## Title: @localization(locale="enUS", key="Title", namespace="ToC")@ -## Title-deDE: @localization(locale="deDE", key="Title", namespace="ToC")@ -## Title-zhCN: @localization(locale="zhCN", key="Title", namespace="ToC")@ -## Title-zhTW: @localization(locale="zhTW", key="Title", namespace="ToC")@ -## Title-frFR: @localization(locale="frFR", key="Title", namespace="ToC")@ +## Title-deDE: @localization(locale="deDE", key="Title", namespace="TOC")@ +## Title-zhCN: @localization(locale="zhCN", key="Title", namespace="TOC")@ +## Title-zhTW: @localization(locale="zhTW", key="Title", namespace="TOC")@ +## Title-frFR: @localization(locale="frFR", key="Title", namespace="TOC")@ #@alpha@ ## Notes: Filter the shit outta trade channel. SVN: @project-revision@ #@end-alpha@ diff --git a/TradeFilter3Options.lua b/TradeFilter3Options.lua index 5864202..c9c003b 100644 --- a/TradeFilter3Options.lua +++ b/TradeFilter3Options.lua @@ -67,10 +67,10 @@ options = { get = function() return TF3.db.profile.turnOn end, set = function() if (TF3.db.profile.turnOn == false) then - print("|cFF33FF99TradeFilter3|r: " .. TF3.version .. " |cff00ff00Enabled|r") + print(L.TOC.Title .. " " .. TF3.version .. " " .. L["ENABLED"]) TF3.db.profile.turnOn = not TF3.db.profile.turnOn else - print("|cFF33FF99TradeFilter3|r: " .. TF3.version .. " |cffff8080Disabled|r") + print(L.TOC.Title .. " " .. TF3.version .. " " .. L["DISABLED"]) TF3.db.profile.turnOn = not TF3.db.profile.turnOn end end, @@ -82,8 +82,8 @@ options = { disabled = function() return not TF3.db.profile.turnOn end, - name = "Channel Selection", - desc = "Channel Selection", + name = L["channelGroup"], + desc = L["channelGroup"], args = { optionsHeader1 = { type = "header", @@ -170,9 +170,9 @@ options = { type = 'execute', order = 3, width = "double", - name = "Reset Trade Filter", - desc = "Reset Trade Filter", - func = function() TF3.db.profile.filters.TRADE = TF3:CopyTable(L.FILTER.TRADE, true) end, + name = L["RTF"], + desc = L["RTF"], + func = function() TF3.db.profile.filters.TRADE = TF3:CopyTable(L.FILTERS.TRADE, true) end, }, tradefilters = { type = 'input', @@ -185,25 +185,22 @@ options = { name = L["BTF"], --~ desc = L["BTF"], get = function(info) - local ret = '' + local ret = "" for k, v in pairs(TF3.db.profile.filters.TRADE) do - if ret == '' then - ret = k..' = '..v + if ret == "" then + ret = v else - ret = ret..'\n'..k..' = '..v + ret = ret .. "\n" .. v end end return ret end, set = function(info, value) TF3:ClearTable(TF3.db.profile.filters.TRADE) - local tbl = { strsplit('\n', value) } - local type, val - for i, str in pairs(tbl) do - type, val = strsplit('=', str) - type = strtrim(type) - val = strtrim(val) - TF3.db.profile.filters.TRADE[type] = val + local tbl = { strsplit("\n", value) } + for k, v in pairs(tbl) do + key = "FILTER" + TF3.db.profile.filters.TRADE[key..k] = v end end, }, @@ -211,9 +208,9 @@ options = { type = 'execute', order = 5, width = "double", - name = "Reset Base Filter", - desc = "Reset Base Filter", - func = function() TF3.db.profile.filters.BASE = TF3:CopyTable(L.FILTER.BASE, true) end, + name = L["RBF"], + desc = L["RBF"], + func = function() TF3.db.profile.filters.BASE = TF3:CopyTable(L.FILTERS.BASE, true) end, }, basefilters = { @@ -225,27 +222,24 @@ options = { order = 6, width = "double", name = L["BCF"], ---~ desc = L["BCF"], + desc = L["BCFD"], get = function(info) - local ret = '' + local ret = "" for k, v in pairs(TF3.db.profile.filters.BASE) do - if ret == '' then - ret = k..' = '..v + if ret == "" then + ret = v else - ret = ret..'\n'..k..' = '..v + ret = ret .. "\n" .. v end end return ret end, set = function(info, value) TF3:ClearTable(TF3.db.profile.filters.BASE) - local tbl = { strsplit('\n', value) } - local type, val - for i, str in pairs(tbl) do - type, val = strsplit('=', str) - type = strtrim(type) - val = strtrim(val) - TF3.db.profile.filters.BASE[type] = val + local tbl = { strsplit("\n", value) } + for k, v in pairs(tbl) do + key = "FILTER" + TF3.db.profile.filters.BASE[key..k] = v end end, }, @@ -279,8 +273,8 @@ options = { type = 'execute', order = 3, width = "double", - name = "Reset Lists", - desc = "Reset Lists", + name = L["RLS"], + desc = L["RLS"], func = function() TF3.db.profile.blacklist = TF3:CopyTable(L.BLACKLIST, true); TF3.db.profile.whitelist = TF3:CopyTable(L.WHITELIST, true) end, }, blist = { @@ -294,25 +288,22 @@ options = { name = L["bLists"], --~ desc = L["bLists"], get = function(info) - local ret = '' + local ret = "" for k, v in pairs(TF3.db.profile.blacklist) do - if ret == '' then - ret = k..' = '..v + if ret == "" then + ret = v else - ret = ret..'\n'..k..' = '..v + ret = ret .. "\n" .. v end end return ret end, set = function(info, value) TF3:ClearTable(TF3.db.profile.blacklist) - local tbl = { strsplit('\n', value) } - local type, val - for i, str in pairs(tbl) do - type, val = strsplit('=', str) - type = strtrim(type) - val = strtrim(val) - TF3.db.profile.blacklist[type] = val + local tbl = { strsplit("\n", value) } + for k, v in pairs(tbl) do + key = "BLIST" + TF3.db.profile.blacklist[key..k] = v end end, }, @@ -327,25 +318,22 @@ options = { name = L["wLists"], --~ desc = L["wLists"], get = function(info) - local ret = '' + local ret = "" for k, v in pairs(TF3.db.profile.whitelist) do - if ret == '' then - ret = k..' = '..v + if ret == "" then + ret = v else - ret = ret..'\n'..k..' = '..v + ret = ret .. "\n" .. v end end return ret end, set = function(info, value) TF3:ClearTable(TF3.db.profile.whitelist) - local tbl = { strsplit('\n', value) } - local type, val - for i, str in pairs(tbl) do - type, val = strsplit('=', str) - type = strtrim(type) - val = strtrim(val) - TF3.db.profile.whitelist[type] = val + local tbl = { strsplit("\n", value) } + for k, v in pairs(tbl) do + key = "WLIST" + TF3.db.profile.whitelist[key..k] = v end end, }, -- 1.7.9.5