diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2012-01-05 01:40:00 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2012-01-05 01:40:00 +0400 |
commit | be025ea31985f7614106b47a519d6e678a19fb95 (patch) | |
tree | 369a126b807ff727a7faf624314e0389e5a9e5c5 /release | |
parent | 049ab984697aa277c476833670275624c4385257 (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 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/space_logic.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py index 1fc58475ace..79a3f72ff48 100644 --- a/release/scripts/startup/bl_ui/space_logic.py +++ b/release/scripts/startup/bl_ui/space_logic.py @@ -20,6 +20,12 @@ import bpy from bpy.types import Header, Menu, Panel +def get_id_by_name(properties, name): + """returns ID""" + for i, prop in enumerate(properties): + if prop.name == name: + return i + return -1 class LOGIC_PT_properties(Panel): bl_space_type = 'LOGIC_EDITOR' @@ -37,10 +43,29 @@ class LOGIC_PT_properties(Panel): ob = context.active_object game = ob.game + if ob.type == 'FONT': + prop = game.properties.get("Text") + if prop: + layout.operator("object.game_property_remove", text="Text Game Property", icon='X').index = get_id_by_name(game.properties, "Text") + row = layout.row() + sub=row.row() + sub.enabled=0 + sub.prop(prop, "name", text="") + row.prop(prop, "type", text="") + # get the property from the body, not the game property + row.prop(ob.data, "body", text="") + else: + props=layout.operator("object.game_property_new", text="Text Game Property", icon='ZOOMIN') + props.name='Text' + props.type='STRING' + layout.operator("object.game_property_new", text="Add Game Property", icon='ZOOMIN') for i, prop in enumerate(game.properties): + if ob.type == 'FONT' and prop.name == "Text": + continue + box = layout.box() row = box.row() row.prop(prop, "name", text="") |