BGE - button for deactivate sensors, controllers and actuators
authorJorge Bernal <jbernalmartinez@gmail.com>
Thu, 17 Apr 2014 01:23:29 +0000 (22:23 -0300)
committerDalai Felinto <dfelinto@gmail.com>
Thu, 17 Apr 2014 01:40:07 +0000 (22:40 -0300)
This change introduces a new checkbox to deactivate the sensors, controllers and/or actuators. It is useful during the development phase to avoid delete sensors, controllers or actuators if you want to test something new.

NOC: The wiki page is being updated (the images mostly), but the feature is already in the 2.71 release log.

{F61628}

Reviewers: moguri, dfelinto, campbellbarton, dingto, #user_interface, billrey

Reviewed By: moguri

CC: billrey
Differential Revision: https://developer.blender.org/D16

13 files changed:
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/space_logic/logic_window.c
source/blender/makesdna/DNA_actuator_types.h
source/blender/makesdna/DNA_controller_types.h
source/blender/makesdna/DNA_sensor_types.h
source/blender/makesrna/intern/rna_actuator.c
source/blender/makesrna/intern/rna_controller.c
source/blender/makesrna/intern/rna_sensor.c
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Converter/KX_ConvertControllers.cpp
source/gameengine/Converter/KX_ConvertSensors.cpp

index 7eb39fd4b3c98a3c95eb9995c231801b9c7a8445..12efd897b5f7999bd8276c91401b837d8383de22 100644 (file)
@@ -173,6 +173,7 @@ enum {
        UI_BUT_COLOR_CUBIC   = (1 << 23),  /* cubic saturation for the color wheel */
        UI_BUT_LIST_ITEM     = (1 << 24),  /* This but is "inside" a list item (currently used to change theme colors). */
        UI_BUT_DRAG_MULTI    = (1 << 25),  /* edit this button as well as the active button (not just dragging) */
+       UI_BUT_SCA_LINK_GREY = (1 << 26),  /* used to flag if sca links shoud be grey out */
 };
 
 #define UI_PANEL_WIDTH          340
index 56222889cf27a2aaecfd0596fd684a0128c08e2e..b7e203408d2bfddd73d1de32b48c5423fa5ccb77 100644 (file)
@@ -443,7 +443,7 @@ static int ui_but_float_precision(uiBut *but, double value)
 
 /* link line drawing is not part of buttons or theme.. so we stick with it here */
 
-static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
+static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int dashInactiveLines)
 {
        rcti rect;
 
@@ -454,11 +454,13 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
        rect.xmax = BLI_rctf_cent_x(&line->to->rect);
        rect.ymax = BLI_rctf_cent_y(&line->to->rect);
        
-       if (line->flag & UI_SELECT)
+       if (dashInactiveLines)
+               UI_ThemeColor(TH_GRID);
+       else if (line->flag & UI_SELECT)
                glColor3ub(100, 100, 100);
        else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
                UI_ThemeColor(TH_TEXT_HI);
-       else 
+       else
                glColor3ub(0, 0, 0);
 
        ui_draw_link_bezier(&rect);
@@ -469,7 +471,8 @@ static void ui_draw_links(uiBlock *block)
        uiBut *but;
        uiLinkLine *line;
 
-       /* Draw the inactive lines (lines with neither button being hovered over).
+       /* Draw the grey out lines. Do this first so they appear at the
+        * bottom of inactive or active lines.
         * As we go, remember if we see any active or selected lines. */
        bool found_selectline = false;
        bool found_activeline = false;
@@ -477,8 +480,10 @@ static void ui_draw_links(uiBlock *block)
        for (but = block->buttons.first; but; but = but->next) {
                if (but->type == LINK && but->link) {
                        for (line = but->link->lines.first; line; line = line->next) {
-                               if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE))
-                                       ui_draw_linkline(line, 0);
+                               if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) {
+                                       if (line->deactive)
+                                               ui_draw_linkline(line, 0, true);
+                               }
                                else
                                        found_activeline = true;
 
@@ -488,14 +493,26 @@ static void ui_draw_links(uiBlock *block)
                }
        }
 
