├── Media
└── di.ogg
├── .gitattributes
├── Filter
├── Filter.xml
├── Filter.old.lua
└── Filter.lua
├── Locale
├── Locale.xml
├── zhCN.lua
└── enUS.lua
├── .gitignore
├── Tinom.xml
├── Tinom.toc
├── AccountStat
├── AccountStat.xml
└── AccountStat.lua
├── Note.lua
├── Build
├── copy2classic.py
└── zip.py
├── debug.lua
├── Core.lua
├── Tinom.lua
├── README.md
├── ChatStat
├── ChatStat.xml
└── ChatStat.lua
├── test
├── test.lua
└── test.xml
└── Options
└── Options.lua
/Media/di.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiXiuMing/Tinom/HEAD/Media/di.ogg
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/Filter/Filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Locale/Locale.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | Tdebug(self,"log","Locale.xml.OnLoad");
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Lua sources
2 | luac.out
3 |
4 | # luarocks build files
5 | *.src.rock
6 | *.zip
7 | *.tar.gz
8 |
9 | # Object files
10 | *.o
11 | *.os
12 | *.ko
13 | *.obj
14 | *.elf
15 |
16 | # Precompiled Headers
17 | *.gch
18 | *.pch
19 |
20 | # Libraries
21 | *.lib
22 | *.a
23 | *.la
24 | *.lo
25 | *.def
26 | *.exp
27 |
28 | # Shared objects (inc. Windows DLLs)
29 | *.dll
30 | *.so
31 | *.so.*
32 | *.dylib
33 |
34 | # Executables
35 | *.exe
36 | *.out
37 | *.app
38 | *.i*86
39 | *.x86_64
40 | *.hex
41 |
42 |
--------------------------------------------------------------------------------
/Tinom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | self:RegisterEvent("ADDON_LOADED");
7 | Tdebug(self,"log","Tinom.xml.OnLoad");
8 |
9 |
10 | Tinom.OnLoaded(self,event,...);
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Tinom.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 80205
2 | ## Title: Tinom 聊天增强
3 | ## Notes: 这个插件用于优化聊天体验,包括过滤,统计,游戏等功能.
4 | ## Author: Tinom
5 | ## Version: 0.1-beta.16
6 | ## SavedVariables: TinomDB, debugDB
7 |
8 | # 角色变量,存储于角色下.","分隔多个变量
9 | # SavedVariablesPerCharacter: chardb
10 |
11 | # 账号变量,存储于账号下.","分隔多个变量
12 | # SavedVariables: globaldb, characterDB, filterDB
13 |
14 |
15 | # 一个井号的属于注释行.
16 | # 索引需要载入的文件,将按照顺序加载.
17 |
18 | debug.lua
19 | Locale\Locale.xml
20 | Tinom.xml
21 | Core.lua
22 | ChatStat\ChatStat.xml
23 | Filter\Filter.xml
24 | Options\Options.xml
25 | AccountStat\AccountStat.xml
26 | test\test.xml
--------------------------------------------------------------------------------
/AccountStat/AccountStat.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Tdebug(self,"log","AccountStat.xml.OnLoad");
7 | self:RegisterEvent("PLAYER_LEAVING_WORLD");
8 |
9 |
10 | Tdebug(self,"log","AccountStat.xml.OnEvent\"PLAYER_LEAVING_WORLD\"");
11 | Tinom.LoginLog(self,event,...);
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Note.lua:
--------------------------------------------------------------------------------
1 | 打开装备自动比较 (常驻)
2 | /run SetCVar(“alwaysCompareItems”, “1”)
3 | 1代表打开 0代表关闭
4 |
5 | 最大镜头距离 (读蓝条失效 可避免)
6 | /console cameraDistanceMaxZoomFactor 4
7 | 最多到4
8 | 这句只要重新加载(读蓝条)就会失效 但是你要是不调整镜头会一直卡在4 建议把滚轮改成其他按键
9 |
10 | 设置血液效果等级 (常驻)
11 | /console violenceLevel 2
12 | 最后一位数字代表暴力等级 默认是2 最大是5 最小是0
13 |
14 | 敌方姓名板显示职业颜色 (常驻)
15 | /console ShowClassColorInNameplate 1
16 | 0代表关闭 1代表打开
17 |
18 | 友方姓名板显示职业颜色 (常驻)
19 | /console ShowClassColorInFriendlyNameplate 1
20 | 0代表关闭 1代表打开
21 |
22 | 聊天窗口显示职业颜色 (常驻)
23 | /console SET chatClassColorOverride “0”
24 | 0代表打开 1代表关闭
25 |
26 | 重要!在使用后再输入一次 /rl 重新加载页面!
27 |
28 | 作者:druMidEA
--------------------------------------------------------------------------------
/Build/copy2classic.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | fileslist = [
4 | "AccountStat",
5 | "ChatStat",
6 | "Filter",
7 | "Locale",
8 | "Options",
9 | "Media",
10 | "Core.lua",
11 | "debug.lua",
12 | "README.md",
13 | "Tinom.lua",
14 | "Tinom.xml",
15 | "Tinom.toc",
16 | ]
17 |
18 | fileslist2 = []
19 |
20 | classic = "..\..\..\..\_classic_\Interface\AddOns\Tinom"
21 |
22 | for file in fileslist:
23 | if os.path.isdir(file):
24 | for fileB in os.listdir(file):
25 | fileslist2.append(file+os.sep+fileB)
26 | else:
27 | fileslist2.append(file)
28 |
29 | print(fileslist2)
30 | for file in fileslist2:
31 | command = "copy "+file+" "+classic+os.sep+file
32 | print(command)
33 | os.system(command)
34 |
--------------------------------------------------------------------------------
/Build/zip.py:
--------------------------------------------------------------------------------
1 | import zipfile, os
2 | try:
3 | import zlib
4 | ziptype = zipfile.ZIP_DEFLATED
5 | except:
6 | ziptype = zipfile.ZIP_STORED
7 |
8 | fileslist = {
9 | "AccountStat",
10 | "ChatStat",
11 | "Filter",
12 | "Locale",
13 | "Options",
14 | "Media",
15 | "Core.lua",
16 | "debug.lua",
17 | "README.md",
18 | "Tinom.lua",
19 | "Tinom.xml",
20 | "Tinom.toc",
21 | }
22 |
23 | Tinomtoc = open("Tinom.toc",mode='r',encoding='UTF-8')
24 | TinomList = Tinomtoc.readlines()
25 | long = len(TinomList[4])
26 | version = TinomList[4][12:(long-1)]
27 | Tinomtoc.close()
28 | zipname = "Build/Tinom"+version+".zip"
29 |
30 | with zipfile.ZipFile(zipname,'w',ziptype) as target:
31 | for file in fileslist:
32 | if os.path.isdir(file):
33 | for fileB in os.listdir(file):
34 | target.write(file+os.sep+fileB,"Tinom/"+file+os.sep+fileB)
35 | else:
36 | target.write(file,"Tinom/"+file)
37 | target.close()
38 |
39 | Tinomzip = zipfile.ZipFile(zipname)
40 | print(zipname+"压缩完成,共压缩文件:"+str(len(Tinomzip.namelist()))+"个.")
--------------------------------------------------------------------------------
/debug.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Debug
4 | -- 排错模块
5 | --
6 | -- 功能:记录操作,统一输出,方便关闭
7 | --
8 | -------------------------------------------------------------------------]]--
9 | -- 初始化排错记录库
10 | local debugDB_Temp = {
11 | log = {};
12 | error = {};
13 | };
14 | local Tinom_Switch_Debug = false;
15 | --[[-------------------------------------------------------------------------
16 | -- 排错函数:
17 | -- Tdebug(self,"error,log","__");
18 | -------------------------------------------------------------------------]]--
19 | local TinomDebugFrame = CreateFrame("Frame")
20 | TinomDebugFrame:RegisterEvent("PLAYER_LOGOUT")
21 | TinomDebugFrame:SetScript("OnEvent", function(self, event, ...)
22 | debugDB = debugDB_Temp;
23 | debugDB.locale = Tinom.newLocale;
24 | end)
25 |
26 | function Tdebug( ... )
27 | if not Tinom_Switch_Debug then
28 | return;
29 | end
30 | local callFrame, callType, callMsg = ...;
31 | local timeNow = date("%H:%M:%S");
32 | local logStr = timeNow.."-["..callType.."]: "..callMsg
33 | if ( callType == "log" ) then
34 | table.insert( debugDB_Temp.log, logStr );
35 | --print(logStr);
36 | elseif ( callType == "error" ) then
37 | table.insert( debugDB_Temp.error, logStr );
38 | --print(logStr);
39 | end
40 | end
41 |
42 | function TdebugSwitch()
43 | Tinom_Switch_Debug = not Tinom_Switch_Debug;
44 | if Tinom_Switch_Debug then
45 | ChatFrame1:AddMessage("排错函数已:开")
46 | return;
47 | end
48 | ChatFrame1:AddMessage("排错函数已:关")
49 | end
50 | SLASH_TINOMDEBUG1 = "/tdebug"
51 | SLASH_TINOMDEBUG2 = "/td"
52 | SlashCmdList["TINOMDEBUG"] = TdebugSwitch;
--------------------------------------------------------------------------------
/AccountStat/AccountStat.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Tinom Account Stat
4 | -- 账户角色统计模块
5 | --
6 | -- 功能:统计角色信息,待开发
7 | --
8 | -------------------------------------------------------------------------]]--
9 |
10 | --[[-------------------------------------------------------------------------
11 | -- 角色登陆次数统计
12 | -------------------------------------------------------------------------]]--
13 | local playerName = UnitName("player");
14 | local loginMsg = "";
15 |
16 | function Tinom.LoginLog(self, event, addonName)
17 | if ( TinomDB.accountDB == nil ) then
18 | TinomDB.accountDB = {};
19 | Tdebug(self,"log","LoginLog.accountDB.Initialize");
20 | end
21 | local accountDB_Temp = TinomDB.accountDB;
22 |
23 | if ((event == "ADDON_LOADED") and (addonName == "Tinom")) then
24 | if (accountDB_Temp[playerName] == nil) then
25 | accountDB_Temp[playerName] = {times=1,lastTime=0,};
26 | loginMsg = "你好:"..playerName.." 初次见面,请多多关照.";
27 | DEFAULT_CHAT_FRAME:AddMessage(loginMsg, 1, 1, 0, 1);
28 | else
29 | accountDB_Temp[playerName].times = accountDB_Temp[playerName].times + 1;
30 | local elapsed = time() - accountDB_Temp[playerName].lastTime;
31 | loginMsg = "你好 "..playerName .. "\n 这是我们第".. accountDB_Temp[playerName].times .."次相见.\n 距离你上次登出的时间是" .. SecondsToTime(elapsed);
32 | DEFAULT_CHAT_FRAME:AddMessage(loginMsg, 1, 1, 0, 1);
33 | end
34 | elseif (event == "PLAYER_LEAVING_WORLD")then
35 | accountDB_Temp[playerName].lastTime = time();
36 | TinomDB.accountDB = accountDB_Temp;
37 | Tdebug(self,"log","LoginLog.SaveCharacter:"..playerName);
38 |
39 | TinomDB.playerDB = {};--##--统计功能完善前发布版先别保存用户数据,防止无休止增长.
40 | TinomDB.chatStatDB = {};--##--统计功能完善前发布版先别保存用户数据,防止无休止增长.
41 | Tdebug(self,"log","ClearDB:chatStatDB;playerDB");
42 | end
43 | end
44 |
45 | Tdebug(self,"log","AccountStat.lua.OnLoaded");
--------------------------------------------------------------------------------
/Locale/zhCN.lua:
--------------------------------------------------------------------------------
1 | -- 判断本地语言是否为指定值,否则直接退出,不再进行之后动作.
2 | if (TinomLocale and (GetLocale() ~= "zhCN")) then return end
3 |
4 | --[[-------------------------------------------------------------------------
5 | -- 本地化表
6 | -------------------------------------------------------------------------]]--
7 | TinomLocale = {
8 | ["白名单设置"] = "白名单设置",
9 | ["开启过滤"] = "开启过滤",
10 | ["高亮显示"] = "高亮显示",
11 | ["黑名单:关键字"] = "黑名单:关键字",
12 | ["替换关键字"] = "替换关键字",
13 | ["替换单设置:"] = "替换单设置:",
14 | ["白名单关键字"] = "白名单关键字",
15 | ["黑名单设置:每行一个角色名或者关键字"] = "黑名单设置:每行一个角色名或者关键字",
16 | ["应用"] = "应用",
17 | ["白名单:关键字"] = "白名单:关键字",
18 | ["缩写频道名"] = "缩写频道名",
19 | ["黑名单关键字"] = "黑名单关键字",
20 | ["新角色名-可选"] = "新角色名-可选",
21 | ["Tinom聊天过滤"] = "Tinom聊天过滤",
22 | ["黑名单设置"] = "黑名单设置",
23 | ["关键字"] = "关键字",
24 | ["替换角色的消息"] = "替换角色的消息",
25 | ["缩写玩家名(|cffffff00注意!被缩写的角色将导致其右键内交互功能失效!|r)"] = "缩写玩家名(|cffffff00注意!被缩写的角色将导致其右键内交互功能失效!|r)",
26 | ["Tinom聊天过滤v"] = "Tinom聊天过滤v",
27 | ["开启过滤系统的主开关"] = "开启过滤系统的主开关",
28 | ["替换单设置"] = "替换单设置",
29 | ["新消息-可选"] = "新消息-可选",
30 | ["基本设置"] = "基本设置",
31 | ["屏蔽灰色物品拾取消息"] = "屏蔽灰色物品拾取消息",
32 | ["白名单设置:每行一个角色名或者关键字"] = "白名单设置:每行一个角色名或者关键字",
33 | ["黑名单:玩家"] = "黑名单:玩家",
34 | ["替换关键字的消息"] = "替换关键字的消息",
35 | ["开启"] = "开启",
36 | ["新关键字-可选"] = "新关键字-可选",
37 | ["过滤"] = "过滤",
38 | ["角色名"] = "角色名",
39 | ["白名单"] = "白名单",
40 | ["屏蔽重复消息"] = "屏蔽重复消息",
41 | ["声音提醒需要开启\n相应的白名单过滤"] = "声音提醒需要开启\n相应的白名单过滤",
42 | ["折叠复读消息"] = "折叠复读消息",
43 | ["替换角色名"] = "替换角色名",
44 | ["黑名单"] = "黑名单",
45 | ["白名单:玩家"] = "白名单:玩家",
46 | ["自动添加黑名单"] = "自动添加黑名单",
47 | ["只有白名单"] = "只有白名单",
48 | ["目前插件处于Beta测试阶段,更新会比较频繁.您可以经常浏览我的更新贴以获取最新版本.NGA:搜索\"Tinom\"进行反馈."] = "目前插件处于Beta测试阶段,更新会比较频繁.您可以经常浏览我的更新贴以获取最新版本.NGA:搜索\"Tinom\"进行反馈.",
49 | ["选一个你喜欢的提示音"] = "选一个你喜欢的提示音",
50 | ["替换类型"] = "替换类型",
51 | ["按角色名替换"] = "按角色名替换",
52 | ["按关键字替换"] = "按关键字替换",
53 | ["过滤优先级从上至下递减"] = "过滤优先级从上至下递减",
54 | ["铃声"] = "铃声",
55 | ["新增"] = "新增",
56 | ["删除"] = "删除",
57 | ["修改"] = "修改",
58 | ["你太短了!"] = "你太短了!",
59 | }
60 |
61 | Tdebug(self,"log","zhCN.lua加载完成");
--------------------------------------------------------------------------------
/Core.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Core Model
4 | -- 内核模块
5 | --
6 | -- 功能:一些常用,可重复使用的公共函数
7 | --
8 | -------------------------------------------------------------------------]]--
9 |
10 | --[[-------------------------------------------------------------------------
11 | -- 从消息获取物品ID和链接:如CHAT_MSG_LOOT:Util.lua
12 | -------------------------------------------------------------------------]]--
13 | function Tinom.GetItemInfoFromHyperlink(link)
14 | local strippedItemLink, itemID = link:match("|Hitem:((%d+).-)|h");
15 | if itemID then
16 | return tonumber(itemID), strippedItemLink;
17 | end
18 | end
19 |
20 | function Tinom.SliderValueFloor( value )
21 | assert(value);
22 |
23 | value = math.floor(value * 100 + 0.5) / 100;
24 | if (value ~= 0) then
25 | value = math.max(0.5, value);
26 | end
27 | return value;
28 | end
29 |
30 | function Tinom.CheckNameInTable(checkTable,checkName)
31 | assert(checkName and checkTable)
32 |
33 | index = strsub(checkName,1,3)
34 | if checkTable[index] then
35 | for _,v in pairs(checkTable[index]) do
36 | if checkName == v then
37 | return true;
38 | end
39 | end
40 | end
41 | return false;
42 | end
43 |
44 | function Tinom.OldToNewTable(oldTable, newTable)
45 | for k,v in next, oldTable do
46 | Tinom.AddAuthorToTable(v,newTable)
47 | end
48 | end
49 |
50 | function Tinom.AddAuthorToTable(tableList, author)
51 | assert(author and tableList)
52 |
53 | index = strsub(author,1,3)
54 | if not tableList[index] then
55 | tableList[index] = {};
56 | end
57 | table.insert(tableList[index],author)
58 | end
59 |
60 | function Tinom.TextToTable( textIn )
61 | assert( textIn )
62 |
63 | local tableOut = {};
64 | for author in string.gmatch(textIn,"%S+") do
65 | local index = strsub(author,1,3)
66 | if not tableOut[index] then
67 | tableOut[index] = {};
68 | end
69 | for i,v in ipairs(tableOut[index]) do
70 | if author == v then
71 | table.remove(tableOut[index],i)
72 | end
73 | end
74 |
75 | table.insert(tableOut[index],author)
76 | end
77 | return tableOut;
78 | end
79 |
80 | function Tinom.TableToText( tableIn )
81 | assert(tableIn)
82 |
83 | local textOut = "";
84 | local num = 0;
85 | for k,vlist in pairs(tableIn) do
86 | textOut = textOut..table.concat(vlist,"\n").."\n";
87 | num = num + #vlist;
88 | end
89 | return textOut, num;
90 | end
91 |
92 | function Tinom.IsMe(nameIn)
93 | if nameIn == UnitName("player") then
94 | return true;
95 | end
96 | return false;
97 | end
--------------------------------------------------------------------------------
/Locale/enUS.lua:
--------------------------------------------------------------------------------
1 | -- 判断本地语言是否为指定值,否则直接退出,不再进行之后动作.
2 | if (TinomLocale and (GetLocale() ~= "enUS")) then return end
3 |
4 | --[[-------------------------------------------------------------------------
5 | -- 本地化表
6 | -------------------------------------------------------------------------]]--
7 | TinomLocale = {
8 | ["白名单设置"] = "White List Settings",
9 | ["开启过滤"] = "Turn on filtering",
10 | ["高亮显示"] = "highlighted",
11 | ["黑名单:关键字"] = "blacklist: keyword",
12 | ["替换关键字"] = "Replace keywords",
13 | ["替换单设置:"] = "Replacement Order Settings:",
14 | ["白名单关键字"] = "whitelist keyword",
15 | ["黑名单设置:每行一个角色名或者关键字"] = "Blacklist setting: one role name or keyword per line",
16 | ["应用"] = "Apply",
17 | ["白名单:关键字"] = "White List: Keywords",
18 | ["缩写频道名"] = "abbreviated channel name",
19 | ["黑名单关键字"] = "blacklist keyword",
20 | ["新角色名-可选"] = "new role name - optional",
21 | ["Tinom聊天过滤"] = "Tinom Chat Filter",
22 | ["黑名单设置"] = "blacklist setting",
23 | ["关键字"] = "keyword",
24 | ["替换角色的消息"] = "Replace role message",
25 | ["缩写玩家名(|cffffff00注意!被缩写的角色将导致其右键内交互功能失效!|r)"] = "Abbreviation player name\n(|cffffff00Note! The abbreviated character will cause its right-click interaction function to be invalid!|r)",
26 | ["Tinom聊天过滤v"] = "Tinom chat filter v",
27 | ["开启过滤系统的主开关"] = "Turn on the main switch of the filter system",
28 | ["替换单设置"] = "Replacement Order Settings",
29 | ["新消息-可选"] = "New Message - Optional",
30 | ["基本设置"] = "Basic Settings",
31 | ["屏蔽灰色物品拾取消息"] = "Block gray item picking message",
32 | ["白名单设置:每行一个角色名或者关键字"] = "Whitelist setting: one role name or keyword per line",
33 | ["黑名单:玩家"] = "blacklist: player",
34 | ["替换关键字的消息"] = "Replace keyword message",
35 | ["开启"] = "on",
36 | ["新关键字-可选"] = "New Keyword - Optional",
37 | ["过滤"] = "Filter",
38 | ["角色名"] = "role name",
39 | ["白名单"] = "white list",
40 | ["屏蔽重复消息"] = "Block duplicate messages",
41 | ["声音提醒需要开启\n相应的白名单过滤"] = "The voice reminder needs to be enabled\n corresponding whitelist filtering",
42 | ["折叠复读消息"] = "Folding Repeat Message",
43 | ["替换角色名"] = "Replace Role Name",
44 | ["黑名单"] = "blacklist",
45 | ["白名单:玩家"] = "White List: Players",
46 | ["自动添加黑名单"] = "Automatically add blacklist",
47 | ["只有白名单"] = "Only whitelist",
48 | ["目前插件处于Beta测试阶段,更新会比较频繁.您可以经常浏览我的更新贴以获取最新版本.NGA:搜索\"Tinom\"进行反馈."] = "The plugin is currently in beta testing, update It will be more frequent. You can often browse my update post to get the latest version. NGA: Search \"Tinom\" for feedback.",
49 | ["选一个你喜欢的提示音"] = "Choose a tone you like",
50 | ["替换类型"] = "Replace Type",
51 | ["按角色名替换"] = "Replace as Name",
52 | ["按关键字替换"] = "Replace as Keyword",
53 | ["过滤优先级从上至下递减"] = "The priority of the filter decreases from top to bottom",
54 | ["铃声"] = "Tone",
55 | ["新增"] = "Add",
56 | ["删除"] = "Del",
57 | ["修改"] = "Rec",
58 | ["你太短了!"] = "You're so short!",
59 | }
60 |
61 | Tdebug(self,"log","zhCN.lua加载完成");
--------------------------------------------------------------------------------
/Tinom.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Tinom Main Frame
4 | -- 主框架
5 | --
6 | -- 功能:初始化与索引
7 | --
8 | -------------------------------------------------------------------------]]--
9 | -- 获取插件的插件名和插件表
10 | --local addonName, addon = ...
11 |
12 | -- 模块化封装
13 | Tinom = {};
14 | -- 游戏版本
15 | _,_,_,Tinom.gameVersion = GetBuildInfo();
16 |
17 | --[[-------------------------------------------------------------------------
18 | -- 本地化函数
19 | -------------------------------------------------------------------------]]--
20 | Tinom.newLocale = {}
21 | Tinom.L = setmetatable(TinomLocale, {
22 | __index = function(_, key)
23 | Tdebug(self,"log","zhCN.lua.未翻译字符串:"..key);
24 | Tinom.newLocale[key] = key;
25 | return key;
26 | end
27 | })
28 |
29 | --[[-------------------------------------------------------------------------
30 | -- 初始化数据库:
31 | -------------------------------------------------------------------------]]--
32 | function Tinom.checkTinomDB()
33 | if ( TinomDB == nil ) then
34 | Tdebug(self,"error","checkTinomDB.未发现数据库");
35 | TinomDB = {
36 | chatStatDB = {},
37 | playerDB = {},
38 | accountDB = {},
39 | Options = {},
40 | filterDB = {
41 | whiteList = {},
42 | whiteListKeyword = {},
43 | blackList = {},
44 | autoBlackList = {},
45 | blackListKeyword = {},
46 | sensitiveList = {},
47 | sensitiveKeyword = {},
48 | replaceName = {},
49 | replaceNameMsg = {},
50 | replaceKeyword = {
51 | ["%?%?+"] = "?",
52 | ["%++"] = "+",
53 | ["MM?"] = "M",
54 | ["~~?"] = "~",
55 | ["··?"] = ".",
56 | ["?"] = "?",
57 | [","] = ",",
58 | ["。"] = ".",
59 | ["%b{}"] = "_",
60 | },
61 | replaceKeywordMsg = {},
62 | },
63 | };
64 | if ( TinomDB.filterDB ) then
65 | Tdebug(self,"log","checkTinomDB.数据库已初始化");
66 | return true;
67 | end
68 | Tdebug(self,"error","checkTinomDB.数据库初始化失败");
69 | return false;
70 | end
71 | Tdebug(self,"log","checkTinomDB.数据库检查完成");
72 | return true;
73 | end
74 |
75 | --[[-------------------------------------------------------------------------
76 | -- 插件加载完成:
77 | -------------------------------------------------------------------------]]--
78 | function Tinom.OnLoaded(self,event,addonName)
79 | if (event == "ADDON_LOADED") and (addonName == "Tinom") and (Tinom.checkTinomDB()) then
80 | Tdebug(self,"log","Tinom.OnLoaded");
81 | Tinom.Check();
82 | Tinom.classicCheak();
83 | Tinom.LoginLog(self,event,addonName);
84 | Tinom.OptionsMainPanel_checkOptions();
85 | Tinom.MsgFilterOn();
86 | Tinom.ChatStat_OnLoad();
87 | Tinom.ReplaceChannelName();
88 | end
89 | end
90 |
91 | -- 怀旧服检查:
92 | function Tinom.classicCheak()
93 | Tinom.Tinom_Switch_MsgFilter_Classic = false;
94 | if ( Tinom.gameVersion < 80205 ) then
95 | Tinom.Tinom_Switch_MsgFilter_Classic = true;
96 | Tdebug(self,"log","检测到怀旧版");
97 | end
98 | end
99 |
100 | function Tinom.Check()
101 | Tinom.Updata_A();
102 | end
103 |
104 | function Tinom.Updata_A()
105 | if TinomDB.UpDataDate and TinomDB.UpDataDate >= 20191022 then
106 | Tinom.Updata_B()
107 | return;
108 | end
109 | if TinomDB.filterDB.replaceKeyword and (not TinomDB.filterDB.replaceKeywordMsg) then
110 | TinomDB.filterDB.replaceKeywordMsg = {};
111 | local tableTemp = TinomDB.filterDB.replaceKeyword;
112 | TinomDB.filterDB.replaceKeyword = {};
113 | for k,v in pairs(tableTemp) do
114 | TinomDB.filterDB.replaceKeyword[k] = v.newWord;
115 | TinomDB.filterDB.replaceKeywordMsg[k] = v.newMsg;
116 | end
117 | end
118 | if TinomDB.filterDB.replaceName and (not TinomDB.filterDB.replaceNameMsg) then
119 | TinomDB.filterDB.replaceNameMsg = {};
120 | local tableTemp = TinomDB.filterDB.replaceName;
121 | TinomDB.filterDB.replaceName = {};
122 | for k,v in pairs(tableTemp) do
123 | TinomDB.filterDB.replaceName[k] = v.newName;
124 | TinomDB.filterDB.replaceName[k] = v.newMsg;
125 | end
126 | end
127 | TinomDB.UpDataDate = 20191022;
128 | Tinom.Updata_B();
129 | end
130 |
131 | function Tinom.Updata_B()
132 | if TinomDB.UpDataDate and TinomDB.UpDataDate >= 20191023 then
133 | return;
134 | end
135 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive = true;
136 | TinomDB.Options.Default.Tinom_Switch_AddMessageFilter_AuthorAliasName = false;
137 | for i,v in ipairs(TinomDB.Options.Default.Tinom_Value_MsgFilter_FiltersList) do
138 | if v[3]=="ReplaceName" then
139 | TinomDB.Options.Default.Tinom_Value_MsgFilter_FiltersList = nil;
140 | break;
141 | end
142 | end
143 | TinomDB.UpDataDate = 20191023;
144 | end
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tinom插件说明
2 |
3 | ## 待办事项
4 | - __[Bug]__ 作好事未遂:反馈走动有时会出现卡顿.
5 | - 解决:加入名单数量显示与自定义限制最大数量,
6 | - 监狱功能:屏蔽一段时间后将其释放出来,以减轻名单压力,再犯加长监禁时间.
7 | - [Func]右键加入黑名单
8 | - [Func]关闭系统关键词过滤:C_CVar.SetCVar("profanityFilter",1);value = C_CVar.GetCVar("name")
9 | - [Func]系统自动角色名染色:C_CVar.SetCVar("colorChatNamesByClass",1)
10 | - [Func]重复发言自定义时间间隔
11 | - [Func]屏蔽社区邀请:|HplayerCommunity;Blizzard Groups
12 | - [Func]优先级调整
13 | - [Func]单独做一个提醒单出来
14 | - [Func]多名单支持,创建 选择 多选 复选 名单内的名单
15 |
16 | ## 插件功能:
17 |
18 | 1. 统计功能:
19 | - [OK]角色信息: GUID(唯一标识),姓名,服务器,等级,职业,种族,性别,当前地区,历史姓名
20 | - [OK]发言信息: 上次发言内容,上次发言时间,总发言计数,总重复发言计数,~~所获成就~~
21 | - 聊天排行榜:统计本服最爱唠嗑的前几名显示于设置界面
22 | 2. 聊天过滤:
23 | - [OK]自动添加过滤: 将重复发言到指定值的角色GUID加入到过滤列表.
24 | - [OK]聊天过滤:角色白名单,角色黑名单,角色临时白名单,角色临时黑名单,关键字黑名单,关键字白名单,20条以内的重复发言.(都要区分聊天频道)白名单模式,关键字提醒,关键字记录,
25 | - [OK]修改聊天频道名: 例如:把"大脚世界频道"改为"世界"或为空,以节省占用空间.
26 | - [OK]修改角色名: 将指定的角色名修改为指定值(例如:小狗).
27 | - [OK]修改角色发言: 将指定角色发言内用修改为指定值(例如:小狗:汪汪汪).
28 | - 右键角色名功能
29 | - 关闭系统过滤功能.
30 | - 特别审查函数: 缓存角色的10条信息,累计重复次数,若其累计到一定值则加入过滤名单.
31 | - 深度分析: 将发言累计到一定程度(发言频率固定)的角色加入特别审查函数甄别.
32 | - 团队模式:暂停一般过滤节省资源,转而过滤像EUI这样的喊话插件.
33 | - 社区邀请过滤:过滤社区邀请提示框和声音,但仍能在公会界面看到邀请.或是全部过滤.
34 | - 状态过滤:角色状态时AFK和忙碌的角色发言丢弃
35 | 3. 聊天增强:(吃瓜模式,强力吃瓜模式,卖瓜模式)
36 | - [OK]高亮显示白名单消息和白名单关键字
37 | - 特别提醒功能:关注的角色名或者消息关键字出现则声音提醒,加框架提醒,加框架显示和保存记录
38 | - 密语组队: 角色密语指定内容则邀请加入队伍,如果失败则提示框提示并密语反馈.
39 | - 消息小尾巴:发送消息末尾加上个"嗝~"啥的,最好做出字数限制,免得滥用,随机小尾巴也是可以的
40 | - 消息装等显示: 显示聊天信息中的装备装等或其它信息.
41 | - 临时截取功能:截取保存一段消息,
42 | - 复制功能:弹出新的框架,展示聊天框内的文本,自由复制
43 | - 笔记功能
44 | - 聊天窗口姓名前加上职业或者职责(UI escape sequences-AtlasID)
45 | - 特定筛选:从聊天框中提取出指定角色或者指定关键词的消息展示到框架上
46 | - 社区增强,消息提醒等功能加入社区选择的功能,有人可能加入了多个社区,只想监视某一个社区的化...
47 | - 关键字规避提醒:即将发出的消息中是否含有屏蔽关键字,有则提醒,或者选项:自动更改谐音字或夹杂字符
48 | - LFG:公会浏览功能,公会申请...
49 | - 成语接龙: 密语成语接龙,~~频道成语接龙~~.(也可有相应的[成语接龙成就]).
50 | - UI全部隐藏,全新的全屏聊天界面,右下角显示是否暂离等
51 | - ~~聊天成就: 角色发言达到一定次数给予相应[聊天成就]并通报,角色重复发言达到一定次数给予相应[广告成就]并通报.~~
52 | - ~~聊天时段: 每小时统计一次发言次数最多的前几名玩家,给予相应[聊天时段成就]并通报.~~
53 | - ~~升级鼓励: 角色与上一次等级相差超过指定值并且达到指定值则给予相应鼓励和[升级成就].~~
54 |
55 | ***
56 |
57 | 1. 其它功能
58 | 1. 随机团本临时指挥系统: 通过密语团员,回复 1 接受指挥信息,回复 2/不回复 则拒绝.
59 | 2. 我是伸手党: BOSS战完毕展示队友战利品框架,附带伸手按钮,密语对方要不要.
60 |
61 | ***
62 | ## 网友需要的功能:
63 | 1. [OK]隐藏灰色物品拾取信息[Idea]:@forever_noyes(CHAT_MSG_LOOT事件是自己拾取的)
64 | - 示例:`[CHAT_MSG_LOOT]: 你获得了战利品:|cff9d9d9d|Hitem:3175::::::::120:102::::::|h[破损的龙鳞]|h|r。"`
65 | 2. 屏蔽社区邀请[Idea]:@zh648990
66 | 3. [OK]怀旧服职业颜色[Idea]:@纯情小猪哥
67 | 1. `|Hchannel:channel:4|h[4. 大脚世界频道]|h |Hplayer:戴育林-怒炉:2956:CHANNEL:4|h[戴育林]|h: 释放他们组个"`
68 | 4. 重复发言过滤自定义时间间隔[Idea]:@zhougl2
69 | 5. [OK]精简消息:消息内的重复内容缩写[Idea]:@appleboy2016
70 | 6. 优先级调整:[Idea]:@powervv
71 | 1. 白名单玩家第一,都不屏蔽,
72 | 2. 黑名单玩家第二,说什么都屏蔽.
73 | 3. 黑白关键字第三,名单应该同时生效.比如我是治疗,白名单关键字设置治疗,但是我不想去血色,那么我关键字黑名单设置血色,这样就显示不包含血色的有治疗关键字的说话.
74 | 7. 清空上次密语玩家功能,有人不想再敲空格还是回复上次的密语人,想改成上次的频道
75 |
76 | ***
77 |
78 | ## 备注:
79 | 2019/09/30:因为升级到8.2.5后频道自动发言的API被禁用了,所以删去了一部分待实现的功能.
80 |
81 | ***
82 |
83 | ## 变量命名:
84 | **局部变量**: 小写开头,第二个单词开始首字母大写,
85 | **全局变量**: Tinom.功能组 变量名, 小写开头,第二个单词开始首字母大写
86 | **布尔变量**: Tinom_Switch_ 功能组 _ 变量名
87 | **函数名**: Tinom. 功能组 _ 函数名, 所有单词首字母大写,酌情_下划线_
88 | **框架名**: Tinom 功能组 框架名, 所有单词首字母大写
89 | **框架用字符串**: TINOM_功能组_框架名_字符串名, 所有字母大写,酌情_下划线_
90 |
91 | 开关:
92 |
93 | 替换角色名开关: Tinom_Switch_MsgFilter_ReplaceName
94 | 替换关键字开关: Tinom_Switch_MsgFilter_ReplaceKeyWord
95 | 替换角色消息开关: Tinom_Switch_MsgFilter_ReplaceNameMsg
96 | 替换关键字消息开关: Tinom_Switch_MsgFilter_ReplaceKeyWordMsg
97 |
98 | 白名单开关: Tinom_Switch_MsgFilter_WhiteList
99 | 黑名单开关: Tinom_Switch_MsgFilter_BlackList
100 | 白名单关键字开关: Tinom_Switch_MsgFilter_WhiteListKeyWord
101 | 黑名单关键字开关: Tinom_Switch_MsgFilter_BlackListKeyWord
102 |
103 | 重复发言开关: Tinom_Switch_MsgFilter_Repeat
104 | 只显示白名单开关: Tinom_Switch_MsgFilter_WhiteListOnly
105 |
106 | 数据库:
107 |
108 | 白名单地址: TinomDB.filterDB.whiteList
109 | 黑名单地址: TinomDB.filterDB.blackList
110 | 白名单关键字地址: TinomDB.filterDB.whiteListKeyWord
111 | 黑名单关键字地址: TinomDB.filterDB.blackListKeyWord
112 |
113 | 替换角色名地址: TinomDB.filterDB.replaceName[].newName
114 | 替换关键字地址: TinomDB.filterDB.replaceKeyWord[].newWord
115 | 替换角色消息地址: TinomDB.filterDB.replaceName[].newMsg
116 | 替换关键字消息地址: TinomDB.filterDB.replaceKeyWord[].newMsg
117 |
118 | 20条信息缓存表: TinomDB_filterDB_cacheMsgTemp
119 | 临时白名单: TinomDB_filterDB_whiteListTemp
120 | 临时黑名单: TinomDB_filterDB_blackListTemp
121 |
122 | ## 数据库结构:
123 |
124 | TinomDB={
125 | Options = {
126 | Default = {
127 | Tinom_Switch_MsgFilter_ReplaceName = false;
128 | Tinom_Switch_MsgFilter_ReplaceKeyWord = false;
129 | Tinom_Switch_MsgFilter_ReplaceNameMsg = false;
130 | Tinom_Switch_MsgFilter_ReplaceKeyWordMsg = false;
131 | Tinom_Switch_MsgFilter_WhiteList = false;
132 | Tinom_Switch_MsgFilter_BlackList = false;
133 | Tinom_Switch_MsgFilter_WhiteListKeyWord = false;
134 | Tinom_Switch_MsgFilter_BlackListKeyWord = false;
135 | Tinom_Switch_MsgFilter_CacheMsgRepeat = false;
136 | Tinom_Switch_MsgFilter_WhiteListOnly = false;
137 | },
138 | },
139 |
140 | playerDB = {
141 | GUID = {
142 | name = "string",
143 | class = "string",
144 | sex = number,
145 | race = "string",
146 | },
147 | },
148 |
149 | accountDB = {
150 | character = {
151 | class = "string",
152 | guid = "string",
153 | sex = number,
154 | race = "string",
155 | },
156 | },
157 |
158 | chatStatDB = {
159 | servername = {
160 | authorName = {
161 | msgCount = number,
162 | msgRepeatTimes = number,
163 | msgLastText = "string",
164 | msgLastTime = number,
165 | authorClass = "string",
166 | authorGUID = "string",
167 | authorSex = number,
168 | authorRace = "string",
169 | }
170 | }
171 | },
172 |
173 | filterDB = {
174 | whiteList = {"name","name","name"},
175 | blackList = {"name","name","name"},
176 |
177 | whiteListKeyWord = {"keyWord","keyWord","keyWord"},
178 | blackListKeyWord = {"keyWord","keyWord","keyWord"},
179 |
180 | replaceName = {
181 | name = {
182 | newName = "NewName",
183 | newMsg = "NewMsg",
184 | },
185 | name = {
186 | newName = "NewName",
187 | newMsg = "NewMsg",
188 | },
189 | name = {
190 | newName = "NewName",
191 | newMsg = "NewMsg",
192 | },
193 | },
194 |
195 | replaceKeyWord = {
196 | keyWord = {
197 | newWord = "NewWord",
198 | newMsg = "NewMsg",
199 | },
200 | keyWord = {
201 | newWord = "NewWord",
202 | newMsg = "NewMsg",
203 | },
204 | keyWord = {
205 | newWord = "NewWord",
206 | newMsg = "NewMsg",
207 | },
208 | },
209 | }
210 |
211 | -- 颜色表
212 | Tinom.classes = {
213 | ["HUNTER"] = "ffa9d271",
214 | ["WARLOCK"] = "ff8686ec",
215 | ["PRIEST"] = "fffefefe",
216 | ["PALADIN"] = "fff38bb9",
217 | ["MAGE"] = "ff3ec5e9",
218 | ["ROGUE"] = "fffef367",
219 | ["DRUID"] = "fffe7b09",
220 | ["SHAMAN"] = "ff006fdc",
221 | ["WARRIOR"] = "ffc59a6c",
222 | ["DEATHKNIGHT"] = "ffc31d39",
223 | ["MONK"] = "ff00fe95",
224 | ["DEMONHUNTER"] = "ffa22fc8"
225 | };
--------------------------------------------------------------------------------
/ChatStat/ChatStat.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | parentMsgNum
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
169 |
170 |
171 |
172 | Tdebug(self,"log","ChatStat.xml加载");
173 | self:RegisterForDrag("LeftButton");
174 |
175 |
176 | if not self.isLocked then
177 | self:StartMoving();
178 | end
179 |
180 |
181 | self:StopMovingOrSizing();
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
--------------------------------------------------------------------------------
/ChatStat/ChatStat.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Chat Statistics
4 | -- 聊天统计模块
5 | --
6 | -- 功能:统计角色频道发言,重复发言,广告等信息.
7 | --
8 | -------------------------------------------------------------------------]]--
9 | --测试开关:测试时处理自己的发言,反之则不处理自己的发言.
10 | local IsTest = true;
11 |
12 | --[[-------------------------------------------------------------------------
13 | -- 信息展示开关,
14 | -------------------------------------------------------------------------]]--
15 | Chat_Switch = {
16 | Normal = true,
17 | Normal_A = true,
18 | Spammer = true,
19 | Spammer_A = true,
20 | }
21 |
22 | ChatStat_FilteredList = {
23 | WhiteList = {0,},
24 | WhiteListKeyword = {0,},
25 | BlackList = {0,},
26 | BlackListKeyword = {0,},
27 | ReplaceName = {0,},
28 | ReplaceNameMsg = {0,},
29 | ReplaceKeyword = {0,},
30 | ReplaceKeywordMsg = {0,},
31 | RepeatMsg = {0,},
32 | SensitiveList = {0,},
33 | SensitiveKeyword = {0,},
34 | AutoBlackList = {0,},
35 | FoldMsg = {0,},
36 | IntervalMsg = {0,},
37 | };
38 |
39 | -- 成就变量
40 | local Achievement_Normal = {
41 | "侃侃而谈","论今评古","入门问讳","软言细语",
42 | "谈词如云","谈吐风生","白费口舌","笨嘴笨舌",
43 | "不言不语","钝口拙腮","娇声娇气","缄口不言",
44 | "口干舌燥","伶牙俐齿","唠唠叨叨","能言善辩",
45 | };
46 |
47 | local Achievement_Spammer = {
48 | "喃喃自语","半吞半吐","不动声色","不讳之门",
49 | "沉静寡言","尺水丈波","出口成章","喋喋不休",
50 | "对牛弹琴","隔墙有耳","拐弯抹角","祸从口出",
51 | "尖酸刻薄",
52 | };
53 |
54 | --[[-------------------------------------------------------------------------
55 | -- 成就返回函数
56 | -------------------------------------------------------------------------]]--
57 | local function chat_Achievement(...)
58 | local attribute, chat_level = ...
59 | if (attribute == "Normal") then
60 | --正常发言成就
61 | if (chat_level > #Achievement_Normal) then
62 | return ""
63 | else
64 | return format(",荣获[%s]成就",Achievement_Normal[chat_level])
65 | end
66 | elseif (attribute == "Spammer") then
67 | --重复发言成就
68 | if (chat_level > #Achievement_Spammer) then
69 | return ""
70 | else
71 | return format(",荣获[%s]成就",Achievement_Spammer[chat_level])
72 | end
73 | else
74 | return ""
75 | end
76 | end
77 |
78 | --[[-------------------------------------------------------------------------
79 | -- 播放声音函数
80 | -------------------------------------------------------------------------]]--
81 | local function playsound( arg )
82 | PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON)
83 | end
84 |
85 | --[[-------------------------------------------------------------------------
86 | -- 重复发言处理函数,spammer(垃圾邮件制造者)
87 | -------------------------------------------------------------------------]]--
88 | local function chat_send( ... )
89 | local attribute, write_msg, _, _, channel = ...
90 | --SendChatMessage(write_msg,"CHANNEL",nil,channel);
91 | --SendChatMessage(write_msg,"PARTY",nil);
92 | if true then
93 | return;
94 | end
95 | if ( (Chat_Switch["Normal"] == true) and (attribute == "Normal") ) then
96 | DEFAULT_CHAT_FRAME:AddMessage(write_msg, 0.5, 0.5, 0.5)
97 | PlaySound(7994)
98 | elseif ( (Chat_Switch["Normal_A"] == true) and (attribute == "Normal_A") ) then
99 | DEFAULT_CHAT_FRAME:AddMessage(write_msg, 1.0, 1.0, 0.0)
100 | elseif ( (Chat_Switch["Spammer"] == true) and (attribute == "Spammer") ) then
101 | PlaySound(10590)
102 | DEFAULT_CHAT_FRAME:AddMessage(write_msg, 1.0, 0.0, 0.0)
103 | elseif ( (Chat_Switch["Spammer_A"] == true) and (attribute == "Spammer_A") ) then
104 | DEFAULT_CHAT_FRAME:AddMessage(write_msg, 1.0, 0.5, 0.0)
105 | end
106 | end
107 |
108 | --[[-------------------------------------------------------------------------
109 | -- 普通发言处理函数
110 | -------------------------------------------------------------------------]]--
111 | local function chat_normal( channel, authorName, msg_count )
112 | local write_msg = format("==玩家:[%s]已累计发言[%s]次==",authorName,msg_count)
113 | local chat_level = msg_count / 10;
114 |
115 | if ( chat_level > 0) and ((msg_count % 10) == 0 ) then
116 | write_msg = write_msg..chat_Achievement("Normal",chat_level);
117 | chat_send("Normal_A",write_msg,"CHANNEL",nil,channel);
118 | else
119 | chat_send("Normal",write_msg,"CHANNEL",nil,channel);
120 | end
121 | end
122 |
123 | --[[-------------------------------------------------------------------------
124 | -- 重复发言处理函数,spammer(垃圾邮件制造者)and (not TinomDB.filterDB.blackList[authorName] )
125 | -------------------------------------------------------------------------]]--
126 | local function chat_spammer( channel, authorName, msg_repeat_times, elapsed )
127 | elapsed = elapsed:gsub("|4.-%:","")
128 | local write_msg = format("==玩家:[%s]已重复发言[%s]次,距上次发言[%s]==",authorName,msg_repeat_times, elapsed)
129 | local chat_level = msg_repeat_times / 10;
130 |
131 | if ( chat_level > 0) and ((msg_repeat_times % 10) == 0 ) then
132 | write_msg = write_msg..chat_Achievement("Spammer",chat_level);
133 | chat_send("Spammer_A",write_msg,"CHANNEL",nil,channel);
134 | if Tinom.CheckNameInTable(TinomDB.filterDB.autoBlackList,authorName) then
135 | return false;
136 | end
137 | return true;
138 | else
139 | chat_send("Spammer",write_msg,"CHANNEL",nil,channel);
140 | end
141 | end
142 |
143 | --[[-------------------------------------------------------------------------
144 | -- 事件触发处理函数
145 | -------------------------------------------------------------------------]]--
146 | local function chat_stat_handler(self, event, msg, author,_,_,_,_,_,channelIndex,_,_,lineID, guid,...)
147 | local authorName, authorServer = author:match( "(.-)%-(.*)" )
148 | if (not guid) or (not guid:find("Player")) then
149 | return;
150 | end
151 |
152 | if not authorServer then
153 | authorName = author;
154 | authorServer = "server";
155 | end
156 |
157 | local ignore = false
158 |
159 | if Tinom.IsMe(authorName) and IsTest == false then
160 | return;
161 | end
162 |
163 | if TinomDB.chatStatDB[authorServer] == nil then
164 | TinomDB.chatStatDB[authorServer] = {}
165 | Tdebug(self,"log","==初始化服务器信息==")
166 | end
167 |
168 | -- 初始化角色信息
169 | local _, Class, _, Race, Sex = GetPlayerInfoByGUID(guid)
170 | local authorNameDB_read = TinomDB.chatStatDB[authorServer][authorName]
171 | local authorNameDB_write = TinomDB.chatStatDB[format(authorServer)][format(authorName)]
172 | if authorNameDB_read == nil then
173 |
174 | TinomDB.chatStatDB[authorServer][authorName] = {
175 | msg_count = 1;
176 | msg_last_text = msg;
177 | msg_last_time = time();
178 | msg_repeat_times = 0;
179 | }
180 |
181 | TinomDB.playerDB[guid] = {
182 | name = authorName;
183 | class = Class;
184 | race = Race;
185 | sex = Sex;
186 | };
187 |
188 | elseif authorNameDB_read.msg_last_text == msg then
189 | --重复发言判断
190 | local elapsed = time() - authorNameDB_read.msg_last_time
191 | authorNameDB_write.msg_repeat_times = authorNameDB_write.msg_repeat_times + 1;
192 | authorNameDB_write.msg_count = authorNameDB_read.msg_count + 1;
193 | authorNameDB_write.msg_last_time = time();
194 |
195 | spammer = chat_spammer( channelIndex, authorName, authorNameDB_read.msg_repeat_times, SecondsToTime(elapsed) );
196 | if spammer and TinomDB.Options.Default.Tinom_Switch_MsgFilter_AutoBlackList then
197 | Tinom.AddAuthorToTable(TinomDB.filterDB.autoBlackList,authorName);
198 | Tdebug(self,"log","AutoBlackList"..authorName..":"..msg);
199 | end
200 | else
201 | --正常发言
202 | authorNameDB_write.msg_last_text = msg;
203 | authorNameDB_write.msg_count = authorNameDB_read.msg_count + 1;
204 | authorNameDB_write.msg_last_time = time();
205 | chat_normal( channelIndex, authorName, authorNameDB_read.msg_count );
206 | end
207 |
208 | -- 统计模块更新数据ChatStat_FilteredList
209 | if TinomChatStatFrame:IsShown() then
210 | TinomChatStatFrameMsgNum:SetText(lineID);
211 | local index = 1;
212 | for p,v in pairs(TinomDB.Options.Default.Tinom_Value_MsgFilter_FiltersList) do
213 | local filterName = v[3];
214 | filterName = Tinom.defaultCheckButtonsName[filterName]
215 | local number = ":|cffff0000"..ChatStat_FilteredList[v[3]][1].."|r";
216 | local authorName = (ChatStat_FilteredList[v[3]][2]) or ""
217 | local str = filterName..number..authorName;
218 | TinomChatStatFrame.Texts[index]:SetText(str)
219 | index = index + 1;
220 | end
221 | PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
222 | --PlaySoundFile("Interface/Addons/Tinom/Media/di.ogg","SFX")
223 | end
224 | end
225 |
226 | --[[-------------------------------------------------------------------------
227 | -- 数据库初始化函数
228 | -------------------------------------------------------------------------]]--
229 | local function initializer_DB(...)
230 | if ( TinomDB.chatStatDB ~= nil ) and (TinomDB.filterDB ~= nil ) then
231 | local chat_stat_frame = CreateFrame("Frame")
232 | chat_stat_frame:RegisterEvent("CHAT_MSG_CHANNEL")
233 | chat_stat_frame:SetScript("OnEvent", chat_stat_handler)
234 | return true
235 | else
236 | Tdebug(self,"error","!!!!数据库初始化失败!!!!!")
237 | end
238 | end
239 |
240 | --[[-------------------------------------------------------------------------
241 | -- 过滤器过滤次数统计
242 | -------------------------------------------------------------------------]]--
243 | function Tinom.ChatStat_Filtered(filterName,authorName)
244 | ChatStat_FilteredList[filterName][1] = ChatStat_FilteredList[filterName][1] + 1;
245 | ChatStat_FilteredList[filterName][2] = authorName;
246 | end
247 |
248 | --[[-------------------------------------------------------------------------
249 | -- 入口,注册初始化触发事件
250 | -------------------------------------------------------------------------]]--
251 | function Tinom.ChatStat_OnLoad()
252 | initializer_DB();
253 | end
--------------------------------------------------------------------------------
/Filter/Filter.old.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Filter Model
4 | -- 聊天过滤模块
5 | --
6 | -- 功能:过滤啊!哈哈哈
7 | --
8 | -------------------------------------------------------------------------]]--
9 | -- 临时表
10 | TinomDB_ChatStatDB_cacheMsgTemp = {
11 | TinomChatStatFrameText_ReplaceMsg_Num = 0,
12 | TinomChatStatFrameText_FoldMsg_Num = 0,
13 | TinomChatStatFrameText_BlackList_Num = 0,
14 | TinomChatStatFrameText_BlackKeywordList_Num = 0,
15 | TinomChatStatFrameText_RepeatMsg_Num = 0,
16 | TinomChatStatFrameText_IntervalMsg_Num = 0,
17 | };
18 |
19 | TinomDB_filterDB_whiteListTemp = {};
20 | TinomDB_filterDB_blackListTemp = {};
21 | TinomDB_playerDB_classTemp = {};
22 |
23 | -- 当前玩家名
24 | local playerName = UnitName("player");
25 |
26 | -- 颜色表
27 | Tinom.classes = {
28 | ["HUNTER"] = "ffa9d271",
29 | ["WARLOCK"] = "ff8686ec",
30 | ["PRIEST"] = "fffefefe",
31 | ["PALADIN"] = "fff38bb9",
32 | ["MAGE"] = "ff3ec5e9",
33 | ["ROGUE"] = "fffef367",
34 | ["DRUID"] = "fffe7b09",
35 | ["SHAMAN"] = "ff006fdc",
36 | ["WARRIOR"] = "ffc59a6c",
37 | ["DEATHKNIGHT"] = "ffc31d39",
38 | ["MONK"] = "ff00fe95",
39 | ["DEMONHUNTER"] = "ffa22fc8"
40 | };
41 |
42 | --[[-------------------------------------------------------------------------
43 | -- 聊天频道名替换函数:因上级函数使用频道名字符串长度作为逻辑条件不便更改,
44 | -- 故通过接管聊天框的AddMessage函数替换字符串,此处为把频道序号后的频道名隐藏.
45 | -------------------------------------------------------------------------]]--
46 | function Tinom.ReplaceChannelName()
47 | for i=1,NUM_CHAT_WINDOWS do
48 | if (i ~= 2) then
49 | local chatFrame = _G["ChatFrame"..i]
50 | local addmsg = chatFrame.AddMessage
51 | chatFrame.AddMessage = function(frame, text,...)
52 | if ( Tinom.Tinom_Switch_MsgFilter_Classic ) then
53 | local name = text:match("|Hplayer.-|h%[(%S-)%]|h")
54 | if ( name ) then
55 | local playerClass = TinomDB_playerDB_classTemp[name] or "PRIEST";
56 | local colorname = "|c"..Tinom.classes[playerClass]..name.."|r"
57 | text = string.gsub(text,"%["..name.."%]","%["..colorname.."%]")
58 | end
59 | end
60 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrChannelName) then
61 | text = text:gsub( "%[(%d)%..-%]", "%[%1%]" )
62 | end
63 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrAuthorName) then
64 | text = text:gsub( "(%|%w-%S-)%-%S-%|", "%1%#%|" );
65 | end
66 | return addmsg(frame,text,...)
67 | end
68 | end
69 | end
70 | end
71 |
72 | --[[-------------------------------------------------------------------------
73 | -- 角色名替换函数:替换角色消息开关,替换名单
74 | -------------------------------------------------------------------------]]--
75 | function Tinom.ReplaceName( name )
76 | --Tdebug(self,"log","Tinom.ReplaceName.触发");
77 | local authorName, authorServer = name:match( "(.-)(%-.*)" );
78 | local newName,newMsg = nil, nil;
79 |
80 | for k,v in pairs(TinomDB.filterDB.replaceName) do
81 | if ( name == k ) then
82 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceName == true ) and (#v.newName > 0) then
83 | newName = v.newName;
84 | end
85 | if ( ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceNameMsg == true ) and (#v.newMsg > 0) ) then
86 | newMsg = v.newMsg;
87 | end
88 | return newMsg, newName;
89 | elseif ( authorName == k ) then
90 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceName == true ) and (#v.newName > 0) then
91 | newName = v.newName..authorServer;
92 | end
93 | if ( ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceNameMsg == true ) and (#v.newMsg > 0) ) then
94 | newMsg = v.newMsg;
95 | end
96 | return newMsg, newName;
97 | end
98 | end
99 | return newMsg, newName;
100 | end
101 |
102 | --[[-------------------------------------------------------------------------
103 | -- 消息替换函数:替换关键字消息开关,替换关键字名单
104 | -------------------------------------------------------------------------]]--
105 | function Tinom.ReplaceMsg( ... )
106 | --Tdebug(self,"log","Tinom.ReplaceMsg.触发");
107 | local msg = ...;
108 | local newMsg = nil;
109 | for k,v in pairs(TinomDB.filterDB.replaceKeyWord) do
110 | if ( msg:find(k) ) then
111 | if ( ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceKeyWordMsg == true ) and #v.newMsg > 0 ) then
112 | newMsg = v.newMsg;
113 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_ReplaceMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_ReplaceMsg_Num+0.1;
114 | return newMsg;
115 | end
116 | if ( ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceKeyWord == true ) and #v.newWord > 0 ) then
117 | newMsg = msg:gsub(k,v.newWord);
118 | end
119 | msg = newMsg or msg;
120 | end
121 | end
122 | -- if msg ~= ... then
123 | -- TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_ReplaceMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_ReplaceMsg_Num+0.1;
124 | -- end
125 | return msg;
126 | end
127 |
128 | --[[-------------------------------------------------------------------------
129 | -- 重复信息过滤函数:
130 | -------------------------------------------------------------------------]]--
131 | function Tinom.RepeatMsg( self,event,msg,authorName,authorServer )
132 | if TinomDB.chatStatDB[authorServer] then
133 | if TinomDB.chatStatDB[authorServer][authorName] then
134 | local elapsed = time() - TinomDB.chatStatDB[authorServer][authorName].msg_last_time;
135 | --Tdebug(self,"log","Tinom.RepeatMsg."..elapsed);
136 | if TinomDB.Options.Default.Tinom_Switch_MsgFilter_IntervalMsg then
137 | if ((elapsed < TinomDB.Options.Default.Tinom_Value_MsgFilter_IntervalMsgTime)
138 | or (TinomDB.Options.Default.Tinom_Value_MsgFilter_IntervalMsgTime == 0)) then
139 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_IntervalMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_IntervalMsg_Num+0.1;
140 | return true;
141 | end
142 | end
143 | if TinomDB.Options.Default.Tinom_Switch_MsgFilter_RepeatMsg then
144 | if ((elapsed < TinomDB.Options.Default.Tinom_Value_MsgFilter_RepeatMsgElapsed)
145 | or (TinomDB.Options.Default.Tinom_Value_MsgFilter_RepeatMsgElapsed == 0)) then
146 | if TinomDB.chatStatDB[authorServer][authorName].msg_last_text == msg then
147 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_RepeatMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_RepeatMsg_Num+0.1;
148 | return true;
149 | end
150 | end
151 | end
152 | end
153 | end
154 | return false;
155 | end
156 | --[[-------------------------------------------------------------------------
157 | -- 重复信息过滤函数:
158 | -------------------------------------------------------------------------]]--
159 |
160 | --[[-------------------------------------------------------------------------
161 | -- 折叠复读消息
162 | -------------------------------------------------------------------------]]--
163 | function Tinom.FoldMsg( newArg1 )
164 | local theMsg = newArg1;
165 | local heatSample = theMsg:match("^......")
166 | if heatSample then
167 | heatSample = heatSample:gsub("(%p)","%%%1")
168 | local a = theMsg:find(heatSample,#heatSample);
169 | if a then
170 | local msg2 = strsub(theMsg,1,a-1)
171 | msg2 = msg2:gsub("(%p)","%%%1")
172 | if theMsg:find(msg2,a+1) then
173 | theMsg, num = theMsg:gsub(msg2,"")
174 | msg2 = msg2:gsub("%%","")
175 | theMsg = msg2..theMsg.." x"..num
176 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_FoldMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_FoldMsg_Num+0.1;
177 | end
178 | end
179 | newArg1 = theMsg;
180 | return newArg1;
181 | end
182 | end
183 |
184 | --[[-------------------------------------------------------------------------
185 | -- 消息过滤函数:白名单开关,黑名单开关,白名单,临时白名单,黑名单,临时黑名单,
186 | -- 替换角色名开关,替换关键字开关 or (authorName == playerName)
187 | -------------------------------------------------------------------------]]--
188 | function Tinom.MsgFilter( self,event,... )
189 | if ( not TinomDB.Options.Default.Tinom_Switch_MsgFilter_MainEnable )then
190 | return false;
191 | end
192 | --if ( event ~= "CHAT_MSG_CHANNEL" ) then return end
193 | local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14 = ...;
194 | if (not arg12) or (not arg12:find("Player")) then return; end
195 | local authorName, authorServer = arg2:match( "(.-)%-(.*)" )
196 | --local eventType = strsub(event, 10);
197 |
198 | -- 针对怀旧服--##--
199 | if not authorServer then
200 | authorName = arg2;
201 | authorServer = "server";
202 | end
203 | -- 怀旧服缓存发言角色职业
204 | if Tinom.Tinom_Switch_MsgFilter_Classic then
205 | local _, Class = GetPlayerInfoByGUID(arg12);
206 | TinomDB_playerDB_classTemp[authorName] = Class;
207 | end
208 |
209 | -- 统计函数 --
210 | --统计函数
211 |
212 | local newArg1, newArg2 = nil, nil;
213 | local ignoreKey = true;
214 |
215 | -- 白名单过滤 --
216 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteList ) then
217 | for k,v in pairs(TinomDB.filterDB.whiteList) do
218 | if ( authorName == v ) then
219 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListSound) then
220 | PlaySound(TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListSoundID);
221 | end
222 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListHighlight) then
223 | arg1 = "|cffffff00"..arg1.."|r"
224 | end
225 | ignoreKey = false;
226 | --return false, newArg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14;
227 | end
228 | end
229 | -- if ( TinomDB.filterDB.whiteList[authorName] or TinomDB_filterDB_whiteListTemp[authorName] ) then
230 | -- return false;
231 | -- end
232 | end
233 |
234 | -- 关键字白名单 --
235 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListKeyWord ) then
236 | for _,v in pairs(TinomDB.filterDB.whiteListKeyWord) do
237 | if arg1:find(v) then
238 | if TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListKeyWordSound then
239 | PlaySound(TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListSoundID);
240 | end
241 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListKeyWordHighlight) then
242 | arg1 = arg1:gsub(v,"|cffffff00"..v.."|r")
243 | end
244 | ignoreKey = false;
245 | --return false, newArg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14;
246 | end
247 | end
248 | end
249 |
250 | if ignoreKey == false then
251 | -- 历史20条信息内重复,不区分角色 --
252 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_RepeatMsg or TinomDB.Options.Default.Tinom_Switch_MsgFilter_IntervalMsg ) then
253 | if ( Tinom.RepeatMsg( self,event,arg1,authorName,authorServer) ) then
254 | return true;
255 | end
256 | end
257 | -- 替换功能 --也可以使用元表方法setmetatable(table1,table2)
258 | if ((TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceName)
259 | or (TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceNameMsg)) then
260 | newArg1, newArg2 = Tinom.ReplaceName( arg2 );
261 | end
262 |
263 | if ((TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceKeyWord)
264 | or (TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceKeyWordMsg)) then
265 | newArg1 = Tinom.ReplaceMsg( newArg1 or arg1 );
266 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_ReplaceMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_ReplaceMsg_Num+0.1;
267 | end
268 |
269 | if ( newArg1 == nil ) then newArg1 = arg1; end
270 | if ( newArg2 == nil ) then newArg2 = arg2; end
271 |
272 | -- 折叠复读消息
273 | local strLength = string.len( newArg1 )
274 | if ((TinomDB.Options.Default.Tinom_Switch_MsgFilter_FoldMsg) and (strLength > 20)) then
275 | newArg1 = Tinom.FoldMsg( newArg1 ) or newArg1;
276 | end
277 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_FoldMsg_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_FoldMsg_Num+0.1;
278 | return false, newArg1, newArg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14;
279 | end
280 |
281 | -- 白名单模式
282 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_WhiteListOnly) then
283 | return true;
284 | end
285 |
286 | -- 黑名单过滤 --
287 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackList ) then
288 | for k,v in pairs(TinomDB.filterDB.blackList) do
289 | if ( authorName == v ) then
290 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_BlackList_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_BlackList_Num+0.1;
291 | return true;
292 | end
293 | end
294 | -- if ( TinomDB.filterDB.blackList[authorName] or TinomDB_filterDB_blackListTemp[authorName]) then
295 | -- return true;
296 | -- end
297 | end
298 |
299 | -- 关键字黑名单过滤 --
300 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackListKeyWord ) then
301 | for _,v in pairs(TinomDB.filterDB.blackListKeyWord) do
302 | if arg1:find(v) then
303 | TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_BlackKeywordList_Num=TinomDB_ChatStatDB_cacheMsgTemp.TinomChatStatFrameText_BlackKeywordList_Num+0.1;
304 | return true;
305 | end
306 | end
307 | end
308 |
309 | -- 历史20条信息内重复,不区分角色 --
310 | if ( TinomDB.Options.Default.Tinom_Switch_MsgFilter_RepeatMsg or TinomDB.Options.Default.Tinom_Switch_MsgFilter_IntervalMsg ) then
311 | if ( Tinom.RepeatMsg( self,event,arg1,authorName,authorServer ) ) then
312 | return true;
313 | end
314 | end
315 |
316 | -- 替换功能 --也可以使用元表方法setmetatable(table1,table2)
317 | if ((TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceName)
318 | or (TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceNameMsg)
319 | ) then
320 | newArg1, newArg2 = Tinom.ReplaceName( arg2 );
321 | end
322 |
323 | if ((TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceKeyWord
324 | or (TinomDB.Options.Default.Tinom_Switch_MsgFilter_ReplaceKeyWordMsg)
325 | ) and (newArg1 == nil)) then
326 | newArg1 = Tinom.ReplaceMsg( arg1 );
327 | end
328 |
329 | if ( newArg1 == nil ) then newArg1 = arg1; end
330 | if ( newArg2 == nil ) then newArg2 = arg2; end
331 |
332 | -- 折叠复读消息
333 | local strLength = string.len( newArg1 )
334 | if ((TinomDB.Options.Default.Tinom_Switch_MsgFilter_FoldMsg) and (strLength > 20)) then
335 | newArg1 = Tinom.FoldMsg( newArg1 ) or newArg1;
336 | end
337 |
338 | return false, newArg1, newArg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14;
339 | end
340 |
341 | --[[-------------------------------------------------------------------------
342 | -- 消息过滤函数:过滤物品消息,屏蔽灰色物品
343 | -------------------------------------------------------------------------]]--
344 | function Tinom.MsgFilter_Item( self, event, ... )
345 | if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_IgnoreGrayItems then return; end
346 | local arg1 = ...;
347 | local itemID = GetItemInfoFromHyperlink(arg1);
348 | local itemName,_,itemRarity = GetItemInfo(itemID);
349 | Tdebug(self,"log","MsgFilter_Item:"..itemName..itemID.."品质:"..itemRarity);
350 | if itemRarity == 0 then
351 | return true;
352 | end
353 | return false;
354 | end
355 |
356 | --[[-------------------------------------------------------------------------
357 | -- 消息过滤函数:开
358 | -------------------------------------------------------------------------]]--
359 | function Tinom.MsgFilterOn()
360 | filterDB_Temp = TinomDB.filterDB;
361 | ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", Tinom.MsgFilter)
362 | ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", Tinom.MsgFilter)
363 | ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", Tinom.MsgFilter)
364 | --ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", Tinom.MsgFilter)
365 | ChatFrame_AddMessageEventFilter("CHAT_MSG_LOOT", Tinom.MsgFilter_Item)
366 | print("过滤已开启")
367 | end
368 |
369 | --[[-------------------------------------------------------------------------
370 | -- 消息过滤函数:关
371 | -------------------------------------------------------------------------]]--
372 | function Tinom.MsgFilterOff()
373 | filterDB_Temp = {};
374 | ChatFrame_RemoveMessageEventFilter("CHAT_MSG_CHANNEL", Tinom.MsgFilter)
375 | ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SAY", Tinom.MsgFilter)
376 | ChatFrame_RemoveMessageEventFilter("CHAT_MSG_YELL", Tinom.MsgFilter)
377 | --ChatFrame_RemoveMessageEventFilter("CHAT_MSG_WHISPER", Tinom.MsgFilter)
378 | ChatFrame_RemoveMessageEventFilter("CHAT_MSG_LOOT", Tinom.MsgFilter_Item)
379 | print("过滤已关闭")
380 | end
381 |
382 |
383 | Tdebug(self,"log","Filter.lua加载完成");
--------------------------------------------------------------------------------
/Filter/Filter.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | -- <姑娘 姑娘> - 郭斯
3 | -- 刚刚路上看到一个浑身脏兮兮的男孩,眼睛一直盯着路上一个小女孩手里拿着的牛奶。
4 | -- 小女孩喝完了把牛奶随手一丢,那个小男孩赶忙过去蹲下捡起地上的牛奶,并放进嘴里。
5 | -- 看到这个画面我鼻子不禁一酸,刚想拉起男孩,就看见他把盒子吹得鼓鼓的放在地上猛地一脚下去“砰!”他马的吓老子一跳!
6 | ]]--
7 | -- 临时表
8 | TinomDB_ChatStatDB_cacheMsgTemp = {
9 | TinomChatStatFrameText_ReplaceMsg_Num = 0,
10 | TinomChatStatFrameText_FoldMsg_Num = 0,
11 | TinomChatStatFrameText_BlackList_Num = 0,
12 | TinomChatStatFrameText_BlackKeywordList_Num = 0,
13 | TinomChatStatFrameText_RepeatMsg_Num = 0,
14 | TinomChatStatFrameText_IntervalMsg_Num = 0,
15 | };
16 |
17 | TinomDB_filterDB_whiteListTemp = {};
18 | TinomDB_filterDB_blackListTemp = {};
19 | TinomDB_playerDB_classTemp = {};
20 |
21 | -- 当前玩家名
22 | local playerName = UnitName("player");
23 |
24 | -- 声音提醒 --
25 | Tinom.ReminderType = {
26 | ["SensitiveKeyword"] = {
27 | switch = "Tinom_Switch_MsgFilter_SensitiveKeywordSound",
28 | soundID = "Tinom_Switch_MsgFilter_SensitiveKeywordSoundID",
29 | };
30 | ["SensitiveList"] = {
31 | switch = "Tinom_Switch_MsgFilter_SensitiveListSound",
32 | soundID = "Tinom_Switch_MsgFilter_SensitiveKeywordSoundID",
33 | };
34 | };
35 |
36 | --[[-------------------------------------------------------------------------
37 | -- AddMessage过滤
38 | -------------------------------------------------------------------------]]--
39 | function Tinom.ReplaceChannelName()
40 | for i=1,NUM_CHAT_WINDOWS do
41 | if (i ~= 2) then
42 | local chatFrame = _G["ChatFrame"..i]
43 | local addmsg = chatFrame.AddMessage
44 | chatFrame.AddMessage = function(frame, text,...)
45 | if (Tinom.addMsgFilters) then
46 | for _, filterFunc in next, Tinom.addMsgFilters do
47 | text = filterFunc(text);
48 | end
49 | end
50 | Tdebug(self,"log",frame.name..":"..text)
51 | return addmsg(frame,text,...)
52 | end
53 | end
54 | end
55 | end
56 | function Tinom.AddMessageFilter_AddMsgFilter (filter)
57 | assert(filter);
58 |
59 | if ( Tinom.addMsgFilters ) then
60 | -- Only allow a filter to be added once
61 | for index, filterFunc in next, Tinom.addMsgFilters do
62 | if ( filterFunc == filter ) then
63 | return;
64 | end
65 | end
66 | else
67 | Tinom.addMsgFilters = {};
68 | end
69 |
70 | tinsert(Tinom.addMsgFilters, filter);
71 | end
72 |
73 | function Tinom.AddMessageFilter_RemoveMsgFilter (filter)
74 | assert(filter);
75 |
76 | if ( Tinom.addMsgFilters ) then
77 | for index, filterFunc in next, Tinom.addMsgFilters do
78 | if ( filterFunc == filter ) then
79 | tremove(Tinom.addMsgFilters, index);
80 | end
81 | end
82 |
83 | if ( #Tinom.addMsgFilters == 0 ) then
84 | Tinom.addMsgFilters = nil;
85 | end
86 | end
87 | end
88 |
89 | function Tinom.AddMessageFilter_AbbrChannelName( text )
90 | --local player, lineID, channelName, channelNum, playerName = string.match( text,"|Hplayer:(.-):(.-):(.-):(.-)|h%[(.-)%]|h")
91 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrChannelName) then
92 | text = text:gsub( "%[(%d).-%]", "[%1]", 1 )
93 | end
94 | return text;
95 | end
96 |
97 | function Tinom.AddMessageFilter_AbbrAuthorName( text )
98 | --local player, lineID, channelName, channelNum, playerName = string.match( text,"|Hplayer:(.-):(.-):(.-):(.-)|h%[(.-)%]|h")
99 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrAuthorName) then
100 | text = text:gsub( "%[|cff(%x%x%x%x%x%x)(.-)(%-%S%S%S).-|r%]", "[|cff%1%2%3|r]", 1 );
101 | end
102 | return text;
103 | end
104 |
105 | function Tinom.AddMessageFilter_AuthorAliasName( text )
106 | local fullName, authorName, authorServer = string.match( text,"|Hplayer:((.-)%-(.-)):")
107 | for k,v in pairs(TinomDB.filterDB.replaceName) do
108 | if ( authorName and (authorName == k) ) then
109 | if (v) then
110 | text = text:gsub(authorName,v,2);
111 | text = text:gsub(v,authorName,1);
112 | Tinom.ChatStat_Filtered("ReplaceName",authorName);
113 | return text;
114 | end
115 | elseif ( fullName and (fullName == k) ) then
116 | if (v) then
117 | text = text:gsub(authorName,v,2);
118 | text = text:gsub(v,authorName,1);
119 | Tinom.ChatStat_Filtered("ReplaceName",authorName);
120 | return text;
121 | end
122 | end
123 | end
124 | return text;
125 | end
126 |
127 | --[[-------------------------------------------------------------------------
128 | -- 频道过滤
129 | -------------------------------------------------------------------------]]--
130 | function Tinom.MsgFilter( self,event,... )
131 | if ( not TinomDB.Options.Default.Tinom_Switch_MsgFilter_MainEnable )then
132 | return false;
133 | end
134 | local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14 = ...;
135 | if not Tinom.CheckChannelLsit(self,arg9) then
136 | return false;
137 | end
138 |
139 | --if ( event ~= "CHAT_MSG_CHANNEL" ) then return end
140 | --local eventType = strsub(event, 10);
141 | if (not arg12) or (not arg12:find("Player")) then return; end
142 | local authorName, authorServer = arg2:match( "(.-)%-(.*)" )
143 |
144 | if authorName == playerName then
145 | --return false;
146 | end
147 | -- 针对怀旧服--##--
148 | if not authorServer then
149 | authorName = arg2;
150 | authorServer = "server";
151 | end
152 |
153 | -- 统计函数 --
154 |
155 | local ignore = false;
156 | local remind = nil;
157 | if ( msgFilters ) then
158 | local newArg1, newArg2;
159 | for _, filterFunc in next, msgFilters do
160 | ignore, newArg1, newArg2, remind = filterFunc(arg1, authorName, authorServer, remind);
161 | if ( ignore == true ) then
162 | return true;
163 | else
164 | arg1 = newArg1 or arg1;
165 | arg2 = newArg2 or arg2;
166 | end
167 | if (ignore == "RightNow!") then
168 | ignore = false;
169 | break;
170 | end
171 | end
172 | if (remind) then
173 | Tinom.Reminder(remind)
174 | end
175 | end
176 | return ignore, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14;
177 | end
178 |
179 | function Tinom.CheckChannelLsit(self,arg9)
180 | for i,v in ipairs(self.channelList) do
181 | if arg9 == v then
182 | return true;
183 | end
184 | end
185 | return false;
186 | end
187 |
188 | function Tinom.MsgFilter_AddMsgFilter (filter)
189 | assert(filter);
190 |
191 | if ( msgFilters ) then
192 | -- Only allow a filter to be added once
193 | for index, filterFunc in next, msgFilters do
194 | if ( filterFunc == filter ) then
195 | return;
196 | end
197 | end
198 | else
199 | msgFilters = {};
200 | end
201 |
202 | tinsert(msgFilters, filter);
203 | end
204 |
205 | function Tinom.MsgFilter_RemoveMsgFilter (filter)
206 | assert(filter);
207 |
208 | if ( msgFilters ) then
209 | for index, filterFunc in next, msgFilters do
210 | if ( filterFunc == filter ) then
211 | tremove(msgFilters, index);
212 | end
213 | end
214 |
215 | if ( #msgFilters == 0 ) then
216 | msgFilters = nil;
217 | end
218 | end
219 | end
220 |
221 | function Tinom.MsgFilter_Whitelist(msg, authorName, authorServer, remind)
222 | assert(authorName and msg);
223 |
224 | for k,v in pairs(TinomDB.filterDB.whiteList) do
225 | if ( authorName == v ) then
226 | return false, nil, nil, remind;
227 | end
228 | end
229 | Tinom.ChatStat_Filtered("WhiteList",authorName);
230 | return true;
231 | end
232 |
233 | function Tinom.MsgFilter_WhitelistKeyword( msg, authorName, authorServer, remind)
234 | assert(authorName and msg);
235 |
236 | for _,keyword in pairs(TinomDB.filterDB.whiteListKeyword) do
237 | if msg:find(keyword) then
238 | return false, nil, nil, remind;
239 | end
240 | end
241 | Tinom.ChatStat_Filtered("WhiteListKeyword",authorName);
242 | return true;
243 | end
244 |
245 | function Tinom.MsgFilter_Blacklist( msg,authorName,authorServer, remind )
246 | assert(authorName);
247 |
248 | if (Tinom.CheckNameInTable(TinomDB.filterDB.blackList,authorName)) then
249 | Tinom.ChatStat_Filtered("BlackList",authorName);
250 | remind = nil;
251 | return true, nil, nil, remind;
252 | end
253 | return false, nil, nil, remind;
254 | end
255 |
256 | function Tinom.MsgFilter_BlacklistKeyword( msg,authorName,authorServer, remind )
257 | assert(authorName and msg);
258 |
259 | if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive then
260 | msg = string.lower(msg);
261 | end
262 | for _,keyword in pairs(TinomDB.filterDB.blackListKeyword) do
263 | if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive then
264 | keyword = string.lower(keyword);
265 | end
266 | if msg:find(keyword) then
267 | Tinom.ChatStat_Filtered("BlackListKeyword",authorName);
268 | return true, nil, nil, remind;
269 | end
270 | end
271 | return false, nil, nil, remind;
272 | end
273 |
274 | function Tinom.MsgFilter_SensitiveList( msg,authorName,authorServer, remind )
275 | for k,v in pairs(TinomDB.filterDB.whiteList) do
276 | if ( authorName == v ) then
277 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListHighlight) then
278 | newArg1 = "|cffffff00"..msg.."|r"
279 | else
280 | newArg1 = msg;
281 | end
282 | Tinom.ChatStat_Filtered("SensitiveList",authorName);
283 | remind = "SensitiveList";
284 | ignore = "RightNow!";
285 | return ignore, newArg1, nil, remind;
286 | end
287 | end
288 | return false, nil, nil, remind;
289 | end
290 |
291 | function Tinom.MsgFilter_SensitiveKeyword( msg,authorName,authorServer, remind )
292 | for _,keyword in pairs(TinomDB.filterDB.sensitiveKeyword) do
293 | if msg:find(keyword) then
294 | if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordHighlight) then
295 | newArg1 = msg:gsub(keyword,"|cffffff00"..keyword.."|r")
296 | else
297 | newArg1 = msg;
298 | end
299 | Tinom.ChatStat_Filtered("SensitiveKeyword",authorName);
300 | remind = "SensitiveKeyword";
301 | ignore = "RightNow!";
302 | return ignore, newArg1, nil, remind;
303 | end
304 | end
305 | return false, nil, nil, remind;
306 | end
307 |
308 | function Tinom.MsgFilter_AutoBlackList( msg,authorName,authorServer, remind )
309 | assert(authorName);
310 |
311 | if (Tinom.CheckNameInTable(TinomDB.filterDB.autoBlackList,authorName)) then
312 | Tinom.ChatStat_Filtered("AutoBlackList",authorName);
313 | remind = nil;
314 | return true, nil, nil, remind;
315 | end
316 | return false, nil, nil, remind;
317 | end
318 |
319 | function Tinom.MsgFilter_RepeatMsg( msg,authorName,authorServer, remind )
320 | assert(authorName and msg and authorServer);
321 |
322 | local exist,elapsed = Tinom.MsgFilter_IsAuthorExist( authorName,authorServer );
323 | if exist and ((elapsed < TinomDB.Options.Default.Tinom_Value_MsgFilter_RepeatMsgElapsed)
324 | or (TinomDB.Options.Default.Tinom_Value_MsgFilter_RepeatMsgElapsed == 0)) then
325 | if TinomDB.chatStatDB[authorServer][authorName].msg_last_text == msg then
326 | Tinom.ChatStat_Filtered("RepeatMsg",authorName);
327 | return true, nil, nil, remind;
328 | end
329 | end
330 | return false, nil, nil, remind;
331 | end
332 |
333 | function Tinom.MsgFilter_IntervalMsg( msg,authorName,authorServer, remind )
334 | assert(authorName and authorServer);
335 |
336 | local exist, elapsed = Tinom.MsgFilter_IsAuthorExist( authorName,authorServer );
337 | if exist and ((elapsed < TinomDB.Options.Default.Tinom_Value_MsgFilter_IntervalMsgTime)
338 | or (TinomDB.Options.Default.Tinom_Value_MsgFilter_IntervalMsgTime == 0)) then
339 | Tinom.ChatStat_Filtered("IntervalMsg",authorName);
340 | return true, nil, nil, remind;
341 | end
342 | return false, nil, nil, remind;
343 | end
344 |
345 | function Tinom.MsgFilter_IsAuthorExist( authorName,authorServer )
346 | if TinomDB.chatStatDB[authorServer] then
347 | if TinomDB.chatStatDB[authorServer][authorName] then
348 | local elapsed = time() - TinomDB.chatStatDB[authorServer][authorName].msg_last_time;
349 | return true, elapsed;
350 | end
351 | end
352 | return false;
353 | end
354 |
355 | function Tinom.MsgFilter_FoldMsg( msg,authorName,authorServer, remind )
356 | if #msg<20 then
357 | return false, msg;
358 | end
359 | newMsg = msg:gsub("%s+","");
360 | local heatSample = newMsg:match("^......");
361 | heatSample = heatSample:gsub("(%p)","%%%1");
362 | local heatLength = newMsg:find(heatSample,#heatSample);
363 |
364 | if heatLength then
365 | local foldMsg = strsub(newMsg,1,heatLength-1);
366 | foldMsg = foldMsg:gsub("(%p)","%%%1");
367 | if newMsg:find(foldMsg,heatLength) then
368 | newMsg, num = newMsg:gsub(foldMsg,"");
369 | foldMsg = foldMsg:gsub("%%","");
370 | newArg1 = foldMsg..newMsg.." x"..num;
371 | Tinom.ChatStat_Filtered("FoldMsg",authorName);
372 | return false, newArg1;
373 | end
374 | end
375 | return false, msg, nil, remind;
376 | end
377 |
378 | -- function Tinom.MsgFilter_ReplaceName( msg,authorName,authorServer, remind )
379 | -- local newMsg,newName;
380 | -- local name = authorName.."-"..authorServer;
381 |
382 | -- for k,v in pairs(TinomDB.filterDB.replaceName) do
383 | -- if ( authorName == k ) then
384 | -- if (v) then
385 | -- Tinom.ChatStat_Filtered("ReplaceName",authorName);
386 | -- newName = v.."-"..authorServer;
387 | -- return false, newMsg, newName, remind;
388 | -- end
389 | -- elseif ( name == k ) then
390 | -- if (v) then
391 | -- Tinom.ChatStat_Filtered("ReplaceName",authorName);
392 | -- newName = v;
393 | -- return false, newMsg, newName, remind;
394 | -- end
395 | -- end
396 | -- end
397 | -- return false, newMsg, newName, remind;
398 | -- end
399 |
400 | function Tinom.MsgFilter_ReplaceNameMsg( msg,authorName,authorServer, remind )
401 | local newMsg,newName;
402 | local name = authorName.."-"..authorServer;
403 |
404 | for k,v in pairs(TinomDB.filterDB.replaceNameMsg) do
405 | if ( authorName == k ) then
406 | if (v) then
407 | Tinom.ChatStat_Filtered("ReplaceNameMsg",authorName);
408 | newMsg = v;
409 | return false, newMsg, newName, remind;
410 | end
411 | elseif ( name == k ) then
412 | if (v) then
413 | Tinom.ChatStat_Filtered("ReplaceNameMsg",authorName);
414 | newMsg = v;
415 | return false, newMsg, newName, remind;
416 | end
417 | end
418 | end
419 | return false, newMsg, newName, remind;
420 | end
421 |
422 | function Tinom.MsgFilter_ReplaceKeyword( msg,authorName,authorServer, remind )
423 | local newMsg = msg;
424 | for i=1,2 do
425 | for k,v in pairs(TinomDB.filterDB.replaceKeyword) do
426 | if (v) then
427 | newMsg = newMsg:gsub(k,v);
428 | end
429 | end
430 | end
431 | if newMsg~=msg then
432 | Tinom.ChatStat_Filtered("ReplaceKeyword",authorName);
433 | end
434 | return false, newMsg, nil, remind;
435 | end
436 |
437 | function Tinom.MsgFilter_ReplaceKeywordMsg( msg,authorName,authorServer, remind )
438 | local newMsg;
439 | for k,v in pairs(TinomDB.filterDB.replaceKeywordMsg) do
440 | if ( msg:find(k) ) then
441 | if (v) then
442 | Tinom.ChatStat_Filtered("ReplaceKeywordMsg",authorName);
443 | newMsg = v;
444 | return false, newMsg, nil, remind;
445 | end
446 | end
447 | end
448 | return false, nil, nil, remind;
449 | end
450 |
451 | function Tinom.Reminder( type )
452 | if not type then return; end
453 |
454 | if TinomDB.Options.Default[Tinom.ReminderType[type].switch] then
455 | PlaySound(TinomDB.Options.Default[Tinom.ReminderType[type].soundID]);
456 | end
457 | end
458 |
459 | --[[-------------------------------------------------------------------------
460 | -- 拾取过滤
461 | -------------------------------------------------------------------------]]--
462 | function Tinom.MsgFilter_Item( self, event, ... )
463 | if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_IgnoreGrayItems then return; end
464 | local arg1 = ...;
465 | local itemID = GetItemInfoFromHyperlink(arg1);
466 | local itemName,_,itemRarity = GetItemInfo(itemID);
467 | Tdebug(self,"log","MsgFilter_Item:"..itemName..itemID.."品质:"..itemRarity);
468 | if itemRarity == 0 then
469 | return true;
470 | end
471 | return false;
472 | end
473 |
474 | --[[-------------------------------------------------------------------------
475 | -- 消息过滤函数:开
476 | -------------------------------------------------------------------------]]--
477 | function Tinom.MsgFilterOn()
478 | filterDB_Temp = TinomDB.filterDB;
479 | ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", Tinom.MsgFilter)
480 | --ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", Tinom.MsgFilter)
481 | --ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", Tinom.MsgFilter)
482 | --ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", Tinom.MsgFilter)
483 | ChatFrame_AddMessageEventFilter("CHAT_MSG_LOOT", Tinom.MsgFilter_Item)
484 | print("过滤已开启")
485 | end
486 |
487 | --[[-------------------------------------------------------------------------
488 | -- 消息过滤函数:关
489 | -------------------------------------------------------------------------]]--
490 | function Tinom.MsgFilterOff()
491 | filterDB_Temp = {};
492 | ChatFrame_RemoveMessageEventFilter("CHAT_MSG_CHANNEL", Tinom.MsgFilter)
493 | --ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SAY", Tinom.MsgFilter)
494 | --ChatFrame_RemoveMessageEventFilter("CHAT_MSG_YELL", Tinom.MsgFilter)
495 | --ChatFrame_RemoveMessageEventFilter("CHAT_MSG_WHISPER", Tinom.MsgFilter)
496 | ChatFrame_RemoveMessageEventFilter("CHAT_MSG_LOOT", Tinom.MsgFilter_Item)
497 | print("过滤已关闭")
498 | end
499 |
--------------------------------------------------------------------------------
/test/test.lua:
--------------------------------------------------------------------------------
1 |
2 | -- 获取插件的插件名和插件表
3 | local addonName, addon = ...
4 |
5 | -- 设置插件的全局名称
6 | Test = {};
7 |
8 | -- 当前玩家名
9 | --local playerName = UnitName("player");
10 |
11 | -- 界面隐藏/显示
12 | -- /run MinimapCluster:Hide();MainMenuBarArtFrame:Hide();PlayerFrame:Hide();MicroButtonAndBagsBar:Hide();StatusTrackingBarManager:Hide();MainMenuBarOverlayFrame:Hide();
13 | -- /run MinimapCluster:Show();MainMenuBarArtFrame:Show();PlayerFrame:Show();MicroButtonAndBagsBar:Show();StatusTrackingBarManager:Show();
14 |
15 | --[[-------------------------------------------------------------------------
16 | -- 从TOC文件中提取版本信息
17 | -------------------------------------------------------------------------]]--
18 | addon.version = GetAddOnMetadata(addonName, "Version")
19 | print("当前插件版本:"..addon.version)
20 | if addon.version == "@project-version" or addon.version == "wowi:version" then
21 | addon.version = "SCM"
22 | end
23 |
24 | --[[-------------------------------------------------------------------------
25 | -- 问候与测试本地化字符串
26 | -------------------------------------------------------------------------]]--
27 | function Tinom.OnLoad(self)
28 | self:RegisterEvent("ADDON_LOADED")
29 | self:SetScript("OnEvent", function(self, event, addon)
30 | if addon == "Tinom" then
31 | print(format("你好%s,%s插件已加载完成.",UnitName("player"),addon))
32 | print("本地化测试:"..Tinom.L["Hello Azeroth!"])
33 | end
34 | end)
35 | end
36 |
37 | --[[-------------------------------------------------------------------------
38 | -- 呱呱叫
39 | -------------------------------------------------------------------------]]--
40 | function Tinom.Test( ... )
41 | local arg1,arg2 = ...
42 | if (arg1 == "") then
43 | print(format("呱唧%s",arg1))
44 | SendChatMessage("呱唧","PARTY",nil);
45 | else
46 | C_FriendList.SendWho(arg1);
47 | local table = C_FriendList.GetWhoInfo(1)
48 | for k,v in pairs(table) do
49 | print(k,v)
50 | end
51 | --print( )
52 | end
53 | return "O(∩_∩)O"
54 | end
55 | SLASH_MYTEST1 = "/test"
56 | SLASH_MYTEST2 = "/testttt"
57 | SlashCmdList["MYTEST"] = Tinom.Test;
58 |
59 | --[[-------------------------------------------------------------------------
60 | -- 小地图显示ping的人 !!功能暂未实现!!
61 | -------------------------------------------------------------------------]]--
62 | --[[ local addona = CreateFrame('ScrollingMessageFrame', false, Minimap)
63 | addona:SetHeight(10)
64 | addona:SetWidth(100)
65 | addona:SetPoint('BOTTOM', Minimap, 0, 20)
66 | addona:SetFont(STANDARD_TEXT_FONT, 12, 'OUTLINE')
67 | addona:SetJustifyH'CENTER'
68 | addona:SetJustifyV'CENTER'
69 | addona:SetMaxLines(1)
70 | addona:SetFading(true)
71 | addona:SetFadeDuration(3)
72 | addona:SetTimeVisible(5)
73 | addona:RegisterEvent'MINIMAP_PING'
74 | addona:SetScript('OnEvent', function(self, event, u)
75 | local c = RAID_CLASS_COLORS[select(2,UnitClass(u))]
76 | local name = UnitName(u)
77 | addona:AddMessage(name, c.r, c.g, c.b)
78 | end) ]]
79 |
80 | --[[-------------------------------------------------------------------------
81 | -- 版本信息
82 | -------------------------------------------------------------------------]]--
83 | local function HelloWow( ... )
84 | local version_a,version_b,datea,version_c = GetBuildInfo()
85 | DEFAULT_CHAT_FRAME:AddMessage("Hello World!", 0.0, 0.0, 0.0)
86 | DEFAULT_CHAT_FRAME:AddMessage("当前版本号为:"..version_a, 1.0, 0.0, 0.0)
87 | DEFAULT_CHAT_FRAME:AddMessage("小版本号为:"..version_b, 0.0, 1.0, 0.0)
88 | DEFAULT_CHAT_FRAME:AddMessage("更新日期为:"..datea, 0.0, 0.0, 1.0)
89 | DEFAULT_CHAT_FRAME:AddMessage("简写版本号为:"..version_c, 1.0, 1.0, 1.0,nil,2)
90 | dateb = date("%m/%d/%y %H:%M:%S")
91 | timea = time()
92 | timeb = time()-1118722038
93 | DEFAULT_CHAT_FRAME:AddMessage(dateb, 1.0, 1.0, 1.0)
94 | DEFAULT_CHAT_FRAME:AddMessage(timea, 1.0, 1.0, 1.0)
95 | DEFAULT_CHAT_FRAME:AddMessage(timeb, 1.0, 1.0, 1.0)
96 | end
97 |
98 | --[[-------------------------------------------------------------------------
99 | -- 创建一个框架
100 | -------------------------------------------------------------------------]]--
101 | local function Create_Frame(frame, width, height, offX, offY, name)
102 | local handle = CreateFrame("Frame", "TinomFrame"..name)
103 | handle:SetWidth(width)
104 | handle:SetHeight(height)
105 | handle:SetParent(frame)
106 | handle:EnableMouse(true)
107 | handle:SetMovable(true)
108 | handle:SetPoint("TOPLEFT", frame ,"TOPLEFT", offX, offY)
109 | end
110 |
111 | --[[-------------------------------------------------------------------------
112 | -- 在屏幕中间展示部落和联盟的图标
113 | -------------------------------------------------------------------------]]--
114 | function myframea( ... )
115 | local f = CreateFrame("Frame",nil,UIParent)
116 | f:SetFrameStrata("BACKGROUND")
117 | f:SetWidth(128) -- Set these to whatever height/width is needed
118 | f:SetHeight(64) -- for your Texture
119 |
120 | local t = f:CreateTexture(nil,"BACKGROUND")
121 | t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp")
122 | t:SetAllPoints(f)
123 | f.texture = t
124 |
125 | f:SetPoint("CENTER",0,0)
126 | f:Show()
127 | end
128 |
129 | --[[-------------------------------------------------------------------------
130 | -- 创建一个框架,如果有喊话的事件,打印一条信息.
131 | -------------------------------------------------------------------------]]--
132 | function Dont_Yell( ... )
133 | local myframeb = CreateFrame("Frame")
134 | myframeb:RegisterEvent("CHAT_MSG_YELL")
135 | myframeb:SetScript("OnEvent", function(self, event, ...)
136 | print("啊啊啊!别叫了!")
137 | return true
138 | end)
139 | end
140 |
141 | --[[-------------------------------------------------------------------------
142 | -- 播放游戏音效
143 | -------------------------------------------------------------------------]]--
144 | local listSounds = {};
145 | local i = 1;
146 | function Test_PlaySound()
147 | for _,v in pairs(SOUNDKIT) do
148 | table.insert(listSounds,v)
149 | end
150 | table.sort(listSounds)
151 |
152 | if i < #listSounds then
153 | PlaySound(listSounds[i])
154 | print("当前播放:"..listSounds[i])
155 | i = i + 1;
156 | else
157 | print("播放完了")
158 | end
159 | end
160 |
161 | --[[-------------------------------------------------------------------------
162 | -- 弹出对话框
163 | -------------------------------------------------------------------------]]--
164 | -- StaticPopupDialogs["EXAMPLE_HELLOWORLD"] = {
165 | -- text = "Do you want to greet the world today?",
166 | -- button1 = "Yes",
167 | -- button2 = "No",
168 | -- OnAccept = function()
169 | -- GreetTheWorld()
170 | -- end,
171 | -- timeout = 0,
172 | -- whileDead = true,
173 | -- hideOnEscape = true,
174 | -- }
175 |
176 | --[[-------------------------------------------------------------------------
177 | -- 设置面板
178 | -------------------------------------------------------------------------]]--
179 | MAINPANEL_LABEL = Tinom.L["TinomTest"];
180 | --MAINPANEL_SUBTEXT = Tinom.L["在这里你可以控制插件主要功能的 开启/关闭 ."];
181 | MAINPANEL_SUBTEXT = "去年高三帮好朋友给实验班的男孩子写一封信,只有“山有木兮木有枝”七个字,想让他领会后半句心悦君兮君不知的含义.第二天男孩子主动来班里送信,还是昨天那封,他在后面补充到“心悦君兮君已知,奈何十二寒窗苦,待到金榜题名时.” 后来这段故事无疾而终 愿你们遇到的每段感情都能有处安放"
182 | MAINPANEL_CONTROLBOUTTON = Tinom.L["开启插件"];
183 | -- 主选项卡
184 | function Tinom.InterfaceOptionsMainPanel_OnLoad( self )
185 | InterfaceOptions_AddCategory(self);
186 | end
187 |
188 | -- 子选项卡
189 | --[[ Tinom.childpanel = CreateFrame("Frame", "TinomChildpanel", Tinom.panel);
190 | Tinom.childpanel.name = "子选项卡";
191 | Tinom.childpanel.parent = Tinom.panel.name;
192 | InterfaceOptions_AddCategory(Tinom.childpanel); ]]
193 |
194 | --[[-------------------------------------------------------------------------
195 | -- 设置面板下拉框反应面板
196 | -------------------------------------------------------------------------]]--
197 | function TinomInterfaceOptionsMainPanelDropDown_OnEvent (self, event, ...)
198 | if ( event == "PLAYER_ENTERING_WORLD" ) then
199 | self.defaultValue = "SHIFT";
200 | --self.oldValue = GetModifiedClick("AUTOLOOTTOGGLE");
201 | --self.value = self.oldValue or self.defaultValue;
202 | self.value = self.defaultValue;
203 | --self.tooltip = _G["OPTION_TOOLTIP_AUTO_LOOT_"..self.value.."_KEY"];
204 | self.tooltip = self.value;
205 |
206 | UIDropDownMenu_SetWidth(self, 190);
207 | UIDropDownMenu_Initialize(self, TinomInterfaceOptionsMainPanelDropDown_Initialize);
208 | UIDropDownMenu_SetSelectedValue(self, self.value);
209 |
210 | self.SetValue =
211 | function (self, value)
212 | self.value = value;
213 | UIDropDownMenu_SetSelectedValue(self, value);
214 | --SetModifiedClick("AUTOLOOTTOGGLE", value);
215 | --SaveBindings(GetCurrentBindingSet());
216 | self.tooltip = value;
217 | end
218 | self.GetValue =
219 | function (self)
220 | return UIDropDownMenu_GetSelectedValue(self);
221 | end
222 | self.RefreshValue =
223 | function (self)
224 | UIDropDownMenu_Initialize(self, TinomInterfaceOptionsMainPanelDropDown_Initialize);
225 | UIDropDownMenu_SetSelectedValue(self, self.value);
226 | end
227 |
228 | self:UnregisterEvent(event);
229 | end
230 | end
231 |
232 | function TinomInterfaceOptionsMainPanelDropDown_OnClick(self)
233 | TinomInterfaceOptionsMainPanelDropDown:SetValue(self.value);
234 | end
235 |
236 | function TinomInterfaceOptionsMainPanelDropDown_Initialize(self)
237 | local selectedValue = UIDropDownMenu_GetSelectedValue(self);
238 | local info = UIDropDownMenu_CreateInfo();
239 |
240 | info.text = "啥啥啥";
241 | info.func = TinomInterfaceOptionsMainPanelDropDown_OnClick;
242 | info.value = "SHIFT";
243 | if ( info.value == selectedValue ) then
244 | info.checked = 1;
245 | else
246 | info.checked = nil;
247 | end
248 | info.tooltipTitle = "标题1";
249 | info.tooltipText = "内容1";
250 | info.tooltipOnButton = 1;
251 | --info.hasArrow = true;
252 | --info.menuTable = {1,2,3,4,5,6,7,8};
253 | UIDropDownMenu_AddButton(info);
254 |
255 | info.text = "恰恰恰";
256 | info.func = TinomInterfaceOptionsMainPanelDropDown_OnClick;
257 | info.value = "ALTy";
258 | if ( info.value == selectedValue ) then
259 | info.checked = 1;
260 | else
261 | info.checked = nil;
262 | end
263 | info.tooltipTitle = "标题2";
264 | info.tooltipText = "内容2";
265 | info.tooltipOnButton = nil;
266 | UIDropDownMenu_AddButton(info);
267 | end
268 |
269 |
270 | --[[-------------------------------------------------------------------------
271 | -- 设置面板-滑条模块
272 | -------------------------------------------------------------------------]]--
273 | MAINPANEL_SLIDERTEXT = "我是一个愚蠢的滑条";
274 | function TinomInterfaceOptionsMainPanelSlider_OnLoad( self )
275 | self.type = CONTROLTYPE_SLIDER;
276 | self.tooltipText = "你好艾泽拉斯";
277 | --self:SetOrientation("HORIZONTAL"); --水平显示滑条
278 | --self:SetOrientation("VERTICAL") --垂直显示滑条
279 | self:SetMinMaxValues(0,1);
280 | self:SetValueStep(0.05);
281 | self:SetValue(0.5);
282 |
283 | -- self.SetDisplayValue = self:SetValue; -->
284 |
285 | -- TinomInterfaceOptionsMainPanelSliderText:SetText("密你啊倒萨"); -->
286 | _G[self:GetName().."Low"]:SetText("小小");
287 | TinomInterfaceOptionsMainPanelSliderHigh:SetText("大大");
288 | end
289 |
290 | --[[-------------------------------------------------------------------------
291 | -- 设置面板-按钮模块
292 | -------------------------------------------------------------------------]]--
293 | TINOM_BUTTON1 = "我是一个按钮";
294 | Tinom_Button1_OnShow = true;
295 |
296 | --[[-------------------------------------------------------------------------
297 | -- 设置面板-标签按钮1
298 | -------------------------------------------------------------------------]]--
299 | function TinomInterfaceOptionsMainPanelWhoIsTinomRaidButton_SelectBase()
300 | PanelTemplates_SelectTab(GraphicsButton);
301 | Graphics_:Show();
302 | GraphicsButton:SetFrameLevel( Graphics_:GetFrameLevel() + 1 );
303 |
304 | if ( Display_RaidSettingsEnabledCheckBox:GetChecked() ) then
305 | PanelTemplates_DeselectTab(RaidButton);
306 | else
307 | PanelTemplates_SetDisabledTabState(RaidButton);
308 | end
309 | RaidGraphics_:Hide();
310 | RaidButton:SetFrameLevel( Graphics_:GetFrameLevel() - 1 );
311 | end
312 |
313 | --[[-------------------------------------------------------------------------
314 | -- 设置面板-颜色滑条模块
315 | -------------------------------------------------------------------------]]--
316 | COLOR_SLIDER_RED = "红色";
317 | COLOR_SLIDER_GREEN = "绿色";
318 | COLOR_SLIDER_BLUE = "蓝色";
319 | COLOR_SLIDER_ALPHA = "透明";
320 | function WhoIsTinomColorSlider_OnLoad( )
321 | local color = {"ColorRedSlider","ColorGreenSlider","ColorBlueSlider","ColorAlphaSlider"}
322 | for i,v in ipairs(color) do
323 | local frame = format("WhoIsTinom"..v)
324 | _G[frame].type = CONTROLTYPE_SLIDER;
325 | _G[frame]:SetMinMaxValues(0,1);
326 | _G[frame]:SetValueStep(0.05);
327 | _G[frame]:SetValue(0.5);
328 | if (v == "ColorAlphaSlider") then
329 | _G[frame.."Low"]:SetText("");
330 | _G[frame.."High"]:SetText("");
331 | else
332 | _G[frame.."Low"]:SetText("0");
333 | _G[frame.."High"]:SetText("1");
334 | end
335 | end
336 |
337 | end
338 |
339 | local ColorRedSlider = 0.5;
340 | local ColorGreenSlider = 0.5;
341 | local ColorBlueSlider = 0.5;
342 | local ColorAlphaSlider = 0.5;
343 | function WhoIsTinomColorSlider_OnChange( self,color,value )
344 | value = math.floor(value * 100 + 0.5) / 100;
345 | self.value = value;
346 | self:SetValue(value);
347 | if (color ~= "alpha") then
348 | _G[self:GetName().."Text2"]:SetText(self.value);
349 | end
350 | ColorRedSlider = WhoIsTinomColorRedSlider:GetValue();
351 | ColorGreenSlider = WhoIsTinomColorGreenSlider:GetValue();
352 | ColorBlueSlider = WhoIsTinomColorBlueSlider:GetValue();
353 | ColorAlphaSlider = WhoIsTinomColorAlphaSlider:GetValue();
354 |
355 | WhoIsTinom:SetBackdropBorderColor(ColorRedSlider, ColorGreenSlider, ColorBlueSlider, 1 - ColorAlphaSlider);
356 | WhoIsTinom:SetBackdropColor(ColorRedSlider, ColorGreenSlider, ColorBlueSlider, 1 - ColorAlphaSlider);
357 | end
358 |
359 | --[[-------------------------------------------------------------------------
360 | -- 一个带滚动条的编辑框:自动滚动
361 | -------------------------------------------------------------------------]]--
362 | function Test.ScrollFrame_EditBox_OnLoad(self)
363 | self:SetScript("OnCursorChanged",function (self, arg1, arg2,arg3,arg4)
364 | -- self:SetID(self:GetID() + 1)
365 | -- if taunts[self:GetID()] then
366 | -- self:SetText(taunts[self:GetID()])
367 | -- else
368 | -- self:Hide()
369 | -- end
370 | --arg1 = math.floor(arg1 + 0.5)
371 | --arg2 = math.floor(arg2 + 0.5)
372 | --arg3 = math.floor(arg3 + 0.5)
373 | --arg4 = math.floor(arg4 + 0.5)
374 |
375 | Test.ScrollFrame_EditBox_OnCursorChanged(self,arg1,arg2,arg3,arg4)
376 | end)
377 | end
378 |
379 | --[[-------------------------------------------------------------------------
380 | -- 一个带滚动条的编辑框:自动滚动
381 | -------------------------------------------------------------------------]]--
382 | local arrow = 0
383 | function Test.ScrollFrame_EditBox_OnCursorChanged(self,arg1,arg2,arg3,arg4)
384 | local vsv = self:GetParent():GetVerticalScroll();
385 | local vsh = self:GetParent():GetHeight();
386 | local ebh = self:GetHeight();
387 | --vsv = math.floor(vsv + 0.5)
388 | --vsh = math.floor(vsh + 0.5)
389 | --
390 | --
391 | print("滚当条值:"..vsv.."滚动条高"..vsh.."光标Y:"..arg2.."行高:"..arg4.."文本框高度:"..ebh)
392 |
393 | -- if (滚动条当前值 + 文本框光标位置Y > 0) then
394 | -- 光标在滚动条上方
395 | -- else (0 > 滚动条当前值 + 光标位置Y - 行高 + 滚动条高度)
396 | -- if (vs + arg2 > 0) or (0 > vs + arg2 - arg4 + h) then
397 | -- self:GetParent():SetVerticalScroll((arg2+h-arg4*2)*-1);
398 | -- end
399 | local eby = arg2;
400 |
401 | -- if ( ebh > vsh ) then
402 | -- if ( (eby+vsh-arg4) < 0) then
403 | -- self:GetParent():SetVerticalScroll((eby+vsh-arg4)*-1);
404 | -- end
405 | -- if ( (eby+vsh-arg4) > 0 ) then
406 | -- self:GetParent():SetVerticalScroll(0);
407 | -- end
408 | -- end
409 | if ( eby < arrow)then
410 | self:GetParent():SetVerticalScroll(eby*-1);
411 | end
412 |
413 | arrow = arg2;
414 | end
415 |
416 | --[[-------------------------------------------------------------------------
417 | -- 一个带滚动条的编辑框
418 | -------------------------------------------------------------------------]]--
419 | -- local s = CreateFrame("ScrollFrame", nil, UIParent, "UIPanelScrollFrameTemplate") -- or you actual parent instead
420 | -- s:SetSize(300,200)
421 | -- s:SetPoint("CENTER")
422 | -- local e = CreateFrame("EditBox", nil, s)
423 | -- e:SetMultiLine(true)
424 | -- e:SetFontObject(ChatFontNormal)
425 | -- e:SetWidth(300)
426 | -- s:SetScrollChild(e)
427 | -- --- demo multi line text
428 | -- e:SetText("line 1\nline 2\nline 3\nmore...\n\n\n\n\n\nanother one\n"
429 | -- .."some very long...dsf v asdf a sdf asd df as df asdf a sdfd as ddf as df asd f asd fd asd f asdf LONG LINE\n\n\nsome more.\nlast!")
430 | -- e:HighlightText() -- select all (if to be used for copy paste)
431 | -- -- optional/just to close that frame
432 | -- e:SetScript("OnEscapePressed", function()
433 | -- s:Hide()
434 | -- end)
435 |
436 | --[[-------------------------------------------------------------------------
437 | -- 隐藏UI所有当前可见元素
438 | -------------------------------------------------------------------------]]--
439 | function TinomhideAll()
440 | if PlayerFrame:IsShown() then
441 | MinimapCluster:Hide();
442 | MainMenuBarArtFrame:Hide();
443 | PlayerFrame:Hide();
444 | MicroButtonAndBagsBar:Hide();
445 | StatusTrackingBarManager:Hide();
446 | else
447 | MinimapCluster:Show();
448 | MainMenuBarArtFrame:Show();
449 | PlayerFrame:Show();
450 | MicroButtonAndBagsBar:Show();
451 | StatusTrackingBarManager:Show();
452 | end
453 | end
454 | SLASH_TINOMSHOW = "/tinomhide"
455 | SlashCmdList["TINOMSHOW"] = TinomhideAll;
456 | --[[-------------------------------------------------------------------------
457 | -- CVar查询,设置
458 | -------------------------------------------------------------------------]]--
459 | function Tinom.CVar( ... )
460 | -- 脏话过滤
461 | Tinom.profanityFilter = GetCVarInfo("profanityFilter")
462 | if Tinom.profanityFilter == "1" then
463 | print("脏话过滤已开"..Tinom.profanityFilter)
464 | SetCVar("profanityFilter",0);
465 | else
466 | print("脏话过滤未开"..Tinom.profanityFilter)
467 | end
468 | -- 角色名染色
469 | Tinom.colorChatNamesByClass = GetCVarInfo("colorChatNamesByClass")
470 | if Tinom.colorChatNamesByClass == "1" then
471 | print("角色名染色已开"..Tinom.colorChatNamesByClass)
472 | else
473 | print("角色名染色未开"..Tinom.colorChatNamesByClass)
474 | SetCVar("colorChatNamesByClass",1);
475 | end
476 |
477 | -- 模型河蟹overrideArchive
478 | Tinom.overrideArchive = GetCVarInfo("overrideArchive")
479 | if Tinom.overrideArchive == "1" then
480 | print("模型河蟹已开"..Tinom.overrideArchive)
481 | SetCVar("overrideArchive",0);
482 | else
483 | print("模型河蟹未开"..Tinom.overrideArchive)
484 | end
485 |
486 | end
--------------------------------------------------------------------------------
/Options/Options.lua:
--------------------------------------------------------------------------------
1 | --[[-------------------------------------------------------------------------
2 | --
3 | -- Options Setting
4 | -- 设置界面
5 | --
6 | -- 功能:面向对象...没有发现对象...
7 | --
8 | -- L["去年高三帮好朋友给实验班的男孩子写一封信,只有“山有木兮木有枝”七个字,
9 | -- 想让他领会后半句心悦君兮君不知的含义.第二天男孩子主动来班里送信,还是昨天那封,他在后面补充到“心悦君兮君已知,奈何十二寒窗苦,
10 | -- 待到金榜题名时.” 后来这段故事无疾而终 愿你们遇到的每段感情都能有处安放"];
11 | -------------------------------------------------------------------------]]--
12 | local L = Tinom.L
13 | Tinom.version = GetAddOnMetadata("Tinom", "Version")
14 | --[[-------------------------------------------------------------------------
15 | -- 字符串:
16 | -------------------------------------------------------------------------]]--
17 | TINOM_OPTION_MAINPANEL_TITLE = L["Tinom聊天过滤v"]..Tinom.version;
18 | TINOM_OPTION_MAINPANEL_SUBTEXT = L["Beta测试阶段,更新频繁.更新贴:NGA:搜索\"Tinom\".|cffffff00关键字默认支持正则表达式,若关键字中带有符号\( \) \. \% \+ \- \* \\ \? \[ \^ \$,请在符号前加\"\%\".如\"1\-60\"写成\"1\%\-60\"|r"];
19 | TINOM_OPTION_MAINPANEL_CHACKBUTTON_MAINENABLE_TEXT = L["开启过滤"];
20 | local regexTutorialStr = {};
21 | regexTutorialStr[1] = L["正则表达式:\nLua的正则表达式是精简版,缺少部分功能,即便如此也足以满足我们的需要.\n|cffffff00字符类:|r 用于表示一个字符集合。\n"]
22 | regexTutorialStr[2] = L["|cffffff00x|r : 表示字符 x 自身\n (这里 x 不能是 魔法字符 ^ $ ( ) % . [ ] * + - ? 中的一员)。\n"]
23 | regexTutorialStr[3] = L["|cffffff00%x|r : 表示字符 x\n (这里的 x 是任意非字母或数字的字符)。\n 这是对魔法字符转义的标准方法。\n 所有非字母或数字的字符(包括所有标点,也包括非魔法字符)\n 都可以用前置一个 '%' 放在模式串中表示自身。 \n"]
24 | regexTutorialStr[4] = L["|cffffff00.|r : (一个点)可表示任何字符。\n"]
25 | regexTutorialStr[5] = L["|cffffff00%a|r : 表示任何字母。\n"]
26 | regexTutorialStr[6] = L["|cffffff00%d|r : 表示任何数字。\n"]
27 | regexTutorialStr[7] = L["|cffffff00%l|r : 表示所有小写字母。\n"]
28 | regexTutorialStr[8] = L["|cffffff00%u|r : 表示所有大写字母。\n"]
29 | regexTutorialStr[9] = L["|cffffff00%w|r : 表示所有字母及数字。\n"]
30 | regexTutorialStr[10] = L["|cffffff00%p|r : 表示所有标点符号。\n"]
31 | regexTutorialStr[11] = L["|cffffff00%s|r : 表示所有空白字符。\n"]
32 | regexTutorialStr[12] = L["|cffffff00[set]|r: 表示 set 中所有字符的联合。\n 可以以 '-' 连接,升序书写范围两端的字符来表示一个范围的字符集。\n 上面提到的 %x 形式也可以在 set 中使用 表示其中的一个元素。\n 其它出现在 set 中的字符则代表它们自己。\n 例如,[%w_] (或 [_%w]) 表示所有的字母数字加下划线),\n [0-7] 表示 8 进制数字,\n [0-7%l%-] 表示 8 进制数字加小写字母与 '-' 字符。\n"]
33 | regexTutorialStr[13] = L[""]
34 | regexTutorialStr[14] = L["|cffffff00[^set]|r: 表示 set 的补集, 其中 set 如上面的解释。\n"]
35 | regexTutorialStr[15] = L["所有单个字母表示的类别(%a,%c,等), 若将其字母改为大写,均表示对应的补集。\n 例如,%S 表示所有非空格的字符。"]
36 | TINOM_REGULAR_EXPRESSION_TUTORIAL = "";
37 | for i,v in ipairs(regexTutorialStr) do
38 | TINOM_REGULAR_EXPRESSION_TUTORIAL = TINOM_REGULAR_EXPRESSION_TUTORIAL..v;
39 | end
40 | local regexTutorialStr2 = {};
41 | --regexTutorialStr2[1] = L[""]
42 | regexTutorialStr2[1] = L["|cffffff00模式条目:|r\n"]
43 | regexTutorialStr2[2] = L["单个字符类匹配该类别中任意单个字符;\n"]
44 | regexTutorialStr2[3] = L["单个字符类跟一个 '*', 将匹配零或多个该类的字符。 这个条目总是匹配尽可能长的串;\n"]
45 | regexTutorialStr2[4] = L["单个字符类跟一个 '+', 将匹配一或更多个该类的字符。 这个条目总是匹配尽可能长的串;\n"]
46 | regexTutorialStr2[5] = L["单个字符类跟一个 '-', 将匹配零或更多个该类的字符。 和 '*' 不同, 这个条目总是匹配尽可能短的串;\n"]
47 | regexTutorialStr2[6] = L["单个字符类跟一个 '?', 将匹配零或一个该类的字符。 只要有可能,它会匹配一个;\n"]
48 | regexTutorialStr2[7] = L["%n, 这里的 n 可以从 1 到 9; 这个条目匹配一个等于 n 号捕获物(后面有描述)的子串。\n"]
49 | regexTutorialStr2[8] = L["%bxy, 这里的 x 和 y 是两个明确的字符; 这个条目匹配以 x 开始 y 结束, 且其中 x 和 y 保持 平衡 的字符串。 意思是,如果从左到右读这个字符串,对每次读到一个 x 就 +1 ,读到一个 y 就 -1, 最终结束处的那个 y 是第一个记数到 0 的 y。 举个例子,条目 %b() 可以匹配到括号平衡的表达式。\n"]
50 | regexTutorialStr2[9] = L["%f[set], 指 边境模式; 这个条目会匹配到一个位于 set 内某个字符之前的一个空串, 且这个位置的前一个字符不属于 set 。 集合 set 的含义如前面所述。 匹配出的那个空串之开始和结束点的计算就看成该处有个字符 '\\0' 一样。\n"]
51 | regexTutorialStr2[10] = L["|cffffff00模式:|r指一个模式条目的序列。\n"]
52 | regexTutorialStr2[11] = L["在模式最前面加上符号 '^' 将锚定从字符串的开始处做匹配。\n在模式最后面加上符号 '$' 将使匹配过程锚定到字符串的结尾。\n如果 '^' 和 '$' 出现在其它位置,它们均没有特殊含义,只表示自身。\n"]
53 | regexTutorialStr2[12] = L["|cffffff00捕获:|r\n模式可以在内部用小括号括起一个子模式; 这些子模式被称为 捕获物。 当匹配成功时,由 捕获物 匹配到的字符串中的子串被保存起来用于未来的用途。\n捕获物以它们左括号的次序来编号。 例如,对于模式 '(a*(.)%w(%s*))',\n字符串中匹配到 'a*(.)%w(%s*)' 的部分保存在第一个捕获物中 (因此是编号 %1 );\n由 '.' 匹配到的字符是 %2 号捕获物,\n匹配到 '%s*' 的那部分是 %3 号。 "]
54 | TINOM_REGULAR_EXPRESSION_TUTORIAL2 = "";
55 | for i,v in ipairs(regexTutorialStr2) do
56 | TINOM_REGULAR_EXPRESSION_TUTORIAL2 = TINOM_REGULAR_EXPRESSION_TUTORIAL2..v;
57 | end
58 | --[[-------------------------------------------------------------------------
59 | -- 默认配置:开关
60 | -------------------------------------------------------------------------]]--
61 | Tinom.defaultOptionsCheckButtons = {
62 | Tinom_Switch_MsgFilter_MainEnable = true,
63 | Tinom_Value_MsgFilter_FiltersList = {};
64 | Tinom_Switch_MsgFilter_AbbrChannelName = false,
65 | Tinom_Switch_MsgFilter_AbbrAuthorName = false,
66 | Tinom_Switch_MsgFilter_AutoBlackList = false,
67 | Tinom_Switch_MsgFilter_IgnoreGrayItems = false,
68 | Tinom_Value_MsgFilter_RepeatMsgElapsed = 0,
69 | Tinom_Value_MsgFilter_IntervalMsgTime = 0,
70 |
71 | Tinom_Switch_MsgFilter_SensitiveListSound = false,
72 | Tinom_Switch_MsgFilter_SensitiveListSoundID = 12867,
73 | Tinom_Switch_MsgFilter_SensitiveListHighlight = false,
74 |
75 | Tinom_Switch_MsgFilter_SensitiveKeywordSound = false,
76 | Tinom_Switch_MsgFilter_SensitiveKeywordSoundID = 12867,
77 | Tinom_Switch_MsgFilter_SensitiveKeywordHighlight = false,
78 |
79 | Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive = true,
80 | Tinom_Switch_AddMessageFilter_AuthorAliasName = false,
81 | };
82 | --[[-------------------------------------------------------------------------
83 | -- 默认配置:复选按钮文本
84 | -------------------------------------------------------------------------]]--
85 | Tinom.defaultCheckButtonsName = {
86 | WhiteList = "白名单",
87 | WhiteListKeyword = "白关键字",
88 | BlackList = "黑名单",
89 | BlackListKeyword = "黑关键字",
90 | ReplaceName = "玩家别名",
91 | ReplaceNameMsg = "替换角色消息",
92 | ReplaceKeyword = "替换关键字",
93 | ReplaceKeywordMsg = "替换关键字消息",
94 | RepeatMsg = "屏蔽重复消息",
95 | SensitiveList = "敏感名单",
96 | SensitiveKeyword = "敏感关键字",
97 | AutoBlackList = "黑名单(自动)",
98 | WhiteListOnly = "只有白名单",
99 | AbbrChannelName = "缩写频道名",
100 | FoldMsg = "折叠复读消息",
101 | IgnoreGrayItems = "屏蔽灰色物品拾取消息",
102 | IntervalMsg = "发言间隔限制",
103 | AbbrAuthorName = "缩写玩家名",
104 | CaseSensitive = "大小写敏感",
105 | AuthorAliasName = "玩家别名",
106 | };
107 | Tinom.FilterFramesTitle = {
108 | WhiteList = 0,
109 | WhiteListKeyword = 0,
110 | BlackList = 0,
111 | BlackListKeyword = 0,
112 | ReplaceName = 0,
113 | ReplaceNameMsg = 0,
114 | ReplaceKeyword = 0,
115 | ReplaceKeywordMsg = 0,
116 | RepeatMsg = 0,
117 | SensitiveList = 0,
118 | SensitiveKeyword = 0,
119 | AutoBlackList = 0,
120 | FoldMsg = 0,
121 | IntervalMsg = 0,
122 | };
123 | Tinom.defaultCheckButtons = {
124 | [1] = {1, false, "WhiteList", "MsgFilter_Whitelist",},
125 | [2] = {2, false, "WhiteListKeyword", "MsgFilter_WhitelistKeyword",},
126 | [3] = {3, true, "RepeatMsg", "MsgFilter_RepeatMsg",},
127 | [4] = {4, false, "IntervalMsg", "MsgFilter_IntervalMsg",},
128 | [5] = {5, false, "AutoBlackList", "MsgFilter_AutoBlackList",},
129 | [6] = {6, true, "BlackList", "MsgFilter_Blacklist",},
130 | [7] = {7, false, "BlackListKeyword", "MsgFilter_BlacklistKeyword",},
131 | [8] = {8, true, "ReplaceKeyword", "MsgFilter_ReplaceKeyword",},
132 | [9] = {9, false, "FoldMsg", "MsgFilter_FoldMsg",},
133 | [10] = {10, false, "SensitiveList", "MsgFilter_SensitiveList",},
134 | [11] = {11, false, "SensitiveKeyword", "MsgFilter_SensitiveKeyword",},
135 | [12] = {12, false, "ReplaceNameMsg", "MsgFilter_ReplaceNameMsg",},
136 | [13] = {13, false, "ReplaceKeywordMsg", "MsgFilter_ReplaceKeywordMsg",},
137 | };
138 | --[[-------------------------------------------------------------------------
139 | -- 地址索引:标签按钮 = 子设置界面
140 | -------------------------------------------------------------------------]]--
141 | Tinom.optionsTabButtons = {
142 | TinomOptionsMainPanelBaseTabButton = "TinomOptionsMainPanelBase",
143 | --TinomOptionsMainPanelWhiteListTabButton = "TinomOptionsMainPanelWhiteListSetting",
144 | --TinomOptionsMainPanelBlackListTabButton = "TinomOptionsMainPanelBlackListSetting",
145 | --TinomOptionsMainPanelReplaceListTabButton = "TinomOptionsMainPanelReplace",
146 | };
147 |
148 | --[[-------------------------------------------------------------------------
149 | -- 初始化:主设置面板加载
150 | -------------------------------------------------------------------------]]--
151 | function Tinom.OptionsMainPanel_OnLoad( self )
152 | TinomOptionsMainPanelCheckButton_MainEnableText:SetText(L["开启过滤"]);
153 | TinomOptionsMainPanelCheckButton_MainEnable.tooltipText = L["开启过滤系统的主开关"];
154 | --设置面板的Okay响应函数,用于保存设置
155 | function self.okay(self)
156 | Tinom.OptionsMainPanel_Updata();
157 | end
158 |
159 | --设置面板的cancel响应函数,用于撤销修改
160 | function self.cancel(self)
161 | Tinom.OptionsMainPanel_LoadOptions();
162 | end
163 |
164 | --先为框架设置一个名字才能添加到设置面板的列表里
165 | self.name = L["Tinom聊天过滤"];
166 | InterfaceOptions_AddCategory(self);
167 |
168 | --可移动设置面板
169 | Tinom.OptionsPanel_EnableMovale();
170 |
171 | --标签按钮加载
172 | Tinom.OptionsTabButton_OnLoad();
173 | end
174 |
175 | -- 初始化:各过滤开关复选框加载其字符串文本
176 | function Tinom.OptionsBaseCheckButton_OnLoad(self)
177 | local buttonName = string.match(self:GetName(),"_(%S+)$");
178 | self.Text:SetText(Tinom.defaultCheckButtonsName[buttonName])
179 | --self.tooltipText = L["开启"]..v..L["过滤"];
180 | end
181 |
182 | -- 总开关复选框函数:
183 | function Tinom.OptionsMainEnableCheckButton_OnClick(self)
184 | Tinom.OptionsTabButton_OnLoad();
185 | if ( self:GetChecked() ) then
186 | Tinom.MsgFilterOn();
187 | else
188 | Tinom.MsgFilterOff();
189 | end
190 | end
191 |
192 | -- 初始化:标签初始函数:
193 | function Tinom.OptionsTabButton_OnLoad()
194 | Tinom.OptionsTabButton_Clear();
195 | if ( TinomOptionsMainPanelCheckButton_MainEnable:GetChecked() ) then
196 | PanelTemplates_SelectTab(TinomOptionsMainPanelBaseTabButton);
197 | TinomOptionsMainPanelBase:Show();
198 | end
199 | end
200 |
201 | -- 开关复选框点击事件函数:
202 | function Tinom.OptionsBaseSettingCheckButton_OnClick(self)
203 |
204 | end
205 |
206 | --[[-------------------------------------------------------------------------
207 | -- 设置界面框架可移动:
208 | -------------------------------------------------------------------------]]--
209 | function Tinom.OptionsPanel_EnableMovale()
210 | local InterfaceOptionsFrame = _G["InterfaceOptionsFrame"];
211 | InterfaceOptionsFrame:SetMovable(true);
212 | InterfaceOptionsFrame:EnableMouse(true);
213 | InterfaceOptionsFrame:RegisterForDrag("LeftButton");
214 | InterfaceOptionsFrame:SetScript("OnDragStart",function( self,event,... )
215 | if not self.isLocked then
216 | self:StartMoving();
217 | end
218 | end)
219 | InterfaceOptionsFrame:SetScript("OnDragStop",function( self,event,... )
220 | self:StopMovingOrSizing();
221 | end)
222 | end
223 |
224 | --[[-------------------------------------------------------------------------
225 | -- 入口:初始化:设置界面数据库检查
226 | -------------------------------------------------------------------------]]--
227 | function Tinom.OptionsMainPanel_checkOptions()
228 | if (not TinomDB.Options.Default) then
229 | Tdebug(self,"log","Options.未发现配置数据库");
230 | TinomDB.Options.Default = Tinom.defaultOptionsCheckButtons;
231 | if ( TinomDB.Options.Default ) then
232 | Tdebug(self,"log","Options.配置数据库已初始化");
233 | Tinom.OptionsMainPanel_LoadOptions();
234 | return;
235 | else
236 | Tdebug(self,"error","Options.配置数据库初始化失败");
237 | end
238 | end
239 | Tdebug(self,"log","Options.数据库检查完成");
240 | Tinom.OptionsMainPanel_LoadOptions();
241 | end
242 |
243 | --[[-------------------------------------------------------------------------
244 | -- 初始化:设置界面加载配置
245 | -------------------------------------------------------------------------]]--
246 | function Tinom.OptionsMainPanel_LoadOptions()
247 | TinomOptionsMainPanelCheckButton_MainEnable:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_MainEnable);
248 | TinomOptionsMainPanelBaseFilterSettingCheckButton_AbbrChannelName:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrChannelName);
249 | TinomOptionsMainPanelBaseFilterSettingCheckButton_IgnoreGrayItems:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_IgnoreGrayItems);
250 | TinomOptionsMainPanelBaseFilterSettingCheckButton_AbbrAuthorName:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrAuthorName);
251 | TinomOptionsMainPanelBaseFilterSettingCheckButton_AuthorAliasName:SetChecked(TinomDB.Options.Default.Tinom_Switch_AddMessageFilter_AuthorAliasName);
252 | TinomOptionsMainPanelBaseFilterSetting_AutoBlackListCheckButton:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_AutoBlackList);
253 | TinomOptionsMainPanelBaseFilterSetting_RepeatMsgSlider:SetValue(TinomDB.Options.Default.Tinom_Value_MsgFilter_RepeatMsgElapsed or 0);
254 | TinomOptionsMainPanelBaseFilterSetting_IntervalMsgSlider:SetValue(TinomDB.Options.Default.Tinom_Value_MsgFilter_IntervalMsgTime or 0);
255 | TinomOptionsMainPanelBaseFilterSetting_SensitiveListSound:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListSound );
256 | TinomOptionsMainPanelBaseFilterSetting_SensitiveListHighlight:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListHighlight);
257 | TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordSound:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordSound);
258 | TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordHighlight:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordHighlight);
259 | TinomOptionsMainPanelBaseFilterSetting_BlackListKeywordCheckButton_CaseSensitive:SetChecked(TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive);
260 | Tinom.OptionsPanel_EditBox_LoadOptions();
261 | Tinom.OptionsTabButton_OnLoad();
262 | TinomFilterButtonsMixin.OnLoad()
263 | Tinom.FiltersList_Updata()
264 | Tinom.AddMessageFilter_Updata()
265 | Tdebug(self,"log","OptionsMainPanel_OnLoad.配置加载完成");
266 | end
267 |
268 | --[[-------------------------------------------------------------------------
269 | -- 初始化:设置界面名单文本框加载配置
270 | -------------------------------------------------------------------------]]--
271 | function Tinom.OptionsPanel_EditBox_LoadOptions(self)
272 | TinomOptionsMainPanelBaseFilterSetting_WhiteListEditBoxScrollFrameEditBox:SetText(table.concat(TinomDB.filterDB.whiteList,"\n"))
273 | TinomOptionsMainPanelBaseFilterSetting_WhiteListEditBoxTitle:SetText(L["白名单"].."-"..#TinomDB.filterDB.whiteList)
274 |
275 | TinomOptionsMainPanelBaseFilterSetting_WhiteListKeywordEditBoxScrollFrameEditBox:SetText(table.concat(TinomDB.filterDB.whiteListKeyword,"\n"))
276 | TinomOptionsMainPanelBaseFilterSetting_WhiteListKeywordEditBoxTitle:SetText(L["白关键字"].."-"..#TinomDB.filterDB.whiteListKeyword)
277 |
278 | TinomOptionsMainPanelBaseFilterSetting_BlackListKeywordEditBoxScrollFrameEditBox:SetText(table.concat(TinomDB.filterDB.blackListKeyword,"\n"))
279 | TinomOptionsMainPanelBaseFilterSetting_BlackListKeywordEditBoxTitle:SetText(L["黑关键字"].."-"..#TinomDB.filterDB.blackListKeyword)
280 |
281 | local blackListText,blackListNum = Tinom.TableToText(TinomDB.filterDB.blackList);
282 | TinomOptionsMainPanelBaseFilterSetting_BlackListEditBoxScrollFrameEditBox:SetText(blackListText)
283 | TinomOptionsMainPanelBaseFilterSetting_BlackListEditBoxTitle:SetText(L["黑名单"].."-"..blackListNum)
284 |
285 | local autoBlackListText,autoBlackListNum = Tinom.TableToText(TinomDB.filterDB.autoBlackList);
286 | TinomOptionsMainPanelBaseFilterSetting_AutoBlackListEditBoxScrollFrameEditBox:SetText(autoBlackListText)
287 | TinomOptionsMainPanelBaseFilterSetting_AutoBlackListEditBoxTitle:SetText(L["黑名单(自动)"].."-"..autoBlackListNum)
288 |
289 | local sensitiveListText,sensitiveListNum = Tinom.TableToText(TinomDB.filterDB.sensitiveList or {});
290 | TinomOptionsMainPanelBaseFilterSetting_SensitiveListEditBoxScrollFrameEditBox:SetText(sensitiveListText)
291 | TinomOptionsMainPanelBaseFilterSetting_SensitiveListEditBoxTitle:SetText(L["敏感单"].."-"..sensitiveListNum)
292 |
293 | TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordEditBoxScrollFrameEditBox:SetText(table.concat(TinomDB.filterDB.sensitiveKeyword,"\n"))
294 | TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordEditBoxTitle:SetText(L["敏感关键字"].."-"..#TinomDB.filterDB.sensitiveKeyword)
295 |
296 |
297 | Tdebug(self,"log","Options.名单已加载:");
298 | end
299 |
300 |
301 | --[[-------------------------------------------------------------------------
302 | -- 保存设置:设置界面更新设置数据库函数:
303 | -------------------------------------------------------------------------]]--
304 | function Tinom.OptionsMainPanel_Updata(self)
305 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_MainEnable = TinomOptionsMainPanelCheckButton_MainEnable:GetChecked();
306 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrChannelName = TinomOptionsMainPanelBaseFilterSettingCheckButton_AbbrChannelName:GetChecked();
307 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_IgnoreGrayItems = TinomOptionsMainPanelBaseFilterSettingCheckButton_IgnoreGrayItems:GetChecked();
308 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrAuthorName = TinomOptionsMainPanelBaseFilterSettingCheckButton_AbbrAuthorName:GetChecked();
309 | TinomDB.Options.Default.Tinom_Switch_AddMessageFilter_AuthorAliasName = TinomOptionsMainPanelBaseFilterSettingCheckButton_AuthorAliasName:GetChecked();
310 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_AutoBlackList = TinomOptionsMainPanelBaseFilterSetting_AutoBlackListCheckButton:GetChecked();
311 | TinomDB.Options.Default.Tinom_Value_MsgFilter_RepeatMsgElapsed = TinomOptionsMainPanelBaseFilterSetting_RepeatMsgSlider:GetValue();
312 | TinomDB.Options.Default.Tinom_Value_MsgFilter_IntervalMsgTime = TinomOptionsMainPanelBaseFilterSetting_IntervalMsgSlider:GetValue();
313 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListSound = TinomOptionsMainPanelBaseFilterSetting_SensitiveListSound:GetChecked();
314 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListHighlight = TinomOptionsMainPanelBaseFilterSetting_SensitiveListHighlight:GetChecked();
315 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordSound = TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordSound:GetChecked();
316 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordHighlight = TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordHighlight:GetChecked();
317 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive = TinomOptionsMainPanelBaseFilterSetting_BlackListKeywordCheckButton_CaseSensitive:GetChecked();
318 | Tinom.OptionsPanel_EditBox_Updata();
319 | Tinom.FiltersList_Updata();
320 | Tinom.AddMessageFilter_Updata()
321 | Tdebug(self,"log","Options.Tinom配置已保存");
322 | end
323 |
324 | --[[-------------------------------------------------------------------------
325 | -- 保存设置:名单文本框保存函数:
326 | -------------------------------------------------------------------------]]--
327 | function Tinom.OptionsPanel_EditBox_Updata()
328 | TinomDB.filterDB.whiteList = Tinom.OptionsPanel_TextToTable(TinomOptionsMainPanelBaseFilterSetting_WhiteListEditBoxScrollFrameEditBox:GetText());
329 | TinomDB.filterDB.whiteListKeyword = Tinom.OptionsPanel_TextToTable(TinomOptionsMainPanelBaseFilterSetting_WhiteListKeywordEditBoxScrollFrameEditBox:GetText());
330 | TinomDB.filterDB.blackList = Tinom.TextToTable(TinomOptionsMainPanelBaseFilterSetting_BlackListEditBoxScrollFrameEditBox:GetText());
331 | TinomDB.filterDB.autoBlackList = Tinom.TextToTable(TinomOptionsMainPanelBaseFilterSetting_AutoBlackListEditBoxScrollFrameEditBox:GetText());
332 | TinomDB.filterDB.blackListKeyword = Tinom.OptionsPanel_TextToTable(TinomOptionsMainPanelBaseFilterSetting_BlackListKeywordEditBoxScrollFrameEditBox:GetText());
333 | TinomDB.filterDB.sensitiveList = Tinom.TextToTable(TinomOptionsMainPanelBaseFilterSetting_SensitiveListEditBoxScrollFrameEditBox:GetText() or "");
334 | TinomDB.filterDB.sensitiveKeyword = Tinom.OptionsPanel_TextToTable(TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordEditBoxScrollFrameEditBox:GetText() or "");
335 |
336 | Tinom.OptionsPanel_EditBox_LoadOptions()
337 | Tdebug(self,"log","Options.名单已保存");
338 | end
339 |
340 | --[[-------------------------------------------------------------------------
341 | -- 标签与子设置框架隐藏函数:
342 | -------------------------------------------------------------------------]]--
343 | function Tinom.OptionsTabButton_Clear()
344 | for k,v in pairs(Tinom.optionsTabButtons) do
345 | PanelTemplates_DeselectTab(_G[k]);
346 | _G[v]:Hide();
347 | end
348 | end
349 |
350 | --[[-------------------------------------------------------------------------
351 | -- 标签切换函数:
352 | -------------------------------------------------------------------------]]--
353 | function Tinom.OptionsTabButton_OnClick( self )
354 | Tinom.OptionsTabButton_Clear();
355 | PanelTemplates_SelectTab(self);
356 | _G[Tinom.optionsTabButtons[self:GetName()]]:Show();
357 | PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
358 | end
359 |
360 | --[[-------------------------------------------------------------------------
361 | -- 文本转表函数:
362 | -------------------------------------------------------------------------]]--
363 | function Tinom.OptionsPanel_TextToTable( textIn )
364 | local tableOut = {};
365 | local index = 1;
366 | while(true)
367 | do
368 | local first,last = string.find(textIn,"\n",index)
369 | if (first and last) then
370 | local str = string.sub(textIn,index,first-1)
371 | if (#str>1) then
372 | table.insert(tableOut,1,str)
373 | end
374 | index = last+1;
375 | else
376 | local str = string.sub(textIn,index);
377 | if (#str>1) then
378 | table.insert(tableOut,1,str);
379 | end
380 | break;
381 | end
382 | end
383 | Tdebug(self,"log","OptionsPanel_TextToTable.End"..#tableOut);
384 | return tableOut;
385 | end
386 |
387 | --[[-------------------------------------------------------------------------
388 | -- 表KEY转文本函数:
389 | -------------------------------------------------------------------------]]--
390 | function Tinom.OptionsPanel_TableToText( tableIn )
391 | local textOut = "";
392 | -- textOut = table.concat(tableIn,"\n") --##--
393 | for k,v in pairs(tableIn) do
394 | textOut = k.."\n"..textOut;
395 | end
396 | return textOut;
397 | --self:SetText(str)
398 | end
399 |
400 | --[[-------------------------------------------------------------------------
401 | -- 文本框编辑时滚动条处理函数:
402 | -------------------------------------------------------------------------]]--
403 | function Tinom.OptionsPanel_EditBox_OnCursorChanged(self)
404 |
405 | end
406 |
407 | -- 单声音选择下拉框:
408 | function Tinom.OptionsSensitiveListSoundDropDown_Initialize(self)
409 | local selectedValue = UIDropDownMenu_GetSelectedValue(self);
410 | local info = UIDropDownMenu_CreateInfo();
411 | local table_sounds = {
412 | [1] = {12867,L["铃声"].."1"},
413 | [2] = {12889,L["铃声"].."2"},
414 | };
415 |
416 | for k,v in pairs(table_sounds) do
417 | info.value = v[1];
418 | info.text = v[2];
419 | info.func = Tinom.OptionsSensitiveListSoundDropDown_OnClick;
420 | if ( info.value == selectedValue ) then
421 | info.checked = 1;
422 | else
423 | info.checked = nil;
424 | end
425 | UIDropDownMenu_AddButton(info);
426 | end
427 | end
428 | function Tinom.OptionsSensitiveListSoundDropDown_OnShow(self,event)
429 | self.defaultValue = 12867;
430 | self.value = TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListSoundID or self.defaultValue;
431 | self.tooltip = L["选一个你喜欢的提示音"];
432 |
433 | UIDropDownMenu_SetWidth(self, 150);
434 | UIDropDownMenu_Initialize(self, Tinom.OptionsSensitiveListSoundDropDown_Initialize);
435 | UIDropDownMenu_SetSelectedValue(self, self.value);
436 |
437 | self.SetValue =
438 | function (self, value)
439 | self.value = value;
440 | UIDropDownMenu_SetSelectedValue(self, value);
441 | end
442 | self.GetValue =
443 | function (self)
444 | return UIDropDownMenu_GetSelectedValue(self);
445 | end
446 | self.RefreshValue =
447 | function (self)
448 | UIDropDownMenu_Initialize(self, Tinom.OptionsSensitiveListSoundDropDown_Initialize);
449 | UIDropDownMenu_SetSelectedValue(self, self.value);
450 | end
451 | end
452 |
453 | function Tinom.OptionsSensitiveListSoundDropDown_OnClick(self)
454 | TinomOptionsMainPanelBaseFilterSetting_SensitiveListDropDown:SetValue(self.value);
455 | PlaySound(self.value);
456 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveListSoundID = self.value
457 | Tdebug(self,"log","OptionsSensitiveListSoundDropDown_OnClick");
458 | end
459 |
460 | function Tinom.OptionsSensitiveKeywordSoundDropDown_Initialize(self)
461 | local selectedValue = UIDropDownMenu_GetSelectedValue(self);
462 | local info = UIDropDownMenu_CreateInfo();
463 | local table_sounds = {
464 | [1] = {12867,L["铃声"].."1"},
465 | [2] = {12889,L["铃声"].."2"},
466 | };
467 |
468 | for k,v in pairs(table_sounds) do
469 | info.value = v[1];
470 | info.text = v[2];
471 | info.func = Tinom.OptionsSensitiveKeywordSoundDropDown_OnClick;
472 | if ( info.value == selectedValue ) then
473 | info.checked = 1;
474 | else
475 | info.checked = nil;
476 | end
477 | UIDropDownMenu_AddButton(info);
478 | end
479 | end
480 | function Tinom.OptionsSensitiveKeywordSoundDropDown_OnShow(self,event)
481 | self.defaultValue = 12867;
482 | self.value = TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordSoundID or self.defaultValue;
483 | self.tooltip = L["选一个你喜欢的提示音"];
484 |
485 | UIDropDownMenu_SetWidth(self, 150);
486 | UIDropDownMenu_Initialize(self, Tinom.OptionsSensitiveKeywordSoundDropDown_Initialize);
487 | UIDropDownMenu_SetSelectedValue(self, self.value);
488 |
489 | self.SetValue =
490 | function (self, value)
491 | self.value = value;
492 | UIDropDownMenu_SetSelectedValue(self, value);
493 | end
494 | self.GetValue =
495 | function (self)
496 | return UIDropDownMenu_GetSelectedValue(self);
497 | end
498 | self.RefreshValue =
499 | function (self)
500 | UIDropDownMenu_Initialize(self, Tinom.OptionsSensitiveKeywordSoundDropDown_Initialize);
501 | UIDropDownMenu_SetSelectedValue(self, self.value);
502 | end
503 | end
504 |
505 | function Tinom.OptionsSensitiveKeywordSoundDropDown_OnClick(self)
506 | TinomOptionsMainPanelBaseFilterSetting_SensitiveKeywordDropDown:SetValue(self.value);
507 | PlaySound(self.value);
508 | TinomDB.Options.Default.Tinom_Switch_MsgFilter_SensitiveKeywordSoundID = self.value
509 | Tdebug(self,"log","OptionsSensitiveKeywordSoundDropDown_OnClick");
510 | end
511 |
512 | --[[-------------------------------------------------------------------------
513 | -- 配置界面入口函数:
514 | -------------------------------------------------------------------------]]--
515 |
516 |
517 | --[[-------------------------------------------------------------------------
518 | -- 设置界面快捷命令:
519 | -------------------------------------------------------------------------]]--
520 | function Tinom.OptionsMainPanel_Show()
521 | InterfaceOptionsFrame_OpenToCategory(TinomOptionsMainPanel);
522 | InterfaceOptionsFrame_OpenToCategory(TinomOptionsMainPanel);
523 | end
524 | SLASH_TINOMOPTIONS1 = "/tinom"
525 | SLASH_TINOMOPTIONS2 = "/ti"
526 | SlashCmdList["TINOMOPTIONS"] = Tinom.OptionsMainPanel_Show;
527 |
528 | Tdebug(self,"log","Options.lua.OnLoaded");
529 |
530 |
531 | --[[-------------------------------------------------------------------------
532 | -- 替换 名字&关键字 界面名单列表按钮点击事件函数:清理高亮 (NEW!)
533 | -------------------------------------------------------------------------]]--
534 | function Tinom.OptionsMainPanel_Replace_ListBrowseButton_ClearHighlight( listType )
535 | if listType == "Keyword" then
536 | for i=1,10 do
537 | _G["TinomOptionsMainPanelReplaceKeywordListButton"..i]:UnlockHighlight();
538 | end
539 | elseif listType == "Name" then
540 | for i=1,10 do
541 | _G["TinomOptionsMainPanelReplaceNameListButton"..i]:UnlockHighlight();
542 | end
543 | end
544 | end
545 |
546 |
547 | TinomFilterButtonsMixin = {}
548 | local lastData;
549 | function TinomFilterButtonsMixin:OnDragStat()
550 | lastData = self:GetInfo();
551 | self:AlphaAllDown();
552 | self:SetAlpha(1)
553 | self:SetScript("OnUpdate", TinomFilterButtonsMixin.OnUpdate);
554 | end
555 |
556 | function TinomFilterButtonsMixin:OnUpdate()
557 | for i,v in ipairs(TinomOptionsMainPanelBase.TinomFilterButtons) do
558 | local MouseOver = v:IsMouseOver();
559 | if MouseOver then
560 | if i == lastData[1] then break; end
561 | PlaySoundFile("Interface/Addons/Tinom/Media/di.ogg","SFX");
562 | self:AlphaAllDown();
563 | v:SetAlpha(1)
564 | self:SetInfo(lastData[1], v:GetInfo());
565 | self:SetInfo(i, lastData);
566 | lastData = v:GetInfo();
567 | end
568 | end
569 | end
570 |
571 | function TinomFilterButtonsMixin:StopMovingEntry()
572 | self:AlphaAllUp()
573 | self:SetScript("OnUpdate", nil);
574 | --self:UpdateStates();
575 | end
576 |
577 | function TinomFilterButtonsMixin:OnLoad()
578 | for i,v in ipairs(TinomOptionsMainPanelBase.TinomFilterButtons) do
579 | local tableTemp = TinomDB.Options.Default.Tinom_Value_MsgFilter_FiltersList or Tinom.defaultCheckButtons;
580 | v:SetInfo( i, tableTemp[i] )
581 | v.CheckButton.tooltipText = "."
582 | --v.CheckButton.tooltipRequirement = "."
583 | v.Button.tooltip = "."
584 | v.Button.tooltipRequirement = "."
585 | end
586 | end
587 |
588 | function Tinom.FiltersList_Updata()
589 | msgFilters = {};
590 | TinomDB.Options.Default.Tinom_Value_MsgFilter_FiltersList = {};
591 |
592 | for i,v in ipairs(TinomOptionsMainPanelBase.TinomFilterButtons) do
593 | buttonInfo = v:GetInfo()
594 | tinsert(TinomDB.Options.Default.Tinom_Value_MsgFilter_FiltersList,i,buttonInfo);
595 | if v.CheckButton:GetChecked() then
596 | Tinom.MsgFilter_AddMsgFilter(Tinom[v.filterFunc])
597 | end
598 | end
599 | if ( #msgFilters == 0 ) then
600 | msgFilters = nil;
601 | end
602 | end
603 |
604 | function TinomFilterButtonsMixin:AlphaAllDown()
605 | for i,v in ipairs(TinomOptionsMainPanelBase.TinomFilterButtons) do
606 | v:SetAlpha(0.5);
607 | end
608 | end
609 | function TinomFilterButtonsMixin:AlphaAllUp()
610 | for i,v in ipairs(TinomOptionsMainPanelBase.TinomFilterButtons) do
611 | v:SetAlpha(1);
612 | end
613 | end
614 |
615 | function TinomFilterButtonsMixin:GetInfo()
616 | local info = {};
617 | ID = self:GetID();
618 | isChecked = self.CheckButton:GetChecked();
619 | filterName = self.filterName;
620 | filterFunc = self.filterFunc;
621 | info = {ID, isChecked, filterName, filterFunc}
622 | return info;
623 | end
624 |
625 | function TinomFilterButtonsMixin:SetInfo( index, data )
626 | TinomOptionsMainPanelBase.TinomFilterButtons[index].CheckButton:SetChecked(data[2]);
627 | TinomOptionsMainPanelBase.TinomFilterButtons[index].filterName = data[3]
628 | TinomOptionsMainPanelBase.TinomFilterButtons[index].filterFunc = data[4]
629 | TinomOptionsMainPanelBase.TinomFilterButtons[index].CheckButton.Text:SetText(index.."."..Tinom.defaultCheckButtonsName[data[3]]);
630 | return true;
631 | end
632 |
633 | -- 过滤器子设置框架全部隐藏
634 | function Tinom.FilterSettingFramesAllHide()
635 | for k,v in pairs(TinomOptionsMainPanelBase.TinomFilterSettingFrames) do
636 | v:Hide();
637 | end
638 | end
639 |
640 | -- 过滤器子设置框架标题
641 | function Tinom.FilterSettingFrames_SetTitle()
642 | for k,v in pairs(TinomOptionsMainPanelBase.TinomFilterSettingFrames) do
643 | local frameName = v:GetName():match("_(%S+)$")
644 | v.Text:SetText(Tinom.defaultCheckButtonsName[frameName]);
645 | end
646 | end
647 |
648 | -- 显示指定过滤器子设置框架
649 | function Tinom.FilterSettingFramesShow(frameName)
650 | _G["TinomOptionsMainPanelBaseFilterSetting_"..frameName]:Show();
651 | end
652 |
653 | -- 过滤器列表设置按钮(齿轮)
654 | function Tinom.FilterButton_OnClick( self )
655 | Tinom.FilterSettingFramesAllHide();
656 | Tinom.FilterSettingFramesShow(self:GetParent().filterName);
657 | end
658 |
659 | -- 过滤器滚轮事件函数:
660 | function Tinom.OptionsMainPanel_Slider_OnMouseWheel(self, delta)
661 | local value = self.value;
662 | if ( delta < 0 ) then
663 | value = value + 1;
664 | else
665 | value = value - 1;
666 | end
667 | value = Tinom.SliderValueFloor(value);
668 | if value<0 then
669 | value = 0;
670 | elseif value>300 then
671 | value = 300;
672 | end
673 | self.value = value;
674 | self:SetValue(value);
675 | self.Text:SetText(self.value.."秒");
676 | end
677 |
678 | -- 替换框架清理文本框
679 | function Tinom.OptionsMainPanel_Replace_ClearEditBox(self)
680 | _G[self:GetParent():GetName().."Key"]:SetText("");
681 | _G[self:GetParent():GetName().."NewKey"]:SetText("");
682 | end
683 |
684 | -- 替换框架新增条目按钮:点击事件
685 | function Tinom.OptionsMainPanel_Replace_ButtonAdd_OnClick(self)
686 | local Key = _G[self:GetParent():GetName().."Key"]:GetText();
687 | local NewKey = _G[self:GetParent():GetName().."NewKey"]:GetText();
688 | local frameName = self:GetName():match("_(%S+)Button");
689 | local replaceType = frameName:match("Replace(%S+)");
690 | if (#Key < 1) then
691 | _G[self:GetParent():GetName().."Key"]:SetText(L["你太短啦!"]);
692 | elseif (#NewKey<1) then
693 | _G[self:GetParent():GetName().."NewKey"]:SetText(L["你太短了!"]);
694 | else
695 | TinomDB.filterDB[Tinom.replaceDBName[frameName]][Key] = NewKey;
696 | Tinom.OptionsMainPanel_Replace_ClearEditBox(self)
697 | Tinom.OptionsMainPanel_Replace_OnShow( self:GetParent() )
698 | Tdebug(self,"log","Options.replaceName.新增条目");
699 | end
700 | end
701 |
702 | -- 删除条目按钮:点击事件
703 | function Tinom.OptionsMainPanel_Replace_ButtonDel_OnClick(self)
704 | local Key = _G[self:GetParent():GetName().."Key"]:GetText();
705 | local frameName = self:GetName():match("_(%S+)Button");
706 | if TinomDB.filterDB[Tinom.replaceDBName[frameName]][Key] then
707 | TinomDB.filterDB[Tinom.replaceDBName[frameName]][Key] = nil;
708 | end
709 | Tinom.OptionsMainPanel_Replace_ClearEditBox(self)
710 | Tinom.OptionsMainPanel_Replace_OnShow( self:GetParent() )
711 | Tdebug(self,"log","Options.replaceName.删除条目");
712 | end
713 |
714 | function Tinom.OptionsMainPanel_Replace_AllHide(listName)
715 | for i,v in ipairs(listName.ReplaceListButtons) do
716 | v:Hide();
717 | end
718 | end
719 |
720 | Tinom.replaceDBName={
721 | ["ReplaceName"] = "replaceName",
722 | ["ReplaceNameMsg"] = "replaceNameMsg",
723 | ["ReplaceKeyword"] = "replaceKeyword",
724 | ["ReplaceKeywordMsg"] = "replaceKeywordMsg",
725 | };
726 |
727 | function Tinom.OptionsMainPanel_Replace_OnShow( self )
728 | local frameName = self:GetName():match("_(%S+)$");
729 | local replaceType = frameName:match("Replace(%S+)");
730 | local listName = _G[self:GetName().."List"];
731 | Tinom.OptionsMainPanel_Replace_AllHide(listName)
732 | self.tableTemp = {};
733 | for k,v in pairs(TinomDB.filterDB[Tinom.replaceDBName[frameName]]) do
734 | if v then
735 | table.insert( self.tableTemp,{k,v})
736 | end
737 | end
738 | if #self.tableTemp > 0 then
739 | Tinom.OptionsMainPanel_Replace_LoadData( self, listName, 1 )
740 | end
741 | end
742 | function Tinom.OptionsMainPanel_Replace_LoadData( replaceFrame, listName, index )
743 | -- Tinom.OptionsMainPanel_Replace_ListBrowseButton_Clear("Keyword");
744 | -- Tinom.OptionsMainPanel_Replace_ListBrowseButton_ClearHighlight("Keyword");
745 | local index_B = index;
746 | for i,v in ipairs(listName.ReplaceListButtons) do
747 | if i>(#replaceFrame.tableTemp - index_B + 1) then break; end
748 | local button = listName.ReplaceListButtons[i]
749 | button:Show();
750 | _G[button:GetName().."_Key"]:SetText(replaceFrame.tableTemp[index][1]);
751 | _G[button:GetName().."_NewKey"]:SetText(replaceFrame.tableTemp[index][2]);
752 | index = index + 1;
753 | end
754 | Tinom.OptionsMainPanel_Replace_ScrollUpdate( replaceFrame,listName );
755 | end
756 |
757 | function Tinom.OptionsMainPanel_Replace_ScrollUpdate( replaceFrame,listName )
758 | local scrollHeight = _G[listName:GetName().."Scroll"]:GetHeight();
759 | if (#replaceFrame.tableTemp>#listName.ReplaceListButtons) then
760 | _G[listName:GetName().."Scroll_HightFrame"]:SetHeight(scrollHeight + #replaceFrame.tableTemp - #listName.ReplaceListButtons)
761 | end
762 | end
763 |
764 | -- 替换框架滚轮事件函数:
765 | function Tinom.OptionsMainPanel_Replace_Scroll_OnMouseWheel(self, delta)
766 | local scrollBar = self.ScrollBar;
767 | if ( delta > 0 ) then
768 | scrollBar:SetValue(scrollBar:GetValue() - 1);
769 | else
770 | scrollBar:SetValue(scrollBar:GetValue() + 1);
771 | end
772 | Tinom.OptionsMainPanel_Replace_LoadData( self:GetParent():GetParent(), self:GetParent(), math.floor(scrollBar:GetValue()+1.5) )
773 | end
774 |
775 | function Tinom.OptionsMainPanel_Replace_OnTextChanged( self )
776 | local Key = self:GetText();
777 | local frameName = self:GetName():match("_(%S+)Key$");
778 |
779 | if ( TinomDB.filterDB[Tinom.replaceDBName[frameName]][Key] ) then
780 | _G[self:GetParent():GetName().."ButtonAdd"]:SetText(L["修改"]);
781 | else
782 | _G[self:GetParent():GetName().."ButtonAdd"]:SetText(L["新增"]);
783 | end
784 | end
785 |
786 | Tinom.AddMessageFilterList = {
787 | {"TinomOptionsMainPanelBaseFilterSettingCheckButton_AbbrChannelName","AddMessageFilter_AbbrChannelName",},
788 | {"TinomOptionsMainPanelBaseFilterSettingCheckButton_AbbrAuthorName","AddMessageFilter_AbbrAuthorName",},
789 | {"TinomOptionsMainPanelBaseFilterSettingCheckButton_AuthorAliasName","AddMessageFilter_AuthorAliasName",},
790 | };
791 | function Tinom.AddMessageFilter_Updata()
792 | Tinom.addMsgFilters = {};
793 |
794 | for i,v in ipairs(Tinom.AddMessageFilterList) do
795 | if _G[v[1]]:GetChecked() then
796 | Tinom.AddMessageFilter_AddMsgFilter(Tinom[v[2]]);
797 | end
798 | end
799 | if ( #Tinom.addMsgFilters == 0 ) then
800 | Tinom.addMsgFilters = nil;
801 | end
802 | end
--------------------------------------------------------------------------------
/test/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | InterfaceOptionsFrame_OpenToCategory(TinomInterfaceOptionsMainPanel)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | self.tooltipText = "这是按钮的鼠标提示信息";
79 |
80 |
81 |
82 |
83 |
84 |
85 | if ( self:GetChecked() ) then
86 | PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
87 | Tinom.MsgFilter( true )
88 | else
89 | PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF);
90 | Tinom.MsgFilter( false )
91 | end
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 | self.type = CONTROLTYPE_DROPDOWN;
122 | BlizzardOptionsPanel_RegisterControl(self, self:GetParent());
123 | self:RegisterEvent("PLAYER_ENTERING_WORLD");
124 |
125 |
126 |
127 | if ( not self.isDisabled ) then
128 | GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT");
129 | GameTooltip:SetText(self.tooltip, nil, nil, nil, nil, true);
130 | end
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 | self.tooltipText = "这是滑条的鼠标提示信息";
165 | TinomInterfaceOptionsMainPanelSlider_OnLoad(self);
166 | self:SetOrientation("HORIZONTAL");
167 |
168 |
169 |
170 | value = math.floor(value * 100 + 0.5) / 100;
171 | if (value ~= 0) then
172 | value = math.max(0.5, value);
173 | end
174 | if (value == 1) then
175 | TinomInterfaceOptionsMainPanelButton1:Enable();
176 | end
177 | self.value = value;
178 | self:SetValue(value);
179 | TinomInterfaceOptionsMainPanelSliderText2:SetText(self.value);
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 | self.invert = true;
217 | self.tooltipText = "这是滑条的鼠标提示信息";
218 | self.type = CONTROLTYPE_SLIDER;
219 | self.tooltipText = "你好艾泽拉斯";
220 | self:SetMinMaxValues(0,1);
221 | self:SetValueStep(0.05);
222 | self:SetValue(0.5);
223 | _G[self:GetName().."Low"]:SetText("")
224 |
225 | self:SetOrientation('VERTICAL');
226 |
227 |
228 |
229 | value = math.floor(value * 100 + 0.5) / 100;
230 | self.value = value;
231 | self:SetValue(value);
232 |
233 | TinomInterfaceOptionsMainPanelSlider:SetValue(value);
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 | WhoIsTinomColorSlider_OnChange( self,"red",value );
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 | WhoIsTinomColorSlider_OnChange( self,"green",value );
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 | WhoIsTinomColorSlider_OnChange( self,"blue",value );
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 | self:SetOrientation('VERTICAL');
475 | WhoIsTinomColorSlider_OnLoad( );
476 |
477 |
478 | WhoIsTinomColorSlider_OnChange( self,"alpha",value );
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
508 |
509 |
510 |
535 |
536 |
537 |
538 |
539 |
540 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 | self.name = MAINPANEL_LABEL;
551 | Tinom.InterfaceOptionsMainPanel_OnLoad(self);
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 | self.name = "子面板1可折叠";
610 | self.parent = TinomInterfaceOptionsMainPanel.name;
611 | InterfaceOptions_AddCategory(self);
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 | self.name = "子面板2不折叠";
623 | self.parent = TinomInterfaceOptionsMainPanel;
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
715 |
716 |
749 |
750 |
783 |
784 |
817 |
818 |
851 |
852 |
885 |
886 |
919 |
920 |
953 |
954 |
988 |
989 |
990 |
991 |
992 |
993 | self:RegisterForDrag("LeftButton")
994 |
995 | tinsert(UISpecialFrames, self:GetName());
996 | self:RegisterEvent("PLAYER_ENTERING_WORLD");
997 |
998 |
999 |
1000 | if not self.isLocked then
1001 | self:StartMoving()
1002 | end
1003 |
1004 |
1005 |
1006 | self:StopMovingOrSizing()
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 | self:SetText("Hello Azelaz!");
1056 | self:SetWidth(300);
1057 | Test.ScrollFrame_EditBox_OnLoad(self)
1058 |
1059 |
1060 | ScrollFrame:Hide();
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 | self:SetScrollChild(ScrollFrameEditBox);
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 | Tinom.OnLoad(self);
1080 |
1081 |
1082 |
1083 |
1084 |
--------------------------------------------------------------------------------