@ -93,6 +93,15 @@ class ReplicatedDatablock(bpy.types.PropertyGroup):
|
|||||||
auto_push: bpy.props.BoolProperty(default=True)
|
auto_push: bpy.props.BoolProperty(default=True)
|
||||||
icon: bpy.props.StringProperty()
|
icon: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
class SessionUser(bpy.types.PropertyGroup):
|
||||||
|
"""Session User
|
||||||
|
|
||||||
|
Blender user information property
|
||||||
|
"""
|
||||||
|
username: bpy.props.StringProperty(name="username")
|
||||||
|
current_frame: bpy.props.IntProperty(name="current_frame")
|
||||||
|
|
||||||
|
|
||||||
class SessionProps(bpy.types.PropertyGroup):
|
class SessionProps(bpy.types.PropertyGroup):
|
||||||
username: bpy.props.StringProperty(
|
username: bpy.props.StringProperty(
|
||||||
name="Username",
|
name="Username",
|
||||||
@ -226,6 +235,7 @@ class SessionProps(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
SessionUser,
|
||||||
ReplicatedDatablock,
|
ReplicatedDatablock,
|
||||||
SessionProps,
|
SessionProps,
|
||||||
|
|
||||||
@ -254,7 +264,10 @@ def register():
|
|||||||
bpy.types.WindowManager.session = bpy.props.PointerProperty(
|
bpy.types.WindowManager.session = bpy.props.PointerProperty(
|
||||||
type=SessionProps)
|
type=SessionProps)
|
||||||
bpy.types.ID.uuid = bpy.props.StringProperty(default="")
|
bpy.types.ID.uuid = bpy.props.StringProperty(default="")
|
||||||
|
bpy.types.WindowManager.online_users = bpy.props.CollectionProperty(
|
||||||
|
type=SessionUser
|
||||||
|
)
|
||||||
|
bpy.types.WindowManager.user_index = bpy.props.IntProperty()
|
||||||
bpy.context.window_manager.session.load()
|
bpy.context.window_manager.session.load()
|
||||||
|
|
||||||
presence.register()
|
presence.register()
|
||||||
|
@ -16,10 +16,18 @@ class BlUser(BlDatablock):
|
|||||||
bl_automatic_push = True
|
bl_automatic_push = True
|
||||||
bl_icon = 'CON_ARMATURE'
|
bl_icon = 'CON_ARMATURE'
|
||||||
|
|
||||||
def construct(self, name):
|
def construct(self, data):
|
||||||
return presence.User()
|
user = bpy.data.window_managers['WinMan'].online_users.add()
|
||||||
|
user.name = self.uuid
|
||||||
|
user.username = data['name']
|
||||||
|
user.current_frame = data['current_frame']
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
|
if self.pointer is None:
|
||||||
|
self.set_pointer()
|
||||||
|
|
||||||
|
self.load(self.data,self.pointer)
|
||||||
|
|
||||||
for obj in bpy.data.objects:
|
for obj in bpy.data.objects:
|
||||||
if obj.hide_select and obj.uuid not in self.data['selected_objects']:
|
if obj.hide_select and obj.uuid not in self.data['selected_objects']:
|
||||||
obj.hide_select = False
|
obj.hide_select = False
|
||||||
@ -30,13 +38,16 @@ class BlUser(BlDatablock):
|
|||||||
|
|
||||||
self.state = UP
|
self.state = UP
|
||||||
|
|
||||||
|
def load(self, data, target):
|
||||||
|
target.current_frame = data['current_frame']
|
||||||
|
|
||||||
def dump(self, pointer=None):
|
def dump(self, pointer=None):
|
||||||
data = utils.dump_anything.dump(pointer)
|
data = utils.dump_anything.dump(pointer)
|
||||||
data['location'] = pointer.location
|
data['location'] = pointer.location
|
||||||
data['color'] = pointer.color
|
data['color'] = pointer.color
|
||||||
data['selected_objects'] = pointer.selected_objects
|
data['selected_objects'] = pointer.selected_objects
|
||||||
data['view_matrix'] = pointer.view_matrix
|
data['view_matrix'] = pointer.view_matrix
|
||||||
data['current_keyframe'] = bpy.context.scene.frame_current
|
data['current_frame'] = bpy.context.scene.frame_current
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -44,7 +55,7 @@ class BlUser(BlDatablock):
|
|||||||
self.pointer.is_dirty = True
|
self.pointer.is_dirty = True
|
||||||
|
|
||||||
def resolve(self):
|
def resolve(self):
|
||||||
pass
|
self.pointer = bpy.data.window_managers['WinMan'].online_users.get(self.uuid)
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return True
|
return True
|
||||||
|
@ -51,6 +51,17 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global client, delayables, ui_context
|
global client, delayables, ui_context
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
|
users = bpy.data.window_managers['WinMan'].online_users
|
||||||
|
|
||||||
|
# TODO: Sync server clients
|
||||||
|
|
||||||
|
users.clear()
|
||||||
|
#load our infos into the local user list
|
||||||
|
local_user = users.add()
|
||||||
|
local_user.name = 'localhost'
|
||||||
|
local_user.username = settings.username
|
||||||
|
local_user.current_frame = context.scene.frame_current
|
||||||
|
|
||||||
# save config
|
# save config
|
||||||
settings.save(context)
|
settings.save(context)
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class SESSION_PT_settings_replication(bpy.types.Panel):
|
|||||||
|
|
||||||
class SESSION_PT_user(bpy.types.Panel):
|
class SESSION_PT_user(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_USER_PT_panel"
|
bl_idname = "MULTIUSER_USER_PT_panel"
|
||||||
bl_label = "Users"
|
bl_label = "Online users"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
bl_category = "Multiuser"
|
||||||
@ -179,47 +179,41 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
online_users = context.window_manager.online_users
|
||||||
|
selected_user = context.window_manager.user_index
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
|
active_user = online_users[selected_user] if len(online_users)-1>=selected_user else 0
|
||||||
|
|
||||||
|
|
||||||
# Create a simple row.
|
# Create a simple row.
|
||||||
col = layout.column(align=True)
|
row = layout.row()
|
||||||
|
box = row.box()
|
||||||
client_keys = operators.client.list(filter=BlUser)
|
split = box.split(factor=0.3)
|
||||||
if client_keys and len(client_keys) > 0:
|
split.label(text="user")
|
||||||
for key in client_keys:
|
split.label(text="frame")
|
||||||
area_msg = col.row(align=True)
|
split.label(text="ping")
|
||||||
item_box = area_msg.box()
|
|
||||||
client = operators.client.get(uuid=key).data
|
|
||||||
|
|
||||||
info = ""
|
|
||||||
|
|
||||||
detail_item_row = item_box.row(align=True)
|
|
||||||
|
|
||||||
if client.get('name'):
|
|
||||||
username = client['name']
|
|
||||||
|
|
||||||
is_local_user = username == settings.username
|
|
||||||
|
|
||||||
if is_local_user:
|
|
||||||
info = "(self)"
|
|
||||||
|
|
||||||
detail_item_row.label(
|
|
||||||
text="{} {}".format(username, info))
|
|
||||||
|
|
||||||
detail_item_row.label(
|
|
||||||
text="{}".format(client.get('current_keyframe')))
|
|
||||||
|
|
||||||
if not is_local_user:
|
|
||||||
detail_item_row.operator(
|
|
||||||
"session.snapview",
|
|
||||||
text="",
|
|
||||||
icon='VIEW_CAMERA').target_client = key
|
|
||||||
row = layout.row(align=True)
|
|
||||||
else:
|
|
||||||
row.label(text="Empty")
|
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
layout.template_list("SESSION_UL_users", "", context.window_manager, "online_users", context.window_manager, "user_index")
|
||||||
|
|
||||||
|
if active_user != 0 and active_user.username != settings.username:
|
||||||
|
row = layout.row()
|
||||||
|
user_operations = row.split()
|
||||||
|
user_operations.operator(
|
||||||
|
"session.snapview",
|
||||||
|
text="",
|
||||||
|
icon='VIEW_CAMERA').target_client = online_users[selected_user].name
|
||||||
|
|
||||||
|
|
||||||
|
class SESSION_UL_users(bpy.types.UIList):
|
||||||
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
|
||||||
|
settings = context.window_manager.session
|
||||||
|
is_local_user = item.username == settings.username
|
||||||
|
|
||||||
|
split = layout.split(factor=0.3)
|
||||||
|
split.label(text=item.username)
|
||||||
|
split.label(text=str(item.current_frame))
|
||||||
|
split.label(text='-')
|
||||||
|
|
||||||
|
|
||||||
class SESSION_PT_presence(bpy.types.Panel):
|
class SESSION_PT_presence(bpy.types.Panel):
|
||||||
@ -368,6 +362,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
SESSION_UL_users,
|
||||||
SESSION_PT_settings,
|
SESSION_PT_settings,
|
||||||
SESSION_PT_settings_user,
|
SESSION_PT_settings_user,
|
||||||
SESSION_PT_settings_network,
|
SESSION_PT_settings_network,
|
||||||
|
Reference in New Issue
Block a user