[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28734] trunk/blender/source/blender: Logic UI: Controller State

Dalai Felinto dfelinto at gmail.com
Wed May 12 10:34:15 CEST 2010


Revision: 28734
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28734
Author:   dfelinto
Date:     2010-05-12 10:34:15 +0200 (Wed, 12 May 2010)

Log Message:
-----------
Logic UI: Controller State
http://www.pasteall.org/pic/show.php?id=3255

New design, with an option to hide/unhide it.

Matt:
1) the way I managed to have the I selected is kind of nasty :) but I think it will have to wait for proper icons.

2) the ALL is so far only working visually, It's still have to change the code to make all sensors and actuators visible when ALL is on. I think this is better than actually marking all states as before (2.49). Maybe it's even nicer nice to have not only have the states disactivated (in gray as they are now), but also to show them as temporary marked. Is that interesting/possible?

3) Can't centralize it :(

4) I think you are right, the icons are nice, but uninformative ... for someone else curious:
http://www.pasteall.org/pic/show.php?id=3254

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_logic/logic_window.c
    trunk/blender/source/blender/makesdna/DNA_object_types.h
    trunk/blender/source/blender/makesrna/intern/rna_object.c

Modified: trunk/blender/source/blender/editors/space_logic/logic_window.c
===================================================================
--- trunk/blender/source/blender/editors/space_logic/logic_window.c	2010-05-12 08:03:36 UTC (rev 28733)
+++ trunk/blender/source/blender/editors/space_logic/logic_window.c	2010-05-12 08:34:15 UTC (rev 28734)
@@ -448,8 +448,8 @@
 
 	case B_SET_STATE_BIT:
 		for(ob=G.main->object.first; ob; ob=ob->id.next) {
-			if(ob->scaflag & OB_SETSTBIT) {
-				ob->scaflag &= ~OB_SETSTBIT;
+			if(ob->scaflag & OB_ALLSTATE) {
+				ob->scaflag &= ~OB_ALLSTATE;
 				ob->state = 0x3FFFFFFF;
 			}
 		}
@@ -4305,9 +4305,9 @@
 	Object *ob= CTX_data_active_object(C);
 	ID **idar;
 	
-	PointerRNA logic_ptr;
+	PointerRNA logic_ptr, settings_ptr;
 	
-	uiLayout *layout, *row;
+	uiLayout *layout, *row, *split, *subsplit, *box, *col;
 	uiBlock *block;
 	uiBut *but;
 	char name[32];
@@ -4355,29 +4355,42 @@
 	uiItemR(row, &logic_ptr, "controllers_show_active_objects", 0, "Act", 0);
 	uiItemR(row, &logic_ptr, "controllers_show_linked_controller", 0, "Link", 0);
 
-	{
-		PointerRNA settings_ptr;
-		row = uiLayoutRow(layout, 0);
-		RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-		uiItemR(row, &logic_ptr, "controllers_show_initial_state", UI_ITEM_R_NO_BG, "", 0);
+	RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
+
+	split= uiLayoutSplit(layout, 0.05, 0);
+	uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT);
+
+	row = uiLayoutRow(split, 1);
+	uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers");
+	uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0);
+
+	if (RNA_boolean_get(&settings_ptr, "show_state_panel")) {
+
+		box= uiLayoutBox(layout);
+		uiLayoutSetAlignment(box, UI_LAYOUT_ALIGN_CENTER); //XXX doesn't seem to work
+		split= uiLayoutSplit(box, 0.15, 0);
+
+		col= uiLayoutColumn(split, 0);
+		uiItemR(col, &settings_ptr, "all_states", UI_ITEM_R_TOGGLE, NULL, 0);
+		/* XXX terrible workaround while we don't have a nice set of icons here :) */
+		if(RNA_boolean_get(&settings_ptr, "debug_state")==0)
+			uiItemR(col, &settings_ptr, "debug_state", UI_ITEM_R_NO_BG, "", 0);
+		else
+			uiItemR(col, &settings_ptr, "debug_state", 0, "", 0); 
+
+		subsplit= uiLayoutSplit(split, 0.7225, 0);
+		col= uiLayoutColumn(subsplit, 0);
+		row= uiLayoutRow(col, 0);
+		uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "all_states")==0);
 		uiTemplateLayers(row, &settings_ptr, "state", &settings_ptr, "used_state", 0);
-		
-		uiBlockBeginAlign(block);
-		uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
-		uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
-		uiBlockEndAlign(block);
-		
-		if (RNA_boolean_get(&logic_ptr, "controllers_show_initial_state")) {
-			row = uiLayoutRow(layout, 0);
-			uiItemL(row, "Initial State:", 0);
-			uiTemplateLayers(row, &settings_ptr, "initial_state", &settings_ptr, "used_state", 0);
-		}
+		row= uiLayoutRow(col, 0);
+		uiTemplateLayers(row, &settings_ptr, "initial_state", &settings_ptr, "used_state", 0);
+
+		col= uiLayoutColumn(subsplit, 0);
+		uiItemL(col, "Visible", 0);
+		uiItemL(col, "Initial", 0);
 	}
 
-	row = uiLayoutRow(layout, 1);
-	uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers");
-	uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0);
-	
 	for(a=0; a<count; a++) {
 		bController *cont;
 		PointerRNA ptr;
@@ -4680,7 +4693,7 @@
 				}
 			}
 			uiBlockBeginAlign(block);
-			uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All",(short)(xco+226), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
+			uiDefButBitS(block, TOG, OB_ALLSTATE, B_SET_STATE_BIT, "All",(short)(xco+226), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
 			uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini",(short)(xco+248), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
 			uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D",(short)(xco+270), yco-10, 15, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
 			uiBlockEndAlign(block);

Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_types.h	2010-05-12 08:03:36 UTC (rev 28733)
+++ trunk/blender/source/blender/makesdna/DNA_object_types.h	2010-05-12 08:34:15 UTC (rev 28734)
@@ -496,9 +496,10 @@
 #define OB_ADDCONT		512
 #define OB_ADDACT		1024
 #define OB_SHOWCONT		2048
-#define OB_SETSTBIT		4096
+#define OB_ALLSTATE		4096
 #define OB_INITSTBIT	8192
 #define OB_DEBUGSTATE	16384
+#define OB_SHOWSTATE	32768
 
 /* ob->restrictflag */
 #define OB_RESTRICT_VIEW	1

Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c	2010-05-12 08:03:36 UTC (rev 28733)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c	2010-05-12 08:34:15 UTC (rev 28734)
@@ -1273,6 +1273,16 @@
 	prop= RNA_def_property(srna, "debug_state", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE);
 	RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine");
+	RNA_def_property_ui_icon(prop, ICON_INFO, 0);
+
+	prop= RNA_def_property(srna, "all_states", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE);
+	RNA_def_property_ui_text(prop, "All", "Set all state bits");
+
+	prop= RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE);
+	RNA_def_property_ui_text(prop, "States", "Show state panel");
+	RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
 }
 
 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)





More information about the Bf-blender-cvs mailing list