[Bf-blender-cvs] [a5b9f22] master: BGE - button for deactivate sensors, controllers and actuators

Jorge Bernal noreply at git.blender.org
Thu Apr 17 03:40:23 CEST 2014


Commit: a5b9f22454cc36c8811b10fe65d40ec900497922
Author: Jorge Bernal
Date:   Wed Apr 16 22:23:29 2014 -0300
https://developer.blender.org/rBa5b9f22454cc36c8811b10fe65d40ec900497922

BGE - button for deactivate sensors, controllers and actuators

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

===================================================================

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

===================================================================

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7eb39fd..12efd89 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -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
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 5622288..b7e2034 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -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);
+						}
 					}
 				}
 			}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index ab9ea75..48fadee 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -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 {
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index acf5d6a..7083700 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -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, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list