diff --git a/Core/Database.lua b/Core/Database.lua index 3826d11..7e3c835 100644 --- a/Core/Database.lua +++ b/Core/Database.lua @@ -41,6 +41,7 @@ function DB:Initialize() iconFontSize = 12, showQualityBorderEquipment = true, showQualityBorderOther = true, + showSearchBar = true, }, } end @@ -70,6 +71,9 @@ function DB:Initialize() if Guda_CharDB.settings.showQualityBorderOther == nil then Guda_CharDB.settings.showQualityBorderOther = true end + if Guda_CharDB.settings.showSearchBar == nil then + Guda_CharDB.settings.showSearchBar = true + end -- Initialize this character's data if not Guda_DB.characters[fullName] then @@ -113,7 +117,7 @@ end -- Get current player's full name function DB:GetPlayerFullName() - return playerName .. "-" .. playerRealm + return playerName end -- Get current character data diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index 26063b5..6b94cf7 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -84,6 +84,11 @@ function Guda_BagFrame_OnShow(self) BagFrame:UpdateBorderVisibility() end + -- Apply search bar visibility setting + if BagFrame.UpdateSearchBarVisibility then + BagFrame:UpdateSearchBarVisibility() + end + BagFrame:Update() end @@ -328,7 +333,26 @@ function BagFrame:ResizeFrame(currentRow, currentCol, columns) local containerWidth = (columns * (buttonSize + spacing)) + 20 local containerHeight = (totalRows * (buttonSize + spacing)) + 20 local frameWidth = containerWidth + 20 - local frameHeight = containerHeight + 115 -- Title (40) + search (30) + footer (45) + + -- Check if search bar is visible + local showSearchBar = addon.Modules.DB:GetSetting("showSearchBar") + if showSearchBar == nil then + showSearchBar = true + end + + -- Adjust frame height based on search bar visibility + -- Footer height varies: more space needed when search bar is visible + local titleHeight = 40 + local searchBarHeight = 30 + local footerHeight + local frameHeight + if showSearchBar then + footerHeight = 55 -- Increased footer height when search bar is visible (toolbar 40px + spacing 15px) + frameHeight = containerHeight + titleHeight + searchBarHeight + footerHeight -- 125 total + else + footerHeight = 45 -- Normal footer height (toolbar 40px + spacing 5px) + frameHeight = containerHeight + titleHeight + footerHeight -- 85 total + end -- Minimum sizes if containerWidth < 200 then @@ -1457,6 +1481,32 @@ function BagFrame:UpdateBorderVisibility() end end +-- Update search bar visibility based on setting +function BagFrame:UpdateSearchBarVisibility() + if not addon or not addon.Modules or not addon.Modules.DB then return end + + local searchBar = getglobal("Guda_BagFrame_SearchBar") + local itemContainer = getglobal("Guda_BagFrame_ItemContainer") + if not searchBar or not itemContainer then return end + + local showSearchBar = addon.Modules.DB:GetSetting("showSearchBar") + if showSearchBar == nil then + showSearchBar = true + end + + if showSearchBar then + searchBar:Show() + -- Anchor ItemContainer to SearchBar's bottom + itemContainer:ClearAllPoints() + itemContainer:SetPoint("TOP", searchBar, "BOTTOM", 0, -5) + else + searchBar:Hide() + -- Anchor ItemContainer directly to frame top (skip search bar space) + itemContainer:ClearAllPoints() + itemContainer:SetPoint("TOP", "Guda_BagFrame", "TOP", 0, -40) + end +end + -- Bag Slot Button Handlers -- OnLoad handler for bag slot buttons diff --git a/UI/BagFrame.xml b/UI/BagFrame.xml index 73aa99b..faa1716 100644 --- a/UI/BagFrame.xml +++ b/UI/BagFrame.xml @@ -49,7 +49,7 @@ - + @@ -252,12 +252,12 @@ - + - + @@ -625,7 +625,7 @@ - + diff --git a/UI/BankFrame.lua b/UI/BankFrame.lua index a1bcdfc..212610c 100644 --- a/UI/BankFrame.lua +++ b/UI/BankFrame.lua @@ -39,6 +39,11 @@ function Guda_BankFrame_OnShow(self) BankFrame:UpdateBorderVisibility() end + -- Apply search bar visibility setting + if BankFrame.UpdateSearchBarVisibility then + BankFrame:UpdateSearchBarVisibility() + end + BankFrame:Update() end @@ -143,7 +148,7 @@ end -- Display items function BankFrame:DisplayItems(bankData, isOtherChar, charName) - local x, y = 10, -10 + local x, y = 5, -10 local row = 0 local col = 0 local buttonSize = addon.Modules.DB:GetSetting("iconSize") or addon.Constants.BUTTON_SIZE @@ -225,10 +230,27 @@ function BankFrame:ResizeFrame(currentRow, currentCol, columns) end -- Calculate required dimensions - local containerWidth = (columns * (buttonSize + spacing)) + 20 + local containerWidth = (columns * (buttonSize + spacing)) + 10 local containerHeight = (totalRows * (buttonSize + spacing)) + 20 local frameWidth = containerWidth + 30 - local frameHeight = containerHeight + 100 -- Title (40) + search (30) + footer (30) + + -- Check if search bar is visible + local showSearchBar = addon.Modules.DB:GetSetting("showSearchBar") + if showSearchBar == nil then + showSearchBar = true + end + + -- Adjust frame height based on search bar visibility + -- Footer height varies: less space when search bar is hidden + local titleHeight = 40 + local searchBarHeight = 30 + local footerHeight = 40 + local frameHeight + if showSearchBar then + frameHeight = containerHeight + titleHeight + searchBarHeight + footerHeight -- 125 total + else + frameHeight = containerHeight + titleHeight + footerHeight -- 80 total + end -- Minimum sizes if containerWidth < 200 then @@ -266,6 +288,12 @@ function BankFrame:ResizeFrame(currentRow, currentCol, columns) itemContainer:SetWidth(containerWidth) itemContainer:SetHeight(containerHeight) end + + -- Resize search bar to match container width + local searchBar = getglobal("Guda_BankFrame_SearchBar") + if searchBar then + searchBar:SetWidth(containerWidth) + end end -- Update bank slots info text @@ -334,7 +362,7 @@ end -- Create MoneyFrame if it doesn't exist function BankFrame:CreateMoneyFrame() local moneyFrame = CreateFrame("Frame", "Guda_BankFrame_MoneyFrame", Guda_BankFrame, "SmallMoneyFrameTemplate") - moneyFrame:SetPoint("BOTTOMRIGHT", Guda_BankFrame, "BOTTOMRIGHT", -15, 7) + moneyFrame:SetPoint("BOTTOMRIGHT", Guda_BankFrame, "BOTTOMRIGHT", -10, 10) moneyFrame:SetWidth(180) moneyFrame:SetHeight(35) @@ -776,6 +804,32 @@ function BankFrame:UpdateBorderVisibility() end end +-- Update search bar visibility based on setting +function BankFrame:UpdateSearchBarVisibility() + if not addon or not addon.Modules or not addon.Modules.DB then return end + + local searchBar = getglobal("Guda_BankFrame_SearchBar") + local itemContainer = getglobal("Guda_BankFrame_ItemContainer") + if not searchBar or not itemContainer then return end + + local showSearchBar = addon.Modules.DB:GetSetting("showSearchBar") + if showSearchBar == nil then + showSearchBar = true + end + + if showSearchBar then + searchBar:Show() + -- Anchor ItemContainer to SearchBar's bottom + itemContainer:ClearAllPoints() + itemContainer:SetPoint("TOP", searchBar, "BOTTOM", 0, -5) + else + searchBar:Hide() + -- Anchor ItemContainer directly to frame top (skip search bar space) + itemContainer:ClearAllPoints() + itemContainer:SetPoint("TOP", "Guda_BankFrame", "TOP", 0, -40) + end +end + -- Initialize function BankFrame:Initialize() -- Hide Blizzard bank frame on load (pfUI style) diff --git a/UI/BankFrame.xml b/UI/BankFrame.xml index cdcad1f..994e150 100644 --- a/UI/BankFrame.xml +++ b/UI/BankFrame.xml @@ -49,7 +49,7 @@ - + @@ -163,7 +163,7 @@ - + @@ -311,7 +311,7 @@ - + @@ -339,7 +339,7 @@ - + diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index cd0d1ad..a393f1c 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -50,6 +50,10 @@ function Guda_SettingsPopup_OnShow(self) if showQualityBorderOther == nil then showQualityBorderOther = true end + local showSearchBar = Guda.Modules.DB:GetSetting("showSearchBar") + if showSearchBar == nil then + showSearchBar = true + end -- Update sliders and checkboxes local bagSlider = getglobal("Guda_SettingsPopup_BagColumnsSlider") @@ -61,6 +65,7 @@ function Guda_SettingsPopup_OnShow(self) local hideBordersCheckbox = getglobal("Guda_SettingsPopup_HideBordersCheckbox") local qualityBorderEquipmentCheckbox = getglobal("Guda_SettingsPopup_QualityBorderEquipmentCheckbox") local qualityBorderOtherCheckbox = getglobal("Guda_SettingsPopup_QualityBorderOtherCheckbox") + local showSearchBarCheckbox = getglobal("Guda_SettingsPopup_ShowSearchBarCheckbox") if bagSlider then bagSlider:SetValue(bagColumns) @@ -97,6 +102,10 @@ function Guda_SettingsPopup_OnShow(self) if qualityBorderOtherCheckbox then qualityBorderOtherCheckbox:SetChecked(showQualityBorderOther and 1 or 0) end + + if showSearchBarCheckbox then + showSearchBarCheckbox:SetChecked(showSearchBar and 1 or 0) + end end -- Toggle visibility @@ -353,7 +362,7 @@ end function Guda_SettingsPopup_HideBordersCheckbox_OnLoad(self) local text = getglobal(self:GetName().."Text") if text then - text:SetText("Frame Borders") + text:SetText("Hide Frame Borders") -- Increase font size local font, _, flags = text:GetFont() @@ -492,6 +501,60 @@ function Guda_SettingsPopup_QualityBorderOtherCheckbox_OnClick(self) end end +-- Show Search Bar Checkbox OnLoad +function Guda_SettingsPopup_ShowSearchBarCheckbox_OnLoad(self) + local text = getglobal(self:GetName().."Text") + if text then + text:SetText("Show Search Bar") + + -- Increase font size + local font, _, flags = text:GetFont() + if font then + text:SetFont(font, 13, flags) + end + end + + local showSearchBar = true + if Guda and Guda.Modules and Guda.Modules.DB then + showSearchBar = Guda.Modules.DB:GetSetting("showSearchBar") + if showSearchBar == nil then + showSearchBar = true + end + end + + self:SetChecked(showSearchBar and 1 or 0) +end + +-- Show Search Bar Checkbox OnClick +function Guda_SettingsPopup_ShowSearchBarCheckbox_OnClick(self) + local isChecked = self:GetChecked() == 1 + + -- Save setting + if Guda and Guda.Modules and Guda.Modules.DB then + Guda.Modules.DB:SetSetting("showSearchBar", isChecked) + end + + -- Update search bar visibility in bag frame + local bagFrame = getglobal("Guda_BagFrame") + if bagFrame and bagFrame:IsShown() then + -- Use the UpdateSearchBarVisibility function which handles anchoring + if Guda.Modules.BagFrame.UpdateSearchBarVisibility then + Guda.Modules.BagFrame:UpdateSearchBarVisibility() + end + Guda.Modules.BagFrame:Update() + end + + -- Update search bar visibility in bank frame + local bankFrame = getglobal("Guda_BankFrame") + if bankFrame and bankFrame:IsShown() then + -- Use the UpdateSearchBarVisibility function which handles anchoring + if Guda.Modules.BankFrame.UpdateSearchBarVisibility then + Guda.Modules.BankFrame:UpdateSearchBarVisibility() + end + 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 7bef134..ac1e096 100644 --- a/UI/SettingsPopup.xml +++ b/UI/SettingsPopup.xml @@ -3,7 +3,7 @@ - + @@ -245,6 +245,25 @@ + + + + + + + + + + + + + Guda_SettingsPopup_ShowSearchBarCheckbox_OnLoad(this) + + + Guda_SettingsPopup_ShowSearchBarCheckbox_OnClick(this) + + +