Compare commits
14 Commits
master
...
break_up_u
Author | SHA1 | Date |
---|---|---|
John McCardle | 6aa151aba3 | |
John McCardle | ec0374ef50 | |
John McCardle | 2cb7339535 | |
John McCardle | 5d6af324bf | |
John McCardle | 567218cd7b | |
John McCardle | 76693acd28 | |
John McCardle | 9efe998a33 | |
John McCardle | 714965da45 | |
John McCardle | 8efa25878f | |
John McCardle | c186d8c7f3 | |
John McCardle | 1b6e2a709b | |
John McCardle | aa7553a818 | |
John McCardle | c0201d989a | |
John McCardle | 83a63a3093 |
|
@ -59,7 +59,7 @@ void GameEngine::run()
|
|||
if (!paused)
|
||||
{
|
||||
}
|
||||
currentScene()->render();
|
||||
currentScene()->sRender();
|
||||
currentFrame++;
|
||||
frameTime = clock.restart().asSeconds();
|
||||
fps = 1 / frameTime;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "PyColor.h"
|
||||
#include "McRFPy_API.h"
|
||||
|
||||
PyGetSetDef PyColor::getsetters[] = {
|
||||
{"r", (getter)PyColor::get_member, (setter)PyColor::set_member, "Red component", (void*)0},
|
||||
|
@ -135,16 +134,3 @@ 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;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ public:
|
|||
static int set_member(PyObject*, PyObject*, void*);
|
||||
|
||||
static PyGetSetDef getsetters[];
|
||||
static PyColorObject* from_arg(PyObject*);
|
||||
};
|
||||
|
||||
namespace mcrfpydef {
|
||||
|
|
|
@ -59,7 +59,7 @@ void PyScene::doAction(std::string name, std::string type)
|
|||
}
|
||||
}
|
||||
|
||||
void PyScene::render()
|
||||
void PyScene::sRender()
|
||||
{
|
||||
game->getWindow().clear();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
PyScene(GameEngine*);
|
||||
void update() override final;
|
||||
void doAction(std::string, std::string) override final;
|
||||
void render() override final;
|
||||
void sRender() override final;
|
||||
|
||||
void do_mouse_input(std::string, std::string);
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
//Scene();
|
||||
Scene(GameEngine*);
|
||||
virtual void update() = 0;
|
||||
virtual void render() = 0;
|
||||
virtual void sRender() = 0;
|
||||
virtual void doAction(std::string, std::string) = 0;
|
||||
bool hasAction(std::string);
|
||||
bool hasAction(int);
|
||||
|
|
|
@ -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 <<"), " <<
|
||||
"outline_color=(" << (int)oc.r << ", " << (int)oc.g << ", " << (int)oc.b << ", " << (int)oc.a <<"), " <<
|
||||
"outlinecolor=(" << (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", "outline", nullptr };
|
||||
float x = 0.0f, y = 0.0f, outline = 0.0f;
|
||||
static const char* keywords[] = { "x", "y", "text", "font", "fill_color", "outline_color", nullptr };
|
||||
float x = 0.0f, y = 0.0f;
|
||||
char* text;
|
||||
PyObject* font=NULL, *fill_color=NULL, *outline_color=NULL;
|
||||
PyObject* font, fill_color, outline_color;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ffzOOOf",
|
||||
const_cast<char**>(keywords), &x, &y, &text, &font, &fill_color, &outline_color, &outline))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ffzOOO",
|
||||
const_cast<char**>(keywords), &x, &y, &text, &font, &fill_color, &outline_color))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -253,30 +253,8 @@ 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.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;
|
||||
}
|
||||
|
|
|
@ -163,15 +163,3 @@ 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");
|
||||
}
|
||||
|
|
135
src/UIEntity.h
135
src/UIEntity.h
|
@ -55,21 +55,148 @@ public:
|
|||
static int set_spritenumber(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
static PyMethodDef methods[];
|
||||
static PyGetSetDef getsetters[];
|
||||
static PyObject* repr(PyUIEntityObject* self);
|
||||
};
|
||||
|
||||
namespace mcrfpydef {
|
||||
static PyTypeObject PyUIEntityType = {
|
||||
/*
|
||||
//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,
|
||||
.tp_repr = (reprfunc)UIEntity::repr,
|
||||
// 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,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 << ", w=" <<
|
||||
ss << "<Frame (x=" << box.getPosition().x << ", y=" << box.getPosition().y << ", x=" <<
|
||||
box.getSize().x << ", w=" << box.getSize().y << ", " <<
|
||||
"outline=" << box.getOutlineThickness() << ", " <<
|
||||
"fill_color=(" << (int)fc.r << ", " << (int)fc.g << ", " << (int)fc.b << ", " << (int)fc.a <<"), " <<
|
||||
|
|
|
@ -45,6 +45,9 @@ 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",
|
||||
|
|
|
@ -421,37 +421,6 @@ 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
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
static PyMethodDef methods[];
|
||||
static PyGetSetDef getsetters[];
|
||||
static PyObject* get_children(PyUIGridObject* self, void* closure);
|
||||
static PyObject* repr(PyUIGridObject* self);
|
||||
|
||||
};
|
||||
|
||||
|
@ -98,6 +97,7 @@ 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
|
||||
|
|
|
@ -98,19 +98,6 @@ 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);
|
||||
|
@ -145,14 +132,3 @@ 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");
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ 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
|
||||
|
@ -61,32 +60,33 @@ 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 = {
|
||||
|
||||
static PyTypeObject PyUIGridPointType = {
|
||||
//PyVarObject_HEAD_INIT(NULL, 0)
|
||||
.tp_name = "mcrfpy.GridPoint",
|
||||
.tp_basicsize = sizeof(PyUIGridPointObject),
|
||||
.tp_itemsize = 0,
|
||||
.tp_repr = (reprfunc)UIGridPoint::repr,
|
||||
// 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 = {
|
||||
static PyTypeObject PyUIGridPointStateType = {
|
||||
//PyVarObject_HEAD_INIT(NULL, 0)
|
||||
.tp_name = "mcrfpy.GridPointState",
|
||||
.tp_basicsize = sizeof(PyUIGridPointStateObject),
|
||||
.tp_itemsize = 0,
|
||||
.tp_repr = (reprfunc)UIGridPointState::repr,
|
||||
// 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,
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,14 @@ 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",
|
||||
|
|
|
@ -154,7 +154,7 @@ void UITestScene::doAction(std::string name, std::string type)
|
|||
*/
|
||||
}
|
||||
|
||||
void UITestScene::render()
|
||||
void UITestScene::sRender()
|
||||
{
|
||||
game->getWindow().clear();
|
||||
game->getWindow().draw(text);
|
||||
|
|
|
@ -18,5 +18,5 @@ public:
|
|||
UITestScene(GameEngine*);
|
||||
void update() override final;
|
||||
void doAction(std::string, std::string) override final;
|
||||
void render() override final;
|
||||
void sRender() override final;
|
||||
};
|
||||
|
|
|
@ -14,23 +14,18 @@ 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
|
||||
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")
|
||||
c = mcrfpy.Caption(512+25, 19, "Hi.", font)
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue