From 6669241115a6b8cc88f95d6e77f049151020f46f Mon Sep 17 00:00:00 2001 From: Darthpred Date: Wed, 20 Aug 2014 07:23:57 +0400 Subject: [PATCH] Hide minimap in combat --- ElvUI_SLE/defaults/profile.lua | 1 + ElvUI_SLE/modules/minimap/minimapcoords.lua | 24 ++++++++++++++++++++++ ElvUI_SLE/options/minimap_c.lua | 29 ++++++++++++++++++--------- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua index e9c3f1d..7dbc92a 100644 --- a/ElvUI_SLE/defaults/profile.lua +++ b/ElvUI_SLE/defaults/profile.lua @@ -315,6 +315,7 @@ P['sle'] = { --Minimap Module ['minimap'] = { ['enable'] = false, + ['combat'] = false, ['coords'] = { ['display'] = "SHOW", ['middle'] = "CORNERS", diff --git a/ElvUI_SLE/modules/minimap/minimapcoords.lua b/ElvUI_SLE/modules/minimap/minimapcoords.lua index 65b13f8..373ea44 100644 --- a/ElvUI_SLE/modules/minimap/minimapcoords.lua +++ b/ElvUI_SLE/modules/minimap/minimapcoords.lua @@ -6,6 +6,18 @@ local framescreated = false local panel, xpos, ypos local middle +local cluster = _G['MinimapCluster'] + +local function HideMinimap() + cluster:Hide() +end + +local function ShowMinimap() + if not InCombatLockdown() then + UIFrameFadeIn(cluster, 0.2, cluster:GetAlpha(), 1) + end +end + local function UpdateCoords(self, elapsed) panel.elapsed = (panel.elapsed or 0) + elapsed if panel.elapsed < .1 then return end @@ -17,6 +29,16 @@ local function UpdateCoords(self, elapsed) panel.elapsed = 0 end +function M:SLEHideMinimap() + if E.db.sle.minimap.combat then + M:RegisterEvent("PLAYER_REGEN_DISABLED", HideMinimap) + M:RegisterEvent("PLAYER_REGEN_ENABLED", ShowMinimap) + else + M:UnregisterEvent("PLAYER_REGEN_DISABLED") + M:UnregisterEvent("PLAYER_REGEN_ENABLED") + end +end + local function UpdatePosition(middle) xpos:ClearAllPoints() ypos:ClearAllPoints() @@ -84,4 +106,6 @@ function M:UpdateSettings() else panel:Show() end + + M:SLEHideMinimap() end \ No newline at end of file diff --git a/ElvUI_SLE/options/minimap_c.lua b/ElvUI_SLE/options/minimap_c.lua index 77e75b8..f327182 100644 --- a/ElvUI_SLE/options/minimap_c.lua +++ b/ElvUI_SLE/options/minimap_c.lua @@ -16,7 +16,15 @@ local function configTable() type = 'description', name = L['MINIMAP_DESC'], }, - + mapiconsenable = { + type = "toggle", + name = L['Hide in Combat'], + order = 3, + desc = L['Hide minimap in combat.'], + disabled = false, + get = function(info) return E.db.sle.minimap.combat end, + set = function(info, value) E.db.sle.minimap.combat = value; E:GetModule('Minimap'):SLEHideMinimap() end, + }, coords = { type = "group", name = L["Minimap Coordinates"], @@ -59,21 +67,22 @@ local function configTable() }, }, }, - mapiconsenable = { - type = "toggle", - name = L['Enable'], - order = 5, - desc = L['Enable/Disable Square Minimap Buttons.'], - get = function(info) return E.private.sle.minimap.mapicons.enable end, - set = function(info, value) E.private.sle.minimap.mapicons.enable = value; E:StaticPopup_Show("PRIVATE_RL") end, - }, mapicons = { type = "group", name = L["Minimap Buttons"], - order = 6, + order = 5, guiInline = true, disabled = function() return not E.private.sle.minimap.mapicons.enable end, args = { + mapiconsenable = { + type = "toggle", + name = L['Enable'], + order = 1, + desc = L['Enable/Disable Square Minimap Buttons.'], + disabled = false, + get = function(info) return E.private.sle.minimap.mapicons.enable end, + set = function(info, value) E.private.sle.minimap.mapicons.enable = value; E:StaticPopup_Show("PRIVATE_RL") end, + }, barenable = { order = 2, type = "toggle", -- 1.7.9.5