svn merge -r39057:39286 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -379,7 +379,7 @@ def path_reference(filepath,
|
||||
is_relative = filepath.startswith("//")
|
||||
filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src))
|
||||
|
||||
if mode in ('ABSOLUTE', 'RELATIVE', 'STRIP'):
|
||||
if mode in {'ABSOLUTE', 'RELATIVE', 'STRIP'}:
|
||||
pass
|
||||
elif mode == 'MATCH':
|
||||
mode = 'RELATIVE' if is_relative else 'ABSOLUTE'
|
||||
|
||||
@@ -294,7 +294,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
|
||||
'''
|
||||
Normal single concave loop filling
|
||||
'''
|
||||
if type(from_data) in (tuple, list):
|
||||
if type(from_data) in {tuple, list}:
|
||||
verts = [Vector(from_data[i]) for ii, i in enumerate(indices)]
|
||||
else:
|
||||
verts = [from_data.vertices[i].co for ii, i in enumerate(indices)]
|
||||
@@ -312,7 +312,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
|
||||
used twice. This is used by lightwave LWO files a lot
|
||||
'''
|
||||
|
||||
if type(from_data) in (tuple, list):
|
||||
if type(from_data) in {tuple, list}:
|
||||
verts = [vert_treplet(Vector(from_data[i]), ii)
|
||||
for ii, i in enumerate(indices)]
|
||||
else:
|
||||
|
||||
@@ -120,7 +120,7 @@ def fromxml(data):
|
||||
py_item = (xml_node.tagName, _fromxml_kwargs(xml_node), [])
|
||||
#_fromxml_iter(py_item, xml_node.childNodes)
|
||||
for xml_node_child in xml_node.childNodes:
|
||||
if xml_node_child.nodeType not in (xml_node_child.TEXT_NODE, xml_node_child.COMMENT_NODE):
|
||||
if xml_node_child.nodeType not in {xml_node_child.TEXT_NODE, xml_node_child.COMMENT_NODE}:
|
||||
py_item[CHILDREN].append(_fromxml(xml_node_child))
|
||||
return py_item
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ def _parse_rna(prop, value):
|
||||
elif prop.type == 'INT':
|
||||
value = int(value)
|
||||
elif prop.type == 'BOOLEAN':
|
||||
if value in (True, False):
|
||||
if value in {True, False}:
|
||||
pass
|
||||
else:
|
||||
if value not in ("True", "False"):
|
||||
if value not in {"True", "False"}:
|
||||
raise Exception("invalid bool value: %s" % value)
|
||||
value = bool(value == "True")
|
||||
elif prop.type in ('STRING', 'ENUM'):
|
||||
elif prop.type in {'STRING', 'ENUM'}:
|
||||
pass
|
||||
elif prop.type == 'POINTER':
|
||||
value = eval("_bpy." + value)
|
||||
|
||||
@@ -148,7 +148,7 @@ class InfoStructRNA:
|
||||
import types
|
||||
functions = []
|
||||
for identifier, attr in self._get_py_visible_attrs():
|
||||
if type(attr) in (types.FunctionType, types.MethodType):
|
||||
if type(attr) in {types.FunctionType, types.MethodType}:
|
||||
functions.append((identifier, attr))
|
||||
return functions
|
||||
|
||||
@@ -156,7 +156,7 @@ class InfoStructRNA:
|
||||
import types
|
||||
functions = []
|
||||
for identifier, attr in self._get_py_visible_attrs():
|
||||
if type(attr) in (types.BuiltinMethodType, types.BuiltinFunctionType):
|
||||
if type(attr) in {types.BuiltinMethodType, types.BuiltinFunctionType}:
|
||||
functions.append((identifier, attr))
|
||||
return functions
|
||||
|
||||
@@ -260,7 +260,7 @@ class InfoPropertyRNA:
|
||||
if self.array_length:
|
||||
type_str += " array of %d items" % (self.array_length)
|
||||
|
||||
if self.type in ("float", "int"):
|
||||
if self.type in {"float", "int"}:
|
||||
type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max))
|
||||
elif self.type == "enum":
|
||||
if self.is_enum_flag:
|
||||
@@ -595,7 +595,7 @@ def BuildRNAInfo():
|
||||
for prop in rna_info.properties:
|
||||
# ERROR CHECK
|
||||
default = prop.default
|
||||
if type(default) in (float, int):
|
||||
if type(default) in {float, int}:
|
||||
if default < prop.min or default > prop.max:
|
||||
print("\t %s.%s, %s not in [%s - %s]" % (rna_info.identifier, prop.identifier, default, prop.min, prop.max))
|
||||
|
||||
|
||||
@@ -61,13 +61,19 @@ class EditExternally(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
import os
|
||||
import subprocess
|
||||
filepath = os.path.normpath(bpy.path.abspath(self.filepath))
|
||||
|
||||
filepath = self.filepath
|
||||
|
||||
if not filepath:
|
||||
self.report({'ERROR'}, "Image path not set")
|
||||
return {'CANCELLED'}
|
||||
|
||||
filepath = os.path.normpath(bpy.path.abspath(filepath))
|
||||
|
||||
if not os.path.exists(filepath):
|
||||
self.report({'ERROR'},
|
||||
"Image path %r not found, image may be packed or "
|
||||
"unsaved." % filepath)
|
||||
|
||||
return {'CANCELLED'}
|
||||
|
||||
cmd = self._editor_guess(context) + [filepath]
|
||||
|
||||
@@ -23,7 +23,15 @@ import mathutils
|
||||
|
||||
|
||||
class prettyface(object):
|
||||
__slots__ = "uv", "width", "height", "children", "xoff", "yoff", "has_parent", "rot"
|
||||
__slots__ = ("uv",
|
||||
"width",
|
||||
"height",
|
||||
"children",
|
||||
"xoff",
|
||||
"yoff",
|
||||
"has_parent",
|
||||
"rot",
|
||||
)
|
||||
|
||||
def __init__(self, data):
|
||||
self.has_parent = False
|
||||
@@ -263,10 +271,9 @@ def lightmap_uvpack(meshes,
|
||||
del trylens
|
||||
|
||||
def trilensdiff(t1, t2):
|
||||
return\
|
||||
abs(t1[1][t1[2][0]] - t2[1][t2[2][0]]) + \
|
||||
abs(t1[1][t1[2][1]] - t2[1][t2[2][1]]) + \
|
||||
abs(t1[1][t1[2][2]] - t2[1][t2[2][2]])
|
||||
return (abs(t1[1][t1[2][0]] - t2[1][t2[2][0]]) +
|
||||
abs(t1[1][t1[2][1]] - t2[1][t2[2][1]]) +
|
||||
abs(t1[1][t1[2][2]] - t2[1][t2[2][2]]))
|
||||
|
||||
while tri_lengths:
|
||||
tri1 = tri_lengths.pop()
|
||||
@@ -520,7 +527,7 @@ def unwrap(operator, context, **kwargs):
|
||||
if obj and obj.type == 'MESH':
|
||||
meshes = [obj.data]
|
||||
else:
|
||||
meshes = {me.name: me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if not me.library if len(me.faces)}.values()
|
||||
meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.faces and me.library is None})
|
||||
|
||||
if not meshes:
|
||||
operator.report({'ERROR'}, "No mesh object.")
|
||||
@@ -543,22 +550,51 @@ class LightMapPack(bpy.types.Operator):
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
PREF_CONTEXT = bpy.props.EnumProperty(
|
||||
name="Selection",
|
||||
description="",
|
||||
items=(("SEL_FACES", "Selected Faces", "Space all UVs evently"),
|
||||
("ALL_FACES", "All Faces", "Average space UVs edge length of each loop"),
|
||||
("ALL_OBJECTS", "Selected Mesh Object", "Average space UVs edge length of each loop")
|
||||
),
|
||||
name="Selection",
|
||||
description="")
|
||||
)
|
||||
|
||||
# Image & UVs...
|
||||
PREF_PACK_IN_ONE = BoolProperty(name="Share Tex Space", default=True, description="Objects Share texture space, map all objects into 1 uvmap")
|
||||
PREF_NEW_UVLAYER = BoolProperty(name="New UV Layer", default=False, description="Create a new UV layer for every mesh packed")
|
||||
PREF_APPLY_IMAGE = BoolProperty(name="New Image", default=False, description="Assign new images for every mesh (only one if shared tex space enabled)")
|
||||
PREF_IMG_PX_SIZE = IntProperty(name="Image Size", min=64, max=5000, default=512, description="Width and Height for the new image")
|
||||
|
||||
PREF_PACK_IN_ONE = BoolProperty(
|
||||
name="Share Tex Space",
|
||||
description=("Objects Share texture space, map all objects "
|
||||
"into 1 uvmap"),
|
||||
default=True,
|
||||
)
|
||||
PREF_NEW_UVLAYER = BoolProperty(
|
||||
name="New UV Layer",
|
||||
description="Create a new UV layer for every mesh packed",
|
||||
default=False,
|
||||
)
|
||||
PREF_APPLY_IMAGE = BoolProperty(
|
||||
name="New Image",
|
||||
description=("Assign new images for every mesh (only one if "
|
||||
"shared tex space enabled)"),
|
||||
default=False,
|
||||
)
|
||||
PREF_IMG_PX_SIZE = IntProperty(
|
||||
name="Image Size",
|
||||
description="Width and Height for the new image",
|
||||
min=64, max=5000,
|
||||
default=512,
|
||||
)
|
||||
# UV Packing...
|
||||
PREF_BOX_DIV = IntProperty(name="Pack Quality", min=1, max=48, default=12, description="Pre Packing before the complex boxpack")
|
||||
PREF_MARGIN_DIV = FloatProperty(name="Margin", min=0.001, max=1.0, default=0.1, description="Size of the margin as a division of the UV")
|
||||
PREF_BOX_DIV = IntProperty(
|
||||
name="Pack Quality",
|
||||
description="Pre Packing before the complex boxpack",
|
||||
min=1, max=48,
|
||||
default=12,
|
||||
)
|
||||
PREF_MARGIN_DIV = FloatProperty(
|
||||
name="Margin",
|
||||
description="Size of the margin as a division of the UV",
|
||||
min=0.001, max=1.0,
|
||||
default=0.1,
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
kwargs = self.as_keywords()
|
||||
|
||||
@@ -586,7 +586,7 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
|
||||
self._values_clear()
|
||||
return {'FINISHED'}
|
||||
|
||||
elif event_type in ('RIGHTMOUSE', 'ESC'):
|
||||
elif event_type in {'RIGHTMOUSE', 'ESC'}:
|
||||
self._values_restore()
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -839,7 +839,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
||||
|
||||
prop_ui = rna_idprop_ui_prop_get(item, prop)
|
||||
|
||||
if prop_type in (float, int):
|
||||
if prop_type in {float, int}:
|
||||
|
||||
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.min)
|
||||
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max)
|
||||
|
||||
@@ -361,7 +361,7 @@ class DATA_PT_paragraph(CurveButtonsPanel, bpy.types.Panel):
|
||||
col.prop(text, "offset_y", text="Y")
|
||||
|
||||
|
||||
class DATA_PT_textboxes(CurveButtonsPanel, bpy.types.Panel):
|
||||
class DATA_PT_text_boxes(CurveButtonsPanel, bpy.types.Panel):
|
||||
bl_label = "Text Boxes"
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -462,7 +462,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel):
|
||||
col.prop(part, "mass")
|
||||
col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
|
||||
|
||||
if part.physics_type in ('NEWTON', 'FLUID'):
|
||||
if part.physics_type in {'NEWTON', 'FLUID'}:
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
@@ -921,7 +921,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel):
|
||||
col = row.column()
|
||||
col.label(text="")
|
||||
|
||||
if part.render_type in ('OBJECT', 'GROUP') and not part.use_advanced_hair:
|
||||
if part.render_type in {'OBJECT', 'GROUP'} and not part.use_advanced_hair:
|
||||
row = layout.row(align=True)
|
||||
row.prop(part, "particle_size")
|
||||
row.prop(part, "size_random", slider=True)
|
||||
|
||||
@@ -354,7 +354,7 @@ class INFO_MT_help(bpy.types.Menu):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
|
||||
layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-258/'
|
||||
layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-259/'
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -924,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
|
||||
@@ -1045,17 +1076,25 @@ class WM_OT_addon_enable(bpy.types.Operator):
|
||||
bl_idname = "wm.addon_enable"
|
||||
bl_label = "Enable Add-On"
|
||||
|
||||
module = StringProperty(name="Module", description="Module name of the addon to enable")
|
||||
module = StringProperty(
|
||||
name="Module",
|
||||
description="Module name of the addon to enable",
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
mod = addon_utils.enable(self.module)
|
||||
|
||||
if mod:
|
||||
# check if add-on is written for current blender version, or raise a warning
|
||||
info = addon_utils.module_bl_info(mod)
|
||||
|
||||
if info.get("blender", (0, 0, 0)) > bpy.app.version:
|
||||
self.report("WARNING','This script was written for a newer version of Blender and might not function (correctly).\nThe script is enabled though.")
|
||||
info_ver = info.get("blender", (0, 0, 0))
|
||||
|
||||
if info_ver > bpy.app.version:
|
||||
self.report({'WARNING'}, ("This script was written Blender "
|
||||
"version %d.%d.%d and might not "
|
||||
"function (correctly).\n"
|
||||
"The script is enabled though.") %
|
||||
info_ver)
|
||||
return {'FINISHED'}
|
||||
else:
|
||||
return {'CANCELLED'}
|
||||
|
||||
@@ -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,7 +263,6 @@ 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)
|
||||
@@ -282,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()
|
||||
@@ -352,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)
|
||||
@@ -363,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):
|
||||
@@ -372,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()
|
||||
@@ -398,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)
|
||||
@@ -548,22 +542,24 @@ class WM_OT_keyconfig_import(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
from os.path import basename
|
||||
import shutil
|
||||
if not self.filepath:
|
||||
raise Exception("Filepath not set")
|
||||
|
||||
f = open(self.filepath, "r")
|
||||
if not f:
|
||||
raise Exception("Could not open file")
|
||||
if not self.filepath:
|
||||
self.report({'ERROR'}, "Filepath not set")
|
||||
return {'CANCELLED'}
|
||||
|
||||
config_name = basename(self.filepath)
|
||||
|
||||
path = bpy.utils.user_resource('SCRIPTS', os.path.join("presets", "keyconfig"), create=True)
|
||||
path = os.path.join(path, config_name)
|
||||
|
||||
if self.keep_original:
|
||||
shutil.copy(self.filepath, path)
|
||||
else:
|
||||
shutil.move(self.filepath, path)
|
||||
try:
|
||||
if self.keep_original:
|
||||
shutil.copy(self.filepath, path)
|
||||
else:
|
||||
shutil.move(self.filepath, path)
|
||||
except Exception as e:
|
||||
self.report({'ERROR'}, "Installing keymap failed: %s" % e)
|
||||
return {'CANCELLED'}
|
||||
|
||||
# sneaky way to check we're actually running the code.
|
||||
bpy.utils.keyconfig_set(path)
|
||||
@@ -609,7 +605,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
|
||||
@@ -619,7 +615,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)
|
||||
@@ -669,17 +667,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"
|
||||
@@ -691,7 +678,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
|
||||
@@ -710,13 +697,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'}
|
||||
@@ -753,7 +740,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
|
||||
|
||||
@@ -349,30 +349,6 @@ class VIEW3D_MT_view_navigation(bpy.types.Menu):
|
||||
layout.operator("view3d.fly")
|
||||
|
||||
|
||||
class VIEW3D_MT_ndof_settings(bpy.types.Menu):
|
||||
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 VIEW3D_MT_view_align(bpy.types.Menu):
|
||||
bl_label = "Align View"
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class ModalOperator(bpy.types.Operator):
|
||||
elif event.type == 'LEFTMOUSE':
|
||||
return {'FINISHED'}
|
||||
|
||||
elif event.type in ('RIGHTMOUSE', 'ESC'):
|
||||
elif event.type in {'RIGHTMOUSE', 'ESC'}:
|
||||
context.object.location.x = self.first_value
|
||||
return {'CANCELLED'}
|
||||
|
||||
@@ -47,4 +47,4 @@ if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
# test call
|
||||
bpy.ops.object.modal_operator()
|
||||
bpy.ops.object.modal_operator('INVOKE_DEFAULT')
|
||||
|
||||
@@ -45,7 +45,7 @@ class ModalDrawOperator(bpy.types.Operator):
|
||||
context.region.callback_remove(self._handle)
|
||||
return {'FINISHED'}
|
||||
|
||||
elif event.type in ('RIGHTMOUSE', 'ESC'):
|
||||
elif event.type in {'RIGHTMOUSE', 'ESC'}:
|
||||
context.region.callback_remove(self._handle)
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class ModalTimerOperator(bpy.types.Operator):
|
||||
|
||||
def modal(self, context, event):
|
||||
if event.type == 'ESC':
|
||||
return self.cancel()
|
||||
return self.cancel(context)
|
||||
|
||||
if event.type == 'TIMER':
|
||||
# change theme color, silly!
|
||||
|
||||
@@ -29,7 +29,7 @@ class ViewOperator(bpy.types.Operator):
|
||||
context.area.header_text_set()
|
||||
return {'FINISHED'}
|
||||
|
||||
elif event.type in ('RIGHTMOUSE', 'ESC'):
|
||||
elif event.type in {'RIGHTMOUSE', 'ESC'}:
|
||||
rv3d.view_location = self._initial_location
|
||||
context.area.header_text_set()
|
||||
return {'CANCELLED'}
|
||||
|
||||
Reference in New Issue
Block a user