fix: pagination
This commit is contained in:
+9
-23
@@ -114,6 +114,7 @@ function MailboxFrame:Update()
|
|||||||
|
|
||||||
-- Filter items based on search text
|
-- Filter items based on search text
|
||||||
local filteredItems = {}
|
local filteredItems = {}
|
||||||
|
local totalItems = table.getn(mailboxData)
|
||||||
for i, mail in ipairs(mailboxData) do
|
for i, mail in ipairs(mailboxData) do
|
||||||
local matchesSearch = true
|
local matchesSearch = true
|
||||||
if searchText ~= "" then
|
if searchText ~= "" then
|
||||||
@@ -158,27 +159,11 @@ function MailboxFrame:Update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Display items
|
-- Display items
|
||||||
self:DisplayItems(filteredItems, charFullName)
|
self:DisplayItems(filteredItems, charFullName, totalItems)
|
||||||
|
|
||||||
-- 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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Display mailbox items in a list
|
-- Display mailbox items in a list
|
||||||
function MailboxFrame:DisplayItems(items, charFullName)
|
function MailboxFrame:DisplayItems(items, charFullName, totalMails)
|
||||||
local container = getglobal("Guda_MailboxFrame_ItemContainer")
|
local container = getglobal("Guda_MailboxFrame_ItemContainer")
|
||||||
|
|
||||||
-- Hide all existing rows first
|
-- Hide all existing rows first
|
||||||
@@ -260,7 +245,7 @@ function MailboxFrame:DisplayItems(items, charFullName)
|
|||||||
end
|
end
|
||||||
if itemButton.qualityBorder then itemButton.qualityBorder:Hide() end
|
if itemButton.qualityBorder then itemButton.qualityBorder:Hide() end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Row Money Frame
|
-- Row Money Frame
|
||||||
local moneyFrame = getglobal(row:GetName() .. "_MoneyFrame")
|
local moneyFrame = getglobal(row:GetName() .. "_MoneyFrame")
|
||||||
if (mail.money or 0) > 0 then
|
if (mail.money or 0) > 0 then
|
||||||
@@ -290,10 +275,11 @@ function MailboxFrame:DisplayItems(items, charFullName)
|
|||||||
nextBtn:Disable()
|
nextBtn:Disable()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update page text in footer
|
-- Update pagination text
|
||||||
local footerFontString = getglobal("Guda_MailboxFrame_Footer_Text")
|
local paginationText = getglobal("Guda_MailboxFrame_Pagination_Text")
|
||||||
local footerText = footerFontString:GetText() or ""
|
if paginationText then
|
||||||
footerFontString:SetText(footerText .. " (Page " .. currentPage .. " of " .. totalPages .. ")")
|
paginationText:SetText(string.format("%d/%d (items: %d)", currentPage, totalPages, totalMails or 0))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Search text changed
|
-- Search text changed
|
||||||
|
|||||||
+28
-49
@@ -244,8 +244,8 @@
|
|||||||
</Scripts>
|
</Scripts>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- Scroll Frame for Items -->
|
<!-- Item Container -->
|
||||||
<ScrollFrame name="$parent_ScrollFrame" inherits="UIPanelScrollFrameTemplate">
|
<Frame name="Guda_MailboxFrame_ItemContainer">
|
||||||
<Size>
|
<Size>
|
||||||
<AbsDimension x="360" y="420"/>
|
<AbsDimension x="360" y="420"/>
|
||||||
</Size>
|
</Size>
|
||||||
@@ -256,49 +256,6 @@
|
|||||||
</Offset>
|
</Offset>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Anchors>
|
</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>
|
</Frame>
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
@@ -307,9 +264,9 @@
|
|||||||
<AbsDimension x="60" y="22"/>
|
<AbsDimension x="60" y="22"/>
|
||||||
</Size>
|
</Size>
|
||||||
<Anchors>
|
<Anchors>
|
||||||
<Anchor point="BOTTOMLEFT">
|
<Anchor point="BOTTOM">
|
||||||
<Offset>
|
<Offset>
|
||||||
<AbsDimension x="120" y="10"/>
|
<AbsDimension x="-100" y="30"/>
|
||||||
</Offset>
|
</Offset>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Anchors>
|
</Anchors>
|
||||||
@@ -325,9 +282,9 @@
|
|||||||
<AbsDimension x="60" y="22"/>
|
<AbsDimension x="60" y="22"/>
|
||||||
</Size>
|
</Size>
|
||||||
<Anchors>
|
<Anchors>
|
||||||
<Anchor point="BOTTOMRIGHT" relativeTo="$parent_MoneyFrame" relativePoint="BOTTOMLEFT">
|
<Anchor point="BOTTOM">
|
||||||
<Offset>
|
<Offset>
|
||||||
<AbsDimension x="-10" y="0"/>
|
<AbsDimension x="100" y="30"/>
|
||||||
</Offset>
|
</Offset>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Anchors>
|
</Anchors>
|
||||||
@@ -337,6 +294,28 @@
|
|||||||
</OnClick>
|
</OnClick>
|
||||||
</Scripts>
|
</Scripts>
|
||||||
</Button>
|
</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>
|
</Frames>
|
||||||
|
|
||||||
<Scripts>
|
<Scripts>
|
||||||
|
|||||||
Reference in New Issue
Block a user