From f34abbe184f1914574dd87842ba66b4cab570e62 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:31:34 +0900 Subject: [PATCH] =?UTF-8?q?[Update/Refactor]=20Add=20Message=20Formats=20F?= =?UTF-8?q?eatures=20more.=20UI=E3=81=A8=E3=81=97=E3=81=A6=E3=81=AE?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E9=A0=85=E7=9B=AE=E8=BF=BD=E5=8A=A0=E3=81=A8?= =?UTF-8?q?=E3=80=81config.json=E3=81=B8=E3=81=AE=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E3=81=BE=E3=81=A7=E3=80=82=20=E9=80=81?= =?UTF-8?q?=E4=BF=A1=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=A8?= =?UTF-8?q?=E3=80=81=E5=8F=97=E4=BF=A1=E3=81=97=E3=81=9F=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E9=80=81=E4=BF=A1=E3=81=99?= =?UTF-8?q?=E3=82=8B=E9=9A=9B=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E9=A0=85=E7=9B=AE=E8=BF=BD=E5=8A=A0=E3=80=82?= =?UTF-8?q?=E3=81=BE=E3=81=9F=E3=80=81=E7=BF=BB=E8=A8=B3=E4=BB=98=E3=81=8D?= =?UTF-8?q?=E3=81=A8=E3=81=9D=E3=81=86=E3=81=98=E3=82=83=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E9=A0=85=E7=9B=AE=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82=20=E3=81=9D=E3=82=8C=E3=81=AB=E4=BC=B4=E3=81=84?= =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E3=81=AA=E3=81=A9=E3=80=82=20=E2=80=BBconfig.json?= =?UTF-8?q?=E3=81=AEMESSAGE=5FFORMAT=E9=A0=85=E7=9B=AE=E3=81=AF=E6=B6=88?= =?UTF-8?q?=E3=81=88=E3=81=BE=E3=81=99=E3=80=82=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E5=85=83=E3=80=85=E8=A8=AD=E5=AE=9A=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AF?= =?UTF-8?q?=E4=BB=8A=E3=81=AE=E3=81=A8=E3=81=93=E3=82=8D=E5=BC=95=E3=81=8D?= =?UTF-8?q?=E7=B6=99=E3=81=92=E3=81=AA=E3=81=84=E7=8A=B6=E6=85=8B=E3=81=A7?= =?UTF-8?q?=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 67 ++-- controller.py | 56 +++- locales/en.yml | 37 ++- locales/ja.yml | 32 +- locales/ko.yml | 2 +- view.py | 290 ++++++++++++------ .../createSideMenuAndSettingsBoxContainers.py | 4 +- .../_SettingBoxGenerator.py | 115 ++++++- .../setting_box_others/__init__.py | 2 + .../createSettingBox_Others.py | 35 +-- .../createSettingBox_Others_Additional.py | 34 -- ...ettingBox_Others_ReceivedMessageFormats.py | 65 ++++ ...ateSettingBox_Others_SendMessageFormats.py | 66 ++++ 13 files changed, 584 insertions(+), 221 deletions(-) create mode 100644 vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_ReceivedMessageFormats.py create mode 100644 vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_SendMessageFormats.py diff --git a/config.py b/config.py index 83de5f21..4477be25 100644 --- a/config.py +++ b/config.py @@ -447,19 +447,6 @@ class Config: self._AUTH_KEYS[key] = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.AUTH_KEYS) - @property - @json_serializable('MESSAGE_FORMAT') - def MESSAGE_FORMAT(self): - return self._MESSAGE_FORMAT - - @MESSAGE_FORMAT.setter - def MESSAGE_FORMAT(self, value): - if isinstance(value, str): - if isUniqueStrings(["[message]", "[translation]"], value) is False: - value = "[message]([translation])" - self._MESSAGE_FORMAT = value - saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property @json_serializable('ENABLE_AUTO_CLEAR_MESSAGE_BOX') def ENABLE_AUTO_CLEAR_MESSAGE_BOX(self): @@ -505,7 +492,32 @@ class Config: # self._STARTUP_OSC_ENABLED_CHECK = value # saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - # Speaker2Chatbox------------------ + @property + @json_serializable('SEND_MESSAGE_FORMAT') + def SEND_MESSAGE_FORMAT(self): + return self._SEND_MESSAGE_FORMAT + + @SEND_MESSAGE_FORMAT.setter + def SEND_MESSAGE_FORMAT(self, value): + if isinstance(value, str): + if isUniqueStrings(["[message]"], value) is False: + value = "[message]" + self._SEND_MESSAGE_FORMAT = value + saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + + @property + @json_serializable('SEND_MESSAGE_FORMAT_WITH_T') + def SEND_MESSAGE_FORMAT_WITH_T(self): + return self._SEND_MESSAGE_FORMAT_WITH_T + + @SEND_MESSAGE_FORMAT_WITH_T.setter + def SEND_MESSAGE_FORMAT_WITH_T(self, value): + if isinstance(value, str): + if isUniqueStrings(["[message]", "[translation]"], value) is False: + value = "[message]([translation])" + self._SEND_MESSAGE_FORMAT_WITH_T = value + saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + @property @json_serializable('RECEIVED_MESSAGE_FORMAT') def RECEIVED_MESSAGE_FORMAT(self): @@ -514,11 +526,27 @@ class Config: @RECEIVED_MESSAGE_FORMAT.setter def RECEIVED_MESSAGE_FORMAT(self, value): if isinstance(value, str): - if isUniqueStrings(["[message]", "[translation]"], value) is False: - value = "[message]([translation])" + if isUniqueStrings(["[message]"], value) is False: + value = "[message]" self._RECEIVED_MESSAGE_FORMAT = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + @property + @json_serializable('RECEIVED_MESSAGE_FORMAT_WITH_T') + def RECEIVED_MESSAGE_FORMAT_WITH_T(self): + return self._RECEIVED_MESSAGE_FORMAT_WITH_T + + @RECEIVED_MESSAGE_FORMAT_WITH_T.setter + def RECEIVED_MESSAGE_FORMAT_WITH_T(self, value): + if isinstance(value, str): + if isUniqueStrings(["[message]", "[translation]"], value) is False: + value = "[message]([translation])" + self._RECEIVED_MESSAGE_FORMAT_WITH_T = value + saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + + + + # Speaker2Chatbox------------------ @property @json_serializable('ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC') def ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC(self): @@ -529,7 +557,6 @@ class Config: if isinstance(value, bool): self._ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - # Speaker2Chatbox------------------ @@ -623,8 +650,10 @@ class Config: "Bing": None, "Google": None, } - self._MESSAGE_FORMAT = "[message]([translation])" - self._RECEIVED_MESSAGE_FORMAT = "[message]([translation])" # speaker2Chatbox + self._SEND_MESSAGE_FORMAT = "[message]" + self._SEND_MESSAGE_FORMAT_WITH_T = "[message]([translation])" + self._RECEIVED_MESSAGE_FORMAT = "[message]" + self._RECEIVED_MESSAGE_FORMAT_WITH_T = "[message]([translation])" self._ENABLE_AUTO_CLEAR_MESSAGE_BOX = True self._ENABLE_NOTICE_XSOVERLAY = False self._ENABLE_SEND_MESSAGE_TO_VRC = True diff --git a/controller.py b/controller.py index 448442bd..ef61dccb 100644 --- a/controller.py +++ b/controller.py @@ -42,7 +42,7 @@ def sendMicMessage(message): if config.ENABLE_TRANSCRIPTION_SEND is True: if config.ENABLE_SEND_MESSAGE_TO_VRC is True: if len(translation) > 0: - osc_message = config.MESSAGE_FORMAT.replace("[message]", message) + osc_message = config.SEND_MESSAGE_FORMAT_WITH_T.replace("[message]", message) osc_message = osc_message.replace("[translation]", translation) else: osc_message = message @@ -116,7 +116,7 @@ def receiveSpeakerMessage(message): # send OSC message if config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC is True: if len(translation) > 0: - osc_message = config.RECEIVED_MESSAGE_FORMAT.replace("[message]", message) + osc_message = config.RECEIVED_MESSAGE_FORMAT_WITH_T.replace("[message]", message) osc_message = osc_message.replace("[translation]", translation) else: osc_message = message @@ -662,16 +662,26 @@ def callbackSetEnableAutoExportMessageLogs(value): else: model.stopLogger() -def callbackSetMessageFormat(value): - print("callbackSetMessageFormat", value) +def callbackSetSendMessageFormat(value): + print("callbackSetSendMessageFormat", value) + if isUniqueStrings(["[message]"], value) is True: + config.SEND_MESSAGE_FORMAT = value + view.clearErrorMessage() + view.setSendMessageFormat_EntryWidgets(config.SEND_MESSAGE_FORMAT) + else: + view.showErrorMessage_SendMessageFormat() + view.setSendMessageFormat_EntryWidgets(config.SEND_MESSAGE_FORMAT) + +def callbackSetSendMessageFormatWithT(value): + print("callbackSetSendMessageFormatWithT", value) if len(value) > 0: if isUniqueStrings(["[message]", "[translation]"], value) is True: - config.MESSAGE_FORMAT = value + config.SEND_MESSAGE_FORMAT_WITH_T = value view.clearErrorMessage() - view.setMessageFormatEntryWidgets(config.MESSAGE_FORMAT) + view.setSendMessageFormatWithT_EntryWidgets(config.SEND_MESSAGE_FORMAT_WITH_T) else: - view.showErrorMessage_MessageFormat() - view.setMessageFormatEntryWidgets(config.MESSAGE_FORMAT) + view.showErrorMessage_SendMessageFormatWithT() + view.setSendMessageFormatWithT_EntryWidgets(config.SEND_MESSAGE_FORMAT_WITH_T) def callbackSetEnableSendMessageToVrc(value): @@ -683,18 +693,31 @@ def callbackSetEnableSendMessageToVrc(value): # print("callbackSetStartupOscEnabledCheck", value) # config.STARTUP_OSC_ENABLED_CHECK = value -# ---------------------Speaker2Chatbox--------------------- + def callbackSetReceivedMessageFormat(value): print("callbackSetReceivedMessageFormat", value) + if isUniqueStrings(["[message]"], value) is True: + config.RECEIVED_MESSAGE_FORMAT = value + view.clearErrorMessage() + view.setReceivedMessageFormat_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + else: + view.showErrorMessage_ReceivedMessageFormat() + view.setReceivedMessageFormat_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + + +def callbackSetReceivedMessageFormatWithT(value): + print("callbackSetReceivedMessageFormatWithT", value) if len(value) > 0: if isUniqueStrings(["[message]", "[translation]"], value) is True: - config.RECEIVED_MESSAGE_FORMAT = value + config.RECEIVED_MESSAGE_FORMAT_WITH_T = value view.clearErrorMessage() - view.setReceivedMessageFormatEntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + view.setReceivedMessageFormatWithT_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT_WITH_T) else: - view.showErrorMessage_ReceivedMessageFormat() - view.setReceivedMessageFormatEntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + view.showErrorMessage_ReceivedMessageFormatWithT() + view.setReceivedMessageFormatWithT_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT_WITH_T) + +# ---------------------Speaker2Chatbox--------------------- def callbackSetEnableSendReceivedMessageToVrc(value): print("callbackSetEnableSendReceivedMessageToVrc", value) config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = value @@ -834,11 +857,14 @@ def createMainWindow(): "callback_set_enable_auto_clear_chatbox": callbackSetEnableAutoClearMessageBox, "callback_set_enable_notice_xsoverlay": callbackSetEnableNoticeXsoverlay, "callback_set_enable_auto_export_message_logs": callbackSetEnableAutoExportMessageLogs, - "callback_set_message_format": callbackSetMessageFormat, "callback_set_enable_send_message_to_vrc": callbackSetEnableSendMessageToVrc, # "callback_set_startup_osc_enabled_check": callbackSetStartupOscEnabledCheck, # [deprecated] - # Speaker2Chatbox---------------- + "callback_set_send_message_format": callbackSetSendMessageFormat, + "callback_set_send_message_format_with_t": callbackSetSendMessageFormatWithT, "callback_set_received_message_format": callbackSetReceivedMessageFormat, + "callback_set_received_message_format_with_t": callbackSetReceivedMessageFormatWithT, + + # Speaker2Chatbox---------------- "callback_set_enable_send_received_message_to_vrc": callbackSetEnableSendReceivedMessageToVrc, # Speaker2Chatbox---------------- diff --git a/locales/en.yml b/locales/en.yml index 275c7510..a4b79641 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -82,6 +82,8 @@ config_window: transcription_mic: Mic transcription_speaker: Speaker others: Others + others_send_message_formats: Message Formats(Send) + others_received_message_formats: Message Formats(Received) others_speaker2chatbox: Speaker2Chatbox advanced_settings: Advanced Settings @@ -180,25 +182,40 @@ config_window: label: Auto Export Message Logs desc: Automatically export the conversation messages as a text file. - message_format: - label: Message Format - desc: "You can change the decoration of the message you want to send.\n[message] will be replaced with the message, and [translation] will be replaced with the translated message.\nIt will be used in Notification XSOverlay too." - example_text: This is an example sentence. Fonts, line breaks, etc. may differ from the actual display. - error_message: "The characters '[message]' and '[translation]' cannot be used." - send_message_to_vrc: label: Send Message To VRChat desc: There is a way to use it without sending messages to VRChat, but it is not supported. Enable this feature when you intend to send a message to VRChat. - # Speaker2Chatbox - received_message_format: - label: Message Format (Speaker2Chatbox) + + send_message_format: + label: Message Format + desc: "You can change the decoration of the message you want to send.\n[message] will be replaced with the message." + example_text: This is an example sentence. Fonts, line breaks, etc. may differ from the actual display. + error_message: "The characters '[message]' cannot be used." + + send_message_format_with_t: + label: Message Format(With translation) + desc: "You can change the decoration of the message you want to send.\n[message] will be replaced with the message, and [translation] will be replaced with the translated message." example_text: This is an example sentence. Fonts, line breaks, etc. may differ from the actual display. error_message: "The characters '[message]' and '[translation]' cannot be used." + received_message_format: + label: Message Format + desc: "You can change the decoration of the received message you want to send.\n[message] will be replaced with the message.\nIt will be used in Notification XSOverlay too." + example_text: This is an example sentence. Fonts, line breaks, etc. may differ from the actual display. + error_message: "The characters '[message]' cannot be used." + + received_message_format_with_t: + label: Message Format(With translation) + desc: It will be used in Notification XSOverlay too. + example_text: This is an example sentence. Fonts, line breaks, etc. may differ from the actual display. + error_message: "The characters '[message]' and '[translation]' cannot be used." + + # Speaker2Chatbox send_received_message_to_vrc: label: Send Received Message To VRChat - # Speaker2Chatbox + # Speaker2Chatbox + osc_ip_address: label: OSC IP Address diff --git a/locales/ja.yml b/locales/ja.yml index 516f46d5..3b56cbcf 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -178,16 +178,36 @@ config_window: label: 会話ログを自動的に保存する desc: テキストファイルとしてログがlogsフォルダ内に保存されます。 - message_format: - label: 送信するメッセージのフォーマット - desc: "VRChatで相手に実際に見えるフォーマットを変更できます。\n[message]がメッセージに置換され、[translation]が翻訳されたメッセージに置換されます。\n※XSOverlayでの通知受け取り機能でも使われます。" - example_text: これは例文です。フォントや改行箇所など、実際の表示とは異なる場合があります。 - error_message: "[message]と[translation]という文字は使えません。" - send_message_to_vrc: label: VRChatにメッセージを送信する desc: "サポート対象外ですが、VRChatにメッセージを送信せずに使う方法があります。送信したい場合、この機能を有効にする事を忘れないでください。" + + send_message_format: + label: 送信するメッセージのフォーマット + desc: "VRChatで相手に実際に見えるフォーマットを変更できます。\n[message]がメッセージに置換されます。" + example_text: これは例文です。フォントや改行箇所など、実際の表示とは異なる場合があります。 + error_message: "[message]という文字は使えません。" + + send_message_format_with_t: + label: 送信するメッセージのフォーマット(翻訳付き) + desc: "VRChatで相手に実際に見えるフォーマットを変更できます。\n[message]がメッセージに置換され、[translation]が翻訳されたメッセージに置換されます。" + example_text: これは例文です。フォントや改行箇所など、実際の表示とは異なる場合があります。 + error_message: "[message]と[translation]という文字は使えません。" + + received_message_format: + label: 送信するメッセージのフォーマット + desc: "VRChatで相手に実際に見えるフォーマットを変更できます。\n[message]がメッセージに置換されます。\n※XSOverlayでの通知受け取り機能にも使われます。" + example_text: これは例文です。フォントや改行箇所など、実際の表示とは異なる場合があります。 + error_message: "[message]という文字は使えません。" + + received_message_format_with_t: + label: 送信するメッセージのフォーマット(翻訳付き) + desc: "VRChatで相手に実際に見えるフォーマットを変更できます。\n[message]がメッセージに置換され、[translation]が翻訳されたメッセージに置換されます。\n※XSOverlayでの通知受け取り機能にも使われます。" + example_text: これは例文です。フォントや改行箇所など、実際の表示とは異なる場合があります。 + error_message: "[message]と[translation]という文字は使えません。" + + osc_ip_address: label: OSC IP Address diff --git a/locales/ko.yml b/locales/ko.yml index 9f6566ee..4beda7f2 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -172,7 +172,7 @@ config_window: # label: Auto Export Message Logs # desc: Automatically export the conversation messages as a text file. - message_format: + send_message_format_with_t: label: 전송 형식 # desc: "You can change the decoration of the message you want to send.\n[message] will be replaced with the message, and [translation] will be replaced with the translated message.\nIt will be used in Notification XSOverlay too." example_text: 예문입니다. 글꼴, 줄 바꿈 등이 실제 표시와 다를 수 있습니다. diff --git a/view.py b/view.py index 315ee6c8..7b95a2f5 100644 --- a/view.py +++ b/view.py @@ -345,20 +345,6 @@ class View(): VAR_ENABLE_AUTO_EXPORT_MESSAGE_LOGS=BooleanVar(value=config.ENABLE_LOGGER), - VAR_LABEL_MESSAGE_FORMAT=StringVar(value=i18n.t("config_window.message_format.label")), - VAR_DESC_MESSAGE_FORMAT=StringVar(value=i18n.t("config_window.message_format.desc")), - CALLBACK_SET_MESSAGE_FORMAT=None, - CALLBACK_SWAP_MESSAGE_FORMAT_REQUIRED_TEXT=self._swapMessageFormatRequiredText, - VAR_MESSAGE_FORMAT=StringVar(value=config.MESSAGE_FORMAT), - VAR_LABEL_EXAMPLE_TEXT_MESSAGE_FORMAT=StringVar(value=""), - VAR_ENTRY_0_MESSAGE_FORMAT=StringVar(value=""), - VAR_ENTRY_1_MESSAGE_FORMAT=StringVar(value=""), - VAR_ENTRY_2_MESSAGE_FORMAT=StringVar(value=""), - VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT=StringVar(value="[message]"), - VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT=StringVar(value="[translation]"), - CALLBACK_FOCUS_OUT_MESSAGE_FORMAT=self.callbackBindFocusOut_MessageFormat, - - VAR_LABEL_ENABLE_SEND_MESSAGE_TO_VRC=StringVar(value=i18n.t("config_window.send_message_to_vrc.label")), VAR_DESC_ENABLE_SEND_MESSAGE_TO_VRC=StringVar(value=i18n.t("config_window.send_message_to_vrc.desc")), CALLBACK_SET_ENABLE_SEND_MESSAGE_TO_VRC=None, @@ -372,25 +358,65 @@ class View(): + VAR_SECOND_TITLE_OTHERS_SEND_MESSAGE_FORMATS=StringVar(value=i18n.t("config_window.side_menu_labels.others_send_message_formats")), + + + VAR_LABEL_SEND_MESSAGE_FORMAT=StringVar(value=i18n.t("config_window.send_message_format.label")), + VAR_DESC_SEND_MESSAGE_FORMAT=StringVar(value=i18n.t("config_window.send_message_format.desc")), + CALLBACK_SET_SEND_MESSAGE_FORMAT=None, + VAR_SEND_MESSAGE_FORMAT=StringVar(value=config.SEND_MESSAGE_FORMAT), + VAR_LABEL_EXAMPLE_TEXT_SEND_MESSAGE_FORMAT=StringVar(value=""), + VAR_ENTRY_0_SEND_MESSAGE_FORMAT=StringVar(value=""), + VAR_ENTRY_1_SEND_MESSAGE_FORMAT=StringVar(value=""), + VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT=StringVar(value="[message]"), + CALLBACK_FOCUS_OUT_SEND_MESSAGE_FORMAT=self.callbackBindFocusOut_SendMessageFormat, + + + VAR_LABEL_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=i18n.t("config_window.send_message_format_with_t.label")), + VAR_DESC_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=i18n.t("config_window.send_message_format_with_t.desc")), + CALLBACK_SET_SEND_MESSAGE_FORMAT_WITH_T=None, + CALLBACK_SWAP_SEND_MESSAGE_FORMAT_WITH_T_REQUIRED_TEXT=self._swapSendMessageFormatWithT_RequiredText, + VAR_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=config.SEND_MESSAGE_FORMAT_WITH_T), + VAR_LABEL_EXAMPLE_TEXT_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_ENTRY_0_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_ENTRY_1_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_ENTRY_2_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value="[message]"), + VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T=StringVar(value="[translation]"), + CALLBACK_FOCUS_OUT_SEND_MESSAGE_FORMAT_WITH_T=self.callbackBindFocusOut_SendMessageFormatWithT, - # -------------------Speaker2Chatbox----------- - VAR_SECOND_TITLE_OTHERS_SPEAKER2CHATBOX=StringVar(value=i18n.t("config_window.side_menu_labels.others_speaker2chatbox")), VAR_LABEL_RECEIVED_MESSAGE_FORMAT=StringVar(value=i18n.t("config_window.received_message_format.label")), VAR_DESC_RECEIVED_MESSAGE_FORMAT=StringVar(value=i18n.t("config_window.received_message_format.desc")), CALLBACK_SET_RECEIVED_MESSAGE_FORMAT=None, - CALLBACK_SWAP_RECEIVED_MESSAGE_FORMAT_REQUIRED_TEXT=self._swapReceivedMessageFormatRequiredText, VAR_RECEIVED_MESSAGE_FORMAT=StringVar(value=config.RECEIVED_MESSAGE_FORMAT), VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT=StringVar(value=""), VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT=StringVar(value=""), VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT=StringVar(value=""), - VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT=StringVar(value=""), VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT=StringVar(value="[message]"), - VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT=StringVar(value="[translation]"), CALLBACK_FOCUS_OUT_RECEIVED_MESSAGE_FORMAT=self.callbackBindFocusOut_ReceivedMessageFormat, + VAR_SECOND_TITLE_OTHERS_RECEIVED_MESSAGE_FORMATS=StringVar(value=i18n.t("config_window.side_menu_labels.others_received_message_formats")), + + VAR_LABEL_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=i18n.t("config_window.received_message_format_with_t.label")), + VAR_DESC_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=i18n.t("config_window.received_message_format_with_t.desc")), + CALLBACK_SET_RECEIVED_MESSAGE_FORMAT_WITH_T=None, + CALLBACK_SWAP_RECEIVED_MESSAGE_FORMAT_WITH_T_REQUIRED_TEXT=self._swapReceivedMessageFormatWithT_RequiredText, + VAR_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=config.RECEIVED_MESSAGE_FORMAT_WITH_T), + VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value=""), + VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value="[message]"), + VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T=StringVar(value="[translation]"), + CALLBACK_FOCUS_OUT_RECEIVED_MESSAGE_FORMAT_WITH_T=self.callbackBindFocusOut_ReceivedMessageFormatWithT, + + + # -------------------Speaker2Chatbox----------- + VAR_SECOND_TITLE_OTHERS_SPEAKER2CHATBOX=StringVar(value=i18n.t("config_window.side_menu_labels.others_speaker2chatbox")), + VAR_LABEL_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC=StringVar(value=i18n.t("config_window.send_received_message_to_vrc.label")), VAR_DESC_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC=StringVar(value=i18n.t("config_window.send_received_message_to_vrc.desc")), CALLBACK_SET_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC=None, @@ -522,15 +548,18 @@ class View(): self.view_variable.CALLBACK_SET_ENABLE_AUTO_CLEAR_MESSAGE_BOX = config_window_registers.get("callback_set_enable_auto_clear_chatbox", None) self.view_variable.CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY = config_window_registers.get("callback_set_enable_notice_xsoverlay", None) self.view_variable.CALLBACK_SET_ENABLE_AUTO_EXPORT_MESSAGE_LOGS = config_window_registers.get("callback_set_enable_auto_export_message_logs", None) - self.view_variable.CALLBACK_SET_MESSAGE_FORMAT = config_window_registers.get("callback_set_message_format", None) self.view_variable.CALLBACK_SET_ENABLE_SEND_MESSAGE_TO_VRC = config_window_registers.get("callback_set_enable_send_message_to_vrc", None) # self.view_variable.CALLBACK_SET_STARTUP_OSC_ENABLED_CHECK = config_window_registers.get("callback_set_startup_osc_enabled_check", None) #[deprecated] - + self.view_variable.CALLBACK_SET_SEND_MESSAGE_FORMAT = config_window_registers.get("callback_set_send_message_format", None) + self.view_variable.CALLBACK_SET_SEND_MESSAGE_FORMAT_WITH_T = config_window_registers.get("callback_set_send_message_format_with_t", None) self.view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT = config_window_registers.get("callback_set_received_message_format", None) + self.view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT_WITH_T = config_window_registers.get("callback_set_received_message_format_with_t", None) + # Speaker2Chatbox---------------- self.view_variable.CALLBACK_SET_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = config_window_registers.get("callback_set_enable_send_received_message_to_vrc", None) + # Speaker2Chatbox---------------- @@ -572,104 +601,134 @@ class View(): self.openSpeakerEnergyThresholdWidget() - self.setMessageFormatEntryWidgets(config.MESSAGE_FORMAT) - self.setReceivedMessageFormatEntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + self.setSendMessageFormat_EntryWidgets(config.SEND_MESSAGE_FORMAT) + self.setSendMessageFormatWithT_EntryWidgets(config.SEND_MESSAGE_FORMAT_WITH_T) + self.setReceivedMessageFormat_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + self.setReceivedMessageFormatWithT_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT_WITH_T) # Insert sample conversation for testing. # self._insertSampleConversationToTextbox() - - def setMessageFormatEntryWidgets(self, message_format:str): +# Send Message Format + def setSendMessageFormat_EntryWidgets(self, message_format:str): result = self.extractMessageFormat(message_format) + self.view_variable.VAR_ENTRY_0_SEND_MESSAGE_FORMAT.set(result.before) + self.view_variable.VAR_ENTRY_1_SEND_MESSAGE_FORMAT.set(result.after) + self.updateSendMessageFormat_ExampleTextWidget() + + def updateSendMessageFormat_ExampleTextWidget(self): + message = i18n.t("config_window.send_message_format.example_text") + example_message = config.SEND_MESSAGE_FORMAT.replace("[message]", message) + + self.view_variable.VAR_LABEL_EXAMPLE_TEXT_SEND_MESSAGE_FORMAT.set(example_message) + + +# Send Message Format With Translation + def setSendMessageFormatWithT_EntryWidgets(self, message_format:str): + result = self.extractMessageFormatWithT(message_format) + if result.is_message_first is True: - self.view_variable.VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT.set("[message]") - self.view_variable.VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT.set("[translation]") + self.view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T.set("[message]") + self.view_variable.VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T.set("[translation]") else: - self.view_variable.VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT.set("[translation]") - self.view_variable.VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT.set("[message]") + self.view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T.set("[translation]") + self.view_variable.VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T.set("[message]") - self.view_variable.VAR_ENTRY_0_MESSAGE_FORMAT.set(result.before) - self.view_variable.VAR_ENTRY_1_MESSAGE_FORMAT.set(result.between) - self.view_variable.VAR_ENTRY_2_MESSAGE_FORMAT.set(result.after) - self.updateMessageFormat_ExampleTextWidget() + self.view_variable.VAR_ENTRY_0_SEND_MESSAGE_FORMAT_WITH_T.set(result.before) + self.view_variable.VAR_ENTRY_1_SEND_MESSAGE_FORMAT_WITH_T.set(result.between) + self.view_variable.VAR_ENTRY_2_SEND_MESSAGE_FORMAT_WITH_T.set(result.after) + self.updateSendMessageFormatWithT_ExampleTextWidget() - def _swapMessageFormatRequiredText(self): - text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT.get() - text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT.get() - self.view_variable.VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT.set(text_1) - self.view_variable.VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT.set(text_0) - self.updateMessageFormat_ExampleTextWidget() + def _swapSendMessageFormatWithT_RequiredText(self): + text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T.get() + text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T.get() + self.view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T.set(text_1) + self.view_variable.VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T.set(text_0) + self.updateSendMessageFormatWithT_ExampleTextWidget() - new_message_format = self.getLatestMessageFormatFromWidget() - callFunctionIfCallable(self.view_variable.CALLBACK_SET_MESSAGE_FORMAT, new_message_format) + new_message_format = self.getLatestMessageFormatWithT_FromWidget() + callFunctionIfCallable(self.view_variable.CALLBACK_SET_SEND_MESSAGE_FORMAT_WITH_T, new_message_format) - def getLatestMessageFormatFromWidget(self): - text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT.get() - text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT.get() - entry_0 = self.view_variable.VAR_ENTRY_0_MESSAGE_FORMAT.get() - entry_1 = self.view_variable.VAR_ENTRY_1_MESSAGE_FORMAT.get() - entry_2 = self.view_variable.VAR_ENTRY_2_MESSAGE_FORMAT.get() + def getLatestMessageFormatWithT_FromWidget(self): + text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T.get() + text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T.get() + entry_0 = self.view_variable.VAR_ENTRY_0_SEND_MESSAGE_FORMAT_WITH_T.get() + entry_1 = self.view_variable.VAR_ENTRY_1_SEND_MESSAGE_FORMAT_WITH_T.get() + entry_2 = self.view_variable.VAR_ENTRY_2_SEND_MESSAGE_FORMAT_WITH_T.get() return entry_0+text_0+entry_1+text_1+entry_2 - def updateMessageFormat_ExampleTextWidget(self): - message = i18n.t("config_window.message_format.example_text", locale=config.UI_LANGUAGE) + def updateSendMessageFormatWithT_ExampleTextWidget(self): + message = i18n.t("config_window.send_message_format_with_t.example_text", locale=config.UI_LANGUAGE) translation_locale = "ja" if config.UI_LANGUAGE == "en" else "en" - translation = i18n.t("config_window.message_format.example_text", locale=translation_locale) + translation = i18n.t("config_window.send_message_format_with_t.example_text", locale=translation_locale) - example_message = config.MESSAGE_FORMAT.replace("[message]", message) + example_message = config.SEND_MESSAGE_FORMAT_WITH_T.replace("[message]", message) example_message = example_message.replace("[translation]", translation) - self.view_variable.VAR_LABEL_EXAMPLE_TEXT_MESSAGE_FORMAT.set(example_message) + self.view_variable.VAR_LABEL_EXAMPLE_TEXT_SEND_MESSAGE_FORMAT_WITH_T.set(example_message) - -# Speaker2Chatbox---------------------------- - def setReceivedMessageFormatEntryWidgets(self, message_format:str): +# Received Message Format + def setReceivedMessageFormat_EntryWidgets(self, message_format:str): result = self.extractMessageFormat(message_format) - if result.is_message_first is True: - self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT.set("[message]") - self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT.set("[translation]") - else: - self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT.set("[translation]") - self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT.set("[message]") - self.view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT.set(result.before) - self.view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT.set(result.between) - self.view_variable.VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT.set(result.after) + self.view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT.set(result.after) self.updateReceivedMessageFormat_ExampleTextWidget() - def _swapReceivedMessageFormatRequiredText(self): - text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT.get() - text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT.get() - self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT.set(text_1) - self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT.set(text_0) - self.updateReceivedMessageFormat_ExampleTextWidget() - - new_message_format = self.getLatestReceivedMessageFormatFromWidget() - callFunctionIfCallable(self.view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT, new_message_format) - - - def getLatestReceivedMessageFormatFromWidget(self): - text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT.get() - text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT.get() - entry_0 = self.view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT.get() - entry_1 = self.view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT.get() - entry_2 = self.view_variable.VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT.get() - return entry_0+text_0+entry_1+text_1+entry_2 - def updateReceivedMessageFormat_ExampleTextWidget(self): - message = i18n.t("config_window.message_format.example_text", locale=config.UI_LANGUAGE) - translation_locale = "ja" if config.UI_LANGUAGE == "en" else "en" - translation = i18n.t("config_window.message_format.example_text", locale=translation_locale) - + message = i18n.t("config_window.received_message_format.example_text") example_message = config.RECEIVED_MESSAGE_FORMAT.replace("[message]", message) - example_message = example_message.replace("[translation]", translation) self.view_variable.VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT.set(example_message) -# Speaker2Chatbox---------------------------- + + +# Received Message Format With Translation + def setReceivedMessageFormatWithT_EntryWidgets(self, message_format:str): + result = self.extractMessageFormatWithT(message_format) + + if result.is_message_first is True: + self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T.set("[message]") + self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T.set("[translation]") + else: + self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T.set("[translation]") + self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T.set("[message]") + + self.view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT_WITH_T.set(result.before) + self.view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT_WITH_T.set(result.between) + self.view_variable.VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT_WITH_T.set(result.after) + self.updateReceivedMessageFormatWithT_ExampleTextWidget() + + def _swapReceivedMessageFormatWithT_RequiredText(self): + text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T.set(text_1) + self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T.set(text_0) + self.updateReceivedMessageFormatWithT_ExampleTextWidget() + + new_message_format = self.getLatestReceivedMessageFormatWithT_FromWidget() + callFunctionIfCallable(self.view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT_WITH_T, new_message_format) + + + def getLatestReceivedMessageFormatWithT_FromWidget(self): + text_0 = self.view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + text_1 = self.view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + entry_0 = self.view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + entry_1 = self.view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + entry_2 = self.view_variable.VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT_WITH_T.get() + return entry_0+text_0+entry_1+text_1+entry_2 + + def updateReceivedMessageFormatWithT_ExampleTextWidget(self): + message = i18n.t("config_window.received_message_format_with_t.example_text", locale=config.UI_LANGUAGE) + translation_locale = "ja" if config.UI_LANGUAGE == "en" else "en" + translation = i18n.t("config_window.received_message_format_with_t.example_text", locale=translation_locale) + + example_message = config.RECEIVED_MESSAGE_FORMAT_WITH_T.replace("[message]", message) + example_message = example_message.replace("[translation]", translation) + + self.view_variable.VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT_WITH_T.set(example_message) @@ -1211,10 +1270,14 @@ class View(): case "SpeakerMaxPhrases": self.setGuiVariable_SpeakerMaxPhrases(config.INPUT_SPEAKER_MAX_PHRASES) - case "MessageFormat": - self.setMessageFormatEntryWidgets(config.MESSAGE_FORMAT) + case "SendMessageFormat": + self.setSendMessageFormat_EntryWidgets(config.SEND_MESSAGE_FORMAT) + case "SendMessageFormatWithT": + self.setSendMessageFormatWithT_EntryWidgets(config.SEND_MESSAGE_FORMAT_WITH_T) case "ReceivedMessageFormat": - self.setReceivedMessageFormatEntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + self.setReceivedMessageFormat_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT) + case "ReceivedMessageFormatWithT": + self.setReceivedMessageFormatWithT_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT_WITH_T) case _: raise ValueError(f"No matching case for target_name: {target_name}") @@ -1365,14 +1428,21 @@ class View(): self.clearErrorMessage() - def callbackBindFocusOut_MessageFormat(self, _e=None): - self.setLatestConfigVariable("MessageFormat") + def callbackBindFocusOut_SendMessageFormat(self, _e=None): + self.setLatestConfigVariable("SendMessageFormat") + self.clearErrorMessage() + + def callbackBindFocusOut_SendMessageFormatWithT(self, _e=None): + self.setLatestConfigVariable("SendMessageFormatWithT") self.clearErrorMessage() def callbackBindFocusOut_ReceivedMessageFormat(self, _e=None): self.setLatestConfigVariable("ReceivedMessageFormat") self.clearErrorMessage() + def callbackBindFocusOut_ReceivedMessageFormatWithT(self, _e=None): + self.setLatestConfigVariable("ReceivedMessageFormatWithT") + self.clearErrorMessage() @@ -1454,16 +1524,28 @@ class View(): ) - def showErrorMessage_MessageFormat(self): + def showErrorMessage_SendMessageFormat(self): self._showErrorMessage( - vrct_gui.config_window.sb__entry_message_format_2, - self._makeInvalidValueErrorMessage(i18n.t("config_window.message_format.error_message")) + vrct_gui.config_window.sb__entry_send_message_format_1, + self._makeInvalidValueErrorMessage(i18n.t("config_window.send_message_format.error_message")) + ) + + def showErrorMessage_SendMessageFormatWithT(self): + self._showErrorMessage( + vrct_gui.config_window.sb__entry_send_message_format_with_t_2, + self._makeInvalidValueErrorMessage(i18n.t("config_window.send_message_format_with_t.error_message")) ) def showErrorMessage_ReceivedMessageFormat(self): self._showErrorMessage( - vrct_gui.config_window.sb__entry_received_message_format_2, - self._makeInvalidValueErrorMessage(i18n.t("config_window.message_format.error_message")) + vrct_gui.config_window.sb__entry_received_message_format_1, + self._makeInvalidValueErrorMessage(i18n.t("config_window.received_message_format.error_message")) + ) + + def showErrorMessage_ReceivedMessageFormatWithT(self): + self._showErrorMessage( + vrct_gui.config_window.sb__entry_received_message_format_with_t_2, + self._makeInvalidValueErrorMessage(i18n.t("config_window.received_message_format_with_t.error_message")) ) @@ -1475,9 +1557,17 @@ class View(): self.view_variable.VAR_ERROR_MESSAGE.set(message) vrct_gui._showErrorMessage(target_widget=target_widget) - @staticmethod def extractMessageFormat(text): + split_result = text.split("[message]") + result_data = SimpleNamespace( + before = split_result[0], + after = split_result[1], + ) + return result_data + + @staticmethod + def extractMessageFormatWithT(text): import re message_index = text.find("[message]") translation_index = text.find("[translation]") diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py index 2e9bec44..232d98ca 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/createSideMenuAndSettingsBoxContainers.py @@ -8,7 +8,7 @@ from ._createSettingBoxContainer import _createSettingBoxContainer from .setting_box_containers.setting_box_appearance import createSettingBox_Appearance from .setting_box_containers.setting_box_transcription import createSettingBox_Mic, createSettingBox_Speaker -from .setting_box_containers.setting_box_others import createSettingBox_Others, createSettingBox_Others_Additional +from .setting_box_containers.setting_box_others import createSettingBox_Others, createSettingBox_Others_SendMessageFormats, createSettingBox_Others_ReceivedMessageFormats, createSettingBox_Others_Additional from .setting_box_containers.setting_box_advanced_settings import createSettingBox_AdvancedSettings from .setting_box_containers.setting_box_translation import createSettingBox_Translation @@ -106,6 +106,8 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl "setting_box_container_attr_name": "setting_box_container_others", "setting_boxes": [ { "var_section_title": None, "setting_box": createSettingBox_Others }, + { "var_section_title": view_variable.VAR_SECOND_TITLE_OTHERS_SEND_MESSAGE_FORMATS, "setting_box": createSettingBox_Others_SendMessageFormats }, + { "var_section_title": view_variable.VAR_SECOND_TITLE_OTHERS_RECEIVED_MESSAGE_FORMATS, "setting_box": createSettingBox_Others_ReceivedMessageFormats }, { "var_section_title": view_variable.VAR_SECOND_TITLE_OTHERS_SPEAKER2CHATBOX, "setting_box": createSettingBox_Others_Additional }, ] }, diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py index b20feb45..f73cb253 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py @@ -538,7 +538,7 @@ class _SettingBoxGenerator(): - def createSettingBoxMessageFormatEntries(self, + def createSettingBoxMessageFormatEntries_WithTranslation(self, base_entry_attr_name, entry_textvariable_0, entry_textvariable_1, @@ -736,6 +736,119 @@ class _SettingBoxGenerator(): + + def createSettingBoxMessageFormatEntries(self, + base_entry_attr_name, + entry_textvariable_0, + entry_textvariable_1, + textvariable_0, + example_label_textvariable, + entry_bind__Any_KeyRelease, + entry_bind__FocusOut=None, + ): + + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(base_entry_attr_name) + + + all_wrapper = CTkFrame(setting_box_item_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) + all_wrapper.grid(row=1, column=0, sticky="ew") + + all_wrapper.grid_columnconfigure(0, weight=1) + + + example_box_wrapper = CTkFrame(all_wrapper, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) + example_box_wrapper.grid(row=0, column=0, pady=self.settings.uism.SB__MESSAGE_FORMAT__ENTRIES_BOTTOM_PADY, sticky="ew") + + entries_wrapper = CTkFrame(all_wrapper, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) + entries_wrapper.grid(row=1, column=0, pady=self.settings.uism.SB__MESSAGE_FORMAT__ENTRIES_BOTTOM_PADY, sticky="ew") + + + + + example_box_wrapper.grid_columnconfigure((0,2), weight=1) + example_frame_widget = CTkFrame(example_box_wrapper, corner_radius=self.settings.uism.SB__MESSAGE_FORMAT__EXAMPLE_CORNER_RADIUS, fg_color=self.settings.ctm.SB__MESSAGE_FORMAT__EXAMPLE_BG_COLOR, width=0, height=0) + example_frame_widget.grid(row=0, column=1) + + example_frame_widget.grid_rowconfigure((0,2), weight=1) + example_frame_widget.grid_columnconfigure((0,2), weight=1) + example_label_widget = CTkLabel( + example_frame_widget, + textvariable=example_label_textvariable, + anchor="center", + justify="center", + wraplength=self.settings.uism.SB__MESSAGE_FORMAT__EXAMPLE_WRAP_LENGTH, + height=0, + font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__MESSAGE_FORMAT__REQUIRED_TEXT_FONT_SIZE, weight="normal"), + text_color=self.settings.ctm.SB__MESSAGE_FORMAT__EXAMPLE_TEXT_COLOR, + ) + example_label_widget.grid(row=1, column=1, padx=self.settings.uism.SB__MESSAGE_FORMAT__EXAMPLE_IPADXY, pady=self.settings.uism.SB__MESSAGE_FORMAT__EXAMPLE_IPADXY, sticky="ew") + + self.config_window.additional_widgets.append(example_box_wrapper) + + + + + entry_textvariables = [entry_textvariable_0, entry_textvariable_1] + for i in range(2): + entry_widget = CTkEntry( + entries_wrapper, + text_color=self.settings.ctm.SB__ENTRY_TEXT_COLOR, + fg_color=self.settings.ctm.SB__ENTRY_BG_COLOR, + border_color=self.settings.ctm.SB__ENTRY_BORDER_COLOR, + height=self.settings.uism.SB__MESSAGE_FORMAT__ENTRY_HEIGHT, + textvariable=entry_textvariables[i], + justify="center", + font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__ENTRY_FONT_SIZE, weight="normal"), + ) + setattr(self.config_window, base_entry_attr_name + "_" + str(i), entry_widget) + + + + if entry_bind__FocusOut is not None: + entry_widget.bind("", entry_bind__FocusOut, "+") + + + label_frame_widget_0 = CTkFrame(entries_wrapper, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) + + label_frame_widget_0.grid_rowconfigure((0,2), weight=1) + label_frame_widget_0.grid_columnconfigure(0, weight=1) + label_widget_0 = CTkLabel( + label_frame_widget_0, + textvariable=textvariable_0, + anchor="center", + height=0, + font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__MESSAGE_FORMAT__REQUIRED_TEXT_FONT_SIZE, weight="normal"), + text_color=self.settings.ctm.LABELS_TEXT_COLOR + ) + label_widget_0.grid(row=1, column=0, padx=0, pady=0, sticky="ew") + + + + + + entries_wrapper.grid_columnconfigure((0,2), weight=1) + entries_wrapper.grid_columnconfigure(1, weight=0) + + entry_widget_0 = getattr(self.config_window, base_entry_attr_name+"_0") + entry_widget_1 = getattr(self.config_window, base_entry_attr_name+"_1") + entry_widget_0.grid(row=0, column=0, sticky="ew") + entry_widget_1.grid(row=0, column=2, sticky="ew") + label_frame_widget_0.grid(row=0, column=1, padx=self.settings.uism.SB__MESSAGE_FORMAT__REQUIRED_TEXT_PADX, sticky="ew") + + def adjusted_command__for_entry_bind__Any_KeyRelease(_e): + message_format = entry_widget_0.get() + textvariable_0.get() + entry_widget_1.get() + entry_bind__Any_KeyRelease(message_format) + + + entry_widget_0.bind("", adjusted_command__for_entry_bind__Any_KeyRelease) + entry_widget_1.bind("", adjusted_command__for_entry_bind__Any_KeyRelease) + + + + return setting_box_frame + + + def createSettingBoxButtonWithImage( self, for_var_label_text, for_var_desc_text, diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/__init__.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/__init__.py index 98b0af6d..9b7e583c 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/__init__.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/__init__.py @@ -1,2 +1,4 @@ from .createSettingBox_Others import createSettingBox_Others +from .createSettingBox_Others_SendMessageFormats import createSettingBox_Others_SendMessageFormats +from .createSettingBox_Others_ReceivedMessageFormats import createSettingBox_Others_ReceivedMessageFormats from .createSettingBox_Others_Additional import createSettingBox_Others_Additional \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py index 1ef60c05..d129a05d 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others.py @@ -7,7 +7,7 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v createSettingBoxCheckbox = sbg.createSettingBoxCheckbox createSettingBoxAutoExportMessageLogs = sbg.createSettingBoxAutoExportMessageLogs createSettingBox_Labels = sbg.createSettingBox_Labels - createSettingBoxMessageFormatEntries = sbg.createSettingBoxMessageFormatEntries + createSettingBoxMessageFormatEntries_WithTranslation = sbg.createSettingBoxMessageFormatEntries_WithTranslation # 元 checkbox_auto_clear_chatbox_callback @@ -30,13 +30,6 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v # def checkbox_startup_osc_enabled_check_callback(checkbox_box_widget): # callFunctionIfCallable(view_variable.CALLBACK_SET_STARTUP_OSC_ENABLED_CHECK, checkbox_box_widget.get()) - def entry_message_format_callback(value): - callFunctionIfCallable(view_variable.CALLBACK_SET_MESSAGE_FORMAT, value) - - def entry_swap_message_format_callback(_e): - callFunctionIfCallable(view_variable.CALLBACK_SWAP_MESSAGE_FORMAT_REQUIRED_TEXT) - - row=0 config_window.sb__auto_clear_message_box = createSettingBoxCheckbox( for_var_label_text=view_variable.VAR_LABEL_ENABLE_AUTO_CLEAR_MESSAGE_BOX, @@ -72,32 +65,6 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v row+=1 - config_window.sb__message_format_labels = createSettingBox_Labels( - for_var_label_text=view_variable.VAR_LABEL_MESSAGE_FORMAT, - for_var_desc_text=view_variable.VAR_DESC_MESSAGE_FORMAT, - labels_attr_name="sb__labels_message_format", - ) - config_window.sb__message_format_labels.grid(row=row, pady=0) - row+=1 - - config_window.sb__message_format = createSettingBoxMessageFormatEntries( - base_entry_attr_name="sb__entry_message_format", - # entry_width=settings.uism.RESPONSIVE_UI_SIZE_INT_150, - entry_textvariable_0=view_variable.VAR_ENTRY_0_MESSAGE_FORMAT, - entry_textvariable_1=view_variable.VAR_ENTRY_1_MESSAGE_FORMAT, - entry_textvariable_2=view_variable.VAR_ENTRY_2_MESSAGE_FORMAT, - textvariable_0=view_variable.VAR_TEXT_REQUIRED_0_MESSAGE_FORMAT, - textvariable_1=view_variable.VAR_TEXT_REQUIRED_1_MESSAGE_FORMAT, - example_label_textvariable=view_variable.VAR_LABEL_EXAMPLE_TEXT_MESSAGE_FORMAT, - entry_bind__Any_KeyRelease=lambda value: entry_message_format_callback(value), - swap_button_command=entry_swap_message_format_callback, - # entry_textvariable=view_variable.VAR_MESSAGE_FORMAT, - entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_MESSAGE_FORMAT, - ) - config_window.sb__message_format.grid(row=row) - row+=1 - - config_window.sb__enable_send_message_to_vrc = createSettingBoxCheckbox( for_var_label_text=view_variable.VAR_LABEL_ENABLE_SEND_MESSAGE_TO_VRC, for_var_desc_text=view_variable.VAR_DESC_ENABLE_SEND_MESSAGE_TO_VRC, diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_Additional.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_Additional.py index c7ba864d..53551128 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_Additional.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_Additional.py @@ -5,46 +5,12 @@ from .._SettingBoxGenerator import _SettingBoxGenerator def createSettingBox_Others_Additional(setting_box_wrapper, config_window, settings, view_variable): sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable) createSettingBoxCheckbox = sbg.createSettingBoxCheckbox - createSettingBox_Labels = sbg.createSettingBox_Labels - createSettingBoxMessageFormatEntries = sbg.createSettingBoxMessageFormatEntries - def checkbox_enable_send_received_message_to_vrc_callback(checkbox_box_widget): callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC, checkbox_box_widget.get()) - def entry_received_message_format_callback(value): - callFunctionIfCallable(view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT, value) - - def entry_swap_received_message_format_callback(_e): - callFunctionIfCallable(view_variable.CALLBACK_SWAP_RECEIVED_MESSAGE_FORMAT_REQUIRED_TEXT) row=0 - config_window.sb__received_message_format_labels = createSettingBox_Labels( - for_var_label_text=view_variable.VAR_LABEL_RECEIVED_MESSAGE_FORMAT, - # for_var_desc_text=view_variable.VAR_DESC_RECEIVED_MESSAGE_FORMAT, - labels_attr_name="sb__labels_message_format", - ) - config_window.sb__received_message_format_labels.grid(row=row, pady=0) - row+=1 - - config_window.sb__received_message_format = createSettingBoxMessageFormatEntries( - base_entry_attr_name="sb__entry_received_message_format", - # entry_width=settings.uism.RESPONSIVE_UI_SIZE_INT_150, - entry_textvariable_0=view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT, - entry_textvariable_1=view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT, - entry_textvariable_2=view_variable.VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT, - textvariable_0=view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT, - textvariable_1=view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT, - example_label_textvariable=view_variable.VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT, - entry_bind__Any_KeyRelease=lambda value: entry_received_message_format_callback(value), - swap_button_command=entry_swap_received_message_format_callback, - # entry_textvariable=view_variable.VAR_RECEIVED_MESSAGE_FORMAT, - entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_RECEIVED_MESSAGE_FORMAT, - ) - config_window.sb__received_message_format.grid(row=row) - row+=1 - - config_window.sb__enable_send_received_message_to_vrc = createSettingBoxCheckbox( for_var_label_text=view_variable.VAR_LABEL_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC, # for_var_desc_text=view_variable.VAR_DESC_ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC, diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_ReceivedMessageFormats.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_ReceivedMessageFormats.py new file mode 100644 index 00000000..0d0bbca7 --- /dev/null +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_ReceivedMessageFormats.py @@ -0,0 +1,65 @@ +from utils import callFunctionIfCallable + +from .._SettingBoxGenerator import _SettingBoxGenerator + +def createSettingBox_Others_ReceivedMessageFormats(setting_box_wrapper, config_window, settings, view_variable): + sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable) + createSettingBox_Labels = sbg.createSettingBox_Labels + createSettingBoxMessageFormatEntries = sbg.createSettingBoxMessageFormatEntries + createSettingBoxMessageFormatEntries_WithTranslation = sbg.createSettingBoxMessageFormatEntries_WithTranslation + + def entry_received_message_format_callback(value): + callFunctionIfCallable(view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT, value) + + + def entry_received_message_format_with_t_callback(value): + callFunctionIfCallable(view_variable.CALLBACK_SET_RECEIVED_MESSAGE_FORMAT_WITH_T, value) + + def entry_swap_received_message_format_with_t_callback(_e): + callFunctionIfCallable(view_variable.CALLBACK_SWAP_RECEIVED_MESSAGE_FORMAT_WITH_T_REQUIRED_TEXT) + + row=0 + config_window.sb__received_message_format_labels = createSettingBox_Labels( + for_var_label_text=view_variable.VAR_LABEL_RECEIVED_MESSAGE_FORMAT, + for_var_desc_text=view_variable.VAR_DESC_RECEIVED_MESSAGE_FORMAT, + labels_attr_name="sb__labels_received_message_format", + ) + config_window.sb__received_message_format_labels.grid(row=row, pady=0) + row+=1 + + config_window.sb__received_message_format = createSettingBoxMessageFormatEntries( + base_entry_attr_name="sb__entry_received_message_format", + entry_textvariable_0=view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT, + entry_textvariable_1=view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT, + textvariable_0=view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT, + example_label_textvariable=view_variable.VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT, + entry_bind__Any_KeyRelease=lambda value: entry_received_message_format_callback(value), + entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_RECEIVED_MESSAGE_FORMAT, + ) + config_window.sb__received_message_format.grid(row=row) + row+=1 + + + + config_window.sb__received_message_format_with_t_labels = createSettingBox_Labels( + for_var_label_text=view_variable.VAR_LABEL_RECEIVED_MESSAGE_FORMAT_WITH_T, + for_var_desc_text=view_variable.VAR_DESC_RECEIVED_MESSAGE_FORMAT_WITH_T, + labels_attr_name="sb__labels_message_format_with_t", + ) + config_window.sb__received_message_format_with_t_labels.grid(row=row, pady=0) + row+=1 + + config_window.sb__received_message_format_with_t = createSettingBoxMessageFormatEntries_WithTranslation( + base_entry_attr_name="sb__entry_received_message_format_with_t", + entry_textvariable_0=view_variable.VAR_ENTRY_0_RECEIVED_MESSAGE_FORMAT_WITH_T, + entry_textvariable_1=view_variable.VAR_ENTRY_1_RECEIVED_MESSAGE_FORMAT_WITH_T, + entry_textvariable_2=view_variable.VAR_ENTRY_2_RECEIVED_MESSAGE_FORMAT_WITH_T, + textvariable_0=view_variable.VAR_TEXT_REQUIRED_0_RECEIVED_MESSAGE_FORMAT_WITH_T, + textvariable_1=view_variable.VAR_TEXT_REQUIRED_1_RECEIVED_MESSAGE_FORMAT_WITH_T, + example_label_textvariable=view_variable.VAR_LABEL_EXAMPLE_TEXT_RECEIVED_MESSAGE_FORMAT_WITH_T, + entry_bind__Any_KeyRelease=lambda value: entry_received_message_format_with_t_callback(value), + swap_button_command=entry_swap_received_message_format_with_t_callback, + entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_RECEIVED_MESSAGE_FORMAT_WITH_T, + ) + config_window.sb__received_message_format_with_t.grid(row=row, pady=0) + row+=1 \ No newline at end of file diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_SendMessageFormats.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_SendMessageFormats.py new file mode 100644 index 00000000..6180ffd8 --- /dev/null +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_others/createSettingBox_Others_SendMessageFormats.py @@ -0,0 +1,66 @@ +from utils import callFunctionIfCallable + +from .._SettingBoxGenerator import _SettingBoxGenerator + +def createSettingBox_Others_SendMessageFormats(setting_box_wrapper, config_window, settings, view_variable): + sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable) + createSettingBox_Labels = sbg.createSettingBox_Labels + createSettingBoxMessageFormatEntries = sbg.createSettingBoxMessageFormatEntries + createSettingBoxMessageFormatEntries_WithTranslation = sbg.createSettingBoxMessageFormatEntries_WithTranslation + + def entry_send_message_format_callback(value): + callFunctionIfCallable(view_variable.CALLBACK_SET_SEND_MESSAGE_FORMAT, value) + + + def entry_send_message_format_with_t_callback(value): + callFunctionIfCallable(view_variable.CALLBACK_SET_SEND_MESSAGE_FORMAT_WITH_T, value) + + def entry_swap_message_format_with_t_callback(_e): + callFunctionIfCallable(view_variable.CALLBACK_SWAP_SEND_MESSAGE_FORMAT_WITH_T_REQUIRED_TEXT) + + + row=0 + config_window.sb__send_message_format_labels = createSettingBox_Labels( + for_var_label_text=view_variable.VAR_LABEL_SEND_MESSAGE_FORMAT, + for_var_desc_text=view_variable.VAR_DESC_SEND_MESSAGE_FORMAT, + labels_attr_name="sb__labels_send_message_format", + ) + config_window.sb__send_message_format_labels.grid(row=row, pady=0) + row+=1 + + config_window.sb__message_format = createSettingBoxMessageFormatEntries( + base_entry_attr_name="sb__entry_send_message_format", + entry_textvariable_0=view_variable.VAR_ENTRY_0_SEND_MESSAGE_FORMAT, + entry_textvariable_1=view_variable.VAR_ENTRY_1_SEND_MESSAGE_FORMAT, + textvariable_0=view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT, + example_label_textvariable=view_variable.VAR_LABEL_EXAMPLE_TEXT_SEND_MESSAGE_FORMAT, + entry_bind__Any_KeyRelease=lambda value: entry_send_message_format_callback(value), + entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_SEND_MESSAGE_FORMAT, + ) + config_window.sb__message_format.grid(row=row) + row+=1 + + + + config_window.sb__send_message_format_with_t_labels = createSettingBox_Labels( + for_var_label_text=view_variable.VAR_LABEL_SEND_MESSAGE_FORMAT_WITH_T, + for_var_desc_text=view_variable.VAR_DESC_SEND_MESSAGE_FORMAT_WITH_T, + labels_attr_name="sb__labels_send_message_format_with_t", + ) + config_window.sb__send_message_format_with_t_labels.grid(row=row, pady=0) + row+=1 + + config_window.sb__message_format_with_t = createSettingBoxMessageFormatEntries_WithTranslation( + base_entry_attr_name="sb__entry_send_message_format_with_t", + entry_textvariable_0=view_variable.VAR_ENTRY_0_SEND_MESSAGE_FORMAT_WITH_T, + entry_textvariable_1=view_variable.VAR_ENTRY_1_SEND_MESSAGE_FORMAT_WITH_T, + entry_textvariable_2=view_variable.VAR_ENTRY_2_SEND_MESSAGE_FORMAT_WITH_T, + textvariable_0=view_variable.VAR_TEXT_REQUIRED_0_SEND_MESSAGE_FORMAT_WITH_T, + textvariable_1=view_variable.VAR_TEXT_REQUIRED_1_SEND_MESSAGE_FORMAT_WITH_T, + example_label_textvariable=view_variable.VAR_LABEL_EXAMPLE_TEXT_SEND_MESSAGE_FORMAT_WITH_T, + entry_bind__Any_KeyRelease=lambda value: entry_send_message_format_with_t_callback(value), + swap_button_command=entry_swap_message_format_with_t_callback, + entry_bind__FocusOut=view_variable.CALLBACK_FOCUS_OUT_SEND_MESSAGE_FORMAT_WITH_T, + ) + config_window.sb__message_format_with_t.grid(row=row, pady=0) + row+=1 \ No newline at end of file