From 3b6aa5b6a588b76e1ed6f25f11ae77dd07ecfa46 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 3 Jun 2010 06:41:24 +0000 Subject: [PATCH] Logic Editor: clear properties operator + logics in the object menu clear properties operator - now it's not part of the copy properties anymore (Matt's suggestion). If anyone want to change the menu, please help yourself (renaming, putting in it's own submenu, making it invisible when mode is not Game ..) --- release/scripts/ui/space_view3d.py | 19 +++++++++- source/blender/editors/object/object_edit.c | 38 ++++++++++++++++--- source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 4a3818eae73..ba2705331a9 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -675,7 +675,11 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.menu("VIEW3D_MT_object_track") layout.menu("VIEW3D_MT_object_group") layout.menu("VIEW3D_MT_object_constraints") + + layout.separator() + layout.menu("VIEW3D_MT_object_game_properties") + layout.menu("VIEW3D_MT_object_game_logicbricks") layout.separator() @@ -853,8 +857,18 @@ class VIEW3D_MT_object_game_properties(bpy.types.Menu): layout.operator("object.game_property_copy", text="Replace").operation="REPLACE" layout.operator("object.game_property_copy", text="Merge").operation="MERGE" - # layout.operator("object.game_property_copy").operation="CLEAR" doesn't really belong as part of copy... layout.operator_menu_enum("object.game_property_copy", "property", text="Copy...") + layout.separator() + layout.operator("object.game_property_clear") + + +class VIEW3D_MT_object_game_logicbricks(bpy.types.Menu): + bl_label = "Logic Bricks" + + def draw(self, context): + layout = self.layout + + layout.operator("object.logic_bricks_copy", text="Copy") # ********** Vertex paint menu ********** @@ -2222,10 +2236,11 @@ classes = [ VIEW3D_MT_object_track, VIEW3D_MT_object_group, VIEW3D_MT_object_constraints, - VIEW3D_MT_object_game_properties, VIEW3D_MT_object_showhide, VIEW3D_MT_make_single_user, VIEW3D_MT_make_links, + VIEW3D_MT_object_game_properties, + VIEW3D_MT_object_game_logicbricks, VIEW3D_MT_hook, VIEW3D_MT_vertex_group, diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 28b9fa241ca..1127d9ab444 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2151,6 +2151,7 @@ static int game_property_new(bContext *C, wmOperator *op) BLI_addtail(&ob->prop, prop); unique_property(NULL, prop, 0); // make_unique_prop_names(prop->name); + WM_event_add_notifier(C, NC_LOGIC, NULL); return OPERATOR_FINISHED; } @@ -2183,6 +2184,8 @@ static int game_property_remove(bContext *C, wmOperator *op) if(prop) { BLI_remlink(&ob->prop, prop); free_property(prop); + + WM_event_add_notifier(C, NC_LOGIC, NULL); return OPERATOR_FINISHED; } else { @@ -2208,13 +2211,11 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot) #define COPY_PROPERTIES_REPLACE 1 #define COPY_PROPERTIES_MERGE 2 -#define COPY_PROPERTIES_CLEAR 3 -#define COPY_PROPERTIES_COPY 4 +#define COPY_PROPERTIES_COPY 3 static EnumPropertyItem game_properties_copy_operations[] ={ {COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""}, {COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""}, - {COPY_PROPERTIES_CLEAR, "CLEAR", 0, "Clear All", ""}, {COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""}, {0, NULL, 0, NULL, NULL}}; @@ -2264,7 +2265,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } } - else if (ELEM3(type, COPY_PROPERTIES_REPLACE, COPY_PROPERTIES_MERGE, COPY_PROPERTIES_CLEAR)) { + else if (ELEM(type, COPY_PROPERTIES_REPLACE, COPY_PROPERTIES_MERGE)) { CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { if (ob != ob_iter) { if (ob->data != ob_iter->data){ @@ -2272,7 +2273,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) for(prop = ob->prop.first; prop; prop= prop->next ) { set_ob_property(ob_iter, prop); } - } else /* replace or clear */ + } else /* replace */ copy_properties( &ob_iter->prop, &ob->prop ); } } @@ -2303,6 +2304,33 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) ot->prop=prop; } +static int game_property_clear_exec(bContext *C, wmOperator *op) +{ + Object *ob=ED_object_active_context(C); + bProperty *prop; + + CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { + free_properties(&ob_iter->prop); + } + CTX_DATA_END; + + WM_event_add_notifier(C, NC_LOGIC, NULL); + return OPERATOR_FINISHED; +} +void OBJECT_OT_game_property_clear(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Clear Game Property"; + ot->idname= "OBJECT_OT_game_property_clear"; + + /* api callbacks */ + ot->exec= game_property_clear_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /************************ Copy Logic Bricks ***********************/ static int logicbricks_copy_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 5b446b3a828..f82b4e0324f 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -88,6 +88,7 @@ void OBJECT_OT_paths_clear(struct wmOperatorType *ot); void OBJECT_OT_game_property_new(struct wmOperatorType *ot); void OBJECT_OT_game_property_remove(struct wmOperatorType *ot); void OBJECT_OT_game_property_copy(struct wmOperatorType *ot); +void OBJECT_OT_game_property_clear(struct wmOperatorType *ot); void OBJECT_OT_logic_bricks_copy(struct wmOperatorType *ot); /* object_select.c */ diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 602b94034bd..274e8ff2d73 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -184,6 +184,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_game_property_new); WM_operatortype_append(OBJECT_OT_game_property_remove); WM_operatortype_append(OBJECT_OT_game_property_copy); + WM_operatortype_append(OBJECT_OT_game_property_clear); WM_operatortype_append(OBJECT_OT_logic_bricks_copy); WM_operatortype_append(OBJECT_OT_shape_key_add);