Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/startup/bl_operators/wm.py')
-rw-r--r--release/scripts/startup/bl_operators/wm.py283
1 files changed, 232 insertions, 51 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 022ee1576d8..b6f77505410 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -19,13 +19,17 @@
# <pep8 compliant>
import bpy
-from bpy.types import Operator
+from bpy.types import (
+ Operator,
+ OperatorFileListElement
+)
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
StringProperty,
+ CollectionProperty,
)
from bpy.app.translations import pgettext_tip as tip_
@@ -55,6 +59,15 @@ rna_relative_prop = BoolProperty(
default=False,
)
+rna_space_type_prop = EnumProperty(
+ name="Type",
+ items=tuple(
+ (e.identifier, e.name, "", e. value)
+ for e in bpy.types.Space.bl_rna.properties["type"].enum_items
+ ),
+ default='EMPTY',
+ )
+
def context_path_validate(context, data_path):
try:
@@ -1089,6 +1102,11 @@ rna_use_soft_limits = BoolProperty(
name="Use Soft Limits",
)
+rna_is_overridable_static = BoolProperty(
+ name="Is Statically Overridable",
+ default=False,
+ )
+
class WM_OT_properties_edit(Operator):
bl_idname = "wm.properties_edit"
@@ -1102,6 +1120,7 @@ class WM_OT_properties_edit(Operator):
min = rna_min
max = rna_max
use_soft_limits = rna_use_soft_limits
+ is_overridable_static = rna_is_overridable_static
soft_min = rna_min
soft_max = rna_max
description = StringProperty(
@@ -1154,6 +1173,9 @@ class WM_OT_properties_edit(Operator):
# print(exec_str)
exec(exec_str)
+ exec_str = "item.property_overridable_static_set('[\"%s\"]', %s)" % (prop, self.is_overridable_static)
+ exec(exec_str)
+
rna_idprop_ui_prop_update(item, prop)
self._last_prop[:] = [prop]
@@ -1281,7 +1303,9 @@ class WM_OT_properties_edit(Operator):
row.prop(self, "min")
row.prop(self, "max")
- layout.prop(self, "use_soft_limits")
+ row = layout.row()
+ row.prop(self, "use_soft_limits")
+ row.prop(self, "is_overridable_static")
row = layout.row(align=True)
row.enabled = self.use_soft_limits
@@ -1492,54 +1516,6 @@ class WM_OT_copy_prev_settings(Operator):
return {'CANCELLED'}
-class WM_OT_blenderplayer_start(Operator):
- """Launch the blender-player with the current blend-file"""
- bl_idname = "wm.blenderplayer_start"
- bl_label = "Start Game In Player"
-
- def execute(self, context):
- import os
- import sys
- import subprocess
-
- gs = context.scene.game_settings
-
- # these remain the same every execution
- blender_bin_path = bpy.app.binary_path
- blender_bin_dir = os.path.dirname(blender_bin_path)
- ext = os.path.splitext(blender_bin_path)[-1]
- player_path = os.path.join(blender_bin_dir, "blenderplayer" + ext)
- # done static vars
-
- if sys.platform == "darwin":
- player_path = os.path.join(blender_bin_dir, "../../../blenderplayer.app/Contents/MacOS/blenderplayer")
-
- if not os.path.exists(player_path):
- self.report({'ERROR'}, "Player path: %r not found" % player_path)
- return {'CANCELLED'}
-
- filepath = bpy.data.filepath + '~' if bpy.data.is_saved else os.path.join(bpy.app.tempdir, "game.blend")
- bpy.ops.wm.save_as_mainfile('EXEC_DEFAULT', filepath=filepath, copy=True)
-
- # start the command line call with the player path
- args = [player_path]
-
- # handle some UI options as command line arguments
- args.extend([
- "-g", "show_framerate", "=", "%d" % gs.show_framerate_profile,
- "-g", "show_profile", "=", "%d" % gs.show_framerate_profile,
- "-g", "show_properties", "=", "%d" % gs.show_debug_properties,
- "-g", "ignore_deprecation_warnings", "=", "%d" % (not gs.use_deprecation_warnings),
- ])
-
- # finish the call with the path to the blend file
- args.append(filepath)
-
- subprocess.call(args)
- os.remove(filepath)
- return {'FINISHED'}
-
-
class WM_OT_keyconfig_test(Operator):
"""Test key-config for conflicts"""
bl_idname = "wm.keyconfig_test"
@@ -1887,6 +1863,37 @@ class WM_OT_addon_disable(Operator):
return {'FINISHED'}
+class WM_OT_owner_enable(Operator):
+ """Enable workspace owner ID"""
+ bl_idname = "wm.owner_enable"
+ bl_label = "Enable Add-on"
+
+ owner_id = StringProperty(
+ name="UI Tag",
+ )
+
+ def execute(self, context):
+ workspace = context.workspace
+ workspace.owner_ids.new(self.owner_id)
+ return {'FINISHED'}
+
+
+class WM_OT_owner_disable(Operator):
+ """Enable workspace owner ID"""
+ bl_idname = "wm.owner_disable"
+ bl_label = "Disable UI Tag"
+
+ owner_id = StringProperty(
+ name="UI Tag",
+ )
+
+ def execute(self, context):
+ workspace = context.workspace
+ owner_id = workspace.owner_ids[self.owner_id]
+ workspace.owner_ids.remove(owner_id)
+ return {'FINISHED'}
+
+
class WM_OT_theme_install(Operator):
"""Load and apply a Blender XML theme file"""
bl_idname = "wm.theme_install"
@@ -2332,6 +2339,174 @@ class WM_OT_app_template_install(Operator):
return {'RUNNING_MODAL'}
+class WM_OT_tool_set_by_name(Operator):
+ """Set the tool by name (for keymaps)"""
+ bl_idname = "wm.tool_set_by_name"
+ bl_label = "Set Tool By Name"
+
+ name = StringProperty(
+ name="Text",
+ description="Display name of the tool",
+ )
+
+ cycle = BoolProperty(
+ name="Cycle",
+ description="Cycle through tools in this group",
+ default=False,
+ options={'SKIP_SAVE'},
+ )
+
+ space_type = rna_space_type_prop
+
+ def execute(self, context):
+ from bl_ui.space_toolsystem_common import (
+ activate_by_name,
+ activate_by_name_or_cycle,
+ )
+
+ if self.properties.is_property_set("space_type"):
+ space_type = self.space_type
+ else:
+ space_type = context.space_data.type
+
+ fn = activate_by_name_or_cycle if self.cycle else activate_by_name
+ if fn(context, space_type, self.name):
+ return {'FINISHED'}
+ else:
+ self.report({'WARNING'}, f"Tool {self.name!r} not found.")
+ return {'CANCELLED'}
+
+
+class WM_OT_toolbar(Operator):
+ bl_idname = "wm.toolbar"
+ bl_label = "Toolbar"
+
+ def execute(self, context):
+ from bl_ui.space_toolsystem_common import (
+ ToolSelectPanelHelper,
+ keymap_from_context,
+ )
+ space_type = context.space_data.type
+
+ cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
+ if cls is None:
+ self.report({'WARNING'}, f"Toolbar not found for {space_type!r}")
+ return {'CANCELLED'}
+
+ wm = context.window_manager
+ keymap = keymap_from_context(context, space_type)
+
+ def draw_menu(popover, context):
+ layout = popover.layout
+ cls.draw_cls(layout, context, detect_layout=False, scale_y=1.0)
+
+ wm.popover(draw_menu, keymap=keymap)
+ return {'FINISHED'}
+
+
+# Studio Light operations
+class WM_OT_studiolight_install(Operator):
+ """Install a user defined studio light"""
+ bl_idname = "wm.studiolight_install"
+ bl_label = "Install Custom Studio Light"
+
+ files = CollectionProperty(
+ name="File Path",
+ type=OperatorFileListElement,
+ )
+ directory = StringProperty(
+ subtype='DIR_PATH',
+ )
+ filter_folder = BoolProperty(
+ name="Filter folders",
+ default=True,
+ options={'HIDDEN'},
+ )
+ filter_glob = StringProperty(
+ default="*.png;*.jpg;*.hdr;*.exr",
+ options={'HIDDEN'},
+ )
+ orientation = EnumProperty(
+ items=(
+ ("MATCAP", "MatCap", ""),
+ ("WORLD", "World", ""),
+ ("CAMERA", "Camera", ""),
+ )
+ )
+
+ def execute(self, context):
+ import traceback
+ import shutil
+ import pathlib
+ userpref = context.user_preferences
+
+ filepaths = [pathlib.Path(self.directory, e.name) for e in self.files]
+ path_studiolights = bpy.utils.user_resource('DATAFILES')
+
+ if not path_studiolights:
+ self.report({'ERROR'}, "Failed to get Studio Light path")
+ return {'CANCELLED'}
+
+ path_studiolights = pathlib.Path(path_studiolights, "studiolights", self.orientation.lower())
+ if not path_studiolights.exists():
+ try:
+ path_studiolights.mkdir(parents=True, exist_ok=True)
+ except:
+ traceback.print_exc()
+
+ for filepath in filepaths:
+ shutil.copy(str(filepath), str(path_studiolights))
+ userpref.studio_lights.new(str(path_studiolights.joinpath(filepath.name)), self.orientation)
+
+ # print message
+ msg = (
+ tip_("StudioLight Installed %r into %r") %
+ (", ".join(str(x.name) for x in self.files), str(path_studiolights))
+ )
+ print(msg)
+ self.report({'INFO'}, msg)
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+ wm.fileselect_add(self)
+ return {'RUNNING_MODAL'}
+
+
+class WM_OT_studiolight_uninstall(Operator):
+ bl_idname = 'wm.studiolight_uninstall'
+ bl_label = "Uninstall Studio Light"
+ index = bpy.props.IntProperty()
+
+ def _remove_path(self, path):
+ if path.exists():
+ path.unlink()
+
+ def execute(self, context):
+ import pathlib
+ userpref = context.user_preferences
+ for studio_light in userpref.studio_lights:
+ if studio_light.index == self.index:
+ self._remove_path(pathlib.Path(studio_light.path))
+ self._remove_path(pathlib.Path(studio_light.path_irr_cache))
+ self._remove_path(pathlib.Path(studio_light.path_sh_cache))
+ userpref.studio_lights.remove(studio_light)
+ return {'FINISHED'}
+ return {'CANCELLED'}
+
+
+class WM_OT_studiolight_userpref_show(Operator):
+ """Show light user preferences"""
+ bl_idname = "wm.studiolight_userpref_show"
+ bl_label = ""
+ bl_options = {'INTERNAL'}
+
+ def execute(self, context):
+ context.user_preferences.active_section = 'LIGHTS'
+ bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
+ return {'FINISHED'}
+
+
classes = (
BRUSH_OT_active_index_set,
WM_OT_addon_disable,
@@ -2344,7 +2519,6 @@ classes = (
WM_OT_app_template_install,
WM_OT_appconfig_activate,
WM_OT_appconfig_default,
- WM_OT_blenderplayer_start,
WM_OT_context_collection_boolean_set,
WM_OT_context_cycle_array,
WM_OT_context_cycle_enum,
@@ -2384,5 +2558,12 @@ classes = (
WM_OT_properties_remove,
WM_OT_sysinfo,
WM_OT_theme_install,
+ WM_OT_owner_disable,
+ WM_OT_owner_enable,
WM_OT_url_open,
+ WM_OT_studiolight_install,
+ WM_OT_studiolight_uninstall,
+ WM_OT_studiolight_userpref_show,
+ WM_OT_tool_set_by_name,
+ WM_OT_toolbar,
)