multi-user/net_ui.py

74 lines
2.4 KiB
Python
Raw Normal View History

import bpy
from . import net_components
from . import net_operators
2019-03-07 13:45:44 +01:00
class SessionPanel(bpy.types.Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "bl network"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
def draw_header(self, context):
net_settings = context.scene.session_settings
if net_settings.is_running:
self.layout.label(text="",icon='HIDE_OFF')
else:
self.layout.label(text="",icon='HIDE_ON')
# self.layout.label(text="Offline")
def draw(self, context):
layout = self.layout
2019-02-08 18:34:10 +01:00
net_settings = context.scene.session_settings
scene = context.scene
# Create a simple row.
row = layout.row()
2019-02-11 17:31:03 +01:00
if net_operators.client:
row.label(text="Net frequency:")
row.prop(net_settings,"update_frequency",text="")
2019-02-08 18:34:10 +01:00
row = layout.row(align=True)
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()
# Debug area
row = layout.row()
2019-02-08 18:34:10 +01:00
area_msg = row.box()
if len(net_operators.client.property_map) > 0:
for key,values in net_operators.client.property_map.items():
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.mtype, values.id.decode()))
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")
row = layout.row()
row.operator("session.stop")
2019-02-08 18:34:10 +01:00
else:
2019-02-11 18:10:56 +01:00
row = layout.row()
2019-03-06 14:01:33 +01:00
row.prop(scene.session_settings,"username",text="username:")
2019-02-11 18:10:56 +01:00
row = layout.row()
2019-02-08 18:34:10 +01:00
row.operator("session.join")
2019-02-25 17:12:31 +01:00
row = layout.row()
2019-02-08 18:34:10 +01:00
row.operator("session.create")
2019-03-07 13:45:44 +01:00
row = layout.row()
row.operator("session.draw")
row.operator("session.update_client")
classes = (
2019-02-11 17:31:03 +01:00
SessionPanel,
)
register, unregister = bpy.utils.register_classes_factory(classes)
if __name__ == "__main__":
register()