From 12616d57d6c3df1c3a1a3ef62571ebefc5714a63 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 16:53:10 +0100 Subject: [PATCH] 0.1.153: Mailinglisten-Zeile ohne ueberlagerte Knoepfe, Rechtsklick auf Taschen-Item haengt es an den Brief an Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9 --- Freewood-OctoWoW-Mail.toc | 2 +- MailUI.lua | 62 ++++++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Freewood-OctoWoW-Mail.toc b/Freewood-OctoWoW-Mail.toc index 6f36fb5..ae19b6a 100644 --- a/Freewood-OctoWoW-Mail.toc +++ b/Freewood-OctoWoW-Mail.toc @@ -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.152 +## Version: 0.1.153 ## Dependencies: Freewood-OctoWoW-Core ## OptionalDeps: Freewood-OctoWoW-Creator, Freewood-OctoWoW-Brett diff --git a/MailUI.lua b/MailUI.lua index f9d756c..e43ca8e 100644 --- a/MailUI.lua +++ b/MailUI.lua @@ -23,6 +23,12 @@ local panes = {} local picks = {} -- Senden-Reiter: gewaehlte Staepel { id, count, key } local picker +-- Breite einer Zeile: aus dem Rahmen gelesen, nicht von der Kindbreite abhaengig (die ist beim ersten Zeichnen manchmal zu klein) +local function RowWidth(scroll, minW) + local w = scroll and scroll.GetWidth and scroll:GetWidth() or 0 + return math.max((w or 0) - 14, minW or 200) +end + local function T(key) return FW.L[key] or key end ------------------------------------------------------------------------ @@ -200,7 +206,7 @@ local function BuildPicker() local row = Row(i) row:ClearAllPoints() row:SetPoint("TOPLEFT", p.scroll.child, "TOPLEFT", 0, -((i - 1) * 36)) - row:SetPoint("TOPRIGHT", p.scroll.child, "TOPRIGHT", 0, -((i - 1) * 36)) + row:SetWidth(RowWidth(p.scroll)) FillItem(row, d.id, d.count) if d.extra then row.name:SetText(row.name:GetText() .. " |cff8a8f9a(" .. T("MAIL_PICK_EXTRA") .. ")|r") end if self.mode == "list" then @@ -330,7 +336,7 @@ local function BuildInbox(parent) row.inboxIndex = m.hasItem and m.i or nil row:ClearAllPoints() row:SetPoint("TOPLEFT", f.scroll.child, "TOPLEFT", 0, -((i - 1) * (ROW_H + ROW_GAP))) - row:SetPoint("TOPRIGHT", f.scroll.child, "TOPRIGHT", 0, -((i - 1) * (ROW_H + ROW_GAP))) + row:SetWidth(RowWidth(f.scroll)) if m.itemTex then row.icon:SetTexture(m.itemTex) elseif m.money > 0 then @@ -465,7 +471,7 @@ local function BuildSend(parent) end row:ClearAllPoints() row:SetPoint("TOPLEFT", itemScroll.child, "TOPLEFT", 0, -((i - 1) * 34)) - row:SetPoint("TOPRIGHT", itemScroll.child, "TOPRIGHT", 0, -((i - 1) * 34)) + row:SetWidth(RowWidth(itemScroll)) FillItem(row, pk.id, pk.count) row.remove:SetScript("OnClick", function() table.remove(picks, i) @@ -582,6 +588,8 @@ local function BuildLists(parent) row:SetHeight(LIST_ROW_H) row.name = UI.CreateLabel(row, "", { font = "heading", size = 14, color = "goldLight" }) row.name:SetPoint("TOPLEFT", row, "TOPLEFT", 12, -12) + row.name:SetWidth(170) + row.name:SetWordWrap(false) row.items = UI.CreateButton(row, "", 130, 24, function() if row.entry then OpenPicker("list", row.entry, function() f.Refresh() end) end end, "default") @@ -589,14 +597,14 @@ local function BuildLists(parent) row.now = UI.CreateButton(row, T("MAIL_LISTS_NOW"), 120, 24, function() if row.entry then Mail:SendLists(row.entry, false) end end, "default") - row.now:SetPoint("LEFT", row.items, "RIGHT", 8, 0) + row.now:SetPoint("TOPLEFT", row, "TOPLEFT", 328, -8) row.remove = UI.CreateButton(row, "X", 26, 24, function() if row.entry then Mail:RemoveList(row.entry) end end, "danger") - row.remove:SetPoint("TOPRIGHT", row, "TOPRIGHT", -8, -8) + row.remove:SetPoint("TOPLEFT", row, "TOPLEFT", 456, -8) UI.AttachTooltip(row.remove, function() return T("MAIL_LISTS_REMOVE") end, "") row.selfNote = UI.CreateLabel(row, T("MAIL_LISTS_SELF"), { size = 11, color = "textDim" }) - row.selfNote:SetPoint("LEFT", row.items, "RIGHT", 8, 0) + row.selfNote:SetPoint("TOPLEFT", row, "TOPLEFT", 328, -13) row.auto = UI.CreateCheckbox(row, T("MAIL_LISTS_AUTO"), function() return row.entry and row.entry.auto end, function(v) if row.entry then row.entry.auto = v and true or false end @@ -626,7 +634,7 @@ local function BuildLists(parent) row.entry = e row:ClearAllPoints() row:SetPoint("TOPLEFT", scroll.child, "TOPLEFT", 0, -((i - 1) * (LIST_ROW_H + ROW_GAP))) - row:SetPoint("TOPRIGHT", scroll.child, "TOPRIGHT", 0, -((i - 1) * (LIST_ROW_H + ROW_GAP))) + row:SetWidth(RowWidth(scroll, 495)) row.name:SetText(e.name) row.items:SetLabel(string.format(T("MAIL_LISTS_ITEMS"), #e.ids)) local me = Mail.IsSelf(e.name) @@ -749,6 +757,46 @@ local function BuildWindow() return f end +-- Rechtsklick auf ein Item in den Taschen: wird dem Brief angehaengt (nur bei unserem Fenster; sonst waere es "benutzen") +local function StackKey(bag, slot) + local seen = {} + for _, s in ipairs(Mail.BagStacks()) do + if not s.locked then + local base = s.id .. ":" .. s.count + seen[base] = (seen[base] or 0) + 1 + if s.bag == bag and s.slot == slot then return s.id, s.count, base .. ":" .. seen[base] end + end + end +end + +local function Intercept(bag, slot) + if not (Mail.open and Mail.Replacing() and window and window:IsShown()) then return false end + if CursorHasItem and CursorHasItem() then return false end + if Mail.busy then return true end + local id, count, key = StackKey(tonumber(bag), tonumber(slot)) + if not id then return true end + local found + for k, pk in ipairs(picks) do + if pk.key == key then found = k end + end + if found then table.remove(picks, found) else picks[#picks + 1] = { id = id, count = count, key = key } end + SelectTab("send") + if picker and picker:IsShown() then picker:Fill() end + return true +end + +local function WrapUse(owner, name) + local orig = owner and owner[name] + if type(orig) ~= "function" then return end + owner[name] = function(bag, slot, ...) + local ok, handled = pcall(Intercept, bag, slot) + if ok and handled then return end + return orig(bag, slot, ...) + end +end +WrapUse(_G, "UseContainerItem") +if _G.C_Container then WrapUse(_G.C_Container, "UseContainerItem") end + local function RefreshCurrent() local pane = panes[current] if window and window:IsShown() and pane and pane.Refresh then pane.Refresh() end