From 0a798bb21be7fab83ac2123f5598b34a55bcba85 Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 23 Jul 2021 12:51:16 +0200 Subject: [PATCH] feat: clean files+add repository sync icons --- multi_user/icons/repository_merge.png | Bin 0 -> 6607 bytes multi_user/icons/repository_push.png | Bin 0 -> 4321 bytes multi_user/operators.py | 118 ++++++++++++-------------- multi_user/preferences.py | 87 +++++++++---------- multi_user/temp.py | 117 ------------------------- multi_user/ui.py | 56 +++++------- 6 files changed, 117 insertions(+), 261 deletions(-) create mode 100644 multi_user/icons/repository_merge.png create mode 100644 multi_user/icons/repository_push.png delete mode 100644 multi_user/temp.py diff --git a/multi_user/icons/repository_merge.png b/multi_user/icons/repository_merge.png new file mode 100644 index 0000000000000000000000000000000000000000..e6b02b77eade0fac57f6eae863f4c856d274bea4 GIT binary patch literal 6607 zcmeHMdpy(o{~y-DDU0JAoem>eq}-LVTv{VG(%GDojB=^mmPu`Q;;(hN2*E-)ne*b>|`u+3scz8U#KcCm<`MTfUPW|lTq4n)g z-y#qQErO>T8G%rlQ~qjv15dg|L#N@89f`;PoIv*2v4-G|cd&JIaImzqvPB@)7bX_o z^-{xW(_1k_%+9sz*GK4JD62oIko5DAXR|37oz%@;CG_7qj}))Dzo%YnJ;R~p+lA#f zf2duCBO!0-*8ULvORuAeTSt%GwxPwN;RB`1s2JYCx%2xUADpGE7bo@g{(1L9!9e7F zoc;-tyI<9V13K4UzS7dO-=F*^<$2!%RqAzQpNd!MG@~La`R$RnUFYsa&0L9VV4k+p zG+LfSjmN#E`WBp%b&VV>arG9hy@c4SpYx_G$l%LEBC%VeyZh6@r^`miUBp8g34#J3&FUzM=vY#{=%YL?)J`{mfh4{wgw$0Viof9kV# z#EhD1RDYlK*OAj_g0HTL-bKt}GQTX85fA%DN27`NS1a;dYsFj9Xezao5~*W6|D~%m zknnBgUm{B7fo9sx$iyoTZ{agfo@AA0I8Ahz(JywpeDUv#+A>d>`hQ7Qapmb)z*b=Zx^$2gjI{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93Bfo7;3J#4wb_9ADuVX3bbGHizGxz-JxPdMXz!7GCyLsJ;7d4QV~He`&uxi z*%gSOo!ahfh$qX8s)|fK;tocW!I%$@CsR5Fy;oFwEU>dVO#bR!!OCB&NdyEzrfVY` zI>$UuxvLw}@)S)10mX4YGuwu7O=YTy9~X`7gZ^wmI~!_VH#vTR(EGVTIyJ6XEH1pNRq1Mtra{ei_7!QrjjP=>5GvQ12D22VLfA&<9g zOgkol?r8q1$&>}pfbXBkO&Cv*l|JTz!})KFKfjjLnopC>(z>qEI%`I&a%zrjI4@wV zZmBKl@PF{Vlldc$_McZ9m-EQx-?r46Lda$5YdP-McvjR7a~!#>Rq&cT?i84&{z|~e zrM?O{#VBJdlTA9vBAbmdwZ(ivxkylcZY{?BCXYq!FesS$_Z3=qu?R5P3Knitj z&*I$ocfM1u_6y4I_`m-4y|OleY9iUhS0*_N1W?|G{mUAFmFxw30aM6 z9>@Fh4FbUxS0J_1s1j(u5imwHyGquQ$ib7zb9@$1^Oudww$pA>*;UnIrR);UuQpE8 zoh~wB1lnnVHm$1Vej+)pS6RNh*ecJmNuDwE24?>3v8 zlv5KMkGTPR^s4EplC|*Q!CYvDUol%8tcH=c(*SVTk?*etcDIx%f&-6B)`$|=Z!wJd zL3v3<{`c1gpO#d}G)7C{_LGu|X5*?8)VpG>m!nM+#hH2&tn$#Ds8?lrA~MDqRFnfA z&jaQw=AW3KS70}{H#j+NFsP=FkmC+4v}vEug3|%P8~(e8R?s(BT=P;y#uENs;96JD z8!P_aXFu+!Qbptf?iA`7@|DsY=t=(@{r_TbT7WM4qJ^interface) # OPERATORS @@ -161,10 +160,11 @@ class SessionConnectOperator(bpy.types.Operator): global deleyables settings = utils.get_preferences() - runtime_settings = context.window_manager.session users = bpy.data.window_managers['WinMan'].online_users - admin_pass = settings.admin_password - server_pass = settings.server_password if settings.server_password else None + active_server_index = context.window_manager.server_index if context.window_manager.server_index<=len(settings.server_preset)-1 else 0 + 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() deleyables.clear() @@ -213,18 +213,15 @@ class SessionConnectOperator(bpy.types.Operator): username=settings.username) # Join a session - if not runtime_settings.admin: + if not active_server.use_admin_password: utils.clean_scene() - # regular session, no admin_password needed nor server_password - admin_pass = None - server_pass = None try: porcelain.remote_add( repo, 'origin', - settings.ip, - settings.port, + active_server.ip, + active_server.port, server_password=server_pass, admin_password=admin_pass) session.connect( @@ -276,8 +273,8 @@ class SessionHostOperator(bpy.types.Operator): settings = utils.get_preferences() runtime_settings = context.window_manager.session users = bpy.data.window_managers['WinMan'].online_users - admin_pass = settings.admin_password - server_pass = settings.server_password if settings.server_password else None + admin_pass = settings.host_admin_password if settings.host_use_admin_password else None + server_pass = settings.host_server_password if settings.host_use_server_password else None users.clear() deleyables.clear() @@ -341,7 +338,7 @@ class SessionHostOperator(bpy.types.Operator): repo, 'origin', '127.0.0.1', - settings.port, + settings.host_port, server_password=server_pass, admin_password=admin_pass) session.host( @@ -929,12 +926,12 @@ class SessionPresetServerAdd(bpy.types.Operator): bl_options = {"REGISTER"} server_name: bpy.props.StringProperty(default="") - server_ip: bpy.props.StringProperty(default="127.0.0.1") - server_port: bpy.props.IntProperty(default=5555) + ip: bpy.props.StringProperty(default="127.0.0.1") + port: bpy.props.IntProperty(default=5555) 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) - server_admin_password: bpy.props.StringProperty(default="", subtype = "PASSWORD") + admin_password: bpy.props.StringProperty(default="", subtype = "PASSWORD") @classmethod def poll(cls, context): @@ -942,37 +939,36 @@ class SessionPresetServerAdd(bpy.types.Operator): def invoke(self, context, event): self.server_name = "" - self.server_ip = "127.0.0.1" - self.server_port = 5555 + self.ip = "127.0.0.1" + self.port = 5555 self.use_server_password = False - self.server_server_password = "" + self.server_password = "" self.use_admin_password = False - self.server_admin_password = "" + self.admin_password = "" assert(context) return context.window_manager.invoke_props_dialog(self) def draw(self, context): layout = self.layout - settings = utils.get_preferences() row = layout.row() row.prop(self, "server_name", text="Server name") row = layout.row(align = True) - row.prop(self, "server_ip", text="IP+port") - row.prop(self, "server_port", text="") + row.prop(self, "ip", text="IP+port") + row.prop(self, "port", text="") row = layout.row() col = row.column() col.prop(self, "use_server_password", text="Server password:") col = row.column() 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() col = row.column() col.prop(self, "use_admin_password", text="Admin password:") col = row.column() 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): 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.name = str(uuid4()) new_server.server_name = self.server_name - new_server.server_ip = self.server_ip - new_server.server_port = self.server_port + new_server.ip = self.ip + new_server.port = self.port 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.server_admin_password = self.server_admin_password + new_server.admin_password = self.admin_password refresh_sidebar_view() @@ -1000,7 +996,7 @@ class SessionPresetServerAdd(bpy.types.Operator): 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""" bl_idname = "session.preset_server_edit" bl_label = "Edit server preset" @@ -1014,40 +1010,31 @@ class SessionPresetServerEdit(bpy.types.Operator): return True 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) return context.window_manager.invoke_props_dialog(self) def draw(self, context): layout = self.layout settings = utils.get_preferences() + settings_active_server = settings.server_preset.get(self.target_server_name) 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.prop(settings, "ip", text="IP+port") - row.prop(settings, "port", text="") + row.prop(settings_active_server, "ip", text="IP+port") + row.prop(settings_active_server, "port", text="") row = layout.row() 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.enabled = True if settings.use_server_password else False - col.prop(settings, "server_password", text="") + col.enabled = True if settings_active_server.use_server_password else False + col.prop(settings_active_server, "server_password", text="") row = layout.row() 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.enabled = True if settings.use_admin_password else False - col.prop(settings, "admin_password", text="") + col.enabled = True if settings_active_server.use_admin_password else False + col.prop(settings_active_server, "admin_password", text="") def execute(self, context): assert(context) @@ -1055,20 +1042,12 @@ class SessionPresetServerEdit(bpy.types.Operator): settings = utils.get_preferences() 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() - self.report({'INFO'}, "Server '" + settings.server_name + "' override") + self.report({'INFO'}, "Server '" + settings_active_server.server_name + "' override") return {'FINISHED'} - class SessionPresetServerRemove(bpy.types.Operator): """Remove a server to the server list preset""" bl_idname = "session.preset_server_remove" @@ -1090,7 +1069,7 @@ class SessionPresetServerRemove(bpy.types.Operator): return {'FINISHED'} -class SessionGetInfo(bpy.types.Operator): +class RefreshServerStatus(bpy.types.Operator): bl_idname = "session.get_info" bl_label = "Get session info" bl_description = "Get session info" @@ -1102,8 +1081,15 @@ class SessionGetInfo(bpy.types.Operator): return (session.state != STATE_ACTIVE) def execute(self, context): - infos = porcelain.request_session_info(self.target_server, timeout=100) - logging.info(f"Session info: {infos}") + settings = utils.get_preferences() + + 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'} @@ -1137,6 +1123,10 @@ class FirstLaunch(bpy.types.Operator): assert(context) settings = utils.get_preferences() 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'} def menu_func_import(self, context): @@ -1167,7 +1157,7 @@ classes = ( SessionPresetServerAdd, SessionPresetServerEdit, SessionPresetServerRemove, - SessionGetInfo, + RefreshServerStatus, GetDoc, FirstLaunch, ) diff --git a/multi_user/preferences.py b/multi_user/preferences.py index 215774f..7023205 100644 --- a/multi_user/preferences.py +++ b/multi_user/preferences.py @@ -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])$") 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 = { "localhost" : { "server_name": "localhost", - "server_ip": "localhost", - "server_port": 5555, + "ip": "localhost", + "port": 5555, + "use_admin_password": True, "admin_password": "admin", "server_password": "" }, "public session" : { "server_name": "public session", - "server_ip": "51.75.71.183", - "server_port": 5555, + "ip": "51.75.71.183", + "port": 5555, "admin_password": "", "server_password": "" }, @@ -83,12 +85,6 @@ def update_ip(self, context): logging.error("Wrong IP format") 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): new_dir = Path(self.cache_directory) @@ -117,12 +113,14 @@ class ReplicatedDatablock(bpy.types.PropertyGroup): class ServerPreset(bpy.types.PropertyGroup): server_name: bpy.props.StringProperty(default="") - server_ip: bpy.props.StringProperty(default="127.0.0.1") - server_port: bpy.props.IntProperty(default=5555) + ip: bpy.props.StringProperty(default="127.0.0.1") + port: bpy.props.IntProperty(default=5555) 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) - 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): self['sync_render_settings'] = value @@ -172,11 +170,7 @@ class ReplicationFlags(bpy.types.PropertyGroup): class SessionPrefs(bpy.types.AddonPreferences): bl_idname = __package__ - ip: bpy.props.StringProperty( - name="ip", - description='Distant host ip', - default="localhost", - update=update_ip) + # User settings username: bpy.props.StringProperty( name="Username", default=f"user_{random_string_digits()}" @@ -185,12 +179,9 @@ class SessionPrefs(bpy.types.AddonPreferences): name="client_instance_color", description='User color', subtype='COLOR', - default=randomColor()) - port: bpy.props.IntProperty( - name="port", - description='Distant host port', - default=5555 + default=randomColor() ) + # Current server settings server_name: bpy.props.StringProperty( name="server_name", description="Custom name of the server", @@ -200,26 +191,33 @@ class SessionPrefs(bpy.types.AddonPreferences): name="server_index", 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", description='Use session password', default=False ) - server_password: bpy.props.StringProperty( + host_server_password: bpy.props.StringProperty( name="server_password", description='Session password', subtype='PASSWORD' ) - use_admin_password: bpy.props.BoolProperty( + host_use_admin_password: bpy.props.BoolProperty( name="use_admin_password", description='Use admin password', default=False ) - admin_password: bpy.props.StringProperty( + host_admin_password: bpy.props.StringProperty( name="admin_password", description='Admin password', subtype='PASSWORD' ) + # Other is_first_launch: bpy.props.BoolProperty( name="is_first_launch", description="First time lauching the addon", @@ -259,7 +257,7 @@ class SessionPrefs(bpy.types.AddonPreferences): description="Remove filecache from memory", default=False ) - # for UI + # For UI category: bpy.props.EnumProperty( name="Category", description="Preferences Category", @@ -431,12 +429,6 @@ class SessionPrefs(bpy.types.AddonPreferences): name="server preset", type=ServerPreset, ) - server_preset_interface: bpy.props.EnumProperty( - name="servers", - description="servers enum", - items=server_list_callback, - update=update_server_preset_interface, - ) # Custom panel panel_category: bpy.props.StringProperty( @@ -475,21 +467,23 @@ class SessionPrefs(bpy.types.AddonPreferences): icon=get_expanded_icon(self.conf_session_hosting_expanded), emboss=False) if self.conf_session_hosting_expanded: + row = box.row() + row.prop(self, "host_port", text="Port: ") row = box.row() row.label(text="Init the session from:") row.prop(self, "init_method", text="") row = box.row() 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.enabled = True if self.use_server_password else False - col.prop(self, "server_password", text="") + col.enabled = True if self.host_use_server_password else False + col.prop(self, "host_server_password", text="") row = box.row() 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.enabled = True if self.use_admin_password else False - col.prop(self, "admin_password", text="") + col.enabled = True if self.host_use_admin_password else False + col.prop(self, "host_admin_password", text="") # NETWORKING box = grid.box() @@ -563,6 +557,7 @@ class SessionPrefs(bpy.types.AddonPreferences): new_db.icon = impl.bl_icon new_db.bl_name = impl.bl_id + # Get a server preset through its name def get_server_preset(self, name): existing_preset = None @@ -572,7 +567,7 @@ class SessionPrefs(bpy.types.AddonPreferences): return existing_preset - # custom at launch server preset + # Custom at launch server preset def generate_default_presets(self): for preset_name, preset_data in DEFAULT_PRESETS.items(): 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.name = str(uuid4()) new_server.server_name = preset_data.get('server_name') - new_server.server_index = preset_data.get('server_index') - new_server.server_ip = preset_data.get('server_ip') - new_server.server_port = preset_data.get('server_port') + new_server.ip = preset_data.get('ip') + new_server.port = preset_data.get('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.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): diff --git a/multi_user/temp.py b/multi_user/temp.py deleted file mode 100644 index fd8c431..0000000 --- a/multi_user/temp.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/multi_user/ui.py b/multi_user/ui.py index e3844ee..5a6a496 100644 --- a/multi_user/ui.py +++ b/multi_user/ui.py @@ -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.separator() 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.enabled =is_server_selected connectopcol.operator("session.connect", text="Connect") 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) col_visible = row_visible.column(align=True) col_visible.enabled = is_server_selected col_visible.operator("session.preset_server_remove", icon="REMOVE", text="").target_server_name = active_server_name col_visible.separator() 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: exitbutton = layout.row() @@ -208,7 +193,6 @@ class SESSION_PT_settings(bpy.types.Panel): length=16 )) - class SESSION_PT_advanced_settings(bpy.types.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), emboss=False) 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.label(text="Init the session from:") host_selection_row.prop(settings, "init_method", text="") host_selection_row = host_selection.row() 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.enabled = True if settings.use_server_password else False - host_selection_col.prop(settings, "server_password", text="") + host_selection_col.enabled = True if settings.host_use_server_password else False + host_selection_col.prop(settings, "host_server_password", text="") host_selection_row = host_selection.row() 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.enabled = True if settings.use_admin_password else False - host_selection_col.prop(settings, "admin_password", text="") + host_selection_col.enabled = True if settings.host_use_admin_password else False + host_selection_col.prop(settings, "host_admin_password", text="") #ADVANCED NET 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}") # Operations - have_right_to_modify = (item.owner == settings.username or \ 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: detail_item_box.operator( "session.commit", text="", - icon='TRIA_UP').target = item.uuid + icon_value=sync_status.icon_id).target = item.uuid detail_item_box.separator() if item.state in [FETCHED, UP]: @@ -579,7 +568,7 @@ class SESSION_PT_repository(bpy.types.Panel): box = layout.box() 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.prop(runtime_settings, "filter_name", text="Filter") row = box.row() @@ -600,8 +589,10 @@ class SESSION_PT_repository(bpy.types.Panel): layout.row().label(text="Empty") elif session.state == STATE_LOBBY and usr and usr['admin']: + row = layout.row() row.operator("session.init", icon='TOOL_SETTINGS', text="Init") else: + row = layout.row() row.label(text="Waiting to start") class VIEW3D_PT_overlay_session(bpy.types.Panel): @@ -658,21 +649,16 @@ class SESSION_UL_network(bpy.types.UIList): server_name = item.server_name split = layout.split(factor=0.7) - # Session with/without password - # TODO : ping lock server - if settings.server_password != None: + if item.is_private: server_private = 'LOCKED' split.label(text=server_name, icon=server_private) else: split.label(text=server_name) - # Session status - # TODO : if session online : vert else rouge - # TODO : ping - - from multi_user import icons 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) classes = (