修复插件的金额格式化

This commit is contained in:
John Smith 2024-03-11 22:44:09 +08:00
parent 67a935866c
commit 87ec69a08d
3 changed files with 18 additions and 6 deletions

View File

@ -112,11 +112,14 @@ class RoomFrame(designer.ui_base.RoomFrameBase):
#
def _on_super_chats_change(self, room: listener.Room, value: List[listener.SuperChatRecord], index, is_new): # noqa
if room.room_key != self._room_key:
return
super_chat = value[index]
col_texts = [
self._format_time(super_chat.time),
super_chat.author_name,
str(super_chat.price),
f'{super_chat.price:.1f}',
super_chat.content,
]
self._update_list_ctrl(self.super_chat_list, index, is_new, col_texts)
@ -155,19 +158,25 @@ class RoomFrame(designer.ui_base.RoomFrameBase):
list_ctrl.Focus(last_row_index)
def _on_gifts_change(self, room: listener.Room, value: List[listener.GiftRecord], index, is_new): # noqa
if room.room_key != self._room_key:
return
gift = value[index]
col_texts = [
self._format_time(gift.time),
gift.author_name,
gift.gift_name,
str(gift.num),
str(gift.price),
f'{gift.price:.1f}',
]
self._update_list_ctrl(self.gift_list, index, is_new, col_texts)
def _on_uid_paid_user_dict_change(
self, room: listener.Room, value: Dict[str, listener.PaidUserRecord], index, is_new # noqa
):
if room.room_key != self._room_key:
return
item_data = self._uid_to_paid_user_item_data.get(index, None)
if item_data is None:
item_data = self._uid_to_paid_user_item_data[index] = self._next_paid_user_item_data
@ -176,10 +185,13 @@ class RoomFrame(designer.ui_base.RoomFrameBase):
paid_user = value[index]
col_texts = [
paid_user.name,
str(paid_user.price),
f'{paid_user.price:.1f}',
]
self._update_list_ctrl(self.paid_user_list, item_data, is_new, col_texts)
def _on_simple_statistics_change(self, room: listener.Room, value=None, index=None, is_new=None): # noqa
text = f'总弹幕数:{room.danmaku_num} 互动用户数:{len(room.interact_uids)} 总付费:{room.total_paid_price}'
if room.room_key != self._room_key:
return
text = f'总弹幕数:{room.danmaku_num} 互动用户数:{len(room.interact_uids)} 总付费:{room.total_paid_price:.1f}'
self.statistics_text.SetLabelText(text)

View File

@ -59,7 +59,7 @@ class AppConfig:
self.template_text = '{author_name} 说:{content}'
# self.template_free_gift = '{author_name} 赠送了{num}个{gift_name},总价{total_coin}银瓜子'
self.template_free_gift = '{author_name} 赠送了{num}{gift_name}'
self.template_paid_gift = '{author_name} 赠送了{num}{gift_name},总价{price}'
self.template_paid_gift = '{author_name} 赠送了{num}{gift_name},总价{price:.1f}'
self.template_member = '{author_name} 购买了{num}{unit} {guard_name}'
self.template_super_chat = '{author_name} 发送了{price}元的醒目留言:{content}'

View File

@ -18,7 +18,7 @@ template_text = {author_name} 说:{content}
# template_free_gift = {author_name} 赠送了{num}个{gift_name},总价{total_coin}银瓜子
template_free_gift = {author_name} 赠送了{num}个{gift_name}
# 付费礼物
template_paid_gift = {author_name} 赠送了{num}个{gift_name},总价{price}元
template_paid_gift = {author_name} 赠送了{num}个{gift_name},总价{price:.1f}元
# 上舰
template_member = {author_name} 购买了{num}{unit} {guard_name}
# 醒目留言