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:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-06-22 18:23:57 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-06-22 18:23:57 +0400
commit5372def2b069699809cf9439381b03364137adb5 (patch)
treeafe69a88cca198ee85617ee284c6fc5be48671c9 /source/blender/src/buttons_logic.c
parent1ee7a20b93ee3c640b119e1a650e49dcb0f97de9 (diff)
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full backward compatibility, multiple active states, multiple state transitions, automatic disabling of sensor and actuators, full GUI support and selective display of sensors and actuators. Note: Python API is available but not documented yet. It will be added asap. State internals =============== The state system is object based. The current state mask is stored in the object as a 32 bit value; each bit set in the mask is an active state. The controllers have a state mask too but only one bit can be set: a controller belongs to a single state. The game engine will only execute controllers that belong to active states. Sensors and actuators don't have a state mask but are effectively attached to states via their links to the controllers. Sensors and actuators can be connected to more than one state. When a controller becomes inactive because of a state change, its links to sensors and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated, i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated, the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that it can react as if the game just started when it gets reconnected to an active controller. For example, an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more controllers of a single state) will generate a pulse each time the state becomes active. This feature is not available on all sensors, see the notes below. GUI === This system system is fully configurable through the GUI: the object state mask is visible under the object bar in the controller's colum as an array of buttons just like the 3D view layer mask. Click on a state bit to only display the controllers of that state. You can select more than one state with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object. The Ini button sets the state mask back to the object default state. You can change the default state of object by first selecting the desired state mask and storing using the menu under the State button. If you define a default state mask, it will be loaded into the object state make when you load the blend file or when you run the game under the blenderplayer. However, when you run the game under Blender, the current selected state mask will be used as the startup state for the object. This allows you to test specific state during the game design. The controller display the state they belong to with a new button in the controller header. When you add a new controller, it is added by default in the lowest enabled state. You can change the controller state by clicking on the button and selecting another state. If more than one state is enabled in the object state mask, controllers are grouped by state for more readibility. The new Sta button in the sensor and actuator column header allows you to display only the sensors and actuators that are linked to visible controllers. A new state actuator is available to modify the state during the game. It defines a bit mask and the operation to apply on the current object state mask: Cpy: the bit mask is copied to the object state mask. Add: the bits that set in the bit mask will be turned on in the object state mask. Sub: the bits that set in the bit mask will be turned off in the object state mask. Inv: the bits that set in the bit mask will be inverted in the objecyy state mask. Notes ===== - Although states have no name, a simply convention consists in using the name of the first controller of the state as the state name. The GUI will support that convention by displaying as a hint the name of the first controller of the state when you move the mouse over a state bit of the object state mask or of the state actuator bit mask. - Each object has a state mask and each object can have a state engine but if several objects are part of a logical group, it is recommended to put the state engine only in the main object and to link the controllers of that object to the sensors and actuators of the different objects. - When loading an old blend file, the state mask of all objects and controllers are initialized to 1 so that all the controllers belong to this single state. This ensures backward compatibility with existing game. - When the state actuator is activated at the same time as other actuators, these actuators are guaranteed to execute before being eventually disabled due to the state change. This is useful for example to send a message or update a property at the time of changing the state. - Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they are acticated again, they will behave as follow: * keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive to new key press. * collision sensor: objects already colliding won't be detected. Only new collisions are detected. * near and radar sensor: same as collision sensor.
Diffstat (limited to 'source/blender/src/buttons_logic.c')
-rw-r--r--source/blender/src/buttons_logic.c626
1 files changed, 479 insertions, 147 deletions
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index b6877b2e2b7..c4fc17bc4d0 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -88,6 +88,7 @@
#include "mydevice.h"
#include "nla.h" /* For __NLA : Important, do not remove */
#include "butspace.h" // own module
+#include "interface.h"
/* internals */
void buttons_enji(uiBlock *, Object *);
@@ -228,7 +229,7 @@ static void sca_move_sensor(void *datav, void *data2_unused)
bSensor *sens_to_delete= datav;
int val;
Base *base;
- bSensor *sens;
+ bSensor *sens, *tmp;
val= pupmenu("Move up%x1|Move down %x2");
@@ -245,12 +246,24 @@ static void sca_move_sensor(void *datav, void *data2_unused)
if(sens) {
if( val==1 && sens->prev) {
- BLI_remlink(&base->object->sensors, sens);
- BLI_insertlinkbefore(&base->object->sensors, sens->prev, sens);
+ for (tmp=sens->prev; tmp; tmp=tmp->prev) {
+ if (tmp->flag & SENS_VISIBLE)
+ break;
+ }
+ if (tmp) {
+ BLI_remlink(&base->object->sensors, sens);
+ BLI_insertlinkbefore(&base->object->sensors, tmp, sens);
+ }
}
else if( val==2 && sens->next) {
- BLI_remlink(&base->object->sensors, sens);
- BLI_insertlink(&base->object->sensors, sens->next, sens);
+ for (tmp=sens->next; tmp; tmp=tmp->next) {
+ if (tmp->flag & SENS_VISIBLE)
+ break;
+ }
+ if (tmp) {
+ BLI_remlink(&base->object->sensors, sens);
+ BLI_insertlink(&base->object->sensors, tmp, sens);
+ }
}
BIF_undo_push("Move sensor");
allqueue(REDRAWBUTSLOGIC, 0);
@@ -267,7 +280,7 @@ static void sca_move_controller(void *datav, void *data2_unused)
bController *controller_to_del= datav;
int val;
Base *base;
- bController *cont;
+ bController *cont, *tmp;
val= pupmenu("Move up%x1|Move down %x2");
@@ -284,12 +297,27 @@ static void sca_move_controller(void *datav, void *data2_unused)
if(cont) {
if( val==1 && cont->prev) {
- BLI_remlink(&base->object->controllers, cont);
- BLI_insertlinkbefore(&base->object->controllers, cont->prev, cont);
+ /* locate the controller that has the same state mask but is earlier in the list */
+ tmp = cont->prev;
+ while(tmp) {
+ if(tmp->state_mask & cont->state_mask)
+ break;
+ tmp = tmp->prev;
+ }
+ if (tmp) {
+ BLI_remlink(&base->object->controllers, cont);
+ BLI_insertlinkbefore(&base->object->controllers, tmp, cont);
+ }
}
else if( val==2 && cont->next) {
+ tmp = cont->next;
+ while(tmp) {
+ if(tmp->state_mask & cont->state_mask)
+ break;
+ tmp = tmp->next;
+ }
BLI_remlink(&base->object->controllers, cont);
- BLI_insertlink(&base->object->controllers, cont->next, cont);
+ BLI_insertlink(&base->object->controllers, tmp, cont);
}
BIF_undo_push("Move controller");
allqueue(REDRAWBUTSLOGIC, 0);
@@ -306,7 +334,7 @@ static void sca_move_actuator(void *datav, void *data2_unused)
bActuator *actuator_to_move= datav;
int val;
Base *base;
- bActuator *act;
+ bActuator *act, *tmp;
val= pupmenu("Move up%x1|Move down %x2");
@@ -323,12 +351,25 @@ static void sca_move_actuator(void *datav, void *data2_unused)
if(act) {
if( val==1 && act->prev) {
- BLI_remlink(&base->object->actuators, act);
- BLI_insertlinkbefore(&base->object->actuators, act->prev, act);
+ /* locate the first visible actuators before this one */
+ for (tmp = act->prev; tmp; tmp=tmp->prev) {
+ if (tmp->flag & ACT_VISIBLE)
+ break;
+ }
+ if (tmp) {
+ BLI_remlink(&base->object->actuators, act);
+ BLI_insertlinkbefore(&base->object->actuators, tmp, act);
+ }
}
else if( val==2 && act->next) {
- BLI_remlink(&base->object->actuators, act);
- BLI_insertlink(&base->object->actuators, act->next, act);
+ for (tmp=act->next; tmp; tmp=tmp->next) {
+ if (tmp->flag & ACT_VISIBLE)
+ break;
+ }
+ if (tmp) {
+ BLI_remlink(&base->object->actuators, act);
+ BLI_insertlink(&base->object->actuators, tmp, act);
+ }
}
BIF_undo_push("Move actuator");
allqueue(REDRAWBUTSLOGIC, 0);
@@ -348,7 +389,7 @@ void do_logic_buts(unsigned short event)
bActuator *act;
Base *base;
Object *ob;
- int didit;
+ int didit, bit;
ob= OBACT;
if(ob==0) return;
@@ -462,6 +503,18 @@ void do_logic_buts(unsigned short event)
make_unique_prop_names(cont->name);
base->object->scaflag |= OB_SHOWCONT;
BLI_addtail(&(base->object->controllers), cont);
+ /* 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<32; bit++) {
+ if (base->object->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;
+ }
}
base= base->next;
}
@@ -469,6 +522,32 @@ void do_logic_buts(unsigned short event)
allqueue(REDRAWBUTSLOGIC, 0);
break;
+ case B_SET_STATE_BIT:
+ base= FIRSTBASE;
+ while(base) {
+ if(base->object->scaflag & OB_SETSTBIT) {
+ base->object->scaflag &= ~OB_SETSTBIT;
+ base->object->state = 0x3FFFFFFF;
+ }
+ base= base->next;
+ }
+ allqueue(REDRAWBUTSLOGIC, 0);
+ break;
+
+ case B_INIT_STATE_BIT:
+ base= FIRSTBASE;
+ while(base) {
+ if(base->object->scaflag & OB_INITSTBIT) {
+ base->object->scaflag &= ~OB_INITSTBIT;
+ base->object->state = base->object->init_state;
+ if (!base->object->state)
+ base->object->state = 1;
+ }
+ base= base->next;
+ }
+ allqueue(REDRAWBUTSLOGIC, 0);
+ break;
+
case B_CHANGE_CONT:
base= FIRSTBASE;
while(base) {
@@ -505,7 +584,7 @@ void do_logic_buts(unsigned short event)
BIF_undo_push("Delete controller");
allqueue(REDRAWBUTSLOGIC, 0);
break;
-
+
case B_ADD_ACT:
base= FIRSTBASE;
while(base) {
@@ -717,6 +796,8 @@ static char *actuator_name(int type)
return "2D Filter";
case ACT_PARENT:
return "Parent";
+ case ACT_STATE:
+ return "State";
}
return "unknown";
}
@@ -732,21 +813,21 @@ static char *actuator_pup(Object *owner)
return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1"
"|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
"|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20";
+ "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22";
break;
case OB_MESH:
return "Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1"
"|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
"|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20";
+ "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22";
break;
default:
return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1"
"|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
"|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20";
+ "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22";
}
}
@@ -815,7 +896,8 @@ static ID **get_selected_and_linked_obs(short *count, short scavisflag)
if(scavisflag & BUTS_ACT_ACT) OBACT->scavisflag |= OB_VIS_ACT;
}
- if(scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK)) {
+ /* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */
+ if(scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK|BUTS_SENS_STATE|BUTS_ACT_STATE)) {
doit= 1;
while(doit) {
doit= 0;
@@ -824,7 +906,7 @@ static ID **get_selected_and_linked_obs(short *count, short scavisflag)
while(ob) {
/* 1st case: select sensor when controller selected */
- if((scavisflag & BUTS_SENS_LINK) && (ob->scavisflag & OB_VIS_SENS)==0) {
+ if((scavisflag & (BUTS_SENS_LINK|BUTS_SENS_STATE)) && (ob->scavisflag & OB_VIS_SENS)==0) {
sens= ob->sensors.first;
while(sens) {
for(a=0; a<sens->totlinks; a++) {
@@ -879,7 +961,7 @@ static ID **get_selected_and_linked_obs(short *count, short scavisflag)
}
/* 4th case: select actuator when controller selected */
- if( (scavisflag & BUTS_ACT_LINK) && (ob->scavisflag & OB_VIS_CONT)) {
+ if( (scavisflag & (BUTS_ACT_LINK|BUTS_ACT_STATE)) && (ob->scavisflag & OB_VIS_CONT)) {
cont= ob->controllers.first;
while(cont) {
for(a=0; a<cont->totlinks; a++) {
@@ -1458,6 +1540,7 @@ static int get_col_actuator(int type)
case ACT_GAME: return TH_BUT_SETTING2;
case ACT_VISIBILITY: return TH_BUT_NUM;
case ACT_CONSTRAINT: return TH_BUT_ACTION;
+ case ACT_STATE: return TH_BUT_SETTING2;
default: return TH_BUT_NEUTRAL;
}
}
@@ -1468,7 +1551,23 @@ static void set_col_actuator(int item, int medium)
}
-static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, short yco, short width)
+char *get_state_name(Object *ob, short bit)
+{
+ bController *cont;
+ unsigned int mask;
+
+ mask = (1<<bit);
+ cont = ob->controllers.first;
+ while (cont) {
+ if (cont->state_mask & mask) {
+ return cont->name;
+ }
+ cont = cont->next;
+ }
+ return (char*)"";
+}
+
+static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
{
bSoundActuator *sa = NULL;
bCDActuator *cda = NULL;
@@ -1487,11 +1586,12 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho
bVisibilityActuator *visAct = NULL;
bTwoDFilterActuator *tdfa = NULL;
bParentActuator *parAct = NULL;
+ bStateActuator *staAct = NULL;
float *fp;
short ysize = 0, wval;
- char *str;
- int myline;
+ char *str, name[32];
+ int myline, stbit;
/* yco is at the top of the rect, draw downwards */
uiBlockSetEmboss(block, UI_EMBOSSM);
@@ -2022,6 +2122,37 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho
break;
+ case ACT_STATE:
+ ysize = 34;
+
+ glRects(xco, yco-ysize, xco+width, yco);
+ uiEmboss((float)xco,
+ (float)yco-ysize, (float)xco+width, (float)yco, 1);
+
+ staAct = act->data;
+
+ str= "Operation %t|Cpy %x0|Add %x1|Sub %x2|Inv %x3";
+
+ uiDefButI(block, MENU, B_REDR, str,
+ xco + 10, yco - 24, 65, 19, &staAct->type,
+ 0.0, 0.0, 0, 0,
+ "Select the bit operation on object state mask");
+
+ for (wval=0; wval<15; wval+=5) {
+ uiBlockBeginAlign(block);
+ for (stbit=0; stbit<5; stbit++) {
+ uiDefButBitI(block, TOG, (1<<(stbit+wval)), 0, "", (short)(xco+85+12*stbit+13*wval), yco-17, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(wval+stbit)));
+ }
+ for (stbit=0; stbit<5; stbit++) {
+ uiDefButBitI(block, TOG, (1<<(stbit+wval+15)), 0, "", (short)(xco+85+12*stbit+13*wval), yco-29, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(wval+stbit+15)));
+ }
+ }
+ uiBlockEndAlign(block);
+
+ yco-= ysize;
+
+ break;
+
case ACT_RANDOM:
ysize = 69;
@@ -2596,6 +2727,120 @@ void buttons_bullet(uiBlock *block, Object *ob)
uiBlockEndAlign(block);
}
+static void check_object_state(void *arg1_but, void *arg2_mask)
+{
+ unsigned int *cont_mask = arg2_mask;
+ uiBut *but = arg1_but;
+
+ if (*cont_mask == 0 || !(G.qual & LR_SHIFTKEY))
+ *cont_mask = (1<<but->retval);
+ but->retval = B_REDR;
+}
+
+static void check_controller_state_mask(void *arg1_but, void *arg2_mask)
+{
+ unsigned int *cont_mask = arg2_mask;
+ uiBut *but = arg1_but;
+
+ /* a controller is always in a single state */
+ *cont_mask = (1<<but->retval);
+ but->retval = B_REDR;
+}
+
+static int first_bit(unsigned int mask)
+{
+ int bit;
+
+ for (bit=0; bit<32; bit++) {
+ if (mask & (1<<bit))
+ return bit;
+ }
+ return -1;
+}
+
+static uiBlock *controller_state_mask_menu(void *arg_cont)
+{
+ uiBlock *block;
+ uiBut *but;
+ bController *cont = arg_cont;
+ int mask;
+
+ short yco = 12, xco = 0, stbit, offset;
+
+ block= uiNewBlock(&curarea->uiblocks, "Controller state mask", UI_EMBOSS, UI_HELV, curarea->win);
+
+ /* use this for a fake extra empy space around the buttons */
+ uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, "");
+
+ for (offset=0; offset<15; offset+=5) {
+ uiBlockBeginAlign(block);
+ 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, "");
+ uiButSetFunc(but, check_controller_state_mask, but, &(cont->state_mask));
+ }
+ 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, "");
+ uiButSetFunc(but, check_controller_state_mask, but, &(cont->state_mask));
+ }
+ }
+ uiBlockEndAlign(block);
+
+ uiBlockSetDirection(block, UI_TOP);
+
+ return block;
+}
+
+static void do_object_state_menu(void *arg, int event)
+{
+ Object *ob = arg;
+
+ switch (event) {
+ case 0:
+ ob->state = 0x3FFFFFFF;
+ break;
+ case 1:
+ ob->state = ob->init_state;
+ if (!ob->state)
+ ob->state = 1;
+ break;
+ case 2:
+ ob->init_state = ob->state;
+ break;
+ }
+ allqueue(REDRAWBUTSLOGIC, 0);
+}
+
+static uiBlock *object_state_mask_menu(void *arg_obj)
+{
+ uiBlock *block;
+ uiBut *but;
+ short xco = 0;
+
+ block= uiNewBlock(&curarea->uiblocks, "obstatemenu", UI_EMBOSSP, UI_HELV, curarea->win);
+ uiBlockSetButmFunc(block, do_object_state_menu, arg_obj);
+
+ uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
+ uiDefBut(block, BUTM, 1, "Recall init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
+ uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, BUTM, 1, "Store init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
+
+ uiBlockSetDirection(block, UI_TOP);
+ return block;
+}
+
+static int is_sensor_linked(uiBlock *block, bSensor *sens)
+{
+ bController *cont;
+ int i, count;
+
+ for (count=0, i=0; i<sens->totlinks; i++) {
+ cont = sens->links[i];
+ if (uiFindInlink(block, cont) != NULL)
+ return 1;
+ }
+ return 0;
+}
+
/* never used, see CVS 1.134 for the code */
/* static FreeCamera *new_freecamera(void) */
@@ -2614,7 +2859,7 @@ void logic_buts(void)
uiBlock *block;
uiBut *but;
World *wrld;
- int a;
+ int a, iact, stbit, offset;
short xco, yco, count, width, ycoo;
char *pupstr, name[32];
@@ -2686,158 +2931,241 @@ void logic_buts(void)
uiClearButLock();
idar= get_selected_and_linked_obs(&count, G.buts->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= 375; yco= 170; width= 230;
+ xco= 695; yco= 170; width= 275;
uiBlockSetEmboss(block, UI_EMBOSSP);
- uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 80, 19, "");
+ uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, 19, "");
uiBlockSetEmboss(block, UI_EMBOSS);
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
+ uiDefButBitS(block, TOG, BUTS_CONT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
+ uiDefButBitS(block, TOG, BUTS_CONT_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
+ uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator");
uiBlockEndAlign(block);
+ ob= OBACT;
+
for(a=0; a<count; a++) {
ob= (Object *)idar[a];
uiClearButLock();
uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- if( (ob->scavisflag & OB_VIS_SENS) == 0) continue;
-
+ if( (ob->scavisflag & OB_VIS_CONT) == 0) continue;
+
/* presume it is only objects for now */
uiBlockSetEmboss(block, UI_EMBOSS);
uiBlockBeginAlign(block);
- if(ob->sensors.first) uiSetCurFont(block, UI_HELVB);
- uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors");
- if(ob->sensors.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor");
+ if(ob->controllers.first) uiSetCurFont(block, UI_HELVB);
+ uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 0, 0, 0, "Active Object name");
+ if(ob->controllers.first) uiSetCurFont(block, UI_HELV);
+ uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller");
uiBlockEndAlign(block);
- yco-=20;
+ yco-=17;
- if(ob->scaflag & OB_SHOWSENS) {
-
- sens= ob->sensors.first;
- while(sens) {
- uiBlockSetEmboss(block, UI_EMBOSSM);
- uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X, xco, yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Delete Sensor");
- uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Sensor settings");
+ /* mark all actuators linked to these controllers */
+ /* note that some of these actuators could be from objects that are not in the display list.
+ It's ok because those actuators will not be displayed here */
+ cont= ob->controllers.first;
+ while(cont) {
+ for (iact=0; iact<cont->totlinks; iact++) {
+ act = cont->links[iact];
+ act->flag |= ACT_LINKED;
+ }
+ cont = cont->next;
+ }
- ycoo= yco;
- if(sens->flag & SENS_SHOW)
- {
- uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 100, 19, &sens->type, 0, 0, 0, 0, "Sensor type");
- but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, sens->name, 0, 31, 0, 0, "Sensor name");
- uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0);
+ if(ob->scaflag & OB_SHOWCONT) {
- sens->otype= sens->type;
- yco= draw_sensorbuttons(sens, block, xco, yco, width,ob->id.name);
- if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
+ /* first show the state */
+ uiBlockSetEmboss(block, UI_EMBOSSP);
+ uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 40, 19, "Object state menu: store and retrieve initial state");
+ uiBlockSetEmboss(block, UI_EMBOSS);
+ if (!ob->state)
+ ob->state = 1;
+ for (offset=0; offset<15; offset+=5) {
+ uiBlockBeginAlign(block);
+ for (stbit=0; stbit<5; stbit++) {
+ but = uiDefButBitI(block, TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+35+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
+ uiButSetFunc(but, check_object_state, but, &(ob->state));
}
- else {
- set_col_sensor(sens->type, 1);
- glRecti(xco+22, yco, xco+width-22,yco+19);
- but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 100, 19, sens, 0, 0, 0, 0, "");
- uiButSetFunc(but, sca_move_sensor, sens, NULL);
- but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+122), yco, (short)(width-144), 19, sens, 0, 31, 0, 0, "");
- uiButSetFunc(but, sca_move_sensor, sens, NULL);
+ for (stbit=0; stbit<5; stbit++) {
+ but = uiDefButBitI(block, TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+35+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_object_state, but, &(ob->state));
}
+ }
+ uiBlockBeginAlign(block);
+ uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All",(short)(xco+235), yco-10, 25, 19, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
+ uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini",(short)(xco+260), yco-10, 25, 19, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
+ uiBlockEndAlign(block);
- but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
-
- yco-=20;
+ 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;
+ }
+ cont= ob->controllers.first;
+ while(cont) {
+ if (cont->state_mask & (1<<stbit)) {
+ /* this controller is visible, mark all its actuator */
+ for (iact=0; iact<cont->totlinks; iact++) {
+ act = cont->links[iact];
+ act->flag |= ACT_VISIBLE;
+ }
+ uiBlockSetEmboss(block, UI_EMBOSSM);
+ uiDefIconButBitS(block, TOG, CONT_DEL, B_DEL_CONT, ICON_X, xco, yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Delete Controller");
+ uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Controller settings");
+ uiBlockSetEmboss(block, UI_EMBOSSP);
+ sprintf(name, "%d", first_bit(cont->state_mask)+1);
+ uiDefBlockBut(block, controller_state_mask_menu, cont, name, (short)(xco+width-44), yco, 22, 19, "Set controller state mask");
+ uiBlockSetEmboss(block, UI_EMBOSSM);
+
+ if(cont->flag & CONT_SHOW) {
+ cont->otype= cont->type;
+ uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 100, 19, &cont->type, 0, 0, 0, 0, "Controller type");
+ but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-166), 19, cont->name, 0, 31, 0, 0, "Controller name");
+ uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0);
+
+ ycoo= yco;
+ yco= draw_controllerbuttons(cont, block, xco, yco, width);
+ if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
+ }
+ else {
+ cpack(0x999999);
+ glRecti(xco+22, yco, xco+width-22,yco+19);
+ but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 100, 19, cont, 0, 0, 0, 0, "Controller type");
+ uiButSetFunc(but, sca_move_controller, cont, NULL);
+ but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+122), yco,(short)(width-166), 19, cont, 0, 0, 0, 0, "Controller name");
+ uiButSetFunc(but, sca_move_controller, cont, NULL);
+ ycoo= yco;
+ }
+
+ but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, "");
+ uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
+
+ uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, cont, LINK_CONTROLLER, 0, 0, 0, "");
+ /* offset is >0 if at least one controller was displayed */
+ offset++;
+ yco-=20;
+ }
+ cont= cont->next;
+ }
- sens= sens->next;
}
yco-= 6;
}
}
-
+
/* ******************************* */
- xco= 675; yco= 170; width= 230;
+ xco= 375; yco= 170; width= 250;
uiBlockSetEmboss(block, UI_EMBOSSP);
- uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, 19, "");
+ uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 70, 19, "");
uiBlockSetEmboss(block, UI_EMBOSS);
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_CONT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_CONT_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator");
+ uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+80, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
+ uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+80+(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
+ uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+80+2*(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
+ uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "Sta", xco+80+3*(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states");
uiBlockEndAlign(block);
- ob= OBACT;
-
for(a=0; a<count; a++) {
ob= (Object *)idar[a];
uiClearButLock();
uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if( (ob->scavisflag & OB_VIS_CONT) == 0) continue;
-
+
+ if( (ob->scavisflag & OB_VIS_SENS) == 0) continue;
+
/* presume it is only objects for now */
uiBlockSetEmboss(block, UI_EMBOSS);
uiBlockBeginAlign(block);
- if(ob->controllers.first) uiSetCurFont(block, UI_HELVB);
- uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 0, 0, 0, "Active Object name");
- if(ob->controllers.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller");
+ if(ob->sensors.first) uiSetCurFont(block, UI_HELVB);
+ uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors");
+ if(ob->sensors.first) uiSetCurFont(block, UI_HELV);
+ uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor");
uiBlockEndAlign(block);
yco-=20;
- if(ob->scaflag & OB_SHOWCONT) {
-
- cont= ob->controllers.first;
- while(cont) {
- uiBlockSetEmboss(block, UI_EMBOSSM);
- uiDefIconButBitS(block, TOG, CONT_DEL, B_DEL_CONT, ICON_X, xco, yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Delete Controller");
- uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Controller settings");
-
- if(cont->flag & CONT_SHOW) {
- cont->otype= cont->type;
- uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 100, 19, &cont->type, 0, 0, 0, 0, "Controller type");
- but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, cont->name, 0, 31, 0, 0, "Controller name");
- uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0);
-
- ycoo= yco;
- yco= draw_controllerbuttons(cont, block, xco, yco, width);
- if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- cpack(0x999999);
- glRecti(xco+22, yco, xco+width-22,yco+19);
- but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 100, 19, cont, 0, 0, 0, 0, "Controller type");
- uiButSetFunc(but, sca_move_controller, cont, NULL);
- but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+122), yco,(short)(width-144), 19, cont, 0, 0, 0, 0, "Controller name");
- uiButSetFunc(but, sca_move_controller, cont, NULL);
+ if(ob->scaflag & OB_SHOWSENS) {
+
+ sens= ob->sensors.first;
+ while(sens) {
+ if (!(G.buts->scaflag & BUTS_SENS_STATE) ||
+ sens->totlinks == 0 || /* always display sensor without links so that is can be edited */
+ is_sensor_linked(block, sens)) {
+ sens->flag |= SENS_VISIBLE;
+ uiBlockSetEmboss(block, UI_EMBOSSM);
+ uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X, xco, yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Delete Sensor");
+ uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Sensor settings");
+
ycoo= yco;
+ if(sens->flag & SENS_SHOW)
+ {
+ uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 100, 19, &sens->type, 0, 0, 0, 0, "Sensor type");
+ but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, sens->name, 0, 31, 0, 0, "Sensor name");
+ uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0);
+
+ sens->otype= sens->type;
+ yco= draw_sensorbuttons(sens, block, xco, yco, width,ob->id.name);
+ if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
+ }
+ else {
+ set_col_sensor(sens->type, 1);
+ glRecti(xco+22, yco, xco+width-22,yco+19);
+ but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 100, 19, sens, 0, 0, 0, 0, "");
+ uiButSetFunc(but, sca_move_sensor, sens, NULL);
+ but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+122), yco, (short)(width-144), 19, sens, 0, 31, 0, 0, "");
+ uiButSetFunc(but, sca_move_sensor, sens, NULL);
+ }
+
+ but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, "");
+ uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
+
+ yco-=20;
}
-
- but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, cont, LINK_CONTROLLER, 0, 0, 0, "");
-
- yco-=20;
-
- cont= cont->next;
+ sens= sens->next;
}
yco-= 6;
}
}
-
+
/* ******************************* */
- xco= 985; yco= 170; width= 280;
+ xco= 1040; yco= 170; width= 280;
uiBlockSetEmboss(block, UI_EMBOSSP);
- uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 100, 19, "");
+ uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 90, 19, "");
uiBlockSetEmboss(block, UI_EMBOSS);
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-110)/3, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-110)/3, yco+35, (width-110)/3, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
+ uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
+ uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
+ uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
+ uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "Sta", xco+110+3*(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states");
uiBlockEndAlign(block);
for(a=0; a<count; a++) {
ob= (Object *)idar[a];
@@ -2859,34 +3187,38 @@ void logic_buts(void)
act= ob->actuators.first;
while(act) {
- uiBlockSetEmboss(block, UI_EMBOSSM);
- uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X, xco, yco, 22, 19, &act->flag, 0, 0, 0, 0, "Delete Actuator");
- uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Actuator settings");
+ if (!(G.buts->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_VISIBLE; /* mark the actuator as visible to help implementing the up/down action */
+ uiBlockSetEmboss(block, UI_EMBOSSM);
+ uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X, xco, yco, 22, 19, &act->flag, 0, 0, 0, 0, "Delete Actuator");
+ uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Actuator settings");
+
+ if(act->flag & ACT_SHOW) {
+ act->otype= act->type;
+ uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 100, 19, &act->type, 0, 0, 0, 0, "Actuator type");
+ but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, act->name, 0, 31, 0, 0, "Actuator name");
+ uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0);
+
+ ycoo= yco;
+ yco= draw_actuatorbuttons(ob, act, block, xco, yco, width);
+ if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
+ }
+ else {
+ set_col_actuator(act->type, 1);
+ glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19));
+ but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 100, 19, act, 0, 0, 0, 0, "Actuator type");
+ uiButSetFunc(but, sca_move_actuator, act, NULL);
+ but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+122), yco, (short)(width-144), 19, act, 0, 0, 0, 0, "Actuator name");
+ uiButSetFunc(but, sca_move_actuator, act, NULL);
+ ycoo= yco;
+ }
- if(act->flag & ACT_SHOW) {
- act->otype= act->type;
- uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 100, 19, &act->type, 0, 0, 0, 0, "Actuator type");
- but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-144), 19, act->name, 0, 31, 0, 0, "Actuator name");
- uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0);
+ uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, act, LINK_ACTUATOR, 0, 0, 0, "");
- ycoo= yco;
- yco= draw_actuatorbuttons(act, block, xco, yco, width);
- if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- set_col_actuator(act->type, 1);
- glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19));
- but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 100, 19, act, 0, 0, 0, 0, "Actuator type");
- uiButSetFunc(but, sca_move_actuator, act, NULL);
- but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+122), yco, (short)(width-144), 19, act, 0, 0, 0, 0, "Actuator name");
- uiButSetFunc(but, sca_move_actuator, act, NULL);
- ycoo= yco;
+ yco-=20;
}
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, act, LINK_ACTUATOR, 0, 0, 0, "");
-
- yco-=20;
-
act= act->next;
}
yco-= 6;