-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLayout.lua
More file actions
103 lines (86 loc) · 4.03 KB
/
Copy pathLayout.lua
File metadata and controls
103 lines (86 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- Pure geometry for the box screen, in native pixels on the 160x144
-- canvas. Font.GLYPH is 8, so the screen is 20x18 characters and every
-- constant here is a multiple of 8.
--
-- The screen is framed by two stacked Game Boy boxes that share their
-- border row, the way adjacent boxes meet in the original. Font.drawBox
-- takes TILE coords, fills its area white and draws a 1-tile border, so a
-- framed region loses 8px on every side:
--
-- Box A = (0, 0, 20, 12) interior px x=8..152, y=8..88
-- header, the grid, the count line, and the sprite panel
-- Box B = (0, 11, 20, 7) interior px x=8..152, y=96..136
-- the stats strip, and the party row in deposit mode
--
-- Row 11 is both A's bottom border and B's top, drawn once as a shared
-- line. Box B must therefore be drawn AFTER box A and BEFORE any content,
-- since drawBox's white fill erases whatever it covers.
local Layout = {}
Layout.CELL = 16
-- Length of each cursor corner arm, in pixels. 5 of a 16px cell reads as a
-- bracket with the edge left open in the middle.
Layout.CURSOR_ARM = 5
Layout.ROW = 8
-- tile rects for the two frames, as drawBox takes them
Layout.BOX_A_TILES = { 0, 0, 20, 12 }
Layout.BOX_B_TILES = { 0, 11, 20, 7 }
-- Box C frames the party row in deposit mode only, drawn OVER the lower
-- part of box B -- which box mode leaves empty anyway, so the frame costs
-- nothing there. Its interior lands exactly on PARTY_Y, which is why no
-- other constant moves. It covers the type line in the stats strip (see
-- drawStats), which is the one row deposit mode gives up.
Layout.BOX_C_TILES = { 0, 14, 20, 4 }
-- header text sits inside box A, above the grid
Layout.HEADER_X, Layout.HEADER_Y = 8, 8
Layout.GRID_X, Layout.GRID_Y = 8, 16
Layout.COLS, Layout.ROWS = 5, 4
-- A column of Font.BORDER.v glyphs separating the grid from the sprite
-- panel, drawn in the same chrome as the frames around it. Box A's
-- interior is 144px wide and the grid takes 80, so the divider's tile comes
-- out of the panel. It spans the full interior height, down through the
-- count line.
Layout.DIVIDER_X = 88
Layout.DIVIDER_TOP = 8
Layout.DIVIDER_ROWS = 10 -- 10 x 8px spans the interior's 80px height
-- 56 wide, after the outer frame took it from 80 to 64 and the divider took
-- another tile. 56 is exactly a 7x7 sprite, the largest in Gen 1, so those
-- sit flush between the divider and the frame; 5x5 and 6x6 still centre
-- with margin.
Layout.PANEL_X, Layout.PANEL_Y = 96, 16
Layout.PANEL_W, Layout.PANEL_H = 56, 64
-- the identity plate (name over level) sits at the panel's top in both
-- modes: the count lives in the box window now, so the panel's header row
-- is free everywhere, and a floor-baseline 56px sprite clears it exactly
Layout.PLATE_Y = 8
-- horizontal centre of the sprite panel; consumers subtract half the
-- sprite's own width so sprites of any size centre correctly
Layout.SPRITE_CX = 124
-- on the frame floor, not lifted: the identity plate above needs every
-- pixel of headroom, so a tall sprite stands on the border instead of
-- floating 4px over it
Layout.SPRITE_BASELINE = 80
function Layout.spritePos(pw, ph)
return Layout.SPRITE_CX - math.floor(pw / 2), Layout.SPRITE_BASELINE - ph
end
-- Below the stats rather than above them, so the stats strip never shifts
-- when deposit mode opens.
Layout.PARTY_X, Layout.PARTY_Y = 8, 120
Layout.PARTY_SLOTS = 6
-- The box window's bottom line, inside box A under the grid: the count on
-- the left, the focused mon's HP on the right (under the sprite).
Layout.COUNT_Y = 80
-- The stats strip inside box B: ATK/DEF, then SPD/SPC, then the type line
-- (box view only -- deposit's party frame covers it).
Layout.STATS_X, Layout.STATS_Y = 8, 96
function Layout.slotXY(index)
local i = index - 1
return Layout.GRID_X + (i % Layout.COLS) * Layout.CELL,
Layout.GRID_Y + math.floor(i / Layout.COLS) * Layout.CELL
end
function Layout.slotAt(col, row)
return row * Layout.COLS + col + 1
end
function Layout.partyXY(index)
return Layout.PARTY_X + (index - 1) * Layout.CELL, Layout.PARTY_Y
end
return Layout