diff --git a/src/PyDrawable.cpp b/src/PyDrawable.cpp index 9648335..7773a26 100644 --- a/src/PyDrawable.cpp +++ b/src/PyDrawable.cpp @@ -154,14 +154,14 @@ static PyMethodDef PyDrawable_methods[] = { // Type initialization static int PyDrawable_init(PyDrawableObject* self, PyObject* args, PyObject* kwds) { - PyErr_SetString(PyExc_TypeError, "_Drawable is an abstract base class and cannot be instantiated directly"); + PyErr_SetString(PyExc_TypeError, "Drawable is an abstract base class and cannot be instantiated directly"); return -1; } namespace mcrfpydef { PyTypeObject PyDrawableType = { .ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0}, - .tp_name = "mcrfpy._Drawable", + .tp_name = "mcrfpy.Drawable", .tp_basicsize = sizeof(PyDrawableObject), .tp_itemsize = 0, .tp_dealloc = (destructor)[](PyObject* self) { @@ -169,7 +169,7 @@ namespace mcrfpydef { obj->data.reset(); Py_TYPE(self)->tp_free(self); }, - .tp_flags = Py_TPFLAGS_DEFAULT, // | Py_TPFLAGS_BASETYPE, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = PyDoc_STR("Base class for all drawable UI elements"), .tp_methods = PyDrawable_methods, .tp_getset = PyDrawable_getsetters, diff --git a/src/UICaption.h b/src/UICaption.h index e39d098..090af65 100644 --- a/src/UICaption.h +++ b/src/UICaption.h @@ -2,6 +2,7 @@ #include "Common.h" #include "Python.h" #include "UIDrawable.h" +#include "PyDrawable.h" class UICaption: public UIDrawable { @@ -68,7 +69,7 @@ namespace mcrfpydef { .tp_methods = UICaption_methods, //.tp_members = PyUIFrame_members, .tp_getset = UICaption::getsetters, - //.tp_base = NULL, + .tp_base = &mcrfpydef::PyDrawableType, .tp_init = (initproc)UICaption::init, // TODO - move tp_new to .cpp file as a static function (UICaption::new) .tp_new = [](PyTypeObject* type, PyObject* args, PyObject* kwds) -> PyObject* diff --git a/src/UIEntity.h b/src/UIEntity.h index 6079a3c..86b7e92 100644 --- a/src/UIEntity.h +++ b/src/UIEntity.h @@ -8,6 +8,7 @@ #include "PyCallable.h" #include "PyTexture.h" +#include "PyDrawable.h" #include "PyColor.h" #include "PyVector.h" #include "PyFont.h" @@ -86,6 +87,7 @@ namespace mcrfpydef { .tp_doc = "UIEntity objects", .tp_methods = UIEntity_all_methods, .tp_getset = UIEntity::getsetters, + .tp_base = &mcrfpydef::PyDrawableType, .tp_init = (initproc)UIEntity::init, .tp_new = PyType_GenericNew, }; diff --git a/src/UIFrame.h b/src/UIFrame.h index e1311d9..b05b3c5 100644 --- a/src/UIFrame.h +++ b/src/UIFrame.h @@ -8,6 +8,7 @@ #include "PyCallable.h" #include "PyColor.h" +#include "PyDrawable.h" #include "PyVector.h" #include "UIDrawable.h" #include "UIBase.h" @@ -89,7 +90,7 @@ namespace mcrfpydef { .tp_methods = UIFrame_methods, //.tp_members = PyUIFrame_members, .tp_getset = UIFrame::getsetters, - //.tp_base = NULL, + .tp_base = &mcrfpydef::PyDrawableType, .tp_init = (initproc)UIFrame::init, .tp_new = [](PyTypeObject* type, PyObject* args, PyObject* kwds) -> PyObject* { diff --git a/src/UIGrid.h b/src/UIGrid.h index 8d46fbd..34d5f45 100644 --- a/src/UIGrid.h +++ b/src/UIGrid.h @@ -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* { diff --git a/src/UISprite.h b/src/UISprite.h index 5c16ab1..bdfec9e 100644 --- a/src/UISprite.h +++ b/src/UISprite.h @@ -8,6 +8,7 @@ #include "PyCallable.h" #include "PyTexture.h" +#include "PyDrawable.h" #include "PyColor.h" #include "PyVector.h" #include "PyFont.h" @@ -95,7 +96,7 @@ namespace mcrfpydef { .tp_methods = UISprite_methods, //.tp_members = PyUIFrame_members, .tp_getset = UISprite::getsetters, - //.tp_base = NULL, + .tp_base = &mcrfpydef::PyDrawableType, .tp_init = (initproc)UISprite::init, .tp_new = [](PyTypeObject* type, PyObject* args, PyObject* kwds) -> PyObject* {