refactor: add texts back

This commit is contained in:
Swann 2021-05-19 14:23:56 +02:00
parent 49fadf084a
commit 3f6e4f7333
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
3 changed files with 29 additions and 12 deletions

View File

@ -268,5 +268,5 @@ class BlCurve(ReplicatedDatablock):
else: else:
return super().diff() return super().diff()
_type = bpy.types.Curve _type = [bpy.types.Curve, bpy.types.TextCurve]
_class = BlCurve _class = BlCurve

View File

@ -25,7 +25,7 @@ import bpy
from replication.protocol import ReplicatedDatablock from replication.protocol import ReplicatedDatablock
from .bl_file import get_filepath, ensure_unpacked from .bl_file import get_filepath, ensure_unpacked
from .dump_anything import Dumper, Loader from .dump_anything import Dumper, Loader
from .bl_datablock import resolve_datablock_from_uuid
class BlFont(ReplicatedDatablock): class BlFont(ReplicatedDatablock):
bl_id = "fonts" bl_id = "fonts"
@ -34,6 +34,7 @@ class BlFont(ReplicatedDatablock):
bl_icon = 'FILE_FONT' bl_icon = 'FILE_FONT'
bl_reload_parent = False bl_reload_parent = False
@staticmethod
def construct(data: dict) -> object: def construct(data: dict) -> object:
filename = data.get('filename') filename = data.get('filename')
@ -42,31 +43,47 @@ class BlFont(ReplicatedDatablock):
else: else:
return bpy.data.fonts.load(get_filepath(filename)) return bpy.data.fonts.load(get_filepath(filename))
def _load(self, data, target): @staticmethod
def load(data: dict, datablock: object):
pass pass
def _dump(self, instance=None): @staticmethod
if instance.filepath == '<builtin>': def dump(datablock: object) -> dict:
if datablock.filepath == '<builtin>':
filename = '<builtin>' filename = '<builtin>'
else: else:
filename = Path(instance.filepath).name filename = Path(datablock.filepath).name
if not filename: if not filename:
raise FileExistsError(instance.filepath) raise FileExistsError(datablock.filepath)
return { return {
'filename': filename, 'filename': filename,
'name': instance.name 'name': datablock.name
} }
def diff(self): def diff(self):
return False return False
@staticmethod
def resolve(data: dict) -> object:
uuid = data.get('uuid')
name = data.get('name')
datablock = resolve_datablock_from_uuid(uuid, bpy.data.fonts)
if datablock is None:
datablock = bpy.data.fonts.get(name)
return datablock
@staticmethod
def resolve_deps(datablock: object) -> [object]: def resolve_deps(datablock: object) -> [object]:
deps = [] deps = []
if self.instance.filepath and self.instance.filepath != '<builtin>': if datablock.filepath and datablock.filepath != '<builtin>':
ensure_unpacked(self.instance) ensure_unpacked(datablock)
deps.append(Path(bpy.path.abspath(self.instance.filepath))) deps.append(Path(bpy.path.abspath(datablock.filepath)))
return deps return deps
_type = bpy.types.VectorFont
_class = BlFont

@ -1 +1 @@
Subproject commit a6b4c5596980f22acb96e956660cf74b7191294d Subproject commit 1a75bbba0bbc075da4efd68e2076dc167abe3b38