Logic UI: Controller State
authorDalai Felinto <dfelinto@gmail.com>
Wed, 12 May 2010 08:34:15 +0000 (08:34 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 12 May 2010 08:34:15 +0000 (08:34 +0000)
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

source/blender/editors/space_logic/logic_window.c
source/blender/makesdna/DNA_object_types.h
source/blender/makesrna/intern/rna_object.c

index 526bdfa2c631c2060162194543a79bd442ae99bf..5b7926c7a0dd417c1606a44470b6a1bb863f500b 100644 (file)
@@ -448,8 +448,8 @@ void do_logic_buts(bContext *C, void *arg, int event)
 
        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 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
        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 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
        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);
-               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);
-               }
-       }
+       RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
 
-       row = uiLayoutRow(layout, 1);
+       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);
+               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);
+       }
+
        for(a=0; a<count; a++) {
                bController *cont;
                PointerRNA ptr;
@@ -4680,7 +4693,7 @@ void logic_buttons(bContext *C, ARegion *ar)
                                }
                        }
                        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);
index 698492e671529bbde456673c94eebfc6d8a2491b..f50909e641b51c1d9d8cb97cca935b8ccd9d9846 100644 (file)
@@ -496,9 +496,10 @@ extern Object workob;
 #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
index c34769dbeec4b2eed26a1073da02a728879d8d0a..95f142d299d837fb227a2c0d69921d208d35d427 100644 (file)
@@ -1273,6 +1273,16 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
        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)