🚨修复更多的错误
@ -12,6 +12,7 @@ from gsuid_core.utils.image.convert import convert_img
|
||||
from gsuid_core.utils.image.image_tools import draw_text_by_line
|
||||
|
||||
from .mono.Character import Character
|
||||
from ..utils.fonts.first_world import fw_font_120
|
||||
from ..utils.map.SR_MAP_PATH import RelicId2Rarity
|
||||
from ..utils.excel.read_excel import light_cone_ranks
|
||||
from ..utils.map.name_covert import name_to_avatar_id, alias_to_char_name
|
||||
@ -292,7 +293,6 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
char_info.paste(attr_bg, (517, 265), attr_bg)
|
||||
|
||||
# 命座
|
||||
lock_img = Image.open(TEXT_PATH / 'icon_lock.png').resize((50, 50))
|
||||
for rank in range(0, 6):
|
||||
rank_bg = Image.open(TEXT_PATH / 'mz_bg.png')
|
||||
if rank < char.char_rank:
|
||||
@ -302,18 +302,23 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
rank_bg.paste(rank_img, (19, 19), rank_img)
|
||||
char_info.paste(rank_bg, (20 + rank * 80, 630), rank_bg)
|
||||
else:
|
||||
rank_img = Image.open(
|
||||
SKILL_PATH / f'{char.char_id}{RANK_MAP[rank + 1]}'
|
||||
).resize((50, 50))
|
||||
rank_img = (
|
||||
Image.open(SKILL_PATH / f'{char.char_id}{RANK_MAP[rank + 1]}')
|
||||
.resize((50, 50))
|
||||
.convert("RGBA")
|
||||
)
|
||||
alpha = rank_img.getchannel('A')
|
||||
alpha = alpha.point(lambda i: i // 2)
|
||||
rank_img.putalpha(alpha)
|
||||
rank_bg.paste(rank_img, (19, 19), rank_img)
|
||||
rank_bg.paste(lock_img, (19, 19), lock_img)
|
||||
# rank_bg.paste(lock_img, (19, 19), lock_img)
|
||||
char_info.paste(rank_bg, (20 + rank * 80, 630), rank_bg)
|
||||
|
||||
# 技能
|
||||
skill_bg = Image.open(TEXT_PATH / 'skill_bg.png')
|
||||
i = 0
|
||||
for skill in char.char_skill:
|
||||
skill_attr_img = Image.open(TEXT_PATH / 'skill_attr4.png')
|
||||
skill_attr_img = Image.open(TEXT_PATH / f'skill_attr{i + 1}.png')
|
||||
skill_panel_img = Image.open(TEXT_PATH / 'skill_panel.png')
|
||||
skill_img = Image.open(
|
||||
SKILL_PATH / f'{char.char_id}_'
|
||||
@ -348,6 +353,7 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
char_info.paste(skill_bg, (0, 710), skill_bg)
|
||||
|
||||
# 武器
|
||||
if char.equipment != {}:
|
||||
weapon_bg = Image.open(TEXT_PATH / 'weapon_bg.png')
|
||||
weapon_id = char.equipment['equipmentID']
|
||||
weapon_img = Image.open(WEAPON_PATH / f'{weapon_id}.png').resize(
|
||||
@ -370,7 +376,8 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
'mm',
|
||||
)
|
||||
rarity_img = Image.open(
|
||||
TEXT_PATH / f'LightCore_Rarity{char.equipment["equipmentRarity"]}.png'
|
||||
TEXT_PATH
|
||||
/ f'LightCore_Rarity{char.equipment["equipmentRarity"]}.png'
|
||||
).resize((306, 72))
|
||||
weapon_bg.paste(rarity_img, (160, 55), rarity_img)
|
||||
weapon_bg_draw.text(
|
||||
@ -391,10 +398,21 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
desc = desc.replace(f'#{i + 1}[i]%', f'{str(temp)}%')
|
||||
for i in range(0, len(desc_params)):
|
||||
desc = desc.replace(f'#{i + 1}[i]', str(desc_params[i]))
|
||||
draw_text_by_line(weapon_bg, (220, 115), desc, sr_font_24, '#F9F9F9', 372)
|
||||
draw_text_by_line(
|
||||
weapon_bg, (220, 115), desc, sr_font_24, '#F9F9F9', 372
|
||||
)
|
||||
char_info.paste(weapon_bg, (22, 870), weapon_bg)
|
||||
else:
|
||||
char_img_draw.text(
|
||||
(525, 1005),
|
||||
'No light cone!',
|
||||
white_color,
|
||||
fw_font_120,
|
||||
'mm',
|
||||
)
|
||||
|
||||
# 遗器
|
||||
if char.char_relic:
|
||||
weapon_rank_bg = Image.open(TEXT_PATH / 'rank_bg.png')
|
||||
char_info.paste(weapon_rank_bg, (690, 880), weapon_rank_bg)
|
||||
|
||||
@ -411,10 +429,12 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
relic_piece_new_img = relic_piece_img.resize(
|
||||
(105, 105), Image.Resampling.LANCZOS
|
||||
).convert("RGBA")
|
||||
relic_img.paste(relic_piece_new_img, (200, 90), relic_piece_new_img)
|
||||
relic_img.paste(
|
||||
relic_piece_new_img, (200, 90), relic_piece_new_img
|
||||
)
|
||||
rarity_img = Image.open(
|
||||
TEXT_PATH
|
||||
/ f'LightCore_Rarity{RelicId2Rarity[str(relic["relicId"])]}.png'
|
||||
TEXT_PATH / f'LightCore_Rarity'
|
||||
f'{RelicId2Rarity[str(relic["relicId"])]}.png'
|
||||
).resize((200, 48))
|
||||
relic_img.paste(rarity_img, (-10, 80), rarity_img)
|
||||
relic_img_draw = ImageDraw.Draw(relic_img)
|
||||
@ -495,10 +515,20 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
|
||||
anchor='rm',
|
||||
)
|
||||
|
||||
char_info.paste(relic_img, RELIC_POS[str(relic["Type"])], relic_img)
|
||||
char_info.paste(
|
||||
relic_img, RELIC_POS[str(relic["Type"])], relic_img
|
||||
)
|
||||
else:
|
||||
char_img_draw.text(
|
||||
(525, 1565),
|
||||
'No relic!',
|
||||
white_color,
|
||||
fw_font_120,
|
||||
'mm',
|
||||
)
|
||||
|
||||
# 发送图片
|
||||
# char_info.show()
|
||||
char_info.show()
|
||||
res = await convert_img(char_info)
|
||||
logger.info('[sr面板]绘图已完成,等待发送!')
|
||||
return res
|
||||
|
@ -37,6 +37,9 @@ class Character:
|
||||
self.seq_str: str = '无匹配'
|
||||
|
||||
async def get_equipment_info(self):
|
||||
if self.equipment == {}:
|
||||
return
|
||||
else:
|
||||
base_attr = self.base_attributes
|
||||
equip = self.equipment
|
||||
ability_property = EquipmentID2AbilityProperty[
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 907 B |
BIN
StarRailUID/starrailuid_charinfo/texture2D/skill_attr5.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
StarRailUID/utils/fonts/FirstWorld.ttf
Normal file
13
StarRailUID/utils/fonts/first_world.py
Normal file
@ -0,0 +1,13 @@
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import ImageFont
|
||||
|
||||
FONT_ORIGIN_PATH = Path(__file__).parent / 'FirstWorld.ttf'
|
||||
|
||||
|
||||
def first_word_origin(size: int) -> ImageFont.FreeTypeFont:
|
||||
return ImageFont.truetype(str(FONT_ORIGIN_PATH), size=size)
|
||||
|
||||
|
||||
fw_font_12 = first_word_origin(12)
|
||||
fw_font_120 = first_word_origin(34)
|