Skip to content
Snippets Groups Projects
Commit 943da2d1 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

tentative viteuf'

parent d80216ac
No related branches found
No related tags found
No related merge requests found
......@@ -106,7 +106,7 @@ class UnityFile:
print(f"lecture de {self.get_full_path()}")
if platform.system() == "Windows":
winsound.PlaySound(self.get_full_path(), winsound.SND_FILENAME)
else:
playsound(self.get_full_path(), sync)
......@@ -118,17 +118,22 @@ class UnityFile:
#https://stackoverflow.com/a/7493603/19587593
def asset_atlas(cls):
cls.atlas = {}
def getinstance(anid, snd_or_dico=None, img=None, base_path=""):
cls.rewrite_list = {}
def getinstance(anid, snd_or_dico=None, img=None, base_path="", name_space=None):
if name_space != None:
anid = cls.check_rewrite(anid, name_space)
if anid not in cls.atlas:
cls.atlas[anid] = cls(anid, snd_or_dico, img, base_path)
cls.atlas[anid] = cls(anid, snd_or_dico, img, base_path)#le name_space n'est pas nécessaire dans ce cas
elif snd_or_dico != None or img != None:
cls.atlas[anid].merge(cls(anid, snd_or_dico, img, base_path))
if not cls.atlas[anid].merge(cls(anid, snd_or_dico, img, base_path)):
anid = cls.rewrite_id(anid, name_space)
cls.atlas[anid] = cls(anid, snd_or_dico, img, base_path)
return cls.atlas[anid]
return getinstance
@asset_atlas
class Asset:
def __init__(self, anid, snd_or_dico=None, img=None, base_path=""):
def __init__(self, anid, snd_or_dico=None, img=None, base_path="", name_space = None):
self.mid = anid
if type(snd_or_dico) == dict:
if img == None:
......@@ -149,6 +154,24 @@ class Asset:
else: #path
self.img = UnityFile(img, base_path, self.mid)
@classmethod
def rewrite_id(cls, anid, name_space):
if anid in cls.atlas.keys():
new_id += f"_{name_space}"
while new_id in cls.atlas.keys():
new_id += name_space
if name_space not in cls.rewrite_list.keys():
cls.rewrite_list[name_space] = {}
cls.rewrite_list[name_space][anid] = new_id
return new_id
@classmethod
def check_rewrite(cls, anid, name_space):
if name_space in cls.rewrite_list.keys() and anid in cls.rewrite_list[name_space].keys():
return cls.rewrite_list[name_space][anid]
else:
return anid
def set_id(self, new_id):
self.mid = new_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment