feat: admin client repository init on connection to an empty server
This commit is contained in:
Submodule multi_user/libs/replication updated: f367804514...a2c7a4e8d9
@ -139,9 +139,7 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
utils.clean_scene()
|
utils.clean_scene()
|
||||||
# regular client, no password needed
|
# regular client, no password needed
|
||||||
admin_pass = None
|
admin_pass = None
|
||||||
else:
|
|
||||||
for scene in bpy.data.scenes:
|
|
||||||
client.add(scene)
|
|
||||||
try:
|
try:
|
||||||
client.connect(
|
client.connect(
|
||||||
id=settings.username,
|
id=settings.username,
|
||||||
@ -213,9 +211,10 @@ class SessionInitOperator(bpy.types.Operator):
|
|||||||
utils.clean_scene()
|
utils.clean_scene()
|
||||||
|
|
||||||
for scene in bpy.data.scenes:
|
for scene in bpy.data.scenes:
|
||||||
scene_uuid = client.add(scene)
|
client.add(scene)
|
||||||
client.commit(scene_uuid)
|
|
||||||
client.push(scene_uuid)
|
client.init()
|
||||||
|
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return operators.client and operators.client.state['STATE'] == 2
|
return operators.client and operators.client.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -478,7 +478,7 @@ def draw_property(context, parent, property_uuid, level=0):
|
|||||||
detail_item_box.label(text="", icon="DECORATE_LOCKED")
|
detail_item_box.label(text="", icon="DECORATE_LOCKED")
|
||||||
|
|
||||||
|
|
||||||
class SESSION_PT_outliner(bpy.types.Panel):
|
class SESSION_PT_repository(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
||||||
bl_label = "Repository"
|
bl_label = "Repository"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
@ -489,7 +489,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return hasattr(context.window_manager, 'session') and \
|
return hasattr(context.window_manager, 'session') and \
|
||||||
operators.client and \
|
operators.client and \
|
||||||
operators.client.state['STATE'] == 2
|
operators.client.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]
|
||||||
|
|
||||||
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')
|
||||||
@ -500,11 +500,13 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
# 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()
|
session = operators.client
|
||||||
|
usr = session.online_users.get(settings.username)
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
if is_repository_init:
|
if session.state['STATE'] == STATE_ACTIVE:
|
||||||
flow = layout.grid_flow(
|
flow = layout.grid_flow(
|
||||||
row_major=True,
|
row_major=True,
|
||||||
columns=0,
|
columns=0,
|
||||||
@ -540,7 +542,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
else:
|
else:
|
||||||
row.label(text="Empty")
|
row.label(text="Empty")
|
||||||
|
|
||||||
elif usr and usr['admin']:
|
elif session.state['STATE'] == STATE_LOBBY and usr and usr['admin']:
|
||||||
row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
|
row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
|
||||||
else:
|
else:
|
||||||
row.label(text="Waiting for init")
|
row.label(text="Waiting for init")
|
||||||
@ -554,7 +556,7 @@ classes = (
|
|||||||
SESSION_PT_settings_replication,
|
SESSION_PT_settings_replication,
|
||||||
SESSION_PT_user,
|
SESSION_PT_user,
|
||||||
SESSION_PT_services,
|
SESSION_PT_services,
|
||||||
SESSION_PT_outliner,
|
SESSION_PT_repository,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user