@ -1,13 +1,11 @@
--[[--------------------------------------------------------------------------
--[[-------------------------------------------------------------------------- -
Grichelde
Grichelde
Copyright 2020 Teilzeit - Jedi < tj @ teilzeit - jedi.de >
Copyright 2020 Teilzeit - Jedi < tj @ teilzeit - jedi.de >
based on Misspelled developed by Nathan Pieper - nrpieper ( @ ) gmail ( dot ) com
based on Misspelled developed by Nathan Pieper - nrpieper ( @ ) gmail ( dot ) com
This code freely distributed for your use in any GPL compliant project .
This code freely distributed for your use in any GPL compliant project .
You may obtain a copy of the License at
See conditions in the LICENSE file attached .
http : // www.apache . org / licenses / LICENSE - 2.0
Unless required by applicable law or agreed to in writing , software
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an " AS IS " BASIS ,
distributed under the License is distributed on an " AS IS " BASIS ,
@ -17,107 +15,141 @@
--------------------------------------------------------------------------]] --
--------------------------------------------------------------------------]] --
local Grichelde = { }
local AddonName , AddonTable = ...
Grichelde = LibStub ( " AceAddon-3.0 " ) : NewAddon ( " Grichelde " , " AceEvent-3.0 " , " AceHook-3.0 " )
Grichelde.Version = " 0.1.0 "
local Grichelde = LibStub ( " AceAddon-3.0 " ) : NewAddon ( " Grichelde " , " AceEvent-3.0 " , " AceHook-3.0 " )
Grichelde.version = GetAddOnMetadata ( AddonName , " Version " )
Grichelde.build = GetAddOnMetadata ( AddonName , " X-Build " ) or " UNKNOWN "
local AceGUI = LibStub ( " AceGUI-3.0 " )
local L = LibStub ( " AceLocale-3.0 " ) : GetLocale ( " Grichelde " , true )
local L = LibStub ( " AceLocale-3.0 " ) : GetLocale ( " Grichelde " , true )
local Grichelde_Debug = false
-- faster function lookups by mapping to local refs
-- faster function lookups by mapping to local refs
local string_find = string.find
local string_find = string.find
local string_gsub = string.gsub
local string_gsub = string.gsub
local string_len = string.len
local string_len = string.len
local string_rep = string.rep
local string_rep = string.rep
local string_sub = string.sub
local string_sub = string.sub
local tostring = string.tostring
local tContains = tContains
local strtrim = strtrim
local strtrim = strtrim
local pairs = table.pairs
local strmatch = strmatch
local ipairs = table.ipairs
local tostring = tostring
local tInsert = table.insert
local tContains = tContains
local pairs = pairs
local ipairs = ipairs
local Grichelde_Saved_CTL_SendChatMessage
local Grichelde_Hooks = { }
local Grichelde_CTL_hookedversion = 0
local Grichelde_ChatTypes = { " SAY " , " EMOTE " , " YELL " , " PARTY " , " GUILD " , " OFFICER " , " RAID " , " RAID_WARNING " , " INSTANCE_CHAT " , " BATTLEGROUND " , " WHISPER " }
--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 " }
local Grichelde_ChatCommands = { " /s " , " /e " , " /me " , " /y " , " /p " , " /pl " , " /g " , " /o " , " /raid " , " /rl " , " /rw " , " /i " , " bg " , " /w " , " /r " , " /tt " }
-- do not replace these patterns
-- do not replace these patterns
local Grichelde_IgnorePatterns = {
local Grichelde_IgnorePatterns = {
" |[Cc]%x%x%x%x%x%x%x%x.-|r " , -- colored items (or links)
" |[Cc]%x%x%x%x%x%x%x%x.-|r " , -- colored items (or links)
" |H.-|h " , -- item links (http://www.wowwiki.com/ItemLink)
" |H.-|h " , -- item links (http://www.wowwiki.com/ItemLink)
" |T.-|t " , -- textures
" |T.-|t " , -- textures
" |n " , -- newline
" |n " , -- newline
" {rt[1-8]} " , -- rumbered raid target icons
" {rt[1-8]} " , -- rumbered raid target icons
" {Star} " , -- named raid target icon 1
" {Star} " , -- named raid target icon 1
" {Circle} " , -- named raid target icon 2
" {Circle} " , -- named raid target icon 2
" {Coin} " , -- named raid target icon 2
" {Coin} " , -- named raid target icon 2
" {Diamond} " , -- named raid target icon 3
" {Diamond} " , -- named raid target icon 3
" {Triangle} " , -- named raid target icon 4
" {Triangle} " , -- named raid target icon 4
" {Moon} " , -- named raid target icon 5
" {Moon} " , -- named raid target icon 5
" {Square} " , -- named raid target icon 6
" {Square} " , -- named raid target icon 6
" {Cross} " , -- named raid target icon 7
" {Cross} " , -- named raid target icon 7
" {X} " , -- named raid target icon 7
" {X} " , -- named raid target icon 7
" {Skull} " -- named raid target icon 8
" {Skull} " -- named raid target icon 8
}
}
function Grichelde : OnInitialize ( )
function Grichelde : OnInitialize ( )
-- print("Grichelde was loaded")
-- Build Interface Options window
-- Build Interface Options window
self : CreateInterfaceOptions ( )
--self:CreateInterfaceOptions()
-- Watch for WIM and Prat to Load, then integrate
-- Watch for WIM and Prat to Load, then integrate
Grichelde : RegisterEvent ( " ADDON_LOADED " )
self : RegisterEvent ( " ADDON_LOADED " , " HookIntoForOtherChatAddons " )
end
function Grichelde : OnEnable ( )
-- Hook in before message is sent to replace all character occurrences where replacements have been defined in the options
self : RawHook ( " SendChatMessage " , true )
if ( Misspelled ) then
print ( " Misspelled detected, Grichelde will have any messsage being cleansed " )
end
-- tell the world we are listening
print ( L.AddonLoaded )
end
-- hooks for removing any misspelled word highlighting in the text before the chat message is sent
function Grichelde : OnDisable ( )
-- The WoW client will disconnect if you attempt to send a color tags in a chat message.
self : Unhook ( " SendChatMessage " )
Grichelde : RawHook ( " SendChatMessage " , true )
end
end
--- @param event string
--- @param event string
--- @param addonName string
--- @param addonName string
function Grichelde : ADDON_LOADED ( event , addonName )
function Grichelde : HookIntoForOtherChatAddons ( event , addonName )
if event == " ADDON_LOADED " and addonName == " WIM " then
if event == " ADDON_LOADED " then
WIM.RegisterWidgetTrigger ( " msg_box " , " whisper,chat,w2w " , " OnEnterPressed " , Grichelde.EditBox_OnEnterPressed )
if addonName == " WIM " then
WIM.RegisterWidgetTrigger ( " msg_box " , " whisper,chat,w2w " , " OnEnterPressed " , Grichelde.EditBox_OnEnterPressed )
-- WIM sends its chat messages via the API ChatThrottleLib, which itself hooks the default SendChatMessage api
-- many times before Grichelde will. ChatThrottleLib might potentially load before Grichelde, so we just hook
-- If available use the WIM API
-- into ChatThrottleLib to be on the safe side.
if ( WIM.RegisterPreSendFilterText ) then -- avoid error if WIM not up to date.
WIM.RegisterPreSendFilterText ( function ( text )
if ( WIM.RegisterPreSendFilterText ) then -- avoid error if WIM not up to date.
return Grichelde : CheckAndReplace ( text )
WIM.RegisterPreSendFilterText ( function ( text )
end )
return Grichelde : ReplaceText ( text )
else
end )
-- WIM sends its chat messages via the API ChatThrottleLib, which itself hooks the default SendChatMessage api
else
-- many times before Grichelde will. ChatThrottleLib might potentially load before Grichelde, so we just hook
if ( ChatThrottleLib and Grichelde_CTL_hookedversion < ChatThrottleLib.version ) then
-- into ChatThrottleLib to be on the safe side.
Grichelde_Saved_CTL_SendChatMessage = ChatThrottleLib.SendChatMessage
if ( ChatThrottleLib ) then
function ChatThrottleLib : SendChatMessage ( prio , prefix , text , ... )
Grichelde_Hooks [ " ChatThrottleLib " ] = ChatThrottleLib.SendChatMessage
text = Grichelde : ReplaceText ( text )
-- print("Grichelde Hooked ChatThrottleLib_SendChatMessaged called")
function ChatThrottleLib : SendChatMessage ( prio , prefix , text , ... )
return Grichelde_Saved_CTL_SendChatMessage ( ChatThrottleLib , prio , prefix , text , ... )
Grichelde : DebugPrint ( " ChatThrottleLib:SendChatMessage : Hook called " )
local replacedText = Grichelde : CheckAndReplace ( text )
return Grichelde_Hooks [ " ChatThrottleLib " ] ( ChatThrottleLib , prio , prefix , replacedText , ... )
end
end
end
Grichelde_CTL_hookedversion = ChatThrottleLib.version
end
end
end
end
end
end
end
end
--- Before a chat message is sent, check if replacement is required and replace the text accordingly.
--- Before a f chat message is sent, check if replacement is required and replace the text accordingly.
--- @param message string
--- @param message string
--- @param type string
--- @param type string
--- @param language string
--- @param language string
--- @param channel string
--- @param channel string
function Grichelde : SendChatMessage ( message , type , language , channel , ... )
function Grichelde : SendChatMessage ( message , type , language , channel , ... )
local text = strtrim ( message )
local replacedText = self : CheckAndReplace ( message , type )
self : DebugPrint ( " SendChatMessage : replacedText: " .. replacedText )
-- Send text in chunks if length exceeds 255 bytes after replacement
local chunks = self : SplitText ( replacedText )
self : DebugPrint ( " SendChatMessage : #chunks: " .. # chunks )
if ( Grichelde : CheckReplacement ( message , type ) ) then
for _ , chunk in ipairs ( chunks ) do
text = Grichelde : ReplaceText ( text )
self.hooks[ " SendChatMessage " ] ( chunk , type , language , channel , ... ) ;
end
end
end
function Grichelde : CheckAndReplace ( message , type )
local text = message
if ( Misspelled ) then
self : DebugPrint ( " Misspelled detected: cleansing message " )
text = Misspelled : RemoveHighlighting ( text )
end
text = strtrim ( text )
self.hooks [ " SendChatMessage " ] ( text , type , language , channel , ... ) ;
if ( self : CheckReplacement ( text , type ) ) then
text = self : ReplaceText ( text )
end
return text
end
end
function Grichelde : CheckReplacement ( text , type )
function Grichelde : CheckReplacement ( text , type )
@ -125,20 +157,41 @@ function Grichelde:CheckReplacement(text, type)
-- check type
-- check type
if ( not tContains ( Grichelde_ChatTypes , type ) ) then
if ( not tContains ( Grichelde_ChatTypes , type ) ) then
self : DebugPrint ( " CheckReplacement : skip channel type " )
return false
return false
end
end
-- don't replace slash commands except chat related commands
-- don't replace slash commands except chat related commands
if string_sub ( text , 1 , 1 ) == " / " then
if string_sub ( text , 1 , 1 ) == " / " then
local firstWord , _ = Grichelde: GetNextWord ( text )
local firstWord , _ = self: SplitOnFirstMatch ( text )
if ( firstWord == nil or not tContains ( Grichelde_ChatCommands , firstWord ) ) then
if ( firstWord == nil or not tContains ( Grichelde_ChatCommands , firstWord ) ) then
self : DebugPrint ( " CheckReplacement : ignore slash command " )
return false
return false
end
end
end
end
-- in any other case
return true
return true
end
end
--- Checks if the text starts with a preversable ignore pattern, such as itemLinks, textures or raid target icons
--- and returns the end location of the match, or 0 if no pattern was found
--- @param text string
--- @return number
function Grichelde : CheckForPreversableText ( text )
self : DebugPrint ( " CheckForPreversableText : text is " .. text )
-- 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 )
if pos1 == 1 and pos2 ~= nil then
self : DebugPrint ( " CheckForPreversableText : Found ignore pattern " .. pattern .. " at ( " .. pos1 .. " , " .. pos2 .. " ) " )
return pos2
end
end
self : DebugPrint ( " CheckForPreversableText : no ignore pattern found " )
return 0
end
--- Replaces all character occurrences for which replacements have been defined in the options,
--- Replaces all character occurrences for which replacements have been defined in the options,
--- while preserving any itemLinks or textures. (http://www.wowwiki.com/ItemLink)
--- while preserving any itemLinks or textures. (http://www.wowwiki.com/ItemLink)
--- @param text string
--- @param text string
@ -148,8 +201,9 @@ function Grichelde:ReplaceText(text)
local newText = text
local newText = text
-- don't replace non-chat related slash commands
-- don't replace non-chat related slash commands
local firstWord , line = Grichelde : GetNextWord ( text )
local firstWord , line = self : SplitOnFirstMatch ( text )
if ( tContains ( Grichelde_ChatCommands , firstWord ) ) then
if ( firstWord ~= nil and tContains ( Grichelde_ChatCommands , firstWord ) ) then
self : DebugPrint ( " ReplaceText : Found slash command " .. ( firstWord + " " ) )
-- skip chat slash command
-- skip chat slash command
finalText = finalText .. firstWord .. ' '
finalText = finalText .. firstWord .. ' '
newText = line
newText = line
@ -158,22 +212,28 @@ function Grichelde:ReplaceText(text)
local current = 1
local current = 1
local lastStart = 1
local lastStart = 1
while current < string_len ( newText ) do
while current < = string_len ( newText ) do
local currentChar = string_sub ( newText , current , current )
local currentChar = string_sub ( newText , current , current )
self : DebugPrint ( " current/char : " .. current .. " , " .. currentChar )
if currentChar ~= ' | ' and currentChar ~= ' { ' then
if currentChar ~= ' | ' and currentChar ~= ' { ' then
current = current + 1
current = current + 1
else
else
-- lookahead-check for itemLinks, textures and raid target icons
-- lookahead-check for itemLinks, textures and raid target icons
local textAhead = string_sub ( newText , current )
local textAhead = string_sub ( newText , current )
local posEnd = Grichelde : CheckForPreversableText ( textAhead )
local posEnd = self : CheckForPreversableText ( textAhead )
if posEnd > 0 then
if posEnd > 0 then
self : DebugPrint ( " ReplaceText : Found an ignore pattern " )
local textBehind = string_sub ( newText , lastStart , current - 1 )
local textBehind = string_sub ( newText , lastStart , current - 1 )
local replacement = Grichelde : ReplaceCharacters ( textBehind )
local replacement = self : ReplaceCharacters ( textBehind )
local preservedText = string_sub ( textAhead , 1 , posEnd )
local preservedText = string_sub ( textAhead , 1 , posEnd )
finalText = finalText .. replacement .. preservedText
finalText = finalText .. replacement .. preservedText
current = current + posEnd
current = current + posEnd
lastStart = current
lastStart = current
self : DebugPrint ( " ReplaceText : restarting at " .. lastStart )
else
else
-- no corresponding end was found to start pattern, continue loop with next char
-- no corresponding end was found to start pattern, continue loop with next char
current = current + 1
current = current + 1
@ -181,29 +241,14 @@ function Grichelde:ReplaceText(text)
end
end
end
end
-- cleanup to the end
-- cleanup remaining text to the end
local remainingText = newText
local remainingText = string_sub ( newText , lastStart )
if lastStart ~= 1 then
local replacement = self : ReplaceCharacters ( remainingText )
remainingText = string_sub ( newText , lastStart )
end
local replacement = Grichelde : ReplaceCharacters ( remainingText )
finalText = finalText .. replacement
finalText = finalText .. replacement
return finalText
end
--- Checks if the text starts with a preversable ignore pattern, such as itemLinks, textures or raid target icons
self : DebugPrint ( " ReplaceText : replaced \" " .. text .. " \" " )
--- @param text string
self : DebugPrint ( " ReplaceText : with \" " .. finalText .. " \" " )
--- @return number
return finalText
function Grichelde : CheckForPreversableText ( text )
-- 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 )
if pos1 == 1 and pos2 ~= nil then
return pos2
end
end
return 0
end
end
--- Replaces all character occurrences for which replacements have been defined in the options
--- Replaces all character occurrences for which replacements have been defined in the options
@ -217,258 +262,82 @@ function Grichelde:ReplaceCharacters(text)
replacement = string_gsub ( replacement , " S " , " Ch " )
replacement = string_gsub ( replacement , " S " , " Ch " )
replacement = string_gsub ( replacement , " t " , " k " )
replacement = string_gsub ( replacement , " t " , " k " )
replacement = string_gsub ( replacement , " T " , " K " )
replacement = string_gsub ( replacement , " T " , " K " )
self : DebugPrint ( " ReplaceCharacters : replaced \" " .. text .. " \" with \" " .. replacement .. " \" " )
return replacement
return replacement
end
end
--- Splits a long text in longest possible chunks of <= 255 length, split at last available space
--[[ Interface Options Window ]] --
--- @param text string
function Grichelde : CreateInterfaceOptions ( )
--- @return table
local cfgFrame = CreateFrame ( " FRAME " , nil , UIParent )
function Grichelde : SplitText ( text )
cfgFrame.name = " Grichelde "
local chunks = { }
local splitText = text
local cfgFrameHeader = cfgFrame : CreateFontString ( " OVERLAY " , nil , " GameFontNormalLarge " )
local textSize = string_len ( splitText )
cfgFrameHeader : SetPoint ( " TOPLEFT " , 15 , - 15 )
cfgFrameHeader : SetText ( self.Version )
while textSize > 255 do
local chunk = string_sub ( splitText , 1 , 255 )
local cfgAutoSelectDict = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgAutoSelectDict " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
local remaining = " "
Misspelled_cfgAutoSelectDict : SetPoint ( " TOPLEFT " , 20 , - 40 )
Misspelled_cfgAutoSelectDictText : SetText ( L [ " Auto Select Dictionary to Load " ] )
-- special case: if space is the start of the next chunk, don't split this chunk
Misspelled_cfgAutoSelectDict : SetChecked ( Misspelled_DB.AutoSelectDictionary )
if string_sub ( splitText , 256 , 256 ) ~= ' ' then
Misspelled_cfgAutoSelectDict : SetScript ( " OnClick " , function ( self )
-- split at last space, don't assign directly as nil might be returned
if self : GetChecked ( ) then
local left , right = self : SplitOnLastMatch ( chunk )
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
if left ~= nil then
else
chunk = left
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end
if right ~= nil then
Misspelled_DB.AutoSelectDictionary = not Misspelled_DB.AutoSelectDictionary
remaining = right
--Toggle the sub options
if Misspelled_DB.AutoSelectDictionary == true then
Misspelled_cfgDictdeDE : Disable ( )
Misspelled_cfgDictenGB : Disable ( )
Misspelled_cfgDictenUS : Disable ( )
Misspelled_cfgDictesES : Disable ( )
Misspelled_cfgDictfrFR : Disable ( )
Misspelled_cfgDictruRU : Disable ( )
Misspelled_cfgDictitIT : Disable ( )
else
Misspelled_cfgDictdeDE : Enable ( )
Misspelled_cfgDictenGB : Enable ( )
Misspelled_cfgDictenUS : Enable ( )
Misspelled_cfgDictesES : Enable ( )
Misspelled_cfgDictfrFR : Enable ( )
Misspelled_cfgDictruRU : Enable ( )
Misspelled_cfgDictitIT : Enable ( )
if Misspelled_DB.LoadDictionary == nil or # Misspelled_DB.LoadDictionary == 0 then
Misspelled_DB.LoadDictionary = " enUS "
Misspelled_cfgDictenUS : setChecked ( true )
end
end
end
end
end )
local cfgDictdeDE = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictdeDE " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictdeDE : SetPoint ( " TOPLEFT " , 40 , - 64 )
Misspelled_cfgDictdeDEText : SetText ( " deDE " )
Misspelled_cfgDictdeDE : SetChecked ( Misspelled_DB.LoadDictionary == " deDE " )
Misspelled_cfgDictdeDE : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " deDE "
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
local cfgDictenGB = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictenGB " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictenGB : SetPoint ( " TOPLEFT " , 40 , - 88 )
Misspelled_cfgDictenGBText : SetText ( " enGB " )
Misspelled_cfgDictenGB : SetChecked ( Misspelled_DB.LoadDictionary == " enGB " )
Misspelled_cfgDictenGB : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " enGB "
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
local cfgDictenUS = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictenUS " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictenUS : SetPoint ( " TOPLEFT " , 40 , - 112 )
Misspelled_cfgDictenUSText : SetText ( " enUS " )
Misspelled_cfgDictenUS : SetChecked ( Misspelled_DB.LoadDictionary == " enUS " )
Misspelled_cfgDictenUS : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " enUS "
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
local cfgDictesES = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictesES " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictesES : SetPoint ( " TOPLEFT " , 40 , - 136 )
Misspelled_cfgDictesESText : SetText ( " esES " )
Misspelled_cfgDictesES : SetChecked ( Misspelled_DB.LoadDictionary == " esES " )
Misspelled_cfgDictesES : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " esES "
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
local cfgDictfrFR = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictfrFR " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictfrFR : SetPoint ( " TOPLEFT " , 40 , - 160 )
Misspelled_cfgDictfrFRText : SetText ( " frFR " )
Misspelled_cfgDictfrFR : SetChecked ( Misspelled_DB.LoadDictionary == " frFR " )
Misspelled_cfgDictfrFR : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " frFR "
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
local cfgDictruRU = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictruRU " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictruRU : SetPoint ( " TOPLEFT " , 40 , - 184 )
Misspelled_cfgDictruRUText : SetText ( " ruRU " )
Misspelled_cfgDictruRU : SetChecked ( Misspelled_DB.LoadDictionary == " ruRU " )
Misspelled_cfgDictruRU : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " ruRU "
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
local cfgDictitIT = CreateFrame ( " CHECKBUTTON " , " Misspelled_cfgDictitIT " , cfgFrame , " InterfaceOptionsCheckButtonTemplate " )
Misspelled_cfgDictitIT : SetPoint ( " TOPLEFT " , 40 , - 208 )
Misspelled_cfgDictitITText : SetText ( " itIT " )
Misspelled_cfgDictitIT : SetChecked ( Misspelled_DB.LoadDictionary == " itIT " )
Misspelled_cfgDictitIT : SetScript ( " OnClick " , function ( self )
if self : GetChecked ( ) then
PlaySound ( 856 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
Misspelled_DB.LoadDictionary = " itIT "
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
else
PlaySound ( 857 ) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end )
--Edit User Dictionary Button
local cfgEditUserDict = CreateFrame ( " Button " , " EdutUserDictButton " , cfgFrame , " UIPanelButtonTemplate " )
cfgEditUserDict : SetPoint ( " TOPLEFT " , 20 , - 287 )
cfgEditUserDict : SetText ( L [ " Edit User Dictionary... " ] )
cfgEditUserDict : SetWidth ( 200 )
cfgEditUserDict : SetHeight ( 24 )
cfgEditUserDict : SetScript ( " OnClick " , function ( self )
--PlaySound("igMainMenuOptionCheckBoxOn")
Misspelled : EditUserDict ( )
end )
--set options on startup
Misspelled_cfgDictdeDE : SetChecked ( false )
Misspelled_cfgDictenUS : SetChecked ( false )
Misspelled_cfgDictenGB : SetChecked ( false )
Misspelled_cfgDictesES : SetChecked ( false )
Misspelled_cfgDictfrFR : SetChecked ( false )
Misspelled_cfgDictruRU : SetChecked ( false )
Misspelled_cfgDictitIT : SetChecked ( false )
if Misspelled_DB.LoadDictionary == " deDE " then
Misspelled_cfgDictdeDE : SetChecked ( true )
elseif Misspelled_DB.LoadDictionary == " enGB " then
Misspelled_cfgDictenGB : SetChecked ( true )
elseif Misspelled_DB.LoadDictionary == " enUS " then
Misspelled_cfgDictenUS : SetChecked ( true )
elseif Misspelled_DB.LoadDictionary == " esES " then
Misspelled_cfgDictesES : SetChecked ( true )
elseif Misspelled_DB.LoadDictionary == " frFR " then
Misspelled_cfgDictfrFR : SetChecked ( true )
elseif Misspelled_DB.LoadDictionary == " ruRU " then
Misspelled_cfgDictruRU : SetChecked ( true )
elseif Misspelled_DB.LoadDictionary == " itIT " then
Misspelled_cfgDictitIT : SetChecked ( true )
end
if Misspelled_DB.AutoSelectDictionary == true then
self : DebugPrint ( " SplitText : chunk: " .. chunk )
Misspelled_cfgDictdeDE : Disable ( )
Misspelled_cfgDictenGB : Disable ( )
tInsert ( chunks , chunk )
Misspelled_cfgDictenUS : Disable ( )
splitText = remaining .. string_sub ( splitText , 256 )
Misspelled_cfgDictesES : Disable ( )
textSize = string_len ( splitText )
Misspelled_cfgDictfrFR : Disable ( )
Misspelled_cfgDictruRU : Disable ( )
Misspelled_cfgDictitIT : Disable ( )
else
Misspelled_cfgDictdeDE : Enable ( )
Misspelled_cfgDictenGB : Enable ( )
Misspelled_cfgDictenUS : Enable ( )
Misspelled_cfgDictesES : Enable ( )
Misspelled_cfgDictfrFR : Enable ( )
Misspelled_cfgDictruRU : Enable ( )
Misspelled_cfgDictitIT : Enable ( )
end
end
InterfaceOptions_AddCategory ( cfgFrame )
-- pickup remaining text < 255
end
self : DebugPrint ( " SplitText : last chunk: " .. splitText )
tInsert ( chunks , splitText )
return chunks
end
-- split first word of a text line
-- split first word of a text line
function Grichelde : GetNextWord ( line )
function Grichelde : SplitOnFirstMatch ( text , start )
-- need to add a trailing separator to catch the last value.
self : DebugPrint ( " SplitOnFirstMatch : text: " .. text .. " , start: " .. self : EmptyIfNil ( start ) )
local wordPattern = " [%s%c]*(%w+)[%s%c]* "
local pos = 1
local s , e = string_find ( line , wordPattern )
if start ~= nil then pos = start end
local word = string_sub ( line , s , e )
local left , right = strmatch ( text , " ^.- .+ " , pos )
local rest = string_sub ( line , e )
self : DebugPrint ( " SplitOnFirstMatch : left: " .. self : EmptyIfNil ( left ) .. " , right: " .. self : EmptyIfNil ( right ) )
return word , rest
return left , right
end
function Grichelde : SplitOnLastMatch ( text , start )
self : DebugPrint ( " SplitOnLastMatch : text: " .. text .. " , start: " .. self : EmptyIfNil ( start ) )
local pos = 1
if start ~= nil then pos = start end
local left , right = strmatch ( text , " .+ .-$ " , pos )
self : DebugPrint ( " SplitOnLastMatch : left: " .. self : EmptyIfNil ( left ) .. " , right: " .. self : EmptyIfNil ( right ) )
return left , right
end
function Grichelde : DebugPrint ( message )
if ( Grichelde_Debug ) then
print ( GRAY_FONT_COLOR_CODE .. " Grichelde: " .. FONT_COLOR_CODE_CLOSE .. " " .. message )
end
end
function Grichelde : EmptyIfNil ( value )
if value == nil then return " " end
return tostring ( value )
end
end
function Grichelde : tprint ( t , indent , done )
function Grichelde : tprint ( t , indent , done )
-- in case we run it standalone
-- in case we run it standalone
local Note = Note or print
local Note = Note or print
-- local Tell = Tell or io.write
-- show strings differently to distinguish them from numbers
-- show strings differently to distinguish them from numbers
local function show ( val )
local function show ( val )
@ -487,14 +356,10 @@ function Grichelde:tprint(t, indent, done)
if type ( value ) == " table " and not done [ value ] then
if type ( value ) == " table " and not done [ value ] then
done [ value ] = true
done [ value ] = true
Note ( show ( key ) , " : " ) ;
Note ( show ( key ) , " : " ) ;
Grichelde : tprint ( value , indent + 2 , done )
self : tprint ( value , indent + 2 , done )
else
else
print ( show ( key ) , " = " )
print ( show ( key ) , " = " )
print ( show ( value ) )
print ( show ( value ) )
end
end
end
end
end
end
function Grichelde : print ( ... )
SELECTED_DOCK_FRAME : AddMessage ( ... )
end