From 87ec69a08d069b52340de58bde7b52998a3e4ea1 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 11 Mar 2024 22:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/native-ui/ui/room_frame.py | 20 +++++++++++++++---- plugins/text-to-speech/config.py | 2 +- .../text-to-speech/data/config.example.ini | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/native-ui/ui/room_frame.py b/plugins/native-ui/ui/room_frame.py index 64ae758..aee8c2c 100644 --- a/plugins/native-ui/ui/room_frame.py +++ b/plugins/native-ui/ui/room_frame.py @@ -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) diff --git a/plugins/text-to-speech/config.py b/plugins/text-to-speech/config.py index 287f498..16d0d2b 100644 --- a/plugins/text-to-speech/config.py +++ b/plugins/text-to-speech/config.py @@ -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}' diff --git a/plugins/text-to-speech/data/config.example.ini b/plugins/text-to-speech/data/config.example.ini index dc66f22..46f2501 100644 --- a/plugins/text-to-speech/data/config.example.ini +++ b/plugins/text-to-speech/data/config.example.ini @@ -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} # 醒目留言