forked from bartvdbraak/blender
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.
This commit is contained in:
parent
80de1162ee
commit
ce6e6112eb
@ -46,9 +46,18 @@ class LOGIC_PT_properties(bpy.types.Panel):
|
||||
row.prop(prop, "debug", text="", toggle=True, icon='INFO')
|
||||
row.operator("object.game_property_remove", text="", icon='X').index = i
|
||||
|
||||
class LOGIC_MT_logicbricks_add(bpy.types.Menu):
|
||||
bl_label = "Add"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator_menu_enum("logic.sensor_add", "type", text="Sensor")
|
||||
layout.operator_menu_enum("logic.controller_add", "type", text="Controller")
|
||||
layout.operator_menu_enum("logic.actuator_add", "type", text="Actuator")
|
||||
|
||||
classes = [
|
||||
LOGIC_PT_properties]
|
||||
LOGIC_PT_properties, LOGIC_MT_logicbricks_add]
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -1340,7 +1340,7 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
|
||||
void OBJECT_OT_constraint_copy(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Copy Constraints to Others";
|
||||
ot->name= "Copy Constraints to Selected";
|
||||
ot->description = "Copy constraints to other selected objects.";
|
||||
ot->idname= "OBJECT_OT_constraint_copy";
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ void logic_keymap(struct wmKeyConfig *keyconf)
|
||||
|
||||
WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
}
|
||||
|
||||
static void logic_refresh(const bContext *C, ScrArea *sa)
|
||||
|
Loading…
Reference in New Issue
Block a user