0.1.218: Mail: Posteingang in 7er-Paketen mit Ladebalken (Absturz bei viel Post)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
Lacustat
2026-11-01 09:51:50 +01:00
co-authored by Claude Sonnet 5.5
parent 75e564388c
commit fece5d4148
4 changed files with 79 additions and 3 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
## Notes: Own mailbox window: open all or selected mails safely, recent recipients, mailing lists with automatic sending, multi-item mails, gold surplus and cash on delivery.
## Notes-deDE: Eigenes Briefkasten-Fenster: alles oder Ausgewähltes sicher öffnen, letzte Empfänger, Mailinglisten mit Automatik, mehrere Items, Gold-Überschuss und Nachnahme.
## Author: Lacustat
## Version: 0.1.217
## Version: 0.1.218
## Dependencies: Freewood-OctoWoW-Core
## OptionalDeps: Freewood-OctoWoW-Creator, Freewood-OctoWoW-Brett
+4
View File
@@ -22,6 +22,8 @@ FW:AddLocale("enUS", {
MAIL_SELECT_ALL = "Select all",
MAIL_SELECT_NONE = "Select none",
MAIL_INBOX_EMPTY = "The inbox is empty.",
MAIL_LOADING = "Fetching mail ... %d / %d",
MAIL_LOADING_WAIT = "The mail is still being fetched. Please wait a moment.",
MAIL_ROW_GOLD = "Gold: %s",
MAIL_ROW_COD = "Cash on delivery: %s (not taken)",
MAIL_ROW_LETTER = "Letter only (not touched)",
@@ -177,6 +179,8 @@ FW:AddLocale("deDE", {
MAIL_SELECT_ALL = "Alle auswählen",
MAIL_SELECT_NONE = "Keine auswählen",
MAIL_INBOX_EMPTY = "Der Posteingang ist leer.",
MAIL_LOADING = "Post wird geholt ... %d / %d",
MAIL_LOADING_WAIT = "Die Post wird noch geholt. Bitte einen Moment warten.",
MAIL_ROW_GOLD = "Gold: %s",
MAIL_ROW_COD = "Nachnahme: %s (wird nicht genommen)",
MAIL_ROW_LETTER = "Nur ein Brief (bleibt unberührt)",
+44 -2
View File
@@ -230,11 +230,49 @@ end
------------------------------------------------------------------------
-- Liste der Briefe: { i, sender, subject, money, cod, days, hasItem, itemName, itemTex, itemCount, sig, key, take, why }
-- Grosse Postfaecher werden in Haeppchen eingelesen (wie die Seiten des Spiels: 7 je Schritt, mit Pause), sonst haengt der Client.
local CHUNK, LOAD_GAP = 7, 0.45
local function InboxCount()
if not GetInboxNumItems then return 0 end
local ok, n = pcall(GetInboxNumItems)
return (ok and tonumber(n)) or 0
end
Mail.InboxCount = InboxCount
-- Rueckgabe: laedt noch?, geladen, gesamt
function Mail.Loading()
local n = InboxCount()
if n <= CHUNK then return false, n, n end
local L = math.min(n, Mail.loadedN or CHUNK)
return L < n, L, n
end
function Mail:StartLoader()
if not self.loader then
self.loader = CreateFrame("Frame")
local acc = 0
self.loader:SetScript("OnUpdate", function(f, elapsed)
acc = acc + (elapsed or 0)
if acc < LOAD_GAP then return end
acc = 0
if not Mail.open then f:Hide() return end
local loading = Mail.Loading()
if loading then
Mail.loadedN = (Mail.loadedN or CHUNK) + CHUNK
FW:Fire("MAIL_INBOX_CHANGED")
end
if not Mail.Loading() then f:Hide() FW:Fire("MAIL_INBOX_CHANGED") end
end)
end
if Mail.Loading() then self.loader:Show() else self.loader:Hide() end
end
function Mail.ReadInbox()
local list = {}
if not GetInboxNumItems then return list end
local ok, n = pcall(GetInboxNumItems)
n = (ok and tonumber(n)) or 0
local n = InboxCount()
if n > CHUNK then n = math.min(n, Mail.loadedN or CHUNK) end
local seen = {}
for i = 1, n do
local ok1, _, _, sender, subject, money, cod, days, hasItem, wasRead, wasReturned, _, canReply = pcall(GetInboxHeaderInfo, i)
@@ -541,6 +579,7 @@ end
-- onlySelected: nur angehakte Briefe
function Mail:StartOpen(onlySelected)
if self.busy or not self.open then return false end
if Mail.Loading() then Say(FW.L.MAIL_LOADING_WAIT) return false end
local only
if onlySelected then
only = {}
@@ -1005,6 +1044,8 @@ function Mail:OnMailShow()
self.gen = self.gen + 1
self.boardTries, self.boardAutoAt, self.boardSending = 0, nil, nil
self.selected = {}
self.loadedN = CHUNK
self:StartLoader()
self:ApplyReplace()
Trace("Briefkasten geoeffnet")
if self.Replacing() then FW:Fire("MAIL_WINDOW_SHOW") end
@@ -1023,6 +1064,7 @@ end
function Mail:OnInboxUpdate()
if self.run then self.run.updated = true end
if self.open and Mail.Loading() and (not self.loader or not self.loader:IsShown()) then self:StartLoader() end
FW:Fire("MAIL_INBOX_CHANGED")
end
+30
View File
@@ -317,6 +317,28 @@ local function BuildInbox(parent)
f.scroll:SetPoint("TOPLEFT", f, "TOPLEFT", 0, -70)
f.scroll:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", 0, 36)
f.scroll:SetWidth(LIST_W)
-- Ladebalken ueber dem Postfach, solange grosse Postfaecher in Haeppchen geholt werden
f.load = CreateFrame("Frame", nil, f)
f.load:SetPoint("TOPLEFT", f, "TOPLEFT", 0, -70)
f.load:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", 0, 36)
f.load:SetWidth(LIST_W)
f.load:SetFrameLevel((f.scroll:GetFrameLevel() or 1) + 20)
f.load:EnableMouse(true)
f.load.bg = f.load:CreateTexture(nil, "BACKGROUND")
f.load.bg:SetAllPoints(f.load)
f.load.bg:SetColorTexture(0.02, 0.02, 0.04, 0.82)
f.load.text = UI.CreateLabel(f.load, "", { size = 12, color = "goldLight", justify = "CENTER" })
f.load.text:SetPoint("CENTER", f.load, "CENTER", 0, 14)
f.load.track = f.load:CreateTexture(nil, "ARTWORK")
f.load.track:SetPoint("CENTER", f.load, "CENTER", 0, -8)
f.load.track:SetWidth(LIST_W - 40)
f.load.track:SetHeight(10)
f.load.track:SetColorTexture(0.15, 0.13, 0.08, 1)
f.load.fill = f.load:CreateTexture(nil, "OVERLAY")
f.load.fill:SetPoint("LEFT", f.load.track, "LEFT", 0, 0)
f.load.fill:SetHeight(10)
f.load.fill:SetColorTexture(0.9, 0.7, 0.25, 1)
f.load:Hide()
f.empty = UI.CreateLabel(f.scroll.child, T("MAIL_INBOX_EMPTY"), { size = 12, color = "textDim" })
f.empty:SetPoint("TOPLEFT", f.scroll.child, "TOPLEFT", 4, -6)
@@ -546,6 +568,14 @@ local function BuildInbox(parent)
end
function f.Refresh()
local loading, done, total = Mail.Loading()
if loading then
f.load.text:SetText(string.format(T("MAIL_LOADING"), done, total))
f.load.fill:SetWidth(math.max(1, (LIST_W - 40) * done / math.max(total, 1)))
f.load:Show()
else
f.load:Hide()
end
local list = Mail.ReadInbox()
local busy = Mail.busy
local takeable = 0