+       /* Draw the inactive lines (lines with neither button being hovered over) */
+       for (but = block->buttons.first; but; but = but->next) {
+               if (but->type == LINK && but->link) {
+                       for (line = but->link->lines.first; line; line = line->next) {
+                               if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) {
+                                       if (!line->deactive)
+                                               ui_draw_linkline(line, 0, false);
+                               }
+                       }
+               }
+       }
+
        /* Draw any active lines (lines with either button being hovered over).
-        * Do this last so they appear on top of inactive lines. */
+        * Do this last so they appear on top of inactive and grey out lines. */
        if (found_activeline) {
                for (but = block->buttons.first; but; but = but->next) {
                        if (but->type == LINK && but->link) {
                                for (line = but->link->lines.first; line; line = line->next) {
                                        if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))
-                                               ui_draw_linkline(line, !found_selectline);
+                                               ui_draw_linkline(line, !found_selectline, false);
                                }
                        }
                }
@@ -1348,7 +1365,7 @@ static uiBut *ui_find_inlink(uiBlock *block, void *poin)
        return NULL;
 }
 
-static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt)
+static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt, short deactive)
 {
        uiLinkLine *line;
        
@@ -1356,6 +1373,7 @@ static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt)
        BLI_addtail(listb, line);
        line->from = but;
        line->to = bt;
+       line->deactive = deactive;
 }
 
 uiBut *uiFindInlink(uiBlock *block, void *poin)
@@ -1382,14 +1400,25 @@ void uiComposeLinks(uiBlock *block)
                                        for (a = 0; a < *(link->totlink); a++) {
                                                bt = ui_find_inlink(block, (*ppoin)[a]);
                                                if (bt) {
-                                                       ui_add_link_line(&link->lines, but, bt);
+                                                       if ((but->flag & UI_BUT_SCA_LINK_GREY) || (bt->flag & UI_BUT_SCA_LINK_GREY)){
+                                                               ui_add_link_line(&link->lines, but, bt, true);
+                                                       }
+                                                       else {
+                                                               ui_add_link_line(&link->lines, but, bt, false);
+                                                       }
+
                                                }
                                        }
                                }
                                else if (link->poin) {
                                        bt = ui_find_inlink(block, *(link->poin) );
                                        if (bt) {
-                                               ui_add_link_line(&link->lines, but, bt);
+                                               if ((but->flag & UI_BUT_SCA_LINK_GREY) || (bt->flag & UI_BUT_SCA_LINK_GREY)){
+                                                       ui_add_link_line(&link->lines, but, bt, true);
+                                               }
+                                               else {
+                                                       ui_add_link_line(&link->lines, but, bt, false);
+                                               }
                                        }
                                }
                        }
