BGE Logic UI: more sensors + rna fixes + actuator empty draw functions (+ camera...
authorDalai Felinto <dfelinto@gmail.com>
Tue, 4 May 2010 07:34:46 +0000 (07:34 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Tue, 4 May 2010 07:34:46 +0000 (07:34 +0000)
source/blender/editors/space_logic/logic_window.c
source/blender/makesdna/DNA_sensor_types.h
source/blender/makesrna/intern/rna_actuator.c
source/blender/makesrna/intern/rna_sensor.c

index 6e145a69139d28f3cbcfa7bacc2fb6cdaed265fd..4e13b278eb0707bb12a6324f9f228aa8e6db4a01 100644 (file)
@@ -3249,7 +3249,43 @@ static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr)
 
 static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr)
 {
-       //XXXSENSOR
+       uiLayout *col, *row;
+
+       uiItemR(layout, ptr, "joystick_index", 0, NULL, 0);
+       uiItemR(layout, ptr, "event_type", 0, NULL, 0);
+
+       switch (RNA_enum_get(ptr, "event_type")) {
+               case SENS_JOY_BUTTON:
+                       uiItemR(layout, ptr, "all_events", 0, NULL, 0);
+
+                       col = uiLayoutColumn(layout, 0);
+                       uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_events")==0);
+                       uiItemR(col, ptr, "button_number", 0, NULL, 0);
+                       break;
+               case SENS_JOY_AXIS:
+                       row = uiLayoutRow(layout, 0);
+                       uiItemR(row, ptr, "axis_number", 0, NULL, 0);
+                       uiItemR(row, ptr, "axis_threshold", 0, NULL, 0);
+
+                       uiItemR(layout, ptr, "all_events", 0, NULL, 0);
+                       col = uiLayoutColumn(layout, 0);
+                       uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_events")==0);
+                       uiItemR(col, ptr, "axis_direction", 0, NULL, 0);
+                       break;
+               case SENS_JOY_HAT:
+                       uiItemR(layout, ptr, "hat_number", 0, NULL, 0);
+                       uiItemR(layout, ptr, "all_events", 0, NULL, 0);
+
+                       col = uiLayoutColumn(layout, 0);
+                       uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_events")==0);
+                       uiItemR(col, ptr, "hat_direction", 0, NULL, 0); //XXXSENSOR - needs a default value (somewhere else in the code)
+                       break;
+               case SENS_JOY_AXIS_SINGLE:
+                       row = uiLayoutRow(layout, 0);
+                       uiItemR(row, ptr, "single_axis_number", 0, NULL, 0);
+                       uiItemR(row, ptr, "axis_threshold", 0, NULL, 0);
+                       break;
+       }
 }
 
 static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr)
@@ -3316,8 +3352,8 @@ static void draw_sensor_radar(uiLayout *layout, PointerRNA *ptr)
        uiItemR(layout, ptr, "axis", 0, NULL, 0);
 
        row= uiLayoutRow(layout, 0);
-       uiItemR(layout, ptr, "angle", 0, NULL, 0);
-       uiItemR(layout, ptr, "distance", 0, NULL, 0);
+       uiItemR(row, ptr, "angle", 0, NULL, 0);
+       uiItemR(row, ptr, "distance", 0, NULL, 0);
 }
 
 static void draw_sensor_random(uiLayout *layout, PointerRNA *ptr)
@@ -3327,7 +3363,17 @@ static void draw_sensor_random(uiLayout *layout, PointerRNA *ptr)
 
 static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr)
 {
-       //XXXSENSOR
+       uiItemR(layout, ptr, "ray_type", 0, NULL, 0);
+       switch (RNA_enum_get(ptr, "ray_type")) {
+               case SENS_RAY_PROPERTY:
+                       uiItemR(layout, ptr, "property", 0, NULL, 0); break;
+               case SENS_RAY_MATERIAL:
+                       uiItemR(layout, ptr, "material", 0, NULL, 0); break;
+       }
+       uiItemR(layout, ptr, "x_ray_mode", 0, NULL, 0);
+       uiItemR(layout, ptr, "range", 0, NULL, 0);
+       uiItemR(layout, ptr, "axis", 0, NULL, 0);
+       //XXXSENSOR - same problem as collision. enums badly used by UI code
 }
 
 static void draw_sensor_touch(uiLayout *layout, PointerRNA *ptr)
