2019-02-08 22:44:02 +08:00
|
|
|
import bpy
|
2019-08-05 23:06:13 +08:00
|
|
|
from . import operators
|
2019-02-08 22:44:02 +08:00
|
|
|
|
2019-04-24 23:42:23 +08:00
|
|
|
|
2019-07-02 23:44:59 +08:00
|
|
|
ICONS = {'Image': 'IMAGE_DATA', 'Curve':'CURVE_DATA', 'Client':'SOLO_ON','Collection': 'FILE_FOLDER', 'Mesh': 'MESH_DATA', 'Object': 'OBJECT_DATA', 'Material': 'MATERIAL_DATA',
|
2019-07-02 22:43:30 +08:00
|
|
|
'Texture': 'TEXTURE_DATA', 'Scene': 'SCENE_DATA','AreaLight':'LIGHT_DATA', 'Light': 'LIGHT_DATA', 'SpotLight': 'LIGHT_DATA', 'SunLight': 'LIGHT_DATA', 'PointLight': 'LIGHT_DATA', 'Camera': 'CAMERA_DATA', 'Action': 'ACTION', 'Armature': 'ARMATURE_DATA', 'GreasePencil': 'GREASEPENCIL'}
|
2019-04-24 23:42:23 +08:00
|
|
|
|
2019-08-09 05:42:02 +08:00
|
|
|
PROP_STATES = [ 'ADDED',
|
|
|
|
'COMMITED',
|
|
|
|
'PUSHED',
|
|
|
|
'FETCHED',
|
|
|
|
'UP']
|
2019-05-15 20:52:45 +08:00
|
|
|
class SESSION_PT_settings(bpy.types.Panel):
|
2019-07-02 22:43:30 +08:00
|
|
|
"""Settings panel"""
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_idname = "MULTIUSER_SETTINGS_PT_panel"
|
2019-07-02 00:04:35 +08:00
|
|
|
bl_label = "Settings"
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-02-08 22:44:02 +08:00
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.label(text="", icon='TOOL_SETTINGS')
|
|
|
|
|
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-05-15 20:52:45 +08:00
|
|
|
if hasattr(context.window_manager, 'session'):
|
2019-08-09 16:58:47 +08:00
|
|
|
settings = context.window_manager.session
|
2019-05-10 23:00:47 +08:00
|
|
|
window_manager = context.window_manager
|
2019-03-15 23:50:59 +08:00
|
|
|
|
2019-08-06 17:34:39 +08:00
|
|
|
# STATE INITIAL
|
|
|
|
if not operators.client or (operators.client and operators.client.state == 0):
|
2019-08-09 21:20:49 +08:00
|
|
|
pass
|
2019-07-02 22:43:30 +08:00
|
|
|
# REPLICATION SETTINGS
|
2019-08-08 20:46:59 +08:00
|
|
|
# row = layout.row()
|
|
|
|
# box = row.box()
|
|
|
|
# row = box.row()
|
|
|
|
# row.label(text="REPLICATION", icon='TRIA_RIGHT')
|
|
|
|
# row = box.row()
|
2019-07-02 22:43:30 +08:00
|
|
|
|
2019-08-08 20:46:59 +08:00
|
|
|
# for item in window_manager.session.supported_datablock:
|
|
|
|
# row.label(text=item.type_name,icon=ICONS[item.type_name])
|
|
|
|
# row.prop(item, "is_replicated", text="")
|
|
|
|
# row = box.row()
|
2019-04-08 23:01:02 +08:00
|
|
|
else:
|
2019-08-06 17:34:39 +08:00
|
|
|
# STATE ACTIVE
|
|
|
|
if operators.client.state == 2:
|
2019-04-22 21:01:09 +08:00
|
|
|
|
2019-04-08 23:01:02 +08:00
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
2019-07-02 00:04:35 +08:00
|
|
|
row = layout.row()
|
2019-05-03 15:55:57 +08:00
|
|
|
|
2019-08-06 17:34:39 +08:00
|
|
|
# STATE SYNCING
|
|
|
|
else:
|
2019-05-03 17:32:14 +08:00
|
|
|
status = "connecting..."
|
|
|
|
row.label(text=status)
|
2019-04-22 21:01:09 +08:00
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
2019-04-01 22:14:21 +08:00
|
|
|
|
2019-05-03 17:32:14 +08:00
|
|
|
|
2019-04-01 22:14:21 +08:00
|
|
|
row = layout.row()
|
2019-03-14 00:02:53 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
class SESSION_PT_settings_network(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel"
|
|
|
|
bl_label = "Network"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return not operators.client or (operators.client and operators.client.state == 0)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
settings = context.window_manager.session
|
|
|
|
scene = context.window_manager
|
|
|
|
row = layout.row()
|
|
|
|
# USER SETTINGS
|
|
|
|
row.label(text="draw overlay:")
|
|
|
|
row.prop(settings, "enable_presence", text="")
|
|
|
|
row = layout.row()
|
|
|
|
row.label(text="clear blend:")
|
|
|
|
row.prop(settings, "start_empty", text="")
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
row.prop(settings, "session_mode", expand=True)
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
if settings.session_mode == 'HOST':
|
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="init scene:")
|
|
|
|
row.prop(settings, "init_scene", text="")
|
|
|
|
row = box.row()
|
|
|
|
row.operator("session.start", text="HOST").host = True
|
|
|
|
else:
|
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
|
|
|
row.prop(settings, "ip", text="ip")
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="port:")
|
|
|
|
row.prop(settings, "port", text="")
|
|
|
|
row = box.row()
|
|
|
|
|
|
|
|
|
|
|
|
row = box.row()
|
|
|
|
row.operator("session.start", text="CONNECT").host = False
|
|
|
|
|
|
|
|
|
|
|
|
class SESSION_PT_settings_user(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_SETTINGS_USER_PT_panel"
|
|
|
|
bl_label = "User"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return not operators.client or (operators.client and operators.client.state == 0)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
settings = context.window_manager.session
|
|
|
|
scene = context.window_manager
|
|
|
|
row = layout.row()
|
|
|
|
# USER SETTINGS
|
|
|
|
row.prop(settings, "username", text="id")
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
row.prop(settings, "client_color", text="color")
|
|
|
|
row = layout.row()
|
|
|
|
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-05-15 20:52:45 +08:00
|
|
|
class SESSION_PT_user(bpy.types.Panel):
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_idname = "MULTIUSER_USER_PT_panel"
|
2019-08-09 16:58:47 +08:00
|
|
|
bl_label = "Users"
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-08-09 21:20:49 +08:00
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-03-14 00:02:53 +08:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-08-06 17:34:39 +08:00
|
|
|
return operators.client and operators.client.state == 2
|
2019-04-22 21:01:09 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-08-09 16:58:47 +08:00
|
|
|
settings = context.window_manager.session
|
2019-05-10 23:00:47 +08:00
|
|
|
scene = context.window_manager
|
2019-03-14 00:02:53 +08:00
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
2019-08-05 23:06:13 +08:00
|
|
|
client_keys = operators.client.list()
|
2019-06-11 00:26:44 +08:00
|
|
|
if client_keys and len(client_keys) > 0:
|
|
|
|
for key in client_keys:
|
2019-08-09 05:42:02 +08:00
|
|
|
pass
|
|
|
|
# if 'Client' in key[0]:
|
|
|
|
# info = ""
|
|
|
|
# item_box = row.box()
|
|
|
|
# detail_item_box = item_box.row()
|
|
|
|
|
|
|
|
# username = key[0].split('/')[1]
|
2019-08-09 16:58:47 +08:00
|
|
|
# if username == settings.username:
|
2019-08-09 05:42:02 +08:00
|
|
|
# info = "(self)"
|
|
|
|
# # detail_item_box = item_box.row()
|
|
|
|
# detail_item_box.label(
|
|
|
|
# text="{} - {}".format(username, info))
|
|
|
|
|
2019-08-09 16:58:47 +08:00
|
|
|
# if settings.username not in key[0]:
|
2019-08-09 05:42:02 +08:00
|
|
|
# detail_item_box.operator(
|
|
|
|
# "session.snapview", text="", icon='VIEW_CAMERA').target_client = username
|
|
|
|
# row = layout.row()
|
2019-04-17 19:39:36 +08:00
|
|
|
else:
|
|
|
|
row.label(text="Empty")
|
|
|
|
|
|
|
|
row = layout.row()
|
2019-03-14 00:02:53 +08:00
|
|
|
|
2019-07-01 21:59:51 +08:00
|
|
|
|
2019-05-09 21:56:30 +08:00
|
|
|
def get_client_key(item):
|
2019-08-08 22:29:16 +08:00
|
|
|
return item.owner
|
2019-03-14 00:02:53 +08:00
|
|
|
|
2019-08-08 20:46:59 +08:00
|
|
|
class SESSION_PT_outliner(bpy.types.Panel):
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
2019-08-09 16:58:47 +08:00
|
|
|
bl_label = "Properties"
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-03-14 00:02:53 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-08-06 17:34:39 +08:00
|
|
|
return operators.client and operators.client.state == 2
|
2019-03-14 00:02:53 +08:00
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
2019-08-06 17:34:39 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-08-06 17:34:39 +08:00
|
|
|
|
2019-05-15 20:52:45 +08:00
|
|
|
if hasattr(context.window_manager,'session'):
|
2019-08-09 16:58:47 +08:00
|
|
|
settings = context.window_manager.session
|
2019-05-10 23:00:47 +08:00
|
|
|
scene = context.window_manager
|
2019-05-15 20:52:45 +08:00
|
|
|
|
2019-02-09 01:34:10 +08:00
|
|
|
row = layout.row()
|
2019-08-09 16:58:47 +08:00
|
|
|
row.prop(settings,'outliner_filter', text="")
|
2019-04-01 22:14:21 +08:00
|
|
|
|
2019-04-11 20:39:31 +08:00
|
|
|
row = layout.row(align=True)
|
|
|
|
# Property area
|
2019-08-08 23:17:58 +08:00
|
|
|
# area_msg = row.box()
|
2019-08-05 23:06:13 +08:00
|
|
|
client_keys = operators.client.list()
|
2019-06-11 00:26:44 +08:00
|
|
|
if client_keys and len(client_keys) > 0:
|
2019-08-08 23:17:58 +08:00
|
|
|
col = layout.column(align=True)
|
2019-06-11 00:26:44 +08:00
|
|
|
for item in sorted(client_keys, key=get_client_key):
|
2019-08-08 23:17:58 +08:00
|
|
|
area_msg = col.row(align = True)
|
2019-04-11 20:39:31 +08:00
|
|
|
item_box = area_msg.box()
|
2019-08-09 20:39:59 +08:00
|
|
|
name = "None"
|
|
|
|
#TODO: refactor that...
|
|
|
|
if hasattr(item.pointer,'name'):
|
|
|
|
name = item.pointer.name
|
|
|
|
else:
|
|
|
|
name = item.buffer['name']
|
|
|
|
|
2019-08-08 23:17:58 +08:00
|
|
|
detail_item_box = item_box.row()
|
2019-08-08 22:29:16 +08:00
|
|
|
detail_item_box.label(text="",icon=item.icon)
|
2019-08-09 20:39:59 +08:00
|
|
|
detail_item_box.label(text="{} ".format(name))
|
2019-08-08 22:29:16 +08:00
|
|
|
detail_item_box.label(text="{} ".format(item.owner))
|
2019-08-09 05:42:02 +08:00
|
|
|
detail_item_box.label(text="{} ".format(PROP_STATES[item.state]))
|
2019-08-09 16:58:47 +08:00
|
|
|
|
2019-08-08 23:17:58 +08:00
|
|
|
|
2019-08-08 22:29:16 +08:00
|
|
|
# right_icon = "DECORATE_UNLOCKED"
|
2019-08-09 16:58:47 +08:00
|
|
|
# if owner == settings.username:
|
2019-08-08 22:29:16 +08:00
|
|
|
# right_icon="DECORATE_UNLOCKED"
|
|
|
|
# else:
|
2019-04-22 18:14:39 +08:00
|
|
|
|
2019-08-08 22:29:16 +08:00
|
|
|
# right_icon="DECORATE_LOCKED"
|
2019-04-24 23:42:23 +08:00
|
|
|
|
2019-08-09 16:58:47 +08:00
|
|
|
# ro = detail_item_box.operator("session.right", text="",emboss=settings.is_admin, icon=right_icon)
|
2019-08-08 22:29:16 +08:00
|
|
|
# ro.key = item[0]
|
2019-04-11 20:39:31 +08:00
|
|
|
# detail_item_box.operator(
|
|
|
|
# "session.remove_prop", text="", icon="X").property_path = key
|
|
|
|
else:
|
|
|
|
area_msg.label(text="Empty")
|
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
|
|
|
|
classes = (
|
2019-05-15 20:52:45 +08:00
|
|
|
SESSION_PT_settings,
|
2019-08-09 21:20:49 +08:00
|
|
|
SESSION_PT_settings_user,
|
|
|
|
SESSION_PT_settings_network,
|
2019-05-15 20:52:45 +08:00
|
|
|
SESSION_PT_user,
|
2019-08-08 20:46:59 +08:00
|
|
|
SESSION_PT_outliner,
|
2019-04-26 22:41:07 +08:00
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-03-14 19:09:33 +08:00
|
|
|
register()
|