646 lines
26 KiB
Lua
646 lines
26 KiB
Lua
local handlers = {}
|
|
local combat = false
|
|
local function frame(id)
|
|
local f = { shown = true, bagID = id, hooks = {} }
|
|
function f:Hide() assert(not combat, 'protected hide during combat'); self.shown = false end
|
|
function f:Show() self.shown = true; for _, fn in ipairs(self.hooks) do fn(self) end end
|
|
function f:IsShown() return self.shown end
|
|
function f:HookScript(_, fn) self.hooks[#self.hooks + 1] = fn end
|
|
function f:GetID() return 6 end -- frame ID is unrelated to the bag ID
|
|
return f
|
|
end
|
|
function CreateFrame()
|
|
-- The first frame is the bag-slot event frame; later frames (#72 backpack count) keep their own handler.
|
|
return { RegisterEvent = function() end, SetScript = function(_, _, fn) handlers.event = handlers.event or fn end }
|
|
end
|
|
function InCombatLockdown() return combat end
|
|
function ToggleBag() return 'original' end
|
|
local toggle = ToggleBag
|
|
Enum = { BagIndex = { ReagentBag = 5 } }
|
|
NUM_CONTAINER_FRAMES = 13
|
|
CharacterReagentBag0Slot = frame()
|
|
ContainerFrame6 = frame(1)
|
|
ContainerFrame2 = frame(5)
|
|
ContainerFrame3 = frame(nil)
|
|
function ContainerFrame3:GetBagID() return 5 end
|
|
KEYRING_CONTAINER = -1
|
|
C_Container = { GetContainerNumSlots = function(id) return id == KEYRING_CONTAINER and 32 or 16 end }
|
|
combat = true
|
|
dofile('client_addons/WoWHybridUI/NativeBagSlots.lua')
|
|
handlers.event(nil, 'PLAYER_LOGIN')
|
|
assert(CharacterReagentBag0Slot.shown and ContainerFrame2.shown)
|
|
assert(ToggleBag == toggle and ToggleBag() == 'original')
|
|
assert(WoWHybridBagDiagnostics.slots[KEYRING_CONTAINER] == 32)
|
|
combat = false
|
|
handlers.event(nil, 'PLAYER_REGEN_ENABLED')
|
|
-- The reagent slot is hidden by Blizzard's own mainmenubarbagbuttons.lua (content 358abf40, #107); the addon
|
|
-- no longer touches it.
|
|
assert(CharacterReagentBag0Slot.shown)
|
|
assert(ContainerFrame6.shown and not ContainerFrame2.shown and not ContainerFrame3.shown)
|
|
-- A recycled container must open normally when rebound to an ordinary bag.
|
|
ContainerFrame2.bagID = 2; ContainerFrame2:Show(); assert(ContainerFrame2.shown)
|
|
ContainerFrame6.bagID = 5; ContainerFrame6:Show(); assert(not ContainerFrame6.shown)
|
|
combat = true; ContainerFrame6:Show(); assert(ContainerFrame6.shown)
|
|
combat = false; handlers.event(nil, 'PLAYER_REGEN_ENABLED'); assert(not ContainerFrame6.shown)
|
|
handlers.event(nil, 'BAG_UPDATE'); assert(#ContainerFrame6.hooks == 1)
|
|
assert(ToggleBag == toggle)
|
|
|
|
-- Invoke the retained original70334 FrameXML methods, rather than a model of
|
|
-- their layout/count behavior. No game process or UI is involved in this test.
|
|
local nativeRoot = 'runtime/continuation-20261113/codex/PTR-feedback-disable/native70334-ui/interface/addons/'
|
|
-- Whitespace-normalized original70334 method fragments for portable source tests.
|
|
-- The live cached originals above supplied these fragments; no unrelated UI was copied.
|
|
local frozenNative = {
|
|
-- fragment SHA256 d8a255444be3c48e4609eba471bda2123582e109fecaaa30d480963c59590d58
|
|
["blizzard_mainmenubarbagbuttons/camelot/mainmenubarbagbuttons.lua"] = [==[
|
|
function KeyRingMixin:BagSlotOnClick()
|
|
if (CursorHasItem()) then
|
|
PutKeyInKeyRing();
|
|
else
|
|
ToggleBag(KEYRING_CONTAINER);
|
|
end
|
|
end
|
|
|
|
function KeyRingMixin:OnBagUpdate()
|
|
if (C_ActionBar.ShouldShowKeyring()) then
|
|
if(GetCVarBool("showKeyring")) then
|
|
self.bagAtlas = "UI-HUD-ActionBar-Keyring-Small";
|
|
else
|
|
self.bagAtlas = "UI-HUD-ActionBar-IconFrame-Slot-Small";
|
|
end
|
|
self:UpdateTextures();
|
|
end
|
|
end
|
|
]==],
|
|
-- fragment SHA256 14f77699430f9ff4c71ec0966a3fde65925d80d26c1eac66d20c7ef076ebb080
|
|
["blizzard_uipanels_game/mainline/containerframe.lua"] = [==[
|
|
function ToggleBag_Individual(id)
|
|
local size = 0;
|
|
if (id == KEYRING_CONTAINER ) then
|
|
size = GetKeyRingSize();
|
|
else
|
|
size = ContainerFrame_GetContainerNumSlots(id);
|
|
end
|
|
|
|
if ( size > 0 or id == KEYRING_CONTAINER ) then
|
|
local containerFrame = ContainerFrameUtil_GetShownFrameForID(id);
|
|
if containerFrame then
|
|
if containerFrame:IsBackpack() then
|
|
CloseAllBags();
|
|
else
|
|
containerFrame:Hide();
|
|
end
|
|
else
|
|
if CanAutoSetGamePadCursorControl(true) then
|
|
SetGamePadCursorControl(true);
|
|
end
|
|
|
|
ContainerFrame_GenerateFrame(ContainerFrame_GetOpenFrame(id), size, id);
|
|
|
|
-- Stop keyring button pulse
|
|
if (id == KEYRING_CONTAINER) then
|
|
SetButtonPulse(KeyRingButton, 0, 1);
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ToggleBag(id)
|
|
if (id == KEYRING_CONTAINER and GetCVarBool("showKeyring") == false) then
|
|
return;
|
|
end
|
|
|
|
if not ContainerFrame_AllowedToOpenBags() then
|
|
return;
|
|
end
|
|
|
|
if ContainerFrameSettingsManager:IsUsingCombinedBags(id) then
|
|
ToggleBag_Combined(id);
|
|
else
|
|
ToggleBag_Individual(id);
|
|
end
|
|
end
|
|
|
|
function ContainerFrameSettingsManager:IsUsingCombinedBags(optionalID)
|
|
if optionalID then
|
|
if not ContainerFrame_IsGenericHeldBag(optionalID) or ContainerFrame_IsBankTab(optionalID) then
|
|
return false;
|
|
end
|
|
end
|
|
|
|
return self.isUsingCombinedBags or InputUtil.IsGamepadUIEnabled();
|
|
end
|
|
|
|
function ContainerFrame_GetContainerNumSlots(bagId)
|
|
if bagId == KEYRING_CONTAINER then
|
|
local keyRingSize = GetKeyRingSize();
|
|
return keyRingSize, keyRingSize;
|
|
end
|
|
|
|
local currentNumSlots = C_Container.GetContainerNumSlots(bagId);
|
|
local maxNumSlots = currentNumSlots;
|
|
|
|
if bagId == Enum.BagIndex.Backpack and not IsAccountSecured() then
|
|
-- If your account isn't secured then the max number of slots you can have in your backpack is 4 more than your current
|
|
maxNumSlots = currentNumSlots + 4;
|
|
end
|
|
|
|
return maxNumSlots, currentNumSlots;
|
|
end
|
|
|
|
function ContainerFrameExtendedSlotPack:UpdateAddSlots()
|
|
if not self.AddSlotsButton then
|
|
self.AddSlotsButton = CreateFrame("BUTTON", nil, self, "AddExtendedSlotsButtonTemplate");
|
|
end
|
|
|
|
self.AddSlotsButton:SetShown(not IsAccountSecured());
|
|
end
|
|
|
|
|
|
do
|
|
local function SortItems(item1, item2)
|
|
local bag1, bag2 = item1:GetBagID(), item2:GetBagID();
|
|
if bag1 ~= bag2 then
|
|
return bag1 < bag2;
|
|
end
|
|
|
|
local isBag1, isBag2 = item1.isBag, item2.isBag;
|
|
if isBag1 ~= isBag2 then
|
|
return isBag1 ~= nil;
|
|
end
|
|
|
|
local id1, id2 = item1:GetID(), item2:GetID();
|
|
return id1 < id2;
|
|
end
|
|
|
|
local function SortItemsByExtendedState(item1, item2)
|
|
local extended1, extended2 = item1:IsExtended(), item2:IsExtended();
|
|
if extended1 ~= extended2 then
|
|
return not extended1;
|
|
end
|
|
|
|
return SortItems(item1, item2);
|
|
end
|
|
|
|
local function UpdateItemSort(items)
|
|
if not ContainerFrameSettingsManager:IsUsingCombinedBags() then
|
|
return;
|
|
end
|
|
|
|
if not IsAccountSecured() then
|
|
table.sort(items, SortItemsByExtendedState);
|
|
else
|
|
table.sort(items, SortItems);
|
|
end
|
|
end
|
|
|
|
local function GetBagSetupIndices(ascendingOrder)
|
|
if ascendingOrder then
|
|
return STARTING_BAG_INDEX, ENDING_BAG_INDEX, 1;
|
|
else
|
|
return ENDING_BAG_INDEX, STARTING_BAG_INDEX, -1;
|
|
end
|
|
end
|
|
|
|
function ContainerFrameMixin:AcquireNewItemButton()
|
|
local itemButton = self.itemButtonPool:Acquire();
|
|
table.insert(self.Items, itemButton);
|
|
|
|
return itemButton;
|
|
end
|
|
|
|
function ContainerFrameMixin:ClearItems()
|
|
self.itemButtonPool:ReleaseAll();
|
|
self.Items = {};
|
|
end
|
|
|
|
function ContainerFrameMixin:UpdateItemSlots()
|
|
self:ClearItems();
|
|
if self:IsCombinedBagContainer() then
|
|
local useAscendingOrder = false;
|
|
local startIndex, endIndex, increment = GetBagSetupIndices(useAscendingOrder);
|
|
for bag = startIndex, endIndex, increment do
|
|
local bagSize = ContainerFrame_GetContainerNumSlots(bag);
|
|
for i = 1, bagSize do
|
|
local itemButton = self:AcquireNewItemButton();
|
|
local slotID = bagSize - i + 1;
|
|
itemButton:Initialize(bag, slotID);
|
|
end
|
|
end
|
|
else
|
|
local bagSize = self:GetBagSize();
|
|
for i = 1, ContainerFrame_GetContainerNumSlots(self:GetBagID()) do
|
|
local itemButton = self:AcquireNewItemButton();
|
|
local slotID = bagSize - i + 1;
|
|
itemButton:Initialize(self:GetBagID(), slotID);
|
|
end
|
|
end
|
|
end
|
|
|
|
function ContainerFrameMixin:UpdateItemLayout()
|
|
local itemsToLayout = {};
|
|
for i, itemButton in self:EnumerateValidItems() do
|
|
local gamepadBagButton = GamepadBagBar and GamepadBagBar:GetBagButton(itemButton.bagID);
|
|
if gamepadBagButton == nil or (gamepadBagButton and gamepadBagButton.isCollapsed ~= true) then
|
|
table.insert(itemsToLayout, itemButton);
|
|
end
|
|
end
|
|
if self:IsCombinedBagContainer() and InputUtil.IsGamepadUIEnabled() then
|
|
local useAscendingOrder = false;
|
|
local startIndex, endIndex, increment = GetBagSetupIndices(useAscendingOrder);
|
|
for bag = startIndex, endIndex, increment do
|
|
local gamepadBagButton = GamepadBagBar and GamepadBagBar:GetBagButton(bag);
|
|
if gamepadBagButton then
|
|
table.insert(itemsToLayout, gamepadBagButton);
|
|
end
|
|
end
|
|
end
|
|
|
|
UpdateItemSort(itemsToLayout);
|
|
|
|
AnchorUtil.GridLayout(itemsToLayout, self:GetInitialItemAnchor(), self:GetAnchorLayout());
|
|
|
|
self:LayoutAddSlots();
|
|
end
|
|
end
|
|
]==],
|
|
-- fragment SHA256 ccef9dc82aca5a7b910d292b4e629c85dc5eae7fbcd4748fd5e020e8522f49bd
|
|
["blizzard_mainmenubarbagbuttons/shared/mainmenubarbagmanager.lua"] = [==[
|
|
function MainMenuBarBagManager:RegisterBagButton(bagButton)
|
|
if not tContains(self.allBagButtons, bagButton) then
|
|
table.insert(self.allBagButtons, bagButton);
|
|
end
|
|
end
|
|
|
|
function MainMenuBarBagManager:EnumerateBagButtons()
|
|
return ipairs(self.allBagButtons);
|
|
end
|
|
]==],
|
|
-- fragment SHA256 c1796d65de9c1a633246bb121380b8473526faea4439770cf233b6e21f33bb26
|
|
["blizzard_mainmenubarbagbuttons/shared/bagsbar.lua"] = [==[
|
|
BagsBarMixin = {};
|
|
function BagsBarMixin:GetBagButtonAnchorPoints()
|
|
-- Returns Point, RelativePoint, xOffset, yOffset
|
|
local padding = self.bagPadding or 0;
|
|
|
|
if self:IsHorizontal() then
|
|
if self:IsDirectionLeft() then
|
|
return "RIGHT", "LEFT", -padding, 0;
|
|
else
|
|
return "LEFT", "RIGHT", padding, 0;
|
|
end
|
|
else
|
|
if self:IsDirectionUp() then
|
|
return "BOTTOM", "TOP", 0, padding;
|
|
else
|
|
return "TOP", "BOTTOM", 0, -padding;
|
|
end
|
|
end
|
|
end
|
|
|
|
function BagsBarMixin:GetBagBarLength()
|
|
-- Measure the total length of the long axis of the bags bar. (Width if we're horizontal, height if we're vertical.)
|
|
|
|
local isHorizontal = self:IsHorizontal();
|
|
local totalLength = 0;
|
|
|
|
for i, bagButton in MainMenuBarBagManager:EnumerateBagButtons() do
|
|
if (isHorizontal) then
|
|
totalLength = totalLength + bagButton:GetWidth();
|
|
else
|
|
totalLength = totalLength + bagButton:GetHeight();
|
|
end
|
|
|
|
if (i ~= 1) then
|
|
totalLength = totalLength + (self.bagPadding or 0);
|
|
end
|
|
end
|
|
|
|
-- Also include BagBarExpandToggle.
|
|
if (self:ShouldShowExpandToggle()) then
|
|
if (isHorizontal) then
|
|
totalLength = totalLength + self.bagBarExpandToggleInitialWidth;
|
|
else
|
|
totalLength = totalLength + self.bagBarExpandToggleInitialHeight;
|
|
end
|
|
end
|
|
|
|
return totalLength;
|
|
end
|
|
|
|
function BagsBarMixin:Layout()
|
|
local isHorizontal = self:IsHorizontal();
|
|
|
|
-- If any of our buttons care about orientation (e.g., Classic Keyring), make sure they're synced with us.
|
|
for i, bagButton in MainMenuBarBagManager:EnumerateBagButtons() do
|
|
if (bagButton.UpdateOrientation) then
|
|
bagButton:UpdateOrientation(isHorizontal);
|
|
end
|
|
end
|
|
|
|
-- Set bar and toggle button size based on orientation
|
|
local longAxisLength = self:GetBagBarLength();
|
|
if isHorizontal then
|
|
self:SetSize(longAxisLength, self.initialHeight);
|
|
else
|
|
-- Swap width/height for vertical bags bar since the bar is horizontal by default
|
|
self:SetSize(self.initialHeight, longAxisLength);
|
|
end
|
|
|
|
-- Get new bag anchor points
|
|
local point, relativePoint, xOffset, yOffset = self:GetBagButtonAnchorPoints();
|
|
|
|
-- Setup backpack button anchor
|
|
MainMenuBarBackpackButton:ClearAllPoints();
|
|
MainMenuBarBackpackButton:SetPoint(point, self, point);
|
|
|
|
if (self:ShouldShowExpandToggle()) then
|
|
if isHorizontal then
|
|
BagBarExpandToggle:SetSize(self.bagBarExpandToggleInitialWidth, self.bagBarExpandToggleInitialHeight);
|
|
else
|
|
-- Swap width/height for vertical bags bar since the bar is horizontal by default
|
|
BagBarExpandToggle:SetSize(self.bagBarExpandToggleInitialHeight, self.bagBarExpandToggleInitialWidth);
|
|
end
|
|
|
|
-- Update expand button
|
|
BagBarExpandToggle:UpdateOrientation();
|
|
BagBarExpandToggle:ClearAllPoints();
|
|
BagBarExpandToggle:SetPoint(point, MainMenuBarBackpackButton, relativePoint);
|
|
end
|
|
|
|
-- Update other bag button anchors
|
|
local anchorRelativeTo = self:ShouldShowExpandToggle() and BagBarExpandToggle or MainMenuBarBackpackButton;
|
|
for i, bagButton in MainMenuBarBagManager:EnumerateBagButtons() do
|
|
if bagButton:IsShown() and bagButton ~= MainMenuBarBackpackButton then
|
|
bagButton:ClearAllPoints();
|
|
bagButton:SetPoint(point, anchorRelativeTo, relativePoint, xOffset, yOffset);
|
|
anchorRelativeTo = bagButton;
|
|
end
|
|
end
|
|
|
|
-- If button layout has changed then we may need to update the dividers we're showing between buttons
|
|
if self.useDividers then
|
|
self:UpdateDividers();
|
|
end
|
|
end
|
|
|
|
function BagsBarMixin:IsHorizontal()
|
|
return self.isHorizontal;
|
|
end
|
|
|
|
function BagsBarMixin:IsDirectionLeft()
|
|
return self:IsHorizontal() and self.direction == Enum.BagsDirection.Left;
|
|
end
|
|
|
|
function BagsBarMixin:IsDirectionUp()
|
|
return not self:IsHorizontal() and self.direction == Enum.BagsDirection.Up;
|
|
end
|
|
|
|
function BagsBarMixin:ShouldShowExpandToggle()
|
|
return not self.hideExpandToggle;
|
|
end
|
|
|
|
]==],
|
|
}
|
|
local function nativeText(relative)
|
|
local file
|
|
if os.getenv('WOWHYBRID_BAG_TEST_FROZEN') ~= '1' then file = io.open(nativeRoot .. relative, 'rb') end
|
|
if not file then return assert(frozenNative[relative], 'Missing pinned native method fixture') end
|
|
local text = file:read('*a'):gsub('\r\n', '\n'); file:close()
|
|
return text
|
|
end
|
|
local function nativeFunction(text, name)
|
|
local first = assert(text:find('function ' .. name .. '(', 1, true))
|
|
local last = assert(text:find('\nend', first, true)) + 3
|
|
assert((loadstring or load)(text:sub(first, last), '@original70334-' .. name))()
|
|
end
|
|
local containerText = nativeText('blizzard_uipanels_game/mainline/containerframe.lua')
|
|
nativeFunction(containerText, 'ContainerFrame_GetContainerNumSlots')
|
|
ContainerFrameExtendedSlotPack = {}
|
|
nativeFunction(containerText, 'ContainerFrameExtendedSlotPack:UpdateAddSlots')
|
|
ContainerFrameMixin = {}
|
|
local block = assert(containerText:find('\ndo\n\tlocal function SortItems(', 1, true))
|
|
local blockEnd = containerText:find('\nfunction ContainerFrameMixin:UpdateFilterIcon', block, true) or (#containerText + 1)
|
|
assert((loadstring or load)(containerText:sub(block, blockEnd - 1), '@original70334-item-layout'))()
|
|
local accountSecured = false
|
|
function IsAccountSecured() return accountSecured end
|
|
local secured = IsAccountSecured
|
|
function GetKeyRingSize() return 32 end
|
|
Enum.BagIndex.Backpack = 0
|
|
local rawSlots = C_Container.GetContainerNumSlots
|
|
assert(ContainerFrame_GetContainerNumSlots(0) == 20) -- Actual original +4 defect.
|
|
assert(C_Container.GetContainerNumSlots(0) == 16)
|
|
function hooksecurefunc(object, name, hook)
|
|
local original = assert(object[name])
|
|
object[name] = function(...)
|
|
local result = { original(...) }
|
|
hook(...)
|
|
return (table.unpack or unpack)(result)
|
|
end
|
|
end
|
|
local createEventFrame = CreateFrame
|
|
function CreateFrame(kind, ...)
|
|
if kind ~= 'BUTTON' then return createEventFrame(kind, ...) end
|
|
local button = frame()
|
|
function button:SetShown(shown) if shown then self:Show() else self:Hide() end end
|
|
return button
|
|
end
|
|
ContainerFrameCombinedBags = frame(0)
|
|
ContainerFrameCombinedBags.UpdateAddSlots = ContainerFrameExtendedSlotPack.UpdateAddSlots
|
|
ContainerFrameCombinedBags:UpdateAddSlots()
|
|
assert(ContainerFrameCombinedBags.AddSlotsButton.shown)
|
|
|
|
local managerText = nativeText('blizzard_mainmenubarbagbuttons/shared/mainmenubarbagmanager.lua')
|
|
MainMenuBarBagManager = { allBagButtons = {} }
|
|
function tContains(items, value) for _, item in ipairs(items) do if item == value then return true end end end
|
|
nativeFunction(managerText, 'MainMenuBarBagManager:RegisterBagButton')
|
|
nativeFunction(managerText, 'MainMenuBarBagManager:EnumerateBagButtons')
|
|
assert((loadstring or load)(nativeText('blizzard_mainmenubarbagbuttons/shared/bagsbar.lua'), '@original70334-bagsbar'))()
|
|
Enum.BagsDirection = { Left = 0, Right = 1, Up = 2, Down = 3 }
|
|
local function sizedFrame(id, width)
|
|
local button = frame(id)
|
|
button.width, button.height = width or 45, 45
|
|
function button:GetWidth() return self.width end
|
|
function button:GetHeight() return self.height end
|
|
function button:SetSize(w, h) assert(not combat); self.width, self.height = w, h end
|
|
function button:ClearAllPoints() self.anchor = nil end
|
|
function button:SetPoint(...) self.anchor = { ... } end
|
|
return button
|
|
end
|
|
BagsBar = sizedFrame(nil, 1)
|
|
for name, method in pairs(BagsBarMixin) do BagsBar[name] = method end
|
|
BagsBar.initialHeight, BagsBar.bagPadding, BagsBar.hideExpandToggle = 45, 2, true
|
|
BagsBar.isHorizontal, BagsBar.direction = true, Enum.BagsDirection.Left
|
|
BagsBar.anchor = { 'TOPLEFT', 'owner native Edit Mode position', 123, 456 }
|
|
local editModeAnchor = BagsBar.anchor
|
|
MainMenuBarBackpackButton = sizedFrame(0)
|
|
local equipped = {}
|
|
for i = 1, 4 do equipped[i] = sizedFrame(i) end
|
|
CharacterReagentBag0Slot = sizedFrame(5)
|
|
KeyRingButton = sizedFrame(KEYRING_CONTAINER, 33)
|
|
for _, button in ipairs({ MainMenuBarBackpackButton, equipped[1], equipped[2], equipped[3], equipped[4], CharacterReagentBag0Slot, KeyRingButton }) do
|
|
MainMenuBarBagManager:RegisterBagButton(button)
|
|
end
|
|
local nativeLength, nativeDirection = BagsBar.GetBagBarLength, BagsBar.direction
|
|
local registeredButtons = {}
|
|
for i, button in ipairs(MainMenuBarBagManager.allBagButtons) do registeredButtons[i] = button end
|
|
local function checkRegistry()
|
|
assert(#MainMenuBarBagManager.allBagButtons == #registeredButtons)
|
|
for i, button in ipairs(registeredButtons) do assert(MainMenuBarBagManager.allBagButtons[i] == button) end
|
|
end
|
|
assert(BagsBar:GetBagBarLength() == 315) -- original70334: the registered reagent slot is measured
|
|
-- The bag bar is fixed in Blizzard's own code now (#107): run the edited store files, not an addon post-hook.
|
|
local function editedChunk(path, first, last, name)
|
|
local text = assert(io.open(path, 'rb')):read('*a')
|
|
local a = assert(text:find(first, 1, true), first)
|
|
local b = assert(text:find(last, a, true), last)
|
|
return assert((loadstring or load)(text:sub(a, b + #last - 1), name))
|
|
end
|
|
function tDeleteItem(items, value) for i = #items, 1, -1 do if items[i] == value then table.remove(items, i) end end end
|
|
CharacterReagentBagMixin, BaseBagSlotButtonMixin = {}, { BagSlotOnLoad = function() end }
|
|
editedChunk('ops/content-nativebars-20261126/7465623.after.lua', 'function CharacterReagentBagMixin:BagSlotOnLoad()',
|
|
'function CharacterReagentBagMixin:BagSlotOnShow()\r\n\tself:Hide();\r\nend', '@content-358abf40-reagent')()
|
|
CharacterReagentBagMixin.BagSlotOnLoad(CharacterReagentBag0Slot) -- content 358abf40: leaves the list, stays hidden
|
|
for i = #registeredButtons, 1, -1 do if registeredButtons[i] == CharacterReagentBag0Slot then table.remove(registeredButtons, i) end end
|
|
handlers.event(nil, 'ADDON_LOADED', 'UnrelatedAddon')
|
|
assert(ContainerFrame_GetContainerNumSlots(0) == 20)
|
|
accountSecured = true -- supported native engine profile
|
|
handlers.event(nil, 'ADDON_LOADED', 'Blizzard_MainMenuBarBagButtons')
|
|
BagsBar:Layout() -- native Edit Mode layout; the addon no longer hooks it
|
|
assert(not CharacterReagentBag0Slot.shown)
|
|
checkRegistry()
|
|
assert(BagsBar.width == 268 and BagsBar.height == 45)
|
|
assert(KeyRingButton.anchor[2] == equipped[4]) -- Native Layout skipped reagent.
|
|
assert(BagsBar.anchor == editModeAnchor and BagsBar.GetBagBarLength == nativeLength and BagsBar.direction == nativeDirection)
|
|
local maxSlots, realSlots = ContainerFrame_GetContainerNumSlots(0)
|
|
assert(maxSlots == 16 and realSlots == 16)
|
|
assert(ContainerFrame_GetContainerNumSlots(1) == 16)
|
|
assert(ContainerFrame_GetContainerNumSlots(KEYRING_CONTAINER) == 32)
|
|
assert(C_Container.GetContainerNumSlots == rawSlots and IsAccountSecured == secured)
|
|
-- No hardcoded16 or fake account state: a future real engine count survives.
|
|
C_Container.GetContainerNumSlots = function(id) if id == 0 then return 24 end return rawSlots(id) end
|
|
assert(ContainerFrame_GetContainerNumSlots(0) == 24)
|
|
C_Container.GetContainerNumSlots = rawSlots
|
|
assert(not ContainerFrameCombinedBags.AddSlotsButton.shown)
|
|
ContainerFrameCombinedBags:UpdateAddSlots()
|
|
assert(not ContainerFrameCombinedBags.AddSlotsButton.shown) -- Original can't restore +.
|
|
|
|
-- Actual original item-button creation now emits only real slots in both modes.
|
|
STARTING_BAG_INDEX, ENDING_BAG_INDEX = 0, 4
|
|
local inventory = { itemButtonPool = {} }
|
|
for name, method in pairs(ContainerFrameMixin) do inventory[name] = method end
|
|
function inventory.itemButtonPool:ReleaseAll() end
|
|
function inventory.itemButtonPool:Acquire()
|
|
return { Initialize = function(self, bag, slot) self.bag, self.slot = bag, slot end }
|
|
end
|
|
function inventory:IsCombinedBagContainer() return true end
|
|
inventory:UpdateItemSlots()
|
|
assert(#inventory.Items == 80)
|
|
for _, item in ipairs(inventory.Items) do assert(item.slot >= 1 and item.slot <= 16 and item.bag <= 4) end
|
|
function inventory:IsCombinedBagContainer() return false end
|
|
function inventory:GetBagID() return 0 end
|
|
function inventory:GetBagSize() return 16 end
|
|
inventory:UpdateItemSlots(); assert(#inventory.Items == 16)
|
|
|
|
-- Native orientation, hidden-keyring geometry and combat deferral survive.
|
|
-- Content 1bd1b939: a keyring hidden at load (no keyring rule) leaves the list in Blizzard's own hidden branch.
|
|
local keyringRule = C_ActionBar
|
|
C_ActionBar = { ShouldShowKeyring = function() return false end }
|
|
function KeyRingButton:Disable() end
|
|
editedChunk('ops/content-keyringbar-20261126/7465621.after.lua', '\tif(not C_ActionBar.ShouldShowKeyring()) then',
|
|
'tDeleteItem(MainMenuBarBagManager.allBagButtons, KeyRingButton);\r\n\tend', '@content-1bd1b939-keyring')()
|
|
C_ActionBar = keyringRule
|
|
assert(not KeyRingButton.shown)
|
|
for i = #registeredButtons, 1, -1 do if registeredButtons[i] == KeyRingButton then table.remove(registeredButtons, i) end end
|
|
checkRegistry()
|
|
handlers.event(nil, 'BAG_UPDATE')
|
|
BagsBar:Layout()
|
|
assert(BagsBar.width == 233) -- no empty keyring slot
|
|
BagsBar.isHorizontal, BagsBar.direction = false, Enum.BagsDirection.Up
|
|
BagsBar:Layout(); assert(BagsBar.width == 45 and BagsBar.height == 233)
|
|
assert(BagsBar.anchor == editModeAnchor and BagsBar.direction == Enum.BagsDirection.Up)
|
|
local moved = { 'BOTTOMRIGHT', 'saved custom layout', -80, 25 }
|
|
BagsBar.anchor = moved
|
|
BagsBar:Layout()
|
|
handlers.event(nil, 'BAG_UPDATE')
|
|
assert(BagsBar.anchor == moved and BagsBar.GetBagBarLength == nativeLength)
|
|
BagsBar.anchor = editModeAnchor
|
|
combat = true; handlers.event(nil, 'BAG_UPDATE'); combat = false; handlers.event(nil, 'PLAYER_REGEN_ENABLED')
|
|
checkRegistry() -- the addon never edits the bag button list
|
|
assert(not tContains(MainMenuBarBagManager.allBagButtons, CharacterReagentBag0Slot))
|
|
assert(ToggleBag == toggle and BagsBar.GetBagBarLength == nativeLength and BagsBar.anchor == editModeAnchor)
|
|
|
|
-- A first click on a visible empty keyring used to reach the original toggle
|
|
-- with showKeyring disabled. Exercise that exact handler and frame creation.
|
|
local keyringText = nativeText('blizzard_mainmenubarbagbuttons/camelot/mainmenubarbagbuttons.lua')
|
|
KeyRingMixin = {}
|
|
nativeFunction(keyringText, 'KeyRingMixin:BagSlotOnClick')
|
|
nativeFunction(keyringText, 'KeyRingMixin:OnBagUpdate')
|
|
nativeFunction(containerText, 'ToggleBag')
|
|
nativeFunction(containerText, 'ToggleBag_Individual')
|
|
ContainerFrameSettingsManager = { isUsingCombinedBags = true }
|
|
nativeFunction(containerText, 'ContainerFrameSettingsManager:IsUsingCombinedBags')
|
|
local enabled, heldItem, allowed, available, gamepad = false, false, true, true, false
|
|
local writes, deposits = 0, 0
|
|
function GetCVarBool(name) assert(name == 'showKeyring'); return enabled end
|
|
function SetCVar(name, value)
|
|
assert(name == 'showKeyring' and value == 1)
|
|
enabled, writes = true, writes + 1
|
|
end
|
|
function ContainerFrame_AllowedToOpenBags() return allowed end
|
|
function CursorHasItem() return heldItem end
|
|
function PutKeyInKeyRing() deposits = deposits + 1 end
|
|
C_ActionBar = { ShouldShowKeyring = function() return available end }
|
|
InputUtil = { IsGamepadUIEnabled = function() return gamepad end }
|
|
function ContainerFrame_IsGenericHeldBag(id) return id >= 0 and id <= 4 end
|
|
function ContainerFrame_IsBankTab() return false end
|
|
function CanAutoSetGamePadCursorControl() return false end
|
|
function SetButtonPulse() end
|
|
local window = frame(KEYRING_CONTAINER)
|
|
window:Hide()
|
|
function window:IsBackpack() return false end
|
|
function ContainerFrameUtil_GetShownFrameForID(id)
|
|
assert(id == KEYRING_CONTAINER)
|
|
if window:IsShown() then return window end
|
|
end
|
|
function ContainerFrame_GetOpenFrame(id) assert(id == KEYRING_CONTAINER); return window end
|
|
function ContainerFrame_GenerateFrame(f, size, id)
|
|
assert(f == window and size == 32 and id == KEYRING_CONTAINER)
|
|
f:Show()
|
|
end
|
|
|
|
KeyRingButton.OnBagUpdate = KeyRingMixin.OnBagUpdate
|
|
function KeyRingButton:UpdateTextures() end
|
|
KeyRingButton:Show()
|
|
KeyRingButton:OnBagUpdate()
|
|
assert(KeyRingButton.bagAtlas == 'UI-HUD-ActionBar-IconFrame-Slot-Small')
|
|
KeyRingMixin.BagSlotOnClick(KeyRingButton)
|
|
assert(not window:IsShown())
|
|
local beforeClick
|
|
function KeyRingButton:HookScript(name, fn)
|
|
assert(name == 'PreClick' and beforeClick == nil)
|
|
beforeClick = fn
|
|
end
|
|
handlers.event(nil, 'BAG_UPDATE')
|
|
handlers.event(nil, 'BAG_UPDATE')
|
|
assert(writes == 0)
|
|
local function click(mouseButton)
|
|
beforeClick(KeyRingButton, mouseButton)
|
|
KeyRingMixin.BagSlotOnClick(KeyRingButton)
|
|
end
|
|
heldItem = true; click('LeftButton'); heldItem = false
|
|
assert(deposits == 1 and writes == 0)
|
|
allowed = false; click('LeftButton'); allowed = true
|
|
available = false; click('RightButton'); available = true
|
|
combat = true; click('LeftButton'); combat = false
|
|
assert(not window:IsShown() and writes == 0)
|
|
click('LeftButton')
|
|
assert(window:IsShown() and writes == 1 and STARTING_BAG_INDEX == 0)
|
|
assert(KeyRingButton.bagAtlas == 'UI-HUD-ActionBar-Keyring-Small')
|
|
click('RightButton')
|
|
assert(not window:IsShown() and writes == 1)
|
|
enabled, gamepad = false, true
|
|
click('RightButton')
|
|
assert(window:IsShown() and writes == 2 and STARTING_BAG_INDEX == KEYRING_CONTAINER)
|
|
print('Native backpack count, bag bar layout/Edit Mode, keyring first click, native toggle/deposit and combat deferral PASS')
|