@@ -3482,6 +3528,87 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr)
        uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove");
 }
 
+static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr)
+{
+       uiLayout *row;
+       uiItemR(layout, ptr, "object", 0, NULL, 0);
+
+       row = uiLayoutRow(layout, 0);
+       uiItemR(row, ptr, "height", 0, NULL, 0);
+       uiItemR(row, ptr, "axis", 0, NULL, 0);
+
+       row = uiLayoutRow(layout, 0);
+       uiItemR(row, ptr, "min", 0, NULL, 0);
+       uiItemR(row, ptr, "max", 0, NULL, 0);
+}
+
+static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_game(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr)
+{
+       uiLayout *row;
+
+       uiItemR(layout, ptr, "mode", 0, NULL, 0);
+       uiItemR(layout, ptr, "object", 0, NULL, 0);
+
+       row = uiLayoutRow(layout, 0);
+       uiItemR(row, ptr, "compound", 0, NULL, 0);
+       uiItemR(row, ptr, "ghost", 0, NULL, 0);
+}
+
+static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
 static void draw_actuator_scene(uiLayout *layout, PointerRNA *ptr)
 {
        uiItemR(layout, ptr, "mode", 0, NULL, 0);
@@ -3489,12 +3616,24 @@ static void draw_actuator_scene(uiLayout *layout, PointerRNA *ptr)
        uiItemR(layout, ptr, "scene", 0, NULL, 0);
 }
 
-static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr)
+static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr)
 {
-       uiItemR(layout, ptr, "mode", 0, NULL, 0);
-       uiItemR(layout, ptr, "object", 0, NULL, 0);
-       uiItemR(layout, ptr, "compound", 0, NULL, 0);
-       uiItemR(layout, ptr, "ghost", 0, NULL, 0);
+       //XXXACTUATOR
+}
+
+static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
+}
+
+static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr)
+{
+       //XXXACTUATOR
 }
 
 void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr)
@@ -3507,12 +3646,60 @@ void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr)
        box = uiLayoutBox(layout);
        
        switch (RNA_enum_get(ptr, "type")) {
+               case ACT_ACTION:
+                       draw_actuator_action(box, ptr);
+                       break;
+               case ACT_ARMATURE:
+                       draw_actuator_armature(box, ptr);
+                       break;
+               case ACT_CAMERA:
+                       draw_actuator_camera(box, ptr);
+                       break;
+               case ACT_CONSTRAINT:
+                       draw_actuator_constraint(box, ptr);
+                       break;
+               case ACT_EDIT_OBJECT:
+                       draw_actuator_edit_object(box, ptr);
+                       break;
+               case ACT_2DFILTER:
+                       draw_actuator_filter_2d(box, ptr);
+                       break;
+               case ACT_GAME:
+                       draw_actuator_game(box, ptr);
+                       break;
+               case ACT_IPO:
+                       draw_actuator_ipo(box, ptr);
+                       break;
+               case ACT_MESSAGE:
+                       draw_actuator_message(box, ptr);
+                       break;
+               case ACT_OBJECT:
+                       draw_actuator_motion(box, ptr);
+                       break;
                case ACT_PARENT:
                        draw_actuator_parent(box, ptr);
                        break;
+               case ACT_PROPERTY:
+                       draw_actuator_property(box, ptr);
+                       break;
+               case ACT_RANDOM:
+                       draw_actuator_random(box, ptr);
+                       break;
                case ACT_SCENE:
                        draw_actuator_scene(box, ptr);
                        break;
+               case ACT_SHAPEACTION:
+                       draw_actuator_shape_action(box, ptr);
+                       break;
+               case ACT_SOUND:
+                       draw_actuator_sound(box, ptr);
+                       break;
+               case ACT_STATE:
+                       draw_actuator_state(box, ptr);
+                       break;
+               case ACT_VISIBILITY:
+                       draw_actuator_visibility(box, ptr);
+                       break;
        }
 }
 
