Compare commits

..

4 Commits

Author SHA1 Message Date
John McCardle 232105a893 Squashed commit of the following: [reprs_and_member_names]
Closes #22
Closes #23
Closes #24
Closes #25
Closes #31
Closes #56

commit 43fac8f4f3
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Apr 20 18:32:52 2024 -0400

    Typo in UIFrame repr

commit 3fd5ad93e2
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Apr 20 18:32:30 2024 -0400

    Add UIGridPoint and UIGridPointState repr

commit 03376897b8
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Apr 20 18:32:17 2024 -0400

    Add UIGrid repr

commit 48af072a33
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Apr 20 18:32:05 2024 -0400

    Add UIEntity repr
2024-04-20 18:33:18 -04:00
John McCardle c2de9b08d6 Refactor: remove "s" prefix from "sRender" method ( -> "render") Closes #44 2024-04-20 14:16:14 -04:00
John McCardle a465a9861d Color parsing for UICaption __init__ - closes #58 2024-04-20 13:37:19 -04:00
John McCardle ac7f7052cd Squashed commit of the following: [break_up_ui_h]
Closes #43

No segfault found in cos_play after completing the checklist. Maybe I accidentally fixed it...?

commit 6aa151aba3
Author: John McCardle <mccardle.john@gmail.com>
Date:   Fri Apr 19 21:43:58 2024 -0400

    UISprite.h/.cpp cleanup

commit ec0374ef50
Author: John McCardle <mccardle.john@gmail.com>
Date:   Fri Apr 19 21:37:39 2024 -0400

    UIGridPoint.h/.cpp reorganization

commit 2cb7339535
Author: John McCardle <mccardle.john@gmail.com>
Date:   Fri Apr 19 21:19:25 2024 -0400

    UIGrid.h/.cpp cleanup. I have reservations about the UIEntityCollection[Iter] classes + methods living there, but not enough to fix it right now.

commit 5d6af324bf
Author: John McCardle <mccardle.john@gmail.com>
Date:   Thu Apr 18 22:14:57 2024 -0400

    UIFrame - moving static method into class namespace; no type object access

commit 567218cd7b
Author: John McCardle <mccardle.john@gmail.com>
Date:   Thu Apr 18 21:23:49 2024 -0400

    UIEntity fixes for the UI.h split: There are segfaults in cos_play, I may have missed a type usage or something

commit 76693acd28
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Apr 13 00:18:37 2024 -0400

    delete leftover comments

commit 9efe998a33
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Apr 13 00:17:43 2024 -0400

    some work on UICaption and UICollection; fixing segfaults resulting from mcrfpydef namepace TypeObject usage

commit 714965da45
Author: John McCardle <mccardle.john@gmail.com>
Date:   Fri Apr 12 14:15:00 2024 -0400

    eliminate extra includes on UICaption

commit 8efa25878f
Author: John McCardle <mccardle.john@gmail.com>
Date:   Wed Apr 10 23:41:14 2024 -0400

    remove a lot of stuff

commit c186d8c7f3
Author: John McCardle <mccardle.john@gmail.com>
Date:   Wed Apr 10 23:10:15 2024 -0400

    We are compiling again! Started refactoring UICaption to be more idiomatic

commit 1b6e2a709b
Author: John McCardle <mccardle.john@gmail.com>
Date:   Tue Apr 9 22:42:02 2024 -0400

    Still not quite compiling; as predicted, a lot of interdependency and definition order bugs to untangle

commit aa7553a818
Author: John McCardle <mccardle.john@gmail.com>
Date:   Tue Apr 9 22:41:20 2024 -0400

    PyTexture clean up scribbles and experiments

commit c0201d989a
Author: John McCardle <mccardle.john@gmail.com>
Date:   Mon Apr 8 22:55:00 2024 -0400

    additional unsaved changes

commit 83a63a3093
Author: John McCardle <mccardle.john@gmail.com>
Date:   Mon Apr 8 22:45:00 2024 -0400

    doesn't compile, but UI.h/.cpp code has been divvy'd up.

    refs #43 @2h
2024-04-20 10:32:04 -04:00
19 changed files with 168 additions and 196 deletions

View File

@ -59,7 +59,7 @@ void GameEngine::run()
if (!paused)
{
}
currentScene()->sRender();
currentScene()->render();
currentFrame++;
frameTime = clock.restart().asSeconds();
fps = 1 / frameTime;

