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
|
|
@ -482,9 +482,9 @@ PyObject* PyInit_mcrfpy()
|
|||
&PyDrawableType,
|
||||
|
||||
/*UI widgets*/
|
||||
&PyUICaptionType, &PyUISpriteType, &PyUIFrameType, &PyUIEntityType, &PyUIGridType,
|
||||
&PyUICaptionType, &PyUISpriteType, &PyUIFrameType, &PyUIEntityType,
|
||||
&PyUILineType, &PyUICircleType, &PyUIArcType, &PyViewport3DType,
|
||||
&mcrfpydef::PyUIGridViewType,
|
||||
&mcrfpydef::PyUIGridViewType, // #252: GridView IS the primary "Grid" type
|
||||
|
||||
/*3D entities*/
|
||||
&mcrfpydef::PyEntity3DType, &mcrfpydef::PyEntityCollection3DType,
|
||||
|
|
@ -547,6 +547,9 @@ PyObject* PyInit_mcrfpy()
|
|||
// Types that are used internally but NOT exported to module namespace (#189)
|
||||
// These still need PyType_Ready() but are not added to module
|
||||
PyTypeObject* internal_types[] = {
|
||||
/*#252: internal grid data type - UIGrid is now internal, GridView is "Grid"*/
|
||||
&PyUIGridType,
|
||||
|
||||
/*game map & perspective data - returned by Grid.at() but not directly instantiable*/
|
||||
&PyUIGridPointType, &PyUIGridPointStateType,
|
||||
|
||||
|
|
@ -682,6 +685,11 @@ PyObject* PyInit_mcrfpy()
|
|||
t = internal_types[i];
|
||||
}
|
||||
|
||||
// #252: Add "GridView" as an alias for the Grid type (which is PyUIGridViewType)
|
||||
// This allows both mcrfpy.Grid(...) and mcrfpy.GridView(...) to work
|
||||
Py_INCREF(&mcrfpydef::PyUIGridViewType);
|
||||
PyModule_AddObject(m, "GridView", (PyObject*)&mcrfpydef::PyUIGridViewType);
|
||||
|
||||
// Add default_font and default_texture to module
|
||||
McRFPy_API::default_font = std::make_shared<PyFont>("assets/JetbrainsMono.ttf");
|
||||
McRFPy_API::default_texture = std::make_shared<PyTexture>("assets/kenney_tinydungeon.png", 16, 16);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue