diff --git a/tests/hud_layout_test.py b/tests/hud_layout_test.py index 1a925264..e7ee56ba 100644 --- a/tests/hud_layout_test.py +++ b/tests/hud_layout_test.py @@ -156,10 +156,12 @@ class RealArchiveTest(unittest.TestCase): ui.apply(full, members, width, height) expected = bytearray(original) baseline['apply'](expected, members, width, height) - # The map, the Purah Pad's frame and the loading screen changed on purpose after it (the map and the - # loading map fill the screen, the frame keeps its width); every other layout is still byte for byte. - for name in ('AppMap_00', 'AppMenuOverlay_00', 'LoadingFade_00'): - lo, hi = members[f'blyt/{name}.bflyt'] + # The map (its layout and the minimap animation's width keys), the Purah Pad's frame and the loading screen + # changed on purpose after it (the maps fill the screen, the frame keeps its width); the rest is byte for byte. + for member in ('blyt/AppMap_00.bflyt', 'blyt/AppMenuOverlay_00.bflyt', 'blyt/LoadingFade_00.bflyt', + 'anim/AppMap_00_MiniMap.bflan', 'anim/LoadingFade_00_BarIn.bflan', + 'anim/LoadingFade_00_BarOut.bflan'): + lo, hi = members[member] expected[lo:hi] = full[lo:hi] self.assertEqual(full, expected) for cap, extension in ((16 / 9, 0), (21 / 9, 300)): diff --git a/tools/ultrawide_layout.py b/tools/ultrawide_layout.py index 12e237d0..4c24f36b 100644 --- a/tools/ultrawide_layout.py +++ b/tools/ultrawide_layout.py @@ -61,6 +61,22 @@ def hud_extent(k, hud_aspect): inner = 1 / ((16 / 9) / hud_aspect) - 1 # 1 / kc - 1 return 960 * inner, 960 * k * inner +# The loading screen's map is a capture of the world map that the game draws as the 3 x 3 tiles of 840 units around the +# player's tile (measured with TOTK_DUMP at 3840x1080: nine 840x840 tile draws into the capture), so only 840 units +# either side of the player are certain to hold map; wider, the capture shows black beside the tiles where the player +# stands near a tile's edge. At 16:9 it is 1470 wide (the screen's 1920 less 450), its left edge 23 units past the +# screen's, and the side panel (a window, so its frame keeps its proportions at any width) covers its right 237 units. +LOADING_MAP_MAX = 1660 + +def loading_map(k): + """(width, shift, panel width) of the loading screen's map capture and side panel for k = 16:9 over the aspect: the + map as wide as the screen allows up to LOADING_MAP_MAX, its left edge where 16:9 has it relative to the screen's + edge (shift: how far its centre moves from x -248), and the panel from the map's right part to the screen's edge.""" + width = min(1920 / k - 450, max(1470, LOADING_MAP_MAX)) + centre = -960 / k - 23 + width / 2 + panel = 960 / k - (centre + width / 2 - 237) + return width, centre + 248, panel + def edits(k, hud_aspect): """(layout, pane, field, value) for the aspect: k = 16/9 over the aspect (the root's scale), w = how far a 1920-wide layout's edge moves out in its own units (960 * (1 / k - 1)). OFF moves a pane out of sight. hud_aspect: the @@ -72,7 +88,9 @@ def edits(k, hud_aspect): out = [ ('AppAlbum_00', 'N_FadeInOut_00', 'scale_x', k), ('AppAlbum_00', 'N_Open_01', 'scale_x', wide), *[('AppMap_00', f'N_BlurInOut_0{i}', 'scale_x', wide) for i in range(4)], - ('AppMap_00', 'N_MiniMap_00', 'x', -270 * (1 - k)), + # With the map as wide as the screen, the layer tabs go to its left edge and the time, temperature and + # position to its right edge, as at 16:9 (neither position is animated; AppMap_00_MiniMap keys their visibility). + ('AppMap_00', 'N_MiniMap_00', 'x', -w), ('AppMap_00', 'N_AllMapTime_00', 'x', w), # The map: the panes that cut it out and its black backing are 2250 wide, so under the 16:9 root the world map # ended short of the screen's sides and black bars showed there. They take the screen's width in the root's # units instead (a size, not a scale: the map inside keeps its proportions and more of it shows), and so do the @@ -90,17 +108,17 @@ def edits(k, hud_aspect): ('CameraSystemWindow_00', 'T_Text_00', 'scale_x', k), ('ChallengeLog_00', 'C_CaptureUp_00', 'x', OFF), ('ChallengeLog_00', 'C_CaptureUp_01', 'x', OFF), ('GameOver_00', 'P_BG_00', 'scale_x', wide), - # The loading screen: the map on the left runs from the screen's left edge to under the side panel, which stays - # at the right edge at its own width. The map's capture panes and their pictures get the wider size (1470 at - # 16:9: the screen's 1920 less 450), so more of the map shows instead of a stretched one; the backgrounds and - # the bar span the screen. + # The loading screen: the map starts at the screen's left edge and the side panel ends at its right edge, each + # unstretched. See loading_map for the widths. ('LoadingFade_00', 'N_Logo_00', 'x', w), ('LoadingFade_00', 'N_Status_00', 'x', w), ('LoadingFade_00', 'N_Tips_00', 'x', -w), ('LoadingFade_00', 'P_BG_00', 'scale_x', wide), ('LoadingFade_00', 'P_BG_01', 'scale_x', wide), ('LoadingFade_00', 'P_Grid_00', 'scale_x', wide), ('LoadingFade_00', 'P_Bar_00', 'scale_x', wide), - *[('LoadingFade_00', pane, 'w', 1920 / k - 450) for pane in ('C_CaptureMap_00', 'C_CaptureMap_01', - 'P_CaptureMap_00', 'P_CaptureMap_01')], - ('LoadingFade_00', 'W_SideBGDeco_00', 'x', 960 / k), ('LoadingFade_00', 'P_SideBGDeco_00', 'x', 960 / k), + *[('LoadingFade_00', pane, 'w', loading_map(k)[0]) for pane in ('C_CaptureMap_00', 'C_CaptureMap_01', + 'P_CaptureMap_00', 'P_CaptureMap_01')], + ('LoadingFade_00', 'N_Map_00', 'x', -248 + loading_map(k)[1]), + ('LoadingFade_00', 'W_SideBGDeco_00', 'x', 960 / k), ('LoadingFade_00', 'W_SideBGDeco_00', 'w', loading_map(k)[2]), + ('LoadingFade_00', 'P_SideBGDeco_00', 'x', 960 / k), ('MessageLog_01', 'P_Capture_00', 'scale_x', wide), ('OwnedHorseList_00', 'N_BG_00', 'scale_x', wide), ('PaCommonBtnTitle_00', 'B_Hit_00', 'x', OFF), ('PaCommonBtnTitle_00', 'N_Cursor_00', 'x', OFF), ('PaLargeDungeonMap_00', 'P_BG_00', 'scale_x', wide), ('PaMessageBtn_00', 'B_Hit_00', 'x', OFF), @@ -219,6 +237,45 @@ def anim_keys(blarc, lo, pane, tag, target): pos += size return out +FLPA_SIZE_X = 8 # BFLAN FLPA target: the pane's width + +# The map's panes that AppMap_00_MiniMap sizes: in the full map they hold the width 2250 in its keys (the minimap +# shrinks them), and the animation's keys win over the layout's size, so a wider screen still cut the map at 2250. +MAP_SIZED = ('N_IconArea_00', 'N_Cut_00', 'N_Capture_00', 'P_MapCapture_00', 'Black8_01', 'N_Cut_01', 'N_Cut_02') + +def wide_anim(blarc, members, k, changed): + """The animation keys that hold the full map's width, for a canvas wider than 16:9: 2250 becomes 2250 / k, the + screen's width in the 16:9 root's units plus the same margin, as edits() does for the layout's sizes.""" + member = 'anim/AppMap_00_MiniMap.bflan' + if member not in members: raise SystemExit(f'AppMap_00_MiniMap: no animation {member} in the archive') + lo = members[member][0] + if blarc[lo:lo + 4] != b'FLAN': return # tests/hud_layout_test.py's synthetic archive: fixed-offset keys only + found = 0 + for pane in MAP_SIZED: + for keys in anim_keys(blarc, lo, pane, b'FLPA', FLPA_SIZE_X): + for key in keys: + if abs(struct.unpack_from('= 1e-4: raise SystemExit(f'{anim} +{offset}: {have}, expected {shipped}') struct.pack_into('