refactor: state with progression !
This commit is contained in:
parent
81752e9a23
commit
8a2d178a4f
@ -89,7 +89,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
session = operators.client
|
session = operators.client
|
||||||
settings = bpy.context.window_manager.session
|
settings = bpy.context.window_manager.session
|
||||||
|
|
||||||
if session and session.state == STATE_ACTIVE:
|
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||||
# Find user
|
# Find user
|
||||||
if self._user is None:
|
if self._user is None:
|
||||||
self._user = session.online_users.get(settings.username)
|
self._user = session.online_users.get(settings.username)
|
||||||
@ -195,7 +195,7 @@ class DrawClient(Draw):
|
|||||||
session = getattr(operators, 'client', None)
|
session = getattr(operators, 'client', None)
|
||||||
renderer = getattr(presence, 'renderer', None)
|
renderer = getattr(presence, 'renderer', None)
|
||||||
|
|
||||||
if session and renderer and session.state == STATE_ACTIVE:
|
if session and renderer and session.state['STATE'] == STATE_ACTIVE:
|
||||||
settings = bpy.context.window_manager.session
|
settings = bpy.context.window_manager.session
|
||||||
users = session.online_users
|
users = session.online_users
|
||||||
|
|
||||||
@ -221,9 +221,9 @@ class ClientUpdate(Timer):
|
|||||||
session = getattr(operators, 'client', None)
|
session = getattr(operators, 'client', None)
|
||||||
renderer = getattr(presence, 'renderer', None)
|
renderer = getattr(presence, 'renderer', None)
|
||||||
|
|
||||||
if session and renderer and session.state == STATE_ACTIVE:
|
if session and renderer and session.state['STATE'] == STATE_ACTIVE:
|
||||||
# Check if session has been closes prematurely
|
# Check if session has been closes prematurely
|
||||||
if session.state == 0:
|
if session.state['STATE'] == 0:
|
||||||
bpy.ops.session.stop()
|
bpy.ops.session.stop()
|
||||||
|
|
||||||
local_user = operators.client.online_users.get(
|
local_user = operators.client.online_users.get(
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d0f2338fb62f2b21dba4ed4737ecaa2b28a9e2ff
|
Subproject commit 5a5571d943a1cb8a4b26e9397d0ced42acbea938
|
@ -400,7 +400,7 @@ class ApplyArmatureOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
if event.type == 'TIMER':
|
if event.type == 'TIMER':
|
||||||
global client
|
global client
|
||||||
if client.state == STATE_ACTIVE:
|
if client.state['STATE'] == STATE_ACTIVE:
|
||||||
nodes = client.list(filter=bl_types.bl_armature.BlArmature)
|
nodes = client.list(filter=bl_types.bl_armature.BlArmature)
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
@ -448,7 +448,7 @@ classes = (
|
|||||||
def load_pre_handler(dummy):
|
def load_pre_handler(dummy):
|
||||||
global client
|
global client
|
||||||
|
|
||||||
if client and client.state in [STATE_ACTIVE, STATE_SYNCING]:
|
if client and client.state['STATE'] in [STATE_ACTIVE, STATE_SYNCING]:
|
||||||
bpy.ops.session.stop()
|
bpy.ops.session.stop()
|
||||||
|
|
||||||
|
|
||||||
@ -462,21 +462,21 @@ def sanitize_deps_graph(dummy):
|
|||||||
"""
|
"""
|
||||||
global client
|
global client
|
||||||
|
|
||||||
if client and client.state in [STATE_ACTIVE]:
|
if client and client.state['STATE'] in [STATE_ACTIVE]:
|
||||||
for node_key in client.list():
|
for node_key in client.list():
|
||||||
client.get(node_key).resolve()
|
client.get(node_key).resolve()
|
||||||
|
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def update_client_frame(scene):
|
def update_client_frame(scene):
|
||||||
if client and client.state == STATE_ACTIVE:
|
if client and client.state['STATE'] == STATE_ACTIVE:
|
||||||
client.update_user_metadata({
|
client.update_user_metadata({
|
||||||
'frame_current': scene.frame_current
|
'frame_current': scene.frame_current
|
||||||
})
|
})
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def depsgraph_evaluation(scene):
|
def depsgraph_evaluation(scene):
|
||||||
if client and client.state == STATE_ACTIVE:
|
if client and client.state['STATE'] == STATE_ACTIVE:
|
||||||
context = bpy.context
|
context = bpy.context
|
||||||
blender_depsgraph = bpy.context.view_layer.depsgraph
|
blender_depsgraph = bpy.context.view_layer.depsgraph
|
||||||
dependency_updates = [u for u in blender_depsgraph.updates]
|
dependency_updates = [u for u in blender_depsgraph.updates]
|
||||||
@ -528,7 +528,7 @@ def register():
|
|||||||
def unregister():
|
def unregister():
|
||||||
global client
|
global client
|
||||||
|
|
||||||
if client and client.state == 2:
|
if client and client.state['STATE'] == 2:
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
client = None
|
client = None
|
||||||
|
|
||||||
|
@ -2,7 +2,11 @@ import bpy
|
|||||||
|
|
||||||
from . import operators
|
from . import operators
|
||||||
from .libs.replication.replication.constants import (ADDED, ERROR, FETCHED,
|
from .libs.replication.replication.constants import (ADDED, ERROR, FETCHED,
|
||||||
MODIFIED, RP_COMMON, UP)
|
MODIFIED, RP_COMMON, UP,
|
||||||
|
STATE_ACTIVE, STATE_AUTH,
|
||||||
|
STATE_CONFIG, STATE_SYNCING,
|
||||||
|
STATE_INITIAL, STATE_SRV_SYNC,
|
||||||
|
STATE_WAITING)
|
||||||
|
|
||||||
ICONS_PROP_STATES = ['TRIA_DOWN', # ADDED
|
ICONS_PROP_STATES = ['TRIA_DOWN', # ADDED
|
||||||
'TRIA_UP', # COMMITED
|
'TRIA_UP', # COMMITED
|
||||||
@ -11,6 +15,21 @@ ICONS_PROP_STATES = ['TRIA_DOWN', # ADDED
|
|||||||
'FILE_REFRESH', # UP
|
'FILE_REFRESH', # UP
|
||||||
'TRIA_UP'] # CHANGED
|
'TRIA_UP'] # CHANGED
|
||||||
|
|
||||||
|
def get_state_str(state):
|
||||||
|
state_str = 'None'
|
||||||
|
if state == STATE_WAITING:
|
||||||
|
state_str = 'WAITING'
|
||||||
|
elif state == STATE_SYNCING:
|
||||||
|
state_str = 'SYNCING'
|
||||||
|
elif state == STATE_AUTH:
|
||||||
|
state_str = 'AUTHENTIFICATION'
|
||||||
|
elif state == STATE_CONFIG:
|
||||||
|
state_str = 'CONFIGURATION'
|
||||||
|
elif state == STATE_ACTIVE:
|
||||||
|
state_str = 'ACTIVE'
|
||||||
|
elif state == STATE_SRV_SYNC:
|
||||||
|
state_str = 'SERVER SYNC'
|
||||||
|
return state_str
|
||||||
|
|
||||||
class SESSION_PT_settings(bpy.types.Panel):
|
class SESSION_PT_settings(bpy.types.Panel):
|
||||||
"""Settings panel"""
|
"""Settings panel"""
|
||||||
@ -31,19 +50,25 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
if hasattr(context.window_manager, 'session'):
|
if hasattr(context.window_manager, 'session'):
|
||||||
# STATE INITIAL
|
# STATE INITIAL
|
||||||
if not operators.client \
|
if not operators.client \
|
||||||
or (operators.client and operators.client.state == 0):
|
or (operators.client and operators.client.state['STATE'] == STATE_INITIAL):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
cli_state = operators.client.state
|
||||||
# STATE ACTIVE
|
# STATE ACTIVE
|
||||||
if operators.client.state == 2:
|
if cli_state['STATE'] == STATE_ACTIVE:
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("session.stop", icon='QUIT', text="Exit")
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
# STATE SYNCING
|
# STATE SYNCING
|
||||||
else:
|
else:
|
||||||
status = "connecting..."
|
row.label(text='Connecting:')
|
||||||
row.label(text=status)
|
row = layout.row()
|
||||||
|
row.label(text=f"{get_state_str(cli_state['STATE'])}")
|
||||||
|
row = layout.row()
|
||||||
|
|
||||||
|
if cli_state['STATE'] in [STATE_SYNCING,STATE_SRV_SYNC]:
|
||||||
|
row.label(text=f"{cli_state['CURRENT']}/{cli_state['TOTAL']}")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
||||||
|
|
||||||
@ -59,7 +84,7 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return not operators.client \
|
return not operators.client \
|
||||||
or (operators.client and operators.client.state == 0)
|
or (operators.client and operators.client.state['STATE'] == 0)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -110,7 +135,7 @@ class SESSION_PT_settings_user(bpy.types.Panel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return not operators.client \
|
return not operators.client \
|
||||||
or (operators.client and operators.client.state == 0)
|
or (operators.client and operators.client.state['STATE'] == 0)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -138,7 +163,7 @@ class SESSION_PT_settings_replication(bpy.types.Panel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return not operators.client \
|
return not operators.client \
|
||||||
or (operators.client and operators.client.state == 0)
|
or (operators.client and operators.client.state['STATE'] == 0)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -180,7 +205,7 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return operators.client and operators.client.state == 2
|
return operators.client and operators.client.state['STATE'] == 2
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
@ -336,7 +361,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return operators.client and operators.client.state == 2
|
return operators.client and operators.client.state['STATE'] == 2
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user