From 8eeb2331bcfaedae8f866b1aa6333baa2ffe918b Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Tue, 23 Dec 2025 04:01:46 +0400 Subject: [PATCH] feat: item tracking with ctrl + click --- Core/Database.lua | 4 ++-- Core/Main.lua | 15 +++++++++------ UI/ItemButton.lua | 4 ++-- UI/SettingsPopup.lua | 32 -------------------------------- UI/SettingsPopup.xml | 18 ------------------ UI/TrackedItemBar.lua | 6 ------ 6 files changed, 13 insertions(+), 66 deletions(-) diff --git a/Core/Database.lua b/Core/Database.lua index 5f192eb..ea44616 100644 --- a/Core/Database.lua +++ b/Core/Database.lua @@ -45,7 +45,7 @@ function DB:Initialize() hoverBagline = false, hideFooter = false, bgTransparency = 0.15, - showTrackedItems = false, + showTrackedItems = true, trackedItems = {}, }, } @@ -70,7 +70,7 @@ function DB:Initialize() Guda_CharDB.settings.showQuestBar = true end if Guda_CharDB.settings.showTrackedItems == nil then - Guda_CharDB.settings.showTrackedItems = false + Guda_CharDB.settings.showTrackedItems = true end if Guda_CharDB.settings.trackedItems == nil then Guda_CharDB.settings.trackedItems = {} diff --git a/Core/Main.lua b/Core/Main.lua index ef066a6..9316884 100644 --- a/Core/Main.lua +++ b/Core/Main.lua @@ -124,12 +124,15 @@ function Main:SetupSlashCommands() addon:Print("Quest bar: %s", show and "ON" or "OFF") elseif msg == "track" then - -- Toggle tracked items - local show = not addon.Modules.DB:GetSetting("showTrackedItems") - addon.Modules.DB:SetSetting("showTrackedItems", show) - if addon.Modules.TrackedItemBar then addon.Modules.TrackedItemBar:Update() end - if addon.Modules.BagFrame then addon.Modules.BagFrame:Update() end - addon:Print("Track items: %s", show and "ON" or "OFF") + -- Toggle tracked items bar visibility + local frame = Guda_TrackedItemBar + if frame then + if frame:IsShown() then + frame:Hide() + else + frame:Show() + end + end elseif msg == "cleanup" then -- Cleanup old characters diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 0cb7e18..acc979b 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -544,7 +544,7 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha local check = getglobal(self:GetName().."_Check") if check then local isTracked = false - if self.hasItem and addon.Modules.DB:GetSetting("showTrackedItems") then + if self.hasItem then local itemID = addon.Modules.Utils:ExtractItemID(self.itemData and self.itemData.link) if itemID then local trackedItems = addon.Modules.DB:GetSetting("trackedItems") or {} @@ -771,7 +771,7 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha if not self.isReadOnly and not self.otherChar then local old_OnClick = self:GetScript("OnClick") self:SetScript("OnClick", function() - if IsControlKeyDown() and addon.Modules.DB:GetSetting("showTrackedItems") then + if IsControlKeyDown() then local itemID = addon.Modules.Utils:ExtractItemID(GetContainerItemLink(this:GetParent():GetID(), this:GetID())) if itemID then local trackedItems = addon.Modules.DB:GetSetting("trackedItems") or {} diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index a0f7039..4dea34d 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -65,10 +65,6 @@ function Guda_SettingsPopup_OnShow(self) if hoverBagline == nil then hoverBagline = false end - local showTrackedItems = Guda.Modules.DB:GetSetting("showTrackedItems") - if showTrackedItems == nil then - showTrackedItems = false - end local bgTransparency = Guda.Modules.DB:GetSetting("bgTransparency") or 0.15 -- Update sliders and checkboxes @@ -85,7 +81,6 @@ function Guda_SettingsPopup_OnShow(self) local showSearchBarCheckbox = getglobal("Guda_SettingsPopup_ShowSearchBarCheckbox") local showQuestBarCheckbox = getglobal("Guda_SettingsPopup_ShowQuestBarCheckbox") local hoverBaglineCheckbox = getglobal("Guda_SettingsPopup_HoverBaglineCheckbox") - local showTrackedItemsCheckbox = getglobal("Guda_SettingsPopup_ShowTrackedItemsCheckbox") if bagSlider then bagSlider:SetValue(bagColumns) @@ -139,9 +134,6 @@ function Guda_SettingsPopup_OnShow(self) hoverBaglineCheckbox:SetChecked(hoverBagline and 1 or 0) end - if showTrackedItemsCheckbox then - showTrackedItemsCheckbox:SetChecked(showTrackedItems and 1 or 0) - end -- Update display (might be too tall for current frame size) local frame = getglobal("Guda_SettingsPopup") @@ -819,27 +811,3 @@ function SettingsPopup:Initialize() Guda:Debug("Settings popup initialized") end --- Show Tracked Items Checkbox OnLoad -function Guda_SettingsPopup_ShowTrackedItemsCheckbox_OnLoad(self) - getglobal(self:GetName().."Text"):SetText("Track items") - local currentValue = Guda.Modules.DB:GetSetting("showTrackedItems") - if currentValue == nil then - currentValue = false - end - self:SetChecked(currentValue and 1 or 0) -end - --- Show Tracked Items Checkbox OnClick -function Guda_SettingsPopup_ShowTrackedItemsCheckbox_OnClick(self) - local isChecked = self:GetChecked() - Guda.Modules.DB:SetSetting("showTrackedItems", isChecked == 1) - - if Guda.Modules.TrackedItemBar and Guda.Modules.TrackedItemBar.Update then - Guda.Modules.TrackedItemBar:Update() - end - - -- Refresh bag frame to show/hide checkmarks - if Guda.Modules.BagFrame and Guda.Modules.BagFrame.Update then - Guda.Modules.BagFrame:Update() - end -end diff --git a/UI/SettingsPopup.xml b/UI/SettingsPopup.xml index 44d6a00..462254d 100644 --- a/UI/SettingsPopup.xml +++ b/UI/SettingsPopup.xml @@ -343,24 +343,6 @@ - - - - - - - - - - - - Guda_SettingsPopup_ShowTrackedItemsCheckbox_OnLoad(this) - - - Guda_SettingsPopup_ShowTrackedItemsCheckbox_OnClick(this) - - - diff --git a/UI/TrackedItemBar.lua b/UI/TrackedItemBar.lua index df60234..672cfb5 100644 --- a/UI/TrackedItemBar.lua +++ b/UI/TrackedItemBar.lua @@ -64,14 +64,8 @@ end -- Update the bar buttons function TrackedItemBar:Update() - local showTrackedItems = addon.Modules.DB:GetSetting("showTrackedItems") local frame = Guda_TrackedItemBar - if showTrackedItems == false then - if frame then frame:Hide() end - return - end - if not frame then return end frame:Show()