added track inventory option and disabled track quest keybindstrip

Leandro Silva [04-10-20 - 22:05]
added track inventory option and disabled track quest keybindstrip
Filename
LeoAltholic.lua
LeoAltholic.txt
LeoAltholicInit.lua
Settings.lua
diff --git a/LeoAltholic.lua b/LeoAltholic.lua
index efebf5a..7d0a4c5 100644
--- a/LeoAltholic.lua
+++ b/LeoAltholic.lua
@@ -522,15 +522,17 @@ local function initCharsData()
     char.inventory.telvar = GetCarriedCurrencyAmount(CURT_TELVAR_STONES)
     char.inventory.writVoucher = GetCarriedCurrencyAmount(CURT_WRIT_VOUCHERS)

-    local bag = SHARED_INVENTORY:GenerateFullSlotData(nil,BAG_WORN,BAG_BACKPACK)
     char.inventory[BAG_WORN] = {}
     char.inventory[BAG_BACKPACK] = {}
-    for _, data in pairs(bag) do
-        char.inventory[data.bagId][data.slotIndex] = {
-            link = GetItemLink(data.bagId, data.slotIndex),
-            name = data.name,
-            count = data.stackCount
-        }
+    if LeoAltholic.globalData.settings.inventory.enabled then
+        local bag = SHARED_INVENTORY:GenerateFullSlotData(nil,BAG_WORN,BAG_BACKPACK)
+        for _, data in pairs(bag) do
+            char.inventory[data.bagId][data.slotIndex] = {
+                link = GetItemLink(data.bagId, data.slotIndex),
+                name = data.name,
+                count = data.stackCount
+            }
+        end
     end

     if char.stats == nil then char.stats = {} end
@@ -1071,7 +1073,6 @@ local function updateBank(bagId, slotIndex, stackCount)
 end

 local function scanBank()
-
     LeoAltholic.globalData.AccountData.inventory[BAG_BANK].list = {}
     LeoAltholic.globalData.AccountData.inventory[BAG_SUBSCRIBER_BANK].list = {}
     local numEmptySoulGems = 0
@@ -1124,7 +1125,7 @@ local function onCloseBank(eventCode, bagId)
 end

 local function onOpenBank(eventCode, bagId)
-    if bagId ~= BAG_BANK and bagId ~= BAG_SUBSCRIBER_BANK then return end
+    if bagId ~= BAG_BANK and bagId ~= BAG_SUBSCRIBER_BANK or not LeoAltholic.globalData.settings.inventory.enabled then return end
     EVENT_MANAGER:UnregisterForEvent(LeoAltholic.name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE)
     EVENT_MANAGER:RegisterForEvent(LeoAltholic.name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, onUpdateBank)
     scanBank()
@@ -1166,6 +1167,9 @@ local function initializeVars()
                 hidden = false,
                 craft = {},
                 riding = true
+            },
+            inventory = {
+                enabled = true
             }
         }
     }
@@ -1195,6 +1199,9 @@ local function initializeVars()
             checklist = {
                 fontScale = 100,
                 upwards = false
+            },
+            inventory = {
+                enabled = true
             }
         }
     end
@@ -1206,6 +1213,11 @@ local function initializeVars()
         migrateDataToV2()
         LeoAltholic.globalData.dataVersion = 2
     end
+    if LeoAltholic.globalData.settings.inventory == nil then
+        LeoAltholic.globalData.settings.inventory = {
+            enabled = true
+        }
+    end
     initCharsData()
     initAccountData()
 end
@@ -1236,13 +1248,18 @@ local function initialize()
     LeoAltholicUI.InitPanels()
     createMessageQueue()

