Fix hide/show when going into menus

Scott Yeskie [07-03-16 - 03:57]
Fix hide/show when going into menus
Filename
RaidDPS.lua
diff --git a/RaidDPS.lua b/RaidDPS.lua
index 5ddeb99..99678db 100644
--- a/RaidDPS.lua
+++ b/RaidDPS.lua
@@ -15,8 +15,6 @@
 -- You should have received a copy of the GNU General Public License
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.

--- TODO: Fix window display/hide
--- TODO: Add icons
 -- TODO: Fix bosses removed > 0hp
 -- TODO: Clear on player activate?

@@ -226,25 +224,25 @@ function RaidDPS:CreateUI()
     ui.bg:SetCenterColor(0, 0, 0, 0.3)
     ui.bg:SetEdgeColor(0, 0, 0, 0)

-    ui.txtFullDps = WINDOW_MANAGER:CreateControl("RaidDPS_UI_dpsFull", ui.main, CT_LABEL)
-    ui.txtDps10 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_dps10", ui.main, CT_LABEL)
-    ui.txtTime = WINDOW_MANAGER:CreateControl("RaidDPS_UI_time", ui.main, CT_LABEL)
-    ui.txtTime10 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_time10", ui.main, CT_LABEL)
+    ui.txtFullDps = WINDOW_MANAGER:CreateControl("RaidDPS_UI_dpsFull", ui.bg, CT_LABEL)
+    ui.txtDps10 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_dps10", ui.bg, CT_LABEL)
+    ui.txtTime = WINDOW_MANAGER:CreateControl("RaidDPS_UI_time", ui.bg, CT_LABEL)
+    ui.txtTime10 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_time10", ui.bg, CT_LABEL)
     ui.txtDps10:SetFont(font)
     ui.txtFullDps:SetFont(font)
     ui.txtTime:SetFont(font)
     ui.txtTime10:SetFont(font)
     --
-    ui.imgTimer1 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_clock1", ui.main, CT_TEXTURE)
+    ui.imgTimer1 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_clock1", ui.bg, CT_TEXTURE)
     ui.imgTimer1:SetTexture("/esoui/art/miscellaneous/timer_32.dds")
     ui.imgTimer1:SetDimensions(16, 16)
-    ui.imgTimer2 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_clock2", ui.main, CT_TEXTURE)
+    ui.imgTimer2 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_clock2", ui.bg, CT_TEXTURE)
     ui.imgTimer2:SetTexture("/esoui/art/miscellaneous/timer_32.dds")
     ui.imgTimer2:SetDimensions(16, 16)
-    ui.imgFull = WINDOW_MANAGER:CreateControl("RaidDPS_UI_iconFull", ui.main, CT_TEXTURE)
+    ui.imgFull = WINDOW_MANAGER:CreateControl("RaidDPS_UI_iconFull", ui.bg, CT_TEXTURE)
     ui.imgFull:SetTexture("/esoui/art/trials/trialpoints_high.dds")
     ui.imgFull:SetDimensions(20, 20)
-    ui.img10 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_icon10", ui.main, CT_TEXTURE)
+    ui.img10 = WINDOW_MANAGER:CreateControl("RaidDPS_UI_icon10", ui.bg, CT_TEXTURE)
     ui.img10:SetTexture("/esoui/art/trials/trialpoints_low.dds")
     ui.img10:SetDimensions(20, 20)

@@ -268,8 +266,14 @@ function RaidDPS:CreateUI()
     ui.txtDps10:SetText("0")
     ui.txtTime:SetText("0:00")
     ui.txtTime10:SetText(":10")
-    --ui.main:SetHidden(true)
+    ui.main:SetHidden(true)
     ui.main:UnregisterForEvent(EVENT_PLAYER_ACTIVATED)
+    ui.main:RegisterForEvent(EVENT_ACTION_LAYER_POPPED, function(_,_,indx) self:ActionLayerChange(indx) end)
+    ui.main:RegisterForEvent(EVENT_ACTION_LAYER_PUSHED, function(_,_,indx) self:ActionLayerChange(indx) end)
+end
+
+function RaidDPS:ActionLayerChange(activeLayerIndex)
+    self.ui.bg:SetHidden(activeLayerIndex > 2)
 end

 function RaidDPS:SaveUIPosition( window )