diff --git a/bl_types/__init__.py b/bl_types/__init__.py index fc9d53d..bd8f0d1 100644 --- a/bl_types/__init__.py +++ b/bl_types/__init__.py @@ -1,4 +1,5 @@ __all__ = [ + 'bl_user', 'bl_object', 'bl_mesh', ] # Order here defines execution order diff --git a/bl_types/bl_user.py b/bl_types/bl_user.py new file mode 100644 index 0000000..348a04f --- /dev/null +++ b/bl_types/bl_user.py @@ -0,0 +1,33 @@ +import bpy +import mathutils + +from .. import utils +from ..presence import User +from ..libs.replication.data import ReplicatedDatablock + +class BlUser(ReplicatedDatablock): + def __init__(self, *args, **kwargs): + self.icon = 'CON_ARMATURE' + + super().__init__( *args, **kwargs) + + def load(self, data, target): + if target is None: + target = User() + + utils.dump_anything.load(target,data) + + def dump(self,pointer=None): + return utils.dump_anything.dump(pointer) + # def load(self, data, target): + # pass + + + # def dump(self, pointer=None): + # pass + + +bl_id = "user" +bl_class = User +bl_rep_class = BlUser + diff --git a/operators.py b/operators.py index b853b79..79f0c0e 100644 --- a/operators.py +++ b/operators.py @@ -69,9 +69,10 @@ def init_supported_datablocks(supported_types_id): global client for type_id in supported_types_id: - for item in getattr(bpy.data,type_id): - print(item) - client.add(item) + if hasattr(bpy.data,type_id): + for item in getattr(bpy.data,type_id): + print(item) + client.add(item) # def default_tick(): @@ -146,7 +147,13 @@ class SessionStartOperator(bpy.types.Operator): address=settings.ip, port=settings.port ) - + + usr = presence.User( + username=settings.username, + color=list(settings.client_color), + ) + client.add(usr) + # settings.is_running = True # bpy.ops.session.refresh() #register_ticks() diff --git a/presence.py b/presence.py index 2ff5b94..a640d91 100644 --- a/presence.py +++ b/presence.py @@ -81,6 +81,15 @@ def get_client_2d(coords): else: return (0, 0) +class User(): + def __init__(self, username=None, color=(0,0,0,1)): + self.name = username + self.color = color + self.location = (0,0,0) + self.active_object = "" + + + class DrawFactory(object): diff --git a/ui.py b/ui.py index 6981f30..a45acb6 100644 --- a/ui.py +++ b/ui.py @@ -188,27 +188,27 @@ class SESSION_PT_outliner(bpy.types.Panel): row = layout.row() 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() + # 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 + area_msg = layout.row() # Property area - area_msg = row.box() + # area_msg = row.box() client_keys = operators.client.list() if client_keys and len(client_keys) > 0: - + col = layout.column(align=True) for item in sorted(client_keys, key=get_client_key): + area_msg = col.row(align = True) item_box = area_msg.box() - - detail_item_box = item_box.row(align = True) + detail_item_box = item_box.row() detail_item_box.label(text="",icon=item.icon) detail_item_box.label(text="{} ".format(item.uuid)) detail_item_box.label(text="{} ".format(item.owner)) - + # right_icon = "DECORATE_UNLOCKED" # if owner == net_settings.username: # right_icon="DECORATE_UNLOCKED"