Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2010-05-16 20:28:50 +0400
committerDalai Felinto <dfelinto@gmail.com>2010-05-16 20:28:50 +0400
commitce6e6112eb81892c8c179c8502ffa8ca17b57f46 (patch)
treea186a028663f6c75f61b0ae0187096431ba9657a /source/blender/editors/space_logic/logic_ops.c
parent80de1162ee31acfe49209552549d918d44dffab1 (diff)
Logic UI: copy logic operator (old Ctrl+C) + add logics (shift+a)
According to Matt the RMB->Copy to selected wouldn't work for logics because the copy we need is for the whole logic (s/c/a). So (at least for the time been), copy logic is possible again. It work as 2.49 (replacing the existent logic). Add Logics is a python menu to give quick access to add logics. I have to see how to put that in Add Menu. I should be easy, but I'll leave it for later.
Diffstat (limited to 'source/blender/editors/space_logic/logic_ops.c')
-rw-r--r--source/blender/editors/space_logic/logic_ops.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index 632331459cb..347b586f49c 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -533,6 +533,48 @@ void LOGIC_OT_actuator_add(wmOperatorType *ot)
prop= RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Actuator to add");
}
+/* Copy Routines */
+
+static int logicbricks_copy_exec(bContext *C, wmOperator *op)
+{
+ Object *ob=ED_object_active_context(C);
+
+ CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
+ if(ob != ob_iter) {
+ if (ob->data != ob_iter->data){
+ copy_sensors(&ob_iter->sensors, &ob->sensors);
+ copy_controllers(&ob_iter->controllers, &ob->controllers);
+ copy_actuators(&ob_iter->actuators, &ob->actuators);
+ }
+
+ if(ob_iter->totcol==ob->totcol) {
+ ob_iter->actcol= ob->actcol;
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter);
+ }
+ }
+ }
+ CTX_DATA_END;
+
+ WM_event_add_notifier(C, NC_LOGIC, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void LOGIC_OT_bricks_copy(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Copy Logic Bricks to Selected";
+ ot->description = "Copy logic bricks to other selected objects.";
+ ot->idname= "LOGIC_OT_bricks_copy";
+
+ /* api callbacks */
+ ot->exec= logicbricks_copy_exec;
+ ot->poll= ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
void ED_operatortypes_logic(void)
{
WM_operatortype_append(LOGIC_OT_sensor_remove);
@@ -541,4 +583,5 @@ void ED_operatortypes_logic(void)
WM_operatortype_append(LOGIC_OT_controller_add);
WM_operatortype_append(LOGIC_OT_actuator_remove);
WM_operatortype_append(LOGIC_OT_actuator_add);
+ WM_operatortype_append(LOGIC_OT_bricks_copy);
}