index f8c9097bdc9d0f0acc5d55c5684bb9848e131ea1..6f4b191419ef9cd8f9c34b60e2ce6054f56e5f9b 100644 (file)
@@ -264,8 +264,11 @@ typedef struct bJoystickSensor {
 #define SENS_COLLISION_PROPERTY 0 // uncommenting to use with RNA/UI. will check if it's working/fix it later - dfelinto
 #define SENS_COLLISION_MATERIAL 1
 #define SENS_COLLISION_PULSE 2
+
 /* ray specific mode */
 /* X-Ray means that the ray will traverse objects that don't have the property/material */
+#define SENS_RAY_PROPERTY              0
+#define SENS_RAY_MATERIAL              1
 #define SENS_RAY_XRAY                  2
 
 /* Some stuff for the mouse sensor Type: */
@@ -278,6 +281,7 @@ typedef struct bJoystickSensor {
 #define BL_SENS_MOUSE_MOUSEOVER      16
 #define BL_SENS_MOUSE_MOUSEOVER_ANY     32
 
+/* Joystick sensor - sorted by axis types */
 #define SENS_JOY_ANY_EVENT             1
 
 #define SENS_JOY_BUTTON                0                       /* axis type */
@@ -293,6 +297,16 @@ typedef struct bJoystickSensor {
 
 #define SENS_JOY_HAT                   2               /* axis type */
 #define SENS_JOY_HAT_DIR               0
+#define SENS_JOY_HAT_UP                        1
+#define SENS_JOY_HAT_RIGHT             2
+#define SENS_JOY_HAT_DOWN              4
+#define SENS_JOY_HAT_LEFT              8
+
+#define SENS_JOY_HAT_UP_RIGHT  SENS_JOY_HAT_UP | SENS_JOY_HAT_RIGHT
+#define SENS_JOY_HAT_DOWN_RIGHT        SENS_JOY_HAT_DOWN | SENS_JOY_HAT_RIGHT
+#define SENS_JOY_HAT_UP_LEFT   SENS_JOY_HAT_UP | SENS_JOY_HAT_LEFT
+#define SENS_JOY_HAT_DOWN_LEFT SENS_JOY_HAT_DOWN | SENS_JOY_HAT_LEFT
+
 
 #define SENS_JOY_AXIS_SINGLE   3               /* axis type */
 
index 05ffcf77a30cbf0ae4599d9ef6aeac52c634177a..27c72888e2d528792a62d0ef325391a3ff78a713 100644 (file)
@@ -153,7 +153,8 @@ static void rna_def_object_actuator(BlenderRNA *brna)
        RNA_def_struct_sdna_from(srna, "bObjectActuator", "data");
 
 
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Motion Type", "Specify the motion system");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -422,6 +423,8 @@ static void rna_def_camera_actuator(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, prop_axis_items);
        RNA_def_property_ui_text(prop, "Axis", "Specify the axis the Camera will try to get behind");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
+       //XXX it's not working (no default value)
+       // probably need to make a get/set function
 }
 
 static void rna_def_sound_actuator(BlenderRNA *brna)
@@ -449,7 +452,8 @@ static void rna_def_sound_actuator(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Sound", "Sound file");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
 
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Type", "");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -538,7 +542,8 @@ static void rna_def_property_actuator(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Property Actuator", "Actuator to handle properties");
        RNA_def_struct_sdna_from(srna, "bPropertyActuator", "data");
 
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Mode", "");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -598,7 +603,7 @@ static void rna_def_edit_object_actuator(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Edit Object Actuator", "Actuator used to edit objects");
        RNA_def_struct_sdna_from(srna, "bEditObjectActuator", "data");
 
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Edit Object", "The mode of the actuator");
@@ -926,7 +931,8 @@ static void rna_def_game_actuator(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Game Actuator", "");
        RNA_def_struct_sdna_from(srna, "bGameActuator", "data");
 
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Game", "");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -989,7 +995,8 @@ static void rna_def_twodfilter_actuator(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "2D Filter Actuator", "Actuator to ..");
        RNA_def_struct_sdna_from(srna, "bTwoDFilterActuator", "data");
 
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "2D Filter Type", "");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -1082,7 +1089,8 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Shape Action Actuator", "Actuator to ..");
        RNA_def_struct_sdna_from(srna, "bActionActuator", "data");
        
-       prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Action type", "Action playback type");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
index b4147fba2a646879a0d60e53889a69f051627f1d..81cde49dfbcea7ff537cbdb1bd4bd7db6f438c60 100644 (file)
@@ -478,8 +478,8 @@ static void rna_def_ray_sensor(BlenderRNA *brna)
                {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
                {0, NULL, 0, NULL, NULL}};
        static EnumPropertyItem prop_type_items[] ={
-               {0, "PROPERTY", 0, "Property", ""},
-               {1, "MATERIAL", 0, "Material", ""},
+               {SENS_RAY_PROPERTY, "PROPERTY", 0, "Property", ""},
+               {SENS_RAY_MATERIAL, "MATERIAL", 0, "Material", ""},
                {0, NULL, 0, NULL, NULL}};
 
        srna= RNA_def_struct(brna, "RaySensor", "Sensor");
@@ -543,6 +543,7 @@ static void rna_def_joystick_sensor(BlenderRNA *brna)
                {SENS_JOY_BUTTON, "BUTTON", 0, "Button", ""},
                {SENS_JOY_AXIS, "AXIS", 0, "Axis", ""},
                {SENS_JOY_HAT, "HAT", 0, "Hat", ""},
+               {SENS_JOY_AXIS_SINGLE, "AXIS_SINGLE", 0, "Single Axis", ""},
                {0, NULL, 0, NULL, NULL}};
 
        static EnumPropertyItem axis_direction_items[] ={
@@ -552,13 +553,25 @@ static void rna_def_joystick_sensor(BlenderRNA *brna)
                {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down Axis", ""},
                {0, NULL, 0, NULL, NULL}};
 
+       static EnumPropertyItem hat_direction_items[] ={
+               {SENS_JOY_HAT_UP, "UP", 0, "Up", ""},
+               {SENS_JOY_HAT_DOWN, "DOWN", 0, "Down", ""},
+               {SENS_JOY_HAT_LEFT, "LEFT", 0, "Left", ""},
+               {SENS_JOY_HAT_RIGHT, "RIGHT", 0, "Right", ""},
+
+               {SENS_JOY_HAT_UP_RIGHT, "UPRIGHT", 0, "Up/Right", ""},
+               {SENS_JOY_HAT_DOWN_LEFT, "DOWNLEFT", 0, "Down/Left", ""},
+               {SENS_JOY_HAT_UP_LEFT, "UPLEFT", 0, "Up/Left", ""},
+               {SENS_JOY_HAT_DOWN_RIGHT, "DOWNRIGHT", 0, "Down/Right", ""},
+               {0, NULL, 0, NULL, NULL}};
+
        srna= RNA_def_struct(brna, "JoystickSensor", "Sensor");
        RNA_def_struct_ui_text(srna, "Joystick Sensor", "Sensor to detect joystick events");
        RNA_def_struct_sdna_from(srna, "bJoystickSensor", "data");
        
        prop= RNA_def_property(srna, "joystick_index", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "joyindex");
-       RNA_def_property_ui_text(prop, "Joystick Index", "Specify which joystick to use");
+       RNA_def_property_ui_text(prop, "Index", "Specify which joystick to use");
        RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX-1);
 
        prop= RNA_def_property(srna, "event_type", PROP_ENUM, PROP_NONE);
@@ -592,16 +605,22 @@ static void rna_def_joystick_sensor(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, axis_direction_items);
        RNA_def_property_ui_text(prop, "Axis Direction", "The direction of the axis");
 
+       /* Single Axis */
+       prop= RNA_def_property(srna, "single_axis_number", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "axis_single");
+       RNA_def_property_ui_text(prop, "Axis Number", "Specify a single axis (verticle/horizontal/other) to detect");
+       RNA_def_property_range(prop, 1, 16);
+
        /* Hat */
        prop= RNA_def_property(srna, "hat_number", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "hat");
        RNA_def_property_ui_text(prop, "Hat Number", "Specify which hat to use");
        RNA_def_property_range(prop, 1, 2);
 
-       prop= RNA_def_property(srna, "hat_direction", PROP_INT, PROP_NONE);
-       RNA_def_property_int_sdna(prop, NULL, "hatf");
+       prop= RNA_def_property(srna, "hat_direction", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "hatf");
+       RNA_def_property_enum_items(prop, hat_direction_items);
        RNA_def_property_ui_text(prop, "Hat Direction", "Specify hat direction");
-       RNA_def_property_range(prop, 0, 12);
 }
 
 void RNA_def_sensor(BlenderRNA *brna)