View File

@ -1,4 +1,5 @@
#include "PyColor.h"
#include "McRFPy_API.h"
PyGetSetDef PyColor::getsetters[] = {
{"r", (getter)PyColor::get_member, (setter)PyColor::set_member, "Red component", (void*)0},
@ -134,3 +135,16 @@ int PyColor::set_member(PyObject* obj, PyObject* value, void* closure)
// TODO
return 0;
}
PyColorObject* PyColor::from_arg(PyObject* args)
{
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "Color");
if (PyObject_IsInstance(args, (PyObject*)type)) return (PyColorObject*)args;
auto obj = (PyColorObject*)type->tp_alloc(type, 0);
int err = init(obj, args, NULL);
if (err) {
Py_DECREF(obj);
return NULL;
}
return obj;
}

View File

@ -29,6 +29,7 @@ public:
static int set_member(PyObject*, PyObject*, void*);
static PyGetSetDef getsetters[];
static PyColorObject* from_arg(PyObject*);
};
namespace mcrfpydef {

View File

@ -59,7 +59,7 @@ void PyScene::doAction(std::string name, std::string type)
}
}
void PyScene::sRender()
void PyScene::render()
{
game->getWindow().clear();

View File

@ -11,7 +11,7 @@ public:
PyScene(GameEngine*);
void update() override final;
void doAction(std::string, std::string) override final;
void sRender() override final;
void render() override final;
void do_mouse_input(std::string, std::string);
};

View File

@ -31,7 +31,7 @@ public:
//Scene();
Scene(GameEngine*);
virtual void update() = 0;
virtual void sRender() = 0;
virtual void render() = 0;
virtual void doAction(std::string, std::string) = 0;
bool hasAction(std::string);
bool hasAction(int);

View File

@ -212,7 +212,7 @@ PyObject* UICaption::repr(PyUICaptionObject* self)
"text='" << (std::string)text.getString() << "', " <<
"outline=" << text.getOutlineThickness() << ", " <<
"fill_color=(" << (int)fc.r << ", " << (int)fc.g << ", " << (int)fc.b << ", " << (int)fc.a <<"), " <<
"outlinecolor=(" << (int)oc.r << ", " << (int)oc.g << ", " << (int)oc.b << ", " << (int)oc.a <<"), " <<
"outline_color=(" << (int)oc.r << ", " << (int)oc.g << ", " << (int)oc.b << ", " << (int)oc.a <<"), " <<
")>";
}
std::string repr_str = ss.str();
@ -222,13 +222,13 @@ PyObject* UICaption::repr(PyUICaptionObject* self)
int UICaption::init(PyUICaptionObject* self, PyObject* args, PyObject* kwds)
{
using namespace mcrfpydef;
static const char* keywords[] = { "x", "y", "text", "font", "fill_color", "outline_color", nullptr };
float x = 0.0f, y = 0.0f;
static const char* keywords[] = { "x", "y", "text", "font", "fill_color", "outline_color", "outline", nullptr };
float x = 0.0f, y = 0.0f, outline = 0.0f;
char* text;
PyObject* font, fill_color, outline_color;
PyObject* font=NULL, *fill_color=NULL, *outline_color=NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ffzOOO",
const_cast<char**>(keywords), &x, &y, &text, &font, &fill_color, &outline_color))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ffzOOOf",
const_cast<char**>(keywords), &x, &y, &text, &font, &fill_color, &outline_color, &outline))
{
return -1;
}
@ -253,8 +253,30 @@ int UICaption::init(PyUICaptionObject* self, PyObject* args, PyObject* kwds)
self->data->text.setPosition(sf::Vector2f(x, y));
self->data->text.setString((std::string)text);
self->data->text.setFillColor(sf::Color(0,0,0,255));
self->data->text.setOutlineColor(sf::Color(128,128,128,255));
self->data->text.setOutlineThickness(outline);
if (fill_color) {
auto fc = PyColor::from_arg(fill_color);
if (!fc) {
PyErr_SetString(PyExc_TypeError, "fill_color must be mcrfpy.Color or arguments to mcrfpy.Color.__init__");
return -1;
}
self->data->text.setFillColor(PyColor::fromPy(fc));
//Py_DECREF(fc);
} else {
self->data->text.setFillColor(sf::Color(0,0,0,255));
}
if (outline_color) {
auto oc = PyColor::from_arg(outline_color);
if (!oc) {
PyErr_SetString(PyExc_TypeError, "outline_color must be mcrfpy.Color or arguments to mcrfpy.Color.__init__");
return -1;
}
self->data->text.setOutlineColor(PyColor::fromPy(oc));
//Py_DECREF(oc);
} else {
self->data->text.setOutlineColor(sf::Color(128,128,128,255));
}
return 0;
}

