Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

Could I have an in-memory data structure that stores which grid cells are occupied and by which tile? Resizing a tile would store which tile occupies which cells, so that could work. #257

@DrewNaylor

Description

@DrewNaylor

So it'll be like (this is JSON):

{cell: [coords: 0-0, occupiedBy: 0-0], 
cell: [coords: 0-1, occupiedBy: 0-0], 
cell: [coords: 0-2, occupiedBy: 0-2], 
cell: [coords: 0-3, occupiedBy: 0-2], 
cell: [coords: 1-0, occupiedBy: 0-0], 
cell: [coords: 1-1, occupiedBy: 0-0], 
cell: [coords: 1-2, occupiedBy: 0-2], 
cell: [coords: 1-3, occupiedBy: 0-2]}

And so on. occupiedBy will be used to look up the tile in a specific spot if necessary, or simply calculate the tile's size if possible as that will be an easier way to see if another tile will fit nearby. If coordinates are not recorded in the data structure, then it's assumed that cell is empty but the tile will still need to be sure it can fit.

I'm not going to use the YAML layout file for this because I need to be able to update this in memory and I can't store too much in memory as that would be bloated.

When pinning, unpinning, and resizing, we will consult this data structure to see where the new tile should go, whether tiles can shift up (if all tiles in a row are unpinned; don't shift tiles around when unpinning if a row is not empty as that's not what WP did I think), and whether tiles need to be pushed to the next row or if they can be pushed to another column, respectively. This will also be used when loading tiles to ensure they don't overlap each other, which should only be a problem when converting the previous tile layout file to the new one with columns and rows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions