Merged changes in the trunk up to revision 39117.

This commit is contained in:
Tamito Kajiyama
2011-08-07 11:13:56 +00:00
133 changed files with 4838 additions and 2440 deletions

View File

@@ -32,6 +32,7 @@ import bpy as _bpy
error_duplicates = False
error_encoding = False
def paths():
@@ -51,14 +52,18 @@ def paths():
def modules(module_cache):
global error_duplicates
global error_encoding
import os
error_duplicates = False
error_encoding = False
path_list = paths()
# fake module importing
def fake_module(mod_name, mod_path, speedy=True):
global error_encoding
if _bpy.app.debug:
print("fake_module", mod_path, mod_name)
import ast
@@ -69,12 +74,28 @@ def modules(module_cache):
line_iter = iter(file_mod)
l = ""
while not l.startswith("bl_info"):
l = line_iter.readline()
try:
l = line_iter.readline()
except UnicodeDecodeError as e:
if not error_encoding:
error_encoding = True
print("Error reading file as UTF-8:", mod_path, e)
file_mod.close()
return None
if len(l) == 0:
break
while l.rstrip():
lines.append(l)
l = line_iter.readline()
try:
l = line_iter.readline()
except UnicodeDecodeError as e:
if not error_encoding:
error_encoding = True
print("Error reading file as UTF-8:", mod_path, e)
file_mod.close()
return None
data = "".join(lines)
else:

View File

