Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2012-01-05 01:40:00 +0400
committerDalai Felinto <dfelinto@gmail.com>2012-01-05 01:40:00 +0400
commitbe025ea31985f7614106b47a519d6e678a19fb95 (patch)
tree369a126b807ff727a7faf624314e0389e5a9e5c5 /source/gameengine/Ketsji/KX_FontObject.cpp
parent049ab984697aa277c476833670275624c4385257 (diff)
This patch creates an interface for ["Text"] properties in Font objects.
Interface: http://www.pasteall.org/pic/show.php?id=23785 Simple test file: http://www.pasteall.org/blend/10616 (I'll commit this to the text suite later) Code Explanation: --------------- (1) it adds a toggle to add/remove a "Text" gameproperty. - internally this property is just another game property (so we can find it within the game.properties lookup). - the property itself has no 'value', the interface shows the content of ob.data.body instead (why? because gameproperties are per object, while the text is per data). (2) at BGE converter time it sets the current value of the object.data.body to the ["Text"] property. (3) if you change object.text (bge text property) it automatically convert ["Text"] to a CStringValue. *** that means if the original property was a CIntegerValue, it will be converted to CStringValue forever *** * the only to do I can think of is to add a warning at doversion time if user has ["Text"] property for a Font object * * when that happens we print a warning in console/popup.*
Diffstat (limited to 'source/gameengine/Ketsji/KX_FontObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
index 5a4d9065605..c20015945aa 100644
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ b/source/gameengine/Ketsji/KX_FontObject.cpp
@@ -34,6 +34,7 @@
#include "KX_Scene.h"
#include "KX_PythonInit.h"
#include "BLI_math.h"
+#include "StringValue.h"
extern "C" {
#include "BLF_api.h"
@@ -224,7 +225,18 @@ int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
if(!PyUnicode_Check(value))
return PY_SET_ATTR_FAIL;
char* chars = _PyUnicode_AsString(value);
- self->m_text = split_string(STR_String(chars));
+
+ /* Allow for some logic brick control */
+ CValue* tprop = self->GetProperty("Text");
+ if(tprop) {
+ CValue *newstringprop = new CStringValue(STR_String(chars), "Text");
+ self->SetProperty("Text", newstringprop);
+ newstringprop->Release();
+ }
+ else {
+ self->m_text = split_string(STR_String(chars));
+ }
+
return PY_SET_ATTR_SUCCESS;
}