From afda6bfa34380d20d77b06061122d34b42502b73 Mon Sep 17 00:00:00 2001 From: "Erik L. Vonderscheer" Date: Sat, 21 Aug 2010 20:59:25 +0000 Subject: [PATCH] Added configuration for repeat recycling(Advanced) Added achievement links to defualt Whitelist Removed defunct default Whitelist entry that produced a bug in new entries --- Docs/changelog.txt | 26 ++++-- Docs/main.txt | 11 +-- TradeFilter3.lua | 14 ++-- TradeFilter3Options.lua | 205 ++++++++++++++++++++++++++++++++++++----------- 4 files changed, 191 insertions(+), 65 deletions(-) diff --git a/Docs/changelog.txt b/Docs/changelog.txt index 6c4d851..7d4d5f9 100644 --- a/Docs/changelog.txt +++ b/Docs/changelog.txt @@ -1,15 +1,27 @@ == ChangeLog +*r199 +**++Added configuration for repeat recycling(Advanced)++\\ +**++Added achievement links to defualt Whitelist++\\ +**++Removed defunct default Whitelist entry that produced a bug in new entries++\\ +*r198 +**++Let's not check for repeats twice++\\ +*r196 +**++Fix repeat counter++\\ +**++Fix error in localization (r195)++\\ +*r195 +**++Fix repeat detection++\\ +**++GUI typo++\\ *r192 -**++Added BG Filters++ -**++Config GUI reorganization++ +**++Added BG Filters++\\ +**++Config GUI reorganization++\\ *r167 -**++Added simple duel spam block++ +**++Added simple duel spam block++\\ *r159 -**++Keep lists sorted!++ +**++Keep lists sorted!++\\ *r155 -**++LDB support for Repeats Blocked++ -**++Ability for Whitelist to bypass repeat filter++ -**++GUI layout changed a little++ +**++LDB support for Repeats Blocked++\\ +**++Ability for Whitelist to bypass repeat filter++\\ +**++GUI layout changed a little++\\ *r148 **++Minor code cleanup++\\ **++AceTimer lib added for repeat table recycling++\\ diff --git a/Docs/main.txt b/Docs/main.txt index 6e0ac48..202f7ff 100644 --- a/Docs/main.txt +++ b/Docs/main.txt @@ -51,8 +51,9 @@ Nothing planned === Supported Translations //Please help localize this project// [[http://www.wowace.com/projects/trade-filter/localization/|HERE]]\\ -German - 97.4%\\ -French - 63.2%\\ -Simplified Chinese - 41.9%\\ -Traditional Chinese - 22.2%\\ -Korean - 47.9%\\ +[[http://www.wowace.com/projects/trade-filter/localization/|German]] - 93.3%\\ +[[http://www.wowace.com/projects/trade-filter/localization/|Simplified Chinese]] - 52.0%\\ +[[http://www.wowace.com/projects/trade-filter/localization/|French]] - 41.9%\\ +[[http://www.wowace.com/projects/trade-filter/localization/|Korean]] - 30.7%\\ +[[http://www.wowace.com/projects/trade-filter/localization/|Russian]] - 26.9%\\ +[[http://www.wowace.com/projects/trade-filter/localization/|Traditional Chinese]] - 14.0%\\ diff --git a/TradeFilter3.lua b/TradeFilter3.lua index 3be8d70..9a79548 100644 --- a/TradeFilter3.lua +++ b/TradeFilter3.lua @@ -49,7 +49,6 @@ local formatIt = string.format local insert = table.insert local sort = table.sort local timerCount = 0 -local repeatdata = {} local currentFriend local redirectFrame = L["redirectFrame"] local debugFrame = L["debugFrame"] @@ -61,6 +60,9 @@ local rptmsgID local lastuserID local rptdone +--[[ Globals ]]-- +repeatdata = {} + local PROJECT_VERSION = "@project-version@" local PROJECT_REVISION = 000 + tonumber(("$Revision: @project-revision@ $"):match("%d+")) TF3.date = sub("$Date: @file-date-iso@ $", 8, 17) @@ -95,6 +97,8 @@ defaults = { special_enable = false, num_repeats = "2", time_repeats = "30", + repeat_recycle_time = "1800", + repeat_recycle_size = "50", repeats_blocked = 0, friendslist = {}, whitelist = {}, @@ -183,7 +187,7 @@ function TF3:IsLoggedIn() self:RegisterEvent("FRIENDLIST_UPDATE", "GetFriends") friends.RegisterCallback(self, "Added") friends.RegisterCallback(self, "Removed") - self:ScheduleRepeatingTimer("RecycleTables", 1800, repeatdata) + self:ScheduleRepeatingTimer("RecycleTables", tonumber(TF3.db.profile.repeat_recycle_time), repeatdata) self:UnregisterEvent("PLAYER_LOGIN") TF3:DuelFilter() @@ -232,11 +236,11 @@ end function TF3:RecycleTables(t, state) local gtime = math.floor(GetTime()*math.pow(10,0)+0.5) / math.pow(10,0) - if (t ~= nil and type(t) == "table" and TF3:GetNumElements(t) >= 100) then + if (t ~= nil and type(t) == "table" and TF3:GetNumElements(t) >= tonumber(TF3.db.profile.repeat_recycle_size)) then local key, value = next(t, state) if key then for k,v in pairs(value) do - if(k == "lastIndex" and gtime - v > 1800) then + if(k == "lastIndex" and gtime - v > tonumber(TF3.db.profile.repeat_recycle_time)) then if (TF3.db.profile.debug) then TF3:FindFrame(debugFrame, "|cFFFFFF80" .. L["RMVRT1"] .. "|r |cFF33FF99" .. key .. "|r |cFFFFFF80" .. L["RMVRT2"] .. "|r") end @@ -247,7 +251,7 @@ function TF3:RecycleTables(t, state) end timerCount = timerCount + 1 if (TF3.db.profile.debug) then - TF3:FindFrame(debugFrame, ("%d " .. L["SECPSD"]):format(1800 * timerCount)) + TF3:FindFrame(debugFrame, ("%d " .. L["SECPSD"]):format(tonumber(TF3.db.profile.repeat_recycle_time) * timerCount)) end end end diff --git a/TradeFilter3Options.lua b/TradeFilter3Options.lua index 80eaf7c..5fb25f4 100644 --- a/TradeFilter3Options.lua +++ b/TradeFilter3Options.lua @@ -3,6 +3,7 @@ File Author: @file-author@ File Revision: @file-revision@ File Date: @file-date-iso@ ]]-- + local TradeFilter3 = LibStub("AceAddon-3.0"):GetAddon("TradeFilter3") local L = LibStub("AceLocale-3.0"):GetLocale("TradeFilter3") local TF3 = TradeFilter3 @@ -13,6 +14,16 @@ local pairs = pairs local insert = table.insert local sort = table.sort +function getnHash(t) + local count = 0; + if not t then return 0; end + if (type(t)) ~= "table" then return 0; end + for i,_ in pairs(t) do + count = count + 1; + end + return count; +end + --[[ Options Table ]]-- options = { type="group", @@ -664,9 +675,10 @@ options = { }, }, }, - repeatGroup = { + repeatGroupMain = { type = "group", handler = TF3, + childGroups = "tab", order = 4, disabled = function() return not TF3.db.profile.turnOn @@ -674,68 +686,165 @@ options = { name = L["REPEAT"], desc = L["REPEAT"], args = { - optionsHeader4 = { - type = "header", - order = 1, - name = L["REPEAT"], - }, repeat_enable = { type = 'toggle', - order = 2, + order = 1, width = "double", name = L["RPTENABLE"], desc = L["RPTENABLED"], get = function() return TF3.db.profile.repeat_enable end, set = function() TF3.db.profile.repeat_enable = not TF3.db.profile.repeat_enable end, }, - num_repeats = { - type = 'input', + repeatGroup = { + type = "group", + handler = TF3, + order = 2, disabled = function() return not TF3.db.profile.repeat_enable end, - order = 3, - width = "full", - name = L["#RPT"], - desc = L["#RPTD"], - usage = L["RPTU"], - get = function(info) return TF3.db.profile.num_repeats end, - set = function(info, value) TF3.db.profile.num_repeats = value end, + name = L["REPEAT"], + desc = L["REPEAT"], + args = { + num_repeats = { + type = 'input', + disabled = function() + return not TF3.db.profile.repeat_enable + end, + order = 3, + width = "full", + name = L["#RPT"], + desc = L["#RPTD"], + usage = L["RPTU"], + get = function(info) return TF3.db.profile.num_repeats end, + set = function(info, value) TF3.db.profile.num_repeats = value end, + }, + time_repeats = { + type = 'input', + disabled = function() + return not TF3.db.profile.repeat_enable + end, + order = 4, + width = "full", + name = L["TRPT"], + desc = L["TRPTD"], + usage = L["RPTU"], + get = function(info) return TF3.db.profile.time_repeats end, + set = function(info, value) TF3.db.profile.time_repeats = value end, + }, + repeats_blocked = { + type = 'input', + disabled = true, + order = 5, + width = "half", + name = L["RPTBLOCKED"], + desc = L["RPTBLOCKEDD"], + get = function(info) return tostring(TF3.db.profile.repeats_blocked) end, + }, + reset_repeats_blocked = { + type = 'execute', + order = 6, + width = "half", + name = L["RPTRESET"], + desc = L["RPTRESETD"], + func = function() + TF3.db.profile.repeats_blocked = 0 + if (LibStub("LibDataBroker-1.1", true)) then + TF3Frame.Blocked.text = TF3.db.profile.repeats_blocked .. "Repeats Blocked" + TF3Frame.Blocked.value = TF3.db.profile.repeats_blocked + end + end, + }, + }, }, - time_repeats = { - type = 'input', + repeatGroupAdv = { + type = "group", + handler = TF3, + order = 3, disabled = function() return not TF3.db.profile.repeat_enable end, - order = 4, - width = "full", - name = L["TRPT"], - desc = L["TRPTD"], - usage = L["RPTU"], - get = function(info) return TF3.db.profile.time_repeats end, - set = function(info, value) TF3.db.profile.time_repeats = value end, - }, - repeats_blocked = { - type = 'input', - disabled = true, - order = 5, - width = "half", - name = L["RPTBLOCKED"], - desc = L["RPTBLOCKEDD"], - get = function(info) return tostring(TF3.db.profile.repeats_blocked) end, - }, - reset_repeats_blocked = { - type = 'execute', - order = 6, - width = "half", - name = L["RPTRESET"], - desc = L["RPTRESETD"], - func = function() - TF3.db.profile.repeats_blocked = 0 - if (LibStub("LibDataBroker-1.1", true)) then - TF3Frame.Blocked.text = TF3.db.profile.repeats_blocked .. "Repeats Blocked" - TF3Frame.Blocked.value = TF3.db.profile.repeats_blocked - end - end, + name = L["RPTA"], + desc = L["RPTAD"], + args = { + repeat_recycle_time = { + type = 'input', + disabled = function() + return not TF3.db.profile.repeat_enable + end, + order = 1, + width = "full", + name = L["RPTRT"], + desc = L["RPTRTD"], + usage = L["RPTRTSU"], + get = function(info) return TF3.db.profile.repeat_recycle_time end, + set = function(info, value) + TF3.db.profile.repeat_recycle_time = value + TF3:ScheduleRepeatingTimer(TF3:RecycleTables(), tonumber(TF3.db.profile.repeat_recycle_time), repeatdata) + end, + }, + repeat_recycle_size = { + type = 'input', + disabled = function() + return not TF3.db.profile.repeat_enable + end, + order = 2, + width = "full", + name = L["RPTRS"], + desc = L["RPTRSD"], + usage = L["RPTRTSU"], + get = function(info) return TF3.db.profile.repeat_recycle_size end, + set = function(info, value) TF3.db.profile.repeat_recycle_size = value end, + }, + repeats_table_size = { + type = 'input', + disabled = true, + order = 3, + name = L["RPTTS"], + get = function() return tostring(getnHash(repeatdata)) end, + }, + blank_space1 = { + type = 'description', + order = 4, + name = "", + }, + options_header5 = { + type = "header", + order = 5, + name = L["RPTTC"], + }, + reset_repeat_table_content = { + type = 'execute', + disabled = function() + return not TF3.db.profile.repeat_enable + end, + order = 6, + name = L["RPTTT"], + desc = L["RPTTTD"], + func = function() TF3:RecycleTables(repeatdata) end, + }, + repeats_table_content = { + type = 'description', + fontSize = "medium", + disabled = true, + order = 7, + name = function() + local ret = "" + for k,v in pairs(repeatdata) do + if ret == "" then + ret = k + else + ret = ret .. "\n" .. k + end + end + return ret + end, + }, + blank_space2 = { + type = 'description', + order = 8, + name = "", + }, + }, }, }, }, -- 1.7.9.5