View File

@ -163,3 +163,15 @@ PyGetSetDef UIEntity::getsetters[] = {
{"sprite_number", (getter)UIEntity::get_spritenumber, (setter)UIEntity::set_spritenumber, "Sprite number (index) on the texture on the display", NULL},
{NULL} /* Sentinel */
};
PyObject* UIEntity::repr(PyUIEntityObject* self) {
std::ostringstream ss;
if (!self->data) ss << "<Entity (invalid internal object)>";
else {
auto ent = self->data;
ss << "<Entity (x=" << self->data->position.x << ", y=" << self->data->position.y << ", sprite_number=" << self->data->sprite.getSpriteIndex() <<
")>";
}
std::string repr_str = ss.str();
return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace");
}

View File

@ -55,148 +55,21 @@ public:
static int set_spritenumber(PyUIEntityObject* self, PyObject* value, void* closure);
static PyMethodDef methods[];
static PyGetSetDef getsetters[];
static PyObject* repr(PyUIEntityObject* self);
};
namespace mcrfpydef {
/*
//TODO: add this method to class scope; move implementation to .cpp file; reconsider for moving to "UIBase.h/.cpp"
// TODO: sf::Vector2f convenience functions here might benefit from a PyVectorObject much like PyColorObject
// Utility function to convert sf::Vector2f to PyObject*
static PyObject* sfVector2f_to_PyObject(sf::Vector2f vector) {
return Py_BuildValue("(ff)", vector.x, vector.y);
}
//TODO: add this method to class scope; move implementation to .cpp file; reconsider for moving to "UIBase.h/.cpp"
// Utility function to convert PyObject* to sf::Vector2f
static sf::Vector2f PyObject_to_sfVector2f(PyObject* obj) {
float x, y;
if (!PyArg_ParseTuple(obj, "ff", &x, &y)) {
return sf::Vector2f(); // TODO / reconsider this default: Return default vector on parse error
}
return sf::Vector2f(x, y);
}
//TODO: add this method to class scope; move implementation to .cpp file
// Utility function to convert UIGridPointState to PyObject*
static PyObject* UIGridPointState_to_PyObject(const UIGridPointState& state) {
PyObject* obj = PyObject_New(PyObject, &PyUIGridPointStateType);
if (!obj) return PyErr_NoMemory();
// Assuming PyUIGridPointStateObject structure has a UIGridPointState* member called 'data'
//((PyUIGridPointStateObject*)obj)->data = new UIGridPointState(state); // Copy constructor // wontimplement / feat - don't use new, get shared_ptr working
return obj;
}
//TODO: add this method to class scope; move implementation to .cpp file
// Function to convert std::vector<UIGridPointState> to a Python list TODO need a PyUICollection style iterable
static PyObject* UIGridPointStateVector_to_PyList(const std::vector<UIGridPointState>& vec) {
PyObject* list = PyList_New(vec.size());
if (!list) return PyErr_NoMemory();
for (size_t i = 0; i < vec.size(); ++i) {
PyObject* obj = UIGridPointState_to_PyObject(vec[i]);
if (!obj) { // Cleanup on failure
Py_DECREF(list);
return NULL;
}
PyList_SET_ITEM(list, i, obj); // This steals a reference to obj
}
return list;
}
//TODO: add this method to class scope; move implementation to .cpp file
static PyObject* PyUIEntity_get_position(PyUIEntityObject* self, void* closure) {
return sfVector2f_to_PyObject(self->data->position);
}
//TODO: add this method to class scope; move implementation to .cpp file
static int PyUIEntity_set_position(PyUIEntityObject* self, PyObject* value, void* closure) {
self->data->position = PyObject_to_sfVector2f(value);
return 0;
}
//TODO: add this method to class scope; move implementation to .cpp file
static PyObject* PyUIEntity_get_gridstate(PyUIEntityObject* self, void* closure) {
// Assuming a function to convert std::vector<UIGridPointState> to PyObject* list
return UIGridPointStateVector_to_PyList(self->data->gridstate);
}
//TODO: add this method to class scope; move implementation to .cpp file
static PyObject* PyUIEntity_get_spritenumber(PyUIEntityObject* self, void* closure) {
return PyLong_FromDouble(self->data->sprite.getSpriteIndex());
}
//TODO: add this method to class scope; move implementation to .cpp file
static int PyUIEntity_set_spritenumber(PyUIEntityObject* self, PyObject* value, void* closure) {
int val;
if (PyLong_Check(value))
val = PyLong_AsLong(value);
else
{
PyErr_SetString(PyExc_TypeError, "Value must be an integer.");
return -1;
}
//self->data->sprite.sprite_index = val;
self->data->sprite.setSpriteIndex(val); // todone - I don't like ".sprite.sprite" in this stack of UIEntity.UISprite.sf::Sprite
return 0;
}
//TODO: add this method to class scope; move implementation to .cpp file
static PyObject* PyUIEntity_at(PyUIEntityObject* self, PyObject* o)
{
int x, y;
if (!PyArg_ParseTuple(o, "ii", &x, &y)) {
PyErr_SetString(PyExc_TypeError, "UIEntity.at requires two integer arguments: (x, y)");
return NULL;
}
if (self->data->grid == NULL) {
PyErr_SetString(PyExc_ValueError, "Entity cannot access surroundings because it is not associated with a grid");
return NULL;
}
PyUIGridPointStateObject* obj = (PyUIGridPointStateObject*)((&PyUIGridPointStateType)->tp_alloc(&PyUIGridPointStateType, 0));
//auto target = std::static_pointer_cast<UIEntity>(target);
obj->data = &(self->data->gridstate[y + self->data->grid->grid_x * x]);
obj->grid = self->data->grid;
obj->entity = self->data;
return (PyObject*)obj;
}
//TODO: add this static array to class scope; move implementation to .cpp file
static PyMethodDef PyUIEntity_methods[] = {
{"at", (PyCFunction)UIEntity::at, METH_O},
{NULL, NULL, 0, NULL}
};
//TODO: add this static array to class scope; move implementation to .cpp file
// Define getters and setters
static PyGetSetDef PyUIEntity_getsetters[] = {
{"position", (getter)PyUIEntity_get_position, (setter)PyUIEntity_set_position, "Entity position", NULL},
{"gridstate", (getter)PyUIEntity_get_gridstate, NULL, "Grid point states for the entity", NULL},
{"sprite_number", (getter)PyUIEntity_get_spritenumber, (setter)PyUIEntity_set_spritenumber, "Sprite number (index) on the texture on the display", NULL},
{NULL} // Sentinel
};
//TODO: add this method to class scope; forward declaration not required after .h/.cpp split
//static int PyUIEntity_init(PyUIEntityObject*, PyObject*, PyObject*); // forward declare
*/
// Define the PyTypeObject for UIEntity
static PyTypeObject PyUIEntityType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.Entity",
.tp_basicsize = sizeof(PyUIEntityObject),
.tp_itemsize = 0,
// Methods omitted for brevity
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "UIEntity objects",
.tp_methods = UIEntity::methods,
.tp_getset = UIEntity::getsetters,
.tp_init = (initproc)UIEntity::init,
.tp_new = PyType_GenericNew,
};
static PyTypeObject PyUIEntityType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.Entity",
.tp_basicsize = sizeof(PyUIEntityObject),
.tp_itemsize = 0,
.tp_repr = (reprfunc)UIEntity::repr,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "UIEntity objects",
.tp_methods = UIEntity::methods,
.tp_getset = UIEntity::getsetters,
.tp_init = (initproc)UIEntity::init,
.tp_new = PyType_GenericNew,
};
}

