Adding text functionality to Caption (why was that missing???)
This commit is contained in:
parent
343669df1e
commit
4b31864b2f
|
@ -1,7 +1,8 @@
|
||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include <list>
|
//#include <list>
|
||||||
#include "UI.h"
|
//#include "UI.h"
|
||||||
// Resources class members memory allocation
|
// Resources class members memory allocation
|
||||||
|
|
||||||
sf::Font Resources::font;
|
sf::Font Resources::font;
|
||||||
GameEngine* Resources::game;
|
GameEngine* Resources::game;
|
||||||
|
std::string Resources::caption_buffer;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <list>
|
//#include <list>
|
||||||
#include "UI.h"
|
//#include "UI.h"
|
||||||
|
|
||||||
class GameEngine; // forward declared
|
class GameEngine; // forward declared
|
||||||
|
|
||||||
|
@ -10,4 +10,5 @@ class Resources
|
||||||
public:
|
public:
|
||||||
static sf::Font font;
|
static sf::Font font;
|
||||||
static GameEngine* game;
|
static GameEngine* game;
|
||||||
|
static std::string caption_buffer;
|
||||||
};
|
};
|
||||||
|
|
12
src/UI.h
12
src/UI.h
|
@ -3,6 +3,7 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "structmember.h"
|
#include "structmember.h"
|
||||||
#include "IndexTexture.h"
|
#include "IndexTexture.h"
|
||||||
|
#include "Resources.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
enum PyObjectsEnum : int
|
enum PyObjectsEnum : int
|
||||||
|
@ -657,12 +658,19 @@ static int PyUIDrawable_set_click(PyUIGridObject* self, PyObject* value, void* c
|
||||||
|
|
||||||
static PyObject* PyUICaption_get_text(PyUICaptionObject* self, void* closure)
|
static PyObject* PyUICaption_get_text(PyUICaptionObject* self, void* closure)
|
||||||
{
|
{
|
||||||
return PyUnicode_FromString("Test String, Please Ignore");
|
Resources::caption_buffer = self->data->text.getString();
|
||||||
|
return PyUnicode_FromString(Resources::caption_buffer.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PyUICaption_set_text(PyUICaptionObject* self, PyObject* value, void* closure)
|
static int PyUICaption_set_text(PyUICaptionObject* self, PyObject* value, void* closure)
|
||||||
{
|
{
|
||||||
// asdf
|
PyObject* s = PyObject_Str(value);
|
||||||
|
PyObject * temp_bytes = PyUnicode_AsEncodedString(s, "UTF-8", "strict"); // Owned reference
|
||||||
|
if (temp_bytes != NULL) {
|
||||||
|
Resources::caption_buffer = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
|
||||||
|
Py_DECREF(temp_bytes);
|
||||||
|
}
|
||||||
|
self->data->text.setString(Resources::caption_buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue