From c26e71cd6a848a7419f77264e48facbcaea96348 Mon Sep 17 00:00:00 2001 From: Swann Date: Wed, 18 Sep 2019 23:55:30 +0200 Subject: [PATCH] feat: dynamic right on selection selection progress --- bl_types/bl_object.py | 2 +- delayable.py | 27 +++++++++++++++++++++++++++ operators.py | 4 +++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/bl_types/bl_object.py b/bl_types/bl_object.py index a48ce49..e2dad28 100644 --- a/bl_types/bl_object.py +++ b/bl_types/bl_object.py @@ -38,7 +38,7 @@ class BlObject(BlDatablock): def load(self, data, target): # Load other meshes metadata # utils.dump_anything.load(target, data) - + target.uuid = data['uuid'] target.matrix_world = mathutils.Matrix(data["matrix_world"]) # Load modifiers diff --git a/delayable.py b/delayable.py index 5dc48d1..427e149 100644 --- a/delayable.py +++ b/delayable.py @@ -66,6 +66,33 @@ class ApplyTimer(Timer): return self._timeout +class DynamicRightSelectTimer(Timer): + def __init__(self, timout=1): + super().__init__(timout) + self.last_selection=[] + + def execute(self): + if operators.client: + users = operators.client.list(filter=BlUser) + + for user in users: + user_ref = operators.client.get(uuid=user) + settings = bpy.context.window_manager.session + + if user_ref.buffer['name'] != settings.username: + for obj in bpy.data.objects: + obj.hide_select = obj.name in user_ref.buffer['selected_objects'] + elif user_ref.pointer: + if user_ref.pointer.selected_objects != self.last_selection: + self.last_selection = user_ref.pointer.selected_objects + + # update our rights + for selected_obj in self.last_selection: + node = operators.client.get(reference=bpy.data.objects[selected_obj]) + node.owner = settings.username + operators.client.change_owner(node.uuid, settings.username) + return self._timeout + # class CheckNewTimer(Timer): class RedrawTimer(Timer): diff --git a/operators.py b/operators.py index aa13367..026cff6 100644 --- a/operators.py +++ b/operators.py @@ -135,7 +135,9 @@ class SessionStartOperator(bpy.types.Operator): settings.user_uuid = client.add(usr) delayables.append(delayable.ClientUpdate( client_uuid=settings.user_uuid)) - + + delayables.append(delayable.DynamicRightSelectTimer()) + for node in client.list(): try: client.commit(node)