View File

@ -225,7 +225,7 @@ PyObject* UIFrame::repr(PyUIFrameObject* self)
auto box = self->data->box;
auto fc = box.getFillColor();
auto oc = box.getOutlineColor();
ss << "<Frame (x=" << box.getPosition().x << ", y=" << box.getPosition().y << ", x=" <<
ss << "<Frame (x=" << box.getPosition().x << ", y=" << box.getPosition().y << ", w=" <<
box.getSize().x << ", w=" << box.getSize().y << ", " <<
"outline=" << box.getOutlineThickness() << ", " <<
"fill_color=(" << (int)fc.r << ", " << (int)fc.g << ", " << (int)fc.b << ", " << (int)fc.a <<"), " <<

View File

@ -45,9 +45,6 @@ public:
};
namespace mcrfpydef {
//TODO: add this method to class scope; move implementation to .cpp file
static PyTypeObject PyUIFrameType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.Frame",

View File

@ -421,6 +421,37 @@ PyObject* UIGrid::get_children(PyUIGridObject* self, void* closure)
return (PyObject*)o;
}
PyObject* UIGrid::repr(PyUIGridObject* self)
{
// if (member_ptr == 0) // x
// self->data->box.setPosition(val, self->data->box.getPosition().y);
// else if (member_ptr == 1) // y
// self->data->box.setPosition(self->data->box.getPosition().x, val);
// else if (member_ptr == 2) // w
// self->data->box.setSize(sf::Vector2f(val, self->data->box.getSize().y));
// else if (member_ptr == 3) // h
// self->data->box.setSize(sf::Vector2f(self->data->box.getSize().x, val));
// else if (member_ptr == 4) // center_x
// self->data->center_x = val;
// else if (member_ptr == 5) // center_y
// self->data->center_y = val;
// else if (member_ptr == 6) // zoom
// self->data->zoom = val;
std::ostringstream ss;
if (!self->data) ss << "<Grid (invalid internal object)>";
else {
auto grid = self->data;
auto box = grid->box;
ss << "<Grid (x=" << box.getPosition().x << ", y=" << box.getPosition().y << ", w=" << box.getSize().x << ", h=" << box.getSize().y << ", " <<
"center=(" << grid->center_x << ", " << grid->center_y << "), zoom=" << grid->zoom <<
")>";
}
std::string repr_str = ss.str();
return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace");
}
/* // TODO standard pointer would need deleted, but I opted for a shared pointer. tp_dealloc currently not even defined in the PyTypeObject
void PyUIGrid_dealloc(PyUIGridObject* self) {
delete self->data; // Clean up the allocated UIGrid object

View File

@ -58,6 +58,7 @@ public:
static PyMethodDef methods[];
static PyGetSetDef getsetters[];
static PyObject* get_children(PyUIGridObject* self, void* closure);
static PyObject* repr(PyUIGridObject* self);
};
@ -97,7 +98,6 @@ public:
};
namespace mcrfpydef {
static PyTypeObject PyUIGridType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.Grid",
@ -110,7 +110,7 @@ namespace mcrfpydef {
// Py_TYPE(self)->tp_free(self);
//},
//TODO - PyUIGrid REPR def:
// .tp_repr = (reprfunc)UIGrid::repr,
.tp_repr = (reprfunc)UIGrid::repr,
//.tp_hash = NULL,
//.tp_iter
//.tp_iternext

View File

@ -98,6 +98,19 @@ PyGetSetDef UIGridPoint::getsetters[] = {
{NULL} /* Sentinel */
};
PyObject* UIGridPoint::repr(PyUIGridPointObject* self) {
std::ostringstream ss;
if (!self->data) ss << "<GridPoint (invalid internal object)>";
else {
auto gp = self->data;
ss << "<GridPoint (walkable=" << (gp->walkable ? "True" : "False") << ", transparent=" << (gp->transparent ? "True" : "False") <<
", tilesprite=" << gp->tilesprite << ", tile_overlay=" << gp->tile_overlay << ", uisprite=" << gp->uisprite <<
")>";
}
std::string repr_str = ss.str();
return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace");
}
PyObject* UIGridPointState::get_bool_member(PyUIGridPointStateObject* self, void* closure) {
if (reinterpret_cast<long>(closure) == 0) { // visible
return PyBool_FromLong(self->data->visible);
@ -132,3 +145,14 @@ PyGetSetDef UIGridPointState::getsetters[] = {
{NULL} /* Sentinel */
};
PyObject* UIGridPointState::repr(PyUIGridPointStateObject* self) {
std::ostringstream ss;
if (!self->data) ss << "<GridPointState (invalid internal object)>";
else {
auto gps = self->data;
ss << "<GridPointState (visible=" << (gps->visible ? "True" : "False") << ", discovered=" << (gps->discovered ? "True" : "False") <<
")>";
}
std::string repr_str = ss.str();
return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace");
}

View File

@ -49,6 +49,7 @@ public:
static int set_bool_member(PyUIGridPointObject* self, PyObject* value, void* closure);
static PyObject* get_bool_member(PyUIGridPointObject* self, void* closure);
static int set_color(PyUIGridPointObject* self, PyObject* value, void* closure);
static PyObject* repr(PyUIGridPointObject* self);
};
// UIGridPointState - entity-specific info for each cell
@ -60,33 +61,32 @@ public:
static PyObject* get_bool_member(PyUIGridPointStateObject* self, void* closure);
static int set_bool_member(PyUIGridPointStateObject* self, PyObject* value, void* closure);
static PyGetSetDef getsetters[];
static PyObject* repr(PyUIGridPointStateObject* self);
};
namespace mcrfpydef {
static PyTypeObject PyUIGridPointType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.GridPoint",
.tp_basicsize = sizeof(PyUIGridPointObject),
.tp_itemsize = 0,
.tp_repr = (reprfunc)UIGridPoint::repr,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "UIGridPoint object",
.tp_getset = UIGridPoint::getsetters,
//.tp_init = (initproc)PyUIGridPoint_init, // TODO Define the init function
.tp_new = PyType_GenericNew,
};
static PyTypeObject PyUIGridPointType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.GridPoint",
.tp_basicsize = sizeof(PyUIGridPointObject),
.tp_itemsize = 0,
// Methods omitted for brevity
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "UIGridPoint object",
.tp_getset = UIGridPoint::getsetters,
//.tp_init = (initproc)PyUIGridPoint_init, // TODO Define the init function
.tp_new = PyType_GenericNew,
};
static PyTypeObject PyUIGridPointStateType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.GridPointState",
.tp_basicsize = sizeof(PyUIGridPointStateObject),
.tp_itemsize = 0,
// Methods omitted for brevity
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "UIGridPointState object", // TODO: Add PyUIGridPointState tp_init
.tp_getset = UIGridPointState::getsetters,
.tp_new = PyType_GenericNew,
};
static PyTypeObject PyUIGridPointStateType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.GridPointState",
.tp_basicsize = sizeof(PyUIGridPointStateObject),
.tp_itemsize = 0,
.tp_repr = (reprfunc)UIGridPointState::repr,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "UIGridPointState object", // TODO: Add PyUIGridPointState tp_init
.tp_getset = UIGridPointState::getsetters,
.tp_new = PyType_GenericNew,
};
}

