diff --git a/InputInput/API.lua b/InputInput/API.lua index 0b7f791..717a855 100644 --- a/InputInput/API.lua +++ b/InputInput/API.lua @@ -182,8 +182,10 @@ Fun({ }, C_AddOns_GetAddOnEnableState = { ['10.2.0'] = C_AddOns.GetAddOnEnableState, - ---@diagnostic disable-next-line: deprecated - ['1.0.0'] = GetAddOnEnableState + ['1.0.0'] = function(name, character) + ---@diagnostic disable-next-line: deprecated + return GetAddOnEnableState(character, name) + end }, C_AddOns_EnableAddOn = { ['10.2.0'] = C_AddOns.EnableAddOn, diff --git a/InputInput/InIt.lua b/InputInput/InIt.lua index 12a2155..cb73e74 100644 --- a/InputInput/InIt.lua +++ b/InputInput/InIt.lua @@ -7,7 +7,7 @@ local Data = {} local Locale = {} local API = {} local LOG = {} -local Environment = 'PRO' +local Environment = 'DEV' AddOnesTable[1] = Widget Widget.N = Name diff --git a/InputInput/Libs/jieba-lua/hmm.lua b/InputInput/Libs/jieba-lua/hmm.lua index 87781ed..24183da 100644 --- a/InputInput/Libs/jieba-lua/hmm.lua +++ b/InputInput/Libs/jieba-lua/hmm.lua @@ -1,12 +1,12 @@ local MIN_FLOAT = -3.14e100 -local start = LibStub("prob_start").prob_start -local emit = LibStub("prob_emit").prob_emit -local trans = LibStub("prob_trans").prob_trans -local ut = LibStub("utils") +local start = LibStub("inputinput-jieba-prob_start").prob_start +local emit = LibStub("inputinput-jieba-prob_emit").prob_emit +local trans = LibStub("inputinput-jieba-prob_trans").prob_trans +local ut = LibStub("inputinput-jieba-utils") -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "hmm", 1 +local MAJOR, MINOR = "inputinput-jieba-hmm", 1 local M, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 diff --git a/InputInput/Libs/jieba-lua/init.lua b/InputInput/Libs/jieba-lua/init.lua index 26f5175..66dcda8 100644 --- a/InputInput/Libs/jieba-lua/init.lua +++ b/InputInput/Libs/jieba-lua/init.lua @@ -1,47 +1,19 @@ local W, M, U, D, G, L, E, API, LOG = unpack((select(2, ...))) -local ut = LibStub("utils") -local utf8 = LibStub("utf8") -local hmm = LibStub("hmm") +local ut = LibStub("inputinput-jieba-utils") +local utf8 = LibStub("inputinput-jieba-utf8") +local hmm = LibStub("inputinput-jieba-hmm") local p = "[%z\1-\127\194-\244][\128-\191]*" -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "jieba", 1 +local MAJOR, MINOR = "inputinput-jieba", 1 local init, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 if not init then return end --- local dict1 = LibStub("dict1").dict --- local dict2 = LibStub("dict2").dict --- local dict3 = LibStub("dict3").dict --- local dict4 = LibStub("dict4").dict --- local dict5 = LibStub("dict5").dict --- local dict6 = LibStub("dict6").dict --- local total = 60101967 - --- local logtotal = math.log(total) - --- for i, v in pairs(dict1) do --- dict1[i] = math.log(v) - logtotal --- end --- for i, v in pairs(dict2) do --- dict2[i] = math.log(v) - logtotal --- end --- for i, v in pairs(dict3) do --- dict3[i] = math.log(v) - logtotal --- end --- for i, v in pairs(dict4) do --- dict4[i] = math.log(v) - logtotal --- end --- for i, v in pairs(dict5) do --- dict5[i] = math.log(v) - logtotal --- end --- for i, v in pairs(dict6) do --- dict6[i] = math.log(v) - logtotal --- end local function dictItem(k) if W.dict1 then return W.dict1[k] or W.dict2[k] or W.dict3[k] or W.dict4[k] or W.dict5[k] or W.dict6[k] diff --git a/InputInput/Libs/jieba-lua/prob_emit.lua b/InputInput/Libs/jieba-lua/prob_emit.lua index 84d2552..439d3d5 100644 --- a/InputInput/Libs/jieba-lua/prob_emit.lua +++ b/InputInput/Libs/jieba-lua/prob_emit.lua @@ -1,5 +1,5 @@ -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "prob_emit", 1 +local MAJOR, MINOR = "inputinput-jieba-prob_emit", 1 local p, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 diff --git a/InputInput/Libs/jieba-lua/prob_start.lua b/InputInput/Libs/jieba-lua/prob_start.lua index 30a0782..0446b9a 100644 --- a/InputInput/Libs/jieba-lua/prob_start.lua +++ b/InputInput/Libs/jieba-lua/prob_start.lua @@ -1,5 +1,5 @@ -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "prob_start", 1 +local MAJOR, MINOR = "inputinput-jieba-prob_start", 1 local p, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 diff --git a/InputInput/Libs/jieba-lua/prob_trans.lua b/InputInput/Libs/jieba-lua/prob_trans.lua index b4d6d97..21ff628 100644 --- a/InputInput/Libs/jieba-lua/prob_trans.lua +++ b/InputInput/Libs/jieba-lua/prob_trans.lua @@ -1,5 +1,5 @@ -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "prob_trans", 1 +local MAJOR, MINOR = "inputinput-jieba-prob_trans", 1 local p, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 diff --git a/InputInput/Libs/jieba-lua/utf8.lua b/InputInput/Libs/jieba-lua/utf8.lua index 02377af..ac75cca 100644 --- a/InputInput/Libs/jieba-lua/utf8.lua +++ b/InputInput/Libs/jieba-lua/utf8.lua @@ -1,6 +1,6 @@ local W, M, U, D, G, L, E, API, LOG = unpack((select(2, ...))) -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "utf8", 1 +local MAJOR, MINOR = "inputinput-jieba-utf8", 1 local utf8, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 diff --git a/InputInput/Libs/jieba-lua/utils.lua b/InputInput/Libs/jieba-lua/utils.lua index 3b6bdd8..f0d628d 100644 --- a/InputInput/Libs/jieba-lua/utils.lua +++ b/InputInput/Libs/jieba-lua/utils.lua @@ -1,7 +1,7 @@ -local utf8 = LibStub("utf8") +local utf8 = LibStub("inputinput-jieba-utf8") -- 使用 LibStub 创建一个新库 -local MAJOR, MINOR = "utils", 1 +local MAJOR, MINOR = "inputinput-jieba-utils", 1 local M, oldVersion = LibStub:NewLibrary(MAJOR, MINOR) -- 检查是否成功创建了新版本的库 diff --git a/InputInput/Log4WOW.lua b/InputInput/Log4WOW.lua index 7234173..569ccea 100644 --- a/InputInput/Log4WOW.lua +++ b/InputInput/Log4WOW.lua @@ -40,6 +40,7 @@ end function LOG:Error(...) Uprint("ERROR", ...) + error(...) end function LOG:Warn(...) diff --git a/InputInput/Main.lua b/InputInput/Main.lua index a0eae19..7ce784d 100644 --- a/InputInput/Main.lua +++ b/InputInput/Main.lua @@ -153,6 +153,7 @@ local function FindHis(his, patt) patt = patt:gsub("%|c.-(%[.-%]).-%|r", function(a1) return a1 end) + local lastChat = getLastUTF8Char(patt) local pattp = U:CutWord(patt) if not pattp or #pattp <= 0 then return '' end for i = #his, 1, -1 do @@ -166,11 +167,26 @@ local function FindHis(his, patt) local hisp = U:CutWord(h) for h_index, h2 in ipairs(hisp) do + -- 先按分词匹配 local patt2 = pattp[#pattp] -- LOG:Debug(patt2) local start, _end = strfind(h2, patt2, 1, true) if start and start > 0 then - -- LOG:Debug(h2) + -- LOG:Debug(patt2) + if _end ~= # h2 then + return strsub(h2, _end + 1) + else + local pnex = hisp[h_index + 1] + if pnex and #pnex > 0 then + return pnex + end + end + end + -- 再使用最后一个字符匹配 + patt2 = lastChat + start, _end = strfind(h2, patt2, 1, true) + if start and start > 0 then + -- LOG:Debug(patt2) if _end ~= # h2 then return strsub(h2, _end + 1) else @@ -182,15 +198,19 @@ local function FindHis(his, patt) end end -- 如果分词匹配不到,使用输入的最后一个字符匹配 - local lastChat = getLastUTF8Char(patt) local start, _end = strfind(h, lastChat, 1, true) if start and start > 0 and _end ~= #h then return strsub(h, _end + 1) end -- LOG:Debug(lastChat) - local playerTip = U:PlayerTip(patt, lastChat) + local playerTip = U:PlayerTip(patt, pattp[#pattp]) if playerTip then return playerTip + else + playerTip = U:PlayerTip(patt, lastChat) + if playerTip then + return playerTip + end end end end @@ -1184,7 +1204,7 @@ frame:HookScript("OnEvent", function(self_f, event, ...) local isLoad = C_AddOns_GetAddOnEnableState("InputInput_Libraries_zh") == 2 if GetLocale() == 'zhCN' or GetLocale() == 'zhTW' then if not (C_AddOns_GetAddOnEnableState("InputInput_Libraries_zh") == 2) then - LOG:Warn('|cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r' .. + LOG:Warn('|cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r' .. format(L['Not enabled, enter/ii to enable'], "|cff409EFF/ii|r")) end end @@ -1194,6 +1214,11 @@ frame:HookScript("OnEvent", function(self_f, event, ...) U:InitGroupMembers() LoadSize(scale, editBox, backdropFrame2, channel_name, II_TIP, II_LANG) LoadPostion(editBox) + + local jieba = LibStub("inputinput-jieba") + for _, i in ipairs(jieba.lcut('汽车站长说只有按照', false, true)) do + LOG:Debug(i) + end end end end) diff --git a/InputInput/Options.lua b/InputInput/Options.lua index e68c04a..1af86de 100644 --- a/InputInput/Options.lua +++ b/InputInput/Options.lua @@ -111,7 +111,7 @@ function OPT:loadOPT() showChannel.Text:SetText(L['Show channel Name']) showChannel:SetChecked(settings.showChannel) - -- 启用|cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r + -- 启用|cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r local enableIL_zh = CreateFrame("CheckButton", W.N .. "enableIL_zh", options, "InterfaceOptionsCheckButtonTemplate") enableIL_zh:SetPoint("TOPLEFT", 16, -206) @@ -134,7 +134,7 @@ function OPT:loadOPT() options:SetScript("OnShow", function(self) UpdateAddOnMemoryUsage() enableIL_zh.Text:SetText(format(L['Enable InputInput_Libraries_zh'], - '|cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r') .. + '|cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r') .. ' |cFF909399' .. GetAddonMemory('InputInput_Libraries_zh') .. ' (' .. L['Need To Reload'] .. ')|r') settings.enableIL_zh = C_AddOns_GetAddOnEnableState("InputInput_Libraries_zh") == 2 enableIL_zh:SetChecked(settings.enableIL_zh) diff --git a/InputInput/Utils.lua b/InputInput/Utils.lua index 5f24758..1010c99 100644 --- a/InputInput/Utils.lua +++ b/InputInput/Utils.lua @@ -312,7 +312,7 @@ local function isAllWhitespace(str) return str:match("^%s*$") ~= nil end -local jieba = LibStub("jieba") +local jieba = LibStub("inputinput-jieba") local wordCache = {} function U:InitWordCache(history) @@ -349,11 +349,20 @@ function U:InitFriends() if accountInfo then local gameAccountInfo = accountInfo.gameAccountInfo if gameAccountInfo and gameAccountInfo.characterName and gameAccountInfo.isOnline then - -- LOG:Debug(gameAccountInfo.characterName) + local realm = gameAccountInfo.realmName + if not realm or realm == '' then + -- LOG:Debug(gameAccountInfo.richPresence) + local zoneName, realmName = strsplit('-', gameAccountInfo.richPresence) + -- LOG:Debug(realmName) + + if realmName and realmName ~= '' then + realm = strtrim(realmName) + end + end U:AddOrMoveToEnd(friendName, - U:join('-', gameAccountInfo.characterName, gameAccountInfo.realmName)) - -- U:AddOrMoveToEnd(friendName, gameAccountInfo.characterName) - -- U:AddOrMoveToEnd(friendName, gameAccountInfo.realmName) + U:join('-', gameAccountInfo.characterName, realm)) + U:AddOrMoveToEnd(friendName, gameAccountInfo.characterName) + U:AddOrMoveToEnd(friendName, realm) end end end @@ -373,8 +382,8 @@ function U:InitGuilds() U:AddOrMoveToEnd(guildName, name) local name, realm = strsplit('-', name) realm = realm or GetRealmName() - -- U:AddOrMoveToEnd(guildName, name) - -- U:AddOrMoveToEnd(guildName, realm) + U:AddOrMoveToEnd(guildName, name) + U:AddOrMoveToEnd(guildName, realm) end end end @@ -388,6 +397,10 @@ function U:InitZones() end U:AddOrMoveToEnd(zoneName, GetZoneText()) U:AddOrMoveToEnd(zoneName, GetSubZoneText()) + if #zoneName >= 200 then + table.remove(zoneName, 1) + table.remove(zoneName, 1) + end D:SaveDB('zoneName', zoneName, true) end @@ -410,8 +423,8 @@ function U:InitGroupMembers() -- 将名字和服务器存储在表中 U:AddOrMoveToEnd(groupMembers, U:join('-', name, realm)) - -- U:AddOrMoveToEnd(groupMembers, name) - -- U:AddOrMoveToEnd(groupMembers, realm) + U:AddOrMoveToEnd(groupMembers, name) + U:AddOrMoveToEnd(groupMembers, realm) end end diff --git a/InputInput_Libraries_zh/InputInput_Libraries_zh.toc b/InputInput_Libraries_zh/InputInput_Libraries_zh.toc index 38730d3..282b50a 100644 --- a/InputInput_Libraries_zh/InputInput_Libraries_zh.toc +++ b/InputInput_Libraries_zh/InputInput_Libraries_zh.toc @@ -1,7 +1,7 @@ ## Interface: 11503 ## IconTexture: Interface\AddOns\InputInput\Media\pet_type_dragon -## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r +## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r ## Notes: InputInput Libraries ZH ## Notes-zhCN: InputInput插件中文词语处理模块-可以使输入提示更智能 ## Notes-zhTW: InputInput插件中文詞語處理模組-可以使輸入提示更智能 diff --git a/InputInput_Libraries_zh/InputInput_Libraries_zh_Cata.toc b/InputInput_Libraries_zh/InputInput_Libraries_zh_Cata.toc index 63ade6d..6a84f3c 100644 --- a/InputInput_Libraries_zh/InputInput_Libraries_zh_Cata.toc +++ b/InputInput_Libraries_zh/InputInput_Libraries_zh_Cata.toc @@ -1,6 +1,6 @@ ## Interface: 40400 -## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r +## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r ## Notes: InputInput Libraries ZH ## Notes-zhCN: InputInput插件中文词语处理模块-可以使输入提示更智能 ## Notes-zhTW: InputInput插件中文詞語處理模組-可以使輸入提示更智能 diff --git a/InputInput_Libraries_zh/InputInput_Libraries_zh_Classic.toc b/InputInput_Libraries_zh/InputInput_Libraries_zh_Classic.toc index 5f69154..7c6c6ad 100644 --- a/InputInput_Libraries_zh/InputInput_Libraries_zh_Classic.toc +++ b/InputInput_Libraries_zh/InputInput_Libraries_zh_Classic.toc @@ -1,6 +1,6 @@ ## Interface: 11503 -## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r +## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r ## Notes: InputInput Libraries ZH ## Notes-zhCN: InputInput插件中文词语处理模块-可以使输入提示更智能 ## Notes-zhTW: InputInput插件中文詞語處理模組-可以使輸入提示更智能 diff --git a/InputInput_Libraries_zh/InputInput_Libraries_zh_Mainline.toc b/InputInput_Libraries_zh/InputInput_Libraries_zh_Mainline.toc index ed31df3..fa23e30 100644 --- a/InputInput_Libraries_zh/InputInput_Libraries_zh_Mainline.toc +++ b/InputInput_Libraries_zh/InputInput_Libraries_zh_Mainline.toc @@ -1,7 +1,7 @@ ## Interface: 110002 ## IconTexture: Interface\AddOns\InputInput\Media\pet_type_dragon -## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r +## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r ## Notes: InputInput Libraries ZH ## Notes-zhCN: InputInput插件中文词语处理模块-可以使输入提示更智能 ## Notes-zhTW: InputInput插件中文詞語處理模組-可以使輸入提示更智能 diff --git a/InputInput_Libraries_zh/InputInput_Libraries_zh_Vanilla.toc b/InputInput_Libraries_zh/InputInput_Libraries_zh_Vanilla.toc index 5f69154..7c6c6ad 100644 --- a/InputInput_Libraries_zh/InputInput_Libraries_zh_Vanilla.toc +++ b/InputInput_Libraries_zh/InputInput_Libraries_zh_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11503 -## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r +## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r ## Notes: InputInput Libraries ZH ## Notes-zhCN: InputInput插件中文词语处理模块-可以使输入提示更智能 ## Notes-zhTW: InputInput插件中文詞語處理模組-可以使輸入提示更智能 diff --git a/InputInput_Libraries_zh/InputInput_Libraries_zh_Wrath.toc b/InputInput_Libraries_zh/InputInput_Libraries_zh_Wrath.toc index 618c9b1..8f76239 100644 --- a/InputInput_Libraries_zh/InputInput_Libraries_zh_Wrath.toc +++ b/InputInput_Libraries_zh/InputInput_Libraries_zh_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffff0000zh|r +## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r_Libraries_|cffF56C6Czh|r ## Notes: InputInput Libraries ZH ## Notes-zhCN: InputInput插件中文词语处理模块-可以使输入提示更智能 ## Notes-zhTW: InputInput插件中文詞語處理模組-可以使輸入提示更智能