Here is a rundown on the selection system...
The selector uses a
flattened indexed array of 72 slots, representing
18 columns * 4 rows. Each occupied slot stores a pointer to the model’s database record.
The model database reads the model sheets, and selection logic uses that information to determine eligibility and placement. Models can specify their own grid coordinates, and those positions get priority. The remaining eligible models fill available spaces from left to right, row by row, within columns
1 through 16.
Reading and parsing all those files is slow - really slow in computer terms. Preparing all the data takes about
0.25 to 0.5 seconds on a low-spec machine. That's a lifetime in live play, but a microcosim in loading, which is where we do it. To make it even less noticable, we spread that work across the loading routine, adding records as models become available and skipping those already processed.
Then, once the data and selection array are populated, it’s
brutally fast. Player browsing, random selection, and other selection operations work from optimized records already in memory. Combined with reusing the finished sub-screen between changes, that lets the selector run during live gameplay with no worries at all.
Drawing the grid
The visible grid is a single sub-screen containing the striped background, grid lines, model icons, player cursors, and control instructions. Each icon’s position comes from its cell in the array, with coordinates relative to the sub-screen.
Highlighted icons appear in their original colors, while the others receive a darkening tint. The outer columns,
0 and 17, receive background fill and borders only when a player highlights a cell there.
Reusing the finished picture
The grid’s contents stay static between selection changes, so we only rebuild the picture when its display state changes, such as when a player highlights another model. Plus, as noted above, a sub-screen is one item in the sprite que. So even though we've blitted several dozen elements to the sub-screen, the final draw is just one sprite.
Masking unused cells
During live gameplay, the renderer draws
RGB (0, 0, 0) boxes over empty cells after drawing the background and grid lines. Remember the sub-screen transparency rule: those zero-valued pixels become transparent when the completed screen is displayed, revealing the gameplay underneath.
The renderer restores the borders of occupied cells, then draws the icons, instructions, and highlights. This keeps the selection overlay’s visible footprint limited to the space its contents need.
HTH,
DC