* KX_PythonSeq - comparisons work again. eg. act1.sensors == act2.sensors, had to copy Py_CmpToRich inline grr!, mailed python-dev about this.

* Shift-Click on states in the logic UI works again.
* New Logic Space has all the view options pressed.
This commit is contained in:
Campbell Barton 2009-09-02 20:46:28 +00:00
parent 21af438ef8
commit e80b37cd75
4 changed files with 64 additions and 28 deletions

@ -83,9 +83,6 @@ static int pupmenu() {return 1;}
#define B_REDR 1 #define B_REDR 1
#define B_IDNAME 2 #define B_IDNAME 2
#define B_ADD_PROP 2701
#define B_CHANGE_PROP 2702
#define B_ADD_SENS 2703 #define B_ADD_SENS 2703
#define B_CHANGE_SENS 2704 #define B_CHANGE_SENS 2704
#define B_DEL_SENS 2705 #define B_DEL_SENS 2705
@ -364,7 +361,6 @@ static void sca_move_actuator(bContext *C, void *datav, void *data2_unused)
void do_logic_buts(bContext *C, void *arg, int event) void do_logic_buts(bContext *C, void *arg, int event)
{ {
bProperty *prop;
bSensor *sens; bSensor *sens;
bController *cont; bController *cont;
bActuator *act; bActuator *act;
@ -386,25 +382,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
case B_SETMAINACTOR: case B_SETMAINACTOR:
ob->gameflag &= ~(OB_SECTOR|OB_PROP); ob->gameflag &= ~(OB_SECTOR|OB_PROP);
break; break;
case B_ADD_PROP:
prop= new_property(PROP_FLOAT);
make_unique_prop_names(C, prop->name);
BLI_addtail(&ob->prop, prop);
ED_undo_push(C, "Add property");
break;
#if 0 // XXX Now done in python
case B_CHANGE_PROP:
prop= ob->prop.first;
while(prop) {
if(prop->type!=prop->otype) {
init_property(prop);
}
prop= prop->next;
}
break;
#endif
case B_ADD_SENS: case B_ADD_SENS:
for(ob=G.main->object.first; ob; ob=ob->id.next) { for(ob=G.main->object.first; ob; ob=ob->id.next) {
if(ob->scaflag & OB_ADDSENS) { if(ob->scaflag & OB_ADDSENS) {
@ -1666,7 +1644,8 @@ char *get_state_name(Object *ob, short bit)
static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask) static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask)
{ {
int shift= 0; // XXX wmWindow *win= CTX_wm_window(C);
int shift= win->eventstate->shift;
unsigned int *cont_mask = arg2_mask; unsigned int *cont_mask = arg2_mask;
uiBut *but = arg1_but; uiBut *but = arg1_but;

@ -102,6 +102,13 @@ static SpaceLink *logic_new(const bContext *C)
slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic"); slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic");
slogic->spacetype= SPACE_LOGIC; slogic->spacetype= SPACE_LOGIC;
/* default options */
slogic->scaflag = (BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) |
(BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) |
(BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) |
(BUTS_SENS_STATE|BUTS_ACT_STATE);
/* header */ /* header */
ar= MEM_callocN(sizeof(ARegion), "header for logic"); ar= MEM_callocN(sizeof(ARegion), "header for logic");

@ -2018,4 +2018,42 @@ void resetGamePythonPath()
} }
/* Copied from pythons 3's Object.c
* also in blenders bpy_uitl.c, mailed the python-dev
* list about enabling something like this again for py3 */
PyObject *
Py_CmpToRich(int op, int cmp)
{
PyObject *res;
int ok;
if (PyErr_Occurred())
return NULL;
switch (op) {
case Py_LT:
ok = cmp < 0;
break;
case Py_LE:
ok = cmp <= 0;
break;
case Py_EQ:
ok = cmp == 0;
break;
case Py_NE:
ok = cmp != 0;
break;
case Py_GT:
ok = cmp > 0;
break;
case Py_GE:
ok = cmp >= 0;
break;
default:
PyErr_BadArgument();
return NULL;
}
res = ok ? Py_True : Py_False;
Py_INCREF(res);
return res;
}

@ -345,6 +345,19 @@ static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b ) /* TODO -
return ( a->type == b->type && a->base == b->base) ? 0 : -1; return ( a->type == b->type && a->base == b->base) ? 0 : -1;
} }
extern PyObject *Py_CmpToRich(int op, int cmp);
static PyObject *KX_PythonSeq_richcmp(PyObject *a, PyObject *b, int op)
{
int cmp_result= -1; /* assume false */
if(BPy_KX_PythonSeq_Check(a) && BPy_KX_PythonSeq_Check(b)) {
cmp_result= KX_PythonSeq_compare((KX_PythonSeq *)a, (KX_PythonSeq *)b);
}
return Py_CmpToRich(op, cmp_result);
}
/* /*
* repr function * repr function
* convert to a list and get its string value * convert to a list and get its string value
@ -374,8 +387,7 @@ PyTypeObject KX_PythonSeq_Type = {
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
/* TODO, richcmp */ NULL, /* cmpfunc tp_compare; */
NULL, /* ( cmpfunc ) KX_PythonSeq_compare, // cmpfunc tp_compare; */
( reprfunc ) KX_PythonSeq_repr, /* reprfunc tp_repr; */ ( reprfunc ) KX_PythonSeq_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */ /* Method suites for standard classes */
@ -401,14 +413,14 @@ PyTypeObject KX_PythonSeq_Type = {
NULL, /* char *tp_doc; Documentation string */ NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */ /* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */ NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */ /* delete references to contained objects */
NULL, /* inquiry tp_clear; */ NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/ /*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/ /*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */ (richcmpfunc)KX_PythonSeq_richcmp, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/ /*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */ 0, /* long tp_weaklistoffset; */