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:
107
GricheldeMinimap.lua
Normal file
107
GricheldeMinimap.lua
Normal file
@@ -0,0 +1,107 @@
|
||||
-- read namespace from global env
|
||||
local _G = _G
|
||||
local Grichelde = _G.Grichelde
|
||||
|
||||
--- add Minimap button
|
||||
function Grichelde:MinimapButton()
|
||||
local function clickHandler(_, button)
|
||||
if button == 'LeftButton' then
|
||||
self:ToggleOptions()
|
||||
elseif button == 'RightButton' then
|
||||
self:ToggleActivation()
|
||||
end
|
||||
end
|
||||
|
||||
local function updateTooltip(tooltip)
|
||||
if not tooltip or not tooltip.AddLine then return end
|
||||
|
||||
local tooltipTitle = self:Format(self.L.Minimap_Tooltip_Enabled, self.L.AddonName)
|
||||
if not self.db.profile.enabled then
|
||||
tooltipTitle = self:Format(self.L.Minimap_Tooltip_Disabled, self.L.AddonName)
|
||||
end
|
||||
|
||||
tooltip:SetText(tooltipTitle,
|
||||
Grichelde.COLORS.HIGHLIGHT.r, Grichelde.COLORS.HIGHLIGHT.g, Grichelde.COLORS.HIGHLIGHT.b, Grichelde.COLORS.HIGHLIGHT.a
|
||||
)
|
||||
|
||||
tooltip:AddDoubleLine(self.L.Minimap_Tooltip_Options_Left, self.L.Minimap_Tooltip_Options_Right,
|
||||
Grichelde.COLORS.GREEN.r, Grichelde.COLORS.GREEN.g, Grichelde.COLORS.GREEN.b, Grichelde.COLORS.GREEN.a,
|
||||
Grichelde.COLORS.NORMAL.r, Grichelde.COLORS.NORMAL.g, Grichelde.COLORS.NORMAL.b, Grichelde.COLORS.NORMAL.a
|
||||
)
|
||||
tooltip:AddDoubleLine(self.L.Minimap_Tooltip_Mappings_Left, self.L.Minimap_Tooltip_Mappings_Right,
|
||||
Grichelde.COLORS.GREEN.r, Grichelde.COLORS.GREEN.g, Grichelde.COLORS.GREEN.b, Grichelde.COLORS.GREEN.a,
|
||||
Grichelde.COLORS.NORMAL.r, Grichelde.COLORS.NORMAL.g, Grichelde.COLORS.NORMAL.b, Grichelde.COLORS.NORMAL.a
|
||||
)
|
||||
end
|
||||
|
||||
local darkened = Grichelde.MINIMAP_ENABLED
|
||||
if not self.db.profile.enabled then
|
||||
darkened = Grichelde.MINIMAP_DARKENDED
|
||||
end
|
||||
|
||||
local ldb = LibStub("LibDataBroker-1.1"):NewDataObject(self.name, {
|
||||
type = "launcher",
|
||||
text = self.AddonName,
|
||||
icon = "Interface\\Icons\\Spell_Holy_Silence",
|
||||
--icon = ([[Interface\Addons\%s\%s]]):format(self.name, self.name),
|
||||
OnClick = clickHandler,
|
||||
OnRightClick = function() self:ShowMappings() end,
|
||||
OnTooltipShow = updateTooltip,
|
||||
iconR = darkened,
|
||||
iconG = darkened,
|
||||
iconB = darkened
|
||||
})
|
||||
|
||||
local icon = LibStub("LibDBIcon-1.0")
|
||||
self:DebugPrint("MinimapButton : hidden: ", self.db.profile.minimapButton.hide)
|
||||
icon:Register(self.name, ldb, self.db.profile.minimapButton)
|
||||
|
||||
return ldb, icon
|
||||
end
|
||||
|
||||
function Grichelde:ToggleMinimapButton()
|
||||
self.db.profile.minimapButton.hide = not self.db.profile.minimapButton.hide
|
||||
self:DebugPrint("ToggleMinimapButton : hidden: ", self.db.profile.minimapButton.hide)
|
||||
|
||||
if self.db.profile.minimapButton.hide then
|
||||
self:HideMinimapButton()
|
||||
else
|
||||
self:ShowMinimapButton()
|
||||
end
|
||||
end
|
||||
|
||||
function Grichelde:ShowMinimapButton()
|
||||
if self.icon then
|
||||
self.icon:Show(self.name)
|
||||
end
|
||||
end
|
||||
|
||||
function Grichelde:HideMinimapButton()
|
||||
if self.icon then
|
||||
self.icon:Hide(self.name)
|
||||
end
|
||||
end
|
||||
|
||||
function Grichelde:ToggleActivation()
|
||||
self.db.profile.enabled = not self.db.profile.enabled
|
||||
-- refresh option UI if open at the moment
|
||||
self.dialog:SelectGroup(self.name, "enabled")
|
||||
|
||||
local formatString = self.L.AddonLoaded
|
||||
local darkened = Grichelde.MINIMAP_ENABLED
|
||||
if not self.db.profile.enabled then
|
||||
formatString = self.L.AddonUnloaded
|
||||
darkened = Grichelde.MINIMAP_DARKENDED
|
||||
end
|
||||
|
||||
if self.dialog ~= nil and self.dialog.OpenFrames[self.name] ~= nil then
|
||||
local namePlusVersion = self:Format(self.L.AddonNamePlusVersion, self.L.AddonName, self.version)
|
||||
local statusText = self:Format(formatString, namePlusVersion)
|
||||
self.dialog.OpenFrames[self.name]:SetStatusText(statusText)
|
||||
end
|
||||
|
||||
self.ldb.iconR = darkened
|
||||
self.ldb.iconG = darkened
|
||||
self.ldb.iconB = darkened
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user