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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'amaranth/scene')
-rw-r--r--amaranth/scene/current_blend.py2
-rwxr-xr-xamaranth/scene/debug.py47
-rw-r--r--amaranth/scene/goto_library.py4
-rw-r--r--amaranth/scene/save_reload.py21
4 files changed, 57 insertions, 17 deletions
diff --git a/amaranth/scene/current_blend.py b/amaranth/scene/current_blend.py
index 7ab855c4..11ac3679 100644
--- a/amaranth/scene/current_blend.py
+++ b/amaranth/scene/current_blend.py
@@ -36,7 +36,7 @@ class FILEBROWSER_PT_amaranth(bpy.types.Panel):
@classmethod
def poll(cls, context):
- return panel_poll_is_upper_region(context.region)
+ return context.area.ui_type == 'FILES' and panel_poll_is_upper_region(context.region)
def draw(self, context):
layout = self.layout
diff --git a/amaranth/scene/debug.py b/amaranth/scene/debug.py
index 38692743..4f702d08 100755
--- a/amaranth/scene/debug.py
+++ b/amaranth/scene/debug.py
@@ -65,7 +65,8 @@ class AMTH_store_data():
'TEXTURE': [], # Textures (Psys, Brushes)
'MODIFIER': [], # Modifiers
'MESH_DATA': [], # Vertex Colors
- 'VIEW3D': [], # Background Images
+ 'OUTLINER_OB_CAMERA': [], # Background Images in Cameras
+ 'OUTLINER_OB_EMPTY': [], # Empty type Image
'NODETREE': [], # Compositor
}
libraries = [] # Libraries x type
@@ -632,6 +633,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
if name not in AMTH_store_data.users['MATERIAL']:
AMTH_store_data.users['MATERIAL'].append(name)
+
# Check Lights
for la in d.lights:
# Cycles
@@ -643,6 +645,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
no.image and no.image.name == x:
if la.name not in AMTH_store_data.users['LIGHT']:
AMTH_store_data.users['LIGHT'].append(la.name)
+
# Check World
for wo in d.worlds:
# Cycles
@@ -654,6 +657,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
no.image and no.image.name == x:
if wo.name not in AMTH_store_data.users['WORLD']:
AMTH_store_data.users['WORLD'].append(wo.name)
+
# Check Textures
for te in d.textures:
if te and te.type == 'IMAGE' and te.image:
@@ -662,6 +666,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
if name == x and \
name not in AMTH_store_data.users['TEXTURE']:
AMTH_store_data.users['TEXTURE'].append(te.name)
+
# Check Modifiers in Objects
for ob in d.objects:
for mo in ob.modifiers:
@@ -672,21 +677,31 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
name = '"{0}" modifier in {1}'.format(mo.name, ob.name)
if name not in AMTH_store_data.users['MODIFIER']:
AMTH_store_data.users['MODIFIER'].append(name)
- # Check Background Images in Viewports
- for scr in d.screens:
- for ar in scr.areas:
- if ar.type == 'VIEW_3D':
- if ar.spaces and \
- ar.spaces.active and \
- ar.spaces.active.background_images:
- for bg in ar.spaces.active.background_images:
- image = bg.image
-
- if bg and image and image.name == x:
- name = 'Background for 3D Viewport in Screen "{0}"'\
- .format(scr.name)
- if name not in AMTH_store_data.users['VIEW3D']:
- AMTH_store_data.users['VIEW3D'].append(name)
+
+ # Check Background Images in Cameras
+ for ob in d.objects:
+ if ob and ob.type == 'CAMERA' and ob.data.background_images:
+ for bg in ob.data.background_images:
+ image = bg.image
+
+ if bg and image and image.name == x:
+ name = 'Used as background for Camera "{0}"'\
+ .format(ob.name)
+ if name not in AMTH_store_data.users['OUTLINER_OB_CAMERA']:
+ AMTH_store_data.users['OUTLINER_OB_CAMERA'].append(name)
+
+ # Check Empties type Image
+ for ob in d.objects:
+ if ob and ob.type == 'EMPTY' and ob.image_user:
+ if ob.image_user.id_data.data:
+ image = ob.image_user.id_data.data
+
+ if image and image.name == x:
+ name = 'Used in Empty "{0}"'\
+ .format(ob.name)
+ if name not in AMTH_store_data.users['OUTLINER_OB_EMPTY']:
+ AMTH_store_data.users['OUTLINER_OB_EMPTY'].append(name)
+
# Check the Compositor
for sce in d.scenes:
if sce.node_tree and sce.node_tree.nodes:
diff --git a/amaranth/scene/goto_library.py b/amaranth/scene/goto_library.py
index b1ea9e5b..d38a62d3 100644
--- a/amaranth/scene/goto_library.py
+++ b/amaranth/scene/goto_library.py
@@ -19,6 +19,10 @@ class AMTH_FILE_PT_libraries(bpy.types.Panel):
bl_category = "Bookmarks"
bl_label = "Libraries"
+ @classmethod
+ def poll(cls, context):
+ return context.area.ui_type == 'FILES'
+
def draw(self, context):
layout = self.layout
diff --git a/amaranth/scene/save_reload.py b/amaranth/scene/save_reload.py
index f3bedb5e..ece61246 100644
--- a/amaranth/scene/save_reload.py
+++ b/amaranth/scene/save_reload.py
@@ -13,6 +13,23 @@ import bpy
KEYMAPS = list()
+def check_for_unsaved_images(self):
+ im_unsaved = []
+
+ for im in bpy.data.images:
+ if im.is_dirty:
+ im_unsaved.append(im.name)
+
+ if im_unsaved:
+ report_text = 'There are unsaved changes in {0} image(s), check console for details.'\
+ .format(len(im_unsaved))
+ self.report({"WARNING"}, report_text)
+
+ print("\nAmaranth found unsaved images when trying to save and reload.")
+ for im in im_unsaved:
+ print('* Image: "' + im + '" has unsaved changes.')
+ return True
+ return
class AMTH_WM_OT_save_reload(bpy.types.Operator):
"""Save and Reload the current blend file"""
@@ -23,6 +40,10 @@ class AMTH_WM_OT_save_reload(bpy.types.Operator):
if not path:
bpy.ops.wm.save_as_mainfile("INVOKE_AREA")
return
+
+ if check_for_unsaved_images(self):
+ return
+
bpy.ops.wm.save_mainfile()
self.report({"INFO"}, "Saved & Reloaded")
bpy.ops.wm.open_mainfile("EXEC_DEFAULT", filepath=path)