feat(Python): establish proper inheritance hierarchy for UI types
All UIDrawable-derived Python types now properly inherit from the Drawable base class in Python, matching the C++ inheritance structure. Changes: - Add Py_TPFLAGS_BASETYPE to PyDrawableType to allow inheritance - Set tp_base = &mcrfpydef::PyDrawableType for all UI types - Add PyDrawable.h include to UI type headers - Rename _Drawable to Drawable and update error message This enables proper Python inheritance: Frame, Caption, Sprite, Grid, and Entity all inherit from Drawable, allowing shared functionality and isinstance() checks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e1c6c53157
commit
1d90cdab1d
6 changed files with 14 additions and 7 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "PyCallable.h"
|
||||
#include "PyTexture.h"
|
||||
#include "PyDrawable.h"
|
||||
#include "PyColor.h"
|
||||
#include "PyVector.h"
|
||||
#include "PyFont.h"
|
||||
|
|
@ -39,6 +40,7 @@ public:
|
|||
sf::FloatRect get_bounds() const override;
|
||||
void move(float dx, float dy) override;
|
||||
void resize(float w, float h) override;
|
||||
void onPositionChanged() override;
|
||||
|
||||
int grid_x, grid_y;
|
||||
//int grid_size; // grid sizes are implied by IndexTexture now
|
||||
|
|
@ -153,7 +155,7 @@ namespace mcrfpydef {
|
|||
.tp_methods = UIGrid_all_methods,
|
||||
//.tp_members = UIGrid::members,
|
||||
.tp_getset = UIGrid::getsetters,
|
||||
//.tp_base = NULL,
|
||||
.tp_base = &mcrfpydef::PyDrawableType,
|
||||
.tp_init = (initproc)UIGrid::init,
|
||||
.tp_new = [](PyTypeObject* type, PyObject* args, PyObject* kwds) -> PyObject*
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue