feat: clean files+add repository sync icons
This commit is contained in:
parent
beaafce4fa
commit
0a798bb21b
BIN
multi_user/icons/repository_merge.png
Normal file
BIN
multi_user/icons/repository_merge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
BIN
multi_user/icons/repository_push.png
Normal file
BIN
multi_user/icons/repository_push.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
@ -110,7 +110,6 @@ def initialize_session():
|
|||||||
for d in deleyables:
|
for d in deleyables:
|
||||||
d.register()
|
d.register()
|
||||||
|
|
||||||
|
|
||||||
# Step 5: Clearing history
|
# Step 5: Clearing history
|
||||||
utils.flush_history()
|
utils.flush_history()
|
||||||
|
|
||||||
@ -144,7 +143,7 @@ def on_connection_end(reason="none"):
|
|||||||
if isinstance(handler, logging.FileHandler):
|
if isinstance(handler, logging.FileHandler):
|
||||||
logger.removeHandler(handler)
|
logger.removeHandler(handler)
|
||||||
if reason != "user":
|
if reason != "user":
|
||||||
bpy.ops.session.notify('INVOKE_DEFAULT', message=f"Disconnected from session. Reason: {reason}. ")
|
bpy.ops.session.notify('INVOKE_DEFAULT', message=f"Disconnected from session. Reason: {reason}. ") #TODO: change op session.notify to add ui + change reason (in replication->interface)
|
||||||
|
|
||||||
|
|
||||||
# OPERATORS
|
# OPERATORS
|
||||||
@ -161,10 +160,11 @@ class SessionConnectOperator(bpy.types.Operator):
|
|||||||
global deleyables
|
global deleyables
|
||||||
|
|
||||||
settings = utils.get_preferences()
|
settings = utils.get_preferences()
|
||||||
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.admin_password
|
active_server_index = context.window_manager.server_index if context.window_manager.server_index<=len(settings.server_preset)-1 else 0
|
||||||
server_pass = settings.server_password if settings.server_password else None
|
active_server = settings.server_preset[active_server_index]
|
||||||
|
admin_pass = active_server.admin_password if active_server.use_admin_password else None
|
||||||
|
server_pass = active_server.server_password if active_server.use_server_password else None
|
||||||
|
|
||||||
users.clear()
|
users.clear()
|
||||||
deleyables.clear()
|
deleyables.clear()
|
||||||
@ -213,18 +213,15 @@ class SessionConnectOperator(bpy.types.Operator):
|
|||||||
username=settings.username)
|
username=settings.username)
|
||||||
|
|
||||||
# Join a session
|
# Join a session
|
||||||
if not runtime_settings.admin:
|
if not active_server.use_admin_password:
|
||||||
utils.clean_scene()
|
utils.clean_scene()
|
||||||
# regular session, no admin_password needed nor server_password
|
|
||||||
admin_pass = None
|
|
||||||
server_pass = None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
porcelain.remote_add(
|
porcelain.remote_add(
|
||||||
repo,
|
repo,
|
||||||
'origin',
|
'origin',
|
||||||
settings.ip,
|
active_server.ip,
|
||||||
settings.port,
|
active_server.port,
|
||||||
server_password=server_pass,
|
server_password=server_pass,
|
||||||
admin_password=admin_pass)
|
admin_password=admin_pass)
|
||||||
session.connect(
|
session.connect(
|
||||||
@ -276,8 +273,8 @@ class SessionHostOperator(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.admin_password
|
admin_pass = settings.host_admin_password if settings.host_use_admin_password else None
|
||||||
server_pass = settings.server_password if settings.server_password else None
|
server_pass = settings.host_server_password if settings.host_use_server_password else None
|
||||||
|
|
||||||
users.clear()
|
users.clear()
|
||||||
deleyables.clear()
|
deleyables.clear()
|
||||||
@ -341,7 +338,7 @@ class SessionHostOperator(bpy.types.Operator):
|
|||||||
repo,
|
repo,
|
||||||
'origin',
|
'origin',
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
settings.port,
|
settings.host_port,
|
||||||
server_password=server_pass,
|
server_password=server_pass,
|
||||||
admin_password=admin_pass)
|
admin_password=admin_pass)
|
||||||
session.host(
|
session.host(
|
||||||
@ -929,12 +926,12 @@ class SessionPresetServerAdd(bpy.types.Operator):
|
|||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
server_name: bpy.props.StringProperty(default="")
|
server_name: bpy.props.StringProperty(default="")
|
||||||
server_ip: bpy.props.StringProperty(default="127.0.0.1")
|
ip: bpy.props.StringProperty(default="127.0.0.1")
|
||||||
server_port: bpy.props.IntProperty(default=5555)
|
port: bpy.props.IntProperty(default=5555)
|
||||||
use_server_password: bpy.props.BoolProperty(default=False)
|
use_server_password: bpy.props.BoolProperty(default=False)
|
||||||
server_server_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
server_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
||||||
use_admin_password: bpy.props.BoolProperty(default=False)
|
use_admin_password: bpy.props.BoolProperty(default=False)
|
||||||
server_admin_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
admin_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@ -942,37 +939,36 @@ class SessionPresetServerAdd(bpy.types.Operator):
|
|||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
self.server_name = ""
|
self.server_name = ""
|
||||||
self.server_ip = "127.0.0.1"
|
self.ip = "127.0.0.1"
|
||||||
self.server_port = 5555
|
self.port = 5555
|
||||||
self.use_server_password = False
|
self.use_server_password = False
|
||||||
self.server_server_password = ""
|
self.server_password = ""
|
||||||
self.use_admin_password = False
|
self.use_admin_password = False
|
||||||
self.server_admin_password = ""
|
self.admin_password = ""
|
||||||
|
|
||||||
assert(context)
|
assert(context)
|
||||||
return context.window_manager.invoke_props_dialog(self)
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
settings = utils.get_preferences()
|
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(self, "server_name", text="Server name")
|
row.prop(self, "server_name", text="Server name")
|
||||||
row = layout.row(align = True)
|
row = layout.row(align = True)
|
||||||
row.prop(self, "server_ip", text="IP+port")
|
row.prop(self, "ip", text="IP+port")
|
||||||
row.prop(self, "server_port", text="")
|
row.prop(self, "port", text="")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.prop(self, "use_server_password", text="Server password:")
|
col.prop(self, "use_server_password", text="Server password:")
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = True if self.use_server_password else False
|
col.enabled = True if self.use_server_password else False
|
||||||
col.prop(self, "server_server_password", text="")
|
col.prop(self, "server_password", text="")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.prop(self, "use_admin_password", text="Admin password:")
|
col.prop(self, "use_admin_password", text="Admin password:")
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = True if self.use_admin_password else False
|
col.enabled = True if self.use_admin_password else False
|
||||||
col.prop(self, "server_admin_password", text="")
|
col.prop(self, "admin_password", text="")
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
assert(context)
|
assert(context)
|
||||||
@ -983,12 +979,12 @@ class SessionPresetServerAdd(bpy.types.Operator):
|
|||||||
new_server = existing_preset if existing_preset else settings.server_preset.add()
|
new_server = existing_preset if existing_preset else settings.server_preset.add()
|
||||||
new_server.name = str(uuid4())
|
new_server.name = str(uuid4())
|
||||||
new_server.server_name = self.server_name
|
new_server.server_name = self.server_name
|
||||||
new_server.server_ip = self.server_ip
|
new_server.ip = self.ip
|
||||||
new_server.server_port = self.server_port
|
new_server.port = self.port
|
||||||
new_server.use_server_password = self.use_server_password
|
new_server.use_server_password = self.use_server_password
|
||||||
new_server.server_server_password = self.server_server_password
|
new_server.server_password = self.server_password
|
||||||
new_server.use_admin_password = self.use_admin_password
|
new_server.use_admin_password = self.use_admin_password
|
||||||
new_server.server_admin_password = self.server_admin_password
|
new_server.admin_password = self.admin_password
|
||||||
|
|
||||||
refresh_sidebar_view()
|
refresh_sidebar_view()
|
||||||
|
|
||||||
@ -1000,7 +996,7 @@ class SessionPresetServerAdd(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class SessionPresetServerEdit(bpy.types.Operator):
|
class SessionPresetServerEdit(bpy.types.Operator): # TODO : use preset, not settings
|
||||||
"""Edit a server to the server list preset"""
|
"""Edit a server to the server list preset"""
|
||||||
bl_idname = "session.preset_server_edit"
|
bl_idname = "session.preset_server_edit"
|
||||||
bl_label = "Edit server preset"
|
bl_label = "Edit server preset"
|
||||||
@ -1014,40 +1010,31 @@ class SessionPresetServerEdit(bpy.types.Operator):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
settings = utils.get_preferences()
|
|
||||||
settings_active_server = settings.server_preset.get(self.target_server_name)
|
|
||||||
|
|
||||||
if settings_active_server :
|
|
||||||
settings.server_name = settings_active_server.server_name
|
|
||||||
settings.ip = settings_active_server.server_ip
|
|
||||||
settings.port = settings_active_server.server_port
|
|
||||||
settings.server_password = settings_active_server.server_server_password
|
|
||||||
settings.admin_password = settings_active_server.server_admin_password
|
|
||||||
|
|
||||||
assert(context)
|
assert(context)
|
||||||
return context.window_manager.invoke_props_dialog(self)
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
settings = utils.get_preferences()
|
settings = utils.get_preferences()
|
||||||
|
settings_active_server = settings.server_preset.get(self.target_server_name)
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(settings, "server_name", text="Server name")
|
row.prop(settings_active_server, "server_name", text="Server name")
|
||||||
row = layout.row(align = True)
|
row = layout.row(align = True)
|
||||||
row.prop(settings, "ip", text="IP+port")
|
row.prop(settings_active_server, "ip", text="IP+port")
|
||||||
row.prop(settings, "port", text="")
|
row.prop(settings_active_server, "port", text="")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.prop(settings, "use_server_password", text="Server password:")
|
col.prop(settings_active_server, "use_server_password", text="Server password:")
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = True if settings.use_server_password else False
|
col.enabled = True if settings_active_server.use_server_password else False
|
||||||
col.prop(settings, "server_password", text="")
|
col.prop(settings_active_server, "server_password", text="")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.prop(settings, "use_admin_password", text="Admin password:")
|
col.prop(settings_active_server, "use_admin_password", text="Admin password:")
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = True if settings.use_admin_password else False
|
col.enabled = True if settings_active_server.use_admin_password else False
|
||||||
col.prop(settings, "admin_password", text="")
|
col.prop(settings_active_server, "admin_password", text="")
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
assert(context)
|
assert(context)
|
||||||
@ -1055,20 +1042,12 @@ class SessionPresetServerEdit(bpy.types.Operator):
|
|||||||
settings = utils.get_preferences()
|
settings = utils.get_preferences()
|
||||||
settings_active_server = settings.server_preset.get(self.target_server_name)
|
settings_active_server = settings.server_preset.get(self.target_server_name)
|
||||||
|
|
||||||
server = settings_active_server if settings_active_server else settings.server_preset.add()
|
|
||||||
server.server_name = settings.server_name
|
|
||||||
server.server_ip = settings.ip
|
|
||||||
server.server_port = settings.port
|
|
||||||
server.server_server_password = settings.server_password
|
|
||||||
server.server_admin_password = settings.admin_password
|
|
||||||
|
|
||||||
refresh_sidebar_view()
|
refresh_sidebar_view()
|
||||||
|
|
||||||
self.report({'INFO'}, "Server '" + settings.server_name + "' override")
|
self.report({'INFO'}, "Server '" + settings_active_server.server_name + "' override")
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class SessionPresetServerRemove(bpy.types.Operator):
|
class SessionPresetServerRemove(bpy.types.Operator):
|
||||||
"""Remove a server to the server list preset"""
|
"""Remove a server to the server list preset"""
|
||||||
bl_idname = "session.preset_server_remove"
|
bl_idname = "session.preset_server_remove"
|
||||||
@ -1090,7 +1069,7 @@ class SessionPresetServerRemove(bpy.types.Operator):
|
|||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class SessionGetInfo(bpy.types.Operator):
|
class RefreshServerStatus(bpy.types.Operator):
|
||||||
bl_idname = "session.get_info"
|
bl_idname = "session.get_info"
|
||||||
bl_label = "Get session info"
|
bl_label = "Get session info"
|
||||||
bl_description = "Get session info"
|
bl_description = "Get session info"
|
||||||
@ -1102,8 +1081,15 @@ class SessionGetInfo(bpy.types.Operator):
|
|||||||
return (session.state != STATE_ACTIVE)
|
return (session.state != STATE_ACTIVE)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
infos = porcelain.request_session_info(self.target_server, timeout=100)
|
settings = utils.get_preferences()
|
||||||
logging.info(f"Session info: {infos}")
|
|
||||||
|
for server in settings.server_preset:
|
||||||
|
infos = porcelain.request_session_info(f"{server.ip}:{server.port}", timeout=1000)
|
||||||
|
server.is_online = True if infos else False
|
||||||
|
if server.is_online:
|
||||||
|
server.is_private = infos.get("private")
|
||||||
|
|
||||||
|
logging.info(f"{server.server_name} status: {infos}")
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -1137,6 +1123,10 @@ class FirstLaunch(bpy.types.Operator):
|
|||||||
assert(context)
|
assert(context)
|
||||||
settings = utils.get_preferences()
|
settings = utils.get_preferences()
|
||||||
settings.is_first_launch = False
|
settings.is_first_launch = False
|
||||||
|
for i in range(len(settings.server_preset)): # TODO: Try to empty the server list preset in a cleaner way
|
||||||
|
settings.server_preset.remove(i)
|
||||||
|
prefs = bpy.context.preferences.addons[__package__].preferences
|
||||||
|
prefs.generate_default_presets()
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
def menu_func_import(self, context):
|
def menu_func_import(self, context):
|
||||||
@ -1167,7 +1157,7 @@ classes = (
|
|||||||
SessionPresetServerAdd,
|
SessionPresetServerAdd,
|
||||||
SessionPresetServerEdit,
|
SessionPresetServerEdit,
|
||||||
SessionPresetServerRemove,
|
SessionPresetServerRemove,
|
||||||
SessionGetInfo,
|
RefreshServerStatus,
|
||||||
GetDoc,
|
GetDoc,
|
||||||
FirstLaunch,
|
FirstLaunch,
|
||||||
)
|
)
|
||||||
|
@ -34,18 +34,20 @@ from replication.interface import session
|
|||||||
IP_REGEX = re.compile("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
|
IP_REGEX = re.compile("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
|
||||||
HOSTNAME_REGEX = re.compile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$")
|
HOSTNAME_REGEX = re.compile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$")
|
||||||
|
|
||||||
|
#SERVER PRESETS AT LAUNCH
|
||||||
DEFAULT_PRESETS = {
|
DEFAULT_PRESETS = {
|
||||||
"localhost" : {
|
"localhost" : {
|
||||||
"server_name": "localhost",
|
"server_name": "localhost",
|
||||||
"server_ip": "localhost",
|
"ip": "localhost",
|
||||||
"server_port": 5555,
|
"port": 5555,
|
||||||
|
"use_admin_password": True,
|
||||||
"admin_password": "admin",
|
"admin_password": "admin",
|
||||||
"server_password": ""
|
"server_password": ""
|
||||||
},
|
},
|
||||||
"public session" : {
|
"public session" : {
|
||||||
"server_name": "public session",
|
"server_name": "public session",
|
||||||
"server_ip": "51.75.71.183",
|
"ip": "51.75.71.183",
|
||||||
"server_port": 5555,
|
"port": 5555,
|
||||||
"admin_password": "",
|
"admin_password": "",
|
||||||
"server_password": ""
|
"server_password": ""
|
||||||
},
|
},
|
||||||
@ -83,12 +85,6 @@ def update_ip(self, context):
|
|||||||
logging.error("Wrong IP format")
|
logging.error("Wrong IP format")
|
||||||
self['ip'] = "127.0.0.1"
|
self['ip'] = "127.0.0.1"
|
||||||
|
|
||||||
def update_server_preset_interface(self, context):
|
|
||||||
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.port = self.server_preset.get(self.server_preset_interface).server_port
|
|
||||||
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)
|
||||||
@ -117,12 +113,14 @@ class ReplicatedDatablock(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
class ServerPreset(bpy.types.PropertyGroup):
|
class ServerPreset(bpy.types.PropertyGroup):
|
||||||
server_name: bpy.props.StringProperty(default="")
|
server_name: bpy.props.StringProperty(default="")
|
||||||
server_ip: bpy.props.StringProperty(default="127.0.0.1")
|
ip: bpy.props.StringProperty(default="127.0.0.1")
|
||||||
server_port: bpy.props.IntProperty(default=5555)
|
port: bpy.props.IntProperty(default=5555)
|
||||||
use_server_password: bpy.props.BoolProperty(default=False)
|
use_server_password: bpy.props.BoolProperty(default=False)
|
||||||
server_server_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
server_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
||||||
use_admin_password: bpy.props.BoolProperty(default=False)
|
use_admin_password: bpy.props.BoolProperty(default=False)
|
||||||
server_admin_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
admin_password: bpy.props.StringProperty(default="", subtype = "PASSWORD")
|
||||||
|
is_online: bpy.props.BoolProperty(default=False)
|
||||||
|
is_private: bpy.props.BoolProperty(default=False)
|
||||||
|
|
||||||
def set_sync_render_settings(self, value):
|
def set_sync_render_settings(self, value):
|
||||||
self['sync_render_settings'] = value
|
self['sync_render_settings'] = value
|
||||||
@ -172,11 +170,7 @@ class ReplicationFlags(bpy.types.PropertyGroup):
|
|||||||
class SessionPrefs(bpy.types.AddonPreferences):
|
class SessionPrefs(bpy.types.AddonPreferences):
|
||||||
bl_idname = __package__
|
bl_idname = __package__
|
||||||
|
|
||||||
ip: bpy.props.StringProperty(
|
# User settings
|
||||||
name="ip",
|
|
||||||
description='Distant host ip',
|
|
||||||
default="localhost",
|
|
||||||
update=update_ip)
|
|
||||||
username: bpy.props.StringProperty(
|
username: bpy.props.StringProperty(
|
||||||
name="Username",
|
name="Username",
|
||||||
default=f"user_{random_string_digits()}"
|
default=f"user_{random_string_digits()}"
|
||||||
@ -185,12 +179,9 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
name="client_instance_color",
|
name="client_instance_color",
|
||||||
description='User color',
|
description='User color',
|
||||||
subtype='COLOR',
|
subtype='COLOR',
|
||||||
default=randomColor())
|
default=randomColor()
|
||||||
port: bpy.props.IntProperty(
|
|
||||||
name="port",
|
|
||||||
description='Distant host port',
|
|
||||||
default=5555
|
|
||||||
)
|
)
|
||||||
|
# Current server settings
|
||||||
server_name: bpy.props.StringProperty(
|
server_name: bpy.props.StringProperty(
|
||||||
name="server_name",
|
name="server_name",
|
||||||
description="Custom name of the server",
|
description="Custom name of the server",
|
||||||
@ -200,26 +191,33 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
name="server_index",
|
name="server_index",
|
||||||
description="index of the server",
|
description="index of the server",
|
||||||
)
|
)
|
||||||
use_server_password: bpy.props.BoolProperty(
|
host_port: bpy.props.IntProperty(
|
||||||
|
name="host_port",
|
||||||
|
description='Distant host port',
|
||||||
|
default=5555
|
||||||
|
)
|
||||||
|
# User host session settings
|
||||||
|
host_use_server_password: bpy.props.BoolProperty(
|
||||||
name="use_server_password",
|
name="use_server_password",
|
||||||
description='Use session password',
|
description='Use session password',
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
server_password: bpy.props.StringProperty(
|
host_server_password: bpy.props.StringProperty(
|
||||||
name="server_password",
|
name="server_password",
|
||||||
description='Session password',
|
description='Session password',
|
||||||
subtype='PASSWORD'
|
subtype='PASSWORD'
|
||||||
)
|
)
|
||||||
use_admin_password: bpy.props.BoolProperty(
|
host_use_admin_password: bpy.props.BoolProperty(
|
||||||
name="use_admin_password",
|
name="use_admin_password",
|
||||||
description='Use admin password',
|
description='Use admin password',
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
admin_password: bpy.props.StringProperty(
|
host_admin_password: bpy.props.StringProperty(
|
||||||
name="admin_password",
|
name="admin_password",
|
||||||
description='Admin password',
|
description='Admin password',
|
||||||
subtype='PASSWORD'
|
subtype='PASSWORD'
|
||||||
)
|
)
|
||||||
|
# Other
|
||||||
is_first_launch: bpy.props.BoolProperty(
|
is_first_launch: bpy.props.BoolProperty(
|
||||||
name="is_first_launch",
|
name="is_first_launch",
|
||||||
description="First time lauching the addon",
|
description="First time lauching the addon",
|
||||||
@ -259,7 +257,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
description="Remove filecache from memory",
|
description="Remove filecache from memory",
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
# for UI
|
# For UI
|
||||||
category: bpy.props.EnumProperty(
|
category: bpy.props.EnumProperty(
|
||||||
name="Category",
|
name="Category",
|
||||||
description="Preferences Category",
|
description="Preferences Category",
|
||||||
@ -431,12 +429,6 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
name="server preset",
|
name="server preset",
|
||||||
type=ServerPreset,
|
type=ServerPreset,
|
||||||
)
|
)
|
||||||
server_preset_interface: bpy.props.EnumProperty(
|
|
||||||
name="servers",
|
|
||||||
description="servers enum",
|
|
||||||
items=server_list_callback,
|
|
||||||
update=update_server_preset_interface,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom panel
|
# Custom panel
|
||||||
panel_category: bpy.props.StringProperty(
|
panel_category: bpy.props.StringProperty(
|
||||||
@ -475,21 +467,23 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
icon=get_expanded_icon(self.conf_session_hosting_expanded),
|
icon=get_expanded_icon(self.conf_session_hosting_expanded),
|
||||||
emboss=False)
|
emboss=False)
|
||||||
if self.conf_session_hosting_expanded:
|
if self.conf_session_hosting_expanded:
|
||||||
|
row = box.row()
|
||||||
|
row.prop(self, "host_port", text="Port: ")
|
||||||
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 = box.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.prop(self, "use_server_password", text="Server password:")
|
col.prop(self, "host_use_server_password", text="Server password:")
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = True if self.use_server_password else False
|
col.enabled = True if self.host_use_server_password else False
|
||||||
col.prop(self, "server_password", text="")
|
col.prop(self, "host_server_password", text="")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.prop(self, "use_admin_password", text="Admin password:")
|
col.prop(self, "host_use_admin_password", text="Admin password:")
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = True if self.use_admin_password else False
|
col.enabled = True if self.host_use_admin_password else False
|
||||||
col.prop(self, "admin_password", text="")
|
col.prop(self, "host_admin_password", text="")
|
||||||
|
|
||||||
# NETWORKING
|
# NETWORKING
|
||||||
box = grid.box()
|
box = grid.box()
|
||||||
@ -563,6 +557,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
new_db.icon = impl.bl_icon
|
new_db.icon = impl.bl_icon
|
||||||
new_db.bl_name = impl.bl_id
|
new_db.bl_name = impl.bl_id
|
||||||
|
|
||||||
|
# Get a server preset through its name
|
||||||
def get_server_preset(self, name):
|
def get_server_preset(self, name):
|
||||||
existing_preset = None
|
existing_preset = None
|
||||||
|
|
||||||
@ -572,7 +567,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
|
|
||||||
return existing_preset
|
return existing_preset
|
||||||
|
|
||||||
# custom at launch server preset
|
# Custom at launch server preset
|
||||||
def generate_default_presets(self):
|
def generate_default_presets(self):
|
||||||
for preset_name, preset_data in DEFAULT_PRESETS.items():
|
for preset_name, preset_data in DEFAULT_PRESETS.items():
|
||||||
existing_preset = self.get_server_preset(preset_name)
|
existing_preset = self.get_server_preset(preset_name)
|
||||||
@ -581,10 +576,12 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
new_server = self.server_preset.add()
|
new_server = self.server_preset.add()
|
||||||
new_server.name = str(uuid4())
|
new_server.name = str(uuid4())
|
||||||
new_server.server_name = preset_data.get('server_name')
|
new_server.server_name = preset_data.get('server_name')
|
||||||
new_server.server_index = preset_data.get('server_index')
|
new_server.ip = preset_data.get('ip')
|
||||||
new_server.server_ip = preset_data.get('server_ip')
|
new_server.port = preset_data.get('port')
|
||||||
new_server.server_port = preset_data.get('server_port')
|
new_server.use_server_password = preset_data.get('use_server_password',False)
|
||||||
new_server.server_password = preset_data.get('server_password',None)
|
new_server.server_password = preset_data.get('server_password',None)
|
||||||
|
new_server.use_admin_password = preset_data.get('use_admin_password',False)
|
||||||
|
new_server.admin_password = preset_data.get('admin_password',None)
|
||||||
|
|
||||||
|
|
||||||
def client_list_callback(scene, context):
|
def client_list_callback(scene, context):
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
class SESSION_PT_network(bpy.types.Panel):
|
|
||||||
bl_idname = "MULTIUSER_SETTINGS_PT_network"
|
|
||||||
bl_label = "Network"
|
|
||||||
bl_space_type = 'VIEW_3D'
|
|
||||||
bl_region_type = 'UI'
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_network'
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return not session \
|
|
||||||
or (session and session.state == 0)
|
|
||||||
|
|
||||||
def draw_header(self, context):
|
|
||||||
self.layout.label(text="", icon='LINKED')
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
|
|
||||||
runtime_settings = context.window_manager.session
|
|
||||||
settings = get_preferences()
|
|
||||||
|
|
||||||
# Create a simple row.
|
|
||||||
row = layout.row()
|
|
||||||
box = row.box()
|
|
||||||
split = box.split(factor=0.35)
|
|
||||||
split.label(text="Server")
|
|
||||||
split = split.split(factor=0.3)
|
|
||||||
split.label(text="Online")
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
layout.template_list("SESSION_UL_network", "", settings,
|
|
||||||
"server_preset_interface", context.window_manager, "user_index")
|
|
||||||
|
|
||||||
|
|
||||||
class SESSION_UL_network(bpy.types.UIList):
|
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
|
|
||||||
settings = get_preferences()
|
|
||||||
server_name = '-'
|
|
||||||
server_status = 'BLANK1'
|
|
||||||
server_private = 'BLANK1'
|
|
||||||
|
|
||||||
if not session:
|
|
||||||
server_name = settings.server_name
|
|
||||||
|
|
||||||
# Session with/without password
|
|
||||||
if settings.server_password != None:
|
|
||||||
server_private = 'LOCKED'
|
|
||||||
split = layout.split(factor=0.35)
|
|
||||||
split.label(text=server_name, icon=server_private)
|
|
||||||
else:
|
|
||||||
split = layout.split(factor=0.35)
|
|
||||||
split.label(text=server_name)
|
|
||||||
|
|
||||||
# Session status
|
|
||||||
# if session online : vert else rouge
|
|
||||||
from multi_user import icons
|
|
||||||
server_status = icons.icons_col["session_status_offline"]
|
|
||||||
split.label(icon=server_status)
|
|
||||||
|
|
||||||
class SESSION_UL_users(bpy.types.UIList):
|
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
|
|
||||||
settings = get_preferences()
|
|
||||||
is_local_user = item.username == settings.username
|
|
||||||
ping = '-'
|
|
||||||
frame_current = '-'
|
|
||||||
scene_current = '-'
|
|
||||||
mode_current = '-'
|
|
||||||
mode_icon = 'BLANK1'
|
|
||||||
status_icon = 'BLANK1'
|
|
||||||
if session:
|
|
||||||
user = session.online_users.get(item.username)
|
|
||||||
if user:
|
|
||||||
ping = str(user['latency'])
|
|
||||||
metadata = user.get('metadata')
|
|
||||||
if metadata and 'frame_current' in metadata:
|
|
||||||
frame_current = str(metadata.get('frame_current','-'))
|
|
||||||
scene_current = metadata.get('scene_current','-')
|
|
||||||
mode_current = metadata.get('mode_current','-')
|
|
||||||
if mode_current == "OBJECT" :
|
|
||||||
mode_icon = "OBJECT_DATAMODE"
|
|
||||||
elif mode_current == "EDIT_MESH" :
|
|
||||||
mode_icon = "EDITMODE_HLT"
|
|
||||||
elif mode_current == 'EDIT_CURVE':
|
|
||||||
mode_icon = "CURVE_DATA"
|
|
||||||
elif mode_current == 'EDIT_SURFACE':
|
|
||||||
mode_icon = "SURFACE_DATA"
|
|
||||||
elif mode_current == 'EDIT_TEXT':
|
|
||||||
mode_icon = "FILE_FONT"
|
|
||||||
elif mode_current == 'EDIT_ARMATURE':
|
|
||||||
mode_icon = "ARMATURE_DATA"
|
|
||||||
elif mode_current == 'EDIT_METABALL':
|
|
||||||
mode_icon = "META_BALL"
|
|
||||||
elif mode_current == 'EDIT_LATTICE':
|
|
||||||
mode_icon = "LATTICE_DATA"
|
|
||||||
elif mode_current == 'POSE':
|
|
||||||
mode_icon = "POSE_HLT"
|
|
||||||
elif mode_current == 'SCULPT':
|
|
||||||
mode_icon = "SCULPTMODE_HLT"
|
|
||||||
elif mode_current == 'PAINT_WEIGHT':
|
|
||||||
mode_icon = "WPAINT_HLT"
|
|
||||||
elif mode_current == 'PAINT_VERTEX':
|
|
||||||
mode_icon = "VPAINT_HLT"
|
|
||||||
elif mode_current == 'PAINT_TEXTURE':
|
|
||||||
mode_icon = "TPAINT_HLT"
|
|
||||||
elif mode_current == 'PARTICLE':
|
|
||||||
mode_icon = "PARTICLES"
|
|
||||||
elif mode_current == 'PAINT_GPENCIL' or mode_current =='EDIT_GPENCIL' or mode_current =='SCULPT_GPENCIL' or mode_current =='WEIGHT_GPENCIL' or mode_current =='VERTEX_GPENCIL':
|
|
||||||
mode_icon = "GREASEPENCIL"
|
|
||||||
if user['admin']:
|
|
||||||
status_icon = 'FAKE_USER_ON'
|
|
||||||
split = layout.split(factor=0.35)
|
|
||||||
split.label(text=item.username, icon=status_icon)
|
|
||||||
split = split.split(factor=0.3)
|
|
||||||
split.label(icon=mode_icon)
|
|
||||||
split.label(text=frame_current)
|
|
||||||
split.label(text=scene_current)
|
|
||||||
split.label(text=ping)
|
|
@ -150,34 +150,19 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
col.template_list("SESSION_UL_network", "", settings, "server_preset", context.window_manager, "server_index")
|
col.template_list("SESSION_UL_network", "", settings, "server_preset", context.window_manager, "server_index")
|
||||||
col.separator()
|
col.separator()
|
||||||
connectOp = col.row()
|
connectOp = col.row()
|
||||||
connectOp.operator("session.host", text="Host") # TODO : add a pop-up for admin and server password ?
|
connectOp.operator("session.host", text="Host") # TODO : add a pop-up for admin and server password ? add port
|
||||||
connectopcol = connectOp.column()
|
connectopcol = connectOp.column()
|
||||||
connectopcol.enabled =is_server_selected
|
connectopcol.enabled =is_server_selected
|
||||||
connectopcol.operator("session.connect", text="Connect")
|
connectopcol.operator("session.connect", text="Connect")
|
||||||
|
|
||||||
col = row.column(align=True)
|
col = row.column(align=True)
|
||||||
col.operator("session.preset_server_add", icon="ADD", text="")
|
col.operator("session.preset_server_add", icon="ADD", text="") # TODO : add conditions (need a name, etc..) + add a checkbox for password without creating preferences
|
||||||
row_visible = col.row(align=True)
|
row_visible = col.row(align=True)
|
||||||
col_visible = row_visible.column(align=True)
|
col_visible = row_visible.column(align=True)
|
||||||
col_visible.enabled = is_server_selected
|
col_visible.enabled = is_server_selected
|
||||||
col_visible.operator("session.preset_server_remove", icon="REMOVE", text="").target_server_name = active_server_name
|
col_visible.operator("session.preset_server_remove", icon="REMOVE", text="").target_server_name = active_server_name
|
||||||
col_visible.separator()
|
col_visible.separator()
|
||||||
col_visible.operator("session.preset_server_edit", icon="GREASEPENCIL", text="").target_server_name = active_server_name
|
col_visible.operator("session.preset_server_edit", icon="GREASEPENCIL", text="").target_server_name = active_server_name
|
||||||
|
|
||||||
# row = layout.row() # TODO : active server in template
|
|
||||||
# row.operator("session.preset_server_add", text="Add") # TODO : add conditions (need a name, etc..) + add a checkbox for password without creating preferences
|
|
||||||
# col = row.column()
|
|
||||||
# col.enabled = is_server_selected
|
|
||||||
# col.operator("session.preset_server_edit", text="Edit").target_server_name = active_server_name
|
|
||||||
# col = row.column()
|
|
||||||
# col.enabled = is_server_selected
|
|
||||||
# col.operator("session.preset_server_remove", text="Remove").target_server_name = active_server_name
|
|
||||||
|
|
||||||
# row = layout.row()
|
|
||||||
# row.operator("session.host", text="Host") # TODO : add a pop-up for admin and server password ?
|
|
||||||
# col = row.column()
|
|
||||||
# col.enabled =is_server_selected
|
|
||||||
# col.operator("session.connect", text="Connect")
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
exitbutton = layout.row()
|
exitbutton = layout.row()
|
||||||
@ -208,7 +193,6 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
length=16
|
length=16
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SESSION_PT_advanced_settings(bpy.types.Panel):
|
class SESSION_PT_advanced_settings(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_SETTINGS_REPLICATION_PT_panel"
|
bl_idname = "MULTIUSER_SETTINGS_REPLICATION_PT_panel"
|
||||||
@ -240,21 +224,23 @@ class SESSION_PT_advanced_settings(bpy.types.Panel):
|
|||||||
icon=get_expanded_icon(settings.sidebar_advanced_hosting_expanded),
|
icon=get_expanded_icon(settings.sidebar_advanced_hosting_expanded),
|
||||||
emboss=False)
|
emboss=False)
|
||||||
if settings.sidebar_advanced_hosting_expanded:
|
if settings.sidebar_advanced_hosting_expanded:
|
||||||
|
host_selection_row = host_selection.row()
|
||||||
|
host_selection_row.prop(settings, "host_port", text="Port:")
|
||||||
host_selection_row = host_selection.row()
|
host_selection_row = host_selection.row()
|
||||||
host_selection_row.label(text="Init the session from:")
|
host_selection_row.label(text="Init the session from:")
|
||||||
host_selection_row.prop(settings, "init_method", text="")
|
host_selection_row.prop(settings, "init_method", text="")
|
||||||
host_selection_row = host_selection.row()
|
host_selection_row = host_selection.row()
|
||||||
host_selection_col = host_selection_row.column()
|
host_selection_col = host_selection_row.column()
|
||||||
host_selection_col.prop(settings, "use_server_password", text="Server password:")
|
host_selection_col.prop(settings, "host_use_server_password", text="Server password:")
|
||||||
host_selection_col = host_selection_row.column()
|
host_selection_col = host_selection_row.column()
|
||||||
host_selection_col.enabled = True if settings.use_server_password else False
|
host_selection_col.enabled = True if settings.host_use_server_password else False
|
||||||
host_selection_col.prop(settings, "server_password", text="")
|
host_selection_col.prop(settings, "host_server_password", text="")
|
||||||
host_selection_row = host_selection.row()
|
host_selection_row = host_selection.row()
|
||||||
host_selection_col = host_selection_row.column()
|
host_selection_col = host_selection_row.column()
|
||||||
host_selection_col.prop(settings, "use_admin_password", text="Admin password:")
|
host_selection_col.prop(settings, "host_use_admin_password", text="Admin password:")
|
||||||
host_selection_col = host_selection_row.column()
|
host_selection_col = host_selection_row.column()
|
||||||
host_selection_col.enabled = True if settings.use_admin_password else False
|
host_selection_col.enabled = True if settings.host_use_admin_password else False
|
||||||
host_selection_col.prop(settings, "admin_password", text="")
|
host_selection_col.prop(settings, "host_admin_password", text="")
|
||||||
|
|
||||||
#ADVANCED NET
|
#ADVANCED NET
|
||||||
net_section = layout.row().box()
|
net_section = layout.row().box()
|
||||||
@ -466,15 +452,18 @@ def draw_property(context, parent, property_uuid, level=0):
|
|||||||
detail_item_box.label(text=f"{name}")
|
detail_item_box.label(text=f"{name}")
|
||||||
|
|
||||||
# Operations
|
# Operations
|
||||||
|
|
||||||
have_right_to_modify = (item.owner == settings.username or \
|
have_right_to_modify = (item.owner == settings.username or \
|
||||||
item.owner == RP_COMMON) and item.state != ERROR
|
item.owner == RP_COMMON) and item.state != ERROR
|
||||||
|
|
||||||
|
from multi_user import icons
|
||||||
|
sync_status = icons.icons_col["repository_push"] #TODO: Link all icons to the right sync (push/merge/issue). For issue use "UNLINKED" for icon
|
||||||
|
# sync_status = icons.icons_col["repository_merge"]
|
||||||
|
|
||||||
if have_right_to_modify:
|
if have_right_to_modify:
|
||||||
detail_item_box.operator(
|
detail_item_box.operator(
|
||||||
"session.commit",
|
"session.commit",
|
||||||
text="",
|
text="",
|
||||||
icon='TRIA_UP').target = item.uuid
|
icon_value=sync_status.icon_id).target = item.uuid
|
||||||
detail_item_box.separator()
|
detail_item_box.separator()
|
||||||
|
|
||||||
if item.state in [FETCHED, UP]:
|
if item.state in [FETCHED, UP]:
|
||||||
@ -579,7 +568,7 @@ class SESSION_PT_repository(bpy.types.Panel):
|
|||||||
|
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.prop(runtime_settings, "filter_owned", text="Show only owned data blocks", icon_only=True, icon="DECORATE_UNLOCKED")
|
row.prop(runtime_settings, "filter_owned", text="Only show owned data blocks", icon_only=True, icon="DECORATE_UNLOCKED")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.prop(runtime_settings, "filter_name", text="Filter")
|
row.prop(runtime_settings, "filter_name", text="Filter")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
@ -600,8 +589,10 @@ class SESSION_PT_repository(bpy.types.Panel):
|
|||||||
layout.row().label(text="Empty")
|
layout.row().label(text="Empty")
|
||||||
|
|
||||||
elif session.state == STATE_LOBBY and usr and usr['admin']:
|
elif session.state == STATE_LOBBY and usr and usr['admin']:
|
||||||
|
row = layout.row()
|
||||||
row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
|
row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
|
||||||
else:
|
else:
|
||||||
|
row = layout.row()
|
||||||
row.label(text="Waiting to start")
|
row.label(text="Waiting to start")
|
||||||
|
|
||||||
class VIEW3D_PT_overlay_session(bpy.types.Panel):
|
class VIEW3D_PT_overlay_session(bpy.types.Panel):
|
||||||
@ -658,21 +649,16 @@ class SESSION_UL_network(bpy.types.UIList):
|
|||||||
server_name = item.server_name
|
server_name = item.server_name
|
||||||
|
|
||||||
split = layout.split(factor=0.7)
|
split = layout.split(factor=0.7)
|
||||||
# Session with/without password
|
if item.is_private:
|
||||||
# TODO : ping lock server
|
|
||||||
if settings.server_password != None:
|
|
||||||
server_private = 'LOCKED'
|
server_private = 'LOCKED'
|
||||||
split.label(text=server_name, icon=server_private)
|
split.label(text=server_name, icon=server_private)
|
||||||
else:
|
else:
|
||||||
split.label(text=server_name)
|
split.label(text=server_name)
|
||||||
|
|
||||||
# Session status
|
|
||||||
# TODO : if session online : vert else rouge
|
|
||||||
# TODO : ping
|
|
||||||
|
|
||||||
|
|
||||||
from multi_user import icons
|
from multi_user import icons
|
||||||
server_status = icons.icons_col["server_offline"]
|
server_status = icons.icons_col["server_offline"]
|
||||||
|
if item.is_online:
|
||||||
|
server_status = icons.icons_col["server_online"]
|
||||||
split.label(icon_value=server_status.icon_id)
|
split.label(icon_value=server_status.icon_id)
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
Loading…
Reference in New Issue
Block a user