Version 0.8.0-beta
- handle replacement via slash command - emote and ooc detection - de-/activate single mappings - move buttons and mappings are disabled when already at top/bottom or deactivated - minimap button is darkened when addon is disabled - help tab with examples - right-click on minimap button quickly de-/activates replacements - fixed mapping to raid warning, instance and battleground chats - localized raid target markers - capital % substitutions - incorrect consolidation - Umlaut and accent replacements
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
--[[---------------------------------------------------------------------------
|
||||
|
||||
Grichelde - Text Replacer
|
||||
|
||||
Copyright 2020 Teilzeit-Jedi <tj@teilzeit-jedi.de>
|
||||
|
||||
This addon is distributed in the hope that it will be useful,
|
||||
@@ -19,39 +20,46 @@ local _G = _G
|
||||
|
||||
-- initialize addon
|
||||
local Grichelde = LibStub("AceAddon-3.0"):NewAddon(AddonTable, 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 "Experimental"
|
||||
Grichelde.classic = _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CLASSIC
|
||||
Grichelde.logLevel = 0 -- cannot reference Grichelde.LOG_LEVELs here as they are loaded afterwards
|
||||
|
||||
-- publish to global env
|
||||
_G.Grichelde = Grichelde
|
||||
_G[AddonName] = Grichelde
|
||||
|
||||
-- Ace3 callbacks
|
||||
function Grichelde:OnInitialize()
|
||||
self.L = LibStub("AceLocale-3.0"):GetLocale(self.name, true)
|
||||
|
||||
-- Build Interface Options window
|
||||
self.db = self:LoadDatabase()
|
||||
self:UpgradeDatabase()
|
||||
|
||||
self.options, self.dialog = self:SetupOptions()
|
||||
self:RefreshOptions("OnProfileChanged")
|
||||
|
||||
self.ldb, self.icon = self:MinimapButton()
|
||||
|
||||
self:SetupSlashCommands()
|
||||
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)
|
||||
|
||||
self.options, self.dialog = self:SetupOptions()
|
||||
self:RefreshOptions("OnProfileChanged")
|
||||
|
||||
self.ldb, self.icon = self:MinimapButton()
|
||||
self:SetupSlashCommands()
|
||||
|
||||
-- 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)
|
||||
if self.db.profile.enabled then
|
||||
local namePlusVersion = self:Format(self.L.AddonNamePlusVersion, self.L.AddonName, self.version)
|
||||
self:Print(self.L.AddonLoaded, self.COLOR_CODES.PREFIX .. namePlusVersion .. self.COLOR_CODES.CLOSE)
|
||||
end
|
||||
end
|
||||
|
||||
function Grichelde:OnDisable()
|
||||
self:Unhook("SendChatMessage")
|
||||
self:CloseOptions()
|
||||
self:HideMinimapButton()
|
||||
self:UnregisterChatCommand("grichelde")
|
||||
self:UnregisterChatCommand("gri")
|
||||
end
|
||||
|
||||
--- Register slash commands 'gri' and 'grichelde'
|
||||
@@ -60,19 +68,21 @@ function Grichelde:SetupSlashCommands()
|
||||
self:RegisterChatCommand("gri", "HandleSlashCommand")
|
||||
end
|
||||
|
||||
function Grichelde:HandleSlashCommand(input)
|
||||
function Grichelde:HandleSlashCommand(input, ...)
|
||||
-- Show the GUI if no input is supplied, otherwise handle the chat input.
|
||||
if self.functions.nilOrEmpty(input) then
|
||||
self:OpenOptions()
|
||||
self:ToggleOptions()
|
||||
else
|
||||
-- handle slash ourselves
|
||||
self:DebugPrint("Handle slash command: " .. input)
|
||||
if input == "mappings" then
|
||||
self:ToogleMappings()
|
||||
elseif input == "options" then
|
||||
self:PrintOptions()
|
||||
self:ToggleOptions()
|
||||
elseif input == "profile" then
|
||||
self:PrintProfile()
|
||||
else
|
||||
self:SendChatMessageOverride(input, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user