From 04d3585f718e418dd99188a2e2c98b3e86972dec Mon Sep 17 00:00:00 2001 From: con1338 Date: Sat, 21 Nov 2026 20:34:44 +0100 Subject: [PATCH 1/2] Bags: the bag window never runs the game's bag code (F24) After a visit to the bank every right-click use from the bags was blocked until a reload ("Forbidden ... ContainerFrame.lua:1611"): the hearthstone, keys, recipes and putting items into the trade window. A check in the game found BankFrame.BankPanel.bankType tainted by EldoUI. ContainerFrameItemButton_OnClick hands that bank type to UseContainerItem on every right-click, and the bank's OnShow sets it only after OpenAllBags(self). EldoUI had written what that bag code reads: its bag window called CloseAllBags() when it closed (which writes FRAME_THAT_OPENED_BAGS), and its own opens built the game's bag frames. The vendor's tab was tainted the same way. While the game's bag frames sit on EldoUI's hidden parent, EldoUI now closes them by hiding them (they run no scripts there) and opens only its own window. That window stays open until the player closes it (close button, Escape, B, a bag block), also through a bank or vendor visit. The Info Bar's bag blocks and the flight view's Bags button go through the Bags module. With the game's bags shown, the game's functions are used as before. - review/fehler.md: F24 with cause, change and checks in the game. - tools/bags/test_game_bag_code.lua: the real helpers, CloseWindow, SyncOpen and the ToggleAllBags hook against a model of the parked frames, plus a text check for direct calls. - Entry in both changelogs; UpdateNewItemList in tools/ci/globals.lua. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 + EldoUI/CHANGELOG.md | 6 + EldoUI/Modules/Bags/Core.lua | 140 +++++++++++++-- EldoUI/Modules/InfoBar.lua | 18 +- EldoUI/Modules/QoL/FlightView.lua | 7 +- review/fehler.md | 51 ++++++ tools/bags/test_game_bag_code.lua | 286 ++++++++++++++++++++++++++++++ tools/ci/check_all.sh | 2 + tools/ci/globals.lua | 1 + 9 files changed, 501 insertions(+), 16 deletions(-) create mode 100644 tools/bags/test_game_bag_code.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index a0da7f3..07e9fca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,12 @@ The in-game **What's New** page (`/eui whatsnew`) shows the highlights of each v - Fishing's Only the splash turns every other sound off while fishing: music, ambience, dialog, emote, pet and ping sounds. The sound effects with the splash stay on, and your own settings come back when fishing mode ends. +### Bags and loot + +#### Fixed + +- Right-clicking an item in EldoUI's bag window to use it (hearthstone, keys, recipes, or to put it into the trade window) is no longer blocked until a reload after a visit to the bank. EldoUI's bag window no longer runs the game's own bag code: bags opened from the Info Bar, with /eui find or with another window stay open until you close them. + ## [0.7.3005] - 2026-11-18 ### Setup and profiles diff --git a/EldoUI/CHANGELOG.md b/EldoUI/CHANGELOG.md index a0da7f3..07e9fca 100644 --- a/EldoUI/CHANGELOG.md +++ b/EldoUI/CHANGELOG.md @@ -12,6 +12,12 @@ The in-game **What's New** page (`/eui whatsnew`) shows the highlights of each v - Fishing's Only the splash turns every other sound off while fishing: music, ambience, dialog, emote, pet and ping sounds. The sound effects with the splash stay on, and your own settings come back when fishing mode ends. +### Bags and loot + +#### Fixed + +- Right-clicking an item in EldoUI's bag window to use it (hearthstone, keys, recipes, or to put it into the trade window) is no longer blocked until a reload after a visit to the bank. EldoUI's bag window no longer runs the game's own bag code: bags opened from the Info Bar, with /eui find or with another window stay open until you close them. + ## [0.7.3005] - 2026-11-18 ### Setup and profiles diff --git a/EldoUI/Modules/Bags/Core.lua b/EldoUI/Modules/Bags/Core.lua index 610422e..10ff0e9 100644 --- a/EldoUI/Modules/Bags/Core.lua +++ b/EldoUI/Modules/Bags/Core.lua @@ -2052,7 +2052,9 @@ function M:CreateWindow(kind) if M.db.clearSearch and search:GetText() ~= "" then search:SetText("") end if not isBank then if M.db.newGlow and C_NewItems and C_NewItems.ClearAll then C_NewItems.ClearAll() end - if M:AnyBagOpen() then CloseAllBags() end + window.eldoOnly = nil + -- Never the game's CloseAllBags() from here (F24, M:CloseGameBags). + if M:AnyBagOpen() then M:CloseGameBags() end elseif bankOpen and not M.showingBlizzardBank then local closeBank = (C_Bank and C_Bank.CloseBankFrame) or CloseBankFrame if closeBank then closeBank() end @@ -3336,6 +3338,94 @@ function M:OwnBank() return self.active and E:BlizzardAllowed(BANK_ID, "replace") end +--------------------------------------------------------------------------- +-- The game's bag code stays the game's (review/fehler.md F24) +-- +-- Blizzard's bank and vendor windows call OpenAllBags(self) when they open, +-- before they choose their tab. If anything that bag code reads was written +-- by EldoUI, the rest of their OnShow runs tainted, and so does the bank tab +-- it stores (BankFrame.BankPanel.bankType). Every right-click on an item in +-- the bags hands that tab to C_Container.UseContainerItem +-- (ContainerFrameItemButton_OnClick), so the hearthstone, keys and recipes +-- were blocked ("Forbidden") until a reload. EldoUI wrote it two ways: +-- CloseAllBags() writes FRAME_THAT_OPENED_BAGS, and an open from EldoUI's +-- code builds the game's bag frames (ContainerFrame_GenerateFrame and its +-- settings manager). +-- So while the game's bag frames sit on EldoUI's hidden parent, EldoUI's +-- own code never runs that code: it closes the frames by hiding them (on +-- the hidden parent they run no scripts, the same as the game's close +-- there), and it opens only its own window. That window (window.eldoOnly) +-- stays open until the player closes it: its close button, Escape, the +-- game's bag toggle (B) or a bag block. With the game's frames shown, the +-- game's functions are used as before. +--------------------------------------------------------------------------- +function M:GameBagsParked() + local frames = BlizzardBagFrames() + if #frames == 0 then return false end + for _, frame in ipairs(frames) do + if frame:GetParent() ~= hider then return false end + end + return true +end + +-- Closes the game's bag frames for EldoUI. `frame` is the window that +-- closes them (CloseAllBags(frame)) when the game's frames are shown. +function M:CloseGameBags(frame) + if not self:GameBagsParked() then + CloseAllBags(frame) + return + end + -- What the CloseAllBags hook does for a close without a window. + if not frame and self.ForgetAutoOpen then self:ForgetAutoOpen() end + for _, bagFrame in ipairs(BlizzardBagFrames()) do + if bagFrame:IsShown() then + -- What the game's close does besides hiding: the items lose their + -- "new" mark (C_NewItems only, nothing of the game's is written). + if type(UpdateNewItemList) == "function" and bagFrame.EnumerateValidItems then + pcall(UpdateNewItemList, bagFrame) + end + bagFrame:Hide() + end + end +end + +-- Opens the bags from EldoUI's code (a slash command, the tour, a window's +-- event, a bag block): the game's own open while its frames are shown, +-- else only EldoUI's window. +function M:OpenBags() + local window = windows.bags + if not (window and self:OwnBags() and self:GameBagsParked()) then + OpenAllBags() + return + end + if not self:AnyBagOpen() then window.eldoOnly = true end + if not window:IsShown() then window.viewChar = E.charKey end + self:OpenWindow(window, self:WindowSide(window)) +end + +-- Closes them again: EldoUI's window when it opened alone, and the game's +-- frames. +function M:CloseBags() + local window = windows.bags + if window and window.eldoOnly and window:IsShown() then + self:CloseWindow(window) + else + self:CloseGameBags() + end +end + +-- The bag blocks of the info bar and the flight view's Bags button. +function M:ToggleBags() + local window = windows.bags + if not (window and self:OwnBags() and self:GameBagsParked()) then + ToggleAllBags() + elseif window:IsShown() then + self:CloseWindow(window) + else + self:OpenBags() + end +end + --------------------------------------------------------------------------- -- Tour help: the bag window explains itself once, after it has stayed -- open a moment (bags are often opened in a hurry). @@ -3372,7 +3462,7 @@ E.Tour:Register("bags:first", { E:Print(L["The bags tour runs in EldoUI's bag window: Blizzard UI > Bags (container windows) > Replace with EldoUI's frame."]) return end - if not (windows.bags and windows.bags:IsShown()) then OpenAllBags() end + if not (windows.bags and windows.bags:IsShown()) then M:OpenBags() end C_Timer.After(1, function() def.offer(def, true) end) end, }) @@ -3399,7 +3489,8 @@ end function M:CloseWindow(window) if window.kind == "bags" then - CloseAllBags() + window.eldoOnly = nil + self:CloseGameBags() end if window:IsShown() then E:SlideOut(window, self:WindowSide(window)) end end @@ -3416,7 +3507,10 @@ function M:SyncOpen() window.viewChar = E.charKey self:OpenWindow(window, self:WindowSide(window)) end - elseif window:IsShown() then + elseif window:IsShown() and not window.eldoOnly then + -- A window EldoUI opened alone (M:OpenBags) stays until the player + -- closes it, like bags that were open before a bank or vendor + -- opened and closed them. window.search:ClearFocus() E:SlideOut(window, self:WindowSide(window)) end @@ -3523,7 +3617,9 @@ end -- is off closes the bags it just opened, one whose "close" setting is off -- opens them again. Trade, the guild bank and the profession window don't -- open bags in the game; for them EldoUI opens the bags on the window's --- event and closes them again only if it opened them. +-- event and closes them again only if it opened them. EldoUI opens and +-- closes through M:OpenBags / M:CloseGameBags, never the game's bag code +-- while its own window replaces the game's (F24). -- Only the bags are opened or closed, never the other window, and nothing -- happens without the player opening that window. --------------------------------------------------------------------------- @@ -3572,7 +3668,7 @@ function M:HookAutoBags() openedBy = kind else openedBy = nil - CloseAllBags(frame) + M:CloseGameBags(frame) end end) hooksecurefunc("CloseAllBags", function(frame) @@ -3585,7 +3681,7 @@ function M:HookAutoBags() local kind = FRAME_KIND[frame:GetName() or ""] if not kind or openedBy ~= kind then return end openedBy = nil - if not M.db.autoClose[kind] then OpenAllBags() end + if not M.db.autoClose[kind] then M:OpenBags() end end) -- The player closing the bags by hand ends "opened by" as well. local function Toggled() @@ -3595,18 +3691,25 @@ function M:HookAutoBags() if ToggleBackpack then hooksecurefunc("ToggleBackpack", Toggled) end end +-- EldoUI closed the bags (its window, combat): like the game's +-- CloseAllBags() above, nothing is kept (M:CloseGameBags). +function M:ForgetAutoOpen() + openedBy, eventOpened = nil, nil +end + function M:OnAutoBagEvent(event) local entry = EVENT_KIND[event] if not (entry and self:AutoBagsAllowed()) then return end local kind, shown = entry[1], entry[2] if shown then - if self.db.autoOpen[kind] and not AnyOpen() then - OpenAllBags() + local window = windows.bags + if self.db.autoOpen[kind] and not AnyOpen() and not (window and window:IsShown()) then + self:OpenBags() eventOpened = kind end elseif eventOpened == kind then eventOpened = nil - if self.db.autoClose[kind] then CloseAllBags() end + if self.db.autoClose[kind] then self:CloseBags() end end end @@ -3620,7 +3723,7 @@ function M:CloseForCombat() for _, animation in pairs(window.eldoAnim or {}) do animation:Stop() end window:Hide() end - if AnyOpen() then CloseAllBags() end + if AnyOpen() then self:CloseGameBags() end end function M:EnableAutoBags() @@ -3663,6 +3766,19 @@ local function HookBagFrames() hooksecurefunc(frame, "Hide", Sync) hooksecurefunc(frame, "SetShown", Sync) end + -- A window EldoUI opened alone (M:OpenBags): the game's bag toggle (B) + -- either opened the game's frames or closed the ones a bank or vendor + -- opened, but the player meant to close the window. Whatever is open + -- closes, and the window follows (SyncOpen). Only ToggleAllBags: the + -- game's own opens call ToggleBackpack too (OpenBackpack). + if ToggleAllBags then + hooksecurefunc("ToggleAllBags", function() + local window = windows.bags + if not (window and window.eldoOnly) then return end + window.eldoOnly = nil + if window:IsShown() and M:OwnBags() then M:CloseGameBags() end + end) + end end M.HookBagFrames = HookBagFrames @@ -4310,7 +4426,7 @@ function M:Find(text) window.viewChar = E.charKey window.allChars = true M.SetRailActive(window.allButton, true) - if not window:IsShown() then OpenAllBags() end + if not window:IsShown() then self:OpenBags() end window.search:SetText(text) self:OpenWindow(window, self:WindowSide(window)) return diff --git a/EldoUI/Modules/InfoBar.lua b/EldoUI/Modules/InfoBar.lua index f6c4e7c..392b931 100644 --- a/EldoUI/Modules/InfoBar.lua +++ b/EldoUI/Modules/InfoBar.lua @@ -199,6 +199,18 @@ local function DB() return M.db or M.defaults end +-- The bag blocks open and close the bags through the Bags module, which +-- keeps the game's bag code out of EldoUI's code while its bag window +-- replaces the game's (review/fehler.md F24). Without it, the game's toggle. +function M.ToggleBags() + local bags = E.modules.Bags + if bags and bags.ToggleBags then + bags:ToggleBags() + elseif ToggleAllBags then + ToggleAllBags() + end +end + local function Hex(r, g, b) return ("|cff%02x%02x%02x"):format(r * 255, g * 255, b * 255) end @@ -516,7 +528,7 @@ E:RegisterDataText("Gold", { alts:Toggle("overview") return end - ToggleAllBags() + M.ToggleBags() end, }) @@ -566,7 +578,7 @@ E:RegisterDataText("Bags", { combatClick = true, hint = { Key("Click"), Key("open your bags") }, onClick = function() - ToggleAllBags() + M.ToggleBags() end, }) @@ -1919,7 +1931,7 @@ E:RegisterDataText("Ammo", { -- Opens a normal game window: works in combat too. combatClick = true, onClick = function() - if ToggleAllBags then ToggleAllBags() end + M.ToggleBags() end, }) diff --git a/EldoUI/Modules/QoL/FlightView.lua b/EldoUI/Modules/QoL/FlightView.lua index c55cac8..b5eb8e8 100644 --- a/EldoUI/Modules/QoL/FlightView.lua +++ b/EldoUI/Modules/QoL/FlightView.lua @@ -95,7 +95,12 @@ local function BuildPanel(panel, preview) onClick = function() M:LandEarly() end }) panel.land:SetPoint("RIGHT", panel.exit, "LEFT", -8, 0) panel.bags = Kit.Button(panel, { text = L["Bags"], width = width, - onClick = function() M:CloseFlightView("bags") if ToggleAllBags then ToggleAllBags() end end }) + onClick = function() + M:CloseFlightView("bags") + -- Through the Bags module: the game's bag code stays the game's (F24). + local bags = E.modules.Bags + if bags and bags.ToggleBags then bags:ToggleBags() elseif ToggleAllBags then ToggleAllBags() end + end }) panel.bags:SetPoint("BOTTOM", panel.exit, "TOP", 0, 8) -- The map opens through the game's own map button (Kit.GameButton), so -- the game opens it; without that button, through the game's own map diff --git a/review/fehler.md b/review/fehler.md index 6859651..731cef0 100644 --- a/review/fehler.md +++ b/review/fehler.md @@ -31,6 +31,7 @@ plausibel = hängt von API-Verhalten ab, das sich ohne Spiel nicht prüfen läss | F21 | Angeln: Das Fangprotokoll bleibt bei 0 (im Spiel gefunden) | niedrig–mittel | behoben | `cfebaee` | | F22 | Auktionshaus: Verkaufen-Seite bleibt nach „Schnellverkauf“ leer; Rechtsklick in die Taschen verboten (im Spiel gefunden) | mittel | teilweise | `391f0b7` | | F23 | Gilden-Tooltip der Infoleiste fragt im Kampf die Gildennachricht ab → ADDON_ACTION_BLOCKED (im Fehlerlog gefunden) | niedrig | behoben | `bb28608` | +| F24 | Nach einem Bankbesuch ist jeder Rechtsklick zum Benutzen aus den Taschen verboten, bis zum Reload (im Spiel gefunden) | hoch | behoben (im Spiel offen) | | **Prüfung der Änderungen:** `luac5.1 -p` über alle 626 Dateien fehlerfrei; luacheck zeigt gegenüber dem Originalstand keine neue Warnung (259 vor und nach den Änderungen, ohne W113/W212); kein neuer unbekannter @@ -544,6 +545,53 @@ Geprüft wurde jeder Fix gegen den Code von 0.7.3005 (nicht im Spiel). Nur sechs - Gegenprobe: Ohne die Kampfprüfung ruft der Tooltip im Kampf die gesperrte Funktion auf, wie im Fehlerlog. - **Im Spiel prüfen:** siehe Tabelle unten. +### F24 – Nach einem Bankbesuch ist jeder Rechtsklick zum Benutzen aus den Taschen verboten (hoch, im Spiel gefunden) +- **Gefunden:** 20./21.11.2026 beim Spielen. Ein Silberdietrich ließ sich per Rechtsklick nicht ins Handelsfenster legen, + danach ging bis zum `/reload` kein Rechtsklick mehr (Ruhestein, später ein Kochrezept in Donnerfels). Im Fehlerlog + derselbe Eintrag wie bei F22: „Forbidden: EldoUI tried to call the protected function UNKNOWN() at + Blizzard_UIPanels_Game/Mainline/ContainerFrame.lua:1611“ (`UseContainerItem` aus `ContainerFrameItemButton_OnClick`), + inzwischen 157-mal, 15.11. bis 21.11., immer außerhalb des Kampfes. Profil: Taschen und Bank „Ersetzen“. +- **Vorgehen:** Blizzards Code aus Gethe/wow-ui-source, Zweig `forever` (Client 1.60.1, Build 70959: `Mainline`-Taschen, + `Camelot`-Bank). Im gesperrten Zustand haben Prüfzeilen im Spiel `issecurevariable` für jeden Wert im Rechtsklick-Pfad + abgefragt und das Ergebnis in `EldoUIErrorsDB` gespeichert. Verunreinigt von EldoUI waren nur `BankFrame.currentBankPage`, + `BankFrame.BankPanel.purchasedBankTabData`, `BankFrame.BankPanel.bankType` sowie `MerchantFrame.selectedTab` und + `MerchantFrame.itemIndex`. Die Taschenknöpfe selbst waren sauber. +- **Ursache:** `ContainerFrameItemButton_OnClick` übergibt `BankFrame:GetActiveBankType()` an `UseContainerItem`, bei + jedem Rechtsklick und auch bei geschlossener Bank (das `BankPanel` bleibt nach dem ersten Bankbesuch „gezeigt“). Den + Bank-Typ setzt Blizzard in `BankFrameBaseMixin:OnShow`, aber erst *nach* `OpenAllBags(self)`. Hatte EldoUI vorher etwas + geschrieben, das Blizzards Taschencode dort liest, läuft der Rest von `OnShow` verunreinigt, und alle drei Bank-Werte + oben sind von EldoUI. Ab dann ist jedes Benutzen aus den Taschen verboten. Das Herausholen aus der Bank ist nicht + geschützt, deshalb fiel es dort nicht auf. EldoUI schrieb diese Werte auf zwei Wegen: + - Sein Taschenfenster rief beim Schließen (X, Escape, `CloseWindow`, Kampfbeginn) Blizzards `CloseAllBags()` auf. Das + setzt `FRAME_THAT_OPENED_BAGS`, und `OpenAllBags(self)` der Bank liest genau diesen Wert. + - Öffnen aus EldoUIs Code (`/eui find`, Tour, Taschen mit Handel, Gildenbank und Beruf öffnen, Infoleiste, Flugansicht) + rief `OpenAllBags`/`ToggleAllBags` auf. Das baut Blizzards Taschenrahmen samt `ContainerFrameSettingsManager`. + `MerchantFrame_OnShow` ruft ebenso zuerst `OpenAllBags(self, true)` und setzt danach seinen Tab. Daher der verunreinigte + Händler-Tab. Das Auktionshaus öffnet die Taschen genauso. Das könnte auch den noch offenen Teil von F22 erklären. +- **Umsetzung:** `Modules/Bags/Core.lua`. Solange Blizzards Taschenrahmen auf EldoUIs verstecktem Elternrahmen liegen + (`M:GameBagsParked`, Taschen „Ersetzen“ oder „Ausblenden“), ruft EldoUI Blizzards Taschencode nicht mehr selbst auf. + - `M:CloseGameBags` versteckt die Rahmen nur. Auf dem versteckten Elternrahmen laufen ohnehin keine Skripte. Wie bei + Blizzard verlieren die Gegenstände ihre „Neu“-Markierung (`UpdateNewItemList`, nur `C_NewItems`). + - `M:OpenBags` öffnet nur EldoUIs Fenster (`window.eldoOnly`). Es bleibt offen, bis der Spieler es schließt: X, Escape, + B (Haken an `ToggleAllBags`) oder ein Taschen-Block. Auch wenn eine Bank oder ein Händler die Taschen öffnet und + wieder schließt, bleibt es offen, wie vorher bei schon offenen Taschen. + - `M:CloseBags` und `M:ToggleBags` sind die Gegenstücke. Infoleiste (Gold, Taschen, Munition) und der Taschen-Knopf der + Flugansicht laufen über `M:ToggleBags`. + - Mit sichtbaren Blizzard-Taschen (Taschen nicht ersetzt) ruft EldoUI wie bisher Blizzards Funktionen auf. Dort bleibt + das Risiko bestehen (offen). +- **Nicht erklärt:** Laut dem Spieler war der Rechtsklick ins Handelsfenster gleich nach einem `/reload` erneut gesperrt. + Nach einem Reload ist der Bank-Typ sauber. Ob dazwischen die Bank offen war, ist nicht bekannt. +- **Test:** `tools/bags/test_game_bag_code.lua` (läuft in `tools/ci/check_all.sh tests`). Er schneidet die Helfer, + `CloseWindow`, `SyncOpen` und den `ToggleAllBags`-Haken aus `Core.lua` und lässt sie gegen ein Modell der versteckten + Taschenrahmen laufen. Geprüft wird: + - Mit versteckten Rahmen ruft EldoUI keine von Blizzards Taschenfunktionen auf. + - Das allein geöffnete Fenster übersteht einen Bankbesuch und schließt mit X, Infoleiste und B, auch an der Bank. + - Der normale Weg mit B ist unverändert. + - Mit sichtbaren Rahmen nutzt EldoUI Blizzards Funktionen wie bisher. + - Eine Textprüfung stellt sicher, dass `Core.lua`, `InfoBar.lua` und `FlightView.lua` sie sonst nirgends direkt aufrufen. + Er läuft nur in der CI, denn auf dem Entwicklungsrechner gibt es kein Lua. +- **Im Spiel prüfen:** siehe Tabelle unten. + ## Sonstiges - **Toter Code:** rund 25 ungenutzte lokale Funktionen und ungenutzte Variablen (luacheck W211). Reste von @@ -571,6 +619,9 @@ Paladin Stufe 24, allein). „Keine Abweichung gemeldet“: Der Schritt war dran | F20 | Angel ablegen (der Angelmodus endet), derselbe Befehl | wieder `1 10 0` | offen | | F21 | ein paar Fische fangen, Maus auf die Zählung der Angelleiste | die Zahl steigt pro Fang um 1, der Tooltip zeigt Ort und Fische | offen | | F23 | in einer Gilde, mit dem Block „Gilde“ auf der Infoleiste: im Kampf die Maus auf den Block; nach dem Kampf noch einmal | im Kampf Gilde und Mitglieder ohne Gildennachricht, kein neuer Eintrag „Blocked: … InfoBar.lua“ in `/eui errors`; nach dem Kampf mit Gildennachricht | offen | +| F24 | `/reload`; Taschen mit B öffnen und mit EldoUIs X schließen; zur Bank, etwas herausholen, Bank schließen; Ruhestein oder Rezept per Rechtsklick aus der Tasche benutzen, danach `/run print(issecurevariable("FRAME_THAT_OPENED_BAGS"))print(issecurevariable(BankFrame.BankPanel,"bankType"))print(issecurevariable(MerchantFrame,"selectedTab"))` | Rechtsklick wirkt, kein neuer Eintrag „ContainerFrame.lua:1611“ in `/eui errors`; dreimal `true` | offen | +| F24 | Taschen über die Infoleiste öffnen, mit B schließen; noch einmal über die Infoleiste öffnen, einen Händler besuchen und verlassen | B schließt das Fenster; nach dem Händler bleibt es offen | offen | +| F24 | mit einem Freund handeln: einen Gegenstand per Rechtsklick aus der Tasche ins Handelsfenster legen | er landet im Handelsfenster | offen | | F17 | Persönliche Ressourcenanzeige (falls genutzt) | Leisten mit EldoUI-Textur | offen | | F17 | Blizzard-Raidframes mit „Improve“ und Click-Casting an; im Kampf jemanden in die Gruppe einladen oder einen Raid bilden lassen, nach dem Kampf mit einer Click-Cast-Bindung auf den neuen Frame klicken | Bindung wirkt sofort nach dem Kampf, nicht erst nach der nächsten Gruppenänderung | offen (Gruppe) | | F17 | Nameplates im EldoUI-Modus, an einer Gruppe Gegner vorbeilaufen | wie vorher; keine Lua-Fehler beim ersten Erscheinen der Plates | keine Abweichung gemeldet, keine Lua-Fehler im Log | diff --git a/tools/bags/test_game_bag_code.lua b/tools/bags/test_game_bag_code.lua new file mode 100644 index 0000000..e2a0f08 --- /dev/null +++ b/tools/bags/test_game_bag_code.lua @@ -0,0 +1,286 @@ +-- Offline test: EldoUI's bag window never runs the game's bag code (F24). +-- Run from the repository root: +-- lua5.1 tools/bags/test_game_bag_code.lua +-- Seen in the game (15.-21.11.2026, 157 times in the error log): "Forbidden: +-- EldoUI tried to call the protected function UNKNOWN() at +-- Blizzard_UIPanels_Game/Mainline/ContainerFrame.lua:1611", every +-- right-click use from the bags (hearthstone, keys, recipes, putting an +-- item into the trade window) blocked until a reload. A check in the game +-- found BankFrame.BankPanel.bankType tainted by EldoUI. The game's bank +-- window calls OpenAllBags(self) before it picks its tab, so a bag value +-- EldoUI had written (CloseAllBags() writes FRAME_THAT_OPENED_BAGS, an open +-- from EldoUI builds the game's bag frames) tainted the tab, and every +-- right-click hands that tab to UseContainerItem. +-- This cuts the real helpers, CloseWindow, SyncOpen and the ToggleAllBags +-- hook out of EldoUI/Modules/Bags/Core.lua (between fixed markers, so a +-- renamed part makes the test fail instead of testing a stale copy) and +-- runs them against a model of the game's bag frames on EldoUI's hidden +-- parent. Checked: while the frames are parked EldoUI calls none of the +-- game's bag functions (open, close, toggle); its window opens alone, stays +-- through a bank visit and closes on its close button, the info bar block +-- and the game's B; with the game's frames shown the game's functions are +-- used as before. A text check makes sure no other place in Core.lua, +-- InfoBar.lua or FlightView.lua calls them directly. +local ROOT = (arg and arg[0] or ""):match("^(.-)tools/bags/") or "./" + +local function ReadFile(path) + local file = assert(io.open(ROOT .. path, "rb"), "can't open " .. path) + local text = file:read("*a") + file:close() + return (text:gsub("\r\n", "\n")) +end + +-- The text from `first` up to (not including) `last`. +local function Between(text, first, last, where) + local from = text:find(first, 1, true) + assert(from, where .. ": marker not found: " .. first) + local to = text:find(last, from + #first, true) + assert(to, where .. ": end marker not found after " .. first .. ": " .. last) + return text:sub(from, to - 1) +end + +local core = ReadFile("EldoUI/Modules/Bags/Core.lua") +local helpers = Between(core, "function M:GameBagsParked()", "-- Tour help: the bag window explains itself once", "Core.lua helpers") +local syncing = Between(core, "function M:CloseWindow(window)", "-- Bank window anywhere: the selected character's saved bank.", "Core.lua SyncOpen") +local HOOK = 'hooksecurefunc("ToggleAllBags", function()' +local hook = Between(core, HOOK, "\t\tend)\n\tend\nend\nM.HookBagFrames = HookBagFrames", "Core.lua ToggleAllBags hook") +hook = "GameToggled = " .. hook:sub(#'hooksecurefunc("ToggleAllBags", ' + 1) .. "end\n" + +--------------------------------------------------------------------------- +-- Model of the game's bag frames and EldoUI's window +--------------------------------------------------------------------------- +local world +local hider = { name = "EldoUI's hidden parent" } +local UIPARENT = { name = "UIParent" } + +local function NewFrame(id, parent) + local frame = { id = id, shown = false, parent = parent } + function frame:GetParent() return self.parent end + function frame:IsShown() return self.shown end + function frame:Show() self.shown = true end + function frame:Hide() self.shown = false end + function frame:EnumerateValidItems() return pairs({}) end + return frame +end + +local frames = {} +local function BlizzardBagFrames() return frames end + +local window = { kind = "bags", shown = false, search = { ClearFocus = function() end } } +function window:IsShown() return self.shown end +function window:Hide() self.shown = false; self.eldoOnly = nil end +local windows = { bags = window } + +local function NewWorld(parked, own) + world = { own = own ~= false, game = {}, newItems = 0, forgot = 0, opens = 0 } + for i = 1, 3 do frames[i] = NewFrame(i - 1, parked and hider or UIPARENT) end + window.shown, window.eldoOnly, window.viewChar = false, nil, nil +end + +-- What the game's functions would do; every call is counted, since one +-- made from EldoUI's code is what tainted the bank. +local function GameOpen() for _, frame in ipairs(frames) do frame:Show() end end +local function GameClose() for _, frame in ipairs(frames) do frame:Hide() end end +local function AnyShown() + for _, frame in ipairs(frames) do + if frame:IsShown() then return true end + end + return false +end +function OpenAllBags() world.game[#world.game + 1] = "OpenAllBags"; GameOpen() end +function CloseAllBags(frame) world.game[#world.game + 1] = "CloseAllBags(" .. tostring(frame and frame.name) .. ")"; GameClose() end +function ToggleAllBags() + world.game[#world.game + 1] = "ToggleAllBags" + if AnyShown() then GameClose() else GameOpen() end +end +function UpdateNewItemList() world.newItems = world.newItems + 1 end + +local E = { charKey = "Hermano-Doomhowl" } +function E:SlideOut(frame) frame:Hide() end + +local M = {} +function M:OwnBags() return world.own end +function M:AnyBagOpen() return AnyShown() end +function M:WindowSide() return "RIGHT" end +function M:OpenWindow(frame) frame.shown = true; world.opens = world.opens + 1 end +function M:ForgetAutoOpen() world.forgot = world.forgot + 1 end + +local env = "local M, E, windows, hider, BlizzardBagFrames = ...\n" +for _, part in ipairs({ { helpers, "helpers" }, { syncing, "SyncOpen" }, { hook, "ToggleAllBags hook" } }) do + local chunk = assert(loadstring(env .. part[1], "=Core.lua " .. part[2])) + chunk(M, E, windows, hider, BlizzardBagFrames) +end + +-- The player presses B: the game's own toggle, then EldoUI's post-hook. +local function PressB() + local calls = #world.game + ToggleAllBags() + GameToggled() + table.remove(world.game, calls + 1) -- the player's own toggle, not EldoUI's +end + +local failures, passed = 0, 0 +local function Check(ok, message) + if ok then + passed = passed + 1 + else + failures = failures + 1 + print("FAIL: " .. message) + end +end + +local function NoGameCalls() + return #world.game == 0 +end + +--------------------------------------------------------------------------- +-- The game's frames on EldoUI's hidden parent (EldoUI's window replaces them) +--------------------------------------------------------------------------- +do + NewWorld(true) + Check(M:GameBagsParked(), "the frames on the hidden parent count as parked") + M:OpenBags() + Check(window:IsShown() and window.eldoOnly and window.viewChar == E.charKey, "OpenBags shows EldoUI's window alone") + Check(not AnyShown(), "OpenBags leaves the game's frames closed") + Check(NoGameCalls(), "OpenBags calls none of the game's bag functions") + M:ToggleBags() + Check(not window:IsShown() and not window.eldoOnly, "the info bar block closes the window again") + Check(NoGameCalls(), "the info bar block calls none of the game's bag functions") + M:ToggleBags() + Check(window:IsShown() and NoGameCalls(), "the info bar block opens it without the game's code") +end + +do + -- The bags opened by the game (B, a bank): the window follows them. + NewWorld(true) + GameOpen() + M:SyncOpen() + Check(window:IsShown() and not window.eldoOnly, "the window follows the game's bags") + M:CloseWindow(window) + Check(not AnyShown(), "the close button closes the game's frames") + Check(world.newItems == 3, "the items of each closed frame lose their new mark, as in the game's close") + Check(world.forgot == 1, "a close without a window forgets who opened the bags, as the game's CloseAllBags() hook does") + Check(NoGameCalls(), "the close button calls none of the game's bag functions (no FRAME_THAT_OPENED_BAGS)") + M:SyncOpen() + Check(not window:IsShown(), "the window stays closed") +end + +do + NewWorld(true) + local bank = { name = "BankFrame" } + GameOpen() + M:CloseGameBags(bank) + Check(not AnyShown() and world.forgot == 0 and NoGameCalls(), + "closing for a window (auto-open off) hides the frames and keeps who opened them") +end + +do + -- Opened alone, then a bank opens and closes the game's bags. + NewWorld(true) + M:OpenBags() + GameOpen() + M:SyncOpen() + GameClose() + M:SyncOpen() + Check(window:IsShown() and window.eldoOnly, "a window opened alone stays when the bank closes the game's bags") + PressB() + M:SyncOpen() + Check(not window:IsShown() and not AnyShown(), "B closes a window opened alone (the game had opened its frames)") + Check(NoGameCalls(), "closing after B calls none of the game's bag functions") +end + +do + -- Opened alone, at the bank (the game's bags open): B closes them. + NewWorld(true) + M:OpenBags() + GameOpen() + M:SyncOpen() + PressB() + M:SyncOpen() + Check(not window:IsShown() and not AnyShown(), "B at the bank closes a window opened alone") +end + +do + -- The normal case is unchanged: B opens, B closes. + NewWorld(true) + PressB() + M:SyncOpen() + Check(window:IsShown() and not window.eldoOnly, "B opens the bags and the window follows") + PressB() + M:SyncOpen() + Check(not window:IsShown(), "B closes them and the window follows") + Check(NoGameCalls(), "the normal B toggle needs no call of EldoUI's") +end + +do + NewWorld(true) + M:OpenBags() + M:CloseBags() + Check(not window:IsShown() and NoGameCalls(), "CloseBags (a window's close event) closes a window opened alone") + GameOpen() + M:SyncOpen() + M:CloseBags() + Check(not AnyShown() and NoGameCalls(), "CloseBags closes the game's frames quietly") +end + +do + NewWorld(true, false) + M:ToggleBags() + Check(world.game[1] == "ToggleAllBags", "without EldoUI's window the info bar block uses the game's toggle") +end + +--------------------------------------------------------------------------- +-- The game's frames shown (Blizzard's bags in use): the game's functions +--------------------------------------------------------------------------- +do + NewWorld(false) + Check(not M:GameBagsParked(), "frames on UIParent are not parked") + M:OpenBags() + Check(world.game[1] == "OpenAllBags" and not window.eldoOnly, "OpenBags uses the game's OpenAllBags") + M:CloseGameBags() + Check(world.game[2] == "CloseAllBags(nil)", "CloseGameBags uses the game's CloseAllBags()") + M:CloseGameBags({ name = "MerchantFrame" }) + Check(world.game[3] == "CloseAllBags(MerchantFrame)", "CloseGameBags hands the window on to CloseAllBags(frame)") + M:ToggleBags() + Check(world.game[4] == "ToggleAllBags", "ToggleBags uses the game's ToggleAllBags") +end + +--------------------------------------------------------------------------- +-- No other direct call of the game's bag functions +--------------------------------------------------------------------------- +local CALLS = { "OpenAllBags%(", "CloseAllBags%(", "ToggleAllBags%(", "OpenBackpack%(", "ToggleBackpack%(", + "CloseBackpack%(", "OpenBag%(", "ToggleBag%(", "CloseBag%(" } + +-- Lines that call one, outside comments and outside `allowed`. +local function DirectCalls(text, allowed) + local found = {} + if allowed then + local from = assert(text:find(allowed, 1, true), "allowed part not found") + text = text:sub(1, from - 1) .. text:sub(from + #allowed) + end + for line in text:gmatch("[^\n]+") do + local code = line:gsub("%-%-.*$", "") + for _, call in ipairs(CALLS) do + if code:find("[^%w_.:\"]" .. call) or code:find("^" .. call) then found[#found + 1] = line end + end + end + return found +end + +do + local list = DirectCalls(core, helpers) + Check(#list == 0, "Core.lua calls the game's bag functions only in its helpers: " .. table.concat(list, " | ")) + local infobar = ReadFile("EldoUI/Modules/InfoBar.lua") + local fallback = Between(infobar, "function M.ToggleBags()", "local function Hex(", "InfoBar.lua ToggleBags") + list = DirectCalls(infobar, fallback) + Check(#list == 0, "InfoBar.lua toggles the bags only through M.ToggleBags: " .. table.concat(list, " | ")) + local flight = ReadFile("EldoUI/Modules/QoL/FlightView.lua") + local button = Between(flight, 'M:CloseFlightView("bags")', "end })", "FlightView.lua Bags button") + list = DirectCalls(flight, button) + Check(#list == 0, "FlightView.lua toggles the bags only through the Bags module: " .. table.concat(list, " | ")) + -- Counter-check: the check finds a direct call. + Check(#DirectCalls("\tif x then CloseAllBags() end\n") == 1, "counter-check: a direct CloseAllBags() is found") +end + +print(("%d checks passed, %d failed"):format(passed, failures)) +os.exit(failures == 0 and 0 or 1) diff --git a/tools/ci/check_all.sh b/tools/ci/check_all.sh index e005080..cc2b91e 100755 --- a/tools/ci/check_all.sh +++ b/tools/ci/check_all.sh @@ -117,6 +117,8 @@ check_tests() { lua5.1 tools/lootsim/test_judgement.lua || bad+=("$name") name="Auction House: Blizzard's screens come back under EldoUI's pages (F22)"; step "$name" lua5.1 tools/auction/test_native_screens.lua || bad+=("$name") + name="Bags: EldoUI's bag window never runs the game's bag code (F24)"; step "$name" + lua5.1 tools/bags/test_game_bag_code.lua || bad+=("$name") name="conUI name: prose is renamed, names stay"; step "$name" lua5.1 tools/brand/test_brand.lua || bad+=("$name") name="German pack: Fork.lua rules"; step "$name" diff --git a/tools/ci/globals.lua b/tools/ci/globals.lua index f7a9eff..e4b03cf 100644 --- a/tools/ci/globals.lua +++ b/tools/ci/globals.lua @@ -1090,6 +1090,7 @@ return { "UpdateAddOnMemoryUsage", "UpdateContainerFrameAnchors", "UpdateMicroButtons", + "UpdateNewItemList", "UpdateUIPanelPositions", "UtilityCooldownViewer", "VehicleSeatIndicator", From 7049de57b9cf3e96cf40f2d2b0728db303eb3555 Mon Sep 17 00:00:00 2001 From: con1338 Date: Sat, 21 Nov 2026 20:36:49 +0100 Subject: [PATCH 2/2] Bags: the backpack key closes a bag window opened alone (F24) A window EldoUI opened on its own (the game's bags closed) did not close with the backpack key or button: the first press opened the game's hidden backpack, the second closed it, and the window stayed. The game's CloseAllBags() without a window is the player's close, so it now ends "opened alone" and the window follows the game's frames. The test runs the two hooks at the end of HookBagFrames as they are and checks the backpack key and a bank closing the bags. Co-Authored-By: Claude Opus 5.5 --- EldoUI/Modules/Bags/Core.lua | 9 ++++ review/fehler.md | 15 +++--- tools/bags/test_game_bag_code.lua | 77 +++++++++++++++++++++++-------- 3 files changed, 77 insertions(+), 24 deletions(-) diff --git a/EldoUI/Modules/Bags/Core.lua b/EldoUI/Modules/Bags/Core.lua index 10ff0e9..0c491d4 100644 --- a/EldoUI/Modules/Bags/Core.lua +++ b/EldoUI/Modules/Bags/Core.lua @@ -3779,6 +3779,15 @@ local function HookBagFrames() if window:IsShown() and M:OwnBags() then M:CloseGameBags() end end) end + -- The game's CloseAllBags() without a window is the player's close + -- (the backpack key or button on the open backpack, Escape): a window + -- opened alone closes with the game's frames. + if CloseAllBags then + hooksecurefunc("CloseAllBags", function(frame) + local window = windows.bags + if window and not frame then window.eldoOnly = nil end + end) + end end M.HookBagFrames = HookBagFrames diff --git a/review/fehler.md b/review/fehler.md index 731cef0..a491259 100644 --- a/review/fehler.md +++ b/review/fehler.md @@ -572,9 +572,11 @@ Geprüft wurde jeder Fix gegen den Code von 0.7.3005 (nicht im Spiel). Nur sechs (`M:GameBagsParked`, Taschen „Ersetzen“ oder „Ausblenden“), ruft EldoUI Blizzards Taschencode nicht mehr selbst auf. - `M:CloseGameBags` versteckt die Rahmen nur. Auf dem versteckten Elternrahmen laufen ohnehin keine Skripte. Wie bei Blizzard verlieren die Gegenstände ihre „Neu“-Markierung (`UpdateNewItemList`, nur `C_NewItems`). - - `M:OpenBags` öffnet nur EldoUIs Fenster (`window.eldoOnly`). Es bleibt offen, bis der Spieler es schließt: X, Escape, - B (Haken an `ToggleAllBags`) oder ein Taschen-Block. Auch wenn eine Bank oder ein Händler die Taschen öffnet und - wieder schließt, bleibt es offen, wie vorher bei schon offenen Taschen. + - `M:OpenBags` öffnet nur EldoUIs Fenster (`window.eldoOnly`). Es bleibt offen, bis der Spieler es schließt: mit X, + Escape, B (Haken an `ToggleAllBags`) oder einem Taschen-Block. Auch Blizzards `CloseAllBags()` ohne Fenster schließt + es, etwa die Rucksack-Taste auf dem offenen Rucksack. Weil Blizzard die Taschen für geschlossen hält, öffnet der + erste Druck der Rucksack-Taste aber nur Blizzards versteckten Rucksack. Öffnet und schließt eine Bank oder ein + Händler die Taschen, bleibt das Fenster offen, wie vorher bei schon offenen Taschen. - `M:CloseBags` und `M:ToggleBags` sind die Gegenstücke. Infoleiste (Gold, Taschen, Munition) und der Taschen-Knopf der Flugansicht laufen über `M:ToggleBags`. - Mit sichtbaren Blizzard-Taschen (Taschen nicht ersetzt) ruft EldoUI wie bisher Blizzards Funktionen auf. Dort bleibt @@ -582,10 +584,11 @@ Geprüft wurde jeder Fix gegen den Code von 0.7.3005 (nicht im Spiel). Nur sechs - **Nicht erklärt:** Laut dem Spieler war der Rechtsklick ins Handelsfenster gleich nach einem `/reload` erneut gesperrt. Nach einem Reload ist der Bank-Typ sauber. Ob dazwischen die Bank offen war, ist nicht bekannt. - **Test:** `tools/bags/test_game_bag_code.lua` (läuft in `tools/ci/check_all.sh tests`). Er schneidet die Helfer, - `CloseWindow`, `SyncOpen` und den `ToggleAllBags`-Haken aus `Core.lua` und lässt sie gegen ein Modell der versteckten - Taschenrahmen laufen. Geprüft wird: + `CloseWindow`, `SyncOpen` und die Haken an `ToggleAllBags` und `CloseAllBags` aus `Core.lua` und lässt sie gegen ein + Modell der versteckten Taschenrahmen laufen. Geprüft wird: - Mit versteckten Rahmen ruft EldoUI keine von Blizzards Taschenfunktionen auf. - - Das allein geöffnete Fenster übersteht einen Bankbesuch und schließt mit X, Infoleiste und B, auch an der Bank. + - Das allein geöffnete Fenster übersteht einen Bankbesuch. Es schließt mit X, Infoleiste und B, auch an der Bank, + und mit dem zweiten Druck der Rucksack-Taste. - Der normale Weg mit B ist unverändert. - Mit sichtbaren Rahmen nutzt EldoUI Blizzards Funktionen wie bisher. - Eine Textprüfung stellt sicher, dass `Core.lua`, `InfoBar.lua` und `FlightView.lua` sie sonst nirgends direkt aufrufen. diff --git a/tools/bags/test_game_bag_code.lua b/tools/bags/test_game_bag_code.lua index e2a0f08..60fc38b 100644 --- a/tools/bags/test_game_bag_code.lua +++ b/tools/bags/test_game_bag_code.lua @@ -12,14 +12,14 @@ -- from EldoUI builds the game's bag frames) tainted the tab, and every -- right-click hands that tab to UseContainerItem. -- This cuts the real helpers, CloseWindow, SyncOpen and the ToggleAllBags --- hook out of EldoUI/Modules/Bags/Core.lua (between fixed markers, so a --- renamed part makes the test fail instead of testing a stale copy) and --- runs them against a model of the game's bag frames on EldoUI's hidden --- parent. Checked: while the frames are parked EldoUI calls none of the --- game's bag functions (open, close, toggle); its window opens alone, stays --- through a bank visit and closes on its close button, the info bar block --- and the game's B; with the game's frames shown the game's functions are --- used as before. A text check makes sure no other place in Core.lua, +-- and CloseAllBags hooks out of EldoUI/Modules/Bags/Core.lua (between fixed +-- markers, so a renamed part makes the test fail instead of testing a stale +-- copy) and runs them against a model of the game's bag frames on EldoUI's +-- hidden parent. Checked: while the frames are parked EldoUI calls none of +-- the game's bag functions (open, close, toggle); its window opens alone, +-- stays through a bank visit and closes on its close button, the info bar +-- block, the game's B and the backpack key; with the game's frames shown +-- the game's functions are used as before. A text check makes sure no other place in Core.lua, -- InfoBar.lua or FlightView.lua calls them directly. local ROOT = (arg and arg[0] or ""):match("^(.-)tools/bags/") or "./" @@ -42,9 +42,10 @@ end local core = ReadFile("EldoUI/Modules/Bags/Core.lua") local helpers = Between(core, "function M:GameBagsParked()", "-- Tour help: the bag window explains itself once", "Core.lua helpers") local syncing = Between(core, "function M:CloseWindow(window)", "-- Bank window anywhere: the selected character's saved bank.", "Core.lua SyncOpen") -local HOOK = 'hooksecurefunc("ToggleAllBags", function()' -local hook = Between(core, HOOK, "\t\tend)\n\tend\nend\nM.HookBagFrames = HookBagFrames", "Core.lua ToggleAllBags hook") -hook = "GameToggled = " .. hook:sub(#'hooksecurefunc("ToggleAllBags", ' + 1) .. "end\n" +-- The two post-hooks at the end of HookBagFrames (ToggleAllBags and +-- CloseAllBags), run as they are against a hooksecurefunc that keeps them. +local hooks = Between(core, 'if ToggleAllBags then\n\t\thooksecurefunc("ToggleAllBags", function()', + "\nend\nM.HookBagFrames = HookBagFrames", "Core.lua HookBagFrames hooks") --------------------------------------------------------------------------- -- Model of the game's bag frames and EldoUI's window @@ -105,18 +106,44 @@ function M:WindowSide() return "RIGHT" end function M:OpenWindow(frame) frame.shown = true; world.opens = world.opens + 1 end function M:ForgetAutoOpen() world.forgot = world.forgot + 1 end +local posthooks = {} +function hooksecurefunc(name, fn) + assert(type(name) == "string" and type(fn) == "function", "hooksecurefunc(name, fn)") + posthooks[name] = fn +end + local env = "local M, E, windows, hider, BlizzardBagFrames = ...\n" -for _, part in ipairs({ { helpers, "helpers" }, { syncing, "SyncOpen" }, { hook, "ToggleAllBags hook" } }) do +for _, part in ipairs({ { helpers, "helpers" }, { syncing, "SyncOpen" }, { hooks, "HookBagFrames hooks" } }) do local chunk = assert(loadstring(env .. part[1], "=Core.lua " .. part[2])) chunk(M, E, windows, hider, BlizzardBagFrames) end +assert(posthooks.ToggleAllBags and posthooks.CloseAllBags, "HookBagFrames: the ToggleAllBags or CloseAllBags hook is missing") --- The player presses B: the game's own toggle, then EldoUI's post-hook. -local function PressB() +-- The player's own toggles (not EldoUI's calls): the game's function, +-- then EldoUI's post-hook. +local function PlayerCall(name, fn) + local calls = #world.game + fn() + table.remove(world.game, calls + 1) + posthooks[name]() +end +-- B: ToggleAllBags. +local function PressB() PlayerCall("ToggleAllBags", ToggleAllBags) end +-- The backpack key on a closed backpack opens it; on an open one the game +-- closes all bags (ToggleBackpack -> CloseAllBags()). +local function PressBackpack() + if AnyShown() then + PlayerCall("CloseAllBags", CloseAllBags) + else + GameOpen() + end +end +-- A bank or vendor closes: the game's CloseAllBags(frame). +local function WindowCloses(frame) local calls = #world.game - ToggleAllBags() - GameToggled() - table.remove(world.game, calls + 1) -- the player's own toggle, not EldoUI's + CloseAllBags(frame) + table.remove(world.game, calls + 1) + posthooks.CloseAllBags(frame) end local failures, passed = 0, 0 @@ -180,7 +207,7 @@ do M:OpenBags() GameOpen() M:SyncOpen() - GameClose() + WindowCloses({ name = "BankFrame" }) M:SyncOpen() Check(window:IsShown() and window.eldoOnly, "a window opened alone stays when the bank closes the game's bags") PressB() @@ -200,6 +227,20 @@ do Check(not window:IsShown() and not AnyShown(), "B at the bank closes a window opened alone") end +do + -- Opened alone: the backpack key opens the game's backpack first (no + -- change on screen), then closes all bags, and the window goes too. + NewWorld(true) + M:OpenBags() + PressBackpack() + M:SyncOpen() + Check(window:IsShown(), "the backpack key on the closed backpack leaves a window opened alone open") + PressBackpack() + M:SyncOpen() + Check(not window:IsShown() and not AnyShown(), "the backpack key on the open backpack closes a window opened alone") + Check(NoGameCalls(), "the backpack key needs no call of EldoUI's") +end + do -- The normal case is unchanged: B opens, B closes. NewWorld(true)