2011-02-23 10:52:22 +00:00
/*
2009-06-17 11:01:05 +00:00
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
2010-02-12 13:34:04 +00:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2009-06-17 11:01:05 +00:00
*
* The Original Code is Copyright ( C ) 2009 Blender Foundation .
* All rights reserved .
*
*
* Contributor ( s ) : Blender Foundation
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
2011-02-27 20:29:51 +00:00
/** \file blender/editors/space_logic/logic_window.c
* \ ingroup splogic
*/
2009-06-17 11:01:05 +00:00
# include <string.h>
# include <stdio.h>
2009-12-29 18:57:59 +00:00
# include <stddef.h>
2009-08-29 23:13:27 +00:00
# include <float.h>
2009-06-17 11:01:05 +00:00
# include "DNA_actuator_types.h"
# include "DNA_controller_types.h"
# include "DNA_property_types.h"
# include "DNA_space_types.h"
# include "DNA_scene_types.h"
# include "DNA_screen_types.h"
# include "DNA_sensor_types.h"
2009-09-24 21:22:24 +00:00
# include "DNA_constraint_types.h"
2009-06-17 11:01:05 +00:00
# include "DNA_windowmanager_types.h"
2010-08-04 04:01:27 +00:00
# include "DNA_object_types.h"
2009-06-17 11:01:05 +00:00
# include "MEM_guardedalloc.h"
# include "BLI_blenlib.h"
2011-01-07 18:36:47 +00:00
# include "BLI_utildefines.h"
2009-06-17 11:01:05 +00:00
2011-02-07 22:48:23 +00:00
# include "BKE_action.h"
2009-06-17 11:01:05 +00:00
# include "BKE_context.h"
# include "BKE_global.h"
# include "BKE_library.h"
# include "BKE_main.h"
# include "BKE_sca.h"
# include "ED_util.h"
# include "WM_types.h"
# include "BIF_gl.h"
# include "UI_interface.h"
2010-04-29 07:01:48 +00:00
# include "RNA_access.h"
2009-06-17 11:01:05 +00:00
/* XXX BAD BAD */
# include "../interface/interface_intern.h"
# include "logic_intern.h"
# define B_REDR 1
# define B_ADD_SENS 2703
# define B_CHANGE_SENS 2704
# define B_DEL_SENS 2705
# define B_ADD_CONT 2706
# define B_CHANGE_CONT 2707
# define B_DEL_CONT 2708
# define B_ADD_ACT 2709
# define B_CHANGE_ACT 2710
# define B_DEL_ACT 2711
# define B_SOUNDACT_BROWSE 2712
# define B_SETPROP 2714
# define B_SETACTOR 2715
# define B_SETMAINACTOR 2716
# define B_SETDYNA 2717
# define B_SET_STATE_BIT 2718
# define B_INIT_STATE_BIT 2719
/* proto */
static ID * * get_selected_and_linked_obs ( bContext * C , short * count , short scavisflag ) ;
static int vergname ( const void * v1 , const void * v2 )
{
char * * x1 , * * x2 ;
x1 = ( char * * ) v1 ;
x2 = ( char * * ) v2 ;
2012-08-23 17:37:04 +00:00
return BLI_natstrcmp ( * x1 , * x2 ) ;
2009-06-17 11:01:05 +00:00
}
void make_unique_prop_names ( bContext * C , char * str )
{
Object * ob ;
bProperty * prop ;
bSensor * sens ;
bController * cont ;
bActuator * act ;
ID * * idar ;
short a , obcount , propcount = 0 , nr ;
char * * names ;
/* this function is called by a Button, and gives the current
2012-03-03 16:31:46 +00:00
* stringpointer as an argument , this is the one that can change
*/
2009-06-17 11:01:05 +00:00
idar = get_selected_and_linked_obs ( C , & obcount , BUTS_SENS_SEL | BUTS_SENS_ACT | BUTS_ACT_SEL | BUTS_ACT_ACT | BUTS_CONT_SEL | BUTS_CONT_ACT ) ;
/* for each object, make properties and sca names unique */
/* count total names */
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < obcount ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
propcount + = BLI_countlist ( & ob - > prop ) ;
propcount + = BLI_countlist ( & ob - > sensors ) ;
propcount + = BLI_countlist ( & ob - > controllers ) ;
propcount + = BLI_countlist ( & ob - > actuators ) ;
}
2012-03-24 06:38:07 +00:00
if ( propcount = = 0 ) {
if ( idar ) MEM_freeN ( idar ) ;
2009-06-17 11:01:05 +00:00
return ;
}
/* make names array for sorting */
names = MEM_callocN ( propcount * sizeof ( void * ) , " names " ) ;
/* count total names */
nr = 0 ;
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < obcount ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
prop = ob - > prop . first ;
2012-03-24 07:52:14 +00:00
while ( prop ) {
2009-06-17 11:01:05 +00:00
names [ nr + + ] = prop - > name ;
prop = prop - > next ;
}
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2009-06-17 11:01:05 +00:00
names [ nr + + ] = sens - > name ;
sens = sens - > next ;
}
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2009-06-17 11:01:05 +00:00
names [ nr + + ] = cont - > name ;
cont = cont - > next ;
}
act = ob - > actuators . first ;
2012-03-24 07:52:14 +00:00
while ( act ) {
2009-06-17 11:01:05 +00:00
names [ nr + + ] = act - > name ;
act = act - > next ;
}
}
qsort ( names , propcount , sizeof ( void * ) , vergname ) ;
/* now we check for double names, and change them */
2012-03-24 06:38:07 +00:00
for ( nr = 0 ; nr < propcount ; nr + + ) {
if ( names [ nr ] ! = str & & strcmp ( names [ nr ] , str ) = = 0 ) {
2009-06-17 11:01:05 +00:00
BLI_newname ( str , + 1 ) ;
}
}
MEM_freeN ( idar ) ;
MEM_freeN ( names ) ;
}
2011-02-14 17:55:27 +00:00
static void do_logic_buts ( bContext * C , void * UNUSED ( arg ) , int event )
2009-06-17 11:01:05 +00:00
{
2010-08-01 12:47:49 +00:00
Main * bmain = CTX_data_main ( C ) ;
2009-06-17 11:01:05 +00:00
bSensor * sens ;
bController * cont ;
bActuator * act ;
Object * ob ;
int didit , bit ;
ob = CTX_data_active_object ( C ) ;
2012-03-24 06:38:07 +00:00
if ( ob = = NULL ) return ;
2009-06-17 11:01:05 +00:00
2012-04-28 06:31:57 +00:00
switch ( event ) {
2009-06-17 11:01:05 +00:00
case B_SETPROP :
2010-01-26 14:00:13 +00:00
/* check for inconsistent types */
2009-06-17 11:01:05 +00:00
ob - > gameflag & = ~ ( OB_SECTOR | OB_MAINACTOR | OB_DYNAMIC | OB_ACTOR ) ;
break ;
case B_SETACTOR :
case B_SETDYNA :
case B_SETMAINACTOR :
ob - > gameflag & = ~ ( OB_SECTOR | OB_PROP ) ;
break ;
2009-09-02 20:46:28 +00:00
2009-06-17 11:01:05 +00:00
case B_ADD_SENS :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ADDSENS ) {
2009-06-17 11:01:05 +00:00
ob - > scaflag & = ~ OB_ADDSENS ;
sens = new_sensor ( SENS_ALWAYS ) ;
BLI_addtail ( & ( ob - > sensors ) , sens ) ;
make_unique_prop_names ( C , sens - > name ) ;
ob - > scaflag | = OB_SHOWSENS ;
}
}
ED_undo_push ( C , " Add sensor " ) ;
break ;
case B_CHANGE_SENS :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2012-03-24 06:38:07 +00:00
if ( sens - > type ! = sens - > otype ) {
2009-06-17 11:01:05 +00:00
init_sensor ( sens ) ;
sens - > otype = sens - > type ;
break ;
}
sens = sens - > next ;
}
}
break ;
case B_DEL_SENS :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2012-03-24 06:38:07 +00:00
if ( sens - > flag & SENS_DEL ) {
2009-06-17 11:01:05 +00:00
BLI_remlink ( & ( ob - > sensors ) , sens ) ;
free_sensor ( sens ) ;
break ;
}
sens = sens - > next ;
}
}
ED_undo_push ( C , " Delete sensor " ) ;
break ;
case B_ADD_CONT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ADDCONT ) {
2009-06-17 11:01:05 +00:00
ob - > scaflag & = ~ OB_ADDCONT ;
cont = new_controller ( CONT_LOGIC_AND ) ;
make_unique_prop_names ( C , cont - > name ) ;
ob - > scaflag | = OB_SHOWCONT ;
BLI_addtail ( & ( ob - > controllers ) , cont ) ;
/* set the controller state mask from the current object state.
2012-03-03 16:31:46 +00:00
* A controller is always in a single state , so select the lowest bit set
* from the object state */
2009-06-17 11:01:05 +00:00
for ( bit = 0 ; bit < 32 ; bit + + ) {
if ( ob - > state & ( 1 < < bit ) )
break ;
}
cont - > state_mask = ( 1 < < bit ) ;
if ( cont - > state_mask = = 0 ) {
/* shouldn't happen, object state is never 0 */
cont - > state_mask = 1 ;
}
}
}
ED_undo_push ( C , " Add controller " ) ;
break ;
case B_SET_STATE_BIT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ALLSTATE ) {
2010-05-12 08:34:15 +00:00
ob - > scaflag & = ~ OB_ALLSTATE ;
2009-06-17 11:01:05 +00:00
ob - > state = 0x3FFFFFFF ;
}
}
break ;
case B_INIT_STATE_BIT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_INITSTBIT ) {
2009-06-17 11:01:05 +00:00
ob - > scaflag & = ~ OB_INITSTBIT ;
ob - > state = ob - > init_state ;
if ( ! ob - > state )
ob - > state = 1 ;
}
}
break ;
case B_CHANGE_CONT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2012-03-24 06:38:07 +00:00
if ( cont - > type ! = cont - > otype ) {
2009-06-17 11:01:05 +00:00
init_controller ( cont ) ;
cont - > otype = cont - > type ;
break ;
}
cont = cont - > next ;
}
}
break ;
case B_DEL_CONT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2012-03-24 06:38:07 +00:00
if ( cont - > flag & CONT_DEL ) {
2009-06-17 11:01:05 +00:00
BLI_remlink ( & ( ob - > controllers ) , cont ) ;
unlink_controller ( cont ) ;
free_controller ( cont ) ;
break ;
}
cont = cont - > next ;
}
}
ED_undo_push ( C , " Delete controller " ) ;
break ;
case B_ADD_ACT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
if ( ob - > scaflag & OB_ADDACT ) {
2009-06-17 11:01:05 +00:00
ob - > scaflag & = ~ OB_ADDACT ;
act = new_actuator ( ACT_OBJECT ) ;
make_unique_prop_names ( C , act - > name ) ;
BLI_addtail ( & ( ob - > actuators ) , act ) ;
ob - > scaflag | = OB_SHOWACT ;
}
}
ED_undo_push ( C , " Add actuator " ) ;
break ;
case B_CHANGE_ACT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
act = ob - > actuators . first ;
2012-03-24 07:52:14 +00:00
while ( act ) {
2012-03-24 06:38:07 +00:00
if ( act - > type ! = act - > otype ) {
2009-06-17 11:01:05 +00:00
init_actuator ( act ) ;
act - > otype = act - > type ;
break ;
}
act = act - > next ;
}
}
break ;
case B_DEL_ACT :
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
act = ob - > actuators . first ;
2012-03-24 07:52:14 +00:00
while ( act ) {
2012-03-24 06:38:07 +00:00
if ( act - > flag & ACT_DEL ) {
2009-06-17 11:01:05 +00:00
BLI_remlink ( & ( ob - > actuators ) , act ) ;
unlink_actuator ( act ) ;
free_actuator ( act ) ;
break ;
}
act = act - > next ;
}
}
ED_undo_push ( C , " Delete actuator " ) ;
break ;
case B_SOUNDACT_BROWSE :
/* since we don't know which... */
didit = 0 ;
2012-03-24 06:38:07 +00:00
for ( ob = bmain - > object . first ; ob ; ob = ob - > id . next ) {
2009-06-17 11:01:05 +00:00
act = ob - > actuators . first ;
2012-04-28 06:31:57 +00:00
while ( act ) {
if ( act - > type = = ACT_SOUND ) {
2009-06-17 11:01:05 +00:00
bSoundActuator * sa = act - > data ;
2012-04-28 06:31:57 +00:00
if ( sa - > sndnr ) {
2010-08-04 04:01:27 +00:00
ID * sound = bmain - > sound . first ;
2009-06-17 11:01:05 +00:00
int nr = 1 ;
2012-03-24 06:38:07 +00:00
if ( sa - > sndnr = = - 2 ) {
2010-08-01 12:47:49 +00:00
// XXX activate_databrowse((ID *)bmain->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE,
2009-06-17 11:01:05 +00:00
// &sa->sndnr, do_logic_buts);
break ;
}
2012-04-28 06:31:57 +00:00
while ( sound ) {
2012-03-24 06:38:07 +00:00
if ( nr = = sa - > sndnr )
2009-06-17 11:01:05 +00:00
break ;
nr + + ;
2010-08-04 04:01:27 +00:00
sound = sound - > next ;
2009-06-17 11:01:05 +00:00
}
2012-03-24 06:38:07 +00:00
if ( sa - > sound )
2010-08-04 04:01:27 +00:00
( ( ID * ) sa - > sound ) - > us - - ;
2009-06-17 11:01:05 +00:00
2010-08-04 04:01:27 +00:00
sa - > sound = ( struct bSound * ) sound ;
2009-06-17 11:01:05 +00:00
2012-03-24 06:38:07 +00:00
if ( sound )
2010-08-04 04:01:27 +00:00
sound - > us + + ;
2009-06-17 11:01:05 +00:00
sa - > sndnr = 0 ;
didit = 1 ;
}
}
act = act - > next ;
}
2012-03-24 06:38:07 +00:00
if ( didit )
2009-06-17 11:01:05 +00:00
break ;
}
break ;
}
}
2010-12-03 17:05:21 +00:00
static const char * sensor_name ( int type )
2009-06-17 11:01:05 +00:00
{
switch ( type ) {
case SENS_ALWAYS :
return " Always " ;
case SENS_TOUCH :
return " Touch " ;
case SENS_NEAR :
return " Near " ;
case SENS_KEYBOARD :
return " Keyboard " ;
case SENS_PROPERTY :
return " Property " ;
2009-09-24 21:22:24 +00:00
case SENS_ARMATURE :
return " Armature " ;
2009-06-17 11:01:05 +00:00
case SENS_ACTUATOR :
return " Actuator " ;
case SENS_DELAY :
return " Delay " ;
case SENS_MOUSE :
return " Mouse " ;
case SENS_COLLISION :
return " Collision " ;
case SENS_RADAR :
return " Radar " ;
case SENS_RANDOM :
return " Random " ;
case SENS_RAY :
return " Ray " ;
case SENS_MESSAGE :
return " Message " ;
case SENS_JOYSTICK :
return " Joystick " ;
}
return " unknown " ;
}
2010-12-03 17:05:21 +00:00
static const char * controller_name ( int type )
2009-06-17 11:01:05 +00:00
{
switch ( type ) {
case CONT_LOGIC_AND :
2010-07-14 23:51:21 +00:00
return " And " ;
2009-06-17 11:01:05 +00:00
case CONT_LOGIC_OR :
2010-07-14 23:51:21 +00:00
return " Or " ;
2009-06-17 11:01:05 +00:00
case CONT_LOGIC_NAND :
2010-07-14 23:51:21 +00:00
return " Nand " ;
2009-06-17 11:01:05 +00:00
case CONT_LOGIC_NOR :
2010-07-14 23:51:21 +00:00
return " Nor " ;
2009-06-17 11:01:05 +00:00
case CONT_LOGIC_XOR :
2010-07-14 23:51:21 +00:00
return " Xor " ;
2009-06-17 11:01:05 +00:00
case CONT_LOGIC_XNOR :
2010-07-14 23:51:21 +00:00
return " Xnor " ;
2009-06-17 11:01:05 +00:00
case CONT_EXPRESSION :
return " Expression " ;
case CONT_PYTHON :
return " Python " ;
}
return " unknown " ;
}
2010-12-03 17:05:21 +00:00
static const char * actuator_name ( int type )
2009-06-17 11:01:05 +00:00
{
switch ( type ) {
case ACT_SHAPEACTION :
return " Shape Action " ;
case ACT_ACTION :
return " Action " ;
case ACT_OBJECT :
return " Motion " ;
case ACT_IPO :
2010-07-13 11:06:19 +00:00
return " F-Curve " ;
2009-06-17 11:01:05 +00:00
case ACT_LAMP :
return " Lamp " ;
case ACT_CAMERA :
return " Camera " ;
case ACT_MATERIAL :
return " Material " ;
case ACT_SOUND :
return " Sound " ;
case ACT_PROPERTY :
return " Property " ;
case ACT_EDIT_OBJECT :
return " Edit Object " ;
case ACT_CONSTRAINT :
return " Constraint " ;
case ACT_SCENE :
return " Scene " ;
case ACT_GROUP :
return " Group " ;
case ACT_RANDOM :
return " Random " ;
case ACT_MESSAGE :
return " Message " ;
case ACT_GAME :
return " Game " ;
case ACT_VISIBILITY :
return " Visibility " ;
case ACT_2DFILTER :
2010-07-13 11:06:19 +00:00
return " Filter 2D " ;
2009-06-17 11:01:05 +00:00
case ACT_PARENT :
return " Parent " ;
case ACT_STATE :
return " State " ;
2009-09-24 21:22:24 +00:00
case ACT_ARMATURE :
return " Armature " ;
2010-05-31 22:35:22 +00:00
case ACT_STEERING :
2011-05-16 20:30:59 +00:00
return " Steering " ;
2009-06-17 11:01:05 +00:00
}
return " unknown " ;
}
static void set_sca_ob ( Object * ob )
{
bController * cont ;
bActuator * act ;
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2009-06-17 11:01:05 +00:00
cont - > mynew = ( bController * ) ob ;
cont = cont - > next ;
}
act = ob - > actuators . first ;
2012-03-24 07:52:14 +00:00
while ( act ) {
2009-06-17 11:01:05 +00:00
act - > mynew = ( bActuator * ) ob ;
act = act - > next ;
}
}
static ID * * get_selected_and_linked_obs ( bContext * C , short * count , short scavisflag )
{
Base * base ;
2010-08-01 12:47:49 +00:00
Main * bmain = CTX_data_main ( C ) ;
2009-06-17 11:01:05 +00:00
Scene * scene = CTX_data_scene ( C ) ;
Object * ob , * obt , * obact = CTX_data_active_object ( C ) ;
ID * * idar ;
bSensor * sens ;
bController * cont ;
unsigned int lay ;
2012-05-19 13:28:19 +00:00
int a , nr , do_it ;
2009-06-17 11:01:05 +00:00
/* we need a sorted object list */
/* set scavisflags flags in Objects to indicate these should be evaluated */
/* also hide ob pointers in ->new entries of controllerss/actuators */
* count = 0 ;
2012-03-24 06:38:07 +00:00
if ( scene = = NULL ) return NULL ;
2009-06-17 11:01:05 +00:00
2010-08-01 12:47:49 +00:00
ob = bmain - > object . first ;
2012-03-24 07:52:14 +00:00
while ( ob ) {
2009-06-17 11:01:05 +00:00
ob - > scavisflag = 0 ;
set_sca_ob ( ob ) ;
ob = ob - > id . next ;
}
/* XXX here it checked 3d lay */
lay = scene - > lay ;
base = FIRSTBASE ;
2012-03-24 07:52:14 +00:00
while ( base ) {
2012-03-24 06:38:07 +00:00
if ( base - > lay & lay ) {
if ( base - > flag & SELECT ) {
if ( scavisflag & BUTS_SENS_SEL ) base - > object - > scavisflag | = OB_VIS_SENS ;
if ( scavisflag & BUTS_CONT_SEL ) base - > object - > scavisflag | = OB_VIS_CONT ;
if ( scavisflag & BUTS_ACT_SEL ) base - > object - > scavisflag | = OB_VIS_ACT ;
2009-06-17 11:01:05 +00:00
}
}
base = base - > next ;
}
2012-03-24 06:38:07 +00:00
if ( obact ) {
if ( scavisflag & BUTS_SENS_ACT ) obact - > scavisflag | = OB_VIS_SENS ;
if ( scavisflag & BUTS_CONT_ACT ) obact - > scavisflag | = OB_VIS_CONT ;
if ( scavisflag & BUTS_ACT_ACT ) obact - > scavisflag | = OB_VIS_ACT ;
2009-06-17 11:01:05 +00:00
}
/* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */
2012-03-24 06:38:07 +00:00
if ( scavisflag & ( BUTS_SENS_LINK | BUTS_CONT_LINK | BUTS_ACT_LINK | BUTS_SENS_STATE | BUTS_ACT_STATE ) ) {
2012-05-19 13:28:19 +00:00
do_it = TRUE ;
while ( do_it ) {
do_it = FALSE ;
2009-06-17 11:01:05 +00:00
2010-08-01 12:47:49 +00:00
ob = bmain - > object . first ;
2012-03-24 07:52:14 +00:00
while ( ob ) {
2009-06-17 11:01:05 +00:00
/* 1st case: select sensor when controller selected */
2012-03-24 06:38:07 +00:00
if ( ( scavisflag & ( BUTS_SENS_LINK | BUTS_SENS_STATE ) ) & & ( ob - > scavisflag & OB_VIS_SENS ) = = 0 ) {
2009-06-17 11:01:05 +00:00
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < sens - > totlinks ; a + + ) {
if ( sens - > links [ a ] ) {
2009-06-17 11:01:05 +00:00
obt = ( Object * ) sens - > links [ a ] - > mynew ;
2012-03-24 06:38:07 +00:00
if ( obt & & ( obt - > scavisflag & OB_VIS_CONT ) ) {
2012-05-19 13:28:19 +00:00
do_it = TRUE ;
2009-06-17 11:01:05 +00:00
ob - > scavisflag | = OB_VIS_SENS ;
break ;
}
}
}
2012-05-19 13:28:19 +00:00
if ( do_it ) break ;
2009-06-17 11:01:05 +00:00
sens = sens - > next ;
}
}
/* 2nd case: select cont when act selected */
2012-05-20 19:49:27 +00:00
if ( ( scavisflag & BUTS_CONT_LINK ) & & ( ob - > scavisflag & OB_VIS_CONT ) = = 0 ) {
2009-06-17 11:01:05 +00:00
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < cont - > totlinks ; a + + ) {
if ( cont - > links [ a ] ) {
2009-06-17 11:01:05 +00:00
obt = ( Object * ) cont - > links [ a ] - > mynew ;
2012-03-24 06:38:07 +00:00
if ( obt & & ( obt - > scavisflag & OB_VIS_ACT ) ) {
2012-05-19 13:28:19 +00:00
do_it = TRUE ;
2009-06-17 11:01:05 +00:00
ob - > scavisflag | = OB_VIS_CONT ;
break ;
}
}
}
2012-05-19 13:28:19 +00:00
if ( do_it ) break ;
2009-06-17 11:01:05 +00:00
cont = cont - > next ;
}
}
/* 3rd case: select controller when sensor selected */
2012-03-24 06:38:07 +00:00
if ( ( scavisflag & BUTS_CONT_LINK ) & & ( ob - > scavisflag & OB_VIS_SENS ) ) {
2009-06-17 11:01:05 +00:00
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2012-09-21 05:19:06 +00:00
for ( a = 0 ; a < sens - > totlinks ; a + + ) {
if ( sens - > links [ a ] ) {
obt = ( Object * ) sens - > links [ a ] - > mynew ;
if ( obt & & ( obt - > scavisflag & OB_VIS_CONT ) = = 0 ) {
do_it = TRUE ;
obt - > scavisflag | = OB_VIS_CONT ;
}
}
}
sens = sens - > next ;
}
}
/* 4th case: select actuator when controller selected */
if ( ( scavisflag & ( BUTS_ACT_LINK | BUTS_ACT_STATE ) ) & & ( ob - > scavisflag & OB_VIS_CONT ) ) {
cont = ob - > controllers . first ;
while ( cont ) {
for ( a = 0 ; a < cont - > totlinks ; a + + ) {
if ( cont - > links [ a ] ) {
obt = ( Object * ) cont - > links [ a ] - > mynew ;
if ( obt & & ( obt - > scavisflag & OB_VIS_ACT ) = = 0 ) {
do_it = TRUE ;
obt - > scavisflag | = OB_VIS_ACT ;
}
}
2012-06-06 14:48:39 +00:00
}
2012-09-21 05:19:06 +00:00
cont = cont - > next ;
}
2009-09-24 21:22:24 +00:00
}
2012-09-21 05:19:06 +00:00
ob = ob - > id . next ;
2009-09-24 21:22:24 +00:00
}
2012-09-21 05:19:06 +00:00
}
}
/* now we count */
ob = bmain - > object . first ;
while ( ob ) {
if ( ob - > scavisflag ) ( * count ) + + ;
ob = ob - > id . next ;
}
2009-06-17 11:01:05 +00:00
2012-09-21 05:19:06 +00:00
if ( * count = = 0 ) return NULL ;
if ( * count > 24 ) * count = 24 ; /* temporal */
idar = MEM_callocN ( ( * count ) * sizeof ( void * ) , " idar " ) ;
ob = bmain - > object . first ;
nr = 0 ;
2012-06-06 14:48:39 +00:00
2012-09-21 05:19:06 +00:00
/* make the active object always the first one of the list */
if ( obact ) {
idar [ 0 ] = ( ID * ) obact ;
nr + + ;
2009-06-17 11:01:05 +00:00
}
2012-09-21 05:19:06 +00:00
while ( ob ) {
if ( ( ob - > scavisflag ) & & ( ob ! = obact ) ) {
idar [ nr ] = ( ID * ) ob ;
nr + + ;
}
if ( nr > = 24 ) break ;
ob = ob - > id . next ;
}
/* just to be sure... these were set in set_sca_done_ob() */
clear_sca_new_poins ( ) ;
return idar ;
}
2009-06-17 11:01:05 +00:00
2012-09-21 05:19:06 +00:00
static void get_armature_bone_constraint ( Object * ob , const char * posechannel , const char * constraint_name , bConstraint * * constraint )
{
/* check that bone exist in the active object */
if ( ob - > type = = OB_ARMATURE & & ob - > pose ) {
bPoseChannel * pchan = BKE_pose_channel_find_name ( ob - > pose , posechannel ) ;
if ( pchan ) {
bConstraint * con = BLI_findstring ( & pchan - > constraints , constraint_name , offsetof ( bConstraint , name ) ) ;
if ( con ) {
* constraint = con ;
}
}
}
/* didn't find any */
2009-06-17 11:01:05 +00:00
}
2010-10-16 08:03:28 +00:00
static void do_sensor_menu ( bContext * C , void * UNUSED ( arg ) , int event )
2009-06-17 11:01:05 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceLogic * slogic = CTX_wm_space_logic ( C ) ;
2009-06-17 11:01:05 +00:00
ID * * idar ;
Object * ob ;
bSensor * sens ;
short count , a ;
idar = get_selected_and_linked_obs ( C , & count , slogic - > scaflag ) ;
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
2012-03-24 06:38:07 +00:00
if ( event = = 0 | | event = = 2 ) ob - > scaflag | = OB_SHOWSENS ;
else if ( event = = 1 ) ob - > scaflag & = ~ OB_SHOWSENS ;
2009-06-17 11:01:05 +00:00
}
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2012-03-24 06:38:07 +00:00
if ( event = = 2 ) sens - > flag | = SENS_SHOW ;
else if ( event = = 3 ) sens - > flag & = ~ SENS_SHOW ;
2009-06-17 11:01:05 +00:00
sens = sens - > next ;
}
}
2012-03-24 06:38:07 +00:00
if ( idar ) MEM_freeN ( idar ) ;
2009-06-17 11:01:05 +00:00
}
2010-10-16 08:03:28 +00:00
static uiBlock * sensor_menu ( bContext * C , ARegion * ar , void * UNUSED ( arg ) )
2009-06-17 11:01:05 +00:00
{
uiBlock * block ;
int yco = 0 ;
2012-01-11 09:33:44 +00:00
block = uiBeginBlock ( C , ar , __func__ , UI_EMBOSSP ) ;
2009-06-17 11:01:05 +00:00
uiBlockSetButmFunc ( block , do_sensor_menu , NULL ) ;
uiDefBut ( block , BUTM , 1 , " Show Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( yco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Show Sensors " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Sensors " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 3 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
uiEndBlock ( C , block ) ;
return block ;
}
2010-10-16 08:03:28 +00:00
static void do_controller_menu ( bContext * C , void * UNUSED ( arg ) , int event )
2009-06-17 11:01:05 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceLogic * slogic = CTX_wm_space_logic ( C ) ;
2009-06-17 11:01:05 +00:00
ID * * idar ;
Object * ob ;
bController * cont ;
short count , a ;
idar = get_selected_and_linked_obs ( C , & count , slogic - > scaflag ) ;
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
2012-03-24 06:38:07 +00:00
if ( event = = 0 | | event = = 2 ) ob - > scaflag | = OB_SHOWCONT ;
else if ( event = = 1 ) ob - > scaflag & = ~ OB_SHOWCONT ;
2009-06-17 11:01:05 +00:00
}
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2012-03-24 06:38:07 +00:00
if ( event = = 2 ) cont - > flag | = CONT_SHOW ;
else if ( event = = 3 ) cont - > flag & = ~ CONT_SHOW ;
2009-06-17 11:01:05 +00:00
cont = cont - > next ;
}
}
2012-03-24 06:38:07 +00:00
if ( idar ) MEM_freeN ( idar ) ;
2009-06-17 11:01:05 +00:00
}
2010-10-16 08:03:28 +00:00
static uiBlock * controller_menu ( bContext * C , ARegion * ar , void * UNUSED ( arg ) )
2009-06-17 11:01:05 +00:00
{
uiBlock * block ;
int yco = 0 ;
2012-01-11 09:33:44 +00:00
block = uiBeginBlock ( C , ar , __func__ , UI_EMBOSSP ) ;
2009-06-17 11:01:05 +00:00
uiBlockSetButmFunc ( block , do_controller_menu , NULL ) ;
uiDefBut ( block , BUTM , 1 , " Show Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
2012-04-29 15:47:02 +00:00
uiDefBut ( block , BUTM , 1 , " Hide Objects " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
2009-06-17 11:01:05 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( yco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Show Controllers " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 2 , 2 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Controllers " , 0 , ( short ) ( yco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 3 , 3 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
uiEndBlock ( C , block ) ;
return block ;
}
2010-10-16 08:03:28 +00:00
static void do_actuator_menu ( bContext * C , void * UNUSED ( arg ) , int event )
2009-06-17 11:01:05 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceLogic * slogic = CTX_wm_space_logic ( C ) ;
2009-06-17 11:01:05 +00:00
ID * * idar ;
Object * ob ;
bActuator * act ;
short count , a ;
idar = get_selected_and_linked_obs ( C , & count , slogic - > scaflag ) ;
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
2012-03-24 06:38:07 +00:00
if ( event = = 0 | | event = = 2 ) ob - > scaflag | = OB_SHOWACT ;
else if ( event = = 1 ) ob - > scaflag & = ~ OB_SHOWACT ;
2009-06-17 11:01:05 +00:00
}
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
act = ob - > actuators . first ;
2012-03-24 07:52:14 +00:00
while ( act ) {
2012-03-24 06:38:07 +00:00
if ( event = = 2 ) act - > flag | = ACT_SHOW ;
else if ( event = = 3 ) act - > flag & = ~ ACT_SHOW ;
2009-06-17 11:01:05 +00:00
act = act - > next ;
}
}
2012-03-24 06:38:07 +00:00
if ( idar ) MEM_freeN ( idar ) ;
2009-06-17 11:01:05 +00:00
}
2010-10-16 08:03:28 +00:00
static uiBlock * actuator_menu ( bContext * C , ARegion * ar , void * UNUSED ( arg ) )
2009-06-17 11:01:05 +00:00
{
uiBlock * block ;
int xco = 0 ;
2012-01-11 09:33:44 +00:00
block = uiBeginBlock ( C , ar , __func__ , UI_EMBOSSP ) ;
2009-06-17 11:01:05 +00:00
uiBlockSetButmFunc ( block , do_actuator_menu , NULL ) ;
uiDefBut ( block , BUTM , 1 , " Show Objects " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Objects " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , ( short ) ( xco - = 6 ) , 160 , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Show Actuators " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
uiDefBut ( block , BUTM , 1 , " Hide Actuators " , 0 , ( short ) ( xco - = 20 ) , 160 , 19 , NULL , 0.0 , 0.0 , 1 , 3 , " " ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
uiEndBlock ( C , block ) ;
return block ;
}
2010-10-16 08:03:28 +00:00
static void check_controller_state_mask ( bContext * UNUSED ( C ) , void * arg1_but , void * arg2_mask )
2009-06-17 11:01:05 +00:00
{
unsigned int * cont_mask = arg2_mask ;
uiBut * but = arg1_but ;
/* a controller is always in a single state */
* cont_mask = ( 1 < < but - > retval ) ;
but - > retval = B_REDR ;
}
static uiBlock * controller_state_mask_menu ( bContext * C , ARegion * ar , void * arg_cont )
{
uiBlock * block ;
uiBut * but ;
bController * cont = arg_cont ;
short yco = 12 , xco = 0 , stbit , offset ;
2012-01-11 09:33:44 +00:00
block = uiBeginBlock ( C , ar , __func__ , UI_EMBOSS ) ;
2009-06-17 11:01:05 +00:00
/* use this for a fake extra empy space around the buttons */
uiDefBut ( block , LABEL , 0 , " " , - 5 , - 5 , 200 , 34 , NULL , 0 , 0 , 0 , 0 , " " ) ;
for ( offset = 0 ; offset < 15 ; offset + = 5 ) {
uiBlockBeginAlign ( block ) ;
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
but = uiDefButBitI ( block , TOG , ( 1 < < ( stbit + offset ) ) , ( stbit + offset ) , " " , ( short ) ( xco + 12 * stbit + 13 * offset ) , yco , 12 , 12 , ( int * ) & ( cont - > state_mask ) , 0 , 0 , 0 , 0 , " " ) ;
uiButSetFunc ( but , check_controller_state_mask , but , & ( cont - > state_mask ) ) ;
}
for ( stbit = 0 ; stbit < 5 ; stbit + + ) {
but = uiDefButBitI ( block , TOG , ( 1 < < ( stbit + offset + 15 ) ) , ( stbit + offset + 15 ) , " " , ( short ) ( xco + 12 * stbit + 13 * offset ) , yco - 12 , 12 , 12 , ( int * ) & ( cont - > state_mask ) , 0 , 0 , 0 , 0 , " " ) ;
uiButSetFunc ( but , check_controller_state_mask , but , & ( cont - > state_mask ) ) ;
}
}
uiBlockEndAlign ( block ) ;
uiBlockSetDirection ( block , UI_TOP ) ;
uiEndBlock ( C , block ) ;
return block ;
}
static int is_sensor_linked ( uiBlock * block , bSensor * sens )
{
bController * cont ;
2011-02-28 03:17:53 +00:00
int i ;
2009-06-17 11:01:05 +00:00
2011-02-28 03:17:53 +00:00
for ( i = 0 ; i < sens - > totlinks ; i + + ) {
2009-06-17 11:01:05 +00:00
cont = sens - > links [ i ] ;
if ( uiFindInlink ( block , cont ) ! = NULL )
return 1 ;
}
return 0 ;
}
2010-05-04 00:06:13 +00:00
/* Sensors code */
2010-06-21 07:51:40 +00:00
static void draw_sensor_header ( uiLayout * layout , PointerRNA * ptr , PointerRNA * logic_ptr )
2010-04-29 07:01:48 +00:00
{
2011-11-23 19:05:52 +00:00
uiLayout * box , * row , * sub ;
2010-07-13 11:06:19 +00:00
bSensor * sens = ( bSensor * ) ptr - > data ;
2010-04-29 07:01:48 +00:00
2012-06-19 23:08:16 +00:00
box = uiLayoutBox ( layout ) ;
row = uiLayoutRow ( box , FALSE ) ;
2010-04-29 07:01:48 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " show_expanded " , UI_ITEM_R_NO_BG , " " , ICON_NONE ) ;
2012-03-24 06:38:07 +00:00
if ( RNA_boolean_get ( ptr , " show_expanded " ) ) {
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " type " , 0 , " " , ICON_NONE ) ;
uiItemR ( row , ptr , " name " , 0 , " " , ICON_NONE ) ;
2012-03-24 06:38:07 +00:00
}
else {
2011-02-27 18:03:19 +00:00
uiItemL ( row , sensor_name ( sens - > type ) , ICON_NONE ) ;
uiItemL ( row , sens - > name , ICON_NONE ) ;
2010-07-13 11:06:19 +00:00
}
2010-06-21 07:51:40 +00:00
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , FALSE ) ;
2012-04-21 15:11:03 +00:00
uiLayoutSetActive ( sub , ( ( RNA_boolean_get ( logic_ptr , " show_sensors_active_states " ) & &
RNA_boolean_get ( ptr , " show_expanded " ) ) | | RNA_boolean_get ( ptr , " pin " ) ) ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " pin " , UI_ITEM_R_NO_BG , " " , ICON_NONE ) ;
2010-06-21 07:51:40 +00:00
2012-03-24 06:38:07 +00:00
if ( RNA_boolean_get ( ptr , " show_expanded " ) = = 0 ) {
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemEnumO ( sub , " LOGIC_OT_sensor_move " , " " , ICON_TRIA_UP , " direction " , 1 ) ; // up
uiItemEnumO ( sub , " LOGIC_OT_sensor_move " , " " , ICON_TRIA_DOWN , " direction " , 2 ) ; // down
2010-07-09 00:14:46 +00:00
}
2010-04-29 07:01:48 +00:00
uiItemO ( row , " " , ICON_X , " LOGIC_OT_sensor_remove " ) ;
}
2010-05-04 00:06:13 +00:00
static void draw_sensor_internal_header ( uiLayout * layout , PointerRNA * ptr )
{
2011-11-23 19:05:52 +00:00
uiLayout * box , * split , * sub , * row ;
2010-04-29 07:01:48 +00:00
2012-06-19 23:08:16 +00:00
box = uiLayoutBox ( layout ) ;
split = uiLayoutSplit ( box , 0.45f , FALSE ) ;
2010-05-05 00:12:31 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , TRUE ) ;
2010-08-17 16:27:10 +00:00
uiItemR ( row , ptr , " use_pulse_true_level " , 0 , " " , ICON_DOTSUP ) ;
uiItemR ( row , ptr , " use_pulse_false_level " , 0 , " " , ICON_DOTSDOWN ) ;
2011-03-24 21:07:54 +00:00
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , FALSE ) ;
2012-04-21 15:11:03 +00:00
uiLayoutSetActive ( sub , ( RNA_boolean_get ( ptr , " use_pulse_true_level " ) | |
RNA_boolean_get ( ptr , " use_pulse_false_level " ) ) ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " frequency " , 0 , " Freq " , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_level " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_tap " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2011-11-23 19:05:52 +00:00
uiItemR ( split , ptr , " invert " , UI_ITEM_R_TOGGLE , " Invert " , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
/* sensors in alphabetical order */
static void draw_sensor_actuator ( uiLayout * layout , PointerRNA * ptr )
2010-04-29 07:01:48 +00:00
{
2010-05-08 22:11:00 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA settings_ptr ;
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2010-05-10 04:59:44 +00:00
uiItemPointerR ( layout , ptr , " actuator " , & settings_ptr , " actuators " , NULL , ICON_LOGIC ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_armature ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-11 06:56:59 +00:00
bSensor * sens = ( bSensor * ) ptr - > data ;
bArmatureSensor * as = ( bArmatureSensor * ) sens - > data ;
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA pose_ptr , pchan_ptr ;
2010-05-19 17:06:36 +00:00
PropertyRNA * bones_prop = NULL ;
2010-05-06 19:12:08 +00:00
uiLayout * row ;
2012-03-24 06:38:07 +00:00
if ( ob - > type ! = OB_ARMATURE ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Sensor only available for armatures " , ICON_NONE ) ;
2010-05-19 09:40:45 +00:00
return ;
}
2010-05-11 06:56:59 +00:00
if ( ob - > pose ) {
RNA_pointer_create ( ( ID * ) ob , & RNA_Pose , ob - > pose , & pose_ptr ) ;
bones_prop = RNA_struct_find_property ( & pose_ptr , " bones " ) ;
}
if ( & pose_ptr . data ) {
uiItemPointerR ( layout , ptr , " bone " , & pose_ptr , " bones " , NULL , ICON_BONE_DATA ) ;
if ( RNA_property_collection_lookup_string ( & pose_ptr , bones_prop , as - > posechannel , & pchan_ptr ) )
uiItemPointerR ( layout , ptr , " constraint " , & pchan_ptr , " constraints " , NULL , ICON_CONSTRAINT_BONE ) ;
}
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " test_type " , 0 , NULL , ICON_NONE ) ;
2011-01-21 08:59:08 +00:00
if ( RNA_enum_get ( ptr , " test_type " ) ! = SENS_ARM_STATE_CHANGED )
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
2010-06-03 08:26:47 +00:00
static void draw_sensor_collision ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-05-04 00:06:13 +00:00
{
2010-05-07 07:31:39 +00:00
uiLayout * row , * split ;
2010-06-03 08:26:47 +00:00
PointerRNA main_ptr ;
RNA_main_pointer_create ( CTX_data_main ( C ) , & main_ptr ) ;
2010-05-07 07:31:39 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.3f , FALSE ) ;
row = uiLayoutRow ( split , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_pulse " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_material " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
2011-03-25 14:32:47 +00:00
switch ( RNA_boolean_get ( ptr , " use_material " ) ) {
2010-05-04 00:06:13 +00:00
case SENS_COLLISION_PROPERTY :
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " property " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
break ;
case SENS_COLLISION_MATERIAL :
2010-06-03 08:26:47 +00:00
uiItemPointerR ( split , ptr , " material " , & main_ptr , " materials " , NULL , ICON_MATERIAL_DATA ) ;
2010-05-04 00:06:13 +00:00
break ;
}
2010-04-29 07:01:48 +00:00
}
static void draw_sensor_delay ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-04 00:06:13 +00:00
uiLayout * row ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2010-05-04 00:06:13 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " delay " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " duration " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_repeat " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_joystick ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-04 07:34:46 +00:00
uiLayout * col , * row ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " joystick_index " , 0 , NULL , ICON_NONE ) ;
uiItemR ( layout , ptr , " event_type " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
switch ( RNA_enum_get ( ptr , " event_type " ) ) {
case SENS_JOY_BUTTON :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " use_all_events " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( layout , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( col , RNA_boolean_get ( ptr , " use_all_events " ) = = FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " button_number " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
break ;
case SENS_JOY_AXIS :
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " axis_number " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " axis_threshold " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " use_all_events " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( layout , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( col , RNA_boolean_get ( ptr , " use_all_events " ) = = FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " axis_direction " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
break ;
case SENS_JOY_HAT :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " hat_number " , 0 , NULL , ICON_NONE ) ;
uiItemR ( layout , ptr , " use_all_events " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( layout , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( col , RNA_boolean_get ( ptr , " use_all_events " ) = = FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " hat_direction " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
break ;
case SENS_JOY_AXIS_SINGLE :
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " single_axis_number " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " axis_threshold " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
break ;
}
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_keyboard ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-08 22:11:00 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA settings_ptr ;
2010-05-07 07:31:39 +00:00
uiLayout * row , * col ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( row , " Key: " , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( col , RNA_boolean_get ( ptr , " use_all_keys " ) = = FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " key " , UI_ITEM_R_EVENT , " " , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " use_all_keys " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( layout , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( col , RNA_boolean_get ( ptr , " use_all_keys " ) = = FALSE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( row , " First Modifier: " , ICON_NONE ) ;
uiItemR ( row , ptr , " modifier_key_1 " , UI_ITEM_R_EVENT , " " , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( row , " Second Modifier: " , ICON_NONE ) ;
uiItemR ( row , ptr , " modifier_key_2 " , UI_ITEM_R_EVENT , " " , ICON_NONE ) ;
2010-05-08 22:11:00 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2011-02-27 18:03:19 +00:00
uiItemPointerR ( layout , ptr , " log " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
uiItemPointerR ( layout , ptr , " target " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_message ( uiLayout * layout , PointerRNA * ptr )
{
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " subject " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_mouse ( uiLayout * layout , PointerRNA * ptr )
{
2012-09-11 22:55:14 +00:00
uiLayout * split ;
split = uiLayoutSplit ( layout , 0.8f , FALSE ) ;
uiItemR ( split , ptr , " mouse_event " , 0 , NULL , ICON_NONE ) ;
if ( RNA_enum_get ( ptr , " mouse_event " ) = = BL_SENS_MOUSE_MOUSEOVER_ANY )
uiItemR ( split , ptr , " use_pulse " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_near ( uiLayout * layout , PointerRNA * ptr )
{
uiLayout * row ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " property " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " distance " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " reset_distance " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_property ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-08 22:11:00 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA settings_ptr ;
2010-05-04 00:06:13 +00:00
uiLayout * row ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " evaluation_type " , 0 , NULL , ICON_NONE ) ;
2010-05-08 22:11:00 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2011-02-27 18:03:19 +00:00
uiItemPointerR ( layout , ptr , " property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
switch ( RNA_enum_get ( ptr , " evaluation_type " ) ) {
case SENS_PROP_INTERVAL :
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " value_min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " value_max " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
break ;
case SENS_PROP_EQUAL :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
break ;
case SENS_PROP_NEQUAL :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
break ;
case SENS_PROP_CHANGED :
break ;
}
}
static void draw_sensor_radar ( uiLayout * layout , PointerRNA * ptr )
{
uiLayout * row ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " property " , 0 , NULL , ICON_NONE ) ;
uiItemR ( layout , ptr , " axis " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " angle " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " distance " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_random ( uiLayout * layout , PointerRNA * ptr )
{
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " seed " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
2010-06-03 08:26:47 +00:00
static void draw_sensor_ray ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-05-04 00:06:13 +00:00
{
2010-05-07 07:31:39 +00:00
uiLayout * split , * row ;
2010-06-03 08:26:47 +00:00
PointerRNA main_ptr ;
2010-05-07 07:31:39 +00:00
2010-06-03 08:26:47 +00:00
RNA_main_pointer_create ( CTX_data_main ( C ) , & main_ptr ) ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.3f , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " ray_type " , 0 , " " , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
switch ( RNA_enum_get ( ptr , " ray_type " ) ) {
case SENS_RAY_PROPERTY :
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " property " , 0 , " " , ICON_NONE ) ;
2010-06-03 08:26:47 +00:00
break ;
2010-05-04 07:34:46 +00:00
case SENS_RAY_MATERIAL :
2010-06-03 08:26:47 +00:00
uiItemPointerR ( split , ptr , " material " , & main_ptr , " materials " , " " , ICON_MATERIAL_DATA ) ;
break ;
2010-05-04 07:34:46 +00:00
}
2010-05-07 07:31:39 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.3 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " axis " , 0 , " " , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " range " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_x_ray " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_sensor_touch ( uiLayout * layout , PointerRNA * ptr )
{
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " material " , 0 , NULL , ICON_NONE ) ;
2010-04-29 07:01:48 +00:00
}
2011-02-14 17:55:27 +00:00
static void draw_brick_sensor ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-04-29 07:01:48 +00:00
{
uiLayout * box ;
2010-08-17 16:27:10 +00:00
if ( ! RNA_boolean_get ( ptr , " show_expanded " ) )
2010-04-29 07:01:48 +00:00
return ;
2010-05-05 00:12:31 +00:00
draw_sensor_internal_header ( layout , ptr ) ;
2010-04-29 07:01:48 +00:00
box = uiLayoutBox ( layout ) ;
2010-05-04 00:06:13 +00:00
2010-04-29 07:01:48 +00:00
switch ( RNA_enum_get ( ptr , " type " ) ) {
2010-05-04 00:06:13 +00:00
case SENS_ACTUATOR :
draw_sensor_actuator ( box , ptr ) ;
break ;
2010-04-29 07:01:48 +00:00
case SENS_ALWAYS :
break ;
2010-05-04 00:06:13 +00:00
case SENS_ARMATURE :
draw_sensor_armature ( box , ptr ) ;
break ;
case SENS_COLLISION :
2010-06-03 08:26:47 +00:00
draw_sensor_collision ( box , ptr , C ) ;
2010-04-29 07:01:48 +00:00
break ;
case SENS_DELAY :
draw_sensor_delay ( box , ptr ) ;
break ;
2010-05-04 00:06:13 +00:00
case SENS_JOYSTICK :
draw_sensor_joystick ( box , ptr ) ;
break ;
case SENS_KEYBOARD :
draw_sensor_keyboard ( box , ptr ) ;
break ;
case SENS_MESSAGE :
draw_sensor_message ( box , ptr ) ;
break ;
case SENS_MOUSE :
draw_sensor_mouse ( box , ptr ) ;
break ;
case SENS_NEAR :
draw_sensor_near ( box , ptr ) ;
break ;
case SENS_PROPERTY :
draw_sensor_property ( box , ptr ) ;
break ;
case SENS_RADAR :
draw_sensor_radar ( box , ptr ) ;
break ;
case SENS_RANDOM :
draw_sensor_random ( box , ptr ) ;
break ;
case SENS_RAY :
2010-06-03 08:26:47 +00:00
draw_sensor_ray ( box , ptr , C ) ;
2010-05-04 00:06:13 +00:00
break ;
case SENS_TOUCH :
draw_sensor_touch ( box , ptr ) ;
break ;
}
}
/* Controller code */
2010-07-13 11:06:19 +00:00
static void draw_controller_header ( uiLayout * layout , PointerRNA * ptr , int xco , int width , int yco )
2010-05-04 00:06:13 +00:00
{
2011-11-23 19:05:52 +00:00
uiLayout * box , * row , * sub ;
2010-07-13 11:06:19 +00:00
bController * cont = ( bController * ) ptr - > data ;
2010-07-14 23:51:21 +00:00
char state [ 3 ] ;
2012-01-11 12:33:51 +00:00
BLI_snprintf ( state , sizeof ( state ) , " %d " , RNA_int_get ( ptr , " states " ) ) ;
2010-05-04 00:06:13 +00:00
2012-06-19 23:08:16 +00:00
box = uiLayoutBox ( layout ) ;
row = uiLayoutRow ( box , FALSE ) ;
2010-05-04 00:06:13 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " show_expanded " , UI_ITEM_R_NO_BG , " " , ICON_NONE ) ;
2012-03-24 06:38:07 +00:00
if ( RNA_boolean_get ( ptr , " show_expanded " ) ) {
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " type " , 0 , " " , ICON_NONE ) ;
uiItemR ( row , ptr , " name " , 0 , " " , ICON_NONE ) ;
2010-07-14 23:51:21 +00:00
/* XXX provisory for Blender 2.50Beta */
uiDefBlockBut ( uiLayoutGetBlock ( layout ) , controller_state_mask_menu , cont , state , ( short ) ( xco + width - 44 ) , yco , 22 + 22 , UI_UNIT_Y , " Set controller state index (from 1 to 30) " ) ;
2012-03-24 06:38:07 +00:00
}
else {
2011-02-27 18:03:19 +00:00
uiItemL ( row , controller_name ( cont - > type ) , ICON_NONE ) ;
uiItemL ( row , cont - > name , ICON_NONE ) ;
uiItemL ( row , state , ICON_NONE ) ;
2010-07-13 11:06:19 +00:00
}
2010-06-16 08:29:40 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_priority " , 0 , " " , ICON_NONE ) ;
2010-07-09 00:14:46 +00:00
2012-03-24 06:38:07 +00:00
if ( RNA_boolean_get ( ptr , " show_expanded " ) = = 0 ) {
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemEnumO ( sub , " LOGIC_OT_controller_move " , " " , ICON_TRIA_UP , " direction " , 1 ) ; // up
uiItemEnumO ( sub , " LOGIC_OT_controller_move " , " " , ICON_TRIA_DOWN , " direction " , 2 ) ; // down
2010-07-09 00:14:46 +00:00
}
2010-05-04 00:06:13 +00:00
uiItemO ( row , " " , ICON_X , " LOGIC_OT_controller_remove " ) ;
}
static void draw_controller_expression ( uiLayout * layout , PointerRNA * ptr )
{
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " expression " , 0 , " " , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
static void draw_controller_python ( uiLayout * layout , PointerRNA * ptr )
{
2011-11-23 19:05:52 +00:00
uiLayout * split , * sub ;
2010-05-04 00:06:13 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.3 , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " mode " , 0 , " " , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
if ( RNA_enum_get ( ptr , " mode " ) = = CONT_PY_SCRIPT ) {
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " text " , 0 , " " , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
else {
2012-06-19 23:08:16 +00:00
sub = uiLayoutSplit ( split , 0.8f , FALSE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " module " , 0 , " " , ICON_NONE ) ;
uiItemR ( sub , ptr , " use_debug " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
}
2010-10-16 08:03:28 +00:00
static void draw_controller_state ( uiLayout * UNUSED ( layout ) , PointerRNA * UNUSED ( ptr ) )
2010-05-04 00:06:13 +00:00
{
}
2011-02-14 17:55:27 +00:00
static void draw_brick_controller ( uiLayout * layout , PointerRNA * ptr )
2010-05-04 00:06:13 +00:00
{
uiLayout * box ;
2010-08-17 16:27:10 +00:00
if ( ! RNA_boolean_get ( ptr , " show_expanded " ) )
2010-05-04 00:06:13 +00:00
return ;
box = uiLayoutBox ( layout ) ;
draw_controller_state ( box , ptr ) ;
switch ( RNA_enum_get ( ptr , " type " ) ) {
case CONT_LOGIC_AND :
break ;
case CONT_LOGIC_OR :
break ;
case CONT_EXPRESSION :
draw_controller_expression ( box , ptr ) ;
break ;
case CONT_PYTHON :
draw_controller_python ( box , ptr ) ;
break ;
case CONT_LOGIC_NAND :
break ;
case CONT_LOGIC_NOR :
break ;
case CONT_LOGIC_XOR :
break ;
case CONT_LOGIC_XNOR :
break ;
}
}
/* Actuator code */
2010-06-21 07:51:40 +00:00
static void draw_actuator_header ( uiLayout * layout , PointerRNA * ptr , PointerRNA * logic_ptr )
2010-05-04 00:06:13 +00:00
{
2011-11-23 19:05:52 +00:00
uiLayout * box , * row , * sub ;
2010-07-13 11:06:19 +00:00
bActuator * act = ( bActuator * ) ptr - > data ;
2010-05-04 00:06:13 +00:00
2012-06-19 23:08:16 +00:00
box = uiLayoutBox ( layout ) ;
row = uiLayoutRow ( box , FALSE ) ;
2010-05-04 00:06:13 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " show_expanded " , UI_ITEM_R_NO_BG , " " , ICON_NONE ) ;
2012-03-24 06:38:07 +00:00
if ( RNA_boolean_get ( ptr , " show_expanded " ) ) {
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " type " , 0 , " " , ICON_NONE ) ;
uiItemR ( row , ptr , " name " , 0 , " " , ICON_NONE ) ;
2012-03-24 06:38:07 +00:00
}
else {
2011-02-27 18:03:19 +00:00
uiItemL ( row , actuator_name ( act - > type ) , ICON_NONE ) ;
uiItemL ( row , act - > name , ICON_NONE ) ;
2010-07-13 11:06:19 +00:00
}
2010-06-21 07:51:40 +00:00
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , FALSE ) ;
2012-04-21 15:11:03 +00:00
uiLayoutSetActive ( sub , ( ( RNA_boolean_get ( logic_ptr , " show_actuators_active_states " ) & &
RNA_boolean_get ( ptr , " show_expanded " ) ) | | RNA_boolean_get ( ptr , " pin " ) ) ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " pin " , UI_ITEM_R_NO_BG , " " , ICON_NONE ) ;
2010-06-21 07:51:40 +00:00
2012-03-24 06:38:07 +00:00
if ( RNA_boolean_get ( ptr , " show_expanded " ) = = 0 ) {
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemEnumO ( sub , " LOGIC_OT_actuator_move " , " " , ICON_TRIA_UP , " direction " , 1 ) ; // up
uiItemEnumO ( sub , " LOGIC_OT_actuator_move " , " " , ICON_TRIA_DOWN , " direction " , 2 ) ; // down
2010-07-09 00:14:46 +00:00
}
2010-05-04 00:06:13 +00:00
uiItemO ( row , " " , ICON_X , " LOGIC_OT_actuator_remove " ) ;
}
2010-05-04 07:34:46 +00:00
static void draw_actuator_action ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-08 22:11:00 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA settings_ptr ;
2011-11-24 04:12:16 +00:00
uiLayout * row , * sub ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2010-05-08 22:11:00 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " play_mode " , 0 , " " , ICON_NONE ) ;
2011-06-16 01:18:52 +00:00
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " use_force " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( sub , ptr , " use_additive " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2011-06-16 01:18:52 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutColumn ( sub , FALSE ) ;
2011-11-23 19:05:52 +00:00
uiLayoutSetActive ( row , ( RNA_boolean_get ( ptr , " use_additive " ) | | RNA_boolean_get ( ptr , " use_force " ) ) ) ;
uiItemR ( row , ptr , " use_local " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2011-06-16 01:18:52 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-03-24 21:07:54 +00:00
uiItemR ( row , ptr , " action " , 0 , " " , ICON_NONE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_continue_last_frame " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2012-03-24 06:38:07 +00:00
if ( ( RNA_enum_get ( ptr , " play_mode " ) = = ACT_ACTION_FROM_PROP ) )
2011-02-27 18:03:19 +00:00
uiItemPointerR ( row , ptr , " property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
else {
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " frame_start " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " frame_end " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
}
2011-06-16 01:18:52 +00:00
uiItemR ( row , ptr , " apply_to_children " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " frame_blend_in " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " priority " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-06-11 01:03:03 +00:00
uiItemR ( row , ptr , " layer " , 0 , NULL , ICON_NONE ) ;
2011-07-03 01:59:17 +00:00
uiItemR ( row , ptr , " layer_weight " , 0 , NULL , ICON_NONE ) ;
2011-06-11 01:03:03 +00:00
2011-02-27 18:03:19 +00:00
uiItemPointerR ( layout , ptr , " frame_property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
# ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
2011-11-23 19:05:52 +00:00
uiItemR ( layout , " stride_length " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
# endif
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_armature ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-10 04:49:09 +00:00
bActuator * act = ( bActuator * ) ptr - > data ;
bArmatureActuator * aa = ( bArmatureActuator * ) act - > data ;
Object * ob = ( Object * ) ptr - > id . data ;
2011-02-07 18:24:15 +00:00
bConstraint * constraint = NULL ;
2010-05-10 04:49:09 +00:00
PointerRNA pose_ptr , pchan_ptr ;
2010-12-31 20:01:38 +00:00
PropertyRNA * bones_prop = NULL ;
2010-05-19 09:40:45 +00:00
2012-03-24 06:38:07 +00:00
if ( ob - > type ! = OB_ARMATURE ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Actuator only available for armatures " , ICON_NONE ) ;
2010-05-19 09:40:45 +00:00
return ;
}
2010-05-10 04:49:09 +00:00
if ( ob - > pose ) {
RNA_pointer_create ( ( ID * ) ob , & RNA_Pose , ob - > pose , & pose_ptr ) ;
bones_prop = RNA_struct_find_property ( & pose_ptr , " bones " ) ;
}
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2010-05-10 04:49:09 +00:00
2012-04-28 06:31:57 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
2010-05-06 03:26:46 +00:00
case ACT_ARM_RUN :
break ;
case ACT_ARM_ENABLE :
case ACT_ARM_DISABLE :
2010-10-07 10:04:07 +00:00
if ( ob - > pose ) {
2010-05-10 04:49:09 +00:00
uiItemPointerR ( layout , ptr , " bone " , & pose_ptr , " bones " , NULL , ICON_BONE_DATA ) ;
if ( RNA_property_collection_lookup_string ( & pose_ptr , bones_prop , aa - > posechannel , & pchan_ptr ) )
uiItemPointerR ( layout , ptr , " constraint " , & pchan_ptr , " constraints " , NULL , ICON_CONSTRAINT_BONE ) ;
}
2010-05-06 03:26:46 +00:00
break ;
case ACT_ARM_SETTARGET :
2010-10-07 10:04:07 +00:00
if ( ob - > pose ) {
2010-05-10 04:49:09 +00:00
uiItemPointerR ( layout , ptr , " bone " , & pose_ptr , " bones " , NULL , ICON_BONE_DATA ) ;
if ( RNA_property_collection_lookup_string ( & pose_ptr , bones_prop , aa - > posechannel , & pchan_ptr ) )
uiItemPointerR ( layout , ptr , " constraint " , & pchan_ptr , " constraints " , NULL , ICON_CONSTRAINT_BONE ) ;
}
2010-05-06 03:26:46 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " target " , 0 , NULL , ICON_NONE ) ;
2011-02-07 18:24:15 +00:00
/* show second target only if the constraint supports it */
get_armature_bone_constraint ( ob , aa - > posechannel , aa - > constraint , & constraint ) ;
if ( constraint & & constraint - > type = = CONSTRAINT_TYPE_KINEMATIC ) {
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " secondary_target " , 0 , NULL , ICON_NONE ) ;
2011-02-07 18:24:15 +00:00
}
2010-05-06 03:26:46 +00:00
break ;
case ACT_ARM_SETWEIGHT :
2010-10-07 10:04:07 +00:00
if ( ob - > pose ) {
2010-05-10 04:49:09 +00:00
uiItemPointerR ( layout , ptr , " bone " , & pose_ptr , " bones " , NULL , ICON_BONE_DATA ) ;
if ( RNA_property_collection_lookup_string ( & pose_ptr , bones_prop , aa - > posechannel , & pchan_ptr ) )
uiItemPointerR ( layout , ptr , " constraint " , & pchan_ptr , " constraints " , NULL , ICON_CONSTRAINT_BONE ) ;
}
2010-05-06 03:26:46 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " weight " , 0 , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
break ;
2012-03-03 02:47:01 +00:00
case ACT_ARM_SETINFLUENCE :
if ( ob - > pose ) {
uiItemPointerR ( layout , ptr , " bone " , & pose_ptr , " bones " , NULL , ICON_BONE_DATA ) ;
if ( RNA_property_collection_lookup_string ( & pose_ptr , bones_prop , aa - > posechannel , & pchan_ptr ) )
uiItemPointerR ( layout , ptr , " constraint " , & pchan_ptr , " constraints " , NULL , ICON_CONSTRAINT_BONE ) ;
}
uiItemR ( layout , ptr , " influence " , 0 , NULL , ICON_NONE ) ;
break ;
2010-05-06 03:26:46 +00:00
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_camera ( uiLayout * layout , PointerRNA * ptr )
{
uiLayout * row ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " object " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " height " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " axis " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " max " , 0 , NULL , ICON_NONE ) ;
2011-06-24 03:30:50 +00:00
uiItemR ( layout , ptr , " damping " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
}
2010-06-03 08:26:47 +00:00
static void draw_actuator_constraint ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-05-04 07:34:46 +00:00
{
2011-11-23 19:05:52 +00:00
uiLayout * row , * col , * sub , * split ;
2010-06-03 08:26:47 +00:00
PointerRNA main_ptr ;
RNA_main_pointer_create ( CTX_data_main ( C ) , & main_ptr ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2012-04-28 06:31:57 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
case ACT_CONST_TYPE_LOC :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " limit " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " limit_min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " limit_max " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " damping " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
break ;
case ACT_CONST_TYPE_DIST :
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.8 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " direction " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_local " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_normal " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
col = uiLayoutColumn ( row , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( col , " Range: " , ICON_NONE ) ;
uiItemR ( col , ptr , " range " , 0 , " " , ICON_NONE ) ;
2010-05-07 23:56:26 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " use_force_distance " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
sub = uiLayoutColumn ( col , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( sub , RNA_boolean_get ( ptr , " use_force_distance " ) = = TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " distance " , 0 , " " , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-04-29 15:47:02 +00:00
uiItemR ( layout , ptr , " damping " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.15f , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " use_material_detect " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-08-17 16:27:10 +00:00
if ( RNA_boolean_get ( ptr , " use_material_detect " ) )
2010-06-03 08:26:47 +00:00
uiItemPointerR ( split , ptr , " material " , & main_ptr , " materials " , NULL , ICON_MATERIAL_DATA ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
else
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " property " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.15 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " use_persistent " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " time " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " damping_rotation " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
break ;
case ACT_CONST_TYPE_ORI :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " direction_axis_pos " , 0 , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2012-04-29 15:47:02 +00:00
uiItemR ( row , ptr , " damping " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " time " , 0 , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " rotation_max " , 0 , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " angle_min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " angle_max " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
break ;
case ACT_CONST_TYPE_FH :
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.75 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2012-04-29 15:47:02 +00:00
uiItemR ( row , ptr , " fh_damping " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " fh_height " , 0 , NULL , ICON_NONE ) ;
2012-04-29 15:47:02 +00:00
uiItemR ( split , ptr , " use_fh_paralel_axis " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-07 07:31:39 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " direction_axis " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( row , 0.9f , FALSE ) ;
2011-03-03 01:47:17 +00:00
uiItemR ( split , ptr , " fh_force " , 0 , NULL , ICON_NONE ) ;
2012-04-29 15:47:02 +00:00
uiItemR ( split , ptr , " use_fh_normal " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.15 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " use_material_detect " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-08-17 16:27:10 +00:00
if ( RNA_boolean_get ( ptr , " use_material_detect " ) )
2010-06-03 08:26:47 +00:00
uiItemPointerR ( split , ptr , " material " , & main_ptr , " materials " , NULL , ICON_MATERIAL_DATA ) ;
2010-05-06 19:12:08 +00:00
else
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " property " , 0 , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.15 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " use_persistent " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 19:12:08 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " time " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " damping_rotation " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
break ;
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_edit_object ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-19 09:40:45 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
2011-11-23 19:05:52 +00:00
uiLayout * row , * split , * sub ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
2012-04-28 06:31:57 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
2010-05-06 03:26:46 +00:00
case ACT_EDOB_ADD_OBJECT :
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " object " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " time " , 0 , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " linear_velocity " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_linear_velocity " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " angular_velocity " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_angular_velocity " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
break ;
case ACT_EDOB_END_OBJECT :
break ;
case ACT_EDOB_REPLACE_MESH :
2012-03-24 06:38:07 +00:00
if ( ob - > type ! = OB_MESH ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Mode only available for mesh objects " , ICON_NONE ) ;
2010-05-19 09:40:45 +00:00
break ;
}
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.6 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " mesh " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_replace_display_mesh " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_replace_physics_mesh " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
break ;
case ACT_EDOB_TRACK_TO :
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.5 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " track_object " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
sub = uiLayoutSplit ( split , 0.7f , FALSE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " time " , 0 , NULL , ICON_NONE ) ;
uiItemR ( sub , ptr , " use_3d_tracking " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
break ;
case ACT_EDOB_DYNAMICS :
2012-03-24 06:38:07 +00:00
if ( ob - > type ! = OB_MESH ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Mode only available for mesh objects " , ICON_NONE ) ;
2010-05-19 09:40:45 +00:00
break ;
}
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " dynamic_operation " , 0 , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
if ( RNA_enum_get ( ptr , " dynamic_operation " ) = = ACT_EDOB_SET_MASS )
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mass " , 0 , NULL , ICON_NONE ) ;
2010-05-06 03:26:46 +00:00
break ;
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_filter_2d ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-11 06:56:59 +00:00
uiLayout * row , * split ;
2010-05-05 21:25:34 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2012-04-28 06:31:57 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
2010-05-05 21:25:34 +00:00
case ACT_2DFILTER_CUSTOMFILTER :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " filter_pass " , 0 , NULL , ICON_NONE ) ;
uiItemR ( layout , ptr , " glsl_shader " , 0 , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
break ;
case ACT_2DFILTER_MOTIONBLUR :
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.75f , TRUE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( row , RNA_boolean_get ( ptr , " use_motion_blur " ) = = TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " motion_blur_factor " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_motion_blur " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
break ;
default : // all other 2D Filters
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " filter_pass " , 0 , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
break ;
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_game ( uiLayout * layout , PointerRNA * ptr )
{
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
if ( RNA_enum_get ( ptr , " mode " ) = = ACT_GAME_LOAD )
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " filename " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
}
2010-06-03 08:26:47 +00:00
static void draw_actuator_message ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-05-04 07:34:46 +00:00
{
2010-05-08 22:11:00 +00:00
Object * ob ;
2010-06-03 08:26:47 +00:00
PointerRNA main_ptr , settings_ptr ;
2010-05-04 21:31:46 +00:00
uiLayout * row ;
2010-06-03 08:26:47 +00:00
RNA_main_pointer_create ( CTX_data_main ( C ) , & main_ptr ) ;
2010-05-08 22:11:00 +00:00
ob = ( Object * ) ptr - > id . data ;
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2010-06-03 08:26:47 +00:00
uiItemPointerR ( layout , ptr , " to_property " , & main_ptr , " objects " , NULL , ICON_OBJECT_DATA ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " subject " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " body_type " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-03-24 06:38:07 +00:00
if ( RNA_enum_get ( ptr , " body_type " ) = = ACT_MESG_MESG )
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " body_message " , 0 , " " , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
else // mode == ACT_MESG_PROP
2011-02-27 18:03:19 +00:00
uiItemPointerR ( row , ptr , " body_property " , & settings_ptr , " properties " , " " , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_motion ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-08 22:11:00 +00:00
Object * ob ;
2010-05-06 01:38:17 +00:00
PointerRNA settings_ptr ;
2011-11-23 19:05:52 +00:00
uiLayout * split , * row , * col , * sub ;
2010-07-08 06:49:08 +00:00
int physics_type ;
2010-05-08 22:11:00 +00:00
ob = ( Object * ) ptr - > id . data ;
2010-05-06 01:38:17 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2010-07-08 06:49:08 +00:00
physics_type = RNA_enum_get ( & settings_ptr , " physics_type " ) ;
2010-05-06 01:38:17 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2010-05-06 01:38:17 +00:00
2010-05-05 21:25:34 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
case ACT_OBJECT_NORMAL :
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " offset_location " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_location " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " offset_rotation " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_rotation " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-06 01:38:17 +00:00
2010-07-08 06:49:08 +00:00
if ( ELEM3 ( physics_type , OB_BODY_TYPE_DYNAMIC , OB_BODY_TYPE_RIGID , OB_BODY_TYPE_SOFT ) ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Dynamic Object Settings: " , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " force " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_force " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-07-08 06:49:08 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " torque " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_torque " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-07-08 06:49:08 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " linear_velocity " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_local_linear_velocity " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_add_linear_velocity " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-07-08 06:49:08 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " angular_velocity " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_angular_velocity " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-07-08 06:49:08 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " damping " , 0 , NULL , ICON_NONE ) ;
2010-07-08 06:49:08 +00:00
}
2010-05-05 21:25:34 +00:00
break ;
case ACT_OBJECT_SERVO :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " reference_object " , 0 , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.9 , FALSE ) ;
row = uiLayoutRow ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " linear_velocity " , 0 , NULL , ICON_NONE ) ;
uiItemR ( split , ptr , " use_local_linear_velocity " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
col = uiLayoutColumn ( row , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " use_servo_limit_x " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
sub = uiLayoutColumn ( col , TRUE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( sub , RNA_boolean_get ( ptr , " use_servo_limit_x " ) = = TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " force_max_x " , 0 , NULL , ICON_NONE ) ;
uiItemR ( sub , ptr , " force_min_x " , 0 , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " use_servo_limit_y " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
sub = uiLayoutColumn ( col , TRUE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( sub , RNA_boolean_get ( ptr , " use_servo_limit_y " ) = = TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " force_max_y " , 0 , NULL , ICON_NONE ) ;
uiItemR ( sub , ptr , " force_min_y " , 0 , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " use_servo_limit_z " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
sub = uiLayoutColumn ( col , TRUE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( sub , RNA_boolean_get ( ptr , " use_servo_limit_z " ) = = TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " force_max_z " , 0 , NULL , ICON_NONE ) ;
uiItemR ( sub , ptr , " force_min_z " , 0 , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
2010-05-06 03:26:46 +00:00
//XXXACTUATOR missing labels from original 2.49 ui (e.g. Servo, Min, Max, Fast)
2010-05-07 18:53:28 +00:00
//Layout designers willing to help on that, please compare with 2.49 ui
// (since the old code is going to be deleted ... soon)
2010-05-06 03:26:46 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( layout , TRUE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , ptr , " proportional_coefficient " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
uiItemR ( col , ptr , " integral_coefficient " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
uiItemR ( col , ptr , " derivate_coefficient " , UI_ITEM_R_SLIDER , NULL , ICON_NONE ) ;
2010-05-05 21:25:34 +00:00
break ;
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_parent ( uiLayout * layout , PointerRNA * ptr )
{
2011-11-23 19:05:52 +00:00
uiLayout * row , * sub ;
2010-05-04 07:34:46 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
2011-01-23 04:54:23 +00:00
if ( RNA_enum_get ( ptr , " mode " ) = = ACT_PARENT_SET ) {
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " object " , 0 , NULL , ICON_NONE ) ;
2011-01-23 04:54:23 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_compound " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( sub , RNA_boolean_get ( ptr , " use_compound " ) = = TRUE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " use_ghost " , 0 , NULL , ICON_NONE ) ;
2011-01-23 04:54:23 +00:00
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_property ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-08 22:11:00 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
2010-05-11 06:56:59 +00:00
bActuator * act = ( bActuator * ) ptr - > data ;
bPropertyActuator * pa = ( bPropertyActuator * ) act - > data ;
Object * ob_from = pa - > ob ;
PointerRNA settings_ptr , obj_settings_ptr ;
2010-05-04 21:31:46 +00:00
2011-11-23 19:05:52 +00:00
uiLayout * row , * sub ;
2010-05-08 22:11:00 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2010-05-11 06:56:59 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
uiItemPointerR ( layout , ptr , " property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-04-28 06:31:57 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
2010-05-04 21:31:46 +00:00
case ACT_PROP_TOGGLE :
break ;
case ACT_PROP_ADD :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_PROP_ASSIGN :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_PROP_COPY :
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " object " , 0 , NULL , ICON_NONE ) ;
2012-03-06 18:40:15 +00:00
if ( ob_from ) {
2010-05-11 06:56:59 +00:00
RNA_pointer_create ( ( ID * ) ob_from , & RNA_GameObjectSettings , ob_from , & obj_settings_ptr ) ;
2011-02-27 18:03:19 +00:00
uiItemPointerR ( row , ptr , " object_property " , & obj_settings_ptr , " properties " , NULL , ICON_NONE ) ;
2012-03-06 18:40:15 +00:00
}
else {
2012-06-19 23:08:16 +00:00
sub = uiLayoutRow ( row , FALSE ) ;
uiLayoutSetActive ( sub , FALSE ) ;
2011-11-23 19:05:52 +00:00
uiItemR ( sub , ptr , " object_property " , 0 , NULL , ICON_NONE ) ;
2010-05-11 06:56:59 +00:00
}
break ;
2010-05-04 21:31:46 +00:00
}
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_random ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-08 22:11:00 +00:00
Object * ob ;
PointerRNA settings_ptr ;
2010-05-04 21:31:46 +00:00
uiLayout * row ;
2010-05-08 22:11:00 +00:00
ob = ( Object * ) ptr - > id . data ;
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2010-05-04 21:31:46 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " seed " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " distribution " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemPointerR ( row , ptr , " property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2010-05-04 21:31:46 +00:00
2012-03-24 06:38:07 +00:00
switch ( RNA_enum_get ( ptr , " distribution " ) ) {
2010-05-04 21:31:46 +00:00
case ACT_RANDOM_BOOL_CONST :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_always_true " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_BOOL_UNIFORM :
2011-02-27 18:03:19 +00:00
uiItemL ( row , " Choose between true and false, 50% chance each " , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_BOOL_BERNOUILLI :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " chance " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_INT_CONST :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " int_value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_INT_UNIFORM :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " int_min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " int_max " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_INT_POISSON :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " int_mean " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_FLOAT_CONST :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " float_value " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_FLOAT_UNIFORM :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " float_min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " float_max " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_FLOAT_NORMAL :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " float_mean " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " standard_derivation " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL :
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " half_life_time " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
break ;
}
2010-05-04 07:34:46 +00:00
}
2010-05-04 00:06:13 +00:00
static void draw_actuator_scene ( uiLayout * layout , PointerRNA * ptr )
{
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
2010-05-04 22:05:41 +00:00
switch ( RNA_enum_get ( ptr , " mode " ) ) {
case ACT_SCENE_CAMERA :
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " camera " , 0 , NULL , ICON_NONE ) ;
2010-05-04 22:05:41 +00:00
break ;
case ACT_SCENE_RESTART :
break ;
default : // ACT_SCENE_SET|ACT_SCENE_ADD_FRONT|ACT_SCENE_ADD_BACK|ACT_SCENE_REMOVE|ACT_SCENE_SUSPEND|ACT_SCENE_RESUME
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " scene " , 0 , NULL , ICON_NONE ) ;
2010-05-04 22:05:41 +00:00
break ;
}
2010-05-04 00:06:13 +00:00
}
2010-05-04 07:34:46 +00:00
static void draw_actuator_shape_action ( uiLayout * layout , PointerRNA * ptr )
2010-05-04 00:06:13 +00:00
{
2010-05-08 22:11:00 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA settings_ptr ;
2010-05-04 21:31:46 +00:00
uiLayout * row ;
2012-03-24 06:38:07 +00:00
if ( ob - > type ! = OB_MESH ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Actuator only available for mesh objects " , ICON_NONE ) ;
2010-05-19 09:40:45 +00:00
return ;
}
2010-05-08 22:11:00 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " mode " , 0 , " " , ICON_NONE ) ;
2011-03-24 21:07:54 +00:00
uiItemR ( row , ptr , " action " , 0 , " " , ICON_NONE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_continue_last_frame " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2012-03-24 06:38:07 +00:00
if ( ( RNA_enum_get ( ptr , " mode " ) = = ACT_ACTION_FROM_PROP ) )
2011-02-27 18:03:19 +00:00
uiItemPointerR ( row , ptr , " property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
else {
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " frame_start " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " frame_end " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
}
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " frame_blend_in " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " priority " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemPointerR ( row , ptr , " frame_property " , & settings_ptr , " properties " , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
# ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
2011-02-27 18:03:19 +00:00
uiItemR ( row , " stride_length " , 0 , NULL , ICON_NONE ) ;
2010-05-04 21:31:46 +00:00
# endif
2010-05-04 07:34:46 +00:00
}
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
static void draw_actuator_sound ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-05-04 07:34:46 +00:00
{
2010-05-28 23:12:45 +00:00
uiLayout * row , * col ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2010-08-04 12:18:07 +00:00
uiTemplateID ( layout , C , ptr , " sound " , NULL , " SOUND_OT_open " , NULL ) ;
2012-03-06 18:40:15 +00:00
if ( ! RNA_pointer_get ( ptr , " sound " ) . data ) {
2011-02-27 18:03:19 +00:00
uiItemL ( layout , " Select a sound from the list or load a new one " , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
return ;
}
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " volume " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " pitch " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( layout , ptr , " use_sound_3d " , 0 , NULL , ICON_NONE ) ;
2010-05-28 23:12:45 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( layout , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( col , RNA_boolean_get ( ptr , " use_sound_3d " ) = = TRUE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " gain_3d_min " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " gain_3d_max " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " distance_3d_reference " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " distance_3d_max " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " rolloff_factor_3d " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " cone_outer_gain_3d " , 0 , NULL , ICON_NONE ) ;
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " cone_outer_angle_3d " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " cone_inner_angle_3d " , 0 , NULL , ICON_NONE ) ;
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_state ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-07 01:30:12 +00:00
uiLayout * split ;
2010-05-07 02:37:05 +00:00
Object * ob = ( Object * ) ptr - > id . data ;
PointerRNA settings_ptr ;
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.35 , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( split , ptr , " operation " , 0 , NULL , ICON_NONE ) ;
2010-05-07 01:30:12 +00:00
2010-08-17 16:27:10 +00:00
uiTemplateLayers ( split , ptr , " states " , & settings_ptr , " used_states " , 0 ) ;
2010-05-04 07:34:46 +00:00
}
static void draw_actuator_visibility ( uiLayout * layout , PointerRNA * ptr )
{
2010-05-04 21:31:46 +00:00
uiLayout * row ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2010-05-04 21:31:46 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , ptr , " use_visible " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " use_occlusion " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " apply_to_children " , 0 , NULL , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
}
2010-05-31 22:35:22 +00:00
static void draw_actuator_steering ( uiLayout * layout , PointerRNA * ptr )
{
uiLayout * row ;
2010-09-03 19:56:22 +00:00
uiLayout * col ;
2010-05-31 22:35:22 +00:00
2012-09-04 18:47:08 +00:00
uiItemR ( layout , ptr , " mode " , 0 , NULL , ICON_NONE ) ;
uiItemR ( layout , ptr , " target " , 0 , NULL , ICON_NONE ) ;
uiItemR ( layout , ptr , " navmesh " , 0 , NULL , ICON_NONE ) ;
2010-05-31 22:35:22 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2012-09-04 18:47:08 +00:00
uiItemR ( row , ptr , " distance " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " velocity " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2012-09-04 18:47:08 +00:00
uiItemR ( row , ptr , " acceleration " , 0 , NULL , ICON_NONE ) ;
uiItemR ( row , ptr , " turn_speed " , 0 , NULL , ICON_NONE ) ;
2011-02-16 17:07:18 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
col = uiLayoutColumn ( row , FALSE ) ;
2012-09-04 18:47:08 +00:00
uiItemR ( col , ptr , " facing " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , FALSE ) ;
2012-09-04 18:47:08 +00:00
uiItemR ( col , ptr , " facing_axis " , 0 , NULL , ICON_NONE ) ;
2012-03-06 18:40:15 +00:00
if ( ! RNA_boolean_get ( ptr , " facing " ) ) {
2012-06-19 23:08:16 +00:00
uiLayoutSetActive ( col , FALSE ) ;
2010-08-15 17:40:57 +00:00
}
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( row , FALSE ) ;
2012-09-04 18:47:08 +00:00
uiItemR ( col , ptr , " normal_up " , 0 , NULL , ICON_NONE ) ;
2012-03-06 18:40:15 +00:00
if ( ! RNA_pointer_get ( ptr , " navmesh " ) . data ) {
2012-06-19 23:08:16 +00:00
uiLayoutSetActive ( col , FALSE ) ;
2010-08-15 12:58:13 +00:00
}
2010-09-03 19:56:22 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2012-09-04 18:47:08 +00:00
uiItemR ( row , ptr , " self_terminated " , 0 , NULL , ICON_NONE ) ;
2012-03-06 18:40:15 +00:00
if ( RNA_enum_get ( ptr , " mode " ) = = ACT_STEERING_PATHFOLLOWING ) {
2012-09-04 18:47:08 +00:00
uiItemR ( row , ptr , " update_period " , 0 , NULL , ICON_NONE ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , FALSE ) ;
2010-07-15 18:41:29 +00:00
}
2012-09-04 18:47:08 +00:00
uiItemR ( row , ptr , " show_visualization " , 0 , NULL , ICON_NONE ) ;
2010-05-31 22:35:22 +00:00
}
2011-02-14 17:55:27 +00:00
static void draw_brick_actuator ( uiLayout * layout , PointerRNA * ptr , bContext * C )
2010-05-04 00:06:13 +00:00
{
uiLayout * box ;
2010-08-17 16:27:10 +00:00
if ( ! RNA_boolean_get ( ptr , " show_expanded " ) )
2010-05-04 00:06:13 +00:00
return ;
box = uiLayoutBox ( layout ) ;
switch ( RNA_enum_get ( ptr , " type " ) ) {
2010-05-04 07:34:46 +00:00
case ACT_ACTION :
draw_actuator_action ( box , ptr ) ;
break ;
case ACT_ARMATURE :
draw_actuator_armature ( box , ptr ) ;
break ;
case ACT_CAMERA :
draw_actuator_camera ( box , ptr ) ;
break ;
case ACT_CONSTRAINT :
2010-06-03 08:26:47 +00:00
draw_actuator_constraint ( box , ptr , C ) ;
2010-05-04 07:34:46 +00:00
break ;
case ACT_EDIT_OBJECT :
draw_actuator_edit_object ( box , ptr ) ;
break ;
case ACT_2DFILTER :
draw_actuator_filter_2d ( box , ptr ) ;
break ;
case ACT_GAME :
draw_actuator_game ( box , ptr ) ;
break ;
case ACT_MESSAGE :
2010-06-03 08:26:47 +00:00
draw_actuator_message ( box , ptr , C ) ;
2010-05-04 07:34:46 +00:00
break ;
case ACT_OBJECT :
draw_actuator_motion ( box , ptr ) ;
break ;
2010-05-04 00:06:13 +00:00
case ACT_PARENT :
draw_actuator_parent ( box , ptr ) ;
break ;
2010-05-04 07:34:46 +00:00
case ACT_PROPERTY :
draw_actuator_property ( box , ptr ) ;
break ;
case ACT_RANDOM :
draw_actuator_random ( box , ptr ) ;
break ;
2010-05-04 00:06:13 +00:00
case ACT_SCENE :
draw_actuator_scene ( box , ptr ) ;
break ;
2010-05-04 07:34:46 +00:00
case ACT_SHAPEACTION :
draw_actuator_shape_action ( box , ptr ) ;
break ;
case ACT_SOUND :
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
draw_actuator_sound ( box , ptr , C ) ;
2010-05-04 07:34:46 +00:00
break ;
case ACT_STATE :
draw_actuator_state ( box , ptr ) ;
break ;
case ACT_VISIBILITY :
draw_actuator_visibility ( box , ptr ) ;
break ;
2010-05-31 22:35:22 +00:00
case ACT_STEERING :
draw_actuator_steering ( box , ptr ) ;
2010-04-29 07:01:48 +00:00
}
}
2009-06-17 11:01:05 +00:00
2012-09-21 05:19:06 +00:00
void logic_buttons ( bContext * C , ARegion * ar )
2009-06-17 11:01:05 +00:00
{
2009-07-28 16:33:02 +00:00
SpaceLogic * slogic = CTX_wm_space_logic ( C ) ;
2009-06-17 11:01:05 +00:00
Object * ob = CTX_data_active_object ( C ) ;
ID * * idar ;
2010-05-05 00:12:31 +00:00
2012-09-21 04:12:55 +00:00
PointerRNA logic_ptr , settings_ptr , object_ptr ;
2010-05-05 00:12:31 +00:00
2010-06-21 17:37:50 +00:00
uiLayout * layout , * row , * box ;
2009-06-17 11:01:05 +00:00
uiBlock * block ;
uiBut * but ;
2012-01-11 09:33:44 +00:00
char uiblockstr [ 32 ] ;
2010-05-05 00:12:31 +00:00
short a , count ;
int xco , yco , width ;
2012-03-24 06:38:07 +00:00
if ( ob = = NULL ) return ;
2010-05-05 00:12:31 +00:00
RNA_pointer_create ( NULL , & RNA_SpaceLogicEditor , slogic , & logic_ptr ) ;
idar = get_selected_and_linked_obs ( C , & count , slogic - > scaflag ) ;
2012-01-11 12:33:51 +00:00
BLI_snprintf ( uiblockstr , sizeof ( uiblockstr ) , " buttonswin %p " , ( void * ) ar ) ;
2012-01-11 09:33:44 +00:00
block = uiBeginBlock ( C , ar , uiblockstr , UI_EMBOSS ) ;
2009-06-17 11:01:05 +00:00
uiBlockSetHandleFunc ( block , do_logic_buts , NULL ) ;
2010-04-29 07:01:48 +00:00
2010-06-21 07:51:40 +00:00
/* loop over all objects and set visible/linked flags for the logic bricks */
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2010-05-05 00:12:31 +00:00
bActuator * act ;
bSensor * sens ;
2010-06-21 07:51:40 +00:00
bController * cont ;
int iact ;
short flag ;
2009-06-17 11:01:05 +00:00
ob = ( Object * ) idar [ a ] ;
2010-05-05 00:12:31 +00:00
2010-06-21 07:51:40 +00:00
/* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that we can determine which is actually linked/visible */
2010-05-05 00:12:31 +00:00
act = ob - > actuators . first ;
2012-03-24 07:52:14 +00:00
while ( act ) {
2009-06-17 11:01:05 +00:00
act - > flag & = ~ ( ACT_LINKED | ACT_VISIBLE ) ;
act = act - > next ;
}
/* same for sensors */
sens = ob - > sensors . first ;
2012-03-24 07:52:14 +00:00
while ( sens ) {
2009-06-17 11:01:05 +00:00
sens - > flag & = ~ ( SENS_VISIBLE ) ;
sens = sens - > next ;
}
2010-06-21 07:51:40 +00:00
/* mark the linked and visible actuators */
cont = ob - > controllers . first ;
2012-03-24 07:52:14 +00:00
while ( cont ) {
2010-06-21 07:51:40 +00:00
flag = ACT_LINKED ;
/* this controller is visible, mark all its actuator */
if ( ( ob - > scaflag & OB_ALLSTATE ) | | ( ob - > state & cont - > state_mask ) )
flag | = ACT_VISIBLE ;
for ( iact = 0 ; iact < cont - > totlinks ; iact + + ) {
act = cont - > links [ iact ] ;
if ( act )
act - > flag | = flag ;
}
cont = cont - > next ;
}
2009-06-17 11:01:05 +00:00
}
2010-05-04 00:06:13 +00:00
2010-05-05 00:12:31 +00:00
/* ****************** Controllers ****************** */
xco = 420 ; yco = 170 ; width = 300 ;
2011-07-16 18:28:24 +00:00
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , xco , yco , width , 20 , UI_GetStyle ( ) ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2010-05-04 00:06:13 +00:00
2010-06-24 04:52:28 +00:00
uiDefBlockBut ( block , controller_menu , NULL , " Controllers " , xco - 10 , yco , 300 , UI_UNIT_Y , " " ) ; /* replace this with uiLayout stuff later */
2010-05-04 00:06:13 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , & logic_ptr , " show_controllers_selected_objects " , 0 , " Sel " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_controllers_active_object " , 0 , " Act " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_controllers_linked_controller " , 0 , " Link " , ICON_NONE ) ;
2010-05-04 00:06:13 +00:00
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2010-05-05 00:12:31 +00:00
bController * cont ;
2010-05-04 00:06:13 +00:00
PointerRNA ptr ;
2010-05-05 00:12:31 +00:00
uiLayout * split , * subsplit , * col ;
2010-06-27 21:03:39 +00:00
2010-05-05 00:12:31 +00:00
2010-05-04 00:06:13 +00:00
ob = ( Object * ) idar [ a ] ;
2010-06-24 04:52:28 +00:00
2010-08-17 16:27:10 +00:00
/* only draw the controller common header if "use_visible" */
2012-09-09 00:00:21 +00:00
if ( ( ob - > scavisflag & OB_VIS_CONT ) = = 0 ) {
continue ;
}
2010-06-16 06:20:56 +00:00
/* Drawing the Controller Header common to all Selected Objects */
RNA_pointer_create ( ( ID * ) ob , & RNA_GameObjectSettings , ob , & settings_ptr ) ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.05f , FALSE ) ;
2010-06-16 06:20:56 +00:00
uiItemR ( split , & settings_ptr , " show_state_panel " , UI_ITEM_R_NO_BG , " " , ICON_DISCLOSURE_TRI_RIGHT ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( split , TRUE ) ;
2012-04-29 15:47:02 +00:00
uiDefButBitS ( block , TOG , OB_SHOWCONT , B_REDR , ob - > id . name + 2 , ( short ) ( xco - 10 ) , yco , ( short ) ( width - 30 ) , UI_UNIT_Y , & ob - > scaflag , 0 , 31 , 0 , 0 , " Object name, click to show/hide controllers " ) ;
2012-09-21 04:12:55 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_Object , ob , & object_ptr ) ;
uiLayoutSetContextPointer ( row , " object " , & object_ptr ) ;
uiItemMenuEnumO ( row , " LOGIC_OT_controller_add " , " type " , " Add Controller " , ICON_NONE ) ;
2010-06-16 06:20:56 +00:00
if ( RNA_boolean_get ( & settings_ptr , " show_state_panel " ) ) {
2012-06-19 23:08:16 +00:00
box = uiLayoutBox ( layout ) ;
split = uiLayoutSplit ( box , 0.2f , FALSE ) ;
2010-06-16 06:20:56 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( split , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemL ( col , " Visible " , ICON_NONE ) ;
uiItemL ( col , " Initial " , ICON_NONE ) ;
2010-06-16 06:20:56 +00:00
2012-06-19 23:08:16 +00:00
subsplit = uiLayoutSplit ( split , 0.85f , FALSE ) ;
col = uiLayoutColumn ( subsplit , FALSE ) ;
row = uiLayoutRow ( col , FALSE ) ;
2012-05-19 13:28:19 +00:00
uiLayoutSetActive ( row , RNA_boolean_get ( & settings_ptr , " use_all_states " ) = = FALSE ) ;
2012-09-21 04:09:09 +00:00
uiTemplateGameStates ( row , & settings_ptr , " states_visible " , & settings_ptr , " used_states " , 0 ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( col , FALSE ) ;
2012-09-21 04:09:09 +00:00
uiTemplateGameStates ( row , & settings_ptr , " states_initial " , & settings_ptr , " used_states " , 0 ) ;
2010-06-16 06:20:56 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( subsplit , FALSE ) ;
2011-02-27 18:03:19 +00:00
uiItemR ( col , & settings_ptr , " use_all_states " , UI_ITEM_R_TOGGLE , NULL , ICON_NONE ) ;
uiItemR ( col , & settings_ptr , " show_debug_state " , 0 , " " , ICON_NONE ) ;
2010-06-16 06:20:56 +00:00
}
/* End of Drawing the Controller Header common to all Selected Objects */
2010-06-24 04:52:28 +00:00
if ( ( ob - > scaflag & OB_SHOWCONT ) = = 0 ) continue ;
2010-05-04 00:06:13 +00:00
2010-06-16 06:20:56 +00:00
2010-05-04 00:06:13 +00:00
uiItemS ( layout ) ;
2012-03-24 06:38:07 +00:00
for ( cont = ob - > controllers . first ; cont ; cont = cont - > next ) {
2010-05-07 02:01:50 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_Controller , cont , & ptr ) ;
2010-05-05 00:12:31 +00:00
2010-05-14 10:45:50 +00:00
if ( ! ( ob - > scaflag & OB_ALLSTATE ) & & ! ( ob - > state & cont - > state_mask ) )
2010-05-05 00:12:31 +00:00
continue ;
2010-05-04 00:06:13 +00:00
2010-05-05 00:12:31 +00:00
/* use two nested splits to align inlinks/links properly */
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.05f , FALSE ) ;
2010-05-05 00:12:31 +00:00
/* put inlink button to the left */
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( split , FALSE ) ;
2010-05-05 00:12:31 +00:00
uiLayoutSetAlignment ( col , UI_LAYOUT_ALIGN_LEFT ) ;
uiDefIconBut ( block , INLINK , 0 , ICON_INLINK , 0 , 0 , UI_UNIT_X , UI_UNIT_Y , cont , LINK_CONTROLLER , 0 , 0 , 0 , " " ) ;
2012-06-19 23:08:16 +00:00
//col = uiLayoutColumn(split, TRUE);
2010-05-05 00:12:31 +00:00
/* nested split for middle and right columns */
2012-06-19 23:08:16 +00:00
subsplit = uiLayoutSplit ( split , 0.95f , FALSE ) ;
2010-05-05 00:12:31 +00:00
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( subsplit , TRUE ) ;
2010-05-04 00:06:13 +00:00
uiLayoutSetContextPointer ( col , " controller " , & ptr ) ;
/* should make UI template for controller header.. function will do for now */
2010-07-13 11:06:19 +00:00
// draw_controller_header(col, &ptr);
draw_controller_header ( col , & ptr , xco , width , yco ) ; //provisory for 2.50 beta
2010-05-04 00:06:13 +00:00
/* draw the brick contents */
draw_brick_controller ( col , & ptr ) ;
2010-05-05 00:12:31 +00:00
2010-05-04 00:06:13 +00:00
/* put link button to the right */
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( subsplit , FALSE ) ;
2010-05-05 00:12:31 +00:00
uiLayoutSetAlignment ( col , UI_LAYOUT_ALIGN_LEFT ) ;
2012-03-24 02:51:46 +00:00
but = uiDefIconBut ( block , LINK , 0 , ICON_LINK , 0 , 0 , UI_UNIT_X , UI_UNIT_Y , NULL , 0 , 0 , 0 , 0 , " " ) ;
2010-05-04 00:06:13 +00:00
uiSetButLink ( but , NULL , ( void * * * ) & ( cont - > links ) , & cont - > totlinks , LINK_CONTROLLER , LINK_ACTUATOR ) ;
}
}
uiBlockLayoutResolve ( block , NULL , & yco ) ; /* stores final height in yco */
2010-05-05 00:12:31 +00:00
/* ****************** Sensors ****************** */
xco = 10 ; yco = 170 ; width = 340 ;
2011-07-16 18:28:24 +00:00
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , xco , yco , width , 20 , UI_GetStyle ( ) ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2010-05-05 00:12:31 +00:00
2010-06-24 04:52:28 +00:00
uiDefBlockBut ( block , sensor_menu , NULL , " Sensors " , xco - 10 , yco , 300 , UI_UNIT_Y , " " ) ; /* replace this with uiLayout stuff later */
2010-05-05 00:12:31 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , & logic_ptr , " show_sensors_selected_objects " , 0 , " Sel " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_sensors_active_object " , 0 , " Act " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_sensors_linked_controller " , 0 , " Link " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_sensors_active_states " , 0 , " State " , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2010-05-05 00:12:31 +00:00
bSensor * sens ;
PointerRNA ptr ;
ob = ( Object * ) idar [ a ] ;
2010-06-16 06:20:56 +00:00
2010-08-17 16:27:10 +00:00
/* only draw the sensor common header if "use_visible" */
2012-03-24 06:38:07 +00:00
if ( ( ob - > scavisflag & OB_VIS_SENS ) = = 0 ) continue ;
2010-06-24 04:52:28 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2012-04-29 15:47:02 +00:00
uiDefButBitS ( block , TOG , OB_SHOWSENS , B_REDR , ob - > id . name + 2 , ( short ) ( xco - 10 ) , yco , ( short ) ( width - 30 ) , UI_UNIT_Y , & ob - > scaflag , 0 , 31 , 0 , 0 , " Object name, click to show/hide sensors " ) ;
2012-09-21 04:12:55 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_Object , ob , & object_ptr ) ;
uiLayoutSetContextPointer ( row , " object " , & object_ptr ) ;
uiItemMenuEnumO ( row , " LOGIC_OT_sensor_add " , " type " , " Add Sensor " , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2010-06-24 04:52:28 +00:00
if ( ( ob - > scaflag & OB_SHOWSENS ) = = 0 ) continue ;
2010-05-05 00:12:31 +00:00
uiItemS ( layout ) ;
2012-03-24 06:38:07 +00:00
for ( sens = ob - > sensors . first ; sens ; sens = sens - > next ) {
2010-05-07 02:01:50 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_Sensor , sens , & ptr ) ;
2010-05-05 00:12:31 +00:00
2010-05-14 10:45:50 +00:00
if ( ( ob - > scaflag & OB_ALLSTATE ) | |
2010-06-21 07:51:40 +00:00
! ( slogic - > scaflag & BUTS_SENS_STATE ) | |
2010-05-05 00:12:31 +00:00
( sens - > totlinks = = 0 ) | | /* always display sensor without links so that is can be edited */
( sens - > flag & SENS_PIN & & slogic - > scaflag & BUTS_SENS_STATE ) | | /* states can hide some sensors, pinned sensors ignore the visible state */
( is_sensor_linked ( block , sens ) )
)
{ // gotta check if the current state is visible or not
uiLayout * split , * col ;
2010-07-08 09:25:18 +00:00
/* make as visible, for move operator */
sens - > flag | = SENS_VISIBLE ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.95f , FALSE ) ;
col = uiLayoutColumn ( split , TRUE ) ;
2010-05-05 00:12:31 +00:00
uiLayoutSetContextPointer ( col , " sensor " , & ptr ) ;
/* should make UI template for sensor header.. function will do for now */
2010-06-21 07:51:40 +00:00
draw_sensor_header ( col , & ptr , & logic_ptr ) ;
2010-05-05 00:12:31 +00:00
/* draw the brick contents */
2010-06-03 08:26:47 +00:00
draw_brick_sensor ( col , & ptr , C ) ;
2010-05-05 00:12:31 +00:00
/* put link button to the right */
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( split , FALSE ) ;
2012-03-04 04:35:12 +00:00
/* use old-school uiButtons for links for now */
2012-03-24 02:51:46 +00:00
but = uiDefIconBut ( block , LINK , 0 , ICON_LINK , 0 , 0 , UI_UNIT_X , UI_UNIT_Y , NULL , 0 , 0 , 0 , 0 , " " ) ;
2010-05-05 00:12:31 +00:00
uiSetButLink ( but , NULL , ( void * * * ) & ( sens - > links ) , & sens - > totlinks , LINK_SENSOR , LINK_CONTROLLER ) ;
}
}
}
uiBlockLayoutResolve ( block , NULL , & yco ) ; /* stores final height in yco */
/* ****************** Actuators ****************** */
xco = 800 ; yco = 170 ; width = 340 ;
2011-07-16 18:28:24 +00:00
layout = uiBlockLayout ( block , UI_LAYOUT_VERTICAL , UI_LAYOUT_PANEL , xco , yco , width , 20 , UI_GetStyle ( ) ) ;
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2010-05-05 00:12:31 +00:00
2010-06-24 04:52:28 +00:00
uiDefBlockBut ( block , actuator_menu , NULL , " Actuators " , xco - 10 , yco , 300 , UI_UNIT_Y , " " ) ; /* replace this with uiLayout stuff later */
2010-05-05 00:12:31 +00:00
2011-02-27 18:03:19 +00:00
uiItemR ( row , & logic_ptr , " show_actuators_selected_objects " , 0 , " Sel " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_actuators_active_object " , 0 , " Act " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_actuators_linked_controller " , 0 , " Link " , ICON_NONE ) ;
uiItemR ( row , & logic_ptr , " show_actuators_active_states " , 0 , " State " , ICON_NONE ) ;
2010-05-05 00:12:31 +00:00
2012-03-24 06:38:07 +00:00
for ( a = 0 ; a < count ; a + + ) {
2010-05-05 00:12:31 +00:00
bActuator * act ;
PointerRNA ptr ;
ob = ( Object * ) idar [ a ] ;
2010-06-16 06:20:56 +00:00
2010-08-17 16:27:10 +00:00
/* only draw the actuator common header if "use_visible" */
2012-09-09 00:00:21 +00:00
if ( ( ob - > scavisflag & OB_VIS_ACT ) = = 0 ) {
continue ;
}
2010-06-24 04:52:28 +00:00
2012-06-19 23:08:16 +00:00
row = uiLayoutRow ( layout , TRUE ) ;
2012-04-29 15:47:02 +00:00
uiDefButBitS ( block , TOG , OB_SHOWACT , B_REDR , ob - > id . name + 2 , ( short ) ( xco - 10 ) , yco , ( short ) ( width - 30 ) , UI_UNIT_Y , & ob - > scaflag , 0 , 31 , 0 , 0 , " Object name, click to show/hide actuators " ) ;
2012-09-21 04:12:55 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_Object , ob , & object_ptr ) ;
uiLayoutSetContextPointer ( row , " object " , & object_ptr ) ;
uiItemMenuEnumO ( row , " LOGIC_OT_actuator_add " , " type " , " Add Actuator " , ICON_NONE ) ;
2010-06-16 06:20:56 +00:00
2010-06-24 04:52:28 +00:00
if ( ( ob - > scaflag & OB_SHOWACT ) = = 0 ) continue ;
2010-05-05 00:12:31 +00:00
uiItemS ( layout ) ;
2012-03-24 06:38:07 +00:00
for ( act = ob - > actuators . first ; act ; act = act - > next ) {
2010-05-05 00:12:31 +00:00
2010-05-07 02:01:50 +00:00
RNA_pointer_create ( ( ID * ) ob , & RNA_Actuator , act , & ptr ) ;
2010-05-05 00:12:31 +00:00
2010-05-14 10:45:50 +00:00
if ( ( ob - > scaflag & OB_ALLSTATE ) | |
2010-06-21 07:51:40 +00:00
! ( slogic - > scaflag & BUTS_ACT_STATE ) | |
2010-05-05 00:12:31 +00:00
! ( act - > flag & ACT_LINKED ) | | /* always display actuators without links so that is can be edited */
( act - > flag & ACT_VISIBLE ) | | /* this actuator has visible connection, display it */
( act - > flag & ACT_PIN & & slogic - > scaflag & BUTS_ACT_STATE ) /* states can hide some sensors, pinned sensors ignore the visible state */
)
{ // gotta check if the current state is visible or not
uiLayout * split , * col ;
2010-07-08 09:25:18 +00:00
/* make as visible, for move operator */
act - > flag | = ACT_VISIBLE ;
2012-06-19 23:08:16 +00:00
split = uiLayoutSplit ( layout , 0.05f , FALSE ) ;
2010-05-05 00:12:31 +00:00
/* put inlink button to the left */
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( split , FALSE ) ;
2010-05-05 00:12:31 +00:00
uiDefIconBut ( block , INLINK , 0 , ICON_INLINK , 0 , 0 , UI_UNIT_X , UI_UNIT_Y , act , LINK_ACTUATOR , 0 , 0 , 0 , " " ) ;
2012-06-19 23:08:16 +00:00
col = uiLayoutColumn ( split , TRUE ) ;
2010-05-05 00:12:31 +00:00
uiLayoutSetContextPointer ( col , " actuator " , & ptr ) ;
/* should make UI template for actuator header.. function will do for now */
2010-06-21 07:51:40 +00:00
draw_actuator_header ( col , & ptr , & logic_ptr ) ;
2010-05-05 00:12:31 +00:00
/* draw the brick contents */
Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50%
Notes:
1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator
uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL);
According to Campbell they are better ways to do that (mdef bind for reference). but for now it works.
2) for the record: action actuator is equal to shape actuator (but runs in armature)
3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one.
2010-05-06 12:01:44 +00:00
draw_brick_actuator ( col , & ptr , C ) ;
2010-05-05 00:12:31 +00:00
}
}
}
uiBlockLayoutResolve ( block , NULL , & yco ) ; /* stores final height in yco */
uiComposeLinks ( block ) ;
uiEndBlock ( C , block ) ;
uiDrawBlock ( C , block ) ;
2012-03-24 06:38:07 +00:00
if ( idar ) MEM_freeN ( idar ) ;
2010-05-05 00:12:31 +00:00
}
2010-05-04 00:06:13 +00:00