From f2eaee95ec1187df5fa604e2d8fe1953faa515f9 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Fri, 20 Oct 2023 22:23:20 -0400 Subject: [PATCH] (minor) sprite object enabled in collection --- src/Resources.h | 3 ++- src/UI.h | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Resources.h b/src/Resources.h index 7fbc42a..f636dd7 100644 --- a/src/Resources.h +++ b/src/Resources.h @@ -1,3 +1,4 @@ +#pragma once #include "Common.h" #include #include "UI.h" @@ -9,4 +10,4 @@ class Resources public: static sf::Font font; static GameEngine* game; -}; \ No newline at end of file +}; diff --git a/src/UI.h b/src/UI.h index b29e5c2..0b71a44 100644 --- a/src/UI.h +++ b/src/UI.h @@ -1281,8 +1281,10 @@ switch (target->derived_type()) \ // this would be a great use case for .tp_base if (!PyObject_IsInstance(o, (PyObject*)&PyUIFrameType) && - //!PyObject_IsInstance(o, (PyObject*)&PyUISpriteType) && - !PyObject_IsInstance(o, (PyObject*)&PyUICaptionType)) + !PyObject_IsInstance(o, (PyObject*)&PyUISpriteType) && + !PyObject_IsInstance(o, (PyObject*)&PyUICaptionType) // && + //!PyObject_IsInstance(o, (PyObject*)&PyUIGridType) + ) { PyErr_SetString(PyExc_TypeError, "Only Frame, Caption, Sprite, and Grid objects can be added to UICollection"); return NULL; @@ -1298,9 +1300,11 @@ switch (target->derived_type()) \ PyUICaptionObject* caption = (PyUICaptionObject*)o; self->data->push_back(caption->data); } - //if (PyObject_IsInstance(o, (PyObject*)&PyUISpriteType)) - //{ - //} + if (PyObject_IsInstance(o, (PyObject*)&PyUISpriteType)) + { + PyUISpriteObject* sprite = (PyUISpriteObject*)o; + self->data->push_back(sprite->data); + } Py_INCREF(Py_None); return Py_None;