45 lines
2.7 KiB
Lua
45 lines
2.7 KiB
Lua
-- OctoTextSize: addon-local factory; Blizzard CreateFrame is unchanged.
|
|
local CreateFrame = OctoTextSize and OctoTextSize.WrapFactory(CreateFrame) or CreateFrame
|
|
-- #90 (owner 2026-11-26): the native guild bank offers a sixth tab to buy, but the Turtle guild bank has 5 tabs
|
|
-- (GuildBank.cpp MAX_TABS = 5). Hide only that purchase tab after the native UpdateTabs; no Blizzard globals change.
|
|
local TURTLE_MAX_TABS = 5;
|
|
local function HideExtraPurchaseTab(frame)
|
|
local numTabs = GetNumGuildBankTabs and GetNumGuildBankTabs() or 0;
|
|
if numTabs < TURTLE_MAX_TABS or not frame or not frame.BankTabs then return; end
|
|
for i = TURTLE_MAX_TABS + 1, #frame.BankTabs do
|
|
local tab = frame.BankTabs[i];
|
|
if tab and tab:IsShown() then tab:Hide(); end
|
|
end
|
|
if frame.BuyInfo and frame.BuyInfo:IsShown() and (GetCurrentGuildBankTab and GetCurrentGuildBankTab() > numTabs) then
|
|
frame.BuyInfo:Hide();
|
|
end
|
|
end
|
|
-- Owner 2026-11-27: the buy panel showed "1/6" and the retail tab price. Turtle GuildBank.cpp GuildBankCosts:
|
|
-- bank (first tab) 2000g, tabs 2..5 500/1000/1500/2000g, paid from the player's money (the gateway sends
|
|
-- UnlockTab:<n>:1), so the purchase check uses GetMoney(), not the guild bank's money.
|
|
local GOLD = 10000;
|
|
local TURTLE_TAB_COST = { 2000 * GOLD, 500 * GOLD, 1000 * GOLD, 1500 * GOLD, 2000 * GOLD };
|
|
local function TurtleTabBuyingInfo(frame)
|
|
if not frame or not frame.BuyInfo then return; end
|
|
local numTabs = GetNumGuildBankTabs and GetNumGuildBankTabs() or 0;
|
|
local cost = TURTLE_TAB_COST[numTabs + 1];
|
|
if frame.BuyInfo.PurchasedText and NUM_GUILDBANK_TABS_PURCHASED then
|
|
frame.BuyInfo.PurchasedText:SetText(format(NUM_GUILDBANK_TABS_PURCHASED, numTabs, TURTLE_MAX_TABS));
|
|
end
|
|
if not cost then return; end
|
|
local affordable = GetMoney() >= cost;
|
|
SetMoneyFrameColor("GuildBankFrameTabCostMoneyFrame", affordable and "white" or "red");
|
|
if frame.BuyInfo.PurchaseButton then frame.BuyInfo.PurchaseButton:SetEnabled(affordable); end
|
|
MoneyFrame_Update("GuildBankFrameTabCostMoneyFrame", cost);
|
|
end
|
|
local function Hook()
|
|
if not GuildBankFrame or GuildBankFrame.octoTurtleTabs then return; end
|
|
GuildBankFrame.octoTurtleTabs = true;
|
|
if GuildBankFrame.UpdateTabs then hooksecurefunc(GuildBankFrame, "UpdateTabs", HideExtraPurchaseTab); end
|
|
if GuildBankFrame.UpdateTabBuyingInfo then hooksecurefunc(GuildBankFrame, "UpdateTabBuyingInfo", TurtleTabBuyingInfo); end
|
|
end
|
|
local f = CreateFrame("Frame");
|
|
f:RegisterEvent("ADDON_LOADED");
|
|
f:SetScript("OnEvent", function(_, _, name) if name == "Blizzard_GuildBankUI" then Hook(); end end);
|
|
if C_AddOns and C_AddOns.IsAddOnLoaded and C_AddOns.IsAddOnLoaded("Blizzard_GuildBankUI") then Hook(); end
|