Version 0.2.2

- added Options UI under Interface Options
- store settings in profiles
- added more translations
This commit is contained in:
2020-05-26 00:51:59 +02:00
parent 32a692279a
commit db3db16594
19 changed files with 4922 additions and 52 deletions

View File

@@ -15,15 +15,14 @@
--------------------------------------------------------------------------]] --
-- initialize addon
local AddonName, AddonTable = ...
local Grichelde = LibStub("AceAddon-3.0"):NewAddon("Grichelde", "AceEvent-3.0", "AceHook-3.0")
Grichelde = LibStub("AceAddon-3.0"):NewAddon(AddonName, "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0")
Grichelde.L = LibStub("AceLocale-3.0"):GetLocale("Grichelde", true)
Grichelde.version = GetAddOnMetadata(AddonName, "Version")
Grichelde.build = GetAddOnMetadata(AddonName, "X-Build") or "UNKNOWN"
local L = LibStub("AceLocale-3.0"):GetLocale("Grichelde", true)
local Grichelde_Debug = false
Grichelde.build = GetAddOnMetadata(AddonName, "X-Build") or "Experimental"
Grichelde.hooks = {}
Grichelde.debug = false
-- faster function lookups by mapping to local refs
local string_find = string.find
@@ -39,34 +38,15 @@ local tContains = tContains
local pairs = pairs
local ipairs = ipairs
local Grichelde_Hooks = {}
--local Grichelde_ChatTypes = { "SAY", "EMOTE", "YELL", "PARTY", "GUILD", "OFFICER", "RAID", "RAID_WARNING", "INSTANCE_CHAT", "BATTLEGROUND", "WHISPER" }
local Grichelde_ChatTypes = { "SAY", "EMOTE", "YELL", "PARTY", "GUILD" }
local Grichelde_ChatCommands = { "/s", "/e", "/me", "/y", "/p", "/pl", "/g", "/o", "/raid", "/rl", "/rw", "/i", "bg", "/w", "/r", "/tt" }
-- do not replace these patterns
local Grichelde_IgnorePatterns = {
"|[Cc]%x%x%x%x%x%x%x%x.-|r", -- colored items (or links)
"|H.-|h", -- item links (http://www.wowwiki.com/ItemLink)
"|T.-|t", -- textures
"|n", -- newline
"{rt[1-8]}", -- rumbered raid target icons
"{Star}", -- named raid target icon 1
"{Circle}", -- named raid target icon 2
"{Coin}", -- named raid target icon 2
"{Diamond}", -- named raid target icon 3
"{Triangle}", -- named raid target icon 4
"{Moon}", -- named raid target icon 5
"{Square}", -- named raid target icon 6
"{Cross}", -- named raid target icon 7
"{X}", -- named raid target icon 7
"{Skull}" -- named raid target icon 8
}
-- Ace3 callbacks
function Grichelde:OnInitialize()
-- Build Interface Options window
--self:CreateInterfaceOptions()
self:LoadDatabase()
self:SetupOptions()
self:SetupSlashCommands()
-- Watch for WIM and Prat to Load, then integrate
self:RegisterEvent("ADDON_LOADED", "HookIntoForOtherChatAddons")
@@ -81,7 +61,7 @@ function Grichelde:OnEnable()
end
-- tell the world we are listening
print(L.AddonLoaded)
print(self.L.AddonLoaded)
end
function Grichelde:OnDisable()
@@ -106,12 +86,12 @@ function Grichelde:HookIntoForOtherChatAddons(event, addonName)
-- into ChatThrottleLib to be on the safe side.
if (ChatThrottleLib) then
Grichelde_Hooks["ChatThrottleLib"] = ChatThrottleLib.SendChatMessage
Grichelde.hooks["ChatThrottleLib"] = ChatThrottleLib.SendChatMessage
function ChatThrottleLib:SendChatMessage(prio, prefix, text, ...)
Grichelde:DebugPrint("ChatThrottleLib:SendChatMessage : Hook called")
local replacedText = Grichelde:CheckAndReplace(text)
return Grichelde_Hooks["ChatThrottleLib"](ChatThrottleLib, prio, prefix, replacedText, ...)
return Grichelde.hooks["ChatThrottleLib"](ChatThrottleLib, prio, prefix, replacedText, ...)
end
end
end
@@ -180,6 +160,26 @@ end
--- @return number
function Grichelde:CheckForPreversableText(text)
self:DebugPrint("CheckForPreversableText : text is " .. text)
-- do not replace these patterns
local Grichelde_IgnorePatterns = {
"|[Cc]%x%x%x%x%x%x%x%x.-|r", -- colored items (or links)
"|H.-|h", -- item links (http://www.wowwiki.com/ItemLink)
"|T.-|t", -- textures
"|n", -- newline
"{rt[1-8]}", -- rumbered raid target icons
"{Star}", -- named raid target icon 1
"{Circle}", -- named raid target icon 2
"{Coin}", -- named raid target icon 2
"{Diamond}", -- named raid target icon 3
"{Triangle}", -- named raid target icon 4
"{Moon}", -- named raid target icon 5
"{Square}", -- named raid target icon 6
"{Cross}", -- named raid target icon 7
"{X}", -- named raid target icon 7
"{Skull}" -- named raid target icon 8
}
-- Calling find on ever pattern might be inefficient but its way less code.
for _, pattern in ipairs(Grichelde_IgnorePatterns) do
local pos1, pos2 = string_find(text, pattern)
@@ -257,6 +257,8 @@ end
function Grichelde:ReplaceCharacters(text)
-- todo: read from options
-- todo: case (in)sensitivity
-- todo: consolidate consecutive
-- todo: prevent infinite loops - is that even possible?
local replacement = text
replacement = string_gsub(replacement, "s", "ch")
replacement = string_gsub(replacement, "S", "Ch")
@@ -324,11 +326,15 @@ function Grichelde:SplitOnLastMatch(text, start)
end
function Grichelde:DebugPrint(message)
if (Grichelde_Debug) then
print(GRAY_FONT_COLOR_CODE .. "Grichelde:" .. FONT_COLOR_CODE_CLOSE .. " " .. message)
if (self.debug) then
self:Print(message)
end
end
function Grichelde:Print(message)
print(GRAY_FONT_COLOR_CODE .. self.L.AddonName .. FONT_COLOR_CODE_CLOSE .. ": " .. message)
end
function Grichelde:EmptyIfNil(value)
if value == nil then return "" end
return tostring(value)