index ab9ea75e5d8fc05091b65f8c8ec0e8a1c620f3b6..48fadee92117998acbe4490156ec74a57beb7a1e 100644 (file)
@@ -147,7 +147,7 @@ enum {
 typedef struct uiLinkLine {  /* only for draw/edit */
        struct uiLinkLine *next, *prev;
        struct uiBut *from, *to;
-       short flag, pad;
+       short flag, deactive;
 } uiLinkLine;
 
 typedef struct {
index acf5d6a2f5573540720c56ee8371a07dab103eff..70837002979f04c392e29876107a01d44960786f 100644 (file)
@@ -945,28 +945,37 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo
        box = uiLayoutBox(layout);
        row = uiLayoutRow(box, false);
        
-       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
        if (RNA_boolean_get(ptr, "show_expanded")) {
-               uiItemR(row, ptr, "type", 0, "", ICON_NONE);
-               uiItemR(row, ptr, "name", 0, "", ICON_NONE);
+               uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
+               uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
        }
        else {
-               uiItemL(row, IFACE_(sensor_name(sens->type)), ICON_NONE);
-               uiItemL(row, sens->name, ICON_NONE);
+               uiItemL(sub, IFACE_(sensor_name(sens->type)), ICON_NONE);
+               uiItemL(sub, sens->name, ICON_NONE);
        }
 
        sub = uiLayoutRow(row, false);
-       uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") &&
-                                RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")));
+       uiLayoutSetActive(sub, (((RNA_boolean_get(logic_ptr, "show_sensors_active_states") &&
+                                RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")) &&
+                                                RNA_boolean_get(ptr, "active")));
        uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
 
        if (RNA_boolean_get(ptr, "show_expanded")==0) {
                sub = uiLayoutRow(row, true);
+               uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
                uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up
                uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down
        }
 
-       uiItemO(row, "", ICON_X, "LOGIC_OT_sensor_remove");
+       sub = uiLayoutRow(row, false);
+       uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
+
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemO(sub, "", ICON_X, "LOGIC_OT_sensor_remove");
 }
 
 static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
@@ -974,6 +983,7 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
        uiLayout *box, *split, *sub, *row;
 
        box = uiLayoutBox(layout);
+       uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
        split = uiLayoutSplit(box, 0.45f, false);
        
        row = uiLayoutRow(split, true);
@@ -1241,6 +1251,7 @@ static void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C)
        draw_sensor_internal_header(layout, ptr);
        
        box = uiLayoutBox(layout);
+       uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
 
        switch (RNA_enum_get(ptr, "type")) {
 
@@ -1300,27 +1311,38 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i
        box = uiLayoutBox(layout);
        row = uiLayoutRow(box, false);
        
-       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
        if (RNA_boolean_get(ptr, "show_expanded")) {
-               uiItemR(row, ptr, "type", 0, "", ICON_NONE);
-               uiItemR(row, ptr, "name", 0, "", ICON_NONE);
+               uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
+               uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
                /* XXX provisory for Blender 2.50Beta */
                uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, IFACE_("Set controller state index (from 1 to 30)"));
        }
        else {
-               uiItemL(row, IFACE_(controller_name(cont->type)), ICON_NONE);
-               uiItemL(row, cont->name, ICON_NONE);
-               uiItemL(row, state, ICON_NONE);
+               uiItemL(sub, IFACE_(controller_name(cont->type)), ICON_NONE);
+               uiItemL(sub, cont->name, ICON_NONE);
+               uiItemL(sub, state, ICON_NONE);
        }
 
-       uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE);
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemR(sub, ptr, "use_priority", 0, "", ICON_NONE);
 
        if (RNA_boolean_get(ptr, "show_expanded")==0) {
                sub = uiLayoutRow(row, true);
+               uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
                uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up
                uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down
        }
-       uiItemO(row, "", ICON_X, "LOGIC_OT_controller_remove");
+
+       sub = uiLayoutRow(row, false);
+       uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
+
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemO(sub, "", ICON_X, "LOGIC_OT_controller_remove");
 }
 
 static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr)
@@ -1357,6 +1379,7 @@ static void draw_brick_controller(uiLayout *layout, PointerRNA *ptr)
                return;
        
        box = uiLayoutBox(layout);
+       uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
 
        draw_controller_state(box, ptr);
        
@@ -1390,28 +1413,38 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *
        
        box = uiLayoutBox(layout);
        row = uiLayoutRow(box, false);
-       
-       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
+
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
        if (RNA_boolean_get(ptr, "show_expanded")) {
-               uiItemR(row, ptr, "type", 0, "", ICON_NONE);
-               uiItemR(row, ptr, "name", 0, "", ICON_NONE);
+               uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
+               uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
        }
        else {
-               uiItemL(row, IFACE_(actuator_name(act->type)), ICON_NONE);
-               uiItemL(row, act->name, ICON_NONE);
+               uiItemL(sub, IFACE_(actuator_name(act->type)), ICON_NONE);
+               uiItemL(sub, act->name, ICON_NONE);
        }
 
        sub = uiLayoutRow(row, false);
-       uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") &&
-                                RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")));
+       uiLayoutSetActive(sub, (((RNA_boolean_get(logic_ptr, "show_actuators_active_states") &&
+                                 RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")) &&
+                                 RNA_boolean_get(ptr, "active")));
        uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
 
        if (RNA_boolean_get(ptr, "show_expanded")==0) {
                sub = uiLayoutRow(row, true);
+               uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
                uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up
                uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down
        }
-       uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove");
+
+       sub = uiLayoutRow(row, false);
+       uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
+
+       sub = uiLayoutRow(row, false);
+       uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
+       uiItemO(sub, "", ICON_X, "LOGIC_OT_actuator_remove");
 }
 
 static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
@@ -2160,6 +2193,7 @@ static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C)
                return;
        
        box = uiLayoutBox(layout);
