fix: pagination

This commit is contained in:
Salikh Gurgenidze
2025-12-27 17:56:03 +04:00
parent 6ca33c1c9f
commit 5f0ade6013
2 changed files with 37 additions and 72 deletions
+9 -23
View File
@@ -114,6 +114,7 @@ function MailboxFrame:Update()
-- Filter items based on search text
local filteredItems = {}
local totalItems = table.getn(mailboxData)
for i, mail in ipairs(mailboxData) do
local matchesSearch = true
if searchText ~= "" then
@@ -158,27 +159,11 @@ function MailboxFrame:Update()
end
-- Display items
self:DisplayItems(filteredItems, charFullName)
-- Update footer info
local totalItems = table.getn(mailboxData)
local displayedItems = table.getn(filteredItems)
local footerText = string.format("Items: %d", totalItems)
if searchText ~= "" then
footerText = string.format("Filtered: %d / %d", displayedItems, totalItems)
end
getglobal("Guda_MailboxFrame_Footer_Text"):SetText(footerText)
-- Update money (total money in mailbox)
local totalMoney = 0
for _, mail in ipairs(mailboxData) do
totalMoney = totalMoney + (mail.money or 0)
end
MoneyFrame_Update("Guda_MailboxFrame_MoneyFrame", totalMoney)
self:DisplayItems(filteredItems, charFullName, totalItems)
end
-- Display mailbox items in a list
function MailboxFrame:DisplayItems(items, charFullName)
function MailboxFrame:DisplayItems(items, charFullName, totalMails)
local container = getglobal("Guda_MailboxFrame_ItemContainer")
-- Hide all existing rows first
@@ -260,7 +245,7 @@ function MailboxFrame:DisplayItems(items, charFullName)
end
if itemButton.qualityBorder then itemButton.qualityBorder:Hide() end
end
-- Row Money Frame
local moneyFrame = getglobal(row:GetName() .. "_MoneyFrame")
if (mail.money or 0) > 0 then
@@ -290,10 +275,11 @@ function MailboxFrame:DisplayItems(items, charFullName)
nextBtn:Disable()
end
-- Update page text in footer
local footerFontString = getglobal("Guda_MailboxFrame_Footer_Text")
local footerText = footerFontString:GetText() or ""
footerFontString:SetText(footerText .. " (Page " .. currentPage .. " of " .. totalPages .. ")")
-- Update pagination text
local paginationText = getglobal("Guda_MailboxFrame_Pagination_Text")
if paginationText then
paginationText:SetText(string.format("%d/%d (items: %d)", currentPage, totalPages, totalMails or 0))
end
end
-- Search text changed
+28 -49
View File
@@ -244,8 +244,8 @@
</Scripts>
</Button>
<!-- Scroll Frame for Items -->
<ScrollFrame name="$parent_ScrollFrame" inherits="UIPanelScrollFrameTemplate">
<!-- Item Container -->
<Frame name="Guda_MailboxFrame_ItemContainer">
<Size>
<AbsDimension x="360" y="420"/>
</Size>
@@ -256,49 +256,6 @@
</Offset>
</Anchor>
</Anchors>
<ScrollChild>
<Frame name="Guda_MailboxFrame_ItemContainer">
<Size>
<AbsDimension x="360" y="420"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT"/>
</Anchors>
</Frame>
</ScrollChild>
</ScrollFrame>
<!-- Footer for stats/info -->
<Frame name="$parent_Footer">
<Size>
<AbsDimension x="380" y="20"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT">
<Offset>
<AbsDimension x="20" y="15"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="ARTWORK">
<FontString name="$parent_Text" inherits="GameFontHighlightSmall" justifyH="LEFT">
<Anchors>
<Anchor point="LEFT"/>
</Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame name="$parent_MoneyFrame" inherits="SmallMoneyFrameTemplate">
<Anchors>
<Anchor point="BOTTOMRIGHT">
<Offset>
<AbsDimension x="-15" y="10"/>
</Offset>
</Anchor>
</Anchors>
</Frame>
<!-- Pagination -->
@@ -307,9 +264,9 @@
<AbsDimension x="60" y="22"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT">
<Anchor point="BOTTOM">
<Offset>
<AbsDimension x="120" y="10"/>
<AbsDimension x="-100" y="30"/>
</Offset>
</Anchor>
</Anchors>
@@ -325,9 +282,9 @@
<AbsDimension x="60" y="22"/>
</Size>
<Anchors>
<Anchor point="BOTTOMRIGHT" relativeTo="$parent_MoneyFrame" relativePoint="BOTTOMLEFT">
<Anchor point="BOTTOM">
<Offset>
<AbsDimension x="-10" y="0"/>
<AbsDimension x="100" y="30"/>
</Offset>
</Anchor>
</Anchors>
@@ -337,6 +294,28 @@
</OnClick>
</Scripts>
</Button>
<Frame name="$parent_Pagination">
<Size>
<AbsDimension x="130" y="22"/>
</Size>
<Anchors>
<Anchor point="BOTTOM">
<Offset>
<AbsDimension x="0" y="30"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="ARTWORK">
<FontString name="$parent_Text" inherits="GameFontHighlightSmall" justifyH="CENTER">
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
</Frames>
<Scripts>