multi-user/net_ui.py

60 lines
1.6 KiB
Python
Raw Normal View History

import bpy
from . import net_components
from . import net_operators
class SessionPanel(bpy.types.Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "Net Session"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
# def draw_header(self, context):
2019-02-11 18:10:56 +01:00
# self.layout.prop(context.scene.session_settings, "username", text="")
def draw(self, context):
layout = self.layout
2019-02-08 18:34:10 +01:00
scene = context.scene
# Create a simple row.
row = layout.row()
2019-02-11 17:31:03 +01:00
if net_operators.client:
row.operator("session.stop")
2019-02-08 18:34:10 +01:00
row = layout.row()
row = layout.row(align=True)
row.prop(scene,"message",text="")
row.operator("session.send").message = scene.message
row = layout.row()
# Debug area
row = layout.row()
area_msg = row.box()
2019-02-11 17:31:03 +01:00
if len(net_operators.client.store) > 0:
for (id,msg) in net_operators.client.store:
area_msg.label(text="{}:{}".format(id,msg))
2019-02-08 18:34:10 +01:00
else:
area_msg.label(text="Empty")
2019-02-08 18:34:10 +01:00
else:
2019-02-11 18:10:56 +01:00
row = layout.row()
row.prop(scene.session_settings,"username",text="")
row = layout.row()
2019-02-08 18:34:10 +01:00
row.operator("session.join")
row.operator("session.create")
2019-02-08 18:34:10 +01:00
2019-02-11 18:10:56 +01:00
classes = (
2019-02-11 17:31:03 +01:00
SessionPanel,
)
register, unregister = bpy.utils.register_classes_factory(classes)
if __name__ == "__main__":
register()