small changes...
- allow RNA_property_enum_items to take the totitems int pointer as NULL (spares a loop on all the enum items). this change also makes enums types with no enum array crash in some places, could support these though Id rather disallow them, generating docs is a quick way to test for this. - open recent file operator used and enum to open the recent file without an enum array, changed to an int type. - added space_logic.py poll functions
This commit is contained in:
@@ -5,6 +5,10 @@ class LOGIC_PT_physics(bpy.types.Panel):
|
||||
__region_type__ = "UI"
|
||||
__label__ = "Physics"
|
||||
|
||||
def poll(self, context):
|
||||
ob = context.active_object
|
||||
return ob and ob.game
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
ob = context.active_object
|
||||
@@ -56,6 +60,10 @@ class LOGIC_PT_collision_bounds(bpy.types.Panel):
|
||||
__space_type__ = "LOGIC_EDITOR"
|
||||
__region_type__ = "UI"
|
||||
__label__ = "Collision Bounds"
|
||||
|
||||
def poll(self, context):
|
||||
ob = context.active_object
|
||||
return ob and ob.game
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -643,25 +643,28 @@ void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPrope
|
||||
|
||||
if(eprop->itemf) {
|
||||
*item= eprop->itemf(ptr);
|
||||
for(tot=0; (*item)[tot].identifier; tot++);
|
||||
*totitem= tot;
|
||||
if(totitem) {
|
||||
for(tot=0; (*item)[tot].identifier; tot++);
|
||||
*totitem= tot;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*item= eprop->item;
|
||||
*totitem= eprop->totitem;
|
||||
if(totitem)
|
||||
*totitem= eprop->totitem;
|
||||
}
|
||||
}
|
||||
|
||||
int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
|
||||
{
|
||||
const EnumPropertyItem *item;
|
||||
int totitem, i;
|
||||
int i;
|
||||
|
||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
||||
|
||||
for(i=0; i<totitem; i++) {
|
||||
if(strcmp(item[i].identifier, identifier)==0) {
|
||||
*value = item[i].value;
|
||||
for(; item->identifier; item++) {
|
||||
if(strcmp(item->identifier, identifier)==0) {
|
||||
*value = item->value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -693,11 +696,9 @@ int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **na
|
||||
|
||||
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
|
||||
{
|
||||
const EnumPropertyItem *item;
|
||||
int totitem;
|
||||
|
||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
||||
const EnumPropertyItem *item= NULL;
|
||||
|
||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
||||
return RNA_enum_identifier(item, value, identifier);
|
||||
}
|
||||
|
||||
@@ -2067,14 +2068,13 @@ int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
|
||||
{
|
||||
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
||||
const EnumPropertyItem *item;
|
||||
int a, totitem;
|
||||
|
||||
if(prop) {
|
||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
||||
|
||||
for(a=0; a<totitem; a++)
|
||||
if(strcmp(item[a].identifier, enumname) == 0)
|
||||
return (item[a].value == RNA_property_enum_get(ptr, prop));
|
||||
for(; item->identifier; item++)
|
||||
if(strcmp(item->identifier, enumname) == 0)
|
||||
return (item->value == RNA_property_enum_get(ptr, prop));
|
||||
|
||||
printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname);
|
||||
return 0;
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
|
||||
static int mathutils_rna_vector_cb_index= -1; /* index for our callbacks */
|
||||
|
||||
static int mathutils_rna_vector_check(PyObject *user)
|
||||
static int mathutils_rna_vector_check(BPy_PropertyRNA *self)
|
||||
{
|
||||
return ((BPy_PropertyRNA *)user)->prop?1:0;
|
||||
return self->prop?1:0;
|
||||
}
|
||||
|
||||
static int mathutils_rna_vector_get(BPy_PropertyRNA *self, int subtype, float *vec_from)
|
||||
@@ -190,7 +190,7 @@ static char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
|
||||
const EnumPropertyItem *item;
|
||||
int totitem;
|
||||
|
||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
||||
return (char*)BPy_enum_as_string((EnumPropertyItem*)item);
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
|
||||
|
||||
static int recentfile_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int event= RNA_enum_get(op->ptr, "nr");
|
||||
int event= RNA_int_get(op->ptr, "nr");
|
||||
|
||||
// XXX wm in context is not set correctly after WM_read_file -> crash
|
||||
// do it before for now, but is this correct with multiple windows?
|
||||
@@ -557,7 +557,7 @@ static void WM_OT_open_recentfile(wmOperatorType *ot)
|
||||
ot->exec= recentfile_exec;
|
||||
ot->poll= WM_operator_winactive;
|
||||
|
||||
RNA_def_property(ot->srna, "nr", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property(ot->srna, "nr", PROP_INT, PROP_UNSIGNED);
|
||||
}
|
||||
|
||||
/* ********* main file *********** */
|
||||
|
||||
Reference in New Issue
Block a user