feat: edit>preferences + serverpassword ui

This commit is contained in:
Fabian 2021-07-12 18:01:35 +02:00
parent 41c7c569ca
commit fc91b252f4
3 changed files with 108 additions and 44 deletions

View File

@ -163,7 +163,8 @@ class SessionStartOperator(bpy.types.Operator):
settings = utils.get_preferences() settings = utils.get_preferences()
runtime_settings = context.window_manager.session runtime_settings = context.window_manager.session
users = bpy.data.window_managers['WinMan'].online_users users = bpy.data.window_managers['WinMan'].online_users
admin_pass = settings.password admin_pass = settings.admin_password
server_pass = settings.server_password
users.clear() users.clear()
deleyables.clear() deleyables.clear()
@ -229,12 +230,14 @@ class SessionStartOperator(bpy.types.Operator):
'origin', 'origin',
'127.0.0.1', '127.0.0.1',
settings.port, settings.port,
server_password=server_pass,
admin_password=admin_pass) admin_password=admin_pass)
session.host( session.host(
repository= repo, repository= repo,
remote='origin', remote='origin',
timeout=settings.connection_timeout, timeout=settings.connection_timeout,
password=admin_pass, server_password=server_pass,
admin_password=admin_pass,
cache_directory=settings.cache_directory, cache_directory=settings.cache_directory,
server_log_level=logging.getLevelName( server_log_level=logging.getLevelName(
logging.getLogger().level), logging.getLogger().level),
@ -247,8 +250,9 @@ class SessionStartOperator(bpy.types.Operator):
else: else:
if not runtime_settings.admin: if not runtime_settings.admin:
utils.clean_scene() utils.clean_scene()
# regular session, no password needed # regular session, no admin_password needed nor server_password
admin_pass = None admin_pass = None
server_pass = None
try: try:
porcelain.remote_add( porcelain.remote_add(
@ -256,11 +260,13 @@ class SessionStartOperator(bpy.types.Operator):
'origin', 'origin',
settings.ip, settings.ip,
settings.port, settings.port,
server_password=server_pass,
admin_password=admin_pass) admin_password=admin_pass)
session.connect( session.connect(
repository= repo, repository= repo,
timeout=settings.connection_timeout, timeout=settings.connection_timeout,
password=admin_pass server_password=server_pass,
admin_password=admin_pass
) )
except Exception as e: except Exception as e:
self.report({'ERROR'}, str(e)) self.report({'ERROR'}, str(e))
@ -865,7 +871,8 @@ class SessionPresetServerAdd(bpy.types.Operator):
new_server.name = settings.server_name new_server.name = settings.server_name
new_server.server_ip = settings.ip new_server.server_ip = settings.ip
new_server.server_port = settings.port new_server.server_port = settings.port
new_server.server_password = settings.password new_server.server_server_password = settings.server_password
new_server.server_admin_password = settings.admin_password
settings.server_preset_interface = settings.server_name settings.server_preset_interface = settings.server_name

View File

@ -37,11 +37,13 @@ DEFAULT_PRESETS = {
"localhost" : { "localhost" : {
"server_ip": "localhost", "server_ip": "localhost",
"server_port": 5555, "server_port": 5555,
"server_password": "admin" "admin_password": "admin",
"server_password": ""
}, },
"public session" : { "public session" : {
"server_ip": "51.75.71.183", "server_ip": "51.75.71.183",
"server_port": 5555, "server_port": 5555,
"admin_password": "",
"server_password": "" "server_password": ""
}, },
} }
@ -82,7 +84,8 @@ def update_server_preset_interface(self, context):
self.server_name = self.server_preset.get(self.server_preset_interface).name self.server_name = self.server_preset.get(self.server_preset_interface).name
self.ip = self.server_preset.get(self.server_preset_interface).server_ip self.ip = self.server_preset.get(self.server_preset_interface).server_ip
self.port = self.server_preset.get(self.server_preset_interface).server_port self.port = self.server_preset.get(self.server_preset_interface).server_port
self.password = self.server_preset.get(self.server_preset_interface).server_password self.server_password = self.server_preset.get(self.server_preset_interface).server_server_password
self.admin_password = self.server_preset.get(self.server_preset_interface).server_admin_password
def update_directory(self, context): def update_directory(self, context):
new_dir = Path(self.cache_directory) new_dir = Path(self.cache_directory)
@ -112,7 +115,8 @@ class ReplicatedDatablock(bpy.types.PropertyGroup):
class ServerPreset(bpy.types.PropertyGroup): class ServerPreset(bpy.types.PropertyGroup):
server_ip: bpy.props.StringProperty() server_ip: bpy.props.StringProperty()
server_port: bpy.props.IntProperty(default=5555) server_port: bpy.props.IntProperty(default=5555)
server_password: bpy.props.StringProperty(default="admin", subtype = "PASSWORD") server_server_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
server_admin_password: bpy.props.StringProperty(default="admin", subtype = "PASSWORD")
def set_sync_render_settings(self, value): def set_sync_render_settings(self, value):
self['sync_render_settings'] = value self['sync_render_settings'] = value
@ -173,6 +177,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
) )
client_color: bpy.props.FloatVectorProperty( client_color: bpy.props.FloatVectorProperty(
name="client_instance_color", name="client_instance_color",
description='User color',
subtype='COLOR', subtype='COLOR',
default=randomColor()) default=randomColor())
port: bpy.props.IntProperty( port: bpy.props.IntProperty(
@ -185,12 +190,18 @@ class SessionPrefs(bpy.types.AddonPreferences):
description="Custom name of the server", description="Custom name of the server",
default='localhost', default='localhost',
) )
password: bpy.props.StringProperty( server_password: bpy.props.StringProperty(
name="password", name="server_password",
default=random_string_digits(), default=random_string_digits(),
description='Session password', description='Session password',
subtype='PASSWORD' subtype='PASSWORD'
) )
admin_password: bpy.props.StringProperty(
name="admin_password",
default=random_string_digits(),
description='Admin password',
subtype='PASSWORD'
)
sync_flags: bpy.props.PointerProperty( sync_flags: bpy.props.PointerProperty(
type=ReplicationFlags type=ReplicationFlags
) )
@ -230,6 +241,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
name="Category", name="Category",
description="Preferences Category", description="Preferences Category",
items=[ items=[
('PREF', "Preferences", "Preferences of this add-on"),
('CONFIG', "Configuration", "Configuration of this add-on"), ('CONFIG', "Configuration", "Configuration of this add-on"),
('UPDATE', "Update", "Update this add-on"), ('UPDATE', "Update", "Update this add-on"),
], ],
@ -283,18 +295,23 @@ class SessionPrefs(bpy.types.AddonPreferences):
conf_session_identity_expanded: bpy.props.BoolProperty( conf_session_identity_expanded: bpy.props.BoolProperty(
name="Identity", name="Identity",
description="Identity", description="Identity",
default=True default=False
) )
conf_session_net_expanded: bpy.props.BoolProperty( conf_session_net_expanded: bpy.props.BoolProperty(
name="Net", name="Net",
description="net", description="net",
default=True default=False
) )
conf_session_hosting_expanded: bpy.props.BoolProperty( conf_session_hosting_expanded: bpy.props.BoolProperty(
name="Rights", name="Rights",
description="Rights", description="Rights",
default=False default=False
) )
conf_session_rep_expanded: bpy.props.BoolProperty(
name="Replication",
description="Replication",
default=False
)
conf_session_cache_expanded: bpy.props.BoolProperty( conf_session_cache_expanded: bpy.props.BoolProperty(
name="Cache", name="Cache",
description="cache", description="cache",
@ -305,6 +322,16 @@ class SessionPrefs(bpy.types.AddonPreferences):
description="Interface", description="Interface",
default=False default=False
) )
sidebar_repository_shown: bpy.props.BoolProperty(
name="sidebar_repository_shown",
description="sidebar_repository_shown",
default=False
)
sidebar_advanced_shown: bpy.props.BoolProperty(
name="sidebar_advanced_shown",
description="sidebar_advanced_shown",
default=False
)
sidebar_advanced_rep_expanded: bpy.props.BoolProperty( sidebar_advanced_rep_expanded: bpy.props.BoolProperty(
name="sidebar_advanced_rep_expanded", name="sidebar_advanced_rep_expanded",
description="sidebar_advanced_rep_expanded", description="sidebar_advanced_rep_expanded",
@ -386,38 +413,25 @@ class SessionPrefs(bpy.types.AddonPreferences):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.row().prop(self, "category", expand=True) layout.row().prop(self, "category", expand=True)
if self.category == 'PREF':
settings=get_preferences()
row = layout.row(align = True)
# USER SETTINGS
row.prop(self, "username", text="User")
row.prop(self, "client_color", text="")
row = layout.row()
row.label(text="Hide settings:")
row = layout.row()
row.prop(self, "sidebar_advanced_shown", text="Hide “Advanced” settings in side pannel (Not in session)")
row = layout.row()
row.prop(self, "sidebar_repository_shown", text="Hide “Repository” settings in side pannel (In session)")
if self.category == 'CONFIG': if self.category == 'CONFIG':
grid = layout.column() grid = layout.column()
# USER INFORMATIONS
box = grid.box()
box.prop(
self, "conf_session_identity_expanded", text="User information",
icon=get_expanded_icon(self.conf_session_identity_expanded),
emboss=False)
if self.conf_session_identity_expanded:
box.row().prop(self, "username", text="name")
box.row().prop(self, "client_color", text="color")
# NETWORK SETTINGS
box = grid.box()
box.prop(
self, "conf_session_net_expanded", text="Networking",
icon=get_expanded_icon(self.conf_session_net_expanded),
emboss=False)
if self.conf_session_net_expanded:
box.row().prop(self, "ip", text="Address")
row = box.row()
row.label(text="Port:")
row.prop(self, "port", text="")
row = box.row()
row.label(text="Init the session from:")
row.prop(self, "init_method", text="")
# HOST SETTINGS # HOST SETTINGS
box = grid.box() box = grid.box()
box.prop( box.prop(
@ -428,6 +442,46 @@ class SessionPrefs(bpy.types.AddonPreferences):
row = box.row() row = box.row()
row.label(text="Init the session from:") row.label(text="Init the session from:")
row.prop(self, "init_method", text="") row.prop(self, "init_method", text="")
row = box.row()
row.prop(self, "server_password", text="Server password")
row = box.row()
row.prop(self, "admin_password", text="Admin password")
# NETWORKING
box = grid.box()
box.prop(
self, "conf_session_net_expanded", text="Network",
icon=get_expanded_icon(self.conf_session_net_expanded),
emboss=False)
if self.conf_session_net_expanded:
row = box.row()
row.label(text="Timeout (ms):")
row.prop(self, "connection_timeout", text="")
# REPLICATION
box = grid.box()
box.prop(
self, "conf_session_rep_expanded", text="Replication",
icon=get_expanded_icon(self.conf_session_rep_expanded),
emboss=False)
if self.conf_session_rep_expanded:
box_row = box.row()
box_row = box.row()
box_row.prop(self.sync_flags, "sync_render_settings")
box_row = box.row()
box_row.prop(self.sync_flags, "sync_active_camera")
box_row = box.row()
box_row.prop(self.sync_flags, "sync_during_editmode")
box_row = box.row()
if self.sync_flags.sync_during_editmode:
warning = box_row.box()
warning.label(text="Don't use this with heavy meshes !", icon='ERROR')
box_row = box.row()
box_row.prop(self, "depsgraph_update_rate", text="Apply delay")
# CACHE SETTINGS # CACHE SETTINGS
box = grid.box() box = grid.box()

View File

@ -182,7 +182,7 @@ class SESSION_PT_settings_network(bpy.types.Panel):
row.prop(settings, "init_method", text="") row.prop(settings, "init_method", text="")
row = box.row() row = box.row()
row.label(text="Admin password:") row.label(text="Admin password:")
row.prop(settings, "password", text="") row.prop(settings, "admin_password", text="")
row = box.row() row = box.row()
row.operator("session.start", text="HOST").host = True row.operator("session.start", text="HOST").host = True
else: else:
@ -198,7 +198,7 @@ class SESSION_PT_settings_network(bpy.types.Panel):
if runtime_settings.admin: if runtime_settings.admin:
row = box.row() row = box.row()
row.label(text="Password:") row.label(text="Password:")
row.prop(settings, "password", text="") row.prop(settings, "admin_password", text="")
row = box.row() row = box.row()
row.operator("session.start", text="CONNECT").host = False row.operator("session.start", text="CONNECT").host = False
@ -242,8 +242,10 @@ class SESSION_PT_advanced_settings(bpy.types.Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
settings = get_preferences()
return not session \ return not session \
or (session and session.state == 0) or (session and session.state == 0) \
and not settings.sidebar_advanced_shown
def draw_header(self, context): def draw_header(self, context):
self.layout.label(text="", icon='PREFERENCES') self.layout.label(text="", icon='PREFERENCES')
@ -254,7 +256,6 @@ class SESSION_PT_advanced_settings(bpy.types.Panel):
runtime_settings = context.window_manager.session runtime_settings = context.window_manager.session
settings = get_preferences() settings = get_preferences()
net_section = layout.row().box() net_section = layout.row().box()
net_section.prop( net_section.prop(
settings, settings,
@ -323,6 +324,7 @@ class SESSION_PT_advanced_settings(bpy.types.Panel):
log_section_row = log_section.row() log_section_row = log_section.row()
log_section_row.label(text="Log level:") log_section_row.label(text="Log level:")
log_section_row.prop(settings, 'logging_level', text="") log_section_row.prop(settings, 'logging_level', text="")
class SESSION_PT_user(bpy.types.Panel): class SESSION_PT_user(bpy.types.Panel):
bl_idname = "MULTIUSER_USER_PT_panel" bl_idname = "MULTIUSER_USER_PT_panel"
bl_label = "Online users" bl_label = "Online users"
@ -573,7 +575,8 @@ class SESSION_PT_repository(bpy.types.Panel):
return hasattr(context.window_manager, 'session') and \ return hasattr(context.window_manager, 'session') and \
session and \ session and \
(session.state == STATE_ACTIVE or \ (session.state == STATE_ACTIVE or \
session.state == STATE_LOBBY and admin) session.state == STATE_LOBBY and admin) and \
not settings.sidebar_repository_shown
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')