From 5906bc348677ab0b757494c9418abcdf7a7801be Mon Sep 17 00:00:00 2001 From: daydensteve Date: Sat, 5 Apr 2025 18:05:00 -0400 Subject: [PATCH 1/2] fixed inappropriate use of character illustration id instead of base character id. The Userbox jinja would break if the profile was using an alternate character illustration --- titles/chuni/frontend.py | 2 +- titles/chuni/templates/chuni_userbox.jinja | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/titles/chuni/frontend.py b/titles/chuni/frontend.py index d13252c..1059d7c 100644 --- a/titles/chuni/frontend.py +++ b/titles/chuni/frontend.py @@ -457,7 +457,7 @@ class ChuniFrontend(FE_Base): user_characters = [] if not force_unlocked: user_characters = await self.data.item.get_characters(profile.user) - user_characters = [chara["characterId"] for chara in user_characters] + [profile.characterId, profile.charaIllustId] + user_characters = [chara["characterId"] for chara in user_characters] + [profile.characterId] for row in rows: if force_unlocked or row["defaultHave"] or row["characterId"] in user_characters: diff --git a/titles/chuni/templates/chuni_userbox.jinja b/titles/chuni/templates/chuni_userbox.jinja index ab0f821..5114b17 100644 --- a/titles/chuni/templates/chuni_userbox.jinja +++ b/titles/chuni/templates/chuni_userbox.jinja @@ -118,9 +118,9 @@ userbox_components = { "{{ nameplates[profile.nameplateId]["texturePath"] }}", "", "", ""], "character":["{{ characters|length }}", - "{{ profile.charaIllustId }}", - "{{ characters[profile.charaIllustId]["name"] }}", - "{{ characters[profile.charaIllustId]["iconPath"] }}", "", "", ""] + "{{ profile.characterId }}", + "{{ characters[profile.characterId]["name"] }}", + "{{ characters[profile.characterId]["iconPath"] }}", "", "", ""] }; types = Object.keys(userbox_components); orig_trophy = curr_trophy = "{{ profile.trophyId }}"; From eb601e32933ab5b598f6772dff13092da5257744 Mon Sep 17 00:00:00 2001 From: daydensteve Date: Sat, 5 Apr 2025 20:10:07 -0400 Subject: [PATCH 2/2] fixed read failures in older chuni versions where sortname doesn't exist. Also noticed some character import errors associated with & --- titles/chuni/read.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/titles/chuni/read.py b/titles/chuni/read.py index b25d97f..50150e8 100644 --- a/titles/chuni/read.py +++ b/titles/chuni/read.py @@ -303,7 +303,7 @@ class ChuniReader(BaseReader): for name in xml_root.findall("name"): id = name.find("id").text name = name.find("str").text - sortName = xml_root.find("sortName").text + sortName = name if xml_root.find("sortName") is None else xml_root.find("sortName").text defaultHave = xml_root.find("defaultHave").text == 'true' disableFlag = xml_root.find("disableFlag") # may not exist in older data is_enabled = True if (disableFlag is None or disableFlag.text == "false") else False @@ -352,12 +352,15 @@ class ChuniReader(BaseReader): if path.exists(f"{root}/{dir}/Chara.xml"): with open(f"{root}/{dir}/Chara.xml", "r", encoding='utf-8') as fp: strdata = fp.read() + # ET may choke if there is a & symbol (which is present in some character xml) + if "&" in strdata: + strdata = strdata.replace("&", "&") xml_root = ET.fromstring(strdata) for name in xml_root.findall("name"): id = name.find("id").text name = name.find("str").text - sortName = xml_root.find("sortName").text + sortName = name if xml_root.find("sortName") is None else xml_root.find("sortName").text for work in xml_root.findall("works"): worksName = work.find("str").text rareType = xml_root.find("rareType").text @@ -401,7 +404,7 @@ class ChuniReader(BaseReader): for name in xml_root.findall("name"): id = name.find("id").text name = name.find("str").text - sortName = xml_root.find("sortName").text + sortName = name if xml_root.find("sortName") is None else xml_root.find("sortName").text for image in xml_root.findall("image"): iconPath = image.find("path").text self.copy_image(iconPath, f"{root}/{dir}", "titles/chuni/img/mapIcon/") @@ -429,7 +432,7 @@ class ChuniReader(BaseReader): for name in xml_root.findall("name"): id = name.find("id").text name = name.find("str").text - sortName = xml_root.find("sortName").text + sortName = name if xml_root.find("sortName") is None else xml_root.find("sortName").text for image in xml_root.findall("image"): imagePath = image.find("path").text self.copy_image(imagePath, f"{root}/{dir}", "titles/chuni/img/systemVoice/")