diff --git a/ChatCopy.lua b/ChatCopy.lua index a793384..c950255 100644 --- a/ChatCopy.lua +++ b/ChatCopy.lua @@ -40,7 +40,7 @@ editBox:SetScript("OnEscapePressed", function(f)f:GetParent():GetParent():Hide() scrollArea:SetScrollChild(editBox) function SimpleChat:CopyFunc() - local cf = SELECTED_DOCK_FRAME + local cf = SELECTED_CHAT_FRAME local _, size = cf:GetFont() FCF_SetChatWindowFontSize(cf, cf, .01) local ct = 1 diff --git a/ChatEmote.lua b/ChatEmote.lua index 79ce1a4..f003c5a 100644 --- a/ChatEmote.lua +++ b/ChatEmote.lua @@ -1,6 +1,7 @@ --[[ ChatEmote.lua 聊天表情相关代码 + 修正只解析一个表情 插件更新地址 http://nga.178.com/read.php?tid=9633520 --]] local SimpleChat = LibStub("AceAddon-3.0"):GetAddon("SimpleChat") @@ -86,7 +87,6 @@ local function ChatEmoteFilter(self, event, msg, ...) for i = customEmoteStartIndex, #emotes do if msg:find(emotes[i][1]) then msg = msg:gsub(emotes[i][1], format(fmtstring, emotes[i][2]), 1) - break end end end diff --git a/ChatLink.lua b/ChatLink.lua new file mode 100644 index 0000000..259ffba --- /dev/null +++ b/ChatLink.lua @@ -0,0 +1,87 @@ +---------------------------------------------- +-- 聊天超链接增强模块 +-- @原作者:M TinyChat +-- 修改日志: +-- 合并物品等级和图标解析,增加货币解析。移除了鼠标提示,预计下版本重新加入。 +---------------------------------------------- +local SimpleChat = LibStub("AceAddon-3.0"):GetAddon("SimpleChat") + +local SimpleChat_Config + +--生成新的ICON超链接 +local function GetHyperlink(Hyperlink, texture) + if not texture then + return Hyperlink + else + return "|T" .. texture .. ":0|t|h" .. Hyperlink + end +end + +--等级图标显示 +local function SetChatLinkIcon(Hyperlink) + local schema, id = string.match(Hyperlink, "|H(%w+):(%d+):") + local texture + if (schema == "item") then + texture = select(10, GetItemInfo(tonumber(id))) + elseif (schema == "currency") then + texture = select(3, GetCurrencyInfo(tonumber(id))) + elseif (schema == "spell") then + texture = select(3, GetSpellInfo(tonumber(id))) + elseif (schema == "achievement") then + texture = select(10, GetAchievementInfo(tonumber(id))) + end + return GetHyperlink(Hyperlink, texture) +end + +--等级图标显示 +local function SetChatLinkLevel(Hyperlink) + local link = string.match(Hyperlink, "|H(.-)|h") + local level = select(4, GetItemInfo(link)) + if (level) then + Hyperlink = Hyperlink:gsub("|h%[(.-)%]|h", "|h[" .. level .. ":%1]|h") + end + return Hyperlink +end + +--过滤器 +local function ChatLinkFilter(self, event, msg, ...) + if not SimpleChat_Config then + return false, msg, ... + end + + -- if SimpleChat_Config.ShowChatLinkIlvl then + -- msg = msg:gsub("(|Hitem:%d+:.-|h.-|h)", SetChatLinkLevel) + -- end + if SimpleChat_Config.ShowChatLinkIcon then + msg = msg:gsub("(|H%w+:%d+:.-|h.-|h)", SetChatLinkIcon) + end + return false, msg, ... +end + +function SimpleChat:InitChatLink() + SimpleChat_Config = self.db.profile + self:RegisterFilter("CHAT_MSG_CHANNEL", ChatLinkFilter)-- 公共频道 + self:RegisterFilter("CHAT_MSG_SAY", ChatLinkFilter)-- 说 + self:RegisterFilter("CHAT_MSG_YELL", ChatLinkFilter)-- 大喊 + self:RegisterFilter("CHAT_MSG_RAID", ChatLinkFilter)-- 团队 + self:RegisterFilter("CHAT_MSG_RAID_LEADER", ChatLinkFilter)-- 团队领袖 + self:RegisterFilter("CHAT_MSG_PARTY", ChatLinkFilter)-- 队伍 + self:RegisterFilter("CHAT_MSG_PARTY_LEADER", ChatLinkFilter)-- 队伍领袖 + self:RegisterFilter("CHAT_MSG_GUILD", ChatLinkFilter)-- 公会 + + self:RegisterFilter("CHAT_MSG_AFK", ChatLinkFilter)-- AFK玩家自动回复 + self:RegisterFilter("CHAT_MSG_DND", ChatLinkFilter)-- 切勿打扰自动回复 + -- 副本和副本领袖 + self:RegisterFilter("CHAT_MSG_INSTANCE_CHAT", ChatLinkFilter) + self:RegisterFilter("CHAT_MSG_INSTANCE_CHAT_LEADER", ChatLinkFilter) + -- 解析战网私聊 + self:RegisterFilter("CHAT_MSG_WHISPER", ChatLinkFilter) + self:RegisterFilter("CHAT_MSG_WHISPER_INFORM", ChatLinkFilter) + self:RegisterFilter("CHAT_MSG_BN_WHISPER", ChatLinkFilter) + self:RegisterFilter("CHAT_MSG_BN_WHISPER_INFORM", ChatLinkFilter) + -- 解析社区聊天内容 + self:RegisterFilter("CHAT_MSG_COMMUNITIES_CHANNEL", ChatLinkFilter) + --拾取信息 + self:RegisterFilter("CHAT_MSG_LOOT", ChatLinkFilter) + self:RegisterFilter("CHAT_MSG_CURRENCY", ChatLinkFilter) +end diff --git a/ChatLinkIcon.lua b/ChatLinkIcon.lua deleted file mode 100644 index 6b1ef4b..0000000 --- a/ChatLinkIcon.lua +++ /dev/null @@ -1,112 +0,0 @@ -------------------------------------- --- 聊天超鏈接增加ICON --- @Author:M TinyChat -------------------------------------- -local SimpleChat = LibStub("AceAddon-3.0"):GetAddon("SimpleChat") - -local SimpleChat_Config - ---生成新的ICON超链接 -local function GetHyperlink(Hyperlink, texture) - if (not texture or (TinyChatDB and TinyChatDB.hideLinkIcon)) then - return Hyperlink - else - return "|HChatLinkIcon|h|T" .. texture .. ":0|t|h" .. Hyperlink - end -end - ---等级图标显示 -local function SetChatLinkIcon(Hyperlink) - local schema, id = string.match(Hyperlink, "|H(%w+):(%d+):") - local texture - if (schema == "item") then - texture = select(10, GetItemInfo(tonumber(id))) - elseif (schema == "currency") then - texture = select(3, GetCurrencyInfo(tonumber(id))) - elseif (schema == "spell") then - texture = select(3, GetSpellInfo(tonumber(id))) - elseif (schema == "achievement") then - texture = select(10, GetAchievementInfo(tonumber(id))) - end - return GetHyperlink(Hyperlink, texture) -end - ---过滤器 -local function ChatIconFilter(self, event, msg, ...) - if (SimpleChat_Config and SimpleChat_Config.ShowChatLinkIcon) then - msg = msg:gsub("(|H%w+:%d+:.-|h.-|h)", SetChatLinkIcon) - end - return false, msg, ... -end - -function SimpleChat:InitChatLinkIcon() - SimpleChat_Config = self.db.profile - self:RegisterFilter("CHAT_MSG_CHANNEL", ChatIconFilter)-- 公共频道 - self:RegisterFilter("CHAT_MSG_SAY", ChatIconFilter)-- 说 - self:RegisterFilter("CHAT_MSG_YELL", ChatIconFilter)-- 大喊 - self:RegisterFilter("CHAT_MSG_RAID", ChatIconFilter)-- 团队 - self:RegisterFilter("CHAT_MSG_RAID_LEADER", ChatIconFilter)-- 团队领袖 - self:RegisterFilter("CHAT_MSG_PARTY", ChatIconFilter)-- 队伍 - self:RegisterFilter("CHAT_MSG_PARTY_LEADER", ChatIconFilter)-- 队伍领袖 - self:RegisterFilter("CHAT_MSG_GUILD", ChatIconFilter)-- 公会 - - self:RegisterFilter("CHAT_MSG_AFK", ChatIconFilter)-- AFK玩家自动回复 - self:RegisterFilter("CHAT_MSG_DND", ChatIconFilter)-- 切勿打扰自动回复 - -- 副本和副本领袖 - self:RegisterFilter("CHAT_MSG_INSTANCE_CHAT", ChatIconFilter) - self:RegisterFilter("CHAT_MSG_INSTANCE_CHAT_LEADER", ChatIconFilter) - -- 解析战网私聊 - self:RegisterFilter("CHAT_MSG_WHISPER", ChatIconFilter) - self:RegisterFilter("CHAT_MSG_WHISPER_INFORM", ChatIconFilter) - self:RegisterFilter("CHAT_MSG_BN_WHISPER", ChatIconFilter) - self:RegisterFilter("CHAT_MSG_BN_WHISPER_INFORM", ChatIconFilter) - -- 解析社区聊天内容 - self:RegisterFilter("CHAT_MSG_COMMUNITIES_CHANNEL", ChatIconFilter) - -- 拾取信息 - self:RegisterFilter("CHAT_MSG_LOOT", ChatIconFilter) - self:RegisterFilter("CHAT_MSG_CURRENCY", ChatIconFilter) -end - -local bigIconFrame --- 鼠标图标大图显示 -function SimpleChat:InitChatLinkBigIconFrame() - bigIconFrame = CreateFrame("Frame", nil, UIParent) - bigIconFrame:SetSize(48, 48) - bigIconFrame:SetFrameStrata("TOOLTIP") - bigIconFrame.icon = bigIconFrame:CreateTexture(nil, "BACKGROUND") - bigIconFrame.icon:SetSize(48, 48) - bigIconFrame.icon:SetPoint("CENTER") - bigIconFrame:Hide() - local function OnHyperlinkEnter(self, linkData, link) - local schema = strsplit(":", linkData) - --if (schema == "item" or schema == "spell" or schema == "achievement") then - -- ShowUIPanel(ItemRefTooltip) - -- if (not ItemRefTooltip:IsShown()) then - -- ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE") - -- end - -- ItemRefTooltip:SetHyperlink(link) - --end - if (schema == "ChatLinkIcon") then - local texture = link:match("%|T(.-):.-%|t") - if (texture) then - local cursorX, cursorY = GetCursorPosition() - bigIconFrame.icon:SetTexture(texture) - bigIconFrame:SetPoint( - "TOP", - UIParent, - "BOTTOMLEFT", - cursorX / UIParent:GetScale() + 24, - cursorY / UIParent:GetScale() + 10 - ) - bigIconFrame:Show() - end - end - end - local function OnHyperlinkLeave(self, linkData, link) - bigIconFrame:Hide() - end - for i = 1, NUM_CHAT_WINDOWS do - _G["ChatFrame" .. i]:HookScript("OnHyperlinkEnter", OnHyperlinkEnter) - _G["ChatFrame" .. i]:HookScript("OnHyperlinkLeave", OnHyperlinkLeave) - end -end diff --git a/ChatLinkIlvl.lua b/ChatLinkIlvl.lua deleted file mode 100644 index e727811..0000000 --- a/ChatLinkIlvl.lua +++ /dev/null @@ -1,85 +0,0 @@ ----------------------------------------------- --- 聊天超鏈接增加物品等級 (支持大祕境鑰匙等級) --- @Author:M TinyChat ----------------------------------------------- -local SimpleChat = LibStub("AceAddon-3.0"):GetAddon("SimpleChat") - -local SimpleChat_Config - -local tooltip = CreateFrame("GameTooltip", "ChatLinkLevelTooltip", UIParent, "GameTooltipTemplate") - -local ItemLevelPattern = gsub(ITEM_LEVEL, "%%d", "(%%d+)") -local ItemPowerPattern = gsub(CHALLENGE_MODE_ITEM_POWER_LEVEL, "%%d", "(%%d+)") -local ItemNamePattern = gsub(CHALLENGE_MODE_KEYSTONE_NAME, "%%s", "(.+)") - ---获取物品实际等级 -local function GetItemLevelAndTexture(ItemLink) - local texture = select(10, GetItemInfo(ItemLink)) - if (not texture) then - return - end - local text, level, extraname - tooltip:SetOwner(UIParent, "ANCHOR_NONE") - tooltip:ClearLines() - tooltip:SetHyperlink(ItemLink) - for i = 2, 4 do - text = _G[tooltip:GetName() .. "TextLeft" .. i]:GetText() or "" - level = string.match(text, ItemLevelPattern) - if (level) then - break - end - level = string.match(text, ItemPowerPattern) - if (level) then - -- extraname = string.match(_G[tooltip:GetName().."TextLeft1"]:GetText(), ItemNamePattern) - -- break - end - end - return level, texture, extraname -end - ---等级图标显示 -local function SetChatLinkLevel(Hyperlink) - local link = string.match(Hyperlink, "|H(.-)|h") - local level, texture, extraname = GetItemLevelAndTexture(link) - if (level and extraname) then - Hyperlink = Hyperlink:gsub("|h%[(.-)%]|h", "|h[" .. level .. ":%1:" .. extraname .. "]|h") - elseif (level) then - Hyperlink = Hyperlink:gsub("|h%[(.-)%]|h", "|h[" .. level .. ":%1]|h") - end - return Hyperlink -end - ---过滤器 -local function ChatLinkIlvlFilter(self, event, msg, ...) - if (SimpleChat_Config and SimpleChat_Config.ShowChatLinkIlvl) then - msg = msg:gsub("(|Hitem:%d+:.-|h.-|h)", SetChatLinkLevel) - end - return false, msg, ... -end - -function SimpleChat:InitChatLinkIlvl() - SimpleChat_Config = self.db.profile - self:RegisterFilter("CHAT_MSG_CHANNEL", ChatLinkIlvlFilter)-- 公共频道 - self:RegisterFilter("CHAT_MSG_SAY", ChatLinkIlvlFilter)-- 说 - self:RegisterFilter("CHAT_MSG_YELL", ChatLinkIlvlFilter)-- 大喊 - self:RegisterFilter("CHAT_MSG_RAID", ChatLinkIlvlFilter)-- 团队 - self:RegisterFilter("CHAT_MSG_RAID_LEADER", ChatLinkIlvlFilter)-- 团队领袖 - self:RegisterFilter("CHAT_MSG_PARTY", ChatLinkIlvlFilter)-- 队伍 - self:RegisterFilter("CHAT_MSG_PARTY_LEADER", ChatLinkIlvlFilter)-- 队伍领袖 - self:RegisterFilter("CHAT_MSG_GUILD", ChatLinkIlvlFilter)-- 公会 - - self:RegisterFilter("CHAT_MSG_AFK", ChatLinkIlvlFilter)-- AFK玩家自动回复 - self:RegisterFilter("CHAT_MSG_DND", ChatLinkIlvlFilter)-- 切勿打扰自动回复 - -- 副本和副本领袖 - self:RegisterFilter("CHAT_MSG_INSTANCE_CHAT", ChatLinkIlvlFilter) - self:RegisterFilter("CHAT_MSG_INSTANCE_CHAT_LEADER", ChatLinkIlvlFilter) - -- 解析战网私聊 - self:RegisterFilter("CHAT_MSG_WHISPER", ChatLinkIlvlFilter) - self:RegisterFilter("CHAT_MSG_WHISPER_INFORM", ChatLinkIlvlFilter) - self:RegisterFilter("CHAT_MSG_BN_WHISPER", ChatLinkIlvlFilter) - self:RegisterFilter("CHAT_MSG_BN_WHISPER_INFORM", ChatLinkIlvlFilter) - -- 解析社区聊天内容 - self:RegisterFilter("CHAT_MSG_COMMUNITIES_CHANNEL", ChatLinkIlvlFilter) - --拾取信息 - self:RegisterFilter("CHAT_MSG_LOOT", ChatLinkIlvlFilter) -end diff --git a/Chatbar.lua b/Chatbar.lua index 73b5c7a..d45283d 100644 --- a/Chatbar.lua +++ b/Chatbar.lua @@ -235,7 +235,6 @@ function SimpleChat:InitChatBar() ChatBar:SetPoint("TOPLEFT", "ChatFrame1", "BOTTOMLEFT", SimpleChat_Config.ChatBarOffsetX, SimpleChat_Config.ChatBarOffsetY - 30) end end - print("|cffffe00a<|r|cffff7d0aSimpleChat|r|cffffe00a>|r 聊天条位置初始化完毕") else local point = SimpleChat_Config.Position.point local relativeTo = SimpleChat_Config.Position.relativeTo @@ -253,4 +252,5 @@ function SimpleChat:InitChatBar() for i = 1, #ChannelButtons do -- 对非战斗记录聊天框的信息进行处理 CreateChannelButton(ChannelButtons[i], i) end + print("|cffffe00a<|r|cffff7d0aSimpleChat|r|cffffe00a>|r 聊天条加载完毕") end diff --git a/Core.lua b/Core.lua index 5da2472..16ff0a3 100644 --- a/Core.lua +++ b/Core.lua @@ -21,7 +21,7 @@ local SimpleChat_Config = { -- 聊天物品链接增强 ShowChatLinkIlvl = true, -- 显示物品链接装等 ShowChatLinkIcon = true, -- 显示物品链接图标 - ShowChatLinkBigIcon = true, -- 鼠标移动到链接图标上时会放大 + -- ShowChatLinkBigIcon = true, -- 鼠标移动到链接图标上时会放大 -- 聊天表情 EmoteIconSize = 18, -- 聊天文字中的表情大小,你可以根据聊天字号调整 EmoteIconListSize = 30, -- 表情选择器的图标大小 @@ -52,9 +52,7 @@ function SimpleChat:OnInitialize() -- 加载功能模块 self:InitChatBar() -- 加载聊天条 self:InitChannel() -- 频道增强 - self:InitChatLinkIlvl() -- 聊天链接装等显示 - self:InitChatLinkIcon() -- 聊天链接图标显示 - self:InitChatLinkBigIconFrame() -- 聊天链接大图标框架 + self:InitChatLink() -- 聊天链接增强 self:InitEmoteTableFrame() -- 表情选择框架 end diff --git a/Libs/AceAddon-3.0/AceAddon-3.0.lua b/Libs/AceAddon-3.0/AceAddon-3.0.lua index e9d4154..2b2a00e 100644 --- a/Libs/AceAddon-3.0/AceAddon-3.0.lua +++ b/Libs/AceAddon-3.0/AceAddon-3.0.lua @@ -6,29 +6,29 @@ -- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present. -- * **OnDisable**, which is only called when your addon is manually being disabled. -- @usage --- -- A small (but complete) addon, that doesn't do anything, +-- -- A small (but complete) addon, that doesn't do anything, -- -- but shows usage of the callbacks. -- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") --- +-- -- function MyAddon:OnInitialize() --- -- do init tasks here, like loading the Saved Variables, +-- -- do init tasks here, like loading the Saved Variables, -- -- or setting up slash commands. -- end --- +-- -- function MyAddon:OnEnable() -- -- Do more initialization here, that really enables the use of your addon. --- -- Register Events, Hook functions, Create Frames, Get information from +-- -- Register Events, Hook functions, Create Frames, Get information from -- -- the game that wasn't available in OnInitialize -- end -- -- function MyAddon:OnDisable() -- -- Unhook, Unregister Events, Hide frames that you created. --- -- You would probably only use an OnDisable if you want to +-- -- You would probably only use an OnDisable if you want to -- -- build a "standby" mode, or be able to toggle modules on/off. -- end -- @class file -- @name AceAddon-3.0.lua --- @release $Id: AceAddon-3.0.lua 1184 2018-07-21 14:13:14Z nevcairiel $ +-- @release $Id: AceAddon-3.0.lua 1202 2019-05-15 23:11:22Z nevcairiel $ local MAJOR, MINOR = "AceAddon-3.0", 12 local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) @@ -75,7 +75,7 @@ end local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype -- used in the addon metatable -local function addontostring( self ) return self.name end +local function addontostring( self ) return self.name end -- Check if the addon is queued for initialization local function queuedForInitialization(addon) @@ -88,14 +88,14 @@ local function queuedForInitialization(addon) end --- Create a new AceAddon-3.0 addon. --- Any libraries you specified will be embeded, and the addon will be scheduled for +-- Any libraries you specified will be embeded, and the addon will be scheduled for -- its OnInitialize and OnEnable callbacks. -- The final addon object, with all libraries embeded, will be returned. -- @paramsig [object ,]name[, lib, ...] -- @param object Table to use as a base for the addon (optional) -- @param name Name of the addon object to create -- @param lib List of libraries to embed into the addon --- @usage +-- @usage -- -- Create a simple addon object -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0") -- @@ -115,10 +115,10 @@ function AceAddon:NewAddon(objectorname, ...) if type(name)~="string" then error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end - if self.addons[name] then + if self.addons[name] then error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2) end - + object = object or {} object.name = name @@ -128,7 +128,7 @@ function AceAddon:NewAddon(objectorname, ...) for k, v in pairs(oldmeta) do addonmeta[k] = v end end addonmeta.__tostring = addontostring - + setmetatable( object, addonmeta ) self.addons[name] = object object.modules = {} @@ -136,7 +136,7 @@ function AceAddon:NewAddon(objectorname, ...) object.defaultModuleLibraries = {} Embed( object ) -- embed NewModule, GetModule methods self:EmbedLibraries(object, select(i,...)) - + -- add to queue of addons to be initialized upon ADDON_LOADED tinsert(self.initializequeue, object) return object @@ -147,7 +147,7 @@ end -- Throws an error if the addon object cannot be found (except if silent is set). -- @param name unique name of the addon object -- @param silent if true, the addon is optional, silently return nil if its not found --- @usage +-- @usage -- -- Get the Addon -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") function AceAddon:GetAddon(name, silent) @@ -202,7 +202,7 @@ end -- @paramsig name[, silent] -- @param name unique name of the module -- @param silent if true, the module is optional, silently return nil if its not found (optional) --- @usage +-- @usage -- -- Get the Addon -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- -- Get the Module @@ -225,23 +225,23 @@ local function IsModuleTrue(self) return true end -- @param name unique name of the module -- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional) -- @param lib List of libraries to embed into the addon --- @usage +-- @usage -- -- Create a module with some embeded libraries -- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0") --- +-- -- -- Create a module with a prototype -- local prototype = { OnEnable = function(self) print("OnEnable called!") end } -- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0") function NewModule(self, name, prototype, ...) if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end - + if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end - + -- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well. -- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is. local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name)) - + module.IsModule = IsModuleTrue module:SetEnabledState(self.defaultModuleState) module.moduleName = name @@ -256,24 +256,24 @@ function NewModule(self, name, prototype, ...) if not prototype or type(prototype) == "string" then prototype = self.defaultModulePrototype or nil end - + if type(prototype) == "table" then local mt = getmetatable(module) mt.__index = prototype setmetatable(module, mt) -- More of a Base class type feel. end - + safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy. self.modules[name] = module tinsert(self.orderedModules, module) - + return module end --- Returns the real name of the addon or module, without any prefix. -- @name //addon//:GetName --- @paramsig --- @usage +-- @paramsig +-- @usage -- print(MyAddon:GetName()) -- -- prints "MyAddon" function GetName(self) @@ -285,8 +285,8 @@ end -- and enabling all modules of the addon (unless explicitly disabled).\\ -- :Enable() also sets the internal `enableState` variable to true -- @name //addon//:Enable --- @paramsig --- @usage +-- @paramsig +-- @usage -- -- Enable MyModule -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyModule = MyAddon:GetModule("MyModule") @@ -306,8 +306,8 @@ end -- and disabling all modules of the addon.\\ -- :Disable() also sets the internal `enableState` variable to false -- @name //addon//:Disable --- @paramsig --- @usage +-- @paramsig +-- @usage -- -- Disable MyAddon -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyAddon:Disable() @@ -320,7 +320,7 @@ end -- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object. -- @name //addon//:EnableModule -- @paramsig name --- @usage +-- @usage -- -- Enable MyModule using :GetModule -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyModule = MyAddon:GetModule("MyModule") @@ -338,7 +338,7 @@ end -- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object. -- @name //addon//:DisableModule -- @paramsig name --- @usage +-- @usage -- -- Disable MyModule using :GetModule -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyModule = MyAddon:GetModule("MyModule") @@ -357,7 +357,7 @@ end -- @name //addon//:SetDefaultModuleLibraries -- @paramsig lib[, lib, ...] -- @param lib List of libraries to embed into the addon --- @usage +-- @usage -- -- Create the addon object -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") -- -- Configure default libraries for modules (all modules need AceEvent-3.0) @@ -376,7 +376,7 @@ end -- @name //addon//:SetDefaultModuleState -- @paramsig state -- @param state Default state for new modules, true for enabled, false for disabled --- @usage +-- @usage -- -- Create the addon object -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") -- -- Set the default state to "disabled" @@ -396,7 +396,7 @@ end -- @name //addon//:SetDefaultModulePrototype -- @paramsig prototype -- @param prototype Default prototype for the new modules (table) --- @usage +-- @usage -- -- Define a prototype -- local prototype = { OnEnable = function(self) print("OnEnable called!") end } -- -- Set the default prototype @@ -428,8 +428,8 @@ end --- Return an iterator of all modules associated to the addon. -- @name //addon//:IterateModules --- @paramsig --- @usage +-- @paramsig +-- @usage -- -- Enable all modules -- for name, module in MyAddon:IterateModules() do -- module:Enable() @@ -438,13 +438,13 @@ local function IterateModules(self) return pairs(self.modules) end -- Returns an iterator of all embeds in the addon -- @name //addon//:IterateEmbeds --- @paramsig +-- @paramsig local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end --- Query the enabledState of an addon. -- @name //addon//:IsEnabled --- @paramsig --- @usage +-- @paramsig +-- @usage -- if MyAddon:IsEnabled() then -- MyAddon:Disable() -- end @@ -489,20 +489,20 @@ end -- - Initialize the addon after creation. -- This function is only used internally during the ADDON_LOADED event --- It will call the **OnInitialize** function on the addon object (if present), +-- It will call the **OnInitialize** function on the addon object (if present), -- and the **OnEmbedInitialize** function on all embeded libraries. --- +-- -- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. -- @param addon addon object to intialize function AceAddon:InitializeAddon(addon) safecall(addon.OnInitialize, addon) - + local embeds = self.embeds[addon] for i = 1, #embeds do local lib = LibStub:GetLibrary(embeds[i], true) if lib then safecall(lib.OnEmbedInitialize, lib, addon) end end - + -- we don't call InitializeAddon on modules specifically, this is handled -- from the event handler and only done _once_ end @@ -510,7 +510,7 @@ end -- - Enable the addon after creation. -- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED, -- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons. --- It will call the **OnEnable** function on the addon object (if present), +-- It will call the **OnEnable** function on the addon object (if present), -- and the **OnEmbedEnable** function on all embeded libraries.\\ -- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled. -- @@ -520,12 +520,12 @@ end function AceAddon:EnableAddon(addon) if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end if self.statuses[addon.name] or not addon.enabledState then return false end - + -- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable. self.statuses[addon.name] = true - + safecall(addon.OnEnable, addon) - + -- make sure we're still enabled before continueing if self.statuses[addon.name] then local embeds = self.embeds[addon] @@ -533,7 +533,7 @@ function AceAddon:EnableAddon(addon) local lib = LibStub:GetLibrary(embeds[i], true) if lib then safecall(lib.OnEmbedEnable, lib, addon) end end - + -- enable possible modules. local modules = addon.orderedModules for i = 1, #modules do @@ -545,24 +545,24 @@ end -- - Disable the addon -- Note: This function is only used internally. --- It will call the **OnDisable** function on the addon object (if present), +-- It will call the **OnDisable** function on the addon object (if present), -- and the **OnEmbedDisable** function on all embeded libraries.\\ -- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled. -- --- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. -- Use :Disable on the addon itself instead. -- @param addon addon object to enable function AceAddon:DisableAddon(addon) if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end if not self.statuses[addon.name] then return false end - + -- set statuses first before calling OnDisable, this allows for aborting the disable in OnDisable. self.statuses[addon.name] = false - + safecall( addon.OnDisable, addon ) - + -- make sure we're still disabling... - if not self.statuses[addon.name] then + if not self.statuses[addon.name] then local embeds = self.embeds[addon] for i = 1, #embeds do local lib = LibStub:GetLibrary(embeds[i], true) @@ -574,12 +574,12 @@ function AceAddon:DisableAddon(addon) self:DisableAddon(modules[i]) end end - + return not self.statuses[addon.name] -- return true if we're disabled end --- Get an iterator over all registered addons. --- @usage +-- @usage -- -- Print a list of all installed AceAddon's -- for name, addon in AceAddon:IterateAddons() do -- print("Addon: " .. name) @@ -587,7 +587,7 @@ end function AceAddon:IterateAddons() return pairs(self.addons) end --- Get an iterator over the internal status registry. --- @usage +-- @usage -- -- Print a list of all enabled addons -- for name, status in AceAddon:IterateAddonStatus() do -- if status then @@ -613,7 +613,7 @@ local function onEvent(this, event, arg1) AceAddon:InitializeAddon(addon) tinsert(AceAddon.enablequeue, addon) end - + if IsLoggedIn() then while(#AceAddon.enablequeue > 0) do local addon = tremove(AceAddon.enablequeue, 1) diff --git a/Libs/AceConsole-3.0/AceConsole-3.0.lua b/Libs/AceConsole-3.0/AceConsole-3.0.lua index 0567a65..678fa95 100644 --- a/Libs/AceConsole-3.0/AceConsole-3.0.lua +++ b/Libs/AceConsole-3.0/AceConsole-3.0.lua @@ -2,14 +2,14 @@ -- You can register slash commands to your custom functions and use the `GetArgs` function to parse them -- to your addons individual needs. -- --- **AceConsole-3.0** can be embeded into your addon, either explicitly by calling AceConsole:Embed(MyAddon) or by +-- **AceConsole-3.0** can be embeded into your addon, either explicitly by calling AceConsole:Embed(MyAddon) or by -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object -- and can be accessed directly, without having to explicitly call AceConsole itself.\\ -- It is recommended to embed AceConsole, otherwise you'll have to specify a custom `self` on all calls you -- make into AceConsole. -- @class file -- @name AceConsole-3.0 --- @release $Id: AceConsole-3.0.lua 1143 2016-07-11 08:52:03Z nevcairiel $ +-- @release $Id: AceConsole-3.0.lua 1202 2019-05-15 23:11:22Z nevcairiel $ local MAJOR,MINOR = "AceConsole-3.0", 7 local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR) @@ -84,11 +84,11 @@ end -- @param persist if false, the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true) function AceConsole:RegisterChatCommand( command, func, persist ) if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand( "command", func[, persist ]): 'command' - expected a string]], 2) end - + if persist==nil then persist=true end -- I'd rather have my addon's "/addon enable" around if the author screws up. Having some extra slash regged when it shouldnt be isn't as destructive. True is a better default. /Mikk - + local name = "ACECONSOLE_"..command:upper() - + if type( func ) == "string" then SlashCmdList[name] = function(input, editBox) self[func](self, input, editBox) @@ -132,9 +132,9 @@ local function nils(n, ...) return ... end end - ---- Retreive one or more space-separated arguments from a string. + +--- Retreive one or more space-separated arguments from a string. -- Treats quoted strings and itemlinks as non-spaced. -- @param str The raw argument string -- @param numargs How many arguments to get (default 1) @@ -144,7 +144,7 @@ end function AceConsole:GetArgs(str, numargs, startpos) numargs = numargs or 1 startpos = max(startpos or 1, 1) - + local pos=startpos -- find start of new arg @@ -169,24 +169,24 @@ function AceConsole:GetArgs(str, numargs, startpos) else delim_or_pipe="([| ])" end - + startpos = pos - + while true do -- find delimiter or hyperlink local ch,_ pos,_,ch = strfind(str, delim_or_pipe, pos) - + if not pos then break end - + if ch=="|" then -- some kind of escape - + if strsub(str,pos,pos+1)=="|H" then -- It's a |H....|hhyper link!|h pos=strfind(str, "|h", pos+2) -- first |h if not pos then break end - + pos=strfind(str, "|h", pos+2) -- second |h if not pos then break end elseif strsub(str,pos, pos+1) == "|T" then @@ -194,16 +194,16 @@ function AceConsole:GetArgs(str, numargs, startpos) pos=strfind(str, "|t", pos+2) if not pos then break end end - + pos=pos+2 -- skip past this escape (last |h if it was a hyperlink) - + else -- found delimiter, done with this arg return strsub(str, startpos, pos-1), AceConsole:GetArgs(str, numargs-1, pos+1) end - + end - + -- search aborted, we hit end of string. return it all as one argument. (yes, even if it's an unterminated quote or hyperlink) return strsub(str, startpos), nils(numargs-1, 1e9) end @@ -214,10 +214,10 @@ end local mixins = { "Print", "Printf", - "RegisterChatCommand", + "RegisterChatCommand", "UnregisterChatCommand", "GetArgs", -} +} -- Embeds AceConsole into the target object making the functions from the mixins list available on target:.. -- @param target target object to embed AceBucket in diff --git a/Libs/AceEvent-3.0/AceEvent-3.0.lua b/Libs/AceEvent-3.0/AceEvent-3.0.lua index bbf55c2..7ccd880 100644 --- a/Libs/AceEvent-3.0/AceEvent-3.0.lua +++ b/Libs/AceEvent-3.0/AceEvent-3.0.lua @@ -2,14 +2,14 @@ -- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around -- CallbackHandler, and dispatches all game events or addon message to the registrees. -- --- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by +-- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object -- and can be accessed directly, without having to explicitly call AceEvent itself.\\ -- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you -- make into AceEvent. -- @class file -- @name AceEvent-3.0 --- @release $Id: AceEvent-3.0.lua 1161 2017-08-12 14:30:16Z funkydude $ +-- @release $Id: AceEvent-3.0.lua 1202 2019-05-15 23:11:22Z nevcairiel $ local CallbackHandler = LibStub("CallbackHandler-1.0") local MAJOR, MINOR = "AceEvent-3.0", 4 @@ -25,22 +25,22 @@ AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib -- APIs and registry for blizzard events, using CallbackHandler lib if not AceEvent.events then - AceEvent.events = CallbackHandler:New(AceEvent, + AceEvent.events = CallbackHandler:New(AceEvent, "RegisterEvent", "UnregisterEvent", "UnregisterAllEvents") end -function AceEvent.events:OnUsed(target, eventname) +function AceEvent.events:OnUsed(target, eventname) AceEvent.frame:RegisterEvent(eventname) end -function AceEvent.events:OnUnused(target, eventname) +function AceEvent.events:OnUnused(target, eventname) AceEvent.frame:UnregisterEvent(eventname) end -- APIs and registry for IPC messages, using CallbackHandler lib if not AceEvent.messages then - AceEvent.messages = CallbackHandler:New(AceEvent, + AceEvent.messages = CallbackHandler:New(AceEvent, "RegisterMessage", "UnregisterMessage", "UnregisterAllMessages" ) AceEvent.SendMessage = AceEvent.messages.Fire diff --git a/SimpleChat.toc b/SimpleChat.toc index c2bd780..7ac042c 100644 --- a/SimpleChat.toc +++ b/SimpleChat.toc @@ -1,8 +1,8 @@ -## Interface: 80100 +## Interface: 80200 ## Title: [Chat]SimpleChat ## Title-zhCN: [社交]简易聊天增强 ## Title-zhTW: [社交]簡易聊天增強 -## Version: 1.7.1 +## Version: 1.7.2 ## Notes: SimpleChat. ## SavedVariablesPerCharacter: SimpleChatDB @@ -25,10 +25,8 @@ channel.lua easyChannel.lua # 聊天表情 ChatEmote.lua -# 聊天链接图标 -ChatLinkIcon.lua -# 聊天物品链接等级 -ChatLinkIlvl.lua +# 聊天链接 +ChatLink.lua # 属性报告 StatReport.lua # 聊天复制 diff --git a/StatReport.lua b/StatReport.lua index 502b558..933b95f 100644 --- a/StatReport.lua +++ b/StatReport.lua @@ -1,7 +1,7 @@ --[[ StatReport.lua 属性通报 - TODO:适配Bfa正式版本,汇报神器项链、武器和盾牌。 + 适配Bfa正式版本,汇报神器项链。修正汇报护甲为0 插件更新地址 http://nga.178.com/read.php?tid=9633520 --]] local SimpleChat = LibStub("AceAddon-3.0"):GetAddon("SimpleChat") @@ -124,7 +124,7 @@ end local function TankInfo() local TankStat = "" TankStat = TankStat .. ("耐力:%s "):format(UnitStat("player", 3)) - TankStat = TankStat .. ("护甲:%s "):format(UnitArmor("player")) + TankStat = TankStat .. ("护甲:%s "):format(select(3, UnitArmor("player"))) TankStat = TankStat .. ("躲闪:%.0f%% "):format(GetDodgeChance()) TankStat = TankStat .. ("招架:%.0f%% "):format(GetParryChance()) TankStat = TankStat .. ("格挡:%.0f%% "):format(GetBlockChance())