2019-02-08 15:44:02 +01:00
|
|
|
import bpy
|
2019-08-05 17:06:13 +02:00
|
|
|
from . import operators
|
2019-02-08 15:44:02 +01:00
|
|
|
|
2019-04-24 17:42:23 +02:00
|
|
|
|
2019-07-02 17:44:59 +02: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 16:43:30 +02: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 17:42:23 +02:00
|
|
|
|
2019-05-15 14:52:45 +02:00
|
|
|
class SESSION_PT_settings(bpy.types.Panel):
|
2019-07-02 16:43:30 +02:00
|
|
|
"""Settings panel"""
|
2019-06-13 18:09:16 +02:00
|
|
|
bl_idname = "MULTIUSER_SETTINGS_PT_panel"
|
2019-07-01 18:04:35 +02:00
|
|
|
bl_label = "Settings"
|
2019-06-13 18:09:16 +02:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-02-08 15:44:02 +01:00
|
|
|
|
2019-07-01 18:04:35 +02:00
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.label(text="", icon='TOOL_SETTINGS')
|
|
|
|
|
|
|
|
|
2019-02-08 15:44:02 +01:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 12:09:33 +01:00
|
|
|
|
2019-05-15 14:52:45 +02:00
|
|
|
if hasattr(context.window_manager, 'session'):
|
|
|
|
net_settings = context.window_manager.session
|
2019-05-10 17:00:47 +02:00
|
|
|
window_manager = context.window_manager
|
2019-03-15 16:50:59 +01:00
|
|
|
|
2019-03-13 17:02:53 +01:00
|
|
|
row = layout.row()
|
2019-08-06 11:34:39 +02:00
|
|
|
# STATE INITIAL
|
|
|
|
if not operators.client or (operators.client and operators.client.state == 0):
|
2019-03-28 11:38:50 +01:00
|
|
|
row = layout.row()
|
2019-07-02 16:43:30 +02:00
|
|
|
|
|
|
|
# USER SETTINGS
|
2019-03-25 14:56:09 +01:00
|
|
|
box = row.box()
|
2019-03-25 18:51:54 +01:00
|
|
|
row = box.row()
|
2019-05-03 11:32:14 +02:00
|
|
|
row.label(text="USER", icon='TRIA_RIGHT')
|
2019-03-25 18:51:54 +01:00
|
|
|
row = box.row()
|
2019-05-15 14:52:45 +02:00
|
|
|
row.prop(window_manager.session, "username", text="id")
|
2019-04-18 11:34:16 +02:00
|
|
|
|
2019-03-25 18:51:54 +01:00
|
|
|
row = box.row()
|
2019-05-15 14:52:45 +02:00
|
|
|
row.prop(window_manager.session, "client_color", text="color")
|
2019-05-02 17:52:32 +02:00
|
|
|
row = box.row()
|
2019-03-25 15:30:05 +01:00
|
|
|
|
2019-07-02 16:43:30 +02:00
|
|
|
|
|
|
|
# NETWORK SETTINGS
|
2019-03-15 16:50:59 +01:00
|
|
|
row = layout.row()
|
2019-05-02 17:52:32 +02:00
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
2019-05-03 11:32:14 +02:00
|
|
|
row.label(text="NETWORK", icon = "TRIA_RIGHT")
|
2019-05-02 17:52:32 +02:00
|
|
|
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="draw overlay:")
|
2019-07-01 18:04:35 +02:00
|
|
|
row.prop(net_settings, "enable_presence", text="")
|
2019-05-10 15:12:52 +02:00
|
|
|
row = box.row()
|
|
|
|
row.label(text="clear blend:")
|
2019-07-01 18:04:35 +02:00
|
|
|
row.prop(net_settings, "start_empty", text="")
|
2019-05-10 15:12:52 +02:00
|
|
|
row = box.row()
|
2019-05-15 14:52:45 +02:00
|
|
|
|
2019-05-02 17:52:32 +02:00
|
|
|
row = box.row()
|
2019-05-10 17:00:47 +02:00
|
|
|
row.prop(net_settings, "session_mode", expand=True)
|
2019-05-02 17:52:32 +02:00
|
|
|
row = box.row()
|
2019-05-10 15:12:52 +02:00
|
|
|
|
2019-05-15 14:52:45 +02:00
|
|
|
if window_manager.session.session_mode == 'HOST':
|
2019-04-01 16:14:21 +02:00
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="init scene:")
|
|
|
|
row.prop(net_settings, "init_scene", text="")
|
2019-07-02 16:43:30 +02:00
|
|
|
row = box.row()
|
2019-08-05 17:58:56 +02:00
|
|
|
row.operator("session.start", text="HOST").host = True
|
2019-04-01 16:14:21 +02:00
|
|
|
else:
|
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
2019-04-18 11:34:16 +02:00
|
|
|
row.prop(net_settings, "ip", text="ip")
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="port:")
|
2019-05-15 14:52:45 +02:00
|
|
|
row.prop(window_manager.session, "port", text="")
|
2019-04-01 16:14:21 +02:00
|
|
|
row = box.row()
|
|
|
|
row.label(text="load data:")
|
|
|
|
row.prop(net_settings, "load_data", text="")
|
2019-05-10 15:12:52 +02:00
|
|
|
|
2019-04-01 16:14:21 +02:00
|
|
|
|
2019-07-02 16:43:30 +02:00
|
|
|
row = box.row()
|
2019-08-05 17:58:56 +02:00
|
|
|
row.operator("session.start", text="CONNECT").host = False
|
2019-03-25 15:30:05 +01:00
|
|
|
|
2019-07-02 16:43:30 +02:00
|
|
|
# REPLICATION SETTINGS
|
2019-08-08 14:46:59 +02:00
|
|
|
# row = layout.row()
|
|
|
|
# box = row.box()
|
|
|
|
# row = box.row()
|
|
|
|
# row.label(text="REPLICATION", icon='TRIA_RIGHT')
|
|
|
|
# row = box.row()
|
2019-07-02 16:43:30 +02:00
|
|
|
|
2019-08-08 14:46:59 +02: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-07-02 16:43:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-08 17:01:02 +02:00
|
|
|
else:
|
2019-08-06 11:34:39 +02:00
|
|
|
# STATE ACTIVE
|
|
|
|
if operators.client.state == 2:
|
2019-04-22 15:01:09 +02:00
|
|
|
|
2019-04-08 17:01:02 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
2019-07-01 15:59:51 +02:00
|
|
|
# row = layout.row(align=True)
|
|
|
|
# row.operator("session.dump", icon='QUIT', text="Dump")
|
|
|
|
# row.operator("session.dump", icon='QUIT', text="Load")
|
2019-07-01 18:04:35 +02:00
|
|
|
row = layout.row()
|
2019-05-03 09:55:57 +02:00
|
|
|
|
2019-08-06 11:34:39 +02:00
|
|
|
# STATE SYNCING
|
|
|
|
else:
|
2019-05-03 11:32:14 +02:00
|
|
|
status = "connecting..."
|
|
|
|
if net_settings.is_admin:
|
2019-08-05 17:06:13 +02:00
|
|
|
status = "init scene...({} tasks remaining)".format(operators.client.active_tasks)
|
2019-05-03 11:32:14 +02:00
|
|
|
row.label(text=status)
|
2019-04-22 15:01:09 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
2019-04-01 16:14:21 +02:00
|
|
|
|
2019-05-03 11:32:14 +02:00
|
|
|
|
2019-04-01 16:14:21 +02:00
|
|
|
row = layout.row()
|
2019-03-13 17:02:53 +01:00
|
|
|
|
2019-03-14 12:09:33 +01:00
|
|
|
|
2019-05-15 14:52:45 +02:00
|
|
|
class SESSION_PT_user(bpy.types.Panel):
|
2019-06-13 18:09:16 +02:00
|
|
|
bl_idname = "MULTIUSER_USER_PT_panel"
|
|
|
|
bl_label = "Users online"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-03-13 17:02:53 +01:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-08-06 11:34:39 +02:00
|
|
|
return operators.client and operators.client.state == 2
|
2019-04-22 15:01:09 +02:00
|
|
|
|
2019-03-13 17:02:53 +01:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 12:09:33 +01:00
|
|
|
|
2019-05-15 14:52:45 +02:00
|
|
|
net_settings = context.window_manager.session
|
2019-05-10 17:00:47 +02:00
|
|
|
scene = context.window_manager
|
2019-03-13 17:02:53 +01:00
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
2019-08-05 17:06:13 +02:00
|
|
|
client_keys = operators.client.list()
|
2019-06-10 18:26:44 +02:00
|
|
|
if client_keys and len(client_keys) > 0:
|
|
|
|
for key in client_keys:
|
2019-04-22 12:14:39 +02:00
|
|
|
if 'Client' in key[0]:
|
2019-04-17 13:39:36 +02:00
|
|
|
info = ""
|
|
|
|
item_box = row.box()
|
|
|
|
detail_item_box = item_box.row()
|
2019-03-14 12:09:33 +01:00
|
|
|
|
2019-04-22 12:14:39 +02:00
|
|
|
username = key[0].split('/')[1]
|
2019-04-17 13:39:36 +02:00
|
|
|
if username == net_settings.username:
|
|
|
|
info = "(self)"
|
|
|
|
# detail_item_box = item_box.row()
|
|
|
|
detail_item_box.label(
|
|
|
|
text="{} - {}".format(username, info))
|
|
|
|
|
2019-04-22 12:14:39 +02:00
|
|
|
if net_settings.username not in key[0]:
|
2019-04-17 13:39:36 +02:00
|
|
|
detail_item_box.operator(
|
|
|
|
"session.snapview", text="", icon='VIEW_CAMERA').target_client = username
|
|
|
|
row = layout.row()
|
|
|
|
else:
|
|
|
|
row.label(text="Empty")
|
|
|
|
|
|
|
|
row = layout.row()
|
2019-03-13 17:02:53 +01:00
|
|
|
|
2019-07-01 15:59:51 +02:00
|
|
|
|
2019-05-09 15:56:30 +02:00
|
|
|
def get_client_key(item):
|
|
|
|
return item[0]
|
2019-03-13 17:02:53 +01:00
|
|
|
|
2019-08-08 14:46:59 +02:00
|
|
|
class SESSION_PT_outliner(bpy.types.Panel):
|
2019-06-13 18:09:16 +02:00
|
|
|
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
|
|
|
bl_label = "Replicated properties"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-03-13 17:02:53 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-08-06 11:34:39 +02:00
|
|
|
return operators.client and operators.client.state == 2
|
2019-03-13 17:02:53 +01:00
|
|
|
|
2019-07-01 18:04:35 +02:00
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
2019-08-06 11:34:39 +02:00
|
|
|
|
2019-03-13 17:02:53 +01:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-08-06 11:34:39 +02:00
|
|
|
|
2019-05-15 14:52:45 +02:00
|
|
|
if hasattr(context.window_manager,'session'):
|
|
|
|
net_settings = context.window_manager.session
|
2019-05-10 17:00:47 +02:00
|
|
|
scene = context.window_manager
|
2019-05-15 14:52:45 +02:00
|
|
|
|
2019-02-08 18:34:10 +01:00
|
|
|
row = layout.row()
|
2019-04-01 16:14:21 +02:00
|
|
|
|
2019-04-11 14:39:31 +02:00
|
|
|
row = layout.row(align=True)
|
|
|
|
row.prop(net_settings, "buffer", text="")
|
|
|
|
row.prop(net_settings, "add_property_depth", text="")
|
|
|
|
add = row.operator("session.add_prop", text="",
|
|
|
|
icon="ADD")
|
|
|
|
add.property_path = net_settings.buffer
|
|
|
|
add.depth = net_settings.add_property_depth
|
|
|
|
row = layout.row()
|
2019-05-15 14:52:45 +02:00
|
|
|
|
2019-04-11 14:39:31 +02:00
|
|
|
# Property area
|
|
|
|
area_msg = row.box()
|
2019-08-05 17:06:13 +02:00
|
|
|
client_keys = operators.client.list()
|
2019-06-10 18:26:44 +02:00
|
|
|
if client_keys and len(client_keys) > 0:
|
2019-05-09 15:56:30 +02:00
|
|
|
|
2019-06-10 18:26:44 +02:00
|
|
|
for item in sorted(client_keys, key=get_client_key):
|
2019-04-22 14:24:19 +02:00
|
|
|
owner = 'toto'
|
|
|
|
try:
|
2019-04-25 10:42:04 +02:00
|
|
|
owner = item[1]
|
2019-04-22 14:24:19 +02:00
|
|
|
except:
|
2019-04-25 10:42:04 +02:00
|
|
|
owner = item[1].decode()
|
2019-04-22 14:24:19 +02:00
|
|
|
pass
|
2019-04-26 16:41:07 +02:00
|
|
|
|
|
|
|
store_type,store_name = item[0].split('/')
|
2019-04-11 14:39:31 +02:00
|
|
|
item_box = area_msg.box()
|
2019-04-18 11:34:16 +02:00
|
|
|
|
2019-04-22 12:14:39 +02:00
|
|
|
detail_item_box = item_box.row(align = True)
|
2019-04-26 16:41:07 +02:00
|
|
|
detail_item_box.label(text="",icon=ICONS[store_type])
|
|
|
|
detail_item_box.label(text="{} ".format(store_name))
|
2019-04-22 12:14:39 +02:00
|
|
|
detail_item_box.label(text="{} ".format(owner))
|
|
|
|
|
2019-04-24 17:42:23 +02:00
|
|
|
right_icon = "DECORATE_UNLOCKED"
|
2019-04-22 12:14:39 +02:00
|
|
|
if owner == net_settings.username:
|
2019-04-24 17:42:23 +02:00
|
|
|
right_icon="DECORATE_UNLOCKED"
|
2019-04-22 12:14:39 +02:00
|
|
|
else:
|
|
|
|
|
2019-04-24 17:42:23 +02:00
|
|
|
right_icon="DECORATE_LOCKED"
|
|
|
|
|
2019-04-26 16:41:07 +02:00
|
|
|
ro = detail_item_box.operator("session.right", text="",emboss=net_settings.is_admin, icon=right_icon)
|
2019-04-24 17:42:23 +02:00
|
|
|
ro.key = item[0]
|
2019-04-11 14:39:31 +02:00
|
|
|
# detail_item_box.operator(
|
|
|
|
# "session.remove_prop", text="", icon="X").property_path = key
|
|
|
|
else:
|
|
|
|
area_msg.label(text="Empty")
|
|
|
|
|
2019-02-08 15:44:02 +01:00
|
|
|
|
|
|
|
classes = (
|
2019-05-15 14:52:45 +02:00
|
|
|
SESSION_PT_settings,
|
|
|
|
SESSION_PT_user,
|
2019-08-08 14:46:59 +02:00
|
|
|
SESSION_PT_outliner,
|
2019-04-26 16:41:07 +02:00
|
|
|
|
2019-02-08 15:44:02 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-03-14 12:09:33 +01:00
|
|
|
register()
|