2019-02-08 15:44:02 +01:00
|
|
|
import bpy
|
|
|
|
from . import net_components
|
|
|
|
from . import net_operators
|
2019-03-07 13:45:44 +01:00
|
|
|
|
2019-02-08 15:44:02 +01:00
|
|
|
|
2019-03-13 17:02:53 +01:00
|
|
|
class SessionSettingsPanel(bpy.types.Panel):
|
2019-02-08 15:44:02 +01:00
|
|
|
"""Creates a Panel in the scene context of the properties editor"""
|
2019-03-13 17:02:53 +01:00
|
|
|
bl_label = "NET settings"
|
|
|
|
bl_idname = "SCENE_PT_SessionSettings"
|
2019-02-08 15:44:02 +01:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "scene"
|
|
|
|
|
2019-02-22 18:22:25 +01:00
|
|
|
def draw_header(self, context):
|
2019-03-13 17:02:53 +01:00
|
|
|
pass
|
|
|
|
# net_settings = context.scene.session_settings
|
2019-02-22 18:22:25 +01:00
|
|
|
|
2019-03-13 17:02:53 +01:00
|
|
|
# if net_settings.is_running:
|
|
|
|
# self.layout.label(text="",icon='HIDE_OFF')
|
|
|
|
# else:
|
|
|
|
# self.layout.label(text="",icon='HIDE_ON')
|
2019-02-22 18:22:25 +01:00
|
|
|
# self.layout.label(text="Offline")
|
2019-02-08 15:44:02 +01:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-02-08 18:34:10 +01:00
|
|
|
|
2019-02-22 18:22:25 +01:00
|
|
|
net_settings = context.scene.session_settings
|
2019-02-08 15:44:02 +01:00
|
|
|
scene = context.scene
|
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
|
|
|
|
2019-02-11 17:31:03 +01:00
|
|
|
if net_operators.client:
|
2019-02-22 18:22:25 +01:00
|
|
|
row.label(text="Net frequency:")
|
|
|
|
row.prop(net_settings,"update_frequency",text="")
|
2019-03-13 17:02:53 +01:00
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", text="exit session")
|
|
|
|
|
|
|
|
else:
|
|
|
|
row = layout.row()
|
|
|
|
row.prop(scene.session_settings,"username",text="username:")
|
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.join")
|
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.create")
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
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):
|
|
|
|
return net_operators.client
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
net_settings = context.scene.session_settings
|
|
|
|
scene = context.scene
|
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
if net_operators.client:
|
|
|
|
if len(net_operators.client.property_map) > 0:
|
|
|
|
for key,values in net_operators.client.property_map.items():
|
|
|
|
if 'client' in key:
|
|
|
|
info = ""
|
|
|
|
item_box = row.box()
|
|
|
|
detail_item_box = item_box.row()
|
|
|
|
|
|
|
|
if values.id == net_operators.client.id:
|
|
|
|
info = "(self)"
|
|
|
|
# detail_item_box = item_box.row()
|
|
|
|
detail_item_box.label(text="{} {}".format(values.id.decode(),info))
|
|
|
|
row = layout.row()
|
|
|
|
else:
|
|
|
|
row.label(text="Empty")
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SessionPropertiesPanel(bpy.types.Panel):
|
|
|
|
"""Creates a Panel in the scene context of the properties editor"""
|
|
|
|
bl_label = "NET properties"
|
|
|
|
bl_idname = "SCENE_PT_layout"
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "scene"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return net_operators.client
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
net_settings = context.scene.session_settings
|
|
|
|
scene = context.scene
|
|
|
|
# Create a simple row.
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
if net_operators.client:
|
2019-02-08 18:34:10 +01:00
|
|
|
row = layout.row(align=True)
|
2019-02-22 18:22:25 +01:00
|
|
|
row.prop(net_settings,"buffer", text="")
|
|
|
|
row.operator("session.add_prop", text="",icon="ADD").property_path = net_settings.buffer
|
2019-02-08 18:34:10 +01:00
|
|
|
row = layout.row()
|
2019-03-13 17:02:53 +01:00
|
|
|
# Property area
|
2019-02-08 18:34:10 +01:00
|
|
|
area_msg = row.box()
|
2019-02-14 14:02:53 +01:00
|
|
|
if len(net_operators.client.property_map) > 0:
|
|
|
|
for key,values in net_operators.client.property_map.items():
|
2019-02-22 18:22:25 +01:00
|
|
|
item_box = area_msg.box()
|
|
|
|
detail_item_box = item_box.row()
|
|
|
|
# detail_item_box = item_box.row()
|
2019-03-14 10:09:46 +01:00
|
|
|
detail_item_box.label(text="{} ({}) {} ".format(key, values.mtype, values.id.decode()))
|
2019-02-22 18:22:25 +01:00
|
|
|
detail_item_box.operator("session.remove_prop",text="",icon="X").property_path = key
|
2019-02-08 18:34:10 +01:00
|
|
|
else:
|
|
|
|
area_msg.label(text="Empty")
|
2019-02-08 15:44:02 +01:00
|
|
|
|
|
|
|
classes = (
|
2019-03-13 17:02:53 +01:00
|
|
|
SessionSettingsPanel,
|
|
|
|
SessionUsersPanel,
|
|
|
|
SessionPropertiesPanel,
|
2019-02-08 15:44:02 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
register()
|