Version 1.6.1 (11-03-2018)

Jarth [03-11-18 - 10:04]
Version 1.6.1 (11-03-2018)
Filename
MementoBar.txt
MementoBar_Constants.lua
MementoBar_Fragments.lua
MementoBar_Menu.lua
MementoBar_Move.lua
diff --git a/MementoBar.txt b/MementoBar.txt
index 3892643..d3a1dfb 100644
--- a/MementoBar.txt
+++ b/MementoBar.txt
@@ -6,7 +6,7 @@

 ## APIVersion: 100022
 ## Title: Memento Bar
-## Version: 1.6.0
+## Version: 1.6.1
 ## Author: Jarth
 ## Description: Show a hotbar with selected memento's. Activate by button press!
 ##
diff --git a/MementoBar_Constants.lua b/MementoBar_Constants.lua
index 3e2c873..21a9c64 100644
--- a/MementoBar_Constants.lua
+++ b/MementoBar_Constants.lua
@@ -12,7 +12,7 @@ MementoBar.Addon = {
     Name = "MementoBar",
     DisplayName = "Memento bar",
     Version = 1.6,
-    MinorVersion = 0,
+    MinorVersion = 1,
     SlashCommand = "/mb",
     Author = "Jarth",
     Website = ""
@@ -29,9 +29,11 @@ MementoBar.Default = {
     FontColor = {r = 0.9, g = 0.9, b = 0.9, a = 0.9},
     UseAccountSettings = true,
     Horizontal = true,
-    ShowBarInMenu = false,
     ShowBarOnHud = true,
     ShowBarOnHudUI = true,
+    ShowBarInMenu = false,
+    ShowBarInStore = false,
+    ShowBarInInventory = false,
     Margin = 2,
     Height = 60,
     Width = 60,
diff --git a/MementoBar_Fragments.lua b/MementoBar_Fragments.lua
index befc98b..f9f5312 100644
--- a/MementoBar_Fragments.lua
+++ b/MementoBar_Fragments.lua
@@ -9,6 +9,23 @@ Filename: MementoBar_Fragments.lua
 local MementoBar = MementoBar

 -------------------------------------------------------------------------------------------------
+-- Helper FUNCTIONS --
+-------------------------------------------------------------------------------------------------
+function MementoBar:HelperSetFragmentBehaviour(value, scene, fragment, statement, frameIsHidden)
+    if value then
+        scene:AddFragment(fragment)
+
+        -- Case when landing on a scene, before a transition
+        if statement then
+            frameIsHidden = false
+        end
+    else
+        scene:RemoveFragment(fragment)
+    end
+    return frameIsHidden
+end
+
+-------------------------------------------------------------------------------------------------
 -- PRIVATE FUNCTIONS --
 -------------------------------------------------------------------------------------------------
 function MementoBar:SetFragmentBehaviour()
@@ -24,33 +41,18 @@ function MementoBar:SetFragmentBehaviour()
         fragment = base.Fragment
     end

-    if saved.ShowBarInMenu then
-        SCENE_MANAGER:GetScene("gameMenuInGame"):AddFragment(fragment)
-
-        -- Case where the user changes visibility in the settings
-        if currentScene ~= nil and currentScene:GetName() == "gameMenuInGame" then
-            frameIsHidden = false
-        end
-    else
-        SCENE_MANAGER:GetScene("gameMenuInGame"):RemoveFragment(fragment)
-    end
-
-    if saved.ShowBarOnHud then
-        HUD_SCENE:AddFragment(fragment)
-
-        -- Case when landing on a scene, before a transition
-        if currentScene == nil then
-            frameIsHidden = false
-        end
-    else
-        HUD_SCENE:RemoveFragment(fragment)
-    end
-
-    if saved.ShowBarOnHudUI then
-        HUD_UI_SCENE:AddFragment(fragment)
-    else
-        HUD_UI_SCENE:RemoveFragment(fragment)
-    end
+    frameIsHidden = MementoBar:HelperSetFragmentBehaviour(saved.ShowBarOnHud, HUD_SCENE, fragment, currentScene == nil, frameIsHidden)
+    frameIsHidden = MementoBar:HelperSetFragmentBehaviour(saved.ShowBarOnHudUI, HUD_UI_SCENE, fragment, false, frameIsHidden)
+    frameIsHidden =
+        MementoBar:HelperSetFragmentBehaviour(
+        saved.ShowBarInMenu,
+        SCENE_MANAGER:GetScene("gameMenuInGame"),
+        fragment,
+        currentScene ~= nil and currentScene:GetName() == "gameMenuInGame",
+        frameIsHidden
+    )
+    frameIsHidden = MementoBar:HelperSetFragmentBehaviour(saved.ShowBarInStore, SCENE_MANAGER:GetScene("store"), fragment, false, frameIsHidden)
+    frameIsHidden = MementoBar:HelperSetFragmentBehaviour(saved.ShowBarInInventory, SCENE_MANAGER:GetScene("inventory"), fragment, false, frameIsHidden)

     frame:SetHidden(frameIsHidden)
 end
diff --git a/MementoBar_Menu.lua b/MementoBar_Menu.lua
index 9270ec8..91891d5 100644
--- a/MementoBar_Menu.lua
+++ b/MementoBar_Menu.lua
@@ -354,7 +354,7 @@ function MementoBar:CreateSettingsWindow()
                 [4] = {
                     type = "dropdown",
                     name = "Cooldown font",
-                    tooltip = "Select the cooldown font.",
+                    tooltip = "Select the " .. "cooldown font.",
                     choices = MementoBar.Global.TimerFonts,
                     disabled = function()
                         return not MementoBar.Saved.IsTimerEnabled
@@ -385,8 +385,34 @@ function MementoBar:CreateSettingsWindow()
             controls = {
                 [1] = {
                     type = "checkbox",
-                    name = "Show bar in menu",
-                    tooltip = "When ON the bar will show when a menu is opened.",
+                    name = "Show bar " .. "on main view/hud",
+                    tooltip = "When ON the bar will show the bar " .. "on main view/hud",
+                    default = MementoBar.Default.ShowBarOnHud,
+                    getFunc = function()
+                        return MementoBar.Saved.ShowBarOnHud
+                    end,
+                    setFunc = function(newValue)
+                        MementoBar.Saved.ShowBarOnHud = newValue
+                        MementoBar:SetFragmentBehaviour()
+                    end
+                },
+                [2] = {
+                    type = "checkbox",
+                    name = "Show bar " .. "on the main view when an overlay is activated/hudui",
+                    tooltip = "When ON the bar will show the bar " .. "on the main view when an overlay is activated/hudui",
+                    default = MementoBar.Default.ShowBarOnHudUI,
+                    getFunc = function()
+                        return MementoBar.Saved.ShowBarOnHudUI
+                    end,
+                    setFunc = function(newValue)
+                        MementoBar.Saved.ShowBarOnHudUI = newValue
+                        MementoBar:SetFragmentBehaviour()
+                    end
+                },
+                [3] = {
+                    type = "checkbox",
+                    name = "Show bar " .. "in menu",
+                    tooltip = "When ON the bar will show the bar " .. "in menu",
                     default = MementoBar.Default.ShowBarInMenu,
                     getFunc = function()
                         return MementoBar.Saved.ShowBarInMenu
@@ -396,29 +422,29 @@ function MementoBar:CreateSettingsWindow()
                         MementoBar:SetFragmentBehaviour()
                     end
                 },
-                [2] = {
+                [4] = {
                     type = "checkbox",
-                    name = "Show bar on hud",
-                    tooltip = "When ON the bar will show the bar on the hud.",
-                    default = MementoBar.Default.ShowBarOnHud,
+                    name = "Show bar " .. "in the inventory",
+                    tooltip = "When ON the bar will show the bar " .. "in the inventory",
+                    default = MementoBar.Default.ShowBarInInventory,
                     getFunc = function()
-                        return MementoBar.Saved.ShowBarOnHud
+                        return MementoBar.Saved.ShowBarInInventory
                     end,
                     setFunc = function(newValue)
-                        MementoBar.Saved.ShowBarOnHud = newValue
+                        MementoBar.Saved.ShowBarInInventory = newValue
                         MementoBar:SetFragmentBehaviour()
                     end
                 },
-                [3] = {
+                [5] = {
                     type = "checkbox",
-                    name = "Show bar in hudui",
-                    tooltip = "When ON the bar will show the bar on the hudui.",
-                    default = MementoBar.Default.ShowBarOnHudUI,
+                    name = "Show bar " .. "in a store",
+                    tooltip = "When ON the bar will show the bar " .. "in a store",
+                    default = MementoBar.Default.ShowBarInStore,
                     getFunc = function()
-                        return MementoBar.Saved.ShowBarOnHudUI
+                        return MementoBar.Saved.ShowBarInStore
                     end,
                     setFunc = function(newValue)
-                        MementoBar.Saved.ShowBarOnHudUI = newValue
+                        MementoBar.Saved.ShowBarInStore = newValue
                         MementoBar:SetFragmentBehaviour()
                     end
                 }
diff --git a/MementoBar_Move.lua b/MementoBar_Move.lua
index 5f33bf3..3bcef52 100644
--- a/MementoBar_Move.lua
+++ b/MementoBar_Move.lua
@@ -15,7 +15,7 @@ local MementoBar = MementoBar
 function MementoBar:UpdateMoveFrame()
     local moveFrame = MementoBar.MoveFrame
     local onMouseEnter, onMouseExit, onMouseDown, onMouseUp = nil, nil, nil, nil
-
+
     if MementoBar.Global.IsMoveEnabled then
         moveFrame = MementoBar:GetOrCreateMoveFrame()
         onMouseEnter = MementoBar.MoveFrameOnEnter
@@ -47,7 +47,7 @@ function MementoBar:GetOrCreateMoveFrame(show)
     if MementoBar.MoveFrame == nil then
         local newMoveFrame = MementoBar.WM:CreateControlFromVirtual(nil, GuiRoot, "MementoBar_MoveFrame")
         local targetFrame = MementoBar_Frame
-
+
         --Variable is used to define what savedVariable the Frame refers to.
         newMoveFrame.TargetFrame = targetFrame

@@ -117,9 +117,9 @@ end

 function MementoBar.MoveFrameUpdateText(frame, position)
     local labelTextTopLeft = ""
-
+
     frame.labelCenter:SetText(string.format("%s,%s", frame:GetWidth(), frame:GetHeight()))
-
+
     if (position) then
         labelTextTopLeft = string.format("%s,%s", frame.TargetFrame:GetLeft(), frame.TargetFrame:GetTop())
     end
@@ -146,7 +146,7 @@ function MementoBar.MoveFrameUpdateColor(frame)
     local centerColor = MementoBar.Saved.CenterColor
     local edgeColor = MementoBar.Saved.EdgeColor
     local fontColor = MementoBar.Saved.FontColor
-
+
     frame.overlay:SetCenterColor(centerColor.r, centerColor.g, centerColor.b, centerColor.a)
     frame.overlay:SetEdgeColor(edgeColor.r, edgeColor.g, edgeColor.b, edgeColor.a)
     frame.labelCenter:SetColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a)