Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_logic/logic_window.c
| Show First 20 Lines • Show All 755 Lines • ▼ Show 20 Lines | static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event) | ||||
| if (idar) MEM_freeN(idar); | if (idar) MEM_freeN(idar); | ||||
| } | } | ||||
| static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) | static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| int yco=0; | int yco=0; | ||||
| block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); | block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN); | ||||
| uiBlockSetButmFunc(block, do_sensor_menu, NULL); | UI_block_func_butmenu_set(block, do_sensor_menu, NULL); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); | ||||
| uiDefBut(block, SEPRLINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Show Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Hide Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); | ||||
| uiBlockSetDirection(block, UI_TOP); | UI_block_direction_set(block, UI_DIR_UP); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static void do_controller_menu(bContext *C, void *UNUSED(arg), int event) | static void do_controller_menu(bContext *C, void *UNUSED(arg), int event) | ||||
| { | { | ||||
| SpaceLogic *slogic= CTX_wm_space_logic(C); | SpaceLogic *slogic= CTX_wm_space_logic(C); | ||||
| ID **idar; | ID **idar; | ||||
| Show All 22 Lines | static void do_controller_menu(bContext *C, void *UNUSED(arg), int event) | ||||
| if (idar) MEM_freeN(idar); | if (idar) MEM_freeN(idar); | ||||
| } | } | ||||
| static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) | static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| int yco=0; | int yco=0; | ||||
| block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); | block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN); | ||||
| uiBlockSetButmFunc(block, do_controller_menu, NULL); | UI_block_func_butmenu_set(block, do_controller_menu, NULL); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); | ||||
| uiDefBut(block, SEPRLINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Show Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Hide Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); | ||||
| uiBlockSetDirection(block, UI_TOP); | UI_block_direction_set(block, UI_DIR_UP); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static void do_actuator_menu(bContext *C, void *UNUSED(arg), int event) | static void do_actuator_menu(bContext *C, void *UNUSED(arg), int event) | ||||
| { | { | ||||
| SpaceLogic *slogic= CTX_wm_space_logic(C); | SpaceLogic *slogic= CTX_wm_space_logic(C); | ||||
| ID **idar; | ID **idar; | ||||
| Show All 22 Lines | static void do_actuator_menu(bContext *C, void *UNUSED(arg), int event) | ||||
| if (idar) MEM_freeN(idar); | if (idar) MEM_freeN(idar); | ||||
| } | } | ||||
| static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) | static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| int xco=0; | int xco=0; | ||||
| block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); | block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN); | ||||
| uiBlockSetButmFunc(block, do_actuator_menu, NULL); | UI_block_func_butmenu_set(block, do_actuator_menu, NULL); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); | ||||
| uiDefBut(block, SEPRLINE, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Show Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); | ||||
| uiDefBut(block, BUTM, 1, IFACE_("Hide Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); | uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); | ||||
| uiBlockSetDirection(block, UI_TOP); | UI_block_direction_set(block, UI_DIR_UP); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, void *arg2_mask) | static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, void *arg2_mask) | ||||
| { | { | ||||
| unsigned int *cont_mask = arg2_mask; | unsigned int *cont_mask = arg2_mask; | ||||
| uiBut *but = arg1_but; | uiBut *but = arg1_but; | ||||
| /* a controller is always in a single state */ | /* a controller is always in a single state */ | ||||
| *cont_mask = (1<<but->retval); | *cont_mask = (1<<but->retval); | ||||
| but->retval = B_REDR; | but->retval = B_REDR; | ||||
| } | } | ||||
| static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont) | static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| bController *cont = arg_cont; | bController *cont = arg_cont; | ||||
| short yco = 12, xco = 0, stbit, offset; | short yco = 12, xco = 0, stbit, offset; | ||||
| block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block= UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| /* use this for a fake extra empy space around the buttons */ | /* use this for a fake extra empy space around the buttons */ | ||||
| uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); | ||||
| for (offset=0; offset<15; offset += 5) { | for (offset=0; offset<15; offset += 5) { | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| for (stbit=0; stbit<5; stbit++) { | for (stbit=0; stbit<5; stbit++) { | ||||
| but = uiDefButBitI(block, TOG, (1<<(stbit+offset)), (stbit+offset), "", (short)(xco+12*stbit+13*offset), yco, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); | but = uiDefButBitI(block, UI_BTYPE_TOGGLE, (1<<(stbit+offset)), (stbit+offset), "", (short)(xco+12*stbit+13*offset), yco, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(but, check_controller_state_mask, but, &(cont->state_mask)); | UI_but_func_set(but, check_controller_state_mask, but, &(cont->state_mask)); | ||||
| } | } | ||||
| for (stbit=0; stbit<5; stbit++) { | for (stbit=0; stbit<5; stbit++) { | ||||
| but = uiDefButBitI(block, TOG, (1<<(stbit+offset+15)), (stbit+offset+15), "", (short)(xco+12*stbit+13*offset), yco-12, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); | but = uiDefButBitI(block, UI_BTYPE_TOGGLE, (1<<(stbit+offset+15)), (stbit+offset+15), "", (short)(xco+12*stbit+13*offset), yco-12, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(but, check_controller_state_mask, but, &(cont->state_mask)); | UI_but_func_set(but, check_controller_state_mask, but, &(cont->state_mask)); | ||||
| } | } | ||||
| } | } | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| uiBlockSetDirection(block, UI_TOP); | UI_block_direction_set(block, UI_DIR_UP); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static bool is_sensor_linked(uiBlock *block, bSensor *sens) | static bool is_sensor_linked(uiBlock *block, bSensor *sens) | ||||
| { | { | ||||
| bController *cont; | bController *cont; | ||||
| int i; | int i; | ||||
| for (i=0; i<sens->totlinks; i++) { | for (i=0; i<sens->totlinks; i++) { | ||||
| cont = sens->links[i]; | cont = sens->links[i]; | ||||
| if (uiFindInlink(block, cont) != NULL) | if (UI_block_links_find_inlink(block, cont) != NULL) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* Sensors code */ | /* Sensors code */ | ||||
| static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr) | static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr) | ||||
| ▲ Show 20 Lines • Show All 1,413 Lines • ▼ Show 20 Lines | void logic_buttons(bContext *C, ARegion *ar) | ||||
| int xco, yco, width, height; | int xco, yco, width, height; | ||||
| if (ob==NULL) return; | if (ob==NULL) return; | ||||
| RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); | RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); | ||||
| idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); | idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); | ||||
| BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar); | BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar); | ||||
| block= uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); | block= UI_block_begin(C, ar, uiblockstr, UI_EMBOSS); | ||||
| uiBlockSetHandleFunc(block, do_logic_buts, NULL); | UI_block_func_handle_set(block, do_logic_buts, NULL); | ||||
| uiBoundsBlock(block, U.widget_unit/2); | UI_block_bounds_set_normal(block, U.widget_unit/2); | ||||
| /* loop over all objects and set visible/linked flags for the logic bricks */ | /* loop over all objects and set visible/linked flags for the logic bricks */ | ||||
| for (a=0; a<count; a++) { | for (a=0; a<count; a++) { | ||||
| bActuator *act; | bActuator *act; | ||||
| bSensor *sens; | bSensor *sens; | ||||
| bController *cont; | bController *cont; | ||||
| int iact; | int iact; | ||||
| short flag; | short flag; | ||||
| Show All 29 Lines | while (cont) { | ||||
| } | } | ||||
| cont = cont->next; | cont = cont->next; | ||||
| } | } | ||||
| } | } | ||||
| /* ****************** Controllers ****************** */ | /* ****************** Controllers ****************** */ | ||||
| xco= 21 * U.widget_unit; yco= - U.widget_unit / 2; width= 15 * U.widget_unit; | xco= 21 * U.widget_unit; yco= - U.widget_unit / 2; width= 15 * U.widget_unit; | ||||
| layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_GetStyle()); | layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get()); | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco - U.widget_unit / 2, yco, width, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ | uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco - U.widget_unit / 2, yco, width, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ | ||||
| uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, IFACE_("Link"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, IFACE_("Link"), ICON_NONE); | ||||
| Show All 13 Lines | for (a=0; a<count; a++) { | ||||
| /* Drawing the Controller Header common to all Selected Objects */ | /* Drawing the Controller Header common to all Selected Objects */ | ||||
| RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); | RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); | ||||
| split = uiLayoutSplit(layout, 0.05f, false); | split = uiLayoutSplit(layout, 0.05f, false); | ||||
| uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT); | uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT); | ||||
| row = uiLayoutRow(split, true); | row = uiLayoutRow(split, true); | ||||
| uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers")); | uiDefButBitS(block, UI_BTYPE_TOGGLE, OB_SHOWCONT, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers")); | ||||
| RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); | RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); | ||||
| uiLayoutSetContextPointer(row, "object", &object_ptr); | uiLayoutSetContextPointer(row, "object", &object_ptr); | ||||
| uiItemMenuEnumO(row, C, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE); | uiItemMenuEnumO(row, C, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE); | ||||
| if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { | if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { | ||||
| box = uiLayoutBox(layout); | box = uiLayoutBox(layout); | ||||
| Show All 31 Lines | for (cont= ob->controllers.first; cont; cont=cont->next) { | ||||
| /* use two nested splits to align inlinks/links properly */ | /* use two nested splits to align inlinks/links properly */ | ||||
| split = uiLayoutSplit(layout, 0.05f, false); | split = uiLayoutSplit(layout, 0.05f, false); | ||||
| /* put inlink button to the left */ | /* put inlink button to the left */ | ||||
| col = uiLayoutColumn(split, false); | col = uiLayoutColumn(split, false); | ||||
| uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); | uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); | ||||
| uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); | uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); | ||||
| but = uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, ""); | but = uiDefIconBut(block, UI_BTYPE_INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, ""); | ||||
| if (!RNA_boolean_get(&ptr, "active")) { | if (!RNA_boolean_get(&ptr, "active")) { | ||||
| uiButSetFlag(but, UI_BUT_SCA_LINK_GREY); | UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY); | ||||
| } | } | ||||
| //col = uiLayoutColumn(split, true); | //col = uiLayoutColumn(split, true); | ||||
| /* nested split for middle and right columns */ | /* nested split for middle and right columns */ | ||||
| subsplit = uiLayoutSplit(split, 0.95f, false); | subsplit = uiLayoutSplit(split, 0.95f, false); | ||||
| col = uiLayoutColumn(subsplit, true); | col = uiLayoutColumn(subsplit, true); | ||||
| uiLayoutSetContextPointer(col, "controller", &ptr); | uiLayoutSetContextPointer(col, "controller", &ptr); | ||||
| /* should make UI template for controller header.. function will do for now */ | /* should make UI template for controller header.. function will do for now */ | ||||
| // draw_controller_header(col, &ptr); | // draw_controller_header(col, &ptr); | ||||
| draw_controller_header(col, &ptr, xco, width, yco); //provisory for 2.50 beta | draw_controller_header(col, &ptr, xco, width, yco); //provisory for 2.50 beta | ||||
| /* draw the brick contents */ | /* draw the brick contents */ | ||||
| draw_brick_controller(col, &ptr); | draw_brick_controller(col, &ptr); | ||||
| /* put link button to the right */ | /* put link button to the right */ | ||||
| col = uiLayoutColumn(subsplit, false); | col = uiLayoutColumn(subsplit, false); | ||||
| uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); | uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); | ||||
| uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); | 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, ""); | but = uiDefIconBut(block, UI_BTYPE_LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| if (!RNA_boolean_get(&ptr, "active")) { | if (!RNA_boolean_get(&ptr, "active")) { | ||||
| uiButSetFlag(but, UI_BUT_SCA_LINK_GREY); | UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY); | ||||
| } | } | ||||
| uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); | UI_but_link_set(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); | ||||
| } | } | ||||
| } | } | ||||
| uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ | UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */ | ||||
| height = yco; | height = yco; | ||||
| /* ****************** Sensors ****************** */ | /* ****************** Sensors ****************** */ | ||||
| xco= U.widget_unit / 2; yco= -U.widget_unit / 2; width= 17 * U.widget_unit; | xco= U.widget_unit / 2; yco= -U.widget_unit / 2; width= 17 * U.widget_unit; | ||||
| layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_GetStyle()); | layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get()); | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ | uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ | ||||
| uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, IFACE_("Link"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, IFACE_("Link"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, IFACE_("State"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, IFACE_("State"), ICON_NONE); | ||||
| for (a=0; a<count; a++) { | for (a=0; a<count; a++) { | ||||
| bSensor *sens; | bSensor *sens; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| ob= (Object *)idar[a]; | ob= (Object *)idar[a]; | ||||
| /* only draw the sensor common header if "use_visible" */ | /* only draw the sensor common header if "use_visible" */ | ||||
| if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; | if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors")); | uiDefButBitS(block, UI_BTYPE_TOGGLE, OB_SHOWSENS, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors")); | ||||
| RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); | RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); | ||||
| uiLayoutSetContextPointer(row, "object", &object_ptr); | uiLayoutSetContextPointer(row, "object", &object_ptr); | ||||
| uiItemMenuEnumO(row, C, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE); | uiItemMenuEnumO(row, C, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE); | ||||
| if ((ob->scaflag & OB_SHOWSENS) == 0) continue; | if ((ob->scaflag & OB_SHOWSENS) == 0) continue; | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| Show All 21 Lines | for (sens= ob->sensors.first; sens; sens=sens->next) { | ||||
| draw_sensor_header(col, &ptr, &logic_ptr); | draw_sensor_header(col, &ptr, &logic_ptr); | ||||
| /* draw the brick contents */ | /* draw the brick contents */ | ||||
| draw_brick_sensor(col, &ptr, C); | draw_brick_sensor(col, &ptr, C); | ||||
| /* put link button to the right */ | /* put link button to the right */ | ||||
| col = uiLayoutColumn(split, false); | col = uiLayoutColumn(split, false); | ||||
| uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); | 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, ""); | but = uiDefIconBut(block, UI_BTYPE_LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| if (!RNA_boolean_get(&ptr, "active")) { | if (!RNA_boolean_get(&ptr, "active")) { | ||||
| uiButSetFlag(but, UI_BUT_SCA_LINK_GREY); | UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY); | ||||
| } | } | ||||
| /* use old-school uiButtons for links for now */ | /* use old-school uiButtons for links for now */ | ||||
| uiSetButLink(but, NULL, (void ***)&sens->links, &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); | UI_but_link_set(but, NULL, (void ***)&sens->links, &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ | UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */ | ||||
| height = MIN2(height, yco); | height = MIN2(height, yco); | ||||
| /* ****************** Actuators ****************** */ | /* ****************** Actuators ****************** */ | ||||
| xco= 40 * U.widget_unit; yco= -U.widget_unit / 2; width= 17 * U.widget_unit; | xco= 40 * U.widget_unit; yco= -U.widget_unit / 2; width= 17 * U.widget_unit; | ||||
| layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_GetStyle()); | layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get()); | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ | uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ | ||||
| uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, IFACE_("Link"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, IFACE_("Link"), ICON_NONE); | ||||
| uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, IFACE_("State"), ICON_NONE); | uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, IFACE_("State"), ICON_NONE); | ||||
| for (a=0; a<count; a++) { | for (a=0; a<count; a++) { | ||||
| bActuator *act; | bActuator *act; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| ob= (Object *)idar[a]; | ob= (Object *)idar[a]; | ||||
| /* only draw the actuator common header if "use_visible" */ | /* only draw the actuator common header if "use_visible" */ | ||||
| if ((ob->scavisflag & OB_VIS_ACT) == 0) { | if ((ob->scavisflag & OB_VIS_ACT) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators")); | uiDefButBitS(block, UI_BTYPE_TOGGLE, OB_SHOWACT, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators")); | ||||
| RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); | RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); | ||||
| uiLayoutSetContextPointer(row, "object", &object_ptr); | uiLayoutSetContextPointer(row, "object", &object_ptr); | ||||
| uiItemMenuEnumO(row, C, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE); | uiItemMenuEnumO(row, C, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE); | ||||
| if ((ob->scaflag & OB_SHOWACT) == 0) continue; | if ((ob->scaflag & OB_SHOWACT) == 0) continue; | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| Show All 14 Lines | for (act= ob->actuators.first; act; act=act->next) { | ||||
| /* make as visible, for move operator */ | /* make as visible, for move operator */ | ||||
| act->flag |= ACT_VISIBLE; | act->flag |= ACT_VISIBLE; | ||||
| split = uiLayoutSplit(layout, 0.05f, false); | split = uiLayoutSplit(layout, 0.05f, false); | ||||
| /* put inlink button to the left */ | /* put inlink button to the left */ | ||||
| col = uiLayoutColumn(split, false); | col = uiLayoutColumn(split, false); | ||||
| uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); | 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, ""); | but = uiDefIconBut(block, UI_BTYPE_INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, ""); | ||||
| if (!RNA_boolean_get(&ptr, "active")) { | if (!RNA_boolean_get(&ptr, "active")) { | ||||
| uiButSetFlag(but, UI_BUT_SCA_LINK_GREY); | UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY); | ||||
| } | } | ||||
| col = uiLayoutColumn(split, true); | col = uiLayoutColumn(split, true); | ||||
| uiLayoutSetContextPointer(col, "actuator", &ptr); | uiLayoutSetContextPointer(col, "actuator", &ptr); | ||||
| /* should make UI template for actuator header.. function will do for now */ | /* should make UI template for actuator header.. function will do for now */ | ||||
| draw_actuator_header(col, &ptr, &logic_ptr); | draw_actuator_header(col, &ptr, &logic_ptr); | ||||
| /* draw the brick contents */ | /* draw the brick contents */ | ||||
| draw_brick_actuator(col, &ptr, C); | draw_brick_actuator(col, &ptr, C); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ | UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */ | ||||
| height = MIN2(height, yco); | height = MIN2(height, yco); | ||||
| UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height - U.widget_unit); | UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height - U.widget_unit); | ||||
| /* set the view */ | /* set the view */ | ||||
| UI_view2d_view_ortho(&ar->v2d); | UI_view2d_view_ortho(&ar->v2d); | ||||
| uiComposeLinks(block); | UI_block_links_compose(block); | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| uiDrawBlock(C, block); | UI_block_draw(C, block); | ||||
| /* restore view matrix */ | /* restore view matrix */ | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| if (idar) MEM_freeN(idar); | if (idar) MEM_freeN(idar); | ||||
| } | } | ||||