feat: Migrate Grid to user-driven layer rendering (closes #150)
- Add `layers` dict parameter to Grid constructor for explicit layer definitions
- `layers={"ground": "color", "terrain": "tile"}` creates named layers
- `layers={}` creates empty grid (entities + pathfinding only)
- Default creates single TileLayer named "tilesprite" for backward compat
- Implement dynamic GridPoint property access via layer names
- `grid.at(x,y).layer_name = value` routes to corresponding layer
- Protected names (walkable, transparent, etc.) still use GridPoint
- Remove base layer rendering from UIGrid::render()
- Layers are now the sole source of grid rendering
- Old chunk_manager remains for GridPoint data access
- FOV overlay unchanged
- Update test to use explicit `layers={}` parameter
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9469c04b01
commit
a258613faa
6 changed files with 200 additions and 87 deletions
10
src/UIGrid.h
10
src/UIGrid.h
|
|
@ -95,11 +95,15 @@ public:
|
|||
std::vector<std::shared_ptr<GridLayer>> layers;
|
||||
bool layers_need_sort = true; // Dirty flag for z_index sorting
|
||||
|
||||
// Layer management
|
||||
std::shared_ptr<ColorLayer> addColorLayer(int z_index);
|
||||
std::shared_ptr<TileLayer> addTileLayer(int z_index, std::shared_ptr<PyTexture> texture = nullptr);
|
||||
// Layer management (#150 - extended with names)
|
||||
std::shared_ptr<ColorLayer> addColorLayer(int z_index, const std::string& name = "");
|
||||
std::shared_ptr<TileLayer> addTileLayer(int z_index, std::shared_ptr<PyTexture> texture = nullptr, const std::string& name = "");
|
||||
void removeLayer(std::shared_ptr<GridLayer> layer);
|
||||
void sortLayers();
|
||||
std::shared_ptr<GridLayer> getLayerByName(const std::string& name);
|
||||
|
||||
// #150 - Protected layer names (reserved for GridPoint properties)
|
||||
static bool isProtectedLayerName(const std::string& name);
|
||||
|
||||
// Background rendering
|
||||
sf::Color fill_color;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue