hardened ui against the db not being upgraded or importer not being ran
This commit is contained in:
parent
954bd565d3
commit
eb18ad22b8
@ -353,122 +353,134 @@ class ChuniFrontend(FE_Base):
|
||||
async def get_available_map_icons(self, version: int, profile: Row) -> (List[dict], int):
|
||||
items = dict()
|
||||
rows = await self.data.static.get_map_icons(version)
|
||||
if rows:
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("map_icons")
|
||||
if rows is None:
|
||||
return (items, 0) # can only happen with old db
|
||||
|
||||
user_map_icons = []
|
||||
if not force_unlocked:
|
||||
user_map_icons = await self.data.item.get_items(profile.user, ItemKind.MAP_ICON.value)
|
||||
user_map_icons = [icon["itemId"] for icon in user_map_icons] + [profile.mapIconId]
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("map_icons")
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["mapIconId"] in user_map_icons:
|
||||
item = dict()
|
||||
item["id"] = row["mapIconId"]
|
||||
item["name"] = row["name"]
|
||||
item["iconPath"] = path.splitext(row["iconPath"])[0] + ".png"
|
||||
items[row["mapIconId"]] = item
|
||||
user_map_icons = []
|
||||
if not force_unlocked:
|
||||
user_map_icons = await self.data.item.get_items(profile.user, ItemKind.MAP_ICON.value)
|
||||
user_map_icons = [icon["itemId"] for icon in user_map_icons] + [profile.mapIconId]
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["mapIconId"] in user_map_icons:
|
||||
item = dict()
|
||||
item["id"] = row["mapIconId"]
|
||||
item["name"] = row["name"]
|
||||
item["iconPath"] = path.splitext(row["iconPath"])[0] + ".png"
|
||||
items[row["mapIconId"]] = item
|
||||
|
||||
return (items, len(rows))
|
||||
|
||||
async def get_available_system_voices(self, version: int, profile: Row) -> (List[dict], int):
|
||||
items = dict()
|
||||
rows = await self.data.static.get_system_voices(version)
|
||||
if rows:
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("system_voices")
|
||||
if rows is None:
|
||||
return (items, 0) # can only happen with old db
|
||||
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("system_voices")
|
||||
|
||||
user_system_voices = []
|
||||
if not force_unlocked:
|
||||
user_system_voices = await self.data.item.get_items(profile.user, ItemKind.SYSTEM_VOICE.value)
|
||||
user_system_voices = [icon["itemId"] for icon in user_system_voices] + [profile.voiceId]
|
||||
user_system_voices = []
|
||||
if not force_unlocked:
|
||||
user_system_voices = await self.data.item.get_items(profile.user, ItemKind.SYSTEM_VOICE.value)
|
||||
user_system_voices = [icon["itemId"] for icon in user_system_voices] + [profile.voiceId]
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["voiceId"] in user_system_voices:
|
||||
item = dict()
|
||||
item["id"] = row["voiceId"]
|
||||
item["name"] = row["name"]
|
||||
item["imagePath"] = path.splitext(row["imagePath"])[0] + ".png"
|
||||
items[row["voiceId"]] = item
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["voiceId"] in user_system_voices:
|
||||
item = dict()
|
||||
item["id"] = row["voiceId"]
|
||||
item["name"] = row["name"]
|
||||
item["imagePath"] = path.splitext(row["imagePath"])[0] + ".png"
|
||||
items[row["voiceId"]] = item
|
||||
|
||||
return (items, len(rows))
|
||||
|
||||
async def get_available_nameplates(self, version: int, profile: Row) -> (List[dict], int):
|
||||
items = dict()
|
||||
rows = await self.data.static.get_nameplates(version)
|
||||
if rows:
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("nameplates")
|
||||
if rows is None:
|
||||
return (items, 0) # can only happen with old db
|
||||
|
||||
user_nameplates = []
|
||||
if not force_unlocked:
|
||||
user_nameplates = await self.data.item.get_items(profile.user, ItemKind.NAMEPLATE.value)
|
||||
user_nameplates = [item["itemId"] for item in user_nameplates] + [profile.nameplateId]
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("nameplates")
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["nameplateId"] in user_nameplates:
|
||||
item = dict()
|
||||
item["id"] = row["nameplateId"]
|
||||
item["name"] = row["name"]
|
||||
item["texturePath"] = path.splitext(row["texturePath"])[0] + ".png"
|
||||
items[row["nameplateId"]] = item
|
||||
user_nameplates = []
|
||||
if not force_unlocked:
|
||||
user_nameplates = await self.data.item.get_items(profile.user, ItemKind.NAMEPLATE.value)
|
||||
user_nameplates = [item["itemId"] for item in user_nameplates] + [profile.nameplateId]
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["nameplateId"] in user_nameplates:
|
||||
item = dict()
|
||||
item["id"] = row["nameplateId"]
|
||||
item["name"] = row["name"]
|
||||
item["texturePath"] = path.splitext(row["texturePath"])[0] + ".png"
|
||||
items[row["nameplateId"]] = item
|
||||
|
||||
return (items, len(rows))
|
||||
|
||||
async def get_available_trophies(self, version: int, profile: Row) -> (List[dict], int):
|
||||
items = dict()
|
||||
rows = await self.data.static.get_trophies(version)
|
||||
if rows:
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("trophies")
|
||||
if rows is None:
|
||||
return (items, 0) # can only happen with old db
|
||||
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("trophies")
|
||||
|
||||
user_trophies = []
|
||||
if not force_unlocked:
|
||||
user_trophies = await self.data.item.get_items(profile.user, ItemKind.TROPHY.value)
|
||||
user_trophies = [item["itemId"] for item in user_trophies] + [profile.trophyId]
|
||||
user_trophies = []
|
||||
if not force_unlocked:
|
||||
user_trophies = await self.data.item.get_items(profile.user, ItemKind.TROPHY.value)
|
||||
user_trophies = [item["itemId"] for item in user_trophies] + [profile.trophyId]
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["trophyId"] in user_trophies:
|
||||
item = dict()
|
||||
item["id"] = row["trophyId"]
|
||||
item["name"] = row["name"]
|
||||
item["rarity"] = row["rareType"]
|
||||
items[row["trophyId"]] = item
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["trophyId"] in user_trophies:
|
||||
item = dict()
|
||||
item["id"] = row["trophyId"]
|
||||
item["name"] = row["name"]
|
||||
item["rarity"] = row["rareType"]
|
||||
items[row["trophyId"]] = item
|
||||
|
||||
return (items, len(rows))
|
||||
|
||||
async def get_available_characters(self, version: int, profile: Row) -> (List[dict], int):
|
||||
items = dict()
|
||||
rows = await self.data.static.get_characters(version)
|
||||
if rows:
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("character_icons")
|
||||
if rows is None:
|
||||
return (items, 0) # can only happen with old db
|
||||
|
||||
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]
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("character_icons")
|
||||
|
||||
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]
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["characterId"] in user_characters:
|
||||
item = dict()
|
||||
item["id"] = row["characterId"]
|
||||
item["name"] = row["name"]
|
||||
item["iconPath"] = path.splitext(row["imagePath3"])[0] + ".png"
|
||||
items[row["characterId"]] = item
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["characterId"] in user_characters:
|
||||
item = dict()
|
||||
item["id"] = row["characterId"]
|
||||
item["name"] = row["name"]
|
||||
item["iconPath"] = path.splitext(row["imagePath3"])[0] + ".png"
|
||||
items[row["characterId"]] = item
|
||||
|
||||
return (items, len(rows))
|
||||
|
||||
async def get_available_avatar_items(self, version: int, category: AvatarCategory, user_unlocked_items: List[int]) -> (List[dict], int):
|
||||
items = dict()
|
||||
rows = await self.data.static.get_avatar_items(version, category.value)
|
||||
if rows:
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("avatar_accessories")
|
||||
if rows is None:
|
||||
return (items, 0) # can only happen with old db
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["avatarAccessoryId"] in user_unlocked_items:
|
||||
item = dict()
|
||||
item["id"] = row["avatarAccessoryId"]
|
||||
item["name"] = row["name"]
|
||||
item["iconPath"] = path.splitext(row["iconPath"])[0] + ".png"
|
||||
item["texturePath"] = path.splitext(row["texturePath"])[0] + ".png"
|
||||
items[row["avatarAccessoryId"]] = item
|
||||
force_unlocked = self.game_cfg.mods.forced_item_unlocks("avatar_accessories")
|
||||
|
||||
for row in rows:
|
||||
if force_unlocked or row["defaultHave"] or row["avatarAccessoryId"] in user_unlocked_items:
|
||||
item = dict()
|
||||
item["id"] = row["avatarAccessoryId"]
|
||||
item["name"] = row["name"]
|
||||
item["iconPath"] = path.splitext(row["iconPath"])[0] + ".png"
|
||||
item["texturePath"] = path.splitext(row["texturePath"])[0] + ".png"
|
||||
items[row["avatarAccessoryId"]] = item
|
||||
|
||||
return (items, len(rows))
|
||||
|
||||
|
@ -124,6 +124,12 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if wears|length == 0 or faces|length == 0 or heads|length == 0 or skins|length == 0 or items|length == 0 or fronts|length == 0 or backs|length == 0 %}
|
||||
<script>
|
||||
// Server DB lacks necessary info. Maybe importer never got ran for this verison?
|
||||
document.getElementById("name_wear").innerHTML = "Server DB needs upgraded or is not populated with necessary data";
|
||||
</script>
|
||||
{% else %}
|
||||
<script>
|
||||
{% include 'titles/chuni/templates/scripts/collapsibles.js' %}
|
||||
|
||||
@ -298,5 +304,6 @@ for (const type of types) {
|
||||
// Expand the first collapsible so the user can get the gist of it.
|
||||
Collapsibles.expandFirst();
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% endblock content %}
|
@ -72,11 +72,11 @@
|
||||
{% if cur_version >= 6 %} <!-- MAP ICON and SYSTEM VOICE introduced in AMAZON -->
|
||||
<tr>
|
||||
<td>Map Icon:</td>
|
||||
<td><div id="map-icon-name">{{ map_icons[profile.mapIconId]["name"] }}</div></td>
|
||||
<td><div id="map-icon-name">{{ map_icons[profile.mapIconId]["name"] if map_icons|length > 0 else "Server DB needs upgraded or is not populated with necessary data" }}</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>System Voice:</td>
|
||||
<td><div id="system-voice-name">{{ system_voices[profile.voiceId]["name"] }}</div></td>
|
||||
<td><div id="system-voice-name">{{ system_voices[profile.voiceId]["name"] if system_voices|length > 0 else "Server DB needs upgraded or is not populated with necessary data" }}</div></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
@ -91,6 +91,12 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if nameplates|length == 0 or characters|length == 0 %}
|
||||
<script>
|
||||
// Server DB lacks necessary info. Maybe importer never got ran for this verison?
|
||||
document.getElementById("name_nameplate").innerHTML = "Server DB needs upgraded or is not populated with necessary data";
|
||||
</script>
|
||||
{% else %}
|
||||
<script>
|
||||
{% include 'titles/chuni/templates/scripts/collapsibles.js' %}
|
||||
|
||||
@ -252,5 +258,5 @@ for (const type of types) {
|
||||
|
||||
Collapsibles.expandAll();
|
||||
</script>
|
||||
|
||||
{% endif %}
|
||||
{% endblock content %}
|
Loading…
x
Reference in New Issue
Block a user