TexFace to Material Settings big patch
[blender.git] / source / blender / editors / space_logic / logic_ops.c
index 60e9595b77a0faad969b69d5d7eb5d33369406b0..b7f9af093488fec67244effaec7daeaf91c3bc1d 100644 (file)
@@ -43,6 +43,7 @@
 #include "BKE_context.h"
 #include "BKE_main.h"
 #include "BKE_sca.h"
+#include "BKE_material.h" //for texface convert
 
 #include "ED_logic.h"
 #include "ED_object.h"
 
 #include "logic_intern.h"
 
+// temporary new includes for texface functions
+#include "DNA_mesh_types.h"
+#include "DNA_material_types.h"
+#include "DNA_meshdata_types.h"
+
 /* ************* Generic Operator Helpers ************* */
 static int edit_sensor_poll(bContext *C)
 {
@@ -687,6 +693,36 @@ static void LOGIC_OT_actuator_move(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
 }
 
+/* ************* TexFace Converter Operator ************* */
+static int texface_convert_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Main *bmain= CTX_data_main(C);
+       do_version_tface(bmain, 0);
+       
+       return OPERATOR_FINISHED;
+}
+
+static int texface_convert_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+       return texface_convert_exec(C, op);
+}
+
+ static void LOGIC_OT_texface_convert(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "TexFace to Material Converter";
+       ot->description = "Convert old texface settings into material. It may create new materials if needed";
+       ot->idname= "LOGIC_OT_texface_convert";
+
+       /* api callbacks */
+       ot->invoke= texface_convert_invoke;
+       ot->exec= texface_convert_exec;
+//     ot->poll= texface_convert_poll;
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 
 void ED_operatortypes_logic(void)
 {
@@ -699,4 +735,5 @@ void ED_operatortypes_logic(void)
        WM_operatortype_append(LOGIC_OT_actuator_remove);
        WM_operatortype_append(LOGIC_OT_actuator_add);
        WM_operatortype_append(LOGIC_OT_actuator_move);
+       WM_operatortype_append(LOGIC_OT_texface_convert);
 }