Revision: 21722
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21722
Author:   campbellbarton
Date:     2009-07-20 18:21:55 +0200 (Mon, 20 Jul 2009)

Log Message:
-----------
BGE Button types panel, can edit existing buttons but not add new ones yet.
World Physics panel too though Im not sure if we'll eventually move this into 
another struct.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_world.py
    branches/blender2.5/blender/release/ui/space_logic.py
    branches/blender2.5/blender/source/blender/blenkernel/BKE_property.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/property.c
    
branches/blender2.5/blender/source/blender/editors/space_logic/logic_buttons.c
    
branches/blender2.5/blender/source/blender/editors/space_logic/logic_window.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_property_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_world.c

Modified: branches/blender2.5/blender/release/ui/buttons_world.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_world.py     2009-07-20 
16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/release/ui/buttons_world.py     2009-07-20 
16:21:55 UTC (rev 21722)
@@ -175,7 +175,27 @@
                col.row().itemR(ao, "blend_mode", expand=True)
                col.row().itemR(ao, "color", expand=True)
                col.itemR(ao, "energy")
+               
+class WORLD_PT_game(WorldButtonsPanel):
+       __label__ = "Game Settings"
 
+       def draw(self, context):
+               layout = self.layout
+               world = context.world
+               
+               flow = layout.column_flow()
+               flow.itemR(world, "physics_engine")
+               flow.itemR(world, "physics_gravity")
+               
+               flow.itemR(world, "game_fps")
+               flow.itemR(world, "game_logic_step_max")
+               flow.itemR(world, "game_physics_substep")
+               flow.itemR(world, "game_physics_step_max")
+               
+               flow.itemR(world, "game_use_occlusion_culling", text="Enable 
Occlusion Culling")
+               flow.itemR(world, "game_occlusion_culling_resolution")
+               
+
 bpy.types.register(WORLD_PT_context_world)     
 bpy.types.register(WORLD_PT_preview)
 bpy.types.register(WORLD_PT_world)
@@ -183,3 +203,4 @@
 bpy.types.register(WORLD_PT_mist)
 bpy.types.register(WORLD_PT_stars)
 bpy.types.register(WORLD_PT_color_correction)
+bpy.types.register(WORLD_PT_game)

Modified: branches/blender2.5/blender/release/ui/space_logic.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_logic.py       2009-07-20 
16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/release/ui/space_logic.py       2009-07-20 
16:21:55 UTC (rev 21722)
@@ -75,7 +75,7 @@
        def draw(self, context):
                layout = self.layout
                
-               ob = context.scene.objects[0]
+               ob = context.active_object
                game = ob.game
                
                flow = layout.column_flow()
@@ -84,5 +84,28 @@
                flow.itemR(game, "collision_compound")
                flow.itemR(game, "collision_margin")
 
+class LOGIC_PT_properties(bpy.types.Panel):
+       __space_type__ = "LOGIC_EDITOR"
+       __region_type__ = "UI"
+       __label__ = "Properties"
+
+       def poll(self, context):
+               ob = context.active_object
+               return ob and ob.game
+       
+       def draw(self, context):
+               layout = self.layout
+               
+               ob = context.active_object
+               game = ob.game
+               
+               for prop in game.properties:
+                       flow = layout.row()
+                       flow.itemR(prop, "name", text="")
+                       flow.itemR(prop, "type", text="")
+                       flow.itemR(prop, "value", text="") # we dont care about 
the type. rna will display correctly
+                       flow.itemR(prop, "debug")
+
 bpy.types.register(LOGIC_PT_physics)
 bpy.types.register(LOGIC_PT_collision_bounds)
+bpy.types.register(LOGIC_PT_properties)

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_property.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_property.h        
2009-07-20 16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_property.h        
2009-07-20 16:21:55 UTC (rev 21722)
@@ -41,6 +41,7 @@
 void copy_properties(struct ListBase *lbn, struct ListBase *lbo);
 void init_property(struct bProperty *prop);
 struct bProperty *new_property(int type);
+void unique_property(struct bProperty *first, struct  bProperty *prop, int 
force);
 struct bProperty *get_ob_property(struct Object *ob, char *name);
 void set_ob_property(struct Object *ob, struct bProperty *propc);
 int compare_property(struct bProperty *prop, char *str);

Modified: 
branches/blender2.5/blender/source/blender/blenkernel/intern/property.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/property.c     
2009-07-20 16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/property.c     
2009-07-20 16:21:55 UTC (rev 21722)
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -99,25 +100,18 @@
        if(prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
        prop->poin= 0;
        
-       prop->otype= prop->type;
        prop->data= 0;
        
        switch(prop->type) {
        case GPROP_BOOL:
-               prop->poin= &prop->data;
-               break;
        case GPROP_INT:
-               prop->poin= &prop->data;
-               break;
        case GPROP_FLOAT:
+       case GPROP_TIME:
                prop->poin= &prop->data;
                break;
        case GPROP_STRING:
                prop->poin= MEM_callocN(MAX_PROPSTRING, "property string");
                break;
-       case GPROP_TIME:
-               prop->poin= &prop->data;
-               break;
        }
 }
 
@@ -136,6 +130,60 @@
        return prop;
 }
 
