Grid/GridView API unification: mcrfpy.Grid now returns GridView, closes #252
mcrfpy.Grid() now creates a GridView that internally owns a GridData (UIGrid). The old UIGrid type is renamed to _GridData (internal). Attribute access on Grid delegates to the underlying UIGrid via tp_getattro/tp_setattro, so all existing Grid properties (grid_w, grid_h, entities, cells, layers, etc.) work transparently. Key changes: - GridView init has two modes: factory (Grid(grid_size=...)) and explicit view (Grid(grid=existing_grid, ...)) for future multi-view support - Entity.grid getter returns GridView wrapper via owning_view back-reference - Entity.grid setter accepts GridView objects - GridLayer set_grid handles GridView (extracts underlying UIGrid) - UIDrawable::removeFromParent handles UIGRIDVIEW type correctly - UIFrame children init accepts GridView objects - Animation system supports GridView (center, zoom, shader.* properties) - PythonObjectCache registration preserves subclass identity - All 263 tests pass (100%) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a61f05229f
commit
109bc21d90
10 changed files with 616 additions and 146 deletions
|
|
@ -26,6 +26,7 @@
|
|||
class DijkstraMap;
|
||||
class UIEntity;
|
||||
class UIDrawable;
|
||||
class UIGridView;
|
||||
class PyTexture;
|
||||
|
||||
class GridData {
|
||||
|
|
@ -130,6 +131,11 @@ public:
|
|||
std::shared_ptr<std::vector<std::shared_ptr<UIDrawable>>> children;
|
||||
bool children_need_sort = true;
|
||||
|
||||
// =========================================================================
|
||||
// #252 - Owning GridView back-reference (for Entity.grid → GridView lookup)
|
||||
// =========================================================================
|
||||
std::weak_ptr<UIGridView> owning_view;
|
||||
|
||||
protected:
|
||||
// Initialize grid storage (flat or chunked) and TCOD map
|
||||
void initStorage(int gx, int gy, GridData* parent_ref);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue