feat: store current scene in user metadata

Related to #40
This commit is contained in:
Swann Martinez 2020-03-05 16:19:13 +01:00
parent d8f49ff298
commit fe9a096ab2
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
2 changed files with 16 additions and 10 deletions

View File

@ -236,7 +236,7 @@ class ClientUpdate(Timer):
local_user_metadata = local_user.get('metadata') local_user_metadata = local_user.get('metadata')
current_view_corners = presence.get_view_corners() current_view_corners = presence.get_view_corners()
scene_current = bpy.context.scene.name
if not local_user_metadata or 'color' not in local_user_metadata.keys(): if not local_user_metadata or 'color' not in local_user_metadata.keys():
metadata = { metadata = {
'view_corners': current_view_corners, 'view_corners': current_view_corners,
@ -245,7 +245,8 @@ class ClientUpdate(Timer):
settings.client_color.g, settings.client_color.g,
settings.client_color.b, settings.client_color.b,
1), 1),
'frame_current':bpy.context.scene.frame_current 'frame_current':bpy.context.scene.frame_current,
'scene_current': scene_current
} }
session.update_user_metadata(metadata) session.update_user_metadata(metadata)
elif current_view_corners != local_user_metadata['view_corners']: elif current_view_corners != local_user_metadata['view_corners']:
@ -253,6 +254,9 @@ class ClientUpdate(Timer):
local_user_metadata['view_corners'] = current_view_corners local_user_metadata['view_corners'] = current_view_corners
local_user_metadata['view_matrix'] = presence.get_view_matrix() local_user_metadata['view_matrix'] = presence.get_view_matrix()
session.update_user_metadata(local_user_metadata) session.update_user_metadata(local_user_metadata)
elif scene_current != local_user_metadata['scene_current']:
local_user_metadata['scene_current'] = scene_current
session.update_user_metadata(local_user_metadata)
# sync online users # sync online users
session_users = operators.client.online_users session_users = operators.client.online_users
@ -260,12 +264,9 @@ class ClientUpdate(Timer):
for index, user in enumerate(ui_users): for index, user in enumerate(ui_users):
if user.username not in session_users.keys(): if user.username not in session_users.keys():
ui_users.remove(index) ui_users.remove(index)
renderer.flush_selection() renderer.flush_selection()
renderer.flush_users() renderer.flush_users()
break break
for user in session_users: for user in session_users:

View File

@ -266,8 +266,10 @@ class SESSION_PT_user(bpy.types.Panel):
# Create a simple row. # Create a simple row.
row = layout.row() row = layout.row()
box = row.box() box = row.box()
split = box.split(factor=0.5) split = box.split(factor=0.3)
split.label(text="user") split.label(text="user")
split = split.split(factor=0.5)
split.label(text="localisation")
split.label(text="frame") split.label(text="frame")
split.label(text="ping") split.label(text="ping")
@ -297,6 +299,7 @@ class SESSION_UL_users(bpy.types.UIList):
is_local_user = item.username == settings.username is_local_user = item.username == settings.username
ping = '-' ping = '-'
frame_current = '-' frame_current = '-'
scene_current = '-'
if session: if session:
user = session.online_users.get(item.username) user = session.online_users.get(item.username)
if user: if user:
@ -304,12 +307,14 @@ class SESSION_UL_users(bpy.types.UIList):
metadata = user.get('metadata') metadata = user.get('metadata')
if metadata and 'frame_current' in metadata: if metadata and 'frame_current' in metadata:
frame_current = str(metadata['frame_current']) frame_current = str(metadata['frame_current'])
scene_current = metadata['scene_current']
split = layout.split(factor=0.5) split = layout.split(factor=0.3)
split.label(text=item.username) split.label(text=item.username)
split = split.split(factor=0.5)
split.label(text=scene_current)
split.label(text=frame_current) split.label(text=frame_current)
split.label(text=ping) split.label(text=ping)
class SESSION_PT_presence(bpy.types.Panel): class SESSION_PT_presence(bpy.types.Panel):
bl_idname = "MULTIUSER_MODULE_PT_panel" bl_idname = "MULTIUSER_MODULE_PT_panel"