BGE panels: wip
[blender-staging.git] / release / ui / buttons_game.py
1
2 import bpy
3  
4 class GameButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "game"
8
9 class GAME_PT_context_game(GameButtonsPanel):
10         __idname__ = "GAME_PT_context_game"
11         __no_header__ = True
12
13         def draw(self, context):
14                 layout = self.layout
15                 ob = context.object
16                 game = context.game
17
18                 split = layout.split(percentage=0.06)
19                 split.itemL(text="", icon="ICON_GAME")
20                 split.itemR(game, "name", text="")
21
22 class GAME_PT_data(GameButtonsPanel):
23         __idname__ = "GAME_PT_data"
24         __label__ = "Data"
25
26         def draw(self, context):
27                 layout = self.layout
28                 ob = context.object
29                 game = context.game
30
31 class GAME_PT_physics(GameButtonsPanel):
32         __idname__ = "GAME_PT_physics"
33         __label__ = "Physics"
34
35         def poll(self, context):
36                 ob = context.active_object
37                 return ob and ob.game
38
39         def draw(self, context):
40                 layout = self.layout
41                 ob = context.active_object
42                 
43                 game = ob.game
44
45                 flow = layout.column_flow()
46                 flow.active = True
47                 flow.itemR(game, "physics_type")
48                 flow.itemR(game, "actor")
49                 
50                 row = layout.row()
51                 row.itemR(game, "ghost")
52                 row.itemR(ob, "restrict_render", text="Invisible") # out of place but useful
53                 
54                 flow = layout.column_flow()
55                 flow.itemR(game, "mass")
56                 flow.itemR(game, "radius")
57                 flow.itemR(game, "no_sleeping")
58                 flow.itemR(game, "damping")
59                 flow.itemR(game, "rotation_damping")
60                 flow.itemR(game, "minimum_velocity")
61                 flow.itemR(game, "maximum_velocity")
62                 
63                 row = layout.row()
64                 row.itemR(game, "do_fh")
65                 row.itemR(game, "rotation_fh")
66                 
67                 flow = layout.column_flow()
68                 flow.itemR(game, "form_factor")
69                 flow.itemR(game, "anisotropic_friction")
70                 
71                 flow = layout.column_flow()
72                 flow.active = game.anisotropic_friction
73                 flow.itemR(game, "friction_coefficients")
74                 
75                 split = layout.split()
76                 sub = split.column()
77                 sub.itemR(game, "lock_x_axis")
78                 sub.itemR(game, "lock_y_axis")
79                 sub.itemR(game, "lock_z_axis")
80                 sub = split.column()
81                 sub.itemR(game, "lock_x_rot_axis")
82                 sub.itemR(game, "lock_y_rot_axis")
83                 sub.itemR(game, "lock_z_rot_axis")
84
85
86 class GAME_PT_collision_bounds(GameButtonsPanel):
87         __idname__ = "GAME_PT_collision_bounds"
88         __label__ = "Collision Bounds"
89
90         def poll(self, context):
91                 ob = context.active_object
92                 return ob and ob.game
93         
94         def draw_header(self, context):
95                 layout = self.layout
96                 ob = context.active_object
97                 game = ob.game
98
99                 layout.itemR(game, "use_collision_bounds", text="")
100         
101         def draw(self, context):
102                 layout = self.layout
103                 
104                 ob = context.scene.objects[0]
105                 game = ob.game
106                 
107                 flow = layout.column_flow()
108                 flow.active = game.use_collision_bounds
109                 flow.itemR(game, "collision_bounds")
110                 flow.itemR(game, "collision_compound")
111                 flow.itemR(game, "collision_margin")
112
113
114
115 bpy.types.register(GAME_PT_context_game)
116 bpy.types.register(GAME_PT_data)
117 bpy.types.register(GAME_PT_physics)
118 bpy.types.register(GAME_PT_collision_bounds)