View File

@ -55,14 +55,7 @@ public:
};
//typedef struct {
// PyObject_HEAD
// std::shared_ptr<UISprite> data;
//} PyUISpriteObject;
namespace mcrfpydef {
static PyTypeObject PyUISpriteType = {
//PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "mcrfpy.Sprite",

View File

@ -154,7 +154,7 @@ void UITestScene::doAction(std::string name, std::string type)
*/
}
void UITestScene::sRender()
void UITestScene::render()
{
game->getWindow().clear();
game->getWindow().draw(text);

View File

@ -18,5 +18,5 @@ public:
UITestScene(GameEngine*);
void update() override final;
void doAction(std::string, std::string) override final;
void sRender() override final;
void render() override final;
};

View File

@ -14,18 +14,23 @@ ui = mcrfpy.sceneUI("pytest")
# Frame
f = mcrfpy.Frame(25, 19, 462, 346, fill_color=(255, 92, 92))
print("Frame alive")
# fill (LinkedColor / Color): f.fill_color
# outline (LinkedColor / Color): f.outline_color
# pos (LinkedVector / Vector): f.pos
# size (LinkedVector / Vector): f.size
# Caption
c = mcrfpy.Caption(512+25, 19, "Hi.", font)
print("Caption attempt w/ fill_color:")
#c = mcrfpy.Caption(512+25, 19, "Hi.", font)
#c = mcrfpy.Caption(512+25, 19, "Hi.", font, fill_color=(255, 128, 128))
c = mcrfpy.Caption(512+25, 19, "Hi.", font, fill_color=mcrfpy.Color(255, 128, 128), outline_color=(128, 255, 128))
print("Caption alive")
# fill (LinkedColor / Color): c.fill_color
#color_val = c.fill_color
print(c.fill_color)
print("Set a fill color")
c.fill_color = (255, 255, 255)
#print("Set a fill color")
#c.fill_color = (255, 255, 255)
print("Lol, did it segfault?")
# outline (LinkedColor / Color): c.outline_color
# font (Font): c.font