diff --git a/Core/Database.lua b/Core/Database.lua index 0ae8c87..3826d11 100644 --- a/Core/Database.lua +++ b/Core/Database.lua @@ -39,6 +39,8 @@ function DB:Initialize() iconSize = 40, iconSpacing = 0, iconFontSize = 12, + showQualityBorderEquipment = true, + showQualityBorderOther = true, }, } end @@ -62,6 +64,12 @@ function DB:Initialize() if not Guda_CharDB.settings.iconFontSize then Guda_CharDB.settings.iconFontSize = 12 end + if Guda_CharDB.settings.showQualityBorderEquipment == nil then + Guda_CharDB.settings.showQualityBorderEquipment = true + end + if Guda_CharDB.settings.showQualityBorderOther == nil then + Guda_CharDB.settings.showQualityBorderOther = true + end -- Initialize this character's data if not Guda_DB.characters[fullName] then diff --git a/Core/Utils.lua b/Core/Utils.lua index 28df5dd..59d535b 100644 --- a/Core/Utils.lua +++ b/Core/Utils.lua @@ -407,4 +407,30 @@ function Utils:GetItemPreferredContainer(itemLink) end return nil +end + +-- Check if an item is equipment (armor, weapon, or other equippable) +-- Returns: true if item is equipment, false otherwise +function Utils:IsEquipment(itemLink) + if not itemLink then return false end + + local itemID = self:ExtractItemID(itemLink) + if not itemID then return false end + + local itemName, _, itemRarity, itemLevel, itemCategory, itemType, itemStackCount, itemSubType, itemTexture, itemEquipLoc = self:GetItemInfoSafe(itemID) + + -- Check if item has an equip location (most reliable method) + if itemEquipLoc and itemEquipLoc ~= "" and itemEquipLoc ~= "INVTYPE_BAG" then + return true + end + + -- Fallback: Check category (in case itemEquipLoc is not set) + if itemCategory then + local categoryLower = string.lower(itemCategory) + if categoryLower == "armor" or categoryLower == "weapon" then + return true + end + end + + return false end \ No newline at end of file diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 71593c4..51a39cb 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -193,11 +193,33 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha -- Special border for keyring items (cyan/blue) self.qualityBorder:SetBackdropBorderColor(0.2, 0.8, 1.0, 1) self.qualityBorder:Show() - elseif itemData.quality then - -- Show colored border for all items (Poor, Common, Uncommon, Rare, Epic, etc.) - local r, g, b = addon.Modules.Utils:GetQualityColor(itemData.quality) - self.qualityBorder:SetBackdropBorderColor(r, g, b, 1) - self.qualityBorder:Show() + elseif itemData.quality and itemData.link then + -- Check settings to determine if we should show borders + local showEquipmentBorder = addon.Modules.DB:GetSetting("showQualityBorderEquipment") + local showOtherBorder = addon.Modules.DB:GetSetting("showQualityBorderOther") + + -- Default to true if settings not found + if showEquipmentBorder == nil then + showEquipmentBorder = true + end + if showOtherBorder == nil then + showOtherBorder = true + end + + -- Check if item is equipment + local isEquipment = addon.Modules.Utils:IsEquipment(itemData.link) + + -- Determine if we should show the border based on item type and settings + local shouldShowBorder = (isEquipment and showEquipmentBorder) or (not isEquipment and showOtherBorder) + + if shouldShowBorder then + -- Show colored border for all items (Poor, Common, Uncommon, Rare, Epic, etc.) + local r, g, b = addon.Modules.Utils:GetQualityColor(itemData.quality) + self.qualityBorder:SetBackdropBorderColor(r, g, b, 1) + self.qualityBorder:Show() + else + self.qualityBorder:Hide() + end else self.qualityBorder:Hide() end diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index 20d94fe..cd0d1ad 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -42,6 +42,14 @@ function Guda_SettingsPopup_OnShow(self) if hideBorders == nil then hideBorders = false end + local showQualityBorderEquipment = Guda.Modules.DB:GetSetting("showQualityBorderEquipment") + if showQualityBorderEquipment == nil then + showQualityBorderEquipment = true + end + local showQualityBorderOther = Guda.Modules.DB:GetSetting("showQualityBorderOther") + if showQualityBorderOther == nil then + showQualityBorderOther = true + end -- Update sliders and checkboxes local bagSlider = getglobal("Guda_SettingsPopup_BagColumnsSlider") @@ -51,6 +59,8 @@ function Guda_SettingsPopup_OnShow(self) local iconSpacingSlider = getglobal("Guda_SettingsPopup_IconSpacingSlider") local lockCheckbox = getglobal("Guda_SettingsPopup_LockBagsCheckbox") local hideBordersCheckbox = getglobal("Guda_SettingsPopup_HideBordersCheckbox") + local qualityBorderEquipmentCheckbox = getglobal("Guda_SettingsPopup_QualityBorderEquipmentCheckbox") + local qualityBorderOtherCheckbox = getglobal("Guda_SettingsPopup_QualityBorderOtherCheckbox") if bagSlider then bagSlider:SetValue(bagColumns) @@ -79,6 +89,14 @@ function Guda_SettingsPopup_OnShow(self) if hideBordersCheckbox then hideBordersCheckbox:SetChecked(hideBorders and 1 or 0) end + + if qualityBorderEquipmentCheckbox then + qualityBorderEquipmentCheckbox:SetChecked(showQualityBorderEquipment and 1 or 0) + end + + if qualityBorderOtherCheckbox then + qualityBorderOtherCheckbox:SetChecked(showQualityBorderOther and 1 or 0) + end end -- Toggle visibility @@ -335,7 +353,7 @@ end function Guda_SettingsPopup_HideBordersCheckbox_OnLoad(self) local text = getglobal(self:GetName().."Text") if text then - text:SetText("Hide Borders") + text:SetText("Frame Borders") -- Increase font size local font, _, flags = text:GetFont() @@ -384,6 +402,96 @@ function Guda_SettingsPopup_HideBordersCheckbox_OnClick(self) end end +-- Quality Border Equipment Checkbox OnLoad +function Guda_SettingsPopup_QualityBorderEquipmentCheckbox_OnLoad(self) + local text = getglobal(self:GetName().."Text") + if text then + text:SetText("Equipment Borders") + + -- Increase font size + local font, _, flags = text:GetFont() + if font then + text:SetFont(font, 13, flags) + end + end + + local showBorders = true + if Guda and Guda.Modules and Guda.Modules.DB then + showBorders = Guda.Modules.DB:GetSetting("showQualityBorderEquipment") + if showBorders == nil then + showBorders = true + end + end + + self:SetChecked(showBorders and 1 or 0) +end + +-- Quality Border Equipment Checkbox OnClick +function Guda_SettingsPopup_QualityBorderEquipmentCheckbox_OnClick(self) + local isChecked = self:GetChecked() == 1 + + -- Save setting + if Guda and Guda.Modules and Guda.Modules.DB then + Guda.Modules.DB:SetSetting("showQualityBorderEquipment", isChecked) + end + + -- Update bag and bank frames + local bagFrame = getglobal("Guda_BagFrame") + if bagFrame and bagFrame:IsShown() then + Guda.Modules.BagFrame:Update() + end + + local bankFrame = getglobal("Guda_BankFrame") + if bankFrame and bankFrame:IsShown() then + Guda.Modules.BankFrame:Update() + end +end + +-- Quality Border Other Checkbox OnLoad +function Guda_SettingsPopup_QualityBorderOtherCheckbox_OnLoad(self) + local text = getglobal(self:GetName().."Text") + if text then + text:SetText("Other Item Borders") + + -- Increase font size + local font, _, flags = text:GetFont() + if font then + text:SetFont(font, 13, flags) + end + end + + local showBorders = true + if Guda and Guda.Modules and Guda.Modules.DB then + showBorders = Guda.Modules.DB:GetSetting("showQualityBorderOther") + if showBorders == nil then + showBorders = true + end + end + + self:SetChecked(showBorders and 1 or 0) +end + +-- Quality Border Other Checkbox OnClick +function Guda_SettingsPopup_QualityBorderOtherCheckbox_OnClick(self) + local isChecked = self:GetChecked() == 1 + + -- Save setting + if Guda and Guda.Modules and Guda.Modules.DB then + Guda.Modules.DB:SetSetting("showQualityBorderOther", isChecked) + end + + -- Update bag and bank frames + local bagFrame = getglobal("Guda_BagFrame") + if bagFrame and bagFrame:IsShown() then + Guda.Modules.BagFrame:Update() + end + + local bankFrame = getglobal("Guda_BankFrame") + if bankFrame and bankFrame:IsShown() then + Guda.Modules.BankFrame:Update() + end +end + -- Initialize function SettingsPopup:Initialize() Guda:Debug("Settings popup initialized") diff --git a/UI/SettingsPopup.xml b/UI/SettingsPopup.xml index f1f79a1..7bef134 100644 --- a/UI/SettingsPopup.xml +++ b/UI/SettingsPopup.xml @@ -3,7 +3,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -175,7 +175,7 @@ - + @@ -194,7 +194,7 @@ - + @@ -207,6 +207,44 @@ + + + + + + + + + + + + + Guda_SettingsPopup_QualityBorderEquipmentCheckbox_OnLoad(this) + + + Guda_SettingsPopup_QualityBorderEquipmentCheckbox_OnClick(this) + + + + + + + + + + + + + + + + Guda_SettingsPopup_QualityBorderOtherCheckbox_OnLoad(this) + + + Guda_SettingsPopup_QualityBorderOtherCheckbox_OnClick(this) + + +