@@ -136,7 +136,7 @@ def display_name(name):
def display_name_from_filepath(name):
"""
Returns the path stripped of directort and extension,
Returns the path stripped of directory and extension,
ensured to be utf8 compatible.
"""
name = _os.path.splitext(basename(name))[0]
@@ -204,7 +204,7 @@ def resolve_ncase(path):
def ensure_ext(filepath, ext, case_sensitive=False):
"""
Return the path with the extension added its its not alredy set.
Return the path with the extension added if it is not already set.
:arg ext: The extension to check for.
:type ext: string

View File

@@ -37,6 +37,15 @@ import bpy
from bpy.props import StringProperty, BoolProperty, EnumProperty
def _check_axis_conversion(op):
if hasattr(op, "axis_forward") and hasattr(op, "axis_up"):
return axis_conversion_ensure(op,
"axis_forward",
"axis_up",
)
return False
class ExportHelper:
filepath = StringProperty(
name="File Path",
@@ -70,21 +79,22 @@ class ExportHelper:
return {'RUNNING_MODAL'}
def check(self, context):
change_ext = False
change_axis = _check_axis_conversion(self)
check_extension = self.check_extension
if check_extension is None:
return False
if check_extension is not None:
filepath = bpy.path.ensure_ext(self.filepath,
self.filename_ext
if check_extension
else "")
filepath = bpy.path.ensure_ext(self.filepath,
self.filename_ext
if check_extension
else "")
if filepath != self.filepath:
self.filepath = filepath
change_ext = True
if filepath != self.filepath:
self.filepath = filepath
return True
return False
return (change_ext or change_axis)
class ImportHelper:
@@ -99,6 +109,9 @@ class ImportHelper:
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def check(self, context):
return _check_axis_conversion(self)
# Axis conversion function, not pretty LUT
# use lookup tabes to convert between any axis

View File

@@ -1,8 +1,7 @@
import bpy
is_ntsc = (bpy.context.scene.render.fps != 25)
bpy.context.scene.render.ffmpeg_format = "AVI"
bpy.context.scene.render.ffmpeg_codec = "XVID"
bpy.context.scene.render.ffmpeg_format = "XVID"
if is_ntsc:
bpy.context.scene.render.ffmpeg_gopsize = 18

View File

@@ -247,15 +247,17 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel):
row.prop(mat, "diffuse_fresnel_factor", text="Factor")
if mat.use_diffuse_ramp:
layout.separator()
layout.template_color_ramp(mat, "diffuse_ramp", expand=True)
layout.separator()
col = layout.column()
col.active = (not mat.use_shadeless)
col.separator()
col.template_color_ramp(mat, "diffuse_ramp", expand=True)
col.separator()
row = layout.row()
row = col.row()
row.prop(mat, "diffuse_ramp_input", text="Input")
row.prop(mat, "diffuse_ramp_blend", text="Blend")
layout.prop(mat, "diffuse_ramp_factor", text="Factor")
col.prop(mat, "diffuse_ramp_factor", text="Factor")
class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel):

View File

@@ -755,6 +755,31 @@ class USERPREF_PT_file(bpy.types.Panel):
from bl_ui.space_userpref_keymap import InputKeyMapPanel
class USERPREF_MT_ndof_settings(bpy.types.Menu):
# accessed from the window keybindings in C (only)
bl_label = "3D Mouse Settings"
def draw(self, context):
layout = self.layout
input_prefs = context.user_preferences.inputs
layout.separator()
layout.prop(input_prefs, "ndof_sensitivity")
if context.space_data.type == 'VIEW_3D':
layout.separator()
layout.prop(input_prefs, "ndof_show_guide")
layout.separator()
layout.label(text="orbit options")
layout.prop(input_prefs, "ndof_orbit_invert_axes")
layout.separator()
layout.label(text="fly options")
layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
@@ -817,12 +842,9 @@ class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel):
#sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
col.separator()
''' not implemented yet
sub = col.column()
sub.label(text="NDOF Device:")
sub.prop(inputs, "ndof_pan_speed", text="Pan Speed")
sub.prop(inputs, "ndof_rotate_speed", text="Orbit Speed")
'''
sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity")
row.separator()
@@ -881,7 +903,7 @@ class USERPREF_PT_addons(bpy.types.Panel):
if not user_addon_paths:
user_script_path = bpy.utils.user_script_path()
if user_script_path is not None:
user_addon_paths.append(os.path.join(user_script_path(), "addons"))
user_addon_paths.append(os.path.join(user_script_path, "addons"))
user_addon_paths.append(os.path.join(bpy.utils.resource_path('USER'), "scripts", "addons"))
for path in user_addon_paths:
@@ -927,6 +949,12 @@ class USERPREF_PT_addons(bpy.types.Panel):
"(see console for details)",
)
if addon_utils.error_encoding:
self.draw_error(col,
"One or more addons do not have UTF-8 encoding\n"
"(see console for details)",
)
filter = context.window_manager.addon_filter
search = context.window_manager.addon_search.lower()
support = context.window_manager.addon_support

View File

@@ -188,10 +188,10 @@ class InputKeyMapPanel:
if km.is_modal:
row.label(text="", icon='LINKED')
if km.is_user_defined:
if km.is_user_modified:
row.operator("wm.keymap_restore", text="Restore")
else:
row.operator("wm.keymap_edit", text="Edit")
row.label()
if km.show_expanded_children:
if children:
@@ -212,7 +212,6 @@ class InputKeyMapPanel:
# "Add New" at end of keymap item list
col = self.indented_layout(col, level + 1)
subcol = col.split(percentage=0.2).column()
subcol.enabled = km.is_user_defined
subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
col.separator()
@@ -243,7 +242,7 @@ class InputKeyMapPanel:
col = self.indented_layout(layout, level)
if km.is_user_defined:
if kmi.show_expanded:
col = col.column(align=True)
box = col.box()
else:
@@ -256,7 +255,6 @@ class InputKeyMapPanel:
row.prop(kmi, "show_expanded", text="", emboss=False)
row = split.row()
row.enabled = km.is_user_defined
row.prop(kmi, "active", text="", emboss=False)
if km.is_modal:
@@ -265,12 +263,13 @@ class InputKeyMapPanel:
row.label(text=kmi.name)
row = split.row()
row.enabled = km.is_user_defined
row.prop(kmi, "map_type", text="")
if map_type == 'KEYBOARD':
row.prop(kmi, "type", text="", full_event=True)
elif map_type == 'MOUSE':
row.prop(kmi, "type", text="", full_event=True)
elif map_type == 'NDOF':
row.prop(kmi, "type", text="", full_event=True)
elif map_type == 'TWEAK':
subrow = row.row()
subrow.prop(kmi, "type", text="")
@@ -280,18 +279,17 @@ class InputKeyMapPanel:
else:
row.label()
if not kmi.is_user_defined:
if (not kmi.is_user_defined) and kmi.is_user_modified:
op = row.operator("wm.keyitem_restore", text="", icon='BACK')
op.item_id = kmi.id
op = row.operator("wm.keyitem_remove", text="", icon='X')
op.item_id = kmi.id
else:
op = row.operator("wm.keyitem_remove", text="", icon='X')
op.item_id = kmi.id
# Expanded, additional event settings
if kmi.show_expanded:
box = col.box()
box.enabled = km.is_user_defined
if map_type not in {'TEXTINPUT', 'TIMER'}:
split = box.split(percentage=0.4)
sub = split.row()
@@ -306,7 +304,7 @@ class InputKeyMapPanel:
sub = split.column()
subrow = sub.row(align=True)
if map_type == 'KEYBOARD':
if map_type in {'KEYBOARD', 'NDOF'}:
subrow.prop(kmi, "type", text="", event=True)
subrow.prop(kmi, "value", text="")
elif map_type == 'MOUSE':
@@ -350,10 +348,10 @@ class InputKeyMapPanel:
row.label()
row.label()
if km.is_user_defined:
if km.is_user_modified:
row.operator("wm.keymap_restore", text="Restore")
else:
row.operator("wm.keymap_edit", text="Edit")
row.label()
for kmi in filtered_items:
self.draw_kmi(display_keymaps, kc, km, kmi, col, 1)
@@ -361,7 +359,6 @@ class InputKeyMapPanel:
# "Add New" at end of keymap item list
col = self.indented_layout(layout, 1)
subcol = col.split(percentage=0.2).column()
subcol.enabled = km.is_user_defined
subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
def draw_hierarchy(self, display_keymaps, layout):
@@ -370,8 +367,7 @@ class InputKeyMapPanel:
def draw_keymaps(self, context, layout):
wm = context.window_manager
kc = wm.keyconfigs.active
defkc = wm.keyconfigs.default
kc = wm.keyconfigs.user
col = layout.column()
sub = col.column()
@@ -396,7 +392,7 @@ class InputKeyMapPanel:
col.separator()
display_keymaps = _merge_keymaps(kc, defkc)
display_keymaps = _merge_keymaps(kc, kc)
if context.space_data.filter_text != "":
filter_text = context.space_data.filter_text.lower()
self.draw_filtered(display_keymaps, filter_text, col)
@@ -590,6 +586,9 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
if not self.filepath:
raise Exception("Filepath not set")
if not self.filepath.endswith('.py'):
self.filepath += '.py'
f = open(self.filepath, "w")
if not f:
raise Exception("Could not open file")
@@ -604,7 +603,7 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
# Generate a list of keymaps to export:
#
# First add all user_defined keymaps (found in inputs.edited_keymaps list),
# First add all user_modified keymaps (found in keyconfigs.user.keymaps list),
# then add all remaining keymaps from the currently active custom keyconfig.
#
# This will create a final list of keymaps that can be used as a 'diff' against
@@ -614,7 +613,9 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
class FakeKeyConfig():
keymaps = []
edited_kc = FakeKeyConfig()
edited_kc.keymaps.extend(context.user_preferences.inputs.edited_keymaps)
for km in wm.keyconfigs.user.keymaps:
if km.is_user_modified:
edited_kc.keymaps.append(km)
# merge edited keymaps with non-default keyconfig, if it exists
if kc != wm.keyconfigs.default:
export_keymaps = _merge_keymaps(edited_kc, kc)
@@ -664,17 +665,6 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
return {'RUNNING_MODAL'}
class WM_OT_keymap_edit(bpy.types.Operator):
"Edit stored key map"
bl_idname = "wm.keymap_edit"
bl_label = "Edit Key Map"
def execute(self, context):
km = context.keymap
km.copy_to_user()
return {'FINISHED'}
class WM_OT_keymap_restore(bpy.types.Operator):
"Restore key map(s)"
bl_idname = "wm.keymap_restore"
@@ -686,7 +676,7 @@ class WM_OT_keymap_restore(bpy.types.Operator):
wm = context.window_manager
if self.all:
for km in wm.keyconfigs.default.keymaps:
for km in wm.keyconfigs.user.keymaps:
km.restore_to_default()
else:
km = context.keymap
@@ -705,13 +695,13 @@ class WM_OT_keyitem_restore(bpy.types.Operator):
@classmethod
def poll(cls, context):
keymap = getattr(context, "keymap", None)
return keymap and keymap.is_user_defined
return keymap
def execute(self, context):
km = context.keymap
kmi = km.keymap_items.from_id(self.item_id)
if not kmi.is_user_defined:
if (not kmi.is_user_defined) and kmi.is_user_modified:
km.restore_item_to_default(kmi)
return {'FINISHED'}
@@ -748,7 +738,7 @@ class WM_OT_keyitem_remove(bpy.types.Operator):
@classmethod
def poll(cls, context):
return hasattr(context, "keymap") and context.keymap.is_user_defined
return hasattr(context, "keymap")
def execute(self, context):
km = context.keymap

View File

@@ -88,8 +88,9 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel):
col = layout.column(align=True)
col.label(text="Shading:")
col.operator("object.shade_smooth", text="Smooth")
col.operator("object.shade_flat", text="Flat")
row = col.row(align=True)
row.operator("object.shade_smooth", text="Smooth")
row.operator("object.shade_flat", text="Flat")
draw_keyframing_tools(context, layout)
@@ -155,8 +156,9 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel):
col = layout.column(align=True)
col.label(text="Shading:")
col.operator("mesh.faces_shade_smooth", text="Smooth")
col.operator("mesh.faces_shade_flat", text="Flat")
row = col.row(align=True)
row.operator("mesh.faces_shade_smooth", text="Smooth")
row.operator("mesh.faces_shade_flat", text="Flat")
draw_repeat_tools(context, layout)