+    --[[
     local keybindStripDescriptor = {
         alignment = KEYBIND_STRIP_ALIGN_LEFT,
         {
             name = "Track with " .. LeoAltholic.displayName,
             keybind = "LEOALTHOLIC_TRACK_QUEST",
             enabled = function() return true end,
-            visible = function() return true end,
+            visible = function()
+                if not LeoAltholic.questSceneOpened then return false end
+                local questIndex = QUEST_JOURNAL_MANAGER:GetFocusedQuestIndex()
+                return GetJournalQuestRepeatType(questIndex) == QUEST_REPEAT_DAILY
+            end,
             order = 100,
             callback = function()
                 trackQuest(QUEST_JOURNAL_MANAGER:GetFocusedQuestIndex())
@@ -1252,15 +1269,13 @@ local function initialize()

     QUEST_JOURNAL_SCENE:RegisterCallback("StateChange",
             function(oldState, newState)
-                if(newState == SCENE_SHOWING) then
-                    local type = GetJournalQuestRepeatType(QUEST_JOURNAL_MANAGER:GetFocusedQuestIndex())
-                    if type == QUEST_REPEAT_DAILY then
-                        KEYBIND_STRIP:AddKeybindButtonGroup(keybindStripDescriptor)
-                    else
-                        KEYBIND_STRIP:RemoveKeybindButtonGroup(keybindStripDescriptor)
-                    end
-                elseif(newState == SCENE_HIDDEN) then
-                    KEYBIND_STRIP:RemoveKeybindButtonGroup(keybindStripDescriptor)
+                KEYBIND_STRIP:RemoveKeybindButtonGroup(keybindStripDescriptor)
+                if newState == SCENE_SHOWING then
+                    LeoAltholic.questSceneOpened = true
+                elseif(newState == SCENE_SHOWN) then
+                    KEYBIND_STRIP:AddKeybindButtonGroup(keybindStripDescriptor)
+                else
+                    LeoAltholic.questSceneOpened = false
                 end
             end)

@@ -1273,6 +1288,7 @@ local function initialize()
                     KEYBIND_STRIP:RemoveKeybindButtonGroup(keybindStripDescriptor)
                 end
             end)
+    ]]

     LeoAltholic.settings = LeoAltholic_Settings:New()
     LeoAltholic.settings:CreatePanel()
diff --git a/LeoAltholic.txt b/LeoAltholic.txt
index 461d025..0be9955 100644
--- a/LeoAltholic.txt
+++ b/LeoAltholic.txt
@@ -1,7 +1,7 @@
 ## Title: Leo's Altholic
 ## APIVersion: 100029 100030
-## Version: 1.7.11
-## AddOnVersion: 1711
+## Version: 1.7.12
+## AddOnVersion: 1712
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoAltholicSavedVariables LeoAltholicCharVariables
 ## DependsOn: LibFeedback LibAddonMenu-2.0
diff --git a/LeoAltholicInit.lua b/LeoAltholicInit.lua
index 8381f9c..6bffb3c 100644
--- a/LeoAltholicInit.lua
+++ b/LeoAltholicInit.lua
@@ -6,7 +6,7 @@ LeoAltholicToolbarUI = LeoAltholicToolbarUI or {}

 LeoAltholic.name = "LeoAltholic"
 LeoAltholic.displayName = "Leo's Altholic"
-LeoAltholic.version = "1.7.11"
+LeoAltholic.version = "1.7.12"
 LeoAltholic.chatPrefix = "|c39B027" .. LeoAltholic.name .. "|r: "

 LeoAltholic.TAB_BIO = "Bio"
diff --git a/Settings.lua b/Settings.lua
index 3ae1af9..a091f7c 100644
--- a/Settings.lua
+++ b/Settings.lua
@@ -29,6 +29,18 @@ function LeoAltholic_Settings:CreatePanel()
     local optionsData = {
         {
             type = "header",
+            name = "|c3f7fff"..GetString(SI_GAME_MENU_SETTINGS).."|r"
+        },{
+            type = "checkbox",
+            name = "Track inventory items",
+            default = true,
+            getFunc = function()
+                if LeoAltholic.globalData.settings.inventory.enabled == nil then LeoAltholic.globalData.settings.inventory.enabled = true end
+                return LeoAltholic.globalData.settings.inventory.enabled
+            end,
+            setFunc = function(value) LeoAltholic.globalData.settings.inventory.enabled = value end,
+        },{
+            type = "header",
             name = "|c3f7fff"..GetString(LEOALT_CHECKLIST).."|r"
         },{
             type = "checkbox",