diff --git a/multi_user/libs/replication b/multi_user/libs/replication index 88c4f06..a45dfef 160000 --- a/multi_user/libs/replication +++ b/multi_user/libs/replication @@ -1 +1 @@ -Subproject commit 88c4f065fca671b8cae3161c588867de44fd1974 +Subproject commit a45dfef587b945cd9f3008fb8fdc6918ef576f08 diff --git a/multi_user/operators.py b/multi_user/operators.py index 47372a0..3fc2abe 100644 --- a/multi_user/operators.py +++ b/multi_user/operators.py @@ -116,16 +116,6 @@ class SessionStartOperator(bpy.types.Operator): default_strategy=settings.right_strategy) # Host a session - if self.host or runtime_settings.admin: - # Scene setup - if settings.start_empty: - utils.clean_scene() - - for scene in bpy.data.scenes: - scene_uuid = client.add(scene) - client.commit(scene_uuid) - client.push(scene_uuid) - if self.host: try: client.host( @@ -183,6 +173,46 @@ class SessionStartOperator(bpy.types.Operator): return {"FINISHED"} +class SessionInitOperator(bpy.types.Operator): + bl_idname = "session.init" + bl_label = "Init session repostitory from" + bl_description = "Init the current session" + bl_options = {"REGISTER"} + + init_method: bpy.props.EnumProperty( + name='init_method', + description='Init repo', + items={ + ('EMPTY', 'an empty scene', 'start empty'), + ('BLEND', 'current scenes', 'use current scenes')}, + default='BLEND') + + @classmethod + def poll(cls, context): + return True + + def draw(self, context): + layout = self.layout + col = layout.column() + col.prop(self, 'init_method', text="") + + def invoke(self, context, event): + wm = context.window_manager + return wm.invoke_props_dialog(self) + + def execute(self, context): + global client + + if self.init_method == 'EMPTY': + utils.clean_scene() + + for scene in bpy.data.scenes: + scene_uuid = client.add(scene) + client.commit(scene_uuid) + client.push(scene_uuid) + + return {"FINISHED"} + class SessionStopOperator(bpy.types.Operator): bl_idname = "session.stop" bl_label = "close" @@ -500,6 +530,7 @@ classes = ( SessionCommit, ApplyArmatureOperator, SessionKickOperator, + SessionInitOperator, ) diff --git a/multi_user/ui.py b/multi_user/ui.py index 3cb6fd7..e675ab7 100644 --- a/multi_user/ui.py +++ b/multi_user/ui.py @@ -90,6 +90,8 @@ class SESSION_PT_settings(bpy.types.Panel): layout = self.layout layout.use_property_split = True row = layout.row() + + if hasattr(context.window_manager, 'session'): # STATE INITIAL @@ -144,6 +146,7 @@ class SESSION_PT_settings(bpy.types.Panel): length=16 )) + class SESSION_PT_settings_network(bpy.types.Panel): bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel" bl_label = "Network" @@ -175,19 +178,10 @@ class SESSION_PT_settings_network(bpy.types.Panel): row.label(text="Port:") row.prop(settings, "port", text="") row = box.row() - row.label(text="IPC Port:") - row.prop(settings, "ipc_port", text="") - row = box.row() - row.label(text="Timeout (ms):") - row.prop(settings, "connection_timeout", text="") - row = box.row() if runtime_settings.session_mode == 'HOST': row.label(text="Password:") row.prop(runtime_settings, "password", text="") row = box.row() - row.label(text="Start empty:") - row.prop(settings, "start_empty", text="") - row = box.row() row.operator("session.start", text="HOST").host = True else: row.prop(runtime_settings, "admin", text='Connect as admin' ,icon='DISCLOSURE_TRI_DOWN' if runtime_settings.admin @@ -196,9 +190,6 @@ class SESSION_PT_settings_network(bpy.types.Panel): row = box.row() row.label(text="Password:") row.prop(runtime_settings, "password", text="") - row = box.row() - row.label(text="Start empty:") - row.prop(settings, "start_empty", text="") row = box.row() row.operator("session.start", text="CONNECT").host = False @@ -249,6 +240,13 @@ class SESSION_PT_settings_replication(bpy.types.Panel): runtime_settings = context.window_manager.session settings = utils.get_preferences() + row = layout.row() + row.label(text="IPC Port:") + row.prop(settings, "ipc_port", text="") + row = layout.row() + row.label(text="Timeout (ms):") + row.prop(settings, "connection_timeout", text="") + # Right managment if runtime_settings.session_mode == 'HOST': row = layout.row() @@ -325,7 +323,7 @@ class SESSION_PT_user(bpy.types.Panel): text="", icon='TIME').target_client = active_user.username - if runtime_settings.admin: + if operators.client.online_users[settings.username]['admin']: user_operations.operator( "session.kick", text="", @@ -479,14 +477,16 @@ def draw_property(context, parent, property_uuid, level=0): class SESSION_PT_outliner(bpy.types.Panel): bl_idname = "MULTIUSER_PROPERTIES_PT_panel" - bl_label = "Properties" + bl_label = "Repository" bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel' @classmethod def poll(cls, context): - return operators.client and operators.client.state['STATE'] == 2 + return hasattr(context.window_manager, 'session') and \ + operators.client and \ + operators.client.state['STATE'] == 2 def draw_header(self, context): self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE') @@ -494,10 +494,14 @@ class SESSION_PT_outliner(bpy.types.Panel): def draw(self, context): layout = self.layout - if hasattr(context.window_manager, 'session'): - # Filters - settings = utils.get_preferences() - runtime_settings = context.window_manager.session + # Filters + settings = utils.get_preferences() + runtime_settings = context.window_manager.session + usr = operators.client.online_users.get(settings.username) + is_repository_init = operators.client.list() + row = layout.row() + + if is_repository_init: flow = layout.grid_flow( row_major=True, columns=0, @@ -522,10 +526,10 @@ class SESSION_PT_outliner(bpy.types.Panel): filter_owner=settings.username) if runtime_settings.filter_owned else operators.client.list() client_keys = [key for key in key_to_filter - if operators.client.get(uuid=key).str_type - in types_filter] + if operators.client.get(uuid=key).str_type + in types_filter] - if client_keys and len(client_keys) > 0: + if client_keys: col = layout.column(align=True) for key in client_keys: draw_property(context, col, key) @@ -533,6 +537,10 @@ class SESSION_PT_outliner(bpy.types.Panel): else: row.label(text="Empty") + elif usr and usr['admin']: + row.operator("session.init", icon='TOOL_SETTINGS', text="Init") + else: + row.label(text="Waiting for init") classes = ( SESSION_UL_users,