feat : undo when no right to do
This commit is contained in:
@ -179,8 +179,12 @@ class RCFClient(object):
|
|||||||
Fast key exist check
|
Fast key exist check
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
if key in self.store.keys():
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
dump_list = []
|
dump_list = []
|
||||||
for k,v in self.store.items():
|
for k,v in self.store.items():
|
||||||
@ -521,9 +525,6 @@ def watchdog_worker(feed,interval, stop_event):
|
|||||||
for item in getattr(bpy.data, helpers.CORRESPONDANCE[datatype]):
|
for item in getattr(bpy.data, helpers.CORRESPONDANCE[datatype]):
|
||||||
key = "{}/{}".format(datatype, item.name)
|
key = "{}/{}".format(datatype, item.name)
|
||||||
try:
|
try:
|
||||||
# if item.id == 'None':
|
|
||||||
# item.id = bpy.context.scene.session_settings.username
|
|
||||||
# feed.put(('DUMP',key,None))
|
|
||||||
if item.is_dirty:
|
if item.is_dirty:
|
||||||
logger.info("{} needs update".format(key))
|
logger.info("{} needs update".format(key))
|
||||||
feed.put(('DUMP',key,None))
|
feed.put(('DUMP',key,None))
|
||||||
|
@ -326,8 +326,8 @@ def load_collection(target=None, data=None, create=False):
|
|||||||
|
|
||||||
# link objects
|
# link objects
|
||||||
for object in data["objects"]:
|
for object in data["objects"]:
|
||||||
# if object not in target.objects.keys():
|
if object not in target.objects.keys():
|
||||||
target.objects.link(bpy.data.objects[object])
|
target.objects.link(bpy.data.objects[object])
|
||||||
|
|
||||||
for object in target.objects.keys():
|
for object in target.objects.keys():
|
||||||
if object not in data["objects"]:
|
if object not in data["objects"]:
|
||||||
@ -348,7 +348,7 @@ def load_collection(target=None, data=None, create=False):
|
|||||||
target.hide_select = False
|
target.hide_select = False
|
||||||
else:
|
else:
|
||||||
target.hide_select = True
|
target.hide_select = True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Collection loading error: {}".format(e))
|
logger.error("Collection loading error: {}".format(e))
|
||||||
|
|
||||||
|
46
operators.py
46
operators.py
@ -135,7 +135,6 @@ def init_datablocks():
|
|||||||
item.id = bpy.context.scene.session_settings.username
|
item.id = bpy.context.scene.session_settings.username
|
||||||
key = "{}/{}".format(datatype, item.name)
|
key = "{}/{}".format(datatype, item.name)
|
||||||
client_instance.set(key)
|
client_instance.set(key)
|
||||||
print(key)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -156,27 +155,37 @@ def default_tick():
|
|||||||
refresh_session_data()
|
refresh_session_data()
|
||||||
|
|
||||||
upload_client_instance_position()
|
upload_client_instance_position()
|
||||||
|
|
||||||
|
return .2
|
||||||
|
|
||||||
|
def undo_test():
|
||||||
|
|
||||||
|
print("UNDO")
|
||||||
|
bpy.ops.ed.undo()
|
||||||
|
|
||||||
|
def undo_tick():
|
||||||
global history
|
global history
|
||||||
try:
|
try:
|
||||||
c = history.get_nowait()
|
c = history.get_nowait()
|
||||||
if c:
|
if c:
|
||||||
bpy.ops.ed.undo()
|
undo_test()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return .2
|
return 1.0
|
||||||
|
|
||||||
|
|
||||||
def register_ticks():
|
def register_ticks():
|
||||||
# REGISTER Updaters
|
# REGISTER Updaters
|
||||||
bpy.app.timers.register(default_tick)
|
bpy.app.timers.register(default_tick)
|
||||||
|
bpy.app.timers.register(undo_tick)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def unregister_ticks():
|
def unregister_ticks():
|
||||||
# REGISTER Updaters
|
# REGISTER Updaters
|
||||||
bpy.app.timers.unregister(default_tick)
|
bpy.app.timers.unregister(default_tick)
|
||||||
|
bpy.app.timers.unregister(undo_tick)
|
||||||
|
|
||||||
|
|
||||||
# OPERATORS
|
# OPERATORS
|
||||||
@ -513,13 +522,21 @@ def ordered(updates):
|
|||||||
|
|
||||||
|
|
||||||
def is_replicated(update):
|
def is_replicated(update):
|
||||||
global client_keys
|
# global client_keys
|
||||||
dickt = dict(client_keys)
|
# dickt = dict(client_keys)
|
||||||
key = "{}/{}".format(update.id.bl_rna.name, update.id.name)
|
global client_instance
|
||||||
|
|
||||||
if key in dickt:
|
|
||||||
|
#Master collection special cae
|
||||||
|
if update.id.name == 'Master Collection':
|
||||||
|
key = "Scene/{}".format(bpy.context.scene.name)
|
||||||
|
else:
|
||||||
|
key = "{}/{}".format(update.id.bl_rna.name, update.id.name)
|
||||||
|
|
||||||
|
if client_instance.exist(key):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
logger.info("{} Not rep".format(key))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_datablock(update,context):
|
def get_datablock(update,context):
|
||||||
@ -560,7 +577,7 @@ def depsgraph_update(scene):
|
|||||||
if ctx.mode in ['OBJECT','PAINT_GPENCIL']:
|
if ctx.mode in ['OBJECT','PAINT_GPENCIL']:
|
||||||
updates = ctx.depsgraph.updates
|
updates = ctx.depsgraph.updates
|
||||||
username = ctx.scene.session_settings.username
|
username = ctx.scene.session_settings.username
|
||||||
update_selected_object(ctx)
|
|
||||||
|
|
||||||
selected_objects = helpers.get_selected_objects(scene)
|
selected_objects = helpers.get_selected_objects(scene)
|
||||||
|
|
||||||
@ -579,7 +596,16 @@ def depsgraph_update(scene):
|
|||||||
key = "{}/{}".format(item.__class__.__name__, item.name)
|
key = "{}/{}".format(item.__class__.__name__, item.name)
|
||||||
client_instance.set(key)
|
client_instance.set(key)
|
||||||
else:
|
else:
|
||||||
|
history.put("etst")
|
||||||
|
try:
|
||||||
|
item = get_datablock(update,ctx)
|
||||||
|
print(item)
|
||||||
|
getattr(bpy.data, helpers.CORRESPONDANCE[update.id.__class__.__name__]).remove(item)
|
||||||
|
except:
|
||||||
|
print("asdasdasd")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
update_selected_object(ctx)
|
||||||
# if update.id.id == username or update.id.id == 'Common' or update.id.id == 'None':
|
# if update.id.id == username or update.id.id == 'Common' or update.id.id == 'None':
|
||||||
# # TODO: handle errors
|
# # TODO: handle errors
|
||||||
# data_ref = get_datablock(update,context)
|
# data_ref = get_datablock(update,context)
|
||||||
|
Reference in New Issue
Block a user