Blender  V2.59
rna_controller_api.c
Go to the documentation of this file.
00001 /*
00002  * $Id: rna_controller_api.c 35238 2011-02-27 20:20:01Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2010 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * 
00024  * Contributor(s):
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #include <stdlib.h>
00035 #include <stdio.h>
00036 
00037 #include "WM_types.h"
00038 #include "RNA_define.h"
00039 
00040 #ifdef RNA_RUNTIME
00041 
00042 #include "BKE_sca.h"
00043 #include "DNA_sensor_types.h"
00044 #include "DNA_controller_types.h"
00045 #include "DNA_actuator_types.h"
00046 
00047 static void rna_Controller_link(bController *cont, bSensor *sens, bActuator *act)
00048 {
00049         if(sens)
00050                 link_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks, sizeof(bController *));
00051         if(act)
00052                 link_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks, sizeof(bActuator *));
00053 }
00054 
00055 static void rna_Controller_unlink(bController *cont, bSensor *sens, bActuator *act)
00056 {
00057         if(sens)
00058                 unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks);
00059         if(act)
00060                 unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks);
00061 }
00062 
00063 #else
00064 
00065 void RNA_api_controller(StructRNA *srna)
00066 {
00067         FunctionRNA *func;
00068         PropertyRNA *parm;
00069 
00070         func= RNA_def_function(srna, "link", "rna_Controller_link");
00071         RNA_def_function_ui_description(func, "Link the controller with a sensor/actuator.");
00072         parm= RNA_def_pointer(func, "sensor", "Sensor", "", "Sensor to link the controller to."); 
00073         RNA_def_property_update(parm, NC_LOGIC, NULL);
00074         parm= RNA_def_pointer(func, "actuator", "Actuator", "", "Actuator to link the controller to."); 
00075         RNA_def_property_update(parm, NC_LOGIC, NULL);
00076 
00077         func= RNA_def_function(srna, "unlink", "rna_Controller_unlink");
00078         RNA_def_function_ui_description(func, "Unlink the controller from a sensor/actuator.");
00079         parm= RNA_def_pointer(func, "sensor", "Sensor", "", "Sensor to unlink the controller from."); 
00080         RNA_def_property_update(parm, NC_LOGIC, NULL);
00081         parm= RNA_def_pointer(func, "actuator", "Actuator", "", "Actuator to unlink the controller from."); 
00082         RNA_def_property_update(parm, NC_LOGIC, NULL);
00083 }
00084 
00085 #endif
00086