+       uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
        
        switch (RNA_enum_get(ptr, "type")) {
                case ACT_ACTION:
@@ -2361,8 +2395,12 @@ void logic_buttons(bContext *C, ARegion *ar)
                        
                        /* put inlink button to the left */
                        col = uiLayoutColumn(split, false);
+                       uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
                        uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT);
-                       uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
+                       but = uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
+                       if (!RNA_boolean_get(&ptr, "active")) {
+                               uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+                       }
                        
                        //col = uiLayoutColumn(split, true);
                        /* nested split for middle and right columns */
@@ -2378,12 +2416,17 @@ void logic_buttons(bContext *C, ARegion *ar)
                        /* draw the brick contents */
                        draw_brick_controller(col, &ptr);
                        
-                       
                        /* put link button to the right */
                        col = uiLayoutColumn(subsplit, false);
+                       uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
                        uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT);
                        but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+                       if (!RNA_boolean_get(&ptr, "active")) {
+                               uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+                       }
+
                        uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
+
                }
        }
        uiBlockLayoutResolve(block, NULL, &yco);        /* stores final height in yco */
@@ -2433,7 +2476,7 @@ void logic_buttons(bContext *C, ARegion *ar)
                                )
                        {       // gotta check if the current state is visible or not
                                uiLayout *split, *col;
-                               
+
                                /* make as visible, for move operator */
                                sens->flag |= SENS_VISIBLE;
 
@@ -2449,9 +2492,14 @@ void logic_buttons(bContext *C, ARegion *ar)
                                
                                /* put link button to the right */
                                col = uiLayoutColumn(split, false);
-                               /* use old-school uiButtons for links for now */
+                               uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
                                but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
-                               uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
+                               if (!RNA_boolean_get(&ptr, "active")) {
+                                       uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+                               }
+
+                               /* use old-school uiButtons for links for now */
+                               uiSetButLink(but, NULL, (void ***)&sens->links, &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
                        }
                }
        }
@@ -2513,7 +2561,11 @@ void logic_buttons(bContext *C, ARegion *ar)
                                
                                /* put inlink button to the left */
                                col = uiLayoutColumn(split, false);
-                               uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
+                               uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
+                               but = uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
+                               if (!RNA_boolean_get(&ptr, "active")) {
+                                       uiButSetFlag(but, UI_BUT_SCA_LINK_GREY);
+                               }
 
                                col = uiLayoutColumn(split, true);
                                uiLayoutSetContextPointer(col, "actuator", &ptr);
index f4e2ff43fc51bc2bed7ea63e589afb6d7e413254..99f0c999a29fc1ed438bdc159c2524c8317fd274 100644 (file)
@@ -264,7 +264,7 @@ typedef struct bActuator {
         * For ipo's and props: to find out which object the actuator
         * belongs to */
        struct Object *ob;
-       
+
 } bActuator;
 
 /* objectactuator->flag */
@@ -322,6 +322,7 @@ typedef struct bActuator {
 #define ACT_LINKED             8       
 #define ACT_VISIBLE            16      
 #define ACT_PIN                        32
+#define ACT_DEACTIVATE  64
 
 /* link codes */
 #define LINK_SENSOR            0
index 0c1aaf5fd20a31750314be634a426e76c33ee647..154542d60c58a35825f2d4803ddc967cd91b6327 100644 (file)
@@ -83,6 +83,7 @@ typedef struct bController {
 #define CONT_NEW               4
 #define CONT_MASK              8
 #define CONT_PRIO              16
+#define CONT_DEACTIVATE        32
 
 /* pyctrl->flag */
 #define CONT_PY_DEBUG  1
index 1b946c829fdcf49ec6437acaa6514a0fff46bfc9..fcdbbe3154154587f030021e238f74b645986dcb 100644 (file)
@@ -257,6 +257,7 @@ typedef struct bJoystickSensor {
 #define SENS_NOT               8
 #define SENS_VISIBLE   16
 #define SENS_PIN               32
+#define SENS_DEACTIVATE        64
 
 /* sensor->pulse */
 #define SENS_PULSE_CONT        0
index e5545f9cb95eb81a8f1cf380546df8735246a783..9880e7da26a76f6b56d712650409bfc36f962055 100644 (file)
@@ -573,6 +573,11 @@ static void rna_def_actuator(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface");
        RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
 
+       prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_DEACTIVATE);
+       RNA_def_property_ui_text(prop, "Active", "Set the active state of the actuator");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
        RNA_api_actuator(srna);
 }
 
index 3b789b16f52b0b9f1ef4705235455f237204dc21..8b5074eaf0d9eb8a60d4d0034dbdbc3b0c781fb3 100644 (file)
@@ -228,6 +228,11 @@ void RNA_def_controller(BlenderRNA *brna)
        RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
        RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+       prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONT_DEACTIVATE);
+       RNA_def_property_ui_text(prop, "Active", "Set the active state of the controller");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
        prop = RNA_def_property(srna, "use_priority", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PRIO);
        RNA_def_property_ui_text(prop, "Priority",
index e570daa828198e8e9d9e0b193714a95ad742940e..f5e59119baab97325eaca2d3b31f13e71cb1ab6f 100644 (file)
@@ -296,6 +296,11 @@ static void rna_def_sensor(BlenderRNA *brna)
        RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
        RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+       prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SENS_DEACTIVATE);
+       RNA_def_property_ui_text(prop, "Active", "Set active state of the sensor");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
        prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW);
        RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface");
