refactor: uui cleanup

This commit is contained in:
Swann
2020-06-17 12:10:16 +02:00
parent 9c3afdbd81
commit 9e6b1a141d
2 changed files with 45 additions and 23 deletions

View File

@ -26,6 +26,7 @@ import time
from operator import itemgetter from operator import itemgetter
from pathlib import Path from pathlib import Path
from subprocess import PIPE, Popen, TimeoutExpired from subprocess import PIPE, Popen, TimeoutExpired
import zmq
import bpy import bpy
import mathutils import mathutils
@ -234,7 +235,8 @@ class SessionStopOperator(bpy.types.Operator):
client.disconnect() client.disconnect()
except Exception as e: except Exception as e:
self.report({'ERROR'}, repr(e)) self.report({'ERROR'}, repr(e))
except zmq.ZMQError:
self.report("A client is already connected (Could be a bug). \n Retry after closing any blender instance from your task manager.")
return {"FINISHED"} return {"FINISHED"}

View File

@ -60,7 +60,7 @@ def get_state_str(state):
if state == STATE_WAITING: if state == STATE_WAITING:
state_str = 'WARMING UP DATA' state_str = 'WARMING UP DATA'
elif state == STATE_SYNCING: elif state == STATE_SYNCING:
state_str = 'FETCHING FROM SERVER' state_str = 'FETCHING'
elif state == STATE_AUTH: elif state == STATE_AUTH:
state_str = 'AUTHENTIFICATION' state_str = 'AUTHENTIFICATION'
elif state == STATE_CONFIG: elif state == STATE_CONFIG:
@ -68,11 +68,11 @@ def get_state_str(state):
elif state == STATE_ACTIVE: elif state == STATE_ACTIVE:
state_str = 'ONLINE' state_str = 'ONLINE'
elif state == STATE_SRV_SYNC: elif state == STATE_SRV_SYNC:
state_str = 'PUSHING TO SERVER' state_str = 'PUSHING'
elif state == STATE_INITIAL: elif state == STATE_INITIAL:
state_str = 'INIT' state_str = 'INIT'
elif state == STATE_QUITTING: elif state == STATE_QUITTING:
state_str = 'QUITTING SESSION' state_str = 'QUITTING'
elif state == STATE_LAUNCHING_SERVICES: elif state == STATE_LAUNCHING_SERVICES:
state_str = 'LAUNCHING SERVICES' state_str = 'LAUNCHING SERVICES'
elif state == STATE_LOBBY: elif state == STATE_LOBBY:
@ -84,11 +84,27 @@ def get_state_str(state):
class SESSION_PT_settings(bpy.types.Panel): class SESSION_PT_settings(bpy.types.Panel):
"""Settings panel""" """Settings panel"""
bl_idname = "MULTIUSER_SETTINGS_PT_panel" bl_idname = "MULTIUSER_SETTINGS_PT_panel"
bl_label = "Online session" bl_label = ""
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
bl_region_type = 'UI' bl_region_type = 'UI'
bl_category = "Multiuser" bl_category = "Multiuser"
def draw_header(self, context):
layout = self.layout
if operators.client and operators.client.state['STATE'] != STATE_INITIAL:
cli_state = operators.client.state
state = operators.client.state.get('STATE')
connection_icon = "KEYTYPE_MOVING_HOLD_VEC"
if state == STATE_ACTIVE:
connection_icon = 'PROP_ON'
else:
connection_icon = 'PROP_CON'
layout.label(text=f"Session - {get_state_str(cli_state['STATE'])}", icon=connection_icon)
else:
layout.label(text="Session",icon="PROP_OFF")
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
@ -102,7 +118,7 @@ class SESSION_PT_settings(bpy.types.Panel):
else: else:
cli_state = operators.client.state cli_state = operators.client.state
row.label(text=f"Status : {get_state_str(cli_state['STATE'])}")
row = layout.row() row = layout.row()
current_state = cli_state['STATE'] current_state = cli_state['STATE']
@ -232,7 +248,7 @@ class SESSION_PT_settings_user(bpy.types.Panel):
row = layout.row() row = layout.row()
class SESSION_PT_settings_replication(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"
bl_label = "Advanced" bl_label = "Advanced"
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
@ -246,7 +262,7 @@ class SESSION_PT_settings_replication(bpy.types.Panel):
or (operators.client and operators.client.state['STATE'] == 0) or (operators.client and operators.client.state['STATE'] == 0)
def draw_header(self, context): def draw_header(self, context):
self.layout.label(text="", icon='TOOL_SETTINGS') self.layout.label(text="", icon='PREFERENCES')
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@ -254,23 +270,27 @@ class SESSION_PT_settings_replication(bpy.types.Panel):
runtime_settings = context.window_manager.session runtime_settings = context.window_manager.session
settings = utils.get_preferences() settings = utils.get_preferences()
row = layout.row()
row.label(text="IPC Port:") net_section = layout.row().box()
row.prop(settings, "ipc_port", text="") net_section.label(text="Network ", icon='TRIA_DOWN')
row = layout.row() net_section_row = net_section.row()
row.label(text="Timeout (ms):") net_section_row.label(text="IPC Port:")
row.prop(settings, "connection_timeout", text="") net_section_row.prop(settings, "ipc_port", text="")
net_section_row = net_section.row()
net_section_row.label(text="Timeout (ms):")
net_section_row.prop(settings, "connection_timeout", text="")
# Right managment replication_section = layout.row().box()
replication_section.label(text="Replication ", icon='TRIA_DOWN')
replication_section_row = replication_section.row()
if runtime_settings.session_mode == 'HOST': if runtime_settings.session_mode == 'HOST':
row = layout.row() replication_section_row.prop(settings.sync_flags, "sync_render_settings")
row.prop(settings.sync_flags, "sync_render_settings")
row = layout.row() replication_section_row = replication_section.row()
replication_section_row.label(text="Per data type timers:")
row = layout.row() replication_section_row = replication_section.row()
# Replication frequencies # Replication frequencies
flow = row .grid_flow( flow = replication_section_row .grid_flow(
row_major=True, columns=0, even_columns=True, even_rows=False, align=True) row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
line = flow.row(align=True) line = flow.row(align=True)
line.label(text=" ") line.label(text=" ")
@ -557,7 +577,7 @@ class SESSION_PT_repository(bpy.types.Panel):
elif session.state['STATE'] == STATE_LOBBY and usr and usr['admin']: elif session.state['STATE'] == STATE_LOBBY and usr and usr['admin']:
row.operator("session.init", icon='TOOL_SETTINGS', text="Init") row.operator("session.init", icon='TOOL_SETTINGS', text="Init")
else: else:
row.label(text="Waiting for init") row.label(text="Waiting to start")
classes = ( classes = (
@ -566,7 +586,7 @@ classes = (
SESSION_PT_settings_user, SESSION_PT_settings_user,
SESSION_PT_settings_network, SESSION_PT_settings_network,
SESSION_PT_presence, SESSION_PT_presence,
SESSION_PT_settings_replication, SESSION_PT_advanced_settings,
SESSION_PT_user, SESSION_PT_user,
SESSION_PT_services, SESSION_PT_services,
SESSION_PT_repository, SESSION_PT_repository,