2020-03-20 21:56:50 +08:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
import bpy
|
2019-09-30 19:35:50 +08:00
|
|
|
|
2020-03-02 18:09:45 +08:00
|
|
|
from . import operators, utils
|
2019-09-30 19:35:50 +08:00
|
|
|
from .libs.replication.replication.constants import (ADDED, ERROR, FETCHED,
|
2020-02-08 00:56:58 +08:00
|
|
|
MODIFIED, RP_COMMON, UP,
|
|
|
|
STATE_ACTIVE, STATE_AUTH,
|
|
|
|
STATE_CONFIG, STATE_SYNCING,
|
|
|
|
STATE_INITIAL, STATE_SRV_SYNC,
|
2020-03-20 18:46:43 +08:00
|
|
|
STATE_WAITING, STATE_QUITTING,
|
2020-06-16 06:02:02 +08:00
|
|
|
STATE_LOBBY,
|
2020-03-20 18:46:43 +08:00
|
|
|
STATE_LAUNCHING_SERVICES)
|
2019-04-24 23:42:23 +08:00
|
|
|
|
2019-09-13 22:46:26 +08:00
|
|
|
ICONS_PROP_STATES = ['TRIA_DOWN', # ADDED
|
2019-08-29 00:58:18 +08:00
|
|
|
'TRIA_UP', # COMMITED
|
|
|
|
'KEYTYPE_KEYFRAME_VEC', # PUSHED
|
|
|
|
'TRIA_DOWN', # FETCHED
|
|
|
|
'FILE_REFRESH', # UP
|
|
|
|
'TRIA_UP'] # CHANGED
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2020-02-09 07:41:00 +08:00
|
|
|
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', fill_empty=' '):
|
|
|
|
"""
|
|
|
|
Call in a loop to create terminal progress bar
|
|
|
|
@params:
|
|
|
|
iteration - Required : current iteration (Int)
|
|
|
|
total - Required : total iterations (Int)
|
|
|
|
prefix - Optional : prefix string (Str)
|
|
|
|
suffix - Optional : suffix string (Str)
|
|
|
|
decimals - Optional : positive number of decimals in percent complete (Int)
|
|
|
|
length - Optional : character length of bar (Int)
|
|
|
|
fill - Optional : bar fill character (Str)
|
2020-02-10 06:37:02 +08:00
|
|
|
From here:
|
|
|
|
https://gist.github.com/greenstick/b23e475d2bfdc3a82e34eaa1f6781ee4
|
2020-02-09 07:41:00 +08:00
|
|
|
"""
|
|
|
|
filledLength = int(length * iteration // total)
|
|
|
|
bar = fill * filledLength + fill_empty * (length - filledLength)
|
2020-04-22 23:04:14 +08:00
|
|
|
return f"{prefix} |{bar}| {iteration}/{total}{suffix}"
|
2020-02-09 07:41:00 +08:00
|
|
|
|
2020-02-08 00:56:58 +08:00
|
|
|
def get_state_str(state):
|
2020-03-20 18:46:43 +08:00
|
|
|
state_str = 'UNKNOWN'
|
2020-02-08 00:56:58 +08:00
|
|
|
if state == STATE_WAITING:
|
2020-02-09 07:41:00 +08:00
|
|
|
state_str = 'WARMING UP DATA'
|
2020-02-08 00:56:58 +08:00
|
|
|
elif state == STATE_SYNCING:
|
2020-02-09 06:23:00 +08:00
|
|
|
state_str = 'FETCHING FROM SERVER'
|
2020-02-08 00:56:58 +08:00
|
|
|
elif state == STATE_AUTH:
|
|
|
|
state_str = 'AUTHENTIFICATION'
|
|
|
|
elif state == STATE_CONFIG:
|
|
|
|
state_str = 'CONFIGURATION'
|
|
|
|
elif state == STATE_ACTIVE:
|
2020-02-09 07:41:00 +08:00
|
|
|
state_str = 'ONLINE'
|
2020-02-08 00:56:58 +08:00
|
|
|
elif state == STATE_SRV_SYNC:
|
2020-02-09 06:23:00 +08:00
|
|
|
state_str = 'PUSHING TO SERVER'
|
2020-02-19 23:22:06 +08:00
|
|
|
elif state == STATE_INITIAL:
|
|
|
|
state_str = 'INIT'
|
2020-02-20 20:17:28 +08:00
|
|
|
elif state == STATE_QUITTING:
|
|
|
|
state_str = 'QUITTING SESSION'
|
2020-03-20 18:46:43 +08:00
|
|
|
elif state == STATE_LAUNCHING_SERVICES:
|
|
|
|
state_str = 'LAUNCHING SERVICES'
|
2020-06-16 06:02:02 +08:00
|
|
|
elif state == STATE_LOBBY:
|
|
|
|
state_str = 'LOBBY'
|
2020-03-20 18:46:43 +08:00
|
|
|
|
2020-02-08 00:56:58 +08:00
|
|
|
return state_str
|
2019-08-22 21:35:21 +08:00
|
|
|
|
2019-05-15 20:52:45 +08:00
|
|
|
class SESSION_PT_settings(bpy.types.Panel):
|
2019-07-02 22:43:30 +08:00
|
|
|
"""Settings panel"""
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_idname = "MULTIUSER_SETTINGS_PT_panel"
|
2019-09-16 04:43:33 +08:00
|
|
|
bl_label = "Session"
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = "Multiuser"
|
2019-02-08 22:44:02 +08:00
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.label(text="", icon='TOOL_SETTINGS')
|
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-08-22 21:35:21 +08:00
|
|
|
layout.use_property_split = True
|
2019-08-09 22:47:15 +08:00
|
|
|
row = layout.row()
|
2020-06-11 00:43:21 +08:00
|
|
|
|
|
|
|
|
2019-03-15 23:50:59 +08:00
|
|
|
|
2019-08-23 18:28:57 +08:00
|
|
|
if hasattr(context.window_manager, 'session'):
|
2019-08-06 17:34:39 +08:00
|
|
|
# STATE INITIAL
|
2019-08-23 18:28:57 +08:00
|
|
|
if not operators.client \
|
2020-02-08 00:56:58 +08:00
|
|
|
or (operators.client and operators.client.state['STATE'] == STATE_INITIAL):
|
2019-08-09 21:20:49 +08:00
|
|
|
pass
|
2019-04-08 23:01:02 +08:00
|
|
|
else:
|
2020-02-08 00:56:58 +08:00
|
|
|
cli_state = operators.client.state
|
2020-02-09 07:41:00 +08:00
|
|
|
|
|
|
|
row.label(text=f"Status : {get_state_str(cli_state['STATE'])}")
|
|
|
|
row = layout.row()
|
|
|
|
|
2020-02-20 20:17:28 +08:00
|
|
|
current_state = cli_state['STATE']
|
|
|
|
|
2019-08-23 18:28:57 +08:00
|
|
|
# STATE ACTIVE
|
2020-02-20 20:17:28 +08:00
|
|
|
if current_state == STATE_ACTIVE:
|
2019-04-08 23:01:02 +08:00
|
|
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
2019-07-02 00:04:35 +08:00
|
|
|
row = layout.row()
|
2019-05-03 15:55:57 +08:00
|
|
|
|
2020-02-20 20:17:28 +08:00
|
|
|
# CONNECTION STATE
|
|
|
|
elif current_state in [
|
|
|
|
STATE_SRV_SYNC,
|
|
|
|
STATE_SYNCING,
|
|
|
|
STATE_AUTH,
|
|
|
|
STATE_CONFIG,
|
|
|
|
STATE_WAITING]:
|
|
|
|
|
2020-02-08 01:09:33 +08:00
|
|
|
if cli_state['STATE'] in [STATE_SYNCING,STATE_SRV_SYNC,STATE_WAITING]:
|
2020-02-20 20:17:28 +08:00
|
|
|
box = row.box()
|
2020-02-09 07:41:00 +08:00
|
|
|
box.label(text=printProgressBar(
|
|
|
|
cli_state['CURRENT'],
|
|
|
|
cli_state['TOTAL'],
|
|
|
|
length=16
|
|
|
|
))
|
|
|
|
|
2019-04-22 21:01:09 +08:00
|
|
|
row = layout.row()
|
|
|
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
2020-02-20 20:17:28 +08:00
|
|
|
elif current_state == STATE_QUITTING:
|
|
|
|
row = layout.row()
|
|
|
|
box = row.box()
|
2020-02-21 01:36:53 +08:00
|
|
|
|
|
|
|
num_online_services = 0
|
|
|
|
for name, state in operators.client.services_state.items():
|
|
|
|
if state == STATE_ACTIVE:
|
|
|
|
num_online_services += 1
|
|
|
|
|
|
|
|
total_online_services = len(operators.client.services_state)
|
|
|
|
|
|
|
|
box.label(text=printProgressBar(
|
|
|
|
total_online_services-num_online_services,
|
|
|
|
total_online_services,
|
|
|
|
length=16
|
|
|
|
))
|
2019-05-03 17:32:14 +08:00
|
|
|
|
2020-06-11 00:43:21 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
class SESSION_PT_settings_network(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel"
|
|
|
|
bl_label = "Network"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-08-23 18:28:57 +08:00
|
|
|
return not operators.client \
|
2020-02-08 00:56:58 +08:00
|
|
|
or (operators.client and operators.client.state['STATE'] == 0)
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2020-02-29 00:34:30 +08:00
|
|
|
|
|
|
|
runtime_settings = context.window_manager.session
|
2020-03-02 18:09:45 +08:00
|
|
|
settings = utils.get_preferences()
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
# USER SETTINGS
|
|
|
|
row = layout.row()
|
2020-02-29 00:34:30 +08:00
|
|
|
row.prop(runtime_settings, "session_mode", expand=True)
|
2019-08-09 21:20:49 +08:00
|
|
|
row = layout.row()
|
|
|
|
|
2020-02-20 01:07:25 +08:00
|
|
|
box = row.box()
|
|
|
|
|
|
|
|
row = box.row()
|
|
|
|
row.prop(settings, "ip", text="IP")
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="Port:")
|
|
|
|
row.prop(settings, "port", text="")
|
|
|
|
row = box.row()
|
2020-02-29 00:34:30 +08:00
|
|
|
if runtime_settings.session_mode == 'HOST':
|
2020-06-12 00:35:52 +08:00
|
|
|
row.label(text="Admin password:")
|
2020-06-05 00:38:03 +08:00
|
|
|
row.prop(runtime_settings, "password", text="")
|
2019-08-09 21:20:49 +08:00
|
|
|
row = box.row()
|
|
|
|
row.operator("session.start", text="HOST").host = True
|
|
|
|
else:
|
2020-06-05 00:38:03 +08:00
|
|
|
row.prop(runtime_settings, "admin", text='Connect as admin' ,icon='DISCLOSURE_TRI_DOWN' if runtime_settings.admin
|
|
|
|
else 'DISCLOSURE_TRI_RIGHT')
|
|
|
|
if runtime_settings.admin:
|
|
|
|
row = box.row()
|
|
|
|
row.label(text="Password:")
|
|
|
|
row.prop(runtime_settings, "password", text="")
|
2019-08-09 21:20:49 +08:00
|
|
|
row = box.row()
|
|
|
|
row.operator("session.start", text="CONNECT").host = False
|
|
|
|
|
|
|
|
|
|
|
|
class SESSION_PT_settings_user(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_SETTINGS_USER_PT_panel"
|
|
|
|
bl_label = "User"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2019-08-23 18:28:57 +08:00
|
|
|
return not operators.client \
|
2020-02-08 00:56:58 +08:00
|
|
|
or (operators.client and operators.client.state['STATE'] == 0)
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
2020-02-29 00:34:30 +08:00
|
|
|
runtime_settings = context.window_manager.session
|
2020-03-02 18:09:45 +08:00
|
|
|
settings = utils.get_preferences()
|
2020-02-29 00:34:30 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
row = layout.row()
|
|
|
|
# USER SETTINGS
|
2019-09-25 00:37:36 +08:00
|
|
|
row.prop(settings, "username", text="name")
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-08-09 21:20:49 +08:00
|
|
|
row = layout.row()
|
2019-08-23 18:28:57 +08:00
|
|
|
row.prop(settings, "client_color", text="color")
|
2019-08-09 21:20:49 +08:00
|
|
|
row = layout.row()
|
|
|
|
|
2019-03-14 19:09:33 +08:00
|
|
|
|
2019-08-29 00:58:18 +08:00
|
|
|
class SESSION_PT_settings_replication(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_SETTINGS_REPLICATION_PT_panel"
|
2019-09-16 23:24:48 +08:00
|
|
|
bl_label = "Advanced"
|
2019-08-29 00:58:18 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-09-24 20:42:59 +08:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2019-08-29 00:58:18 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return not operators.client \
|
2020-02-08 00:56:58 +08:00
|
|
|
or (operators.client and operators.client.state['STATE'] == 0)
|
2019-08-29 00:58:18 +08:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
2020-02-29 00:34:30 +08:00
|
|
|
runtime_settings = context.window_manager.session
|
2020-03-02 18:09:45 +08:00
|
|
|
settings = utils.get_preferences()
|
2020-02-29 00:34:30 +08:00
|
|
|
|
2020-06-11 00:43:21 +08:00
|
|
|
row = layout.row()
|
|
|
|
row.label(text="IPC Port:")
|
|
|
|
row.prop(settings, "ipc_port", text="")
|
|
|
|
row = layout.row()
|
|
|
|
row.label(text="Timeout (ms):")
|
|
|
|
row.prop(settings, "connection_timeout", text="")
|
|
|
|
|
2019-09-25 00:37:36 +08:00
|
|
|
# Right managment
|
2020-02-29 00:34:30 +08:00
|
|
|
if runtime_settings.session_mode == 'HOST':
|
2020-04-03 00:42:41 +08:00
|
|
|
row = layout.row()
|
|
|
|
row.prop(settings.sync_flags,"sync_render_settings")
|
|
|
|
|
2019-09-25 00:37:36 +08:00
|
|
|
row = layout.row(align=True)
|
|
|
|
row.label(text="Right strategy:")
|
|
|
|
row.prop(settings,"right_strategy",text="")
|
|
|
|
|
|
|
|
row = layout.row()
|
2019-08-29 00:58:18 +08:00
|
|
|
|
2019-09-25 00:37:36 +08:00
|
|
|
row = layout.row()
|
|
|
|
# Replication frequencies
|
|
|
|
flow = row .grid_flow(
|
2019-09-16 17:16:46 +08:00
|
|
|
row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
|
2019-09-16 04:16:54 +08:00
|
|
|
line = flow.row(align=True)
|
|
|
|
line.label(text=" ")
|
|
|
|
line.separator()
|
|
|
|
line.label(text="refresh (sec)")
|
|
|
|
line.label(text="apply (sec)")
|
2019-09-19 05:10:36 +08:00
|
|
|
|
2020-02-29 00:34:30 +08:00
|
|
|
for item in settings.supported_datablocks:
|
2019-09-16 04:16:54 +08:00
|
|
|
line = flow.row(align=True)
|
2019-09-16 19:43:43 +08:00
|
|
|
line.prop(item, "auto_push", text="", icon=item.icon)
|
2019-09-16 04:16:54 +08:00
|
|
|
line.separator()
|
|
|
|
line.prop(item, "bl_delay_refresh", text="")
|
|
|
|
line.prop(item, "bl_delay_apply", text="")
|
2019-08-29 00:58:18 +08:00
|
|
|
|
|
|
|
|
2019-05-15 20:52:45 +08:00
|
|
|
class SESSION_PT_user(bpy.types.Panel):
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_idname = "MULTIUSER_USER_PT_panel"
|
2020-01-18 01:15:37 +08:00
|
|
|
bl_label = "Online users"
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
2019-08-09 21:20:49 +08:00
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2020-06-16 21:19:38 +08:00
|
|
|
return operators.client and operators.client.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]
|
2019-03-14 00:02:53 +08:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2020-01-18 01:15:37 +08:00
|
|
|
online_users = context.window_manager.online_users
|
|
|
|
selected_user = context.window_manager.user_index
|
2020-03-02 18:09:45 +08:00
|
|
|
settings = utils.get_preferences()
|
2020-01-18 01:15:37 +08:00
|
|
|
active_user = online_users[selected_user] if len(online_users)-1>=selected_user else 0
|
2020-04-03 20:59:33 +08:00
|
|
|
runtime_settings = context.window_manager.session
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
# Create a simple row.
|
2020-01-18 01:15:37 +08:00
|
|
|
row = layout.row()
|
|
|
|
box = row.box()
|
2020-06-11 21:25:58 +08:00
|
|
|
split = box.split(factor=0.35)
|
2020-01-18 01:15:37 +08:00
|
|
|
split.label(text="user")
|
2020-03-05 23:19:13 +08:00
|
|
|
split = split.split(factor=0.5)
|
|
|
|
split.label(text="localisation")
|
2020-01-18 01:15:37 +08:00
|
|
|
split.label(text="frame")
|
|
|
|
split.label(text="ping")
|
2019-08-09 22:47:15 +08:00
|
|
|
|
2020-01-18 01:15:37 +08:00
|
|
|
row = layout.row()
|
2020-06-10 20:56:03 +08:00
|
|
|
layout.template_list("SESSION_UL_users", "", context.window_manager, "online_users", context.window_manager, "user_index")
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2020-01-18 01:15:37 +08:00
|
|
|
if active_user != 0 and active_user.username != settings.username:
|
|
|
|
row = layout.row()
|
|
|
|
user_operations = row.split()
|
2020-01-22 23:17:48 +08:00
|
|
|
user_operations.alert = context.window_manager.session.time_snap_running
|
2020-01-18 01:15:37 +08:00
|
|
|
user_operations.operator(
|
|
|
|
"session.snapview",
|
|
|
|
text="",
|
2020-01-22 22:15:44 +08:00
|
|
|
icon='VIEW_CAMERA').target_client = active_user.username
|
2020-01-22 23:17:48 +08:00
|
|
|
|
|
|
|
user_operations.alert = context.window_manager.session.user_snap_running
|
|
|
|
user_operations.operator(
|
|
|
|
"session.snaptime",
|
|
|
|
text="",
|
|
|
|
icon='TIME').target_client = active_user.username
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2020-06-11 00:43:21 +08:00
|
|
|
if operators.client.online_users[settings.username]['admin']:
|
2020-04-03 20:59:33 +08:00
|
|
|
user_operations.operator(
|
|
|
|
"session.kick",
|
|
|
|
text="",
|
|
|
|
icon='CANCEL').user = active_user.username
|
|
|
|
|
2019-04-17 19:39:36 +08:00
|
|
|
|
2020-01-18 01:15:37 +08:00
|
|
|
class SESSION_UL_users(bpy.types.UIList):
|
|
|
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
|
2020-01-20 06:10:22 +08:00
|
|
|
session = operators.client
|
2020-03-02 18:09:45 +08:00
|
|
|
settings = utils.get_preferences()
|
2020-01-18 01:15:37 +08:00
|
|
|
is_local_user = item.username == settings.username
|
2020-01-20 06:10:22 +08:00
|
|
|
ping = '-'
|
2020-01-22 23:17:48 +08:00
|
|
|
frame_current = '-'
|
2020-03-05 23:19:13 +08:00
|
|
|
scene_current = '-'
|
2020-06-11 21:25:58 +08:00
|
|
|
status_icon = 'DOT'
|
2020-01-20 06:10:22 +08:00
|
|
|
if session:
|
2020-01-22 23:17:48 +08:00
|
|
|
user = session.online_users.get(item.username)
|
|
|
|
if user:
|
|
|
|
ping = str(user['latency'])
|
|
|
|
metadata = user.get('metadata')
|
2020-02-08 00:08:36 +08:00
|
|
|
if metadata and 'frame_current' in metadata:
|
2020-01-22 23:17:48 +08:00
|
|
|
frame_current = str(metadata['frame_current'])
|
2020-03-05 23:19:13 +08:00
|
|
|
scene_current = metadata['scene_current']
|
2020-06-10 05:56:20 +08:00
|
|
|
if user['admin']:
|
|
|
|
status_icon = 'FAKE_USER_ON'
|
2020-06-11 21:25:58 +08:00
|
|
|
split = layout.split(factor=0.35)
|
2020-06-10 05:56:20 +08:00
|
|
|
split.label(text=item.username, icon=status_icon)
|
2020-03-05 23:19:13 +08:00
|
|
|
split = split.split(factor=0.5)
|
|
|
|
split.label(text=scene_current)
|
2020-01-22 23:17:48 +08:00
|
|
|
split.label(text=frame_current)
|
2020-01-20 06:10:22 +08:00
|
|
|
split.label(text=ping)
|
2020-03-05 23:19:13 +08:00
|
|
|
|
2019-07-01 21:59:51 +08:00
|
|
|
|
2019-09-24 20:42:59 +08:00
|
|
|
class SESSION_PT_presence(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_MODULE_PT_panel"
|
|
|
|
bl_label = "Presence overlay"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-09-25 00:37:36 +08:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2019-09-24 20:42:59 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2020-02-09 06:23:00 +08:00
|
|
|
return not operators.client \
|
|
|
|
or (operators.client and operators.client.state['STATE'] in [STATE_INITIAL, STATE_ACTIVE])
|
2019-09-24 20:42:59 +08:00
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.prop(context.window_manager.session, "enable_presence", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
settings = context.window_manager.session
|
|
|
|
layout.active = settings.enable_presence
|
|
|
|
col = layout.column()
|
|
|
|
col.prop(settings,"presence_show_selected")
|
|
|
|
col.prop(settings,"presence_show_user")
|
2020-03-06 00:20:04 +08:00
|
|
|
row = layout.column()
|
|
|
|
row.active = settings.presence_show_user
|
|
|
|
row.prop(settings,"presence_show_far_user")
|
|
|
|
|
2019-09-24 20:42:59 +08:00
|
|
|
|
2020-02-19 23:22:06 +08:00
|
|
|
class SESSION_PT_services(bpy.types.Panel):
|
|
|
|
bl_idname = "MULTIUSER_SERVICE_PT_panel"
|
|
|
|
bl_label = "Services"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2020-02-20 21:17:50 +08:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2020-02-19 23:22:06 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return operators.client and operators.client.state['STATE'] == 2
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
online_users = context.window_manager.online_users
|
|
|
|
selected_user = context.window_manager.user_index
|
|
|
|
settings = context.window_manager.session
|
|
|
|
active_user = online_users[selected_user] if len(online_users)-1>=selected_user else 0
|
|
|
|
|
|
|
|
# Create a simple row.
|
|
|
|
for name, state in operators.client.services_state.items():
|
2020-02-20 01:07:25 +08:00
|
|
|
row = layout.row()
|
2020-02-19 23:22:06 +08:00
|
|
|
row.label(text=name)
|
2020-04-14 23:22:28 +08:00
|
|
|
row.label(text=get_state_str(state))
|
2020-02-19 23:22:06 +08:00
|
|
|
|
|
|
|
|
2019-09-24 20:42:59 +08:00
|
|
|
|
2019-08-23 18:28:57 +08:00
|
|
|
def draw_property(context, parent, property_uuid, level=0):
|
2020-03-02 18:09:45 +08:00
|
|
|
settings = utils.get_preferences()
|
2020-02-29 00:34:30 +08:00
|
|
|
runtime_settings = context.window_manager.session
|
2019-08-26 23:27:12 +08:00
|
|
|
item = operators.client.get(uuid=property_uuid)
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2020-01-22 21:33:34 +08:00
|
|
|
if item.state == ERROR:
|
2019-08-22 21:35:21 +08:00
|
|
|
return
|
|
|
|
|
2019-08-23 18:28:57 +08:00
|
|
|
area_msg = parent.row(align=True)
|
2019-08-22 21:35:21 +08:00
|
|
|
if level > 0:
|
|
|
|
for i in range(level):
|
|
|
|
area_msg.label(text="")
|
|
|
|
line = area_msg.box()
|
|
|
|
|
2019-10-09 20:09:11 +08:00
|
|
|
name = item.data['name'] if item.data else item.uuid
|
2019-08-22 21:35:21 +08:00
|
|
|
|
2019-08-23 18:28:57 +08:00
|
|
|
detail_item_box = line.row(align=True)
|
2019-08-22 21:35:21 +08:00
|
|
|
|
2019-08-29 00:58:18 +08:00
|
|
|
detail_item_box.label(text="",
|
2020-02-29 00:34:30 +08:00
|
|
|
icon=settings.supported_datablocks[item.str_type].icon)
|
2020-04-22 23:04:14 +08:00
|
|
|
detail_item_box.label(text=f"{name}")
|
2019-08-28 22:19:32 +08:00
|
|
|
|
|
|
|
# Operations
|
|
|
|
|
2020-06-05 00:38:03 +08:00
|
|
|
have_right_to_modify = item.owner == settings.username or \
|
|
|
|
item.owner == RP_COMMON
|
2019-09-27 23:16:02 +08:00
|
|
|
|
|
|
|
if have_right_to_modify:
|
|
|
|
detail_item_box.operator(
|
|
|
|
"session.commit",
|
|
|
|
text="",
|
|
|
|
icon='TRIA_UP').target = item.uuid
|
|
|
|
detail_item_box.separator()
|
|
|
|
|
2019-08-28 22:19:32 +08:00
|
|
|
if item.state in [FETCHED, UP]:
|
2019-08-23 18:28:57 +08:00
|
|
|
detail_item_box.operator(
|
|
|
|
"session.apply",
|
|
|
|
text="",
|
2019-08-29 00:58:18 +08:00
|
|
|
icon=ICONS_PROP_STATES[item.state]).target = item.uuid
|
2019-09-13 22:46:26 +08:00
|
|
|
elif item.state in [MODIFIED, ADDED]:
|
2019-08-28 19:13:32 +08:00
|
|
|
detail_item_box.operator(
|
|
|
|
"session.commit",
|
|
|
|
text="",
|
2019-08-29 00:58:18 +08:00
|
|
|
icon=ICONS_PROP_STATES[item.state]).target = item.uuid
|
2019-08-22 21:35:21 +08:00
|
|
|
else:
|
2019-08-29 00:58:18 +08:00
|
|
|
detail_item_box.label(text="", icon=ICONS_PROP_STATES[item.state])
|
2019-08-22 21:35:21 +08:00
|
|
|
|
|
|
|
right_icon = "DECORATE_UNLOCKED"
|
2019-09-24 20:42:59 +08:00
|
|
|
if not have_right_to_modify:
|
2019-08-23 18:28:57 +08:00
|
|
|
right_icon = "DECORATE_LOCKED"
|
|
|
|
|
2019-08-28 22:19:32 +08:00
|
|
|
if have_right_to_modify:
|
|
|
|
ro = detail_item_box.operator(
|
|
|
|
"session.right", text="", icon=right_icon)
|
|
|
|
ro.key = property_uuid
|
2019-08-22 21:35:21 +08:00
|
|
|
|
2019-08-28 22:19:32 +08:00
|
|
|
detail_item_box.operator(
|
|
|
|
"session.remove_prop", text="", icon="X").property_path = property_uuid
|
|
|
|
else:
|
2019-08-29 00:58:18 +08:00
|
|
|
detail_item_box.label(text="", icon="DECORATE_LOCKED")
|
|
|
|
|
2019-08-22 21:35:21 +08:00
|
|
|
|
2020-06-16 21:19:38 +08:00
|
|
|
class SESSION_PT_repository(bpy.types.Panel):
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
2020-06-11 00:43:21 +08:00
|
|
|
bl_label = "Repository"
|
2019-06-14 00:09:16 +08:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
2020-04-14 23:22:28 +08:00
|
|
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
2019-03-14 00:02:53 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2020-06-11 00:43:21 +08:00
|
|
|
return hasattr(context.window_manager, 'session') and \
|
|
|
|
operators.client and \
|
2020-06-16 21:19:38 +08:00
|
|
|
operators.client.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]
|
2019-03-14 00:02:53 +08:00
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
def draw_header(self, context):
|
|
|
|
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-03-14 00:02:53 +08:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2020-06-11 00:43:21 +08:00
|
|
|
# Filters
|
|
|
|
settings = utils.get_preferences()
|
|
|
|
runtime_settings = context.window_manager.session
|
2020-06-16 21:19:38 +08:00
|
|
|
|
|
|
|
session = operators.client
|
|
|
|
usr = session.online_users.get(settings.username)
|
|
|
|
|
2020-06-11 00:43:21 +08:00
|
|
|
row = layout.row()
|
|
|
|
|
2020-06-16 21:19:38 +08:00
|
|
|
if session.state['STATE'] == STATE_ACTIVE:
|
2019-08-29 00:58:18 +08:00
|
|
|
flow = layout.grid_flow(
|
2019-09-16 17:16:46 +08:00
|
|
|
row_major=True,
|
|
|
|
columns=0,
|
|
|
|
even_columns=True,
|
|
|
|
even_rows=False,
|
|
|
|
align=True)
|
2019-08-29 00:58:18 +08:00
|
|
|
|
2020-02-29 00:34:30 +08:00
|
|
|
for item in settings.supported_datablocks:
|
2019-09-13 23:00:15 +08:00
|
|
|
col = flow.column(align=True)
|
2019-09-16 17:16:46 +08:00
|
|
|
col.prop(item, "use_as_filter", text="", icon=item.icon)
|
2019-04-01 22:14:21 +08:00
|
|
|
|
2019-09-19 05:10:36 +08:00
|
|
|
row = layout.row(align=True)
|
2020-02-29 00:34:30 +08:00
|
|
|
row.prop(runtime_settings, "filter_owned", text="Show only owned")
|
2019-09-19 05:10:36 +08:00
|
|
|
|
2019-04-11 20:39:31 +08:00
|
|
|
row = layout.row(align=True)
|
2019-09-19 05:10:36 +08:00
|
|
|
|
|
|
|
# Properties
|
2020-02-29 00:34:30 +08:00
|
|
|
types_filter = [t.type_name for t in settings.supported_datablocks
|
2019-09-16 17:16:46 +08:00
|
|
|
if t.use_as_filter]
|
2019-09-13 23:00:15 +08:00
|
|
|
|
2019-09-19 05:10:36 +08:00
|
|
|
key_to_filter = operators.client.list(
|
2020-02-29 00:34:30 +08:00
|
|
|
filter_owner=settings.username) if runtime_settings.filter_owned else operators.client.list()
|
2019-09-19 05:10:36 +08:00
|
|
|
|
|
|
|
client_keys = [key for key in key_to_filter
|
2020-06-11 00:43:21 +08:00
|
|
|
if operators.client.get(uuid=key).str_type
|
|
|
|
in types_filter]
|
2019-08-09 22:47:15 +08:00
|
|
|
|
2020-06-11 00:43:21 +08:00
|
|
|
if client_keys:
|
2019-08-08 23:17:58 +08:00
|
|
|
col = layout.column(align=True)
|
2019-08-09 22:47:15 +08:00
|
|
|
for key in client_keys:
|
2019-08-23 18:28:57 +08:00
|
|
|
draw_property(context, col, key)
|
|
|
|
|
2019-04-11 20:39:31 +08:00
|
|
|
else:
|
2019-09-13 23:00:15 +08:00
|
|
|
row.label(text="Empty")
|
2019-04-11 20:39:31 +08:00
|
|
|
|
2020-06-16 21:19:38 +08:00
|
|
|
elif session.state['STATE'] == STATE_LOBBY and usr and usr['admin']:
|
2020-06-11 00:43:21 +08:00
|
|
|
row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
|
|
|
|
else:
|
|
|
|
row.label(text="Waiting for init")
|
2019-02-08 22:44:02 +08:00
|
|
|
|
|
|
|
classes = (
|
2020-01-18 01:15:37 +08:00
|
|
|
SESSION_UL_users,
|
2019-05-15 20:52:45 +08:00
|
|
|
SESSION_PT_settings,
|
2019-08-09 21:20:49 +08:00
|
|
|
SESSION_PT_settings_user,
|
|
|
|
SESSION_PT_settings_network,
|
2019-09-25 00:37:36 +08:00
|
|
|
SESSION_PT_presence,
|
2019-08-29 00:58:18 +08:00
|
|
|
SESSION_PT_settings_replication,
|
2019-05-15 20:52:45 +08:00
|
|
|
SESSION_PT_user,
|
2020-04-14 23:22:28 +08:00
|
|
|
SESSION_PT_services,
|
2020-06-16 21:19:38 +08:00
|
|
|
SESSION_PT_repository,
|
2020-04-14 23:22:28 +08:00
|
|
|
|
2019-02-08 22:44:02 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-03-14 19:09:33 +08:00
|
|
|
register()
|