119 lines
6.5 KiB
Python
119 lines
6.5 KiB
Python
"""#107 + micro menu (owner 2026-11-26: "can you not edit the code of the micro menu bar and the bag bar? so they are
|
|
permanently fixed? i'd like real fixes wherever possible"). Native Blizzard code instead of addon hooks:
|
|
- 7465623 shared/mainmenubarbagbuttons.lua: Turtle has no reagent bag. CharacterReagentBag0Slot still runs the base
|
|
bag-slot setup but leaves MainMenuBarBagManager's button list and stays hidden, so BagsBar:GetBagBarLength and Layout
|
|
never count or anchor it (the bar was one slot too wide, and whether an addon hid the slot before or after the first
|
|
Layout decided after each reload whether the empty gap showed). The gamepad copy (combined bags) inherits the hide.
|
|
- 7494336 camelot/micromenucontaineroverrides.lua: no Legacy, Housing or Adventure Guide button (no Turtle data); left
|
|
out of GenerateButtonInfos like the native AchievementMicroButton, so they are never parented or anchored.
|
|
- 8147620 camelot/mainmenubarmicrobuttonsoverrides.lua: Collections is the Mounts button: Mounts tooltip, opens on the
|
|
Mounts tab. The existing override already never disables it for an empty journal."""
|
|
import hashlib, json, struct, sys
|
|
from pathlib import Path
|
|
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
|
|
import frozen_store as fs
|
|
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
crlf = lambda s: s.replace('\r\n', '\n').replace('\n', '\r\n').encode()
|
|
def once(old, a, b):
|
|
a, b = crlf(a), crlf(b); assert old.count(a) == 1, (a[:60], old.count(a)); return old.replace(a, b)
|
|
def bags(old):
|
|
a = """function CharacterReagentBagMixin:SetBarExpanded(isExpanded)
|
|
-- Remains shown regardless of expand state
|
|
end
|
|
"""
|
|
return once(old, a, a + """
|
|
-- Octo (Turtle server): there is no reagent bag container. The slot keeps the base setup but is not part of the bag
|
|
-- bar: it leaves MainMenuBarBagManager's list, so BagsBar:GetBagBarLength and Layout never count or anchor it (no
|
|
-- empty gap left of the keyring), and it never shows.
|
|
function CharacterReagentBagMixin:BagSlotOnLoad()
|
|
BaseBagSlotButtonMixin.BagSlotOnLoad(self);
|
|
tDeleteItem(MainMenuBarBagManager.allBagButtons, self);
|
|
self:Hide();
|
|
end
|
|
|
|
function CharacterReagentBagMixin:BagSlotOnShow()
|
|
self:Hide();
|
|
end
|
|
""")
|
|
def menu(old):
|
|
for line in (" MicroMenuUtil.GenerateButtonGameRuleInfo(LegacyMicroButton),\n",
|
|
" MicroMenuUtil.GenerateButtonGameRuleInfo(HousingMicroButton, Enum.GameRule.HousingDashboardDisabled),\n",
|
|
" MicroMenuUtil.GenerateButtonCallbackInfo(EJMicroButton, GameRulesUtil.EJIsDisabled),\n"):
|
|
old = once(old, line, "")
|
|
return once(old, "function MicroMenuMixin:GenerateButtonInfos()\n",
|
|
"-- Octo (Turtle): no Legacy, Housing or Adventure Guide button; Turtle has no data for them. Like the native\n"
|
|
"-- AchievementMicroButton they are left out of the list, so they are never parented or anchored.\n"
|
|
"function MicroMenuMixin:GenerateButtonInfos()\n")
|
|
def mounts(old):
|
|
# The earlier #1 override block was appended with LF line endings; match it byte for byte.
|
|
a = """function CollectionMicroButtonMixin:UpdateMicroButton()
|
|
if ( CollectionsJournal and CollectionsJournal:IsShown() ) then
|
|
self:SetPushed();
|
|
else
|
|
self:SetNormal();
|
|
end
|
|
end
|
|
"""
|
|
assert old.count(a.encode()) == 1
|
|
return old.replace(a.encode(), (a + """
|
|
-- Octo (Turtle): this button is the Mounts button. Turtle has no pets, toys, heirlooms or appearances, so it says
|
|
-- Mounts and opens the journal on its Mounts tab.
|
|
local MOUNTS_TOOLTIP_LABEL = MOUNTS or "Mounts";
|
|
local collectionsOnLoad = CollectionMicroButtonMixin.OnLoad;
|
|
function CollectionMicroButtonMixin:OnLoad()
|
|
collectionsOnLoad(self);
|
|
self.tooltipText = MicroButtonTooltipText(MOUNTS_TOOLTIP_LABEL, "TOGGLECOLLECTIONS");
|
|
end
|
|
|
|
local collectionsOnEvent = CollectionMicroButtonMixin.OnEvent;
|
|
function CollectionMicroButtonMixin:OnEvent(event, ...)
|
|
collectionsOnEvent(self, event, ...);
|
|
if ( event == "UPDATE_BINDINGS" ) then
|
|
self.tooltipText = MicroButtonTooltipText(MOUNTS_TOOLTIP_LABEL, "TOGGLECOLLECTIONS");
|
|
end
|
|
end
|
|
|
|
function CollectionMicroButtonMixin:OnClick(button, down)
|
|
if Kiosk.IsEnabled() or DISALLOW_FRAME_TOGGLING then
|
|
return;
|
|
end
|
|
|
|
if ( not KeybindFrames_InQuickKeybindMode() ) then
|
|
if not ( CollectionsJournal and CollectionsJournal:IsShown() ) then
|
|
SetCVar("petJournalTab", 1);
|
|
end
|
|
ToggleCollectionsJournal();
|
|
end
|
|
end
|
|
""").encode())
|
|
FILES = [(7465623, 'interface/addons/blizzard_mainmenubarbagbuttons/shared/mainmenubarbagbuttons.lua', bags),
|
|
(7494336, 'interface/addons/blizzard_micromenu/camelot/micromenucontaineroverrides.lua', menu),
|
|
(8147620, 'interface/addons/blizzard_micromenu/camelot/mainmenubarmicrobuttonsoverrides.lua', mounts)]
|
|
WHY = '#107/#1: native bag bar without reagent slot; native micro menu (no Legacy/Housing/EJ, Mounts button)'
|
|
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
|
|
patched = bytearray(root); pins = []
|
|
for FID, NAME, edit in FILES:
|
|
cells = []
|
|
for g in lay['groups']:
|
|
f = 0
|
|
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += d
|
|
if f == FID: cells.append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
en = [(g, at) for g, at in cells if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, len(en)
|
|
g, at = en[0]; ck = root[at:at + 16].hex(); old = store.read(ck)[2]
|
|
new = edit(old)
|
|
(H / 'inputs' / f'{FID}.before.lua').write_bytes(old); (H / 'inputs' / f'{FID}.after.lua').write_bytes(new)
|
|
patched[at:at + 16] = bytes.fromhex(md5(new))
|
|
d = H / 'pins' / str(FID); d.mkdir(parents=True, exist_ok=True)
|
|
(d / 'before.bin').write_bytes(old); (d / 'after.bin').write_bytes(new)
|
|
pin = dict(fdid=FID, table=NAME, parent_root=fs.ROOT, selected_group={}, original_decoded=dict(file='before.bin', md5=ck, sha256=sha(old)),
|
|
encrypted_original=False, after_decoded=dict(file='after.bin', md5=md5(new), sha256=sha(new)), reason=WHY)
|
|
(d / 'pin.json').write_text(json.dumps(pin, indent=1) + '\n')
|
|
pins.append(dict(file=str(d / 'pin.json'), sha256=sha((d / 'pin.json').read_bytes()), type='wdc_enus'))
|
|
print(FID, len(old), len(new))
|
|
(H / 'components.json').write_text(json.dumps(pins, indent=2) + '\n')
|
|
(H / 'selected-root.json').write_text(json.dumps(dict(parent_build=fs.BUILD, parent_root=fs.ROOT,
|
|
decoded_root_sha256=sha(bytes(patched)), parent_root_sha256=sha(root)), indent=2) + '\n')
|
|
print('pins', len(pins))
|