Still doesn't compile, but now the issue is in UI.h overcoupling. Progress!

This commit is contained in:
John McCardle 2024-03-25 20:48:08 -04:00
parent 13672c8fdb
commit 1601fc7fab
3 changed files with 19 additions and 9 deletions

View File

@ -1,5 +1,13 @@
#include "PyColor.h" #include "PyColor.h"
PyGetSetDef PyColor::getsetters[] = {
{"r", (getter)PyColor::get_member, (setter)PyColor::set_member, "Red component", (void*)0},
{"g", (getter)PyColor::get_member, (setter)PyColor::set_member, "Green component", (void*)1},
{"b", (getter)PyColor::get_member, (setter)PyColor::set_member, "Blue component", (void*)2},
{"a", (getter)PyColor::get_member, (setter)PyColor::set_member, "Alpha component", (void*)3},
{NULL}
};
PyColor::PyColor(sf::Color* target, std::weak_ptr<UIDrawable> parent, int index) PyColor::PyColor(sf::Color* target, std::weak_ptr<UIDrawable> parent, int index)
{ {
data.index = index; data.index = index;
@ -34,10 +42,10 @@ Py_hash_t PyColor::hash(PyObject* obj)
auto ptr = self.data.parent.lock(); auto ptr = self.data.parent.lock();
if (ptr || self->data.index == PyColor::SELF_OWNED) if (ptr || self->data.index == PyColor::SELF_OWNED)
{ {
value += self->data.target->r; value += self->data.target.r;
value << 8; value += self->data.target->g; value << 8; value += self->data.target.g;
value << 8; value += self->data.target->b; value << 8; value += self->data.target.b;
value << 8; value += self->data.target->a; value << 8; value += self->data.target.a;
} }
if (ptr) if (ptr)
{ {

View File

@ -20,10 +20,10 @@ class PyColor
{ {
private: private:
_PyColorData data; _PyColorData data;
static int SELF_OWNED = -1; static const int SELF_OWNED = -1;
public: public:
PyColor(sf::Color* target, std::weak_ptr<UIDrawable> parent, int index) // linked constructor PyColor(sf::Color* target, std::weak_ptr<UIDrawable> parent, int index); // linked constructor
PyColor::PyColor(sf::Color target) // simple color container PyColor(sf::Color target); // simple color container
void set(sf::Color); void set(sf::Color);
sf::Color get(); sf::Color get();
PyObject* pyObject(); PyObject* pyObject();
@ -34,13 +34,14 @@ public:
static PyObject* get_member(PyObject*, void*); static PyObject* get_member(PyObject*, void*);
static int set_member(PyObject*, PyObject*, void*); static int set_member(PyObject*, PyObject*, void*);
static PyGetSetDef getsetters[] = { static PyGetSetDef getsetters[];
/*static PyGetSetDef getsetters[] = {
{"r", (getter)PyColor::get_member, (setter)PyColor::set_member, "Red component", (void*)0}, {"r", (getter)PyColor::get_member, (setter)PyColor::set_member, "Red component", (void*)0},
{"g", (getter)PyColor::get_member, (setter)PyColor::set_member, "Green component", (void*)1}, {"g", (getter)PyColor::get_member, (setter)PyColor::set_member, "Green component", (void*)1},
{"b", (getter)PyColor::get_member, (setter)PyColor::set_member, "Blue component", (void*)2}, {"b", (getter)PyColor::get_member, (setter)PyColor::set_member, "Blue component", (void*)2},
{"a", (getter)PyColor::get_member, (setter)PyColor::set_member, "Alpha component", (void*)3}, {"a", (getter)PyColor::get_member, (setter)PyColor::set_member, "Alpha component", (void*)3},
{NULL} {NULL}
}; };*/
}; };

View File

@ -7,6 +7,7 @@
#include <list> #include <list>
#include "PyCallable.h" #include "PyCallable.h"
#include "PyTexture.h" #include "PyTexture.h"
#include "PyColor.h"
enum PyObjectsEnum : int enum PyObjectsEnum : int
{ {