Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-05-05 04:12:31 +0400
committerMatt Ebb <matt@mke3.net>2010-05-05 04:12:31 +0400
commit96aa9f7002aa2d87b815a73f8aa86cc9b1fdf9e7 (patch)
tree940307f45d4761f9c3233c0173410cdff9dff486 /source/blender/editors
parentc3cd8175c1c542ea9478a87c921f64adf1add9c1 (diff)
Logic Editor UI work
* Re-structured code (can delete the old function entirely when this is done) * Fixed links/inlinks * Fixed some bugs in add and remove controller/actuator * Cleaned up some ui layouts * Use key event types in keyboard sensor * Implemented object controller 'state' in RNA/layout engine (still needs tweaks)
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_logic/logic_ops.c23
-rw-r--r--source/blender/editors/space_logic/logic_window.c493
2 files changed, 293 insertions, 223 deletions
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index 669af07e16c..ee65068e537 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -306,6 +306,7 @@ static int controller_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
BLI_remlink(&(ob->controllers), cont);
+ unlink_controller(cont);
free_controller(cont);
WM_event_add_notifier(C, NC_LOGIC, NULL);
@@ -344,12 +345,27 @@ static int controller_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
bController *cont;
int type= RNA_enum_get(op->ptr, "type");
-
+ int bit;
+
cont= new_controller(type);
BLI_addtail(&(ob->controllers), cont);
make_unique_prop_names(C, cont->name);
+
+ /* set the controller state mask from the current object state.
+ A controller is always in a single state, so select the lowest bit set
+ from the object state */
+ for (bit=0; bit<OB_MAX_STATES; bit++) {
+ if (ob->state & (1<<bit))
+ break;
+ }
+ cont->state_mask = (1<<bit);
+ if (cont->state_mask == 0) {
+ /* shouldn't happen, object state is never 0 */
+ cont->state_mask = 1;
+ }
+
ob->scaflag |= OB_SHOWCONT;
-
+
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
@@ -390,6 +406,7 @@ static int actuator_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
BLI_remlink(&(ob->actuators), act);
+ unlink_actuator(act);
free_actuator(act);
WM_event_add_notifier(C, NC_LOGIC, NULL);
@@ -432,7 +449,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op)
act= new_actuator(type);
BLI_addtail(&(ob->actuators), act);
make_unique_prop_names(C, act->name);
- ob->scaflag |= OB_SHOWCONT;
+ ob->scaflag |= OB_SHOWACT;
WM_event_add_notifier(C, NC_LOGIC, NULL);
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 54ace5ef8ba..5f77e571510 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -3187,21 +3187,22 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr)
static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
{
- uiLayout *box, *row;
+ uiLayout *box, *split, *row;
box= uiLayoutBox(layout);
- row= uiLayoutRow(box, 0);
-
- if (!RNA_boolean_get(ptr, "expanded"))
- return;
-
- row= uiLayoutRow(box, 0);
+ split = uiLayoutSplit(box, 0.45, 0);
+
+ row= uiLayoutRow(split, 1);
uiItemR(row, ptr, "pulse_true_level", 0, "", ICON_DOTSUP);
uiItemR(row, ptr, "pulse_false_level", 0, "", ICON_DOTSDOWN);
- uiItemR(row, ptr, "frequency", 0, "", 0);
- uiItemR(row, ptr, "level", 0, "", 0);
- uiItemR(row, ptr, "tap", 0, "", 0);
- uiItemR(row, ptr, "invert", 0, "", 0);
+ uiItemR(row, ptr, "frequency", 0, "Freq", 0);
+
+ row= uiLayoutRow(split, 1);
+ uiItemR(row, ptr, "level", UI_ITEM_R_TOGGLE, NULL, 0);
+ uiItemR(row, ptr, "tap", UI_ITEM_R_TOGGLE, NULL, 0);
+
+ row= uiLayoutRow(split, 1);
+ uiItemR(row, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", 0);
}
/* sensors in alphabetical order */
@@ -3290,10 +3291,21 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr)
static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr)
{
- uiItemR(layout, ptr, "key", 0, NULL, 0);
+ uiLayout *row;
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "Key:", 0);
+ uiItemR(row, ptr, "key", UI_ITEM_R_EVENT, "", 0);
uiItemR(layout, ptr, "all_keys", 0, NULL, 0);
- uiItemR(layout, ptr, "modifier_key", 0, NULL, 0);
- uiItemR(layout, ptr, "second_modifier_key", 0, NULL, 0);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "First Modifier:", 0);
+ uiItemR(row, ptr, "modifier_key", UI_ITEM_R_EVENT, "", 0);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "Second Modifier:", 0);
+ uiItemR(row, ptr, "second_modifier_key", UI_ITEM_R_EVENT, "", 0);
+
uiItemR(layout, ptr, "target", 0, NULL, 0);
uiItemR(layout, ptr, "log", 0, NULL, 0);
@@ -3387,11 +3399,11 @@ void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr)
if (!RNA_boolean_get(ptr, "expanded"))
return;
+
+ draw_sensor_internal_header(layout, ptr);
box = uiLayoutBox(layout);
- draw_sensor_internal_header(box, ptr);
-
switch (RNA_enum_get(ptr, "type")) {
case SENS_ACTUATOR:
@@ -3850,42 +3862,38 @@ void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr)
}
}
-void logic_buttons(bContext *C, ARegion *ar)
+static void logic_buttons_new(bContext *C, ARegion *ar)
{
SpaceLogic *slogic= CTX_wm_space_logic(C);
Object *ob= CTX_data_active_object(C);
ID **idar;
- bSensor *sens;
- bController *cont;
- bActuator *act;
+
+ PointerRNA logic_ptr;
+
+ uiLayout *layout, *row;
uiBlock *block;
uiBut *but;
- uiLayout *layout, *row;
- PointerRNA logic_ptr;
- int a, iact, stbit, offset;
- int xco, yco, width, ycoo;
- short count;
char name[32];
- /* pin is a bool used for actuator and sensor drawing with states
- * pin so changing states dosnt hide the logic brick */
- char pin;
-
+ short a, count;
+ int xco, yco, width;
+
if(ob==NULL) return;
-// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
+
+ RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
+ idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
+
sprintf(name, "buttonswin %p", ar);
block= uiBeginBlock(C, ar, name, UI_EMBOSS);
uiBlockSetHandleFunc(block, do_logic_buts, NULL);
-
- RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
/* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
- we can determine which is actually linked/visible */
+ we can determine which is actually linked/visible */
for(a=0; a<count; a++) {
+ bActuator *act;
+ bSensor *sens;
ob= (Object *)idar[a];
- act= ob->actuators.first;
+
+ act = ob->actuators.first;
while(act) {
act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
act = act->next;
@@ -3897,14 +3905,10 @@ void logic_buttons(bContext *C, ARegion *ar)
sens = sens->next;
}
}
-
- /* start with the controller because we need to know which one is visible */
- /* ******************************* */
- xco= 400; yco= 170; width= 300;
-
-
- if (G.rt >0) { // new UI code to replace old one
+ /* ****************** Controllers ****************** */
+
+ xco= 420; yco= 170; width= 300;
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first);
row = uiLayoutRow(layout, 1);
@@ -3914,60 +3918,35 @@ void logic_buttons(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);
-
-
- /* State part - ugly */
- if(ob->scaflag & OB_SHOWCONT) {
- unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */
-
- /* first show the state */
- uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, UI_UNIT_Y, "Object state menu: store and retrieve initial state");
-
- if (!ob->state)
- ob->state = 1;
- for (offset=0; offset<15; offset+=5) {
- uiBlockBeginAlign(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- }
+ {
+ PointerRNA settings_ptr;
+ row = uiLayoutRow(layout, 0);
+ RNA_pointer_create(NULL, &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",(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");
+ 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);
-
- yco-=35;
-
- /* display only the controllers that match the current state */
- offset = 0;
- for (stbit=0; stbit<32; stbit++) {
- if (!(ob->state & (1<<stbit)))
- continue;
- /* add a separation between controllers of different states */
- if (offset) {
- offset = 0;
- yco -= 6;
- }
-
- //draw controller
+
+ 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);
}
}
-// cont= ob->controllers.first;
- /* draw individual controllers*/
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;
- uiLayout *split, *col;
+ uiLayout *split, *subsplit, *col;
+ int iact;
+
ob= (Object *)idar[a];
if (!(ob->scavisflag & OB_VIS_CONT) || !(ob->scaflag & OB_SHOWCONT)) continue;
@@ -3976,19 +3955,33 @@ void logic_buttons(bContext *C, ARegion *ar)
for(cont= ob->controllers.first; cont; cont=cont->next) {
RNA_pointer_create(&ob->id, &RNA_Controller, cont, &ptr);
-
-// if (!(cont->state_mask & (1<<stbit)))
-// continue;
-
+
+ if (!(ob->state & cont->state_mask))
+ continue;
+ //if (!(cont->state_mask & (1<<stbit)))
+ // continue;
+
/* this controller is visible, mark all its actuator */
+ /* XXX: perhaps move this to a preprocessing stage if possible? */
for (iact=0; iact<cont->totlinks; iact++) {
- act = cont->links[iact];
+ bActuator *act = cont->links[iact];
if (act)
act->flag |= ACT_VISIBLE;
}
- split = uiLayoutSplit(layout, 0.95, 0);
- col = uiLayoutColumn(split, 1);
+ /* use two nested splits to align inlinks/links properly */
+ split = uiLayoutSplit(layout, 0.05, 0);
+
+ /* put inlink button to the left */
+ col = uiLayoutColumn(split, 0);
+ 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, "");
+
+ //col = uiLayoutColumn(split, 1);
+ /* nested split for middle and right columns */
+ subsplit = uiLayoutSplit(split, 0.95, 0);
+
+ col = uiLayoutColumn(subsplit, 1);
uiLayoutSetContextPointer(col, "controller", &ptr);
/* should make UI template for controller header.. function will do for now */
@@ -3997,17 +3990,199 @@ void logic_buttons(bContext *C, ARegion *ar)
/* draw the brick contents */
draw_brick_controller(col, &ptr);
+
/* put link button to the right */
- col = uiLayoutColumn(split, 0);
- /* use oldskool uiButtons for links for now */
- but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width+UI_UNIT_X), yco, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ col = uiLayoutColumn(subsplit, 0);
+ 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, "");
uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
}
}
uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
+
+
+ /* ****************** Sensors ****************** */
+
+ xco= 10; yco= 170; width= 340;
+ layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first);
+ row = uiLayoutRow(layout, 1);
+
+ uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
+
+ uiItemR(row, &logic_ptr, "sensors_show_selected_objects", 0, "Sel", 0);
+ uiItemR(row, &logic_ptr, "sensors_show_active_objects", 0, "Act", 0);
+ uiItemR(row, &logic_ptr, "sensors_show_linked_controller", 0, "Link", 0);
+ uiItemR(row, &logic_ptr, "sensors_show_active_states", 0, "State", 0);
+
+ row = uiLayoutRow(layout, 1);
+ uiDefButBitS(block, TOG, OB_SHOWSENS, 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 sensors");
+ uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", 0);
+
+ for(a=0; a<count; a++) {
+ bSensor *sens;
+ PointerRNA ptr;
+
+ ob= (Object *)idar[a];
+
+ if (!(ob->scavisflag & OB_VIS_SENS) || !(ob->scaflag & OB_SHOWSENS)) continue;
+
+ uiItemS(layout);
+
+ for(sens= ob->sensors.first; sens; sens=sens->next) {
+ RNA_pointer_create(&ob->id, &RNA_Sensor, sens, &ptr);
+
+ if ((slogic->scaflag & BUTS_SENS_STATE) ||
+ (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
+ (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
+ (is_sensor_linked(block, sens))
+ )
+ { // gotta check if the current state is visible or not
+ uiLayout *split, *col;
+
+ split = uiLayoutSplit(layout, 0.95, 0);
+ col = uiLayoutColumn(split, 1);
+ uiLayoutSetContextPointer(col, "sensor", &ptr);
+
+ /* should make UI template for sensor header.. function will do for now */
+ draw_sensor_header(col, &ptr);
+
+ /* draw the brick contents */
+ draw_brick_sensor(col, &ptr);
+
+ /* put link button to the right */
+ col = uiLayoutColumn(split, 0);
+ /* use oldskool uiButtons for links for now */
+ 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);
+ }
+ }
+ }
+ uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
+
+ /* ****************** Actuators ****************** */
+
+ xco= 800; yco= 170; width= 340;
+ layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first);
+ row = uiLayoutRow(layout, 1);
+
+ uiDefBlockBut(block, sensor_menu, NULL, "Actuators", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
+
+ uiItemR(row, &logic_ptr, "actuators_show_selected_objects", 0, "Sel", 0);
+ uiItemR(row, &logic_ptr, "actuators_show_active_objects", 0, "Act", 0);
+ uiItemR(row, &logic_ptr, "actuators_show_linked_controller", 0, "Link", 0);
+ uiItemR(row, &logic_ptr, "actuators_show_active_states", 0, "State", 0);
+
+ row = uiLayoutRow(layout, 1);
+ uiDefButBitS(block, TOG, OB_SHOWACT, 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 actuators");
+ uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", 0);
+
+ for(a=0; a<count; a++) {
+ bActuator *act;
+ PointerRNA ptr;
+
+ ob= (Object *)idar[a];
+
+ if (!(ob->scavisflag & OB_VIS_ACT) || !(ob->scaflag & OB_SHOWACT)) continue;
+
+ uiItemS(layout);
+
+ for(act= ob->actuators.first; act; act=act->next) {
+
+ RNA_pointer_create(&ob->id, &RNA_Actuator, act, &ptr);
+
+ if ((slogic->scaflag & BUTS_ACT_STATE) ||
+ !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
+ (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */
+ (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE) /* states can hide some sensors, pinned sensors ignore the visible state */
+ )
+ { // gotta check if the current state is visible or not
+ uiLayout *split, *col;
+
+ split = uiLayoutSplit(layout, 0.05, 0);
+
+ /* put inlink button to the left */
+ col = uiLayoutColumn(split, 0);
+ uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
+
+ col = uiLayoutColumn(split, 1);
+ uiLayoutSetContextPointer(col, "actuator", &ptr);
+
+ /* should make UI template for actuator header.. function will do for now */
+ draw_actuator_header(col, &ptr);
+
+ /* draw the brick contents */
+ draw_brick_actuator(col, &ptr);
+
+ }
+ }
+ }
+ uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
+
+
+ uiComposeLinks(block);
+
+ uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+
+ if(idar) MEM_freeN(idar);
+}
+void logic_buttons(bContext *C, ARegion *ar)
+{
+ SpaceLogic *slogic= CTX_wm_space_logic(C);
+ Object *ob= CTX_data_active_object(C);
+ ID **idar;
+ bSensor *sens;
+ bController *cont;
+ bActuator *act;
+ uiBlock *block;
+ uiBut *but;
+ PointerRNA logic_ptr;
+ int a, iact, stbit, offset;
+ int xco, yco, width, ycoo;
+ short count;
+ char name[32];
+ /* pin is a bool used for actuator and sensor drawing with states
+ * pin so changing states dosnt hide the logic brick */
+ char pin;
+
+ if (G.rt != 0) {
+ logic_buttons_new(C, ar);
+ return;
+ }
+
+ if(ob==NULL) return;
+// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
+
+ sprintf(name, "buttonswin %p", ar);
+ block= uiBeginBlock(C, ar, name, UI_EMBOSS);
+ uiBlockSetHandleFunc(block, do_logic_buts, NULL);
+
+ RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
+
+ idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
+
+ /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
+ we can determine which is actually linked/visible */
+ for(a=0; a<count; a++) {
+ ob= (Object *)idar[a];
+ act= ob->actuators.first;
+ while(act) {
+ act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
+ act = act->next;
+ }
+ /* same for sensors */
+ sens= ob->sensors.first;
+ while(sens) {
+ sens->flag &= ~(SENS_VISIBLE);
+ sens = sens->next;
+ }
+ }
+
+ /* start with the controller because we need to know which one is visible */
+ /* ******************************* */
+ xco= 400; yco= 170; width= 300;
- } else { //G.rt == 0 // to be removed ... old code
uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, UI_UNIT_Y, "");
uiBlockBeginAlign(block);
@@ -4144,67 +4319,10 @@ void logic_buttons(bContext *C, ARegion *ar)
yco-= 6;
}
}
- } //XXX endif G.rt == 0 // new UI code to replace old one
/* ******************************* */
xco= 10; yco= 170; width= 300;
- if (G.rt >0) { //XXX new UI code to replace old one
- layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first);
- row = uiLayoutRow(layout, 1);
-
- uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
-
- uiItemR(row, &logic_ptr, "sensors_show_selected_objects", 0, "Sel", 0);
- uiItemR(row, &logic_ptr, "sensors_show_active_objects", 0, "Act", 0);
- uiItemR(row, &logic_ptr, "sensors_show_linked_controller", 0, "Link", 0);
- uiItemR(row, &logic_ptr, "sensors_show_active_states", 0, "State", 0);
-
- row = uiLayoutRow(layout, 1);
- uiDefButBitS(block, TOG, OB_SHOWSENS, 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 sensors");
- uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", 0);
-
- for(a=0; a<count; a++) {
- PointerRNA ptr;
-
- ob= (Object *)idar[a];
-
- if (!(ob->scavisflag & OB_VIS_SENS) || !(ob->scaflag & OB_SHOWSENS)) continue;
-
- uiItemS(layout);
-
- for(sens= ob->sensors.first; sens; sens=sens->next) {
- RNA_pointer_create(&ob->id, &RNA_Sensor, sens, &ptr);
-
- if ((slogic->scaflag & BUTS_SENS_STATE) ||
- (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
- (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
- (is_sensor_linked(block, sens))
- )
- { // gotta check if the current state is visible or not
- uiLayout *split, *col;
-
- split = uiLayoutSplit(layout, 0.95, 0);
- col = uiLayoutColumn(split, 1);
- uiLayoutSetContextPointer(col, "sensor", &ptr);
-
- /* should make UI template for sensor header.. function will do for now */
- draw_sensor_header(col, &ptr);
-
- /* draw the brick contents */
- draw_brick_sensor(col, &ptr);
-
- /* put link button to the right */
- col = uiLayoutColumn(split, 0);
- /* use oldskool uiButtons for links for now */
- but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width+UI_UNIT_X), yco, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
- }
- }
- }
- uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
- } else { //XXX G.rt == 0 { // to be removed == new UI code to replace old one
-
uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 70, UI_UNIT_Y, "");
uiBlockBeginAlign(block);
@@ -4286,71 +4404,8 @@ void logic_buttons(bContext *C, ARegion *ar)
yco-= 6;
}
}
-
- } //XXX endif G.rt == 0 // new UI code to replace old one
-
/* ******************************* */
xco= 800; yco= 170; width= 300;
-
- if (G.rt >0) { //XXX new UI code to replace old one
- layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first);
- row = uiLayoutRow(layout, 1);
-
- uiDefBlockBut(block, sensor_menu, NULL, "Actuators", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
-
- uiItemR(row, &logic_ptr, "actuators_show_selected_objects", 0, "Sel", 0);
- uiItemR(row, &logic_ptr, "actuators_show_active_objects", 0, "Act", 0);
- uiItemR(row, &logic_ptr, "actuators_show_linked_controller", 0, "Link", 0);
- uiItemR(row, &logic_ptr, "actuators_show_active_states", 0, "State", 0);
-
- row = uiLayoutRow(layout, 1);
- uiDefButBitS(block, TOG, OB_SHOWACT, 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 actuators");
- uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", 0);
-
- for(a=0; a<count; a++) {
- PointerRNA ptr;
-
- ob= (Object *)idar[a];
-
- if (!(ob->scavisflag & OB_VIS_ACT) || !(ob->scaflag & OB_SHOWACT)) continue;
-
- uiItemS(layout);
-
- for(act= ob->actuators.first; act; act=act->next) {
-
- RNA_pointer_create(&ob->id, &RNA_Actuator, act, &ptr);
-
- if ((slogic->scaflag & BUTS_ACT_STATE) ||
- !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
- (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */
- (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE) /* states can hide some sensors, pinned sensors ignore the visible state */
- )
- { // gotta check if the current state is visible or not
- uiLayout *split, *col;
-
- split = uiLayoutSplit(layout, 0.95, 0);
- col = uiLayoutColumn(split, 1);
- uiLayoutSetContextPointer(col, "actuator", &ptr);
-
- /* should make UI template for actuator header.. function will do for now */
- draw_actuator_header(col, &ptr);
-
- /* draw the brick contents */
- draw_brick_actuator(col, &ptr);
-
- /* put link button to the right */
- col = uiLayoutColumn(split, 0);
- /* use oldskool uiButtons for links for now */
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
- }
- }
- }
- uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */
-
- } else { //XXX G.rt == 0 { // to be removed == new UI code to replace old one
-
-
uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 90, UI_UNIT_Y, "");
uiBlockBeginAlign(block);
@@ -4429,8 +4484,6 @@ void logic_buttons(bContext *C, ARegion *ar)
}
}
- } //XXX endif G.rt == 0 // new UI code to replace old one
-
uiComposeLinks(block);
uiEndBlock(C, block);