feat: added an initialization step
This commit is contained in:
Submodule multi_user/libs/replication updated: 88c4f065fc...a45dfef587
@ -116,16 +116,6 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
default_strategy=settings.right_strategy)
|
default_strategy=settings.right_strategy)
|
||||||
|
|
||||||
# Host a session
|
# 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:
|
if self.host:
|
||||||
try:
|
try:
|
||||||
client.host(
|
client.host(
|
||||||
@ -183,6 +173,46 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
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):
|
class SessionStopOperator(bpy.types.Operator):
|
||||||
bl_idname = "session.stop"
|
bl_idname = "session.stop"
|
||||||
bl_label = "close"
|
bl_label = "close"
|
||||||
@ -500,6 +530,7 @@ classes = (
|
|||||||
SessionCommit,
|
SessionCommit,
|
||||||
ApplyArmatureOperator,
|
ApplyArmatureOperator,
|
||||||
SessionKickOperator,
|
SessionKickOperator,
|
||||||
|
SessionInitOperator,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if hasattr(context.window_manager, 'session'):
|
if hasattr(context.window_manager, 'session'):
|
||||||
# STATE INITIAL
|
# STATE INITIAL
|
||||||
@ -144,6 +146,7 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
length=16
|
length=16
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
class SESSION_PT_settings_network(bpy.types.Panel):
|
class SESSION_PT_settings_network(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel"
|
bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel"
|
||||||
bl_label = "Network"
|
bl_label = "Network"
|
||||||
@ -175,19 +178,10 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
|||||||
row.label(text="Port:")
|
row.label(text="Port:")
|
||||||
row.prop(settings, "port", text="")
|
row.prop(settings, "port", text="")
|
||||||
row = box.row()
|
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':
|
if runtime_settings.session_mode == 'HOST':
|
||||||
row.label(text="Password:")
|
row.label(text="Password:")
|
||||||
row.prop(runtime_settings, "password", text="")
|
row.prop(runtime_settings, "password", text="")
|
||||||
row = box.row()
|
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
|
row.operator("session.start", text="HOST").host = True
|
||||||
else:
|
else:
|
||||||
row.prop(runtime_settings, "admin", text='Connect as admin' ,icon='DISCLOSURE_TRI_DOWN' if runtime_settings.admin
|
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 = box.row()
|
||||||
row.label(text="Password:")
|
row.label(text="Password:")
|
||||||
row.prop(runtime_settings, "password", text="")
|
row.prop(runtime_settings, "password", text="")
|
||||||
row = box.row()
|
|
||||||
row.label(text="Start empty:")
|
|
||||||
row.prop(settings, "start_empty", text="")
|
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("session.start", text="CONNECT").host = False
|
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
|
runtime_settings = context.window_manager.session
|
||||||
settings = utils.get_preferences()
|
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
|
# Right managment
|
||||||
if runtime_settings.session_mode == 'HOST':
|
if runtime_settings.session_mode == 'HOST':
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
@ -325,7 +323,7 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
text="",
|
text="",
|
||||||
icon='TIME').target_client = active_user.username
|
icon='TIME').target_client = active_user.username
|
||||||
|
|
||||||
if runtime_settings.admin:
|
if operators.client.online_users[settings.username]['admin']:
|
||||||
user_operations.operator(
|
user_operations.operator(
|
||||||
"session.kick",
|
"session.kick",
|
||||||
text="",
|
text="",
|
||||||
@ -479,14 +477,16 @@ def draw_property(context, parent, property_uuid, level=0):
|
|||||||
|
|
||||||
class SESSION_PT_outliner(bpy.types.Panel):
|
class SESSION_PT_outliner(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
||||||
bl_label = "Properties"
|
bl_label = "Repository"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
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):
|
def draw_header(self, context):
|
||||||
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
||||||
@ -494,10 +494,14 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
if hasattr(context.window_manager, 'session'):
|
# Filters
|
||||||
# Filters
|
settings = utils.get_preferences()
|
||||||
settings = utils.get_preferences()
|
runtime_settings = context.window_manager.session
|
||||||
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(
|
flow = layout.grid_flow(
|
||||||
row_major=True,
|
row_major=True,
|
||||||
columns=0,
|
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()
|
filter_owner=settings.username) if runtime_settings.filter_owned else operators.client.list()
|
||||||
|
|
||||||
client_keys = [key for key in key_to_filter
|
client_keys = [key for key in key_to_filter
|
||||||
if operators.client.get(uuid=key).str_type
|
if operators.client.get(uuid=key).str_type
|
||||||
in types_filter]
|
in types_filter]
|
||||||
|
|
||||||
if client_keys and len(client_keys) > 0:
|
if client_keys:
|
||||||
col = layout.column(align=True)
|
col = layout.column(align=True)
|
||||||
for key in client_keys:
|
for key in client_keys:
|
||||||
draw_property(context, col, key)
|
draw_property(context, col, key)
|
||||||
@ -533,6 +537,10 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
else:
|
else:
|
||||||
row.label(text="Empty")
|
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 = (
|
classes = (
|
||||||
SESSION_UL_users,
|
SESSION_UL_users,
|
||||||
|
Reference in New Issue
Block a user