Phase 4.2: Add GridView UIDrawable type (addresses #252)
GridView is a new UIDrawable that renders a GridData object independently. Multiple GridViews can reference the same Grid for split-screen, minimap, or different camera/zoom perspectives on shared grid state. - New files: UIGridView.h/cpp with full rendering pipeline (copied from UIGrid::render, adapted to use grid_data pointer) - Add UIGRIDVIEW to PyObjectsEnum - Add UIGRIDVIEW cases to all switch(derived_type()) sites: Animation.cpp, UICollection.cpp, UIDrawable.cpp, McRFPy_API.cpp, ImGuiSceneExplorer.cpp - Python type: mcrfpy.GridView(grid=, pos=, size=, zoom=, fill_color=) - Properties: grid, center, zoom, fill_color, texture - Register type with metaclass for callback support All 258 existing tests pass. New GridView test suite added. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
13d5512a41
commit
4b13e5f5db
10 changed files with 824 additions and 2 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include "PyInputState.h"
|
||||
#include "PyBehavior.h"
|
||||
#include "PyTrigger.h"
|
||||
#include "UIGridView.h"
|
||||
#include "PySound.h"
|
||||
#include "PySoundBuffer.h"
|
||||
#include "PyMusic.h"
|
||||
|
|
@ -465,6 +466,7 @@ PyObject* PyInit_mcrfpy()
|
|||
PyTypeObject* ui_types_with_callbacks[] = {
|
||||
&PyUIFrameType, &PyUICaptionType, &PyUISpriteType, &PyUIGridType,
|
||||
&PyUILineType, &PyUICircleType, &PyUIArcType, &PyViewport3DType,
|
||||
&mcrfpydef::PyUIGridViewType,
|
||||
nullptr
|
||||
};
|
||||
for (int i = 0; ui_types_with_callbacks[i] != nullptr; i++) {
|
||||
|
|
@ -482,6 +484,7 @@ PyObject* PyInit_mcrfpy()
|
|||
/*UI widgets*/
|
||||
&PyUICaptionType, &PyUISpriteType, &PyUIFrameType, &PyUIEntityType, &PyUIGridType,
|
||||
&PyUILineType, &PyUICircleType, &PyUIArcType, &PyViewport3DType,
|
||||
&mcrfpydef::PyUIGridViewType,
|
||||
|
||||
/*3D entities*/
|
||||
&mcrfpydef::PyEntity3DType, &mcrfpydef::PyEntityCollection3DType,
|
||||
|
|
@ -635,6 +638,7 @@ PyObject* PyInit_mcrfpy()
|
|||
PyUICaptionType.tp_weaklistoffset = offsetof(PyUICaptionObject, weakreflist);
|
||||
PyUISpriteType.tp_weaklistoffset = offsetof(PyUISpriteObject, weakreflist);
|
||||
PyUIGridType.tp_weaklistoffset = offsetof(PyUIGridObject, weakreflist);
|
||||
mcrfpydef::PyUIGridViewType.tp_weaklistoffset = offsetof(PyUIGridViewObject, weakreflist);
|
||||
PyUIEntityType.tp_weaklistoffset = offsetof(PyUIEntityObject, weakreflist);
|
||||
PyUILineType.tp_weaklistoffset = offsetof(PyUILineObject, weakreflist);
|
||||
PyUICircleType.tp_weaklistoffset = offsetof(PyUICircleObject, weakreflist);
|
||||
|
|
@ -1596,6 +1600,16 @@ static void find_in_collection(std::vector<std::shared_ptr<UIDrawable>>* collect
|
|||
}
|
||||
break;
|
||||
}
|
||||
case PyObjectsEnum::UIGRIDVIEW: {
|
||||
auto gridview = std::static_pointer_cast<UIGridView>(drawable);
|
||||
auto type = &mcrfpydef::PyUIGridViewType;
|
||||
auto o = (PyUIGridViewObject*)type->tp_alloc(type, 0);
|
||||
if (o) {
|
||||
o->data = gridview;
|
||||
py_obj = (PyObject*)o;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue