mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 22:15:57 +00:00
Add keyboard and mouse button prompts (prompts = pc)
The Button prompts row gets a third choice, PC: every button glyph of the game's button font and every image of the button guide is drawn as the key or mouse button the keyboard defaults press it with (E, Shift, Space, left click, Q, R, right click, F, Tab, M, 1 to 4, W A S D, Ctrl, C) and the right stick as the mouse, whatever the pad layout. The setup writes romfs-patches-pc next to the Xbox folders (make_romfs_patches.py --prompts pc, button_icons.py pc_icons); --binds <totk.ini> draws the keys of its bind_ lines instead. At a game resolution of another shape the game takes romfs-patches-pc-<w>x<h> (--prompts pc --aspect) in place of romfs-patches-<w>x<h> when it is there. (cherry picked from commit 3f81cf02be664100bd9c569c53588d620d90b527)
This commit is contained in:
1 parent
56b3cd1246
commit
cb628b08b7
22 files changed
+386
-84
No files matched your search
+4
-4
@@ -241,10 +241,10 @@ def write_if_changed(path, text):
|
||||
def copy_romfs_patches(version, out):
|
||||
"""totk.exe loads romfs-patches beside romfs-index.bin (runtime/romfs.c overlay_init). tools/make_romfs_patches.py
|
||||
writes them into build/<version> only, so a build in another directory ran without the 60 fps overlay (the quick
|
||||
menus' captured background turned black). Copies them when their manifest differs; romfs-patches-xbox and
|
||||
romfs-patches-xbox-label (the same with Xbox button prompts, make_romfs_patches.py --prompts) the same way when they
|
||||
were made."""
|
||||
for name in ('romfs-patches', 'romfs-patches-xbox', 'romfs-patches-xbox-label'):
|
||||
menus' captured background turned black). Copies them when their manifest differs; romfs-patches-xbox,
|
||||
romfs-patches-xbox-label and romfs-patches-pc (the same with Xbox or keyboard and mouse button prompts,
|
||||
make_romfs_patches.py --prompts) the same way when they were made."""
|
||||
for name in ('romfs-patches', 'romfs-patches-xbox', 'romfs-patches-xbox-label', 'romfs-patches-pc'):
|
||||
src = ROOT / 'build' / version / name
|
||||
dst = out / name
|
||||
if src.resolve() == dst.resolve() or not (src / 'manifest.tsv').is_file():
|
||||
|
||||
+176
-7
@@ -1,6 +1,7 @@
|
||||
# Adapted from MacNativeGames games/totk/scripts/make_button_icons.py @ 933b6a0 (MIT, Copyright (c) 2026
|
||||
# MacNativeGames contributors).
|
||||
"""Xbox button icons for the game's prompts, drawn on the player's machine for tools/make_romfs_patches.py --prompts.
|
||||
"""Xbox and keyboard-and-mouse button icons for the game's prompts, drawn on the player's machine for
|
||||
tools/make_romfs_patches.py --prompts.
|
||||
The outlines are our own shapes with letters cut out of them in the game's own text fonts: nothing of the game is in
|
||||
the repository.
|
||||
|
||||
@@ -9,13 +10,15 @@ Font/Font*.Nin_NX_NVN.bfarc.zs: private-use code points from U+E040 (A, B, X, Y,
|
||||
Minus, the sticks). A .bfotf is an OpenType (CFF) font after an 8-byte header; from offset 4 on, every byte is XORed
|
||||
with a 4-byte key, which the size in the header's second word gives away (bfotf_decode). redraw_font draws the shoulder
|
||||
buttons, the triggers, Plus, Minus and the d-pad as an Xbox controller names them (LB RB, LT RT, Menu and View, a
|
||||
cross), can swap the glyphs of the face buttons (A with B, X with Y), and has fontTools write the font again. The
|
||||
archive then grows by a kilobyte or two, more than the game's resource size table allows it: grow_restbl raises those
|
||||
entries (without it the game stops at start, MacNativeGames found).
|
||||
cross), or every button as the key or mouse button the keyboard presses it with (pc_icons), can swap the glyphs of
|
||||
the face buttons (A with B, X with Y), and has fontTools write the font again. The archive then grows by a kilobyte or
|
||||
two, more than the game's resource size table allows it: grow_restbl raises those entries (without it the game stops at
|
||||
start, MacNativeGames found).
|
||||
|
||||
The button guide in play (bottom right) draws L and ZL from images of the common layout archive instead
|
||||
(timg/__Combined.bntx, Nt_KeyTexL_00 and Nt_KeyTexZL_00): bntx_redraw paints the same icons into them, the size
|
||||
unchanged. The sticks keep the Switch icons, and so do prompts drawn as fixed images (some tutorial animations).
|
||||
The button guide in play (bottom right) draws its buttons, L and ZL among them, from images of the common layout
|
||||
archive instead (timg/__Combined.bntx, Nt_KeyTexL_00 and Nt_KeyTexZL_00): bntx_redraw paints the same icons into them,
|
||||
the size unchanged. The Xbox prompts redraw L and ZL, the keyboard and mouse ones every image (PC_HUD_TEXTURES: A, B, X,
|
||||
Y, L, ZL and the stick's two). Prompts drawn as fixed images (some tutorial animations) keep the Switch icons.
|
||||
|
||||
Needs fontTools (tools/requirements-installer.txt, tools/requirements-py314.txt).
|
||||
"""
|
||||
@@ -180,6 +183,172 @@ def xbox_icons(g):
|
||||
}
|
||||
|
||||
|
||||
# ---- keyboard and mouse prompts (--prompts pc): every button the keyboard drives, drawn as the key or mouse button
|
||||
# bound to it, in the same filled-shape style. Each glyph keeps the advance of the game's own (a wider glyph runs into
|
||||
# the text of a right-aligned guide).
|
||||
# The keyboard defaults of runtime/input_map.c (input_map_reset; the totk.ini bind_ lines apply on top, pc_binds). The
|
||||
# right stick is the camera, which the mouse drives.
|
||||
PC_BINDS = {
|
||||
'A': 'e', 'B': 'lshift', 'X': 'space', 'Y': 'mouse_l', 'L': 'q', 'R': 'r', 'ZL': 'mouse_r', 'ZR': 'f',
|
||||
'PLUS': 'tab', 'MINUS': 'm', 'LEFT': '1', 'UP': '2', 'RIGHT': '3', 'DOWN': '4', 'LCLICK': 'lctrl', 'RCLICK': 'c',
|
||||
'LSTICK_UP': 'w', 'LSTICK_LEFT': 'a', 'LSTICK_DOWN': 's', 'LSTICK_RIGHT': 'd',
|
||||
}
|
||||
# What a key shows: its letter, a symbol or a short name (key names as in totk.ini; the rest show their name).
|
||||
PC_LABELS = {
|
||||
'lshift': '⇧', 'rshift': '⇧', 'lctrl': 'CTRL', 'rctrl': 'CTRL', 'lalt': 'ALT', 'tab': 'TAB',
|
||||
'enter': 'ENT', 'backspace': 'BKSP', 'capslock': 'CAPS', 'insert': 'INS', 'delete': 'DEL', 'home': 'HOME',
|
||||
'end': 'END', 'pageup': 'PGUP', 'pagedown': 'PGDN', 'up': '↑', 'down': '↓', 'left': '←',
|
||||
'right': '→', 'num_add': '+', 'num_sub': '-', 'num_mul': '*', 'num_div': '/', 'num_decimal': '.',
|
||||
'minus': '-', 'equals': '=', 'lbracket': '[', 'rbracket': ']', 'semicolon': ';', 'apostrophe': "'", 'comma': ',',
|
||||
'period': '.', 'slash': '/', 'backslash': '\\', 'grave': '`', 'mouse_x1': 'M4', 'mouse_x2': 'M5',
|
||||
}
|
||||
# The one-letter panes around the action prompt (T_A_00 ...) are in the Normal font (Rodin B and Symbol): one character
|
||||
# of it per key.
|
||||
PC_LETTER_LABELS = {'lshift': '↑', 'rshift': '↑', 'space': '▬', 'mouse_l': 'L', 'mouse_r': 'R',
|
||||
'mouse_m': 'M', 'lctrl': 'C', 'rctrl': 'C', 'tab': 'T'}
|
||||
# The button guide's images in the pc style: every symbol mask of the action prompt (LSt_00 the stick tilted, LSt_01
|
||||
# the stick pressed).
|
||||
PC_HUD_TEXTURES = {'Nt_KeyTexA_00': 0xE040, 'Nt_KeyTexB_00': 0xE041, 'Nt_KeyTexX_00': 0xE042, 'Nt_KeyTexY_00': 0xE043,
|
||||
'Nt_KeyTexL_00': 0xE044, 'Nt_KeyTexZL_00': 0xE046, 'Nt_KeyTexLSt_00': 0xE05E,
|
||||
'Nt_KeyTexLSt_01': 0xE056}
|
||||
PC_MOUSE = ('mouse_l', 'mouse_r', 'mouse_m')
|
||||
|
||||
|
||||
def pc_binds(ini_text=None):
|
||||
"""PC_BINDS with the first key of each bind_<action> line of a totk.ini text over it (a line without a key entry,
|
||||
or with key:default, keeps the default)."""
|
||||
binds = dict(PC_BINDS)
|
||||
for line in (ini_text or '').splitlines():
|
||||
line = line.split('#')[0].split(';')[0].strip()
|
||||
if not line.lower().startswith('bind_') or '=' not in line:
|
||||
continue
|
||||
action, value = (s.strip() for s in line.split('=', 1))
|
||||
keys = [e.strip()[4:].strip().lower() for e in value.split(',') if e.strip().lower().startswith('key:')]
|
||||
keys = [k for k in keys if k != 'default']
|
||||
if keys and action[5:].upper() in binds:
|
||||
binds[action[5:].upper()] = keys[0]
|
||||
return binds
|
||||
|
||||
|
||||
def font_advances(blob):
|
||||
"""Code point -> advance of every glyph of the button font (a .bfotf)."""
|
||||
font = TTFont(io.BytesIO(bfotf_decode(blob)[0]))
|
||||
return {cp: font['hmtx'][name][0] for cp, name in font.getBestCmap().items()}
|
||||
|
||||
|
||||
def pc_letter(key):
|
||||
"""The one character the panes around the action prompt show for key."""
|
||||
if key in PC_LETTER_LABELS:
|
||||
return PC_LETTER_LABELS[key]
|
||||
return PC_LABELS.get(key, key.upper())[0]
|
||||
|
||||
|
||||
def pc_icons(g, adv, binds=PC_BINDS):
|
||||
"""Code point -> (advance, draw(pen)) for every button glyph but Home and Capture, drawn as the key or mouse button
|
||||
binds puts on it. g: Glyphs for the key labels; adv: the game's advance of each glyph (font_advances), which each
|
||||
drawing keeps."""
|
||||
def mouse_body(pen, cx, y0, y1, lit=None):
|
||||
"""A mouse seen from above; lit ('l', 'r', 'm' or None) its pressed button, filled, the others hollow."""
|
||||
h = y1 - y0; r = h * 0.33; t = h * 0.07; gap = h * 0.035
|
||||
x0, x1, mid = cx - r, cx + r, y0 + h * 0.52
|
||||
rounded(pen, x0, y0, x1, y1, r * 0.9, r)
|
||||
reverse = ReverseContourPen(pen) # holes; they never overlap each other or leave the body
|
||||
ri = r - t
|
||||
if lit in ('l', 'r'): # the seams around the pressed button
|
||||
sx0, sx1 = (x0 + t, cx - gap) if lit == 'l' else (cx + gap, x1 - t)
|
||||
polygon(reverse, [(sx0, mid - gap), (sx1, mid - gap), (sx1, mid + gap), (sx0, mid + gap)])
|
||||
polygon(reverse, [(cx - gap, mid + gap), (cx + gap, mid + gap), (cx + gap, y1 - t), (cx - gap, y1 - t)])
|
||||
if lit != 'l': # hollow left button, its outer top corner following the body
|
||||
ix0, ix1 = x0 + t, cx - gap
|
||||
reverse.moveTo((ix1, mid + gap)); reverse.lineTo((ix1, y1 - t)); reverse.lineTo((ix0 + ri, y1 - t))
|
||||
reverse.curveTo((ix0 + ri - K * ri, y1 - t), (ix0, y1 - t - ri + K * ri), (ix0, y1 - t - ri))
|
||||
reverse.lineTo((ix0, mid + gap)); reverse.closePath()
|
||||
if lit != 'r':
|
||||
ix0, ix1 = cx + gap, x1 - t
|
||||
reverse.moveTo((ix0, mid + gap)); reverse.lineTo((ix1, mid + gap)); reverse.lineTo((ix1, y1 - t - ri))
|
||||
reverse.curveTo((ix1, y1 - t - ri + K * ri), (ix1 - ri + K * ri, y1 - t), (ix1 - ri, y1 - t))
|
||||
reverse.lineTo((ix0, y1 - t)); reverse.closePath()
|
||||
if lit == 'm': # the wheel, filled over the gap between the hollow buttons
|
||||
rounded(pen, cx - h * 0.06, mid + h * 0.12, cx + h * 0.06, mid + h * 0.36, h * 0.06)
|
||||
|
||||
def key_cap(pen, x0, y0, x1, y1, key):
|
||||
"""A key: a rounded square with its label cut out; a mouse button draws the mouse."""
|
||||
if key in PC_MOUSE:
|
||||
mouse_body(pen, (x0 + x1) / 2, y0, y1, key[6:])
|
||||
return
|
||||
w, h = x1 - x0, y1 - y0
|
||||
rounded(pen, x0, y0, x1, y1, min(w, h) * 0.18)
|
||||
if key == 'space': # an open bracket lying on its back
|
||||
t = h * 0.09
|
||||
bx0, bx1, by0, by1 = x0 + w * 0.22, x1 - w * 0.22, y0 + h * 0.36, y0 + h * 0.60
|
||||
polygon(ReverseContourPen(pen), [(bx0, by0), (bx1, by0), (bx1, by1), (bx1 - t, by1), (bx1 - t, by0 + t),
|
||||
(bx0 + t, by0 + t), (bx0 + t, by1), (bx0, by1)])
|
||||
return
|
||||
label = PC_LABELS.get(key, key.upper())
|
||||
cap = h * (0.52 if len(label) == 1 else 0.36 if len(label) == 2 else 0.26)
|
||||
g.hole(pen, label, (x0 + x1) / 2, (y0 + y1) / 2, cap, w * 0.74)
|
||||
|
||||
def arrow(pen, cx, cy, d, s):
|
||||
"""A filled arrowhead pointing d, s its half size."""
|
||||
polygon(pen, {'up': [(cx - s, cy - s * 0.6), (cx + s, cy - s * 0.6), (cx, cy + s * 0.8)],
|
||||
'down': [(cx + s, cy + s * 0.6), (cx - s, cy + s * 0.6), (cx, cy - s * 0.8)],
|
||||
'left': [(cx + s * 0.6, cy - s), (cx + s * 0.6, cy + s), (cx - s * 0.8, cy)],
|
||||
'right': [(cx - s * 0.6, cy + s), (cx - s * 0.6, cy - s), (cx + s * 0.8, cy)]}[d])
|
||||
|
||||
def one(key, advance):
|
||||
def draw(pen):
|
||||
side = min(advance - 80, Y1 - Y0)
|
||||
key_cap(pen, (advance - side) / 2, Y0, (advance + side) / 2, Y1, key)
|
||||
return advance, draw
|
||||
|
||||
def grid(cells, advance):
|
||||
"""Small keys in a grid: cells = [(key, column, row)], row 0 on top."""
|
||||
def draw(pen):
|
||||
cols, rows = max(c for _, c, _ in cells) + 1, max(r for _, _, r in cells) + 1
|
||||
gap = 24; size = min((advance - 60 - gap * (cols - 1)) / cols, (Y1 - Y0 - gap * (rows - 1)) / rows)
|
||||
left, top = (advance - cols * size - gap * (cols - 1)) / 2, CY + (rows * size + gap * (rows - 1)) / 2
|
||||
for key, c, r in cells:
|
||||
x, y = left + c * (size + gap), top - (r + 1) * size - r * gap
|
||||
key_cap(pen, x, y, x + size, y + size, key)
|
||||
return advance, draw
|
||||
|
||||
def mouse_move(advance, *dirs):
|
||||
"""The mouse, no button pressed, with an arrow for each direction the prompt means."""
|
||||
def draw(pen):
|
||||
mouse_body(pen, advance / 2, Y0 + 30, Y1 - 30)
|
||||
off = (Y1 - Y0 - 60) * 0.33 + 70
|
||||
spots = {'up': (advance / 2 + off, CY + 110), 'down': (advance / 2 + off, CY - 110),
|
||||
'left': (advance / 2 - off, CY), 'right': (advance / 2 + off, CY)}
|
||||
for d in dirs:
|
||||
arrow(pen, *spots[d], d, 52)
|
||||
return advance, draw
|
||||
|
||||
b = binds
|
||||
up, left, down, right = b['LSTICK_UP'], b['LSTICK_LEFT'], b['LSTICK_DOWN'], b['LSTICK_RIGHT']
|
||||
du, dl, dd, dr = b['UP'], b['LEFT'], b['DOWN'], b['RIGHT']
|
||||
return {
|
||||
**{cp: one(b[name], adv[cp]) for cp, name in ((0xE040, 'A'), (0xE041, 'B'), (0xE042, 'X'), (0xE043, 'Y'),
|
||||
(0xE044, 'L'), (0xE045, 'R'), (0xE046, 'ZL'), (0xE047, 'ZR'),
|
||||
(0xE04B, 'PLUS'), (0xE04C, 'MINUS'), (0xE056, 'LCLICK'),
|
||||
(0xE057, 'RCLICK'))},
|
||||
# the d-pad: its four keys as a cross (up on top), or the keys of the directions the prompt means
|
||||
0xE049: grid([(du, 1, 0), (dl, 0, 1), (dd, 1, 1), (dr, 2, 1)], adv[0xE049]),
|
||||
0xE060: one(du, adv[0xE060]), 0xE061: one(dd, adv[0xE061]), 0xE062: one(dl, adv[0xE062]),
|
||||
0xE063: one(dr, adv[0xE063]), 0xE064: grid([(du, 0, 0), (dd, 0, 1)], adv[0xE064]),
|
||||
0xE065: grid([(dl, 0, 0), (dr, 1, 0)], adv[0xE065]),
|
||||
# the left stick: its keys (W A S D)
|
||||
0xE05E: grid([(up, 1, 0), (left, 0, 1), (down, 1, 1), (right, 2, 1)], adv[0xE05E]),
|
||||
0xE052: one(up, adv[0xE052]), 0xE050: one(down, adv[0xE050]), 0xE05A: one(left, adv[0xE05A]),
|
||||
0xE058: one(right, adv[0xE058]), 0xE05C: grid([(up, 0, 0), (down, 0, 1)], adv[0xE05C]),
|
||||
0xE054: grid([(left, 0, 0), (right, 1, 0)], adv[0xE054]),
|
||||
# the right stick: the mouse
|
||||
0xE05F: mouse_move(adv[0xE05F]), 0xE053: mouse_move(adv[0xE053], 'up'),
|
||||
0xE051: mouse_move(adv[0xE051], 'down'), 0xE05B: mouse_move(adv[0xE05B], 'left'),
|
||||
0xE059: mouse_move(adv[0xE059], 'right'), 0xE05D: mouse_move(adv[0xE05D], 'up', 'down'),
|
||||
0xE055: mouse_move(adv[0xE055], 'left', 'right'), 0xE068: mouse_move(adv[0xE068], 'left', 'right'),
|
||||
}
|
||||
|
||||
|
||||
def redraw_font(otf, icons, swaps=()):
|
||||
"""The OpenType font otf with the glyphs of each (code point, code point) pair of swaps trading places (outlines and
|
||||
horizontal metrics), then every code point of icons (code point -> (advance, draw)) drawn anew, written again by
|
||||
|
||||
+27
-10
@@ -38,6 +38,11 @@ from the game's own files on the player's machine, nothing added (tools/button_i
|
||||
every pad not labelled the Nintendo way), so the face buttons keep their letters; the action prompt's diamond keeps
|
||||
the Switch positions (A on the right).
|
||||
--xbox-prompts is the older name of --prompts xbox.
|
||||
--prompts pc: keyboard and mouse prompts, for prompts = pc (romfs-patches-pc, or romfs-patches-pc-<w>x<h> with
|
||||
--aspect): every button of the button font is drawn as the key or mouse button the keyboard defaults put on it
|
||||
(button_icons.pc_icons; --binds <totk.ini> takes the first key of its bind_ lines instead), and so are the button
|
||||
guide's images (A, B, X, Y, L, ZL and the stick's two). The one-letter panes around the action prompt name the keys
|
||||
with one character of the Normal font (E, an arrow for Shift, a bar for Space, L and R for the mouse buttons).
|
||||
|
||||
Input: build/extracted/<version>/romfs (romfs.bin and index.json, verified by tools/extract.py). Output:
|
||||
build/<version>/romfs-patches/<path> by default (romfs-patches-<style> with --prompts), and <out>/manifest.tsv (path, size, SHA-256 of the overlay, SHA-256 of the original). Run with .venv-py314.
|
||||
@@ -58,9 +63,11 @@ ap.add_argument('--romfs', type=Path, help='default build/extracted/<version>/ro
|
||||
ap.add_argument('--out', type=Path,
|
||||
help='default build/<version>/romfs-patches (romfs-patches-<style> with --prompts)')
|
||||
ap.add_argument('--aspect', help='<w>x<h> of a game resolution of another shape than 16:9: also lay the UI out for it')
|
||||
ap.add_argument('--prompts', choices=('xbox', 'xbox-label'),
|
||||
ap.add_argument('--prompts', choices=('xbox', 'xbox-label', 'pc'),
|
||||
help='Xbox button icons in the prompts: xbox for pad_layout = nintendo (A shown as B, X as Y), '
|
||||
'xbox-label for pad_layout = xbox or auto (the face buttons keep their letters)')
|
||||
'xbox-label for pad_layout = xbox or auto (the face buttons keep their letters), '
|
||||
'pc for the keyboard and mouse')
|
||||
ap.add_argument('--binds', type=Path, help='--prompts pc: a totk.ini whose bind_ lines the key icons follow')
|
||||
ap.add_argument('--xbox-prompts', dest='prompts', action='store_const', const='xbox', help='the same as --prompts xbox')
|
||||
args = ap.parse_args()
|
||||
args.romfs = args.romfs or root / 'build/extracted' / args.version / 'romfs'
|
||||
@@ -231,9 +238,11 @@ LAYOUT_MSG = 'LayoutMsg/DoCommand_00.msbt'
|
||||
RESTBL = max((p for p in files if p.startswith('System/Resource/ResourceSizeTable.') and p.endswith('.rsizetable.zs')),
|
||||
key=lambda p: int((re.search(r'\.(\d+)\.', p) or [0, 0])[1]), default=None)
|
||||
by_position = args.prompts == 'xbox' # the face buttons' prompts swapped to the labels (pad_layout = nintendo)
|
||||
pc = args.prompts == 'pc'
|
||||
letter_panes = by_position or pc # the one-letter panes around the action prompt change
|
||||
if args.prompts:
|
||||
assert FONTS, 'no Font/Font*.Nin_NX_NVN.bfarc.zs in the RomFS'
|
||||
assert MALS or not by_position, 'no Mals/<language>.Product.<version>.sarc.zs in the RomFS'
|
||||
assert MALS or not letter_panes, 'no Mals/<language>.Product.<version>.sarc.zs in the RomFS'
|
||||
assert RESTBL, 'no System/Resource/ResourceSizeTable.Product.<n>...rsizetable.zs in the RomFS'
|
||||
spec = importlib.util.spec_from_file_location('button_icons', Path(__file__).with_name('button_icons.py'))
|
||||
icons = importlib.util.module_from_spec(spec)
|
||||
@@ -252,7 +261,7 @@ with (args.romfs / 'romfs.bin').open('rb') as image:
|
||||
for name, (lo, hi) in sarc_members(pack).items():
|
||||
d = zstd.ZstdDict(pack[lo:hi])
|
||||
dictionaries[d.dict_id] = d
|
||||
prompt_files = (FONTS + (MALS if by_position else []) + [RESTBL]) if args.prompts else []
|
||||
prompt_files = (FONTS + (MALS if letter_panes else []) + [RESTBL]) if args.prompts else []
|
||||
originals = {path: read(path) for path in [ARCHIVE] + prompt_files}
|
||||
raw = originals[ARCHIVE]
|
||||
info = zstd.get_frame_info(raw)
|
||||
@@ -297,19 +306,27 @@ if args.prompts:
|
||||
text = sarc_members(archives[icons.TEXT_ARCHIVE])
|
||||
missing = [name for name in icons.TEXT_FONTS if name not in text]
|
||||
assert not missing, f'no {", ".join(missing)} in {icons.TEXT_ARCHIVE}'
|
||||
drawn = icons.xbox_icons(icons.text_glyphs(archives[icons.TEXT_ARCHIVE][slice(*text[name])]
|
||||
for name in icons.TEXT_FONTS))
|
||||
glyphs = icons.text_glyphs(archives[icons.TEXT_ARCHIVE][slice(*text[name])] for name in icons.TEXT_FONTS)
|
||||
if pc:
|
||||
binds = icons.pc_binds(args.binds.read_text(encoding='utf-8', errors='replace') if args.binds else None)
|
||||
advances = icons.font_advances(archives[icons.TEXT_ARCHIVE][slice(*text[icons.FONT])])
|
||||
drawn = icons.pc_icons(glyphs, advances, binds)
|
||||
pane_letters = {letter: icons.pc_letter(binds[letter]) for letter in 'ABXY'}
|
||||
else:
|
||||
drawn = icons.xbox_icons(glyphs)
|
||||
pane_letters = KEY_LETTERS
|
||||
bntx = members['timg/__Combined.bntx'][0]
|
||||
letters = {}
|
||||
if by_position:
|
||||
bntx_swap(blarc, bntx, KEY_TEXTURES)
|
||||
if letter_panes:
|
||||
for member, (lo, hi) in members.items():
|
||||
if member.endswith('.bflyt'):
|
||||
changed = bflyt_letters(blarc, lo, hi, KEY_LETTERS)
|
||||
changed = bflyt_letters(blarc, lo, hi, pane_letters)
|
||||
if changed:
|
||||
letters[member] = changed
|
||||
assert 'blyt/DoCommand_00.bflyt' in letters, 'no letter panes in blyt/DoCommand_00.bflyt'
|
||||
hud = icons.bntx_redraw(blarc, bntx, icons.HUD_TEXTURES, drawn)
|
||||
hud = icons.bntx_redraw(blarc, bntx, icons.PC_HUD_TEXTURES if pc else icons.HUD_TEXTURES, drawn)
|
||||
outputs[ARCHIVE] = bytes(blarc)
|
||||
fonts = {} # each distinct font is drawn once (1.4.3's four archives hold the same one)
|
||||
for path, bfarc in archives.items():
|
||||
@@ -319,11 +336,11 @@ if args.prompts:
|
||||
fonts[otf] = icons.redraw_font(otf, drawn, KEY_GLYPHS if by_position else ())
|
||||
outputs[path] = sarc_replace(bfarc, {icons.FONT: icons.bfotf_encode(fonts[otf], key, bfarc[lo:hi])})
|
||||
messages = {}
|
||||
for path in MALS if by_position else []:
|
||||
for path in MALS if letter_panes else []:
|
||||
mals = bytearray(unpack(path))
|
||||
lo, hi = sarc_members(mals)[LAYOUT_MSG]
|
||||
msbt = bytearray(mals[lo:hi])
|
||||
changed = msbt_letters(msbt, KEY_LETTERS)
|
||||
changed = msbt_letters(msbt, pane_letters)
|
||||
assert len(changed) == sum(len(v) for v in letters.values()), (path, changed)
|
||||
mals[lo:hi] = msbt
|
||||
outputs[path] = bytes(mals)
|
||||
|
||||
Reference in new issue
Block a user