index 725e9815a6756b2f34c94495fb120c73b55e4098..d7578c3f03fbc736ce371e3063a25b7977e5749a 100644 (file)
@@ -1106,7 +1106,7 @@ void BL_ConvertActuators(const char* maggiename,
                        ; /* generate some error */
                }
                
-               if (baseact)
+               if (baseact && !(bact->flag & ACT_DEACTIVATE))
                {
                        baseact->SetExecutePriority(executePriority++);
                        uniquename += "#ACT#";
index ab5f1611cb9de43afad4bcc154e6a1330369fad7..cd7a560edad84b638b2c2df4c8081198ddd1ac48 100644 (file)
@@ -197,7 +197,7 @@ void BL_ConvertControllers(
                        }
                }
 
-               if (gamecontroller)
+               if (gamecontroller && !(bcontr->flag & CONT_DEACTIVATE))
                {
                        LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
                        gamecontroller->SetExecutePriority(executePriority++);
index 2e2ebda47e28a03b7171a458082cb284fca6a07e..6ab382f7956c95d1ca2db0cf97963e5c92c15b1a 100644 (file)
@@ -49,6 +49,7 @@
 #include "DNA_object_types.h"
 #include "DNA_material_types.h"
 #include "DNA_sensor_types.h"
+#include "DNA_controller_types.h"
 #include "DNA_actuator_types.h" /* for SENS_ALL_KEYS ? this define is
                                  * probably misplaced */
 /* end of blender include block */
@@ -575,7 +576,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
                        }
                }
 
-               if (gamesensor)
+               if (gamesensor && !(sens->flag & SENS_DEACTIVATE))
                {
                        gamesensor->SetExecutePriority(executePriority++);
                        STR_String uniquename = sens->name;
@@ -606,16 +607,19 @@ void BL_ConvertSensors(struct Object* blenderobject,
                        {
                                bController* linkedcont = (bController*) sens->links[i];
                                if (linkedcont) {
-                                       SCA_IController* gamecont = converter->FindGameController(linkedcont);
+                                       // If the controller is deactived doesn't register it
+                                       if (!(linkedcont->flag & CONT_DEACTIVATE)) {
+                                               SCA_IController* gamecont = converter->FindGameController(linkedcont);
 
-                                       if (gamecont) {
-                                               logicmgr->RegisterToSensor(gamecont,gamesensor);
-                                       }
-                                       else {
-                                               printf("Warning, sensor \"%s\" could not find its controller "
-                                                      "(link %d of %d) from object \"%s\"\n"
-                                                      "\tthere has been an error converting the blender controller for the game engine,"
-                                                      "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
+                                               if (gamecont) {
+                                                       logicmgr->RegisterToSensor(gamecont,gamesensor);
+                                               }
+                                               else {
+                                                       printf("Warning, sensor \"%s\" could not find its controller "
+                                                              "(link %d of %d) from object \"%s\"\n"
+                                                              "\tthere has been an error converting the blender controller for the game engine,"
+                                                              "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
+                                               }
                                        }
                                }
                                else {