+/* used by unique_property() only */
+static bProperty *get_property__internal(bProperty *first, bProperty *self, 
const char *name)
+{
+       bProperty *p;
+       for(p= first; p; p= p->next) {
+               if (p!=self && (strcmp(p->name, name)==0))
+                       return p;
+       }
+       return NULL;
+}
+void unique_property(bProperty *first, bProperty *prop, int force)
+{
+       bProperty *p;
+
+       /* set the first if its not set */
+       if(first==NULL) {
+               first= prop;
+               while(first->prev) {
+                       first= first->prev;
+               }
+       }
+
+       if(force) {
+               /* change other names to make them unique */
+               while((p = get_property__internal(first, prop, prop->name))) {
+                       unique_property(first, p, 0);
+               }
+       }else {
+               /* change our own name until its unique */
+               if(get_property__internal(first, prop, prop->name)) {
+                       /* there is a collision */
+                       char new_name[sizeof(prop->name)];
+                       char base_name[sizeof(prop->name)];
+                       char num[sizeof(prop->name)];
+                       int i= 0;
+
+                       /* strip numbers */
+                       strcpy(base_name, prop->name);
+                       for(i= strlen(base_name)-1; (i>=0 && 
isdigit(base_name[i])); i--) {
+                               base_name[i]= '\0';
+                       }
+                       i= 0;
+
+                       do { /* ensure we have enough chars for the new number 
in the name */
+                               sprintf(num, "%d", i++);
+                               BLI_strncpy(new_name, base_name, 
sizeof(prop->name) - strlen(num));
+                               strcat(new_name, num);
+                       } while(get_property__internal(first, prop, new_name));
+
+                       strcpy(prop->name, new_name);
+               }
+       }
+}
+
 bProperty *get_ob_property(Object *ob, char *name)
 {
        bProperty *prop;

Modified: 
branches/blender2.5/blender/source/blender/editors/space_logic/logic_buttons.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_logic/logic_buttons.c  
    2009-07-20 16:06:03 UTC (rev 21721)
+++ 
branches/blender2.5/blender/source/blender/editors/space_logic/logic_buttons.c  
    2009-07-20 16:21:55 UTC (rev 21722)
@@ -66,6 +66,7 @@
 
 #include "logic_intern.h"
 
+#if 0
 static void do_logic_panel_events(bContext *C, void *arg, int event)
 {
        
@@ -96,12 +97,12 @@
        uiBlockSetHandleFunc(block, do_logic_panel_events, NULL);
        
 }      
+#endif
 
-
 void logic_buttons_register(ARegionType *art)
 {
        PanelType *pt;
-
+#if 0
        pt= MEM_callocN(sizeof(PanelType), "spacetype logic panel properties");
        strcpy(pt->idname, "LOGIC_PT_properties");
        strcpy(pt->label, "Logic Properties");
@@ -113,6 +114,7 @@
        strcpy(pt->label, "View Properties");
        pt->draw= logic_panel_view_properties;
        BLI_addtail(&art->paneltypes, pt);
+#endif
 
 }
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_logic/logic_window.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_logic/logic_window.c   
    2009-07-20 16:06:03 UTC (rev 21721)
+++ 
branches/blender2.5/blender/source/blender/editors/space_logic/logic_window.c   
    2009-07-20 16:21:55 UTC (rev 21722)
@@ -393,7 +393,7 @@
                BLI_addtail(&ob->prop, prop);
                ED_undo_push(C, "Add property");
                break;
-       
+#if 0 // XXX Now done in python
        case B_CHANGE_PROP:
                prop= ob->prop.first;
                while(prop) {
@@ -403,7 +403,7 @@
                        prop= prop->next;
                }
                break;
-       
+#endif
        case B_ADD_SENS:
                for(ob=G.main->object.first; ob; ob=ob->id.next) {
                        if(ob->scaflag & OB_ADDSENS) {

Modified: 
branches/blender2.5/blender/source/blender/makesdna/DNA_property_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_property_types.h    
2009-07-20 16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_property_types.h    
2009-07-20 16:21:55 UTC (rev 21722)
@@ -39,12 +39,9 @@
 typedef struct bProperty {
        struct bProperty *next, *prev;
        char name[32];
-       short type, otype;              /* otype is for buttons, when a 
property type changes */
+       short type, flag;
        int data;                               /* data should be 4 bytes to 
store int,float stuff */
-       int old;                                /* old is for simul */
-       short flag, pad;
-       void *poin;
-       void *oldpoin;                  /* oldpoin is for simul */
+       void *poin;                             /* references data unless its a 
string which is malloc'd */
        
 } bProperty;
 

Modified: 
branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c     
2009-07-20 16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c     
2009-07-20 16:21:55 UTC (rev 21722)
@@ -705,7 +705,7 @@
 
        prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
-       RNA_def_property_struct_type(prop, "GameProperty");
+       RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */
        RNA_def_property_ui_text(prop, "Properties", "Game engine properties.");
 
        prop= RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE);

Modified: 
branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c   
2009-07-20 16:06:03 UTC (rev 21721)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c   
2009-07-20 16:21:55 UTC (rev 21722)
@@ -33,6 +33,8 @@
 
 #ifdef RNA_RUNTIME
 
+#include "BKE_property.h"
+
 static StructRNA* rna_GameProperty_refine(struct PointerRNA *ptr)
 {
        bProperty *property= (bProperty*)ptr->data;
@@ -67,6 +69,24 @@
        *(float*)(&prop->data)= value;
 }
 
+static void rna_GameProperty_type_set(PointerRNA *ptr, int value)
+{
+       bProperty *prop= (bProperty*)(ptr->data);
+
+       if(prop->type != value) {
+               prop->type= value;
+               init_property(prop);
+       }
+}
+
+static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value)
+{
+       bProperty *prop= (bProperty*)(ptr->data);
+       BLI_strncpy(prop->name, value, sizeof(prop->name));
+       unique_property(NULL, prop, 1);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to