Skip to content

Commit

Permalink
Merge pull request #11 from BA-OST-Index/dev
Browse files Browse the repository at this point in the history
2023-12-10 updates
  • Loading branch information
sctop authored Dec 9, 2023
2 parents abde575 + 3c361a2 commit 2b3c178
Show file tree
Hide file tree
Showing 20 changed files with 302 additions and 96 deletions.
40 changes: 24 additions & 16 deletions main_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ def arg_check(arg):
return True

@staticmethod
def storypart_extract_all_data(parts, key_name):
def storypart_extract_all_data(part, key_name):
temp = OrderedDict()
for segment in parts["data"]:
for segment in part["data"]:
for obj in segment[key_name]:
if obj["uuid"] not in temp.keys():
temp[obj["uuid"]] = obj
return [i for i in temp.values()]

@staticmethod
def storypart_extract_all_data_track(parts):
return JinjaTool.storypart_extract_all_data(parts, "track")
def storypart_extract_all_data_track(part):
return JinjaTool.storypart_extract_all_data(part, "track")

@staticmethod
def storypart_extract_all_data_background(parts):
return JinjaTool.storypart_extract_all_data(parts, "background")
def storypart_extract_all_data_background(part):
return JinjaTool.storypart_extract_all_data(part, "background")

@staticmethod
def storypart_extract_all_data_characters(parts):
return JinjaTool.storypart_extract_all_data(parts, "character")
def storypart_extract_all_data_characters(part):
return JinjaTool.storypart_extract_all_data(part, "character")

@staticmethod
@lru_cache()
Expand Down Expand Up @@ -266,18 +266,26 @@ def py_tooltip_character(character, instance_id, instance_type, extra_data):
related_parts = []
for (index, part) in enumerate(story["part"], 1):
seg_index = -1

# 针对 char-char (in-story) 设计,这部分只精确到part
if instance_type == "character":
is_exit = 0
for char2 in JinjaTool.storypart_extract_all_data_characters(part):
if char2["uuid"] == instance_id:
is_exit = 1
break
if is_exit == 1:
related_parts.append([part, index, seg_index, 0])

# 直接跳过剩下循环
continue

# 其它数据
for (index2, segment) in enumerate(part["data"], 1):
is_exit = 0
for char in segment["character"]:
if char["uuid"] == char_data["uuid"]:
if instance_type == "character":
for char2 in segment["character"]:
if char2["uuid"] == instance_id:
is_exit = 1
break
if is_exit == 1:
break
elif instance_type == "track":
if instance_type == "track":
for track in segment["track"]:
if track["instance_id"] == instance_id:
is_exit = 1
Expand Down
9 changes: 6 additions & 3 deletions page/en/character_all.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "template/en/base.html" %}
{% from 'template/base/_macro.html' import generate_tag_badge %}

{% block title %}{{ char.name.en }}{% endblock title %}
{% block other_head %}
Expand All @@ -10,17 +11,17 @@ <h1>{{ char.name.en }}</h1>
<p>{{ char.desc.en }}</p>
<div>
<p>Select the mode you want to display character names:&nbsp;
<select id="char_lang_display" onchange="set_char_lang_display_status('en', this)">
<select id="char_lang_display" onchange="setCharLangDisplayStatus('en', this)">
<option value="0">English Only</option>
<option value="1">English + Japanese</option>
</select>
</p>
<script>display_char_lang_element('en'); document.getElementById("char_lang_display").value = localStorage.getItem("char_lang_en");</script>
<script>displayCharLangElement('en'); document.getElementById("char_lang_display").value = localStorage.getItem("char_lang_en");</script>
<p>Enable student's detailed description?&nbsp;
<input type="radio" name="desc_enable" value="enable" id="char_desc_radio_1">&nbsp;Enable&nbsp;
<input type="radio" name="desc_enable" value="disable" id="char_desc_radio_0">&nbsp;Disable
</p>
<script>set_listen_char_desc_preference(); check_char_desc_radio();</script>
<script>setListenerOnCharDescPreference(); displayCharDescRadioStatus();</script>
</div>
{% if char.filetype == -51 %}
<h2>NPC</h2>
Expand All @@ -39,6 +40,7 @@ <h2>Students</h2>
<li>
<a href="/en/character/student/{{ curr.student.name.path_name|lower }}/">
<img src="{{ get_static('images/student/icon/' + curr.student.image.collection_texture + '.webp') }}" class="icon-stu"/>{{ curr.student.name.name.en }}<span lang="jp" class="char-lang-jp">&nbsp;/&nbsp;{{ curr.student.name.name.jp }}</span>
{% if curr.student.bond_track %}<a href="/en/{{ '/'.join(curr.student.bond_track.namespace) }}.html" class="badge-stu-bond-track">{{ generate_tag_badge("momo", curr.student.bond_track.no|string + ". " + curr.student.bond_track.name.realname.en) }}</a>{% endif %}
</a>
<br/>
<div class="stu-list-desc">
Expand All @@ -60,6 +62,7 @@ <h2>Students</h2>
<li>
<a href="/en/character/student/{{ curr.name.path_name|lower }}/">
<img src="{{ get_static('images/student/icon/' + curr.image.collection_texture + '.webp') }}" class="icon-stu"/>{{ curr.name.name.en }}<span lang="jp" class="char-lang-jp">&nbsp;/&nbsp;{{ curr.name.name.jp }})</span>
{% if curr.bond_track %}<a href="/en/{{ '/'.join(curr.bond_track.namespace) }}.html" class="badge-stu-bond-track">{{ generate_tag_badge("momo", curr.bond_track.no|string + ". " + curr.bond_track.name.realname.en) }}</a>{% endif %}
</a>
<br/>
<div class="stu-list-desc">
Expand Down
22 changes: 19 additions & 3 deletions page/en/story.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

{% block title %}Story/{{ story.name.en }}{% endblock title %}
{% block article_content %}
{% from "template/en/_macro_page.html" import output_usedby_character, output_usedby_track_list, output_usedby_background_list %}
{% from "template/en/_macro_tooltip.html" import tooltip_storypart_source, tooltip_add_data_js %}
{% from "template/en/_macro_page.html" import output_usedby_character, output_usedby_track_list, output_usedby_background_list, output_storyinfo_source %}
{% from "template/en/_macro.html" import get_ordinal_number, filetype_to_name, generate_track_anchor %}
{% from "template/base/_macro.html" import get_story_text_color_css, get_storypart_text_color_css %}
{% from "template/base/_macro.html" import get_story_text_color_css, get_storypart_text_color_css, generate_popup_for_tooltip_anchor %}

<h1>Story/<span class="{{ get_story_text_color_css(story) }}">{{ story.name.en }}</span></h1>
{% include "template/en/infobox/story.html" %}
Expand Down Expand Up @@ -35,10 +36,24 @@ <h2>Battle/Bond Track Info</h2>
<p>This story contains no battle/recollection lobby part, therefore there's no such track information.</p>
{% endif %}

<h2>Story Reference</h2>
<p>The following lists all the available sources for referencing this story.</p>
{{ output_storyinfo_source(story.source) }}

<h2>Story Parts</h2>
{% set story_part_tooltip_data = {} %}
{% for part in story.part %}
{% set part_index = loop.index %}
<h3 class="{{ get_storypart_text_color_css(part) }}" id="story-part-{{ loop.index }}">{{ loop.index }}. {{ part.name.en }}</h3>

{# 检测有没有source #}
{% set enable_source = False %}
{% if part.source.en|length != 0 or part.source.zh_tw|length != 0 or part.source.zh_cn_cn|length != 0 or part.source.zh_cn_jp|length != 0 %}
{% set enable_source = True %}
{% set tooltip_id = generate_tooltip_id() %}
{% do story_part_tooltip_data.update({tooltip_id: tooltip_storypart_source(part)}) %}
{% endif %}

<h3 class="{{ get_storypart_text_color_css(part) }}" id="story-part-{{ loop.index }}">{{ loop.index }}. {{ part.name.en }} {% if enable_source %}{{ generate_popup_for_tooltip_anchor(tooltip_id) }}{% endif %}</h3>

{% for segment in part.data %}
<ul style="margin: 0;">
Expand All @@ -58,4 +73,5 @@ <h4>Backgrounds</h4>
{% else %}
<p>Nothing to show!</p>
{% endfor %}
{{ tooltip_add_data_js(story_part_tooltip_data) }}
{% endblock %}
8 changes: 4 additions & 4 deletions page/en/track.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{% extends "template/en/base.html" %}

{% block title %}Track/{{ track.name.realname.en }}{% endblock title %}
{% block other_head %}
<script src="{{ get_static('js/track_player.js') }}"></script>
{% endblock other_head %}
{% block article_content %}
{% from "template/en/_macro_page.html" import output_usedby_background, output_usedby_story, output_usedby_battle, output_usedby_ui, output_usedby_video, output_usedby_character_dict, track_version_video_player, output_track_album %}
{% from "template/en/_macro.html" import tracktype_to_name, generate_album_anchor, generate_track_anchor, output_track_stat_badge_all %}
{% from "template/en/_macro.html" import tracktype_to_name, generate_album_anchor, generate_track_anchor, output_track_stat_badge_all, generate_character_anchor_flat %}
{% from "template/en/_macro_page2.html" import track_stats_table %}

<h1>Track/{{ track.no }}. {{ track.name.realname.en }} {{ output_track_stat_badge_all(track.stats) }}</h1>
Expand Down Expand Up @@ -41,6 +38,9 @@ <h2>Play Music Here</h2>

<h2>Track Stats</h2>
{{ track_stats_table(track.stats) }}
<h3>Recollection Lobby Characters</h3>
<p>The recollection lobbies of the listed characters use this track.</p>
{{ generate_character_anchor_flat(track.bond_chars) }}

<h2>Usage Info</h2>
<p>This section shows instances where the song has been referenced.</p>
Expand Down
9 changes: 6 additions & 3 deletions page/zh_cn/character_all.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "template/zh_cn/base.html" %}
{% from 'template/base/_macro.html' import generate_tag_badge %}
{% from 'template/zh_cn/_macro.html' import auto_zhcn_gen, nothing_to_show %}

{% block title %}{{ char.name.zh_cn }}{% endblock title %}
Expand All @@ -11,19 +12,19 @@ <h1>{{ char.name.zh_cn }}</h1>
<p>{{ char.desc.zh_cn }}</p>
<div>
<p>选择显示角色名字的模式:
<select id="char_lang_display" onchange="set_char_lang_display_status('zh', this)">
<select id="char_lang_display" onchange="setCharLangDisplayStatus('zh', this)">
<option value="0">仅中文</option>
<option value="1">中文+英文</option>
<option value="2">中文+日语</option>
<option value="3">中文+英文+日语</option>
</select>
</p>
<script>display_char_lang_element('zh'); document.getElementById("char_lang_display").value = localStorage.getItem("char_lang_zh");</script>
<script>displayCharLangElement('zh'); document.getElementById("char_lang_display").value = localStorage.getItem("char_lang_zh");</script>
<p>是否启用显示学生详细信息?&nbsp;
<input type="radio" name="desc_enable" value="enable" id="char_desc_radio_1">&nbsp;启用&nbsp;
<input type="radio" name="desc_enable" value="disable" id="char_desc_radio_0">&nbsp;禁用
</p>
<script>set_listen_char_desc_preference(); check_char_desc_radio();</script>
<script>setListenerOnCharDescPreference(); displayCharDescRadioStatus();</script>
</div>
{% if char.filetype == -51 %}
<h2>NPC</h2>
Expand All @@ -42,6 +43,7 @@ <h2>学生</h2>
<li>
<a href="/zh_cn/character/student/{{ curr.student.name.path_name|lower }}/">
<img src="{{ get_static('images/student/icon/' + curr.student.image.collection_texture + '.webp') }}" class="icon-stu"/>{{ auto_zhcn_gen(curr.student.name.name) }}<span lang="en" class="char-lang-en">&nbsp;/&nbsp;{{ curr.student.name.name.en }}</span><span lang="jp" class="char-lang-jp">&nbsp;/&nbsp;{{ curr.student.name.name.jp }}</span>
{% if curr.student.bond_track %}<a href="/en/{{ '/'.join(curr.student.bond_track.namespace) }}.html" class="badge-stu-bond-track">{{ generate_tag_badge("momo", curr.student.bond_track.no|string + ". " + curr.student.bond_track.name.realname.en) }}</a>{% endif %}
</a>
<br/>
<div class="stu-list-desc">
Expand All @@ -63,6 +65,7 @@ <h2>学生</h2>
<li>
<a href="/zh_cn/character/student/{{ curr.name.path_name|lower }}/">
<img src="{{ get_static('images/student/icon/' + curr.image.collection_texture + '.webp') }}" class="icon-stu"/>{{ auto_zhcn_gen(curr.name.name) }}<span lang="en" class="char-lang-en">&nbsp;/&nbsp;{{ curr.name.name.en }}</span><span lang="jp" class="char-lang-jp">&nbsp;/&nbsp;{{ curr.name.name.jp }}</span>
{% if curr.bond_track %}<a href="/en/{{ '/'.join(curr.bond_track.namespace) }}.html" class="badge-stu-bond-track">{{ generate_tag_badge("momo", curr.bond_track.no|string + ". " + curr.bond_track.name.realname.en) }}</a>{% endif %}
</a>
<br/>
<div class="stu-list-desc">
Expand Down
22 changes: 19 additions & 3 deletions page/zh_cn/story.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

{% block title %}故事/{{ story.name.zh_cn_jp }}{% endblock title %}
{% block article_content %}
{% from "template/base/_macro.html" import get_story_text_color_css, get_storypart_text_color_css %}
{% from "template/zh_cn/_macro_page.html" import output_usedby_character, output_usedby_track_list, output_usedby_background_list %}
{% from "template/zh_cn/_macro_tooltip.html" import tooltip_storypart_source, tooltip_add_data_js %}
{% from "template/base/_macro.html" import get_story_text_color_css, get_storypart_text_color_css, generate_popup_for_tooltip_anchor %}
{% from "template/zh_cn/_macro_page.html" import output_usedby_character, output_usedby_track_list, output_usedby_background_list, output_storyinfo_source %}
{% from "template/zh_cn/_macro.html" import auto_zhcn_gen, nothing_to_show, filetype_to_name, generate_track_anchor %}

<h1>故事/<span class="{{ get_story_text_color_css(story) }}">{{ auto_zhcn_gen(story.name) }}</span></h1>
Expand Down Expand Up @@ -35,10 +36,24 @@ <h2>战斗/羁绊曲目信息</h2>
<p>此故事无战斗/羁绊剧情部分,因而这里没有相关曲目信息。</p>
{% endif %}

<h2>故事引用源</h2>
<p>以下列出可供引用的故事来源。</p>
{{ output_storyinfo_source(story.source) }}

<h2>故事部分</h2>
{% set story_part_tooltip_data = {} %}
{% for part in story.part %}
{% set part_index = loop.index %}
<h3 class="{{ get_storypart_text_color_css(part) }}" id="story-part-{{ loop.index }}">{{ loop.index }}. {{ auto_zhcn_gen(part.name) }}</h3>

{# 检测有没有source #}
{% set enable_source = False %}
{% if part.source.en|length != 0 or part.source.zh_tw|length != 0 or part.source.zh_cn_cn|length != 0 or part.source.zh_cn_jp|length != 0 %}
{% set enable_source = True %}
{% set tooltip_id = generate_tooltip_id() %}
{% do story_part_tooltip_data.update({tooltip_id: tooltip_storypart_source(part)}) %}
{% endif %}

<h3 class="{{ get_storypart_text_color_css(part) }}" id="story-part-{{ loop.index }}">{{ loop.index }}. {{ auto_zhcn_gen(part.name) }} {% if enable_source %}{{ generate_popup_for_tooltip_anchor(tooltip_id) }}{% endif %}</h3>

{% for segment in part.data %}
<ul style="margin: 0;">
Expand All @@ -58,4 +73,5 @@ <h4>背景</h4>
{% else %}
<p>{{ nothing_to_show }}</p>
{% endfor %}
{{ tooltip_add_data_js(story_part_tooltip_data) }}
{% endblock %}
8 changes: 4 additions & 4 deletions page/zh_cn/track.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{% extends "template/zh_cn/base.html" %}

{% block title %}曲子/{{ track.no }}. {{ track.name.realname.en }} ({{ track.name.realname.zh_cn }}){% endblock title %}
{% block other_head %}
<script src="{{ get_static('js/track_player.js') }}"></script>
{% endblock other_head %}
{% block article_content %}
{% from "template/zh_cn/_macro_page.html" import output_usedby_background, output_usedby_story, output_usedby_battle, output_usedby_ui, output_usedby_video, output_usedby_character_dict, track_version_video_player, output_track_album %}
{% from "template/zh_cn/_macro.html" import tracktype_to_name, generate_album_anchor, generate_track_anchor, nothing_to_show, output_track_stat_badge_all %}
{% from "template/zh_cn/_macro.html" import tracktype_to_name, generate_album_anchor, generate_track_anchor, nothing_to_show, output_track_stat_badge_all, generate_character_anchor_flat %}
{% from "template/zh_cn/_macro_page2.html" import track_stats_table %}

<h1>曲子/{{ track.no }}. {{ track.name.realname.en }}{% if track.name.realname.zh_cn %}&nbsp;({{ track.name.realname.zh_cn }}){% endif %} {{ output_track_stat_badge_all(track.stats) }}</h1>
Expand Down Expand Up @@ -41,6 +38,9 @@ <h2>在线播放音乐</h2>

<h2>曲子详细信息</h2>
{{ track_stats_table(track.stats) }}
<h3>回忆大厅角色</h3>
<p>以下角色的回忆大厅使用了本音乐。</p>
{{ generate_character_anchor_flat(track.bond_chars) }}

<h2>使用信息</h2>
<p>此处显示引用了这首曲子的实例。</p>
Expand Down
2 changes: 1 addition & 1 deletion template/base/_macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{% macro word_case(text) %}{{ text[0]|upper }}{{ text[1:] }}{% endmacro %}

{% macro generate_tooltip_anchor(tooltip_id) %}onmouseover="showTooltip(this)" data-tooltip="{{ tooltip_id }}"{% endmacro %}
{% macro generate_tooltip_anchor(tooltip_id) %}onmouseover="showTooltipById(this)" data-tooltip="{{ tooltip_id }}"{% endmacro %}

{% macro generate_popup_for_tooltip_anchor(tooltip_id) %}<span onclick="showPopupByTooltipId('{{ tooltip_id }}')" style="display: inline-block"><img src="{{ get_static('images/site/circle-info.svg') }}" class="popup-icon"></span>{% endmacro %}

Expand Down
Loading

0 comments on commit 2b3c178

Please sign in to comment.