Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions src/arknights/arknightsGameData/builder/operatorBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,18 +503,56 @@ def clear_all(cls):
cls.tokens_map = {}


def convert_color_tag(text: str) -> str:
"""
将 <color=#FF6237>{0}</color>
转换为 <span style="color: #FF6237; font-size: inherit">
"""
pattern = r'<color=(#[0-9A-Fa-f]{6})>\{0\}</color>'
match = re.match(pattern, text.strip())
if match:
color = match.group(1)
return f'<span style="color: {color}; font-size: inherit">'
return text


def html_tag_format(text: str):
if text is None:
return ''

for o, f in html_symbol.items():
rich_text_styles = JsonData.get_json_data('gamedata_const')['richTextStyles']
convert_dict = {
'</>': '</span>',
'\\n': '<br>',
'\n': '<br>',
}

for key, value in rich_text_styles.items():
new_key = f"<@{key}>"
new_value = convert_color_tag(value)
convert_dict[new_key] = new_value

for o, f in convert_dict.items():
text = text.replace(o, f)

return remove_xml_tag(text)
# 将中文字符前的 '<' 替换为 '&lt;'
text = re.sub(r'<(?=[\u4e00-\u9fa5])', '&lt;', text)
# 将中文字符后的 '>' 替换为 '&gt;'
text = re.sub(r'(?<=[\u4e00-\u9fa5])>', '&gt;', text)

# 将<$ba.+>替换为下划线
pattern = r'<\$ba\.[^>]+>'
replacement = '<span style="text-decoration: underline; font-size: inherit">'
text = re.sub(pattern, replacement, text)

return text


def parse_template(blackboard: list, description: str):
formatter = {'0%': lambda v: f'{round(v * 100)}%'}
formatter = {
'0%': lambda v: f'{round(v * 100)}%',
# 修复带小数点的百分比
'0.0%': lambda v: f'{v * 100:.1f}%'
}
data_dict = {item['key']: item.get('valueStr') or item.get('value') for index, item in enumerate(blackboard)}

desc = html_tag_format(description.replace('>-{', '>{'))
Expand All @@ -529,11 +567,12 @@ def parse_template(blackboard: list, description: str):
if len(key) >= 2 and key[1] in formatter and value:
value = formatter[key[1]](value)

desc = desc.replace(desc_item[0], f' [cl {value}@#174CC6 cle] ')
desc = desc.replace(desc_item[0], f'{value}')

return desc



def build_range(grids):
_max = [0, 0, 0, 0]
for item in [{'row': 0, 'col': 0}] + grids:
Expand Down
6 changes: 3 additions & 3 deletions src/arknights/operatorArchives/template/operatorInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<span v-if="data.info.is_sp" style="background: #9c27b0">异格干员</span>
<span v-for="item in data.info.tags">{{ item }}</span>
</div>
<div class="trait" v-html="colorSpan(data.detail.operator_trait, false)"></div>
<div class="trait" v-html="data.detail.operator_trait"></div>
<div class="name" style="padding-top: 10px; font-size: 50px">{{ data.info.name }}</div>
<div class="name" style="padding-bottom: 10px; font-size: 30px">
<span>{{ data.info.number }}</span>
Expand Down Expand Up @@ -144,7 +144,7 @@
:style="{backgroundImage: `url('${buildingSkillIconPath(item.bs_icon)}')`}">
</div>
<div style="width: 100px">{{ item.bs_name }}</div>
<div style="width: calc(100% - 160px);padding-left: 10px">{{ item.bs_desc }}</div>
<div style="width: calc(100% - 160px);padding-left: 10px" v-html="item.bs_desc"></div>
</div>
</div>
<div class="skills">
Expand All @@ -168,7 +168,7 @@
</div>
<div v-if="skillItem(item).duration > 0">持续 {{ skillItem(item).duration }} 秒</div>
</div>
<div class="skill-desc" v-html="colorSpan(skillItem(item).description)"></div>
<div class="skill-desc" v-html="skillItem(item).description"></div>
</div>
<div class="skill-range">
<div v-html="range(skillItem(item).range)"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/arknights/operatorArchives/template/operatorModule.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ body {
.option {
padding-left: 20px;
color: #202020;
font-size: 0;
/* font-size: 0; */
}

.talent {
Expand Down
6 changes: 3 additions & 3 deletions src/arknights/operatorArchives/template/operatorModule.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
<template v-for="part in stage.parts">
<template v-for="item in part.overrideTraitDataBundle.candidates || []">
<div class="option" v-if="item.additionalDescription"
v-html="colorSpan(item.additionalDescription)"></div>
v-html="item.additionalDescription"></div>
<div class="option" v-if="item.overrideDescripton"
v-html="colorSpan(item.overrideDescripton)"></div>
v-html="item.overrideDescripton"></div>
</template>
</template>
</div>
Expand All @@ -73,7 +73,7 @@
v-if="item.name">
<div class="option">
<div class="sub-title h4"><span>{{ name }}</span></div>
<span v-html="colorSpan(item.upgradeDescription)"></span>
<span v-html="item.upgradeDescription"></span>
</div>
</template>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/arknights/operatorArchives/template/operatorToken.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</div>
</div>
</div>
<div v-html="colorSpan(maxSkill(skill).description)"></div>
<div v-html="maxSkill(skill).description"></div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/arknights/operatorArchives/template/skillsDetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
:style="{backgroundImage: 'url(..//level/master' + (skill.skill_level - 7) + '.png)'}"></div>
<span v-else>{{ skill.skill_level }}</span>
</td>
<td v-html="colorSpan(skill.description)"></td>
<td v-html="skill.description"></td>
<td style="text-align: center">{{ skill.sp_init }}/{{ skill.sp_cost }}</td>
<td style="text-align: center">{{ skill.duration > 0 ? skill.duration : '无' }}</td>
<td>
Expand Down