Version 0.6.0
- honour capital/mixed cases for ignore case - consolidate consecutive matches - database upgrade capability - case sensitivity option reversed - removed obsolete WIM handling - skip empty mapping - Deletion of mapping
This commit is contained in:
@@ -1,17 +1,15 @@
|
||||
--[[---------------------------------------------------------------------------
|
||||
Grichelde
|
||||
|
||||
Grichelde - Text Replacer
|
||||
Copyright 2020 Teilzeit-Jedi <tj@teilzeit-jedi.de>
|
||||
|
||||
based on Misspelled developed by Nathan Pieper - nrpieper (@) gmail (dot) com
|
||||
This addon is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
This code freely distributed for your use in any GPL compliant project.
|
||||
See conditions in the LICENSE file attached.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the addon. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
-----------------------------------------------------------------------------]]
|
||||
|
||||
@@ -27,6 +25,7 @@ Grichelde.build = GetAddOnMetadata(AddonName, "X-Build") or "Experimental"
|
||||
Grichelde.hooks = {}
|
||||
Grichelde.classic = _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CLASSIC
|
||||
Grichelde.debug = false
|
||||
Grichelde.trace = false
|
||||
|
||||
-- publish to global env
|
||||
_G.Grichelde = Grichelde
|
||||
@@ -35,25 +34,21 @@ _G.Grichelde = Grichelde
|
||||
function Grichelde:OnInitialize()
|
||||
-- Build Interface Options window
|
||||
self.db = self:LoadDatabase()
|
||||
self:UpgradeDatabase()
|
||||
|
||||
self.options, self.dialog = self:SetupOptions()
|
||||
|
||||
-- load replacements from database
|
||||
self:RefreshOptions("OnProfileChanged")
|
||||
self:DebugPrint(self.db.profile)
|
||||
|
||||
self:SetupSlashCommands()
|
||||
|
||||
-- Watch for WIM and Prat to Load, then integrate
|
||||
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 (_G.Misspelled) then
|
||||
self:PrefixedPrint(self.L.Addon_Detected_Misspelled)
|
||||
end
|
||||
|
||||
-- tell the world we are listening
|
||||
self:Print(self.L.AddonLoaded, self.COLOR_CODES.PREFIX .. self.L.AddonName .. " " .. self.L.VersionAbbr .. self.version .. self.COLOR_CODES.CLOSE)
|
||||
end
|
||||
@@ -76,40 +71,4 @@ function Grichelde:SetupSlashCommands()
|
||||
|
||||
self:RegisterChatCommand("grichelde", HandleSlashCommand)
|
||||
self:RegisterChatCommand("gri", HandleSlashCommand)
|
||||
end
|
||||
|
||||
--- Hook into WIM to catch whisper sending event.
|
||||
-- @param event string
|
||||
-- @param addonName string
|
||||
function Grichelde:HookIntoForOtherChatAddons(event, addonName)
|
||||
if event == "ADDON_LOADED" then
|
||||
if addonName == "WIM" then
|
||||
_G.WIM.RegisterWidgetTrigger("msg_box", "whisper,chat,w2w", "OnEnterPressed", Grichelde.EditBox_OnEnterPressed)
|
||||
|
||||
-- If available use the WIM API
|
||||
if (_G.WIM.RegisterPreSendFilterText) then -- avoid error if WIM not up to date.
|
||||
_G.WIM.RegisterPreSendFilterText(function(text)
|
||||
return self:CheckAndReplace(text)
|
||||
end)
|
||||
else
|
||||
-- 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
|
||||
-- into ChatThrottleLib to be on the safe side.
|
||||
|
||||
if (_G.ChatThrottleLib) then
|
||||
self.hooks["ChatThrottleLib"] = _G.ChatThrottleLib.SendChatMessage
|
||||
|
||||
function _G.ChatThrottleLib:SendChatMessage(prio, prefix, text, ...)
|
||||
Grichelde:DebugPrint("ChatThrottleLib:SendChatMessage : Hook called")
|
||||
local replacedText = Grichelde:CheckAndReplace(text)
|
||||
return Grichelde.hooks["ChatThrottleLib"](_G.ChatThrottleLib, prio, prefix, replacedText, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (_G.WIM) then
|
||||
self:PrefixedPrint(self.L.Addon_Detected_WIM)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user