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-08-17 00:45:37 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-08-17 00:45:37 +0400
commitfda00bc034de33371c4c7471467889f7d33c780b (patch)
tree4f239406f7bafb931d74ab11088f6239f3822eef /source/blender/src/buttons_logic.c
parentae42934c935c654d4ec29c2156a8ebe212f3652e (diff)
BGE patch: New Delay sensor (derived from patch #17472)
Introduction of a new Delay sensor that can be used to generate positive and negative triggers at precise time, expressed in number of frames. The delay parameter defines the length of the initial OFF period. A positive trigger is generated at the end of this period. The duration parameter defines the length of the ON period following the OFF period. A negative trigger is generated at the end of the ON period. If duration is 0, the sensor stays ON and there is no negative trigger. The sensor runs the OFF-ON cycle once unless the repeat option is set: the OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0). The new generic SCA_ISensor::reset() Python function can be used at any time to restart the sensor: the current cycle is interrupted and no trigger is generated.
Diffstat (limited to 'source/blender/src/buttons_logic.c')
-rw-r--r--source/blender/src/buttons_logic.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index cdb66714573..e16e058e093 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -683,6 +683,8 @@ static char *sensor_name(int type)
return "Property";
case SENS_ACTUATOR:
return "Actuator";
+ case SENS_DELAY:
+ return "Delay";
case SENS_MOUSE:
return "Mouse";
case SENS_COLLISION:
@@ -704,7 +706,7 @@ static char *sensor_name(int type)
static char *sensor_pup(void)
{
/* the number needs to match defines in game.h */
- return "Sensors %t|Always %x0|Keyboard %x3|Mouse %x5|"
+ return "Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5|"
"Touch %x1|Collision %x6|Near %x2|Radar %x7|"
"Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12";
}
@@ -1000,6 +1002,7 @@ static int get_col_sensor(int type)
{
switch(type) {
case SENS_ALWAYS: return TH_BUT_ACTION;
+ case SENS_DELAY: return TH_BUT_ACTION;
case SENS_TOUCH: return TH_BUT_NEUTRAL;
case SENS_COLLISION: return TH_BUT_SETTING;
case SENS_NEAR: return TH_BUT_SETTING1;
@@ -1070,8 +1073,8 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
bRaySensor *raySens = NULL;
bMessageSensor *mes = NULL;
bJoystickSensor *joy = NULL;
- bActuatorSensor *as = NULL;
-
+ bActuatorSensor *as = NULL;
+ bDelaySensor *ds = NULL;
short ysize;
char *str;
@@ -1297,6 +1300,27 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
yco-= ysize;
break;
}
+ case SENS_DELAY:
+ {
+ ysize= 48;
+
+ glRects(xco, yco-ysize, xco+width, yco);
+ uiEmboss((float)xco, (float)yco-ysize,
+ (float)xco+width, (float)yco, 1);
+
+ draw_default_sensor_header(sens, block, xco, yco, width);
+ ds = sens->data;
+
+ uiDefButS(block, NUM, 0, "Delay",(short)(10+xco),(short)(yco-44),(short)((width-22)*0.4+10), 19,
+ &ds->delay, 0.0, 5000.0, 0, 0, "Delay in number of frames before the positive trigger");
+ uiDefButS(block, NUM, 0, "Dur",(short)(10+xco+(width-22)*0.4+10),(short)(yco-44),(short)((width-22)*0.4-10), 19,
+ &ds->duration, 0.0, 5000.0, 0, 0, "If >0, delay in number of frames before the negative trigger following the positive trigger");
+ uiDefButBitS(block, TOG, SENS_DELAY_REPEAT, 0, "REP",(short)(xco + 10 + (width-22)*0.8),(short)(yco - 44),
+ (short)(0.20 * (width-22)), 19, &ds->flag, 0.0, 0.0, 0, 0,
+ "Toggle repeat option. If selected, the sensor restarts after Delay+Dur frames");
+ yco-= ysize;
+ break;
+ }
case SENS_MOUSE:
{
ms= sens->data;