2019-02-08 22:44:02 +08:00
|
|
|
import bpy
|
2019-03-25 22:30:05 +08:00
|
|
|
|
2019-04-10 23:01:21 +08:00
|
|
|
from . import client, operators
|
2019-03-07 20:45:44 +08:00
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
class SessionSettingsPanel(bpy.types.Panel):
|
2019-02-08 22:44:02 +08:00
|
|
|
"""Creates a Panel in the scene context of the properties editor"""
|
2019-03-14 00:02:53 +08:00
|
|
|
bl_label = "NET settings"
|
|
|
|
bl_idname = "SCENE_PT_SessionSettings"
|
2019-02-08 22:44:02 +08:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-04-01 22:14:21 +08:00
|
|
|
if hasattr(context.scene, 'session_settings'):
|
|
|
|
net_settings = context.scene.session_settings
|
|
|
|
scene = context.scene
|
2019-03-15 23:50:59 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
row = layout.row()
|
2019-04-10 23:01:21 +08:00
|
|
|
if operators.client_instance is None:
|
2019-04-01 22:14:21 +08:00
|
|
|
|
2019-03-28 18:38:50 +08:00
|
|
|
row = layout.row()
|
2019-03-25 21:56:09 +08:00
|
|
|
box = row.box()
|
2019-03-26 01:51:54 +08:00
|
|
|
row = box.row()
|
2019-04-01 22:14:21 +08:00
|
|
|
row.label(text="User infos")
|
2019-03-26 01:51:54 +08:00
|
|
|
row = box.row()
|
2019-04-01 22:14:21 +08:00
|
|
|
row.prop(scene.session_settings, "username", text="id")
|
2019-04-18 17:34:16 +08:00
|
|
|
|
2019-03-26 01:51:54 +08:00
|
|
|
row = box.row()
|
2019-04-01 22:14:21 +08:00
|
|
|
row.prop(scene.session_settings, "client_color", text="color")
|
2019-03-25 22:30:05 +08:00
|
|
|
|
2019-03-15 23:50:59 +08:00
|
|
|
row = layout.row()
|
2019-04-01 22:14:21 +08:00
|
|
|
row.prop(scene.session_settings, "session_mode", expand=True)
|
|
|
|
row = layout.row()
|
2019-03-25 22:30:05 +08:00
|
|
|
|
2019-04-01 22:14:21 +08:00
|
|
|
if scene.session_settings.session_mode == 'HOST':
|
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="init scene:")
|
|
|
|
row.prop(net_settings, "init_scene", text="")
|
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.create", text="HOST")
|
|
|
|
else:
|
|
|
|
box = row.box()
|
|
|
|
row = box.row()
|
2019-04-18 17:34:16 +08:00
|
|
|
row.prop(net_settings, "ip", text="ip")
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="port:")
|
|
|
|
row.prop(scene.session_settings, "port", text="")
|
2019-04-01 22:14:21 +08:00
|
|
|
row = box.row()
|
|
|
|
row.label(text="load data:")
|
|
|
|
row.prop(net_settings, "load_data", text="")
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="clear scene:")
|
|
|
|
row.prop(net_settings, "clear_scene", text="")
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.join", text="CONNECT")
|
2019-03-25 22:30:05 +08:00
|
|
|
|
2019-04-08 23:01:02 +08:00
|
|
|
else:
|
|
|
|
|
2019-04-10 23:01:21 +08:00
|
|
|
if operators.client_instance.agent.is_alive():
|
2019-04-08 23:01:02 +08:00
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
2019-04-10 23:01:21 +08:00
|
|
|
# elif operators.client.status is client.RCFStatus.CONNECTING:
|
2019-04-08 23:01:02 +08:00
|
|
|
# row.label(text="connecting...")
|
|
|
|
# row = layout.row()
|
|
|
|
# row.operator("session.stop", icon='QUIT', text="CANCEL")
|
2019-04-01 22:14:21 +08:00
|
|
|
|
|
|
|
row = layout.row()
|
2019-03-14 00:02:53 +08:00
|
|
|
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
class SessionUsersPanel(bpy.types.Panel):
|
|
|
|
"""Creates a Panel in the scene context of the properties editor"""
|
|
|
|
bl_label = "NET users"
|
|
|
|
bl_idname = "SCENE_PT_SessionUsers"
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-04-10 23:01:21 +08:00
|
|
|
if operators.client_instance:
|
2019-04-17 19:39:36 +08:00
|
|
|
return operators.client_instance.agent.is_alive()
|
2019-03-16 00:37:02 +08:00
|
|
|
return False
|
2019-03-14 00:02:53 +08:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
net_settings = context.scene.session_settings
|
|
|
|
scene = context.scene
|
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
2019-04-17 19:39:36 +08:00
|
|
|
if operators.client_keys and len(operators.client_keys) > 0:
|
|
|
|
for key in operators.client_keys:
|
2019-04-22 18:14:39 +08:00
|
|
|
if 'Client' in key[0]:
|
2019-04-17 19:39:36 +08:00
|
|
|
info = ""
|
|
|
|
item_box = row.box()
|
|
|
|
detail_item_box = item_box.row()
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-04-22 18:14:39 +08:00
|
|
|
username = key[0].split('/')[1]
|
2019-04-17 19:39:36 +08: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 18:14:39 +08:00
|
|
|
if net_settings.username not in key[0]:
|
2019-04-17 19:39:36 +08: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-14 00:02:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
class SessionPropertiesPanel(bpy.types.Panel):
|
|
|
|
"""Creates a Panel in the scene context of the properties editor"""
|
|
|
|
bl_label = "NET properties"
|
2019-04-01 22:14:21 +08:00
|
|
|
bl_idname = "SCENE_PT_SessionProps"
|
2019-03-14 00:02:53 +08:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-04-10 23:01:21 +08:00
|
|
|
if operators.client_instance:
|
|
|
|
return operators.client_instance.agent.is_alive()
|
2019-04-17 19:39:36 +08:00
|
|
|
|
2019-03-16 00:37:02 +08:00
|
|
|
return False
|
2019-03-14 00:02:53 +08:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-04-01 22:14:21 +08:00
|
|
|
if hasattr(context.scene,'session_settings'):
|
|
|
|
net_settings = context.scene.session_settings
|
|
|
|
scene = context.scene
|
|
|
|
# Create a simple row.
|
2019-02-09 01:34:10 +08:00
|
|
|
row = layout.row()
|
2019-04-01 22:14:21 +08:00
|
|
|
|
2019-04-11 20:39:31 +08: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()
|
|
|
|
# Property area
|
|
|
|
area_msg = row.box()
|
|
|
|
area_msg.operator("session.refresh", text="",
|
|
|
|
icon="UV_SYNC_SELECT")
|
|
|
|
if operators.client_keys and len(operators.client_keys) > 0:
|
|
|
|
for item in operators.client_keys:
|
2019-04-22 20:24:19 +08:00
|
|
|
owner = 'toto'
|
|
|
|
try:
|
|
|
|
owner = item[1].decode()
|
|
|
|
except:
|
|
|
|
pass
|
2019-04-11 20:39:31 +08:00
|
|
|
item_box = area_msg.box()
|
2019-04-18 17:34:16 +08:00
|
|
|
|
2019-04-22 18:14:39 +08:00
|
|
|
detail_item_box = item_box.row(align = True)
|
2019-04-18 17:34:16 +08:00
|
|
|
|
2019-04-11 20:39:31 +08:00
|
|
|
# detail_item_box = item_box.row()
|
|
|
|
|
2019-04-22 18:14:39 +08:00
|
|
|
detail_item_box.label(text="{} ".format(item[0]))
|
|
|
|
|
|
|
|
detail_item_box.label(text="{} ".format(owner))
|
|
|
|
|
|
|
|
if owner == net_settings.username:
|
|
|
|
detail_item_box.label(text="",icon="DECORATE_UNLOCKED")
|
|
|
|
else:
|
|
|
|
|
|
|
|
detail_item_box.label(text="",icon="DECORATE_LOCKED")
|
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
|
|
|
|
2019-04-01 21:39:05 +08:00
|
|
|
class SessionTaskPanel(bpy.types.Panel):
|
|
|
|
"""Creates a Panel in the scene context of the properties editor"""
|
|
|
|
bl_label = "NET tasks"
|
2019-04-01 22:14:21 +08:00
|
|
|
bl_idname = "SCENE_PT_SessionTasks"
|
2019-04-01 21:39:05 +08:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-04-10 23:01:21 +08:00
|
|
|
if operators.client:
|
|
|
|
return operators.client.agent.is_alive()
|
|
|
|
# return operators.client.status == client.RCFStatus.CONNECTED
|
2019-04-01 21:39:05 +08:00
|
|
|
return False
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
|
|
|
|
2019-04-10 23:01:21 +08:00
|
|
|
if operators.update_list:
|
2019-04-01 21:39:05 +08:00
|
|
|
# Property area
|
|
|
|
area_msg = row.box()
|
2019-04-10 23:01:21 +08:00
|
|
|
if len(operators.update_list) > 0:
|
|
|
|
for key, values in operators.update_list.items():
|
2019-04-01 21:39:05 +08:00
|
|
|
item_box = area_msg.box()
|
|
|
|
detail_item_box = item_box.row()
|
|
|
|
# detail_item_box = item_box.row()
|
|
|
|
|
|
|
|
detail_item_box.label(text="{} - {} ".format(
|
|
|
|
key, values))
|
|
|
|
else:
|
|
|
|
area_msg.label(text="Empty")
|
|
|
|
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
classes = (
|
2019-03-14 00:02:53 +08:00
|
|
|
SessionSettingsPanel,
|
2019-04-17 19:39:36 +08:00
|
|
|
SessionUsersPanel,
|
2019-04-09 00:21:48 +08:00
|
|
|
SessionPropertiesPanel,
|
2019-04-08 21:54:21 +08:00
|
|
|
# SessionTaskPanel,
|
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()
|