feat: get remove property operator back
This commit is contained in:
parent
1ee124e5b1
commit
91940837ee
109
operators.py
109
operators.py
@ -41,36 +41,36 @@ context = None
|
|||||||
|
|
||||||
|
|
||||||
# def update_client_selected_object(context):
|
# def update_client_selected_object(context):
|
||||||
# session = bpy.context.window_manager.session
|
# session = bpy.context.window_manager.session
|
||||||
# username = bpy.context.window_manager.session.username
|
# username = bpy.context.window_manager.session.username
|
||||||
# client_key = "Client/{}".format(username)
|
# client_key = "Client/{}".format(username)
|
||||||
# client_data = client.get(client_key)
|
# client_data = client.get(client_key)
|
||||||
|
|
||||||
# selected_objects = utils.get_selected_objects(context.scene)
|
# selected_objects = utils.get_selected_objects(context.scene)
|
||||||
# if len(selected_objects) > 0 and len(client_data) > 0:
|
# if len(selected_objects) > 0 and len(client_data) > 0:
|
||||||
|
|
||||||
# for obj in selected_objects:
|
# for obj in selected_objects:
|
||||||
# # if obj not in client_data[0][1]['active_objects']:
|
# # if obj not in client_data[0][1]['active_objects']:
|
||||||
# client_data[0][1]['active_objects'] = selected_objects
|
# client_data[0][1]['active_objects'] = selected_objects
|
||||||
|
|
||||||
# client.set(client_key, client_data[0][1])
|
# client.set(client_key, client_data[0][1])
|
||||||
# break
|
# break
|
||||||
|
|
||||||
# elif client_data and client_data[0][1]['active_objects']:
|
# elif client_data and client_data[0][1]['active_objects']:
|
||||||
# client_data[0][1]['active_objects'] = []
|
# client_data[0][1]['active_objects'] = []
|
||||||
# client.set(client_key, client_data[0][1])
|
# client.set(client_key, client_data[0][1])
|
||||||
|
|
||||||
def add_datablock(datablock):
|
def add_datablock(datablock):
|
||||||
global client
|
global client
|
||||||
child=[]
|
child = []
|
||||||
|
|
||||||
if hasattr(datablock,"data"):
|
if hasattr(datablock, "data"):
|
||||||
child.append(add_datablock(datablock.data))
|
child.append(add_datablock(datablock.data))
|
||||||
|
|
||||||
if datablock.uuid and client.exist(datablock.uuid) :
|
if datablock.uuid and client.exist(datablock.uuid):
|
||||||
return datablock.uuid
|
return datablock.uuid
|
||||||
else:
|
else:
|
||||||
new_uuid = client.add(datablock,childs=child)
|
new_uuid = client.add(datablock, childs=child)
|
||||||
datablock.uuid = new_uuid
|
datablock.uuid = new_uuid
|
||||||
return new_uuid
|
return new_uuid
|
||||||
|
|
||||||
@ -80,12 +80,11 @@ def init_supported_datablocks(supported_types_id):
|
|||||||
global client
|
global client
|
||||||
|
|
||||||
for type_id in supported_types_id:
|
for type_id in supported_types_id:
|
||||||
if hasattr(bpy.data,type_id):
|
if hasattr(bpy.data, type_id):
|
||||||
for item in getattr(bpy.data,type_id):
|
for item in getattr(bpy.data, type_id):
|
||||||
add_datablock(item)
|
add_datablock(item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# def default_tick():
|
# def default_tick():
|
||||||
# upload_client_instance_position()
|
# upload_client_instance_position()
|
||||||
|
|
||||||
@ -116,7 +115,6 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
host: bpy.props.BoolProperty(default=False)
|
host: bpy.props.BoolProperty(default=False)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return True
|
return True
|
||||||
@ -136,13 +134,12 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
# init the factory with supported types
|
# init the factory with supported types
|
||||||
for type in bl_types.types_to_register():
|
for type in bl_types.types_to_register():
|
||||||
_type = getattr(bl_types,type)
|
_type = getattr(bl_types, type)
|
||||||
supported_bl_types.append(_type.bl_id)
|
supported_bl_types.append(_type.bl_id)
|
||||||
bpy_factory.register_type(_type.bl_class,_type.bl_rep_class)
|
bpy_factory.register_type(_type.bl_class, _type.bl_rep_class)
|
||||||
|
|
||||||
client = Client(factory=bpy_factory)
|
client = Client(factory=bpy_factory)
|
||||||
|
|
||||||
|
|
||||||
if self.host:
|
if self.host:
|
||||||
client.host(
|
client.host(
|
||||||
id=settings.username,
|
id=settings.username,
|
||||||
@ -168,7 +165,7 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
# settings.is_running = True
|
# settings.is_running = True
|
||||||
# bpy.ops.session.refresh()
|
# bpy.ops.session.refresh()
|
||||||
#register_ticks()
|
# register_ticks()
|
||||||
|
|
||||||
# Launch drawing module
|
# Launch drawing module
|
||||||
if settings.enable_presence:
|
if settings.enable_presence:
|
||||||
@ -196,34 +193,12 @@ class SessionStopOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
# del client_instance
|
# del client_instance
|
||||||
|
|
||||||
|
|
||||||
# unregister_ticks()
|
# unregister_ticks()
|
||||||
# presence.renderer.stop()
|
# presence.renderer.stop()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class SessionPropertyAddOperator(bpy.types.Operator):
|
|
||||||
bl_idname = "session.add_prop"
|
|
||||||
bl_label = "add"
|
|
||||||
bl_description = "broadcast a property to connected client_instances"
|
|
||||||
bl_options = {"REGISTER"}
|
|
||||||
|
|
||||||
property_path: bpy.props.StringProperty(default="None")
|
|
||||||
depth: bpy.props.IntProperty(default=1)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
global client
|
|
||||||
|
|
||||||
client.add(self.property_path)
|
|
||||||
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class SessionPropertyRemoveOperator(bpy.types.Operator):
|
class SessionPropertyRemoveOperator(bpy.types.Operator):
|
||||||
bl_idname = "session.remove_prop"
|
bl_idname = "session.remove_prop"
|
||||||
bl_label = "remove"
|
bl_label = "remove"
|
||||||
@ -239,7 +214,7 @@ class SessionPropertyRemoveOperator(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global client
|
global client
|
||||||
try:
|
try:
|
||||||
del client.property_map[self.property_path]
|
client.remove(self.property_path)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
except:
|
except:
|
||||||
@ -316,36 +291,6 @@ class SessionSnapUserOperator(bpy.types.Operator):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SessionDumpDatabase(bpy.types.Operator, ExportHelper):
|
|
||||||
bl_idname = "session.dump"
|
|
||||||
bl_label = "dump json data"
|
|
||||||
bl_description = "dump session stored data to a json file"
|
|
||||||
bl_options = {"REGISTER"}
|
|
||||||
|
|
||||||
# ExportHelper mixin class uses this
|
|
||||||
filename_ext = ".json"
|
|
||||||
|
|
||||||
filter_glob: bpy.props.StringProperty(
|
|
||||||
default="*.json",
|
|
||||||
options={'HIDDEN'},
|
|
||||||
maxlen=255, # Max internal buffer length, longer would be clamped.
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
print(self.filepath)
|
|
||||||
if client and client.state() == 3:
|
|
||||||
client.dump(self.filepath)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
return {"CANCELLED"}
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class SessionSaveConfig(bpy.types.Operator):
|
class SessionSaveConfig(bpy.types.Operator):
|
||||||
bl_idname = "session.save"
|
bl_idname = "session.save"
|
||||||
bl_label = "Save session configuration"
|
bl_label = "Save session configuration"
|
||||||
@ -359,6 +304,7 @@ class SessionSaveConfig(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context.window_manager.session.save()
|
context.window_manager.session.save()
|
||||||
|
|
||||||
|
|
||||||
class SessionApply(bpy.types.Operator):
|
class SessionApply(bpy.types.Operator):
|
||||||
bl_idname = "session.apply"
|
bl_idname = "session.apply"
|
||||||
bl_label = "apply the target item into the blender data"
|
bl_label = "apply the target item into the blender data"
|
||||||
@ -371,7 +317,6 @@ class SessionApply(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global client
|
global client
|
||||||
|
|
||||||
@ -379,18 +324,18 @@ class SessionApply(bpy.types.Operator):
|
|||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
SessionStartOperator,
|
SessionStartOperator,
|
||||||
SessionPropertyAddOperator,
|
|
||||||
SessionStopOperator,
|
SessionStopOperator,
|
||||||
SessionPropertyRemoveOperator,
|
SessionPropertyRemoveOperator,
|
||||||
SessionSnapUserOperator,
|
SessionSnapUserOperator,
|
||||||
SessionPropertyRightOperator,
|
SessionPropertyRightOperator,
|
||||||
SessionDumpDatabase,
|
|
||||||
SessionSaveConfig,
|
SessionSaveConfig,
|
||||||
SessionApply,
|
SessionApply,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
|
6
ui.py
6
ui.py
@ -60,7 +60,6 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
row.operator("session.stop", icon='QUIT', text="CANCEL")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SESSION_PT_settings_network(bpy.types.Panel):
|
class SESSION_PT_settings_network(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel"
|
bl_idname = "MULTIUSER_SETTINGS_NETWORK_PT_panel"
|
||||||
bl_label = "Network"
|
bl_label = "Network"
|
||||||
@ -243,6 +242,8 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
else:
|
else:
|
||||||
detail_item_box.label(text="{} ".format(PROP_STATES[item.state]))
|
detail_item_box.label(text="{} ".format(PROP_STATES[item.state]))
|
||||||
|
|
||||||
|
detail_item_box.operator(
|
||||||
|
"session.remove_prop", text="", icon="X").property_path = key
|
||||||
|
|
||||||
# right_icon = "DECORATE_UNLOCKED"
|
# right_icon = "DECORATE_UNLOCKED"
|
||||||
# if owner == settings.username:
|
# if owner == settings.username:
|
||||||
@ -253,8 +254,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
|
|
||||||
# ro = detail_item_box.operator("session.right", text="",emboss=settings.is_admin, icon=right_icon)
|
# ro = detail_item_box.operator("session.right", text="",emboss=settings.is_admin, icon=right_icon)
|
||||||
# ro.key = item[0]
|
# ro.key = item[0]
|
||||||
# detail_item_box.operator(
|
|
||||||
# "session.remove_prop", text="", icon="X").property_path = key
|
|
||||||
else:
|
else:
|
||||||
area_msg.label(text="Empty")
|
area_msg.label(text="Empty")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user