Merge branch 'develop'

This commit is contained in:
misyaguziya
2024-05-23 16:57:13 +09:00
43 changed files with 1504 additions and 911 deletions

131
config.py
View File

@@ -736,57 +736,57 @@ class Config:
self._ENABLE_NOTICE_XSOVERLAY = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
# @property
# @json_serializable('OVERLAY_SETTINGS')
# def OVERLAY_SETTINGS(self):
# return self._OVERLAY_SETTINGS
@property
@json_serializable('OVERLAY_SETTINGS')
def OVERLAY_SETTINGS(self):
return self._OVERLAY_SETTINGS
# @OVERLAY_SETTINGS.setter
# def OVERLAY_SETTINGS(self, value):
# if isinstance(value, dict) and set(value.keys()) == set(self.OVERLAY_SETTINGS.keys()):
# for key, value in value.items():
# if isinstance(value, float):
# self._OVERLAY_SETTINGS[key] = value
# saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.OVERLAY_SETTINGS)
@OVERLAY_SETTINGS.setter
def OVERLAY_SETTINGS(self, value):
if isinstance(value, dict) and set(value.keys()) == set(self.OVERLAY_SETTINGS.keys()):
for key, value in value.items():
if isinstance(value, float):
self._OVERLAY_SETTINGS[key] = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.OVERLAY_SETTINGS)
# @property
# @json_serializable('ENABLE_OVERLAY_SMALL_LOG')
# def ENABLE_OVERLAY_SMALL_LOG(self):
# return self._ENABLE_OVERLAY_SMALL_LOG
@property
@json_serializable('ENABLE_OVERLAY_SMALL_LOG')
def ENABLE_OVERLAY_SMALL_LOG(self):
return self._ENABLE_OVERLAY_SMALL_LOG
# @ENABLE_OVERLAY_SMALL_LOG.setter
# def ENABLE_OVERLAY_SMALL_LOG(self, value):
# if isinstance(value, bool):
# self._ENABLE_OVERLAY_SMALL_LOG = value
# saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@ENABLE_OVERLAY_SMALL_LOG.setter
def ENABLE_OVERLAY_SMALL_LOG(self, value):
if isinstance(value, bool):
self._ENABLE_OVERLAY_SMALL_LOG = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
# @property
# @json_serializable('OVERLAY_SMALL_LOG_SETTINGS')
# def OVERLAY_SMALL_LOG_SETTINGS(self):
# return self._OVERLAY_SMALL_LOG_SETTINGS
@property
@json_serializable('OVERLAY_SMALL_LOG_SETTINGS')
def OVERLAY_SMALL_LOG_SETTINGS(self):
return self._OVERLAY_SMALL_LOG_SETTINGS
# @OVERLAY_SMALL_LOG_SETTINGS.setter
# def OVERLAY_SMALL_LOG_SETTINGS(self, value):
# if isinstance(value, dict) and set(value.keys()) == set(self.OVERLAY_SMALL_LOG_SETTINGS.keys()):
# for key, value in value.items():
# match (key):
# case "x_pos" | "y_pos" | "depth":
# if isinstance(value, float):
# self._OVERLAY_SMALL_LOG_SETTINGS[key] = value
# case "display_duration" | "fadeout_duration":
# if isinstance(value, int):
# self._OVERLAY_SMALL_LOG_SETTINGS[key] = value
# saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.OVERLAY_SMALL_LOG_SETTINGS)
@OVERLAY_SMALL_LOG_SETTINGS.setter
def OVERLAY_SMALL_LOG_SETTINGS(self, value):
if isinstance(value, dict) and set(value.keys()) == set(self.OVERLAY_SMALL_LOG_SETTINGS.keys()):
for key, value in value.items():
match (key):
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation":
if isinstance(value, float):
self._OVERLAY_SMALL_LOG_SETTINGS[key] = value
case "display_duration" | "fadeout_duration":
if isinstance(value, int):
self._OVERLAY_SMALL_LOG_SETTINGS[key] = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.OVERLAY_SMALL_LOG_SETTINGS)
# @property
# @json_serializable('OVERLAY_UI_TYPE')
# def OVERLAY_UI_TYPE(self):
# return self._OVERLAY_UI_TYPE
@property
@json_serializable('OVERLAY_UI_TYPE')
def OVERLAY_UI_TYPE(self):
return self._OVERLAY_UI_TYPE
# @OVERLAY_UI_TYPE.setter
# def OVERLAY_UI_TYPE(self, value):
# if isinstance(value, str):
# self._OVERLAY_UI_TYPE = value
@OVERLAY_UI_TYPE.setter
def OVERLAY_UI_TYPE(self, value):
if isinstance(value, str):
self._OVERLAY_UI_TYPE = value
# saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@@ -892,6 +892,17 @@ class Config:
self._ENABLE_LOGGER = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@json_serializable('ENABLE_VRC_MIC_MUTE_SYNC')
def ENABLE_VRC_MIC_MUTE_SYNC(self):
return self._ENABLE_VRC_MIC_MUTE_SYNC
@ENABLE_VRC_MIC_MUTE_SYNC.setter
def ENABLE_VRC_MIC_MUTE_SYNC(self, value):
if isinstance(value, bool):
self._ENABLE_VRC_MIC_MUTE_SYNC = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@json_serializable('IS_CONFIG_WINDOW_COMPACT_MODE')
def IS_CONFIG_WINDOW_COMPACT_MODE(self):
@@ -905,7 +916,7 @@ class Config:
def init_config(self):
# Read Only
self._VERSION = "2.2.3"
self._VERSION = "2.2.4"
self._ENABLE_SPEAKER2CHATBOX = False # Speaker2Chatbox
self._ENABLE_SPEAKER2CHATBOX_PASS_CONFIRMATION = "VRCT=0YEN"
self._PATH_LOCAL = os_path.dirname(sys.argv[0])
@@ -1054,23 +1065,27 @@ class Config:
self._ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = False
self._SEND_MESSAGE_BUTTON_TYPE = "show"
self._ENABLE_NOTICE_XSOVERLAY = False
# self._OVERLAY_SETTINGS = {
# "opacity": 1.0,
# "ui_scaling": 1.0,
# }
# self._ENABLE_OVERLAY_SMALL_LOG = False
# self._OVERLAY_SMALL_LOG_SETTINGS = {
# "x_pos": 0.0,
# "y_pos": -0.41,
# "depth": 1.0,
# "display_duration": 5,
# "fadeout_duration": 2,
# }
# self._OVERLAY_UI_TYPE = "default"
self._OVERLAY_SETTINGS = {
"opacity": 1.0,
"ui_scaling": 1.0,
}
self._ENABLE_OVERLAY_SMALL_LOG = False
self._OVERLAY_SMALL_LOG_SETTINGS = {
"x_pos": 0.0,
"y_pos": 0.0,
"z_pos": 0.0,
"x_rotation": 0.0,
"y_rotation": 0.0,
"z_rotation": 0.0,
"display_duration": 5,
"fadeout_duration": 2,
}
self._OVERLAY_UI_TYPE = "default"
self._ENABLE_SEND_MESSAGE_TO_VRC = True
self._ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = False # Speaker2Chatbox
self._ENABLE_SPEAKER2CHATBOX_PASS = "000000000"
self._ENABLE_LOGGER = False
self._ENABLE_VRC_MIC_MUTE_SYNC = False
self._IS_CONFIG_WINDOW_COMPACT_MODE = False
def load_config(self):

View File

@@ -27,10 +27,10 @@ def callbackFilepathConfigFile():
def callbackQuitVrct():
setMainWindowGeometry()
# def callbackEnableEasterEgg():
# config.IS_EASTER_EGG_ENABLED = True
# config.OVERLAY_UI_TYPE = "sakura"
# view.printToTextbox_enableEasterEgg()
def callbackEnableEasterEgg():
config.IS_EASTER_EGG_ENABLED = True
config.OVERLAY_UI_TYPE = "sakura"
view.printToTextbox_enableEasterEgg()
def setMainWindowGeometry():
PRE_SCALING_INT = strPctToInt(view.getPreUiScaling())
@@ -61,10 +61,11 @@ def messageFormatter(format_type:str, translation, message):
return osc_message
def changeToCTranslate2Process():
config.CHOICE_INPUT_TRANSLATOR = "CTranslate2"
config.CHOICE_OUTPUT_TRANSLATOR = "CTranslate2"
updateTranslationEngineAndEngineList()
view.printToTextbox_TranslationEngineLimitError()
if config.CHOICE_INPUT_TRANSLATOR != "CTranslate2" or config.CHOICE_OUTPUT_TRANSLATOR != "CTranslate2":
config.CHOICE_INPUT_TRANSLATOR = "CTranslate2"
config.CHOICE_OUTPUT_TRANSLATOR = "CTranslate2"
updateTranslationEngineAndEngineList()
view.printToTextbox_TranslationEngineLimitError()
# func transcription send message
def sendMicMessage(message):
@@ -161,14 +162,12 @@ def receiveSpeakerMessage(message):
xsoverlay_message = messageFormatter("RECEIVED", translation, message)
model.notificationXSOverlay(xsoverlay_message)
# if model.overlay.initialized is False:
# model.startOverlay()
# else:
# if config.ENABLE_OVERLAY_SMALL_LOG is True:
# overlay_image = model.createOverlayImageShort(message, translation)
# model.updateOverlay(overlay_image)
# # overlay_image = model.createOverlayImageLong("receive", message, translation)
# # model.updateOverlay(overlay_image)
if config.ENABLE_OVERLAY_SMALL_LOG is True:
if model.overlay.initialized is True:
overlay_image = model.createOverlayImageShort(message, translation)
model.updateOverlay(overlay_image)
# overlay_image = model.createOverlayImageLong("receive", message, translation)
# model.updateOverlay(overlay_image)
# ------------Speaker2Chatbox------------
if config.ENABLE_SPEAKER2CHATBOX is True:
@@ -401,10 +400,10 @@ def callbackSelectedTranslationEngine(selected_translation_engine):
def callbackToggleTranslation(is_turned_on):
config.ENABLE_TRANSLATION = is_turned_on
if config.ENABLE_TRANSLATION is True:
model.changeTranslatorCTranslate2Model()
if model.isLoadedCTranslate2Model() is False:
model.changeTranslatorCTranslate2Model()
view.printToTextbox_enableTranslation()
else:
model.clearTranslatorCTranslate2Model()
view.printToTextbox_disableTranslation()
def callbackToggleTranscriptionSend(is_turned_on):
@@ -427,6 +426,12 @@ def callbackToggleTranscriptionReceive(is_turned_on):
stopThreadingTranscriptionReceiveMessage()
view.changeTranscriptionDisplayStatus("SPEAKER_OFF")
if config.ENABLE_TRANSCRIPTION_RECEIVE is True and config.ENABLE_OVERLAY_SMALL_LOG is True:
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
model.startOverlay()
elif config.ENABLE_TRANSCRIPTION_RECEIVE is False:
pass
def callbackToggleForeground(is_turned_on):
config.ENABLE_FOREGROUND = is_turned_on
if config.ENABLE_FOREGROUND is True:
@@ -577,7 +582,7 @@ def callbackSetCtranslate2WeightType(value):
def callbackSetDeeplAuthKey(value):
print("callbackSetDeeplAuthKey", str(value))
view.clearNotificationMessage()
if len(value) == 39:
if len(value) == 36 or len(value) == 39:
result = model.authenticationTranslatorDeepLAuthKey(auth_key=value)
if result is True:
key = value
@@ -858,44 +863,44 @@ def callbackSetWhisperWeightType(value):
config.SELECTED_TRANSCRIPTION_ENGINE = "Google"
view.showRestartButtonIfRequired()
# # VR Tab
# def callbackSetOverlaySettings(value, set_type:str):
# print("callbackSetOverlaySettings", value, set_type)
# pre_settings = config.OVERLAY_SETTINGS
# pre_settings[set_type] = value
# config.OVERLAY_SETTINGS = pre_settings
# match (set_type):
# case "opacity":
# model.updateOverlayImageOpacity()
# case "ui_scaling":
# model.updateOverlayImageUiScaling()
# VR Tab
def callbackSetOverlaySettings(value, set_type:str):
print("callbackSetOverlaySettings", value, set_type)
pre_settings = config.OVERLAY_SETTINGS
pre_settings[set_type] = value
config.OVERLAY_SETTINGS = pre_settings
match (set_type):
case "opacity":
model.updateOverlayImageOpacity()
case "ui_scaling":
model.updateOverlayImageUiScaling()
# def callbackSetEnableOverlaySmallLog(value):
# print("callbackSetEnableOverlaySmallLog", value)
# config.ENABLE_OVERLAY_SMALL_LOG = value
def callbackSetEnableOverlaySmallLog(value):
print("callbackSetEnableOverlaySmallLog", value)
config.ENABLE_OVERLAY_SMALL_LOG = value
# if config.ENABLE_OVERLAY_SMALL_LOG is True:
# pass
# else:
# if model.overlay.initialized is True:
# model.clearOverlayImage()
if config.ENABLE_OVERLAY_SMALL_LOG is True and config.ENABLE_TRANSCRIPTION_RECEIVE is True:
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
model.startOverlay()
elif config.ENABLE_OVERLAY_SMALL_LOG is False:
model.clearOverlayImage()
model.shutdownOverlay()
# def callbackSetOverlaySmallLogSettings(value, set_type:str):
# print("callbackSetOverlaySmallLogSettings", value, set_type)
# pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
# pre_settings[set_type] = value
# config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
# match (set_type):
# case "x_pos":
# model.updateOverlayPosition()
# case "y_pos":
# model.updateOverlayPosition()
# case "depth":
# model.updateOverlayPosition()
# case "display_duration":
# model.updateOverlayTimes()
# case "fadeout_duration":
# model.updateOverlayTimes()
if config.ENABLE_OVERLAY_SMALL_LOG is True:
view.setStateOverlaySmallLog("enabled")
elif config.ENABLE_OVERLAY_SMALL_LOG is False:
view.setStateOverlaySmallLog("disabled")
def callbackSetOverlaySmallLogSettings(value, set_type:str):
print("callbackSetOverlaySmallLogSettings", value, set_type)
pre_settings = config.OVERLAY_SMALL_LOG_SETTINGS
pre_settings[set_type] = value
config.OVERLAY_SMALL_LOG_SETTINGS = pre_settings
match (set_type):
case "x_pos" | "y_pos" | "z_pos" | "x_rotation" | "y_rotation" | "z_rotation":
model.updateOverlayPosition()
case "display_duration" | "fadeout_duration":
model.updateOverlayTimes()
# Others Tab
def callbackSetEnableAutoClearMessageBox(value):
@@ -924,6 +929,18 @@ def callbackSetEnableAutoExportMessageLogs(value):
else:
model.stopLogger()
def callbackSetEnableVrcMicMuteSync(value):
print("callbackSetEnableVrcMicMuteSync", value)
config.ENABLE_VRC_MIC_MUTE_SYNC = value
if config.ENABLE_VRC_MIC_MUTE_SYNC is True:
model.startCheckMuteSelfStatus()
view.setStateVrcMicMuteSync("enabled")
else:
model.stopCheckMuteSelfStatus()
view.setStateVrcMicMuteSync("disabled")
model.changeMicTranscriptStatus()
def callbackSetEnableSendMessageToVrc(value):
print("callbackSetEnableSendMessageToVrc", value)
config.ENABLE_SEND_MESSAGE_TO_VRC = value
@@ -978,7 +995,6 @@ def callbackSetEnableSendReceivedMessageToVrc(value):
config.ENABLE_SEND_RECEIVED_MESSAGE_TO_VRC = value
# ---------------------Speaker2Chatbox---------------------
# Advanced Settings Tab
def callbackSetOscIpAddress(value):
if value == "":
@@ -1044,12 +1060,17 @@ def createMainWindow(splash):
if config.ENABLE_LOGGER is True:
model.startLogger()
# init OSC receive
model.startReceiveOSC()
if config.ENABLE_VRC_MIC_MUTE_SYNC is True:
model.startCheckMuteSelfStatus()
splash.toProgress(3) # Last one.
# set UI and callback
view.register(
common_registers={
# "callback_enable_easter_egg": callbackEnableEasterEgg,
"callback_enable_easter_egg": callbackEnableEasterEgg,
"callback_update_software": callbackUpdateSoftware,
"callback_restart_software": callbackRestartSoftware,
@@ -1137,10 +1158,10 @@ def createMainWindow(splash):
"callback_set_use_whisper_feature": callbackSetUserWhisperFeature,
"callback_set_whisper_weight_type": callbackSetWhisperWeightType,
# # VR Tab
# "callback_set_overlay_settings": callbackSetOverlaySettings,
# "callback_set_enable_overlay_small_log": callbackSetEnableOverlaySmallLog,
# "callback_set_overlay_small_log_settings": callbackSetOverlaySmallLogSettings,
# VR Tab
"callback_set_overlay_settings": callbackSetOverlaySettings,
"callback_set_enable_overlay_small_log": callbackSetEnableOverlaySmallLog,
"callback_set_overlay_small_log_settings": callbackSetOverlaySmallLogSettings,
# Others Tab
"callback_set_enable_auto_clear_chatbox": callbackSetEnableAutoClearMessageBox,
@@ -1148,6 +1169,7 @@ def createMainWindow(splash):
"callback_set_send_message_button_type": callbackSetSendMessageButtonType,
"callback_set_enable_notice_xsoverlay": callbackSetEnableNoticeXsoverlay,
"callback_set_enable_auto_export_message_logs": callbackSetEnableAutoExportMessageLogs,
"callback_set_enable_vrc_mic_mute_sync": callbackSetEnableVrcMicMuteSync,
"callback_set_enable_send_message_to_vrc": callbackSetEnableSendMessageToVrc,
# Others(Message Formats(Send)
"callback_set_send_message_format": callbackSetSendMessageFormat,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -18,7 +18,7 @@ main_window:
textbox_tab_system: System
textbox_system_message:
enabled_easter_egg: Whoa! You caught us! There is something...like...easter-egg-ish function has enabled!
enabled_easter_egg: Whoa! You caught us! There is something...like...easter-egg-ish function has enabled! It'll affect to Overlay(VR) for now;).
enabled_translation: Translation feature is turned on.
disabled_translation: Translation feature is turned off.
enabled_voice2chatbox: Transcription from the microphone has started.
@@ -46,6 +46,8 @@ main_window:
opened_web_page_vrct_documents: "Opened VRCT Documents page in your web browser.\nFor any issues, requests, or inquiries, please feel free to contact us through the links at the bottom of the documents page, the \"Contact Form,\" or via X (formerly Twitter)!"
update_available: New version is here!
state_text_enabled: Enabled
state_text_disabled: Disabled
cover_message: The functionality is temporarily disabled until the settings window is closed.
@@ -72,7 +74,10 @@ overlay_settings:
ui_scaling: UI Scaling
x_position: X-axis (left-right)
y_position: Y-axis (up-down)
depth: Z-axis (front-back)
z_position: Z-axis (front-back)
x_rotation: X-axis rotation
y_rotation: Y-axis rotation
z_rotation: Z-axis rotation
display_duration: Display duration
fadeout_duration: Fadeout duration
@@ -243,6 +248,10 @@ config_window:
label: Auto Export Message Logs
desc: Automatically export the conversation messages as a text file.
vrc_mic_mute_sync:
label: VRC Mic Mute Sync
desc: "VRCT will not send the message to VRChat while VRChat's mic is muted.\n*There is a bit latency and Push-To-Talk is not supported."
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.

View File

@@ -45,6 +45,8 @@ main_window:
opened_web_page_vrct_documents: "お使いのブラウザで、VRCTのドキュメントを開きました。使用方法などはそちらに記載されています。\n不具合、ご要望、その他お問い合わせはドキュメント最下部にあるLinks、「お問合せフォーム」もしくはX (元Twitter) にて気軽にご連絡ください!"
update_available: 新しいバージョンが出ました!
state_text_enabled: 有効
state_text_disabled: 無効
cover_message: 設定画面が閉じられるまで、一時的に機能を停止しています。
@@ -71,7 +73,10 @@ overlay_settings:
ui_scaling: サイズ
x_position: X軸左右
y_position: Y軸上下
depth: Z軸前後
z_position: Z軸前後
x_rotation: X軸の回転
y_rotation: Y軸の回転
z_rotation: Z軸の回転
display_duration: 表示時間
fadeout_duration: フェードアウト時間
@@ -242,6 +247,11 @@ config_window:
label: 会話ログを自動的に保存する
desc: テキストファイルとしてログがlogsフォルダ内に保存されます。
vrc_mic_mute_sync:
label: VRCマイクミュート同期
desc: "VRChatのマイクがミュートされている間は、メッセージをVRChatに送信しません。\n※若干の遅延はあります。また、Push-To-Talkは非対応です。"
send_message_to_vrc:
label: VRChatにメッセージを送信する
desc: "サポート対象外ですが、VRChatにメッセージを送信せずに使う方法があります。送信したい場合、この機能を有効にする事を忘れないでください。"

385
model.py
View File

@@ -9,7 +9,7 @@ from datetime import datetime
from logging import getLogger, FileHandler, Formatter, INFO
from time import sleep
from queue import Queue
from threading import Thread, Event
from threading import Thread
from requests import get as requests_get
import webbrowser
@@ -17,7 +17,7 @@ from typing import Callable
from flashtext import KeywordProcessor
from models.translation.translation_translator import Translator
from models.transcription.transcription_utils import getInputDevices, getOutputDevices
from models.osc.osc_tools import sendTyping, sendMessage, sendTestAction, receiveOscParameters
from models.osc.osc_tools import sendTyping, sendMessage, receiveOscParameters, getOSCParameterValue
from models.transcription.transcription_recorder import SelectedMicEnergyAndAudioRecorder, SelectedSpeakerEnergyAndAudioRecorder
from models.transcription.transcription_recorder import SelectedMicEnergyRecorder, SelectedSpeakerEnergyRecorder
from models.transcription.transcription_transcriber import AudioTranscriber
@@ -26,28 +26,37 @@ from models.translation.translation_languages import translation_lang
from models.transcription.transcription_languages import transcription_lang
from models.translation.translation_utils import checkCTranslate2Weight
from models.transcription.transcription_whisper import checkWhisperWeight
# from models.overlay.overlay import Overlay
# from models.overlay.overlay_image import OverlayImage
from models.overlay.overlay import Overlay
from models.overlay.overlay_image import OverlayImage
from config import config
class threadFnc(Thread):
def __init__(self, fnc, end_fnc=None, daemon=True, *args, **kwargs):
super(threadFnc, self).__init__(daemon=daemon, *args, **kwargs)
super(threadFnc, self).__init__(daemon=daemon, target=fnc, *args, **kwargs)
self.fnc = fnc
self.end_fnc = end_fnc
self._stop = Event()
self.loop = True
self._pause = False
def stop(self):
self._stop.set()
def stopped(self):
return self._stop.is_set()
self.loop = False
def pause(self):
self._pause = True
def resume(self):
self._pause = False
def run(self):
while True:
if self.stopped():
if callable(self.end_fnc):
self.end_fnc()
return
while self.loop:
self.fnc(*self._args, **self._kwargs)
while self._pause:
sleep(0.1)
if callable(self.end_fnc):
self.end_fnc()
return
class Model:
_instance = None
@@ -72,18 +81,24 @@ class Model:
self.previous_receive_message = ""
self.translator = Translator()
self.keyword_processor = KeywordProcessor()
# self.overlay = Overlay(
# config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
# config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
# config.OVERLAY_SMALL_LOG_SETTINGS["depth"],
# config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"],
# config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"],
# config.OVERLAY_SETTINGS["opacity"],
# config.OVERLAY_SETTINGS["ui_scaling"],
# )
# self.overlay_image = OverlayImage()
# self.pre_overlay_message = None
# self.th_overlay = None
self.overlay = Overlay(
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"],
config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"],
config.OVERLAY_SETTINGS["opacity"],
config.OVERLAY_SETTINGS["ui_scaling"],
)
self.overlay_image = OverlayImage()
self.pre_overlay_message = None
self.th_overlay = None
self.mic_audio_queue = None
self.mic_mute_status = None
self.mic_mute_status_check = None
def checkCTranslatorCTranslate2ModelWeight(self):
return checkCTranslate2Weight(config.PATH_LOCAL, config.CTRANSLATE2_WEIGHT_TYPE)
@@ -91,8 +106,8 @@ class Model:
def changeTranslatorCTranslate2Model(self):
self.translator.changeCTranslate2Model(config.PATH_LOCAL, config.CTRANSLATE2_WEIGHT_TYPE)
def clearTranslatorCTranslate2Model(self):
self.translator.clearCTranslate2Model()
def isLoadedCTranslate2Model(self):
return self.translator.isLoadedCTranslate2Model()
def checkTranscriptionWhisperModelWeight(self):
return checkWhisperWeight(config.PATH_LOCAL, config.WHISPER_WEIGHT_TYPE)
@@ -153,59 +168,62 @@ class Model:
compatible_engines.remove('DeepL_API')
return compatible_engines
def getTranslate(self, translator_name, source_language, target_language, target_country, message):
success_flag = False
translation = self.translator.translate(
translator_name=translator_name,
source_language=source_language,
target_language=target_language,
target_country=target_country,
message=message
)
# 翻訳失敗時のフェールセーフ処理
if isinstance(translation, str):
success_flag = True
else:
while True:
translation = self.translator.translate(
translator_name="CTranslate2",
source_language=source_language,
target_language=target_language,
target_country=target_country,
message=message
)
if translation is not False:
break
sleep(0.1)
return translation, success_flag
def getInputTranslate(self, message):
translation_success_flag = True
translator_name=config.CHOICE_INPUT_TRANSLATOR
source_language=config.SOURCE_LANGUAGE
target_language=config.TARGET_LANGUAGE
target_country = config.TARGET_COUNTRY
translation = self.translator.translate(
translator_name=translator_name,
source_language=source_language,
target_language=target_language,
target_country=target_country,
message=message
)
# 翻訳失敗時のフェールセーフ処理
if translation is False:
translation_success_flag = False
translation = self.translator.translate(
translator_name="CTranslate2",
source_language=source_language,
target_language=target_language,
target_country=target_country,
message=message
)
return translation, translation_success_flag
translation, success_flag = self.getTranslate(
translator_name,
source_language,
target_language,
target_country,
message
)
return translation, success_flag
def getOutputTranslate(self, message):
translation_success_flag = True
translator_name=config.CHOICE_OUTPUT_TRANSLATOR
source_language=config.TARGET_LANGUAGE
target_language=config.SOURCE_LANGUAGE
target_country=config.SOURCE_COUNTRY
translation = self.translator.translate(
translator_name=translator_name,
source_language=source_language,
target_language=target_language,
target_country=target_country,
message=message
)
# 翻訳失敗時のフェールセーフ処理
if translation is False:
translation_success_flag = False
translation = self.translator.translate(
translator_name="CTranslate2",
source_language=source_language,
target_language=target_language,
target_country=target_country,
message=message
)
return translation, translation_success_flag
translation, success_flag = self.getTranslate(
translator_name,
source_language,
target_language,
target_country,
message
)
return translation, success_flag
def addKeywords(self):
for f in config.INPUT_MIC_WORD_FILTER:
@@ -240,39 +258,51 @@ class Model:
def oscSendMessage(message):
sendMessage(message, config.OSC_IP_ADDRESS, config.OSC_PORT)
def checkOSCStarted(self, fnc):
self.is_valid_osc = False
def checkOscReceive(address, osc_arguments):
if self.is_valid_osc is False:
self.is_valid_osc = True
@staticmethod
def getMuteSelfStatus():
return getOSCParameterValue(address="/avatar/parameters/MuteSelf")
self.listening_server = receiveOscParameters(checkOscReceive)
def oscListener():
self.listening_server.serve_forever()
def startCheckMuteSelfStatus(self):
def checkMuteSelfStatus():
if self.mic_mute_status is not None:
self.changeMicTranscriptStatus()
self.stopCheckMuteSelfStatus()
def sendTestActionLoop():
for _ in range(10):
sendTestAction()
if self.is_valid_osc is True:
break
sleep(0.1)
self.listening_server.shutdown()
status = self.getMuteSelfStatus()
if status is not None:
self.mic_mute_status = status
self.changeMicTranscriptStatus()
self.stopCheckMuteSelfStatus()
# start receive osc
th_receive_osc_parameters = Thread(target=oscListener)
th_receive_osc_parameters.daemon = True
th_receive_osc_parameters.start()
if not isinstance(self.mic_mute_status_check, threadFnc):
self.mic_mute_status_check = threadFnc(checkMuteSelfStatus)
self.mic_mute_status_check.daemon = True
self.mic_mute_status_check.start()
# check osc started
th_send_osc_test_action = Thread(target=sendTestActionLoop)
th_send_osc_test_action.daemon = True
th_send_osc_test_action.start()
def stopCheckMuteSelfStatus(self):
if isinstance(self.mic_mute_status_check, threadFnc):
self.mic_mute_status_check.stop()
self.mic_mute_status_check = None
th_receive_osc_parameters.join()
th_send_osc_test_action.join()
def startReceiveOSC(self):
osc_parameter_prefix = "/avatar/parameters/"
param_MuteSelf = "MuteSelf"
if self.is_valid_osc is False:
fnc()
def change_handler_mute(address, osc_arguments):
if osc_arguments is True and self.mic_mute_status is False:
self.mic_mute_status = osc_arguments
self.changeMicTranscriptStatus()
elif osc_arguments is False and self.mic_mute_status is True:
self.mic_mute_status = osc_arguments
self.changeMicTranscriptStatus()
dict_filter_and_target = {
osc_parameter_prefix + param_MuteSelf: change_handler_mute,
}
th_osc_server = Thread(target=receiveOscParameters, args=(dict_filter_and_target,))
th_osc_server.daemon = True
th_osc_server.start()
@staticmethod
def checkSoftwareUpdated():
@@ -365,8 +395,9 @@ class Model:
pass
return
mic_audio_queue = Queue()
# mic_energy_queue = Queue()
self.mic_audio_queue = Queue()
# self.mic_energy_queue = Queue()
mic_device = choice_mic_device[0]
record_timeout = config.INPUT_MIC_RECORD_TIMEOUT
phase_timeout = config.INPUT_MIC_PHRASE_TIMEOUT
@@ -379,8 +410,8 @@ class Model:
dynamic_energy_threshold=config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD,
record_timeout=record_timeout,
)
# self.mic_audio_recorder.recordIntoQueue(mic_audio_queue, mic_energy_queue)
self.mic_audio_recorder.recordIntoQueue(mic_audio_queue, None)
# self.mic_audio_recorder.recordIntoQueue(self.mic_audio_queue, mic_energy_queue)
self.mic_audio_recorder.recordIntoQueue(self.mic_audio_queue, None)
self.mic_transcriber = AudioTranscriber(
speaker=False,
source=self.mic_audio_recorder.source,
@@ -392,15 +423,18 @@ class Model:
)
def sendMicTranscript():
try:
self.mic_transcriber.transcribeAudioQueue(mic_audio_queue, config.SOURCE_LANGUAGE, config.SOURCE_COUNTRY)
message = self.mic_transcriber.getTranscript()
fnc(message)
res = self.mic_transcriber.transcribeAudioQueue(self.mic_audio_queue, config.SOURCE_LANGUAGE, config.SOURCE_COUNTRY)
if res:
message = self.mic_transcriber.getTranscript()
fnc(message)
except Exception:
pass
def endMicTranscript():
mic_audio_queue.queue.clear()
# mic_energy_queue.queue.clear()
while not self.mic_audio_queue.empty():
self.mic_audio_queue.get()
# while not self.mic_energy_queue.empty():
# self.mic_energy_queue.get()
del self.mic_transcriber
gc.collect()
@@ -422,12 +456,50 @@ class Model:
# self.mic_get_energy.daemon = True
# self.mic_get_energy.start()
self.changeMicTranscriptStatus()
def resumeMicTranscript(self):
# キューをクリア
if isinstance(self.mic_audio_queue, Queue):
while not self.mic_audio_queue.empty():
self.mic_audio_queue.get()
# 文字起こしを再開
# if isinstance(self.mic_print_transcript, threadFnc):
# self.mic_print_transcript.resume()
# 音声のレコードを再開
if isinstance(self.mic_audio_recorder, SelectedMicEnergyAndAudioRecorder):
self.mic_audio_recorder.resume()
def pauseMicTranscript(self):
# 文字起こしを一時停止
# if isinstance(self.mic_print_transcript, threadFnc):
# self.mic_print_transcript.pause()
# 音声のレコードを一時停止
if isinstance(self.mic_audio_recorder, SelectedMicEnergyAndAudioRecorder):
self.mic_audio_recorder.pause()
def changeMicTranscriptStatus(self):
if config.ENABLE_VRC_MIC_MUTE_SYNC is True:
if self.mic_mute_status is True:
self.pauseMicTranscript()
elif self.mic_mute_status is False:
self.resumeMicTranscript()
else:
pass
else:
self.resumeMicTranscript()
def stopMicTranscript(self):
if isinstance(self.mic_print_transcript, threadFnc):
self.mic_print_transcript.stop()
self.mic_print_transcript.join()
self.mic_print_transcript = None
if isinstance(self.mic_audio_recorder, SelectedMicEnergyAndAudioRecorder):
self.mic_audio_recorder.stop(wait_for_stop=True)
self.mic_audio_recorder.resume()
self.mic_audio_recorder.stop()
self.mic_audio_recorder = None
# if isinstance(self.mic_get_energy, threadFnc):
# self.mic_get_energy.stop()
@@ -465,7 +537,7 @@ class Model:
self.mic_energy_plot_progressbar.stop()
self.mic_energy_plot_progressbar = None
if isinstance(self.mic_energy_recorder, SelectedMicEnergyRecorder):
self.mic_energy_recorder.stop(wait_for_stop=True)
self.mic_energy_recorder.stop()
self.mic_energy_recorder = None
def startSpeakerTranscript(self, fnc, error_fnc=None):
@@ -493,7 +565,7 @@ class Model:
record_timeout=record_timeout,
)
# self.speaker_audio_recorder.recordIntoQueue(speaker_audio_queue, speaker_energy_queue)
self.speaker_audio_recorder.recordIntoQueue(speaker_audio_queue ,None)
self.speaker_audio_recorder.recordIntoQueue(speaker_audio_queue, None)
self.speaker_transcriber = AudioTranscriber(
speaker=True,
source=self.speaker_audio_recorder.source,
@@ -505,9 +577,10 @@ class Model:
)
def sendSpeakerTranscript():
try:
self.speaker_transcriber.transcribeAudioQueue(speaker_audio_queue, config.TARGET_LANGUAGE, config.TARGET_COUNTRY)
message = self.speaker_transcriber.getTranscript()
fnc(message)
res = self.speaker_transcriber.transcribeAudioQueue(speaker_audio_queue, config.TARGET_LANGUAGE, config.TARGET_COUNTRY)
if res:
message = self.speaker_transcriber.getTranscript()
fnc(message)
except Exception:
pass
@@ -538,9 +611,10 @@ class Model:
def stopSpeakerTranscript(self):
if isinstance(self.speaker_print_transcript, threadFnc):
self.speaker_print_transcript.stop()
self.speaker_print_transcript.join()
self.speaker_print_transcript = None
if isinstance(self.speaker_audio_recorder, SelectedSpeakerEnergyAndAudioRecorder):
self.speaker_audio_recorder.stop(wait_for_stop=True)
self.speaker_audio_recorder.stop()
self.speaker_audio_recorder = None
# if isinstance(self.speaker_get_energy, threadFnc):
# self.speaker_get_energy.stop()
@@ -578,71 +652,64 @@ class Model:
self.speaker_energy_plot_progressbar.stop()
self.speaker_energy_plot_progressbar = None
if isinstance(self.speaker_energy_recorder, SelectedSpeakerEnergyRecorder):
self.speaker_energy_recorder.stop(wait_for_stop=True)
self.speaker_energy_recorder.stop()
self.speaker_energy_recorder = None
def notificationXSOverlay(self, message):
xsoverlayForVRCT(content=f"{message}")
# def createOverlayImageShort(self, message, translation):
# your_language = config.TARGET_LANGUAGE
# target_language = config.SOURCE_LANGUAGE
# ui_type = config.OVERLAY_UI_TYPE
# self.pre_overlay_message = {
# "message" : message,
# "your_language" : your_language,
# "translation" : translation,
# "target_language" : target_language,
# "ui_type" : ui_type,
# }
# return self.overlay_image.createOverlayImageShort(message, your_language, translation, target_language, ui_type)
def createOverlayImageShort(self, message, translation):
your_language = config.TARGET_LANGUAGE
target_language = config.SOURCE_LANGUAGE
ui_type = config.OVERLAY_UI_TYPE
self.pre_overlay_message = {
"message" : message,
"your_language" : your_language,
"translation" : translation,
"target_language" : target_language,
"ui_type" : ui_type,
}
return self.overlay_image.createOverlayImageShort(message, your_language, translation, target_language, ui_type)
# def createOverlayImageLong(self, message_type, message, translation):
# your_language = config.TARGET_LANGUAGE if message_type == "receive" else config.SOURCE_LANGUAGE
# target_language = config.SOURCE_LANGUAGE if message_type == "receive" else config.TARGET_LANGUAGE
# return self.overlay_image.create_overlay_image_long(message_type, message, your_language, translation, target_language)
# def clearOverlayImage(self):
# if self.overlay.initialized is True:
# self.overlay.uiManager.uiClear()
def clearOverlayImage(self):
self.overlay.clearImage()
# def updateOverlay(self, img):
# if self.overlay.initialized is True:
# self.overlay.uiManager.uiUpdate(img)
def updateOverlay(self, img):
self.overlay.updateImage(img)
# def startOverlay(self):
# if self.overlay.initialized is False:
# self.overlay.init()
def startOverlay(self):
self.overlay.startOverlay()
# if self.overlay.initialized is True and self.th_overlay is None:
# self.th_overlay = Thread(target=self.overlay.startOverlay)
# self.th_overlay.daemon = True
# self.th_overlay.start()
def updateOverlayPosition(self):
self.overlay.updatePosition(
config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"],
config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"],
config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"],
config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"],
config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"],
config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"],
)
# def updateOverlayPosition(self):
# if self.overlay.initialized is True:
# pos = (config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"], config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"])
# self.overlay.uiManager.setPosition(pos)
# depth = config.OVERLAY_SMALL_LOG_SETTINGS["depth"]
# self.overlay.uiManager.setDepth(depth)
# self.overlay.uiManager.posUpdate()
def updateOverlayTimes(self):
display_duration = config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"]
self.overlay.updateDisplayDuration(display_duration)
fadeout_duration = config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"]
self.overlay.updateFadeoutDuration(fadeout_duration)
# def updateOverlayTimes(self):
# if self.overlay.initialized is True:
# display_duration = config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"]
# self.overlay.uiManager.setFadeTime(display_duration)
# fadeout_duration = config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"]
# self.overlay.uiManager.setFadeInterval(fadeout_duration)
# self.overlay.uiManager.update()
def updateOverlayImageOpacity(self):
opacity = config.OVERLAY_SETTINGS["opacity"]
self.overlay.updateOpacity(opacity, with_fade=True)
# def updateOverlayImageOpacity(self):
# if self.overlay.initialized is True:
# opacity = config.OVERLAY_SETTINGS["opacity"]
# self.overlay.uiManager.setTransparency(opacity)
def updateOverlayImageUiScaling(self):
ui_scaling = config.OVERLAY_SETTINGS["ui_scaling"]
self.overlay.updateUiScaling(ui_scaling)
# def updateOverlayImageUiScaling(self):
# if self.overlay.initialized is True:
# ui_scaling = config.OVERLAY_SETTINGS["ui_scaling"]
# self.overlay.uiManager.setUiScaling(ui_scaling)
def shutdownOverlay(self):
self.overlay.shutdownOverlay()
model = Model()

View File

@@ -1,10 +1,10 @@
from time import sleep
import threading
from pythonosc import osc_message_builder
from pythonosc import udp_client
from pythonosc import dispatcher
from pythonosc import osc_server
from tinyoscquery.queryservice import OSCQueryService
from tinyoscquery.query import OSCQueryBrowser, OSCQueryClient
from tinyoscquery.utility import get_open_udp_port, get_open_tcp_port
# send OSC message typing
@@ -48,6 +48,22 @@ def sendChangeVoice(ip_address="127.0.0.1", port=9000):
sendInputVoice(flag=0, ip_address=ip_address, port=port)
sleep(0.05)
def getOSCParameterValue(address, server_name="VRChat-Client"):
value = None
try:
browser = OSCQueryBrowser()
sleep(1)
service = browser.find_service_by_name(server_name)
if service is not None:
oscq = OSCQueryClient(service)
mute_self_node = oscq.query_node(address)
value = mute_self_node.value[0]
browser.zc.close()
browser.browser.cancel()
except Exception:
pass
return value
def receiveOscParameters(dict_filter_and_target, ip_address="127.0.0.1", title="VRCT"):
osc_port = get_open_udp_port()
@@ -55,14 +71,14 @@ def receiveOscParameters(dict_filter_and_target, ip_address="127.0.0.1", title="
osc_dispatcher = dispatcher.Dispatcher()
for filter, target in dict_filter_and_target.items():
osc_dispatcher.map(filter, target)
osc_udp_server = osc_server.ThreadingOSCUDPServer((ip_address, osc_port), osc_dispatcher)
threading.Thread(target=osc_udp_server.serve_forever, daemon = True).start()
osc_client = OSCQueryService(title, http_port, osc_port)
for filter, target in dict_filter_and_target.items():
osc_client.advertise_endpoint(filter)
osc_udp_server.serve_forever()
if __name__ == "__main__":
osc_parameter_prefix = "/avatar/parameters/"
osc_avatar_change_path = "/avatar/change"

View File

@@ -1,198 +1,198 @@
import psutil
import os
import ctypes
import time
import asyncio
from psutil import process_iter
from threading import Thread
import openvr
import numpy as np
from PIL import Image
try:
from . import overlay_utils as utils
except ImportError:
import overlay_utils as utils
def checkSteamvrRunning():
for proc in psutil.process_iter():
if "vrserver.exe" == proc.name().lower():
return True
return False
# This code is based on the following source:
# [GOpy](https://github.com/MeroFune/GOpy)
def mat34Id():
def mat34Id(array):
arr = openvr.HmdMatrix34_t()
arr[0][0] = 1
arr[1][1] = 1
arr[2][2] = 1
for i in range(3):
for j in range(4):
arr[i][j] = array[i][j]
return arr
class UIElement:
def __init__(self, overlayRoot, key: str, name: str, settings: dict = None) -> None:
"""
pos is a 2-tuple representing (x, y) normalized position of the overlay on the screen
"""
self.overlay = overlayRoot
self.overlayKey = key
self.overlayName = name
self.settings = settings
self.handle = self.overlay.createOverlay(self.overlayKey, self.overlayName)
def getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation):
arr = np.zeros((3, 4))
rot = utils.euler_to_rotation_matrix((x_rotation, y_rotation, z_rotation))
self.setImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0))) # blank image for default
self.setColor(self.settings['Color'])
self.setTransparency(self.settings['Transparency'])
self.overlay.setOverlayWidthInMeters(
self.handle,
self.settings['Ui_scaling']
)
for i in range(3):
for j in range(3):
arr[i][j] = rot[i][j]
self.updatePosition()
self.overlay.showOverlay(self.handle)
arr[0][3] = x_pos * z_pos
arr[1][3] = y_pos * z_pos
arr[2][3] = - z_pos
return arr
def setImage(self, img):
# configure overlay appearance
width, height = img.size
img = img.tobytes()
img = (ctypes.c_char * len(img)).from_buffer_copy(img)
self.overlay.setOverlayRaw(self.handle, img, width, height, 4)
def getHMDBaseMatrix():
x_pos = 0.0
y_pos = -0.4
z_pos = 1.0
x_rotation = 0.0
y_rotation = 0.0
z_rotation = 0.0
arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation)
return arr
def setColor(self, col):
"""
col is a 3-tuple representing (r, g, b)
"""
self.overlay.setOverlayColor(self.handle, col[0], col[1], col[2])
def getLeftHandBaseMatrix():
x_pos = 0.0
y_pos = -0.06
z_pos = -0.14
x_rotation = -62.0
y_rotation = 154.0
z_rotation = 71.0
arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation)
return arr
def setTransparency(self, a):
self.overlay.setOverlayAlpha(self.handle, a)
def updatePosition(self):
self.transform = mat34Id() # no rotation required for HMD attachment
# assign position
self.transform[0][3] = self.settings["Normalized_icon_X_position"] * self.settings['Icon_plane_depth']
self.transform[1][3] = self.settings["Normalized_icon_Y_position"] * self.settings['Icon_plane_depth']
self.transform[2][3] = - self.settings['Icon_plane_depth']
self.overlay.setOverlayTransformTrackedDeviceRelative(
self.handle,
openvr.k_unTrackedDeviceIndex_Hmd,
self.transform
)
def setPosition(self, pos):
"""
pos is a 2-tuple representing normalized (x, y)
"""
self.settings["Normalized_icon_X_position"] = pos[0]
self.settings["Normalized_icon_Y_position"] = pos[1]
def setDepth(self, depth):
self.settings["Icon_plane_depth"] = depth
def setUiScaling(self, ui_scaling):
self.overlay.setOverlayWidthInMeters(
self.handle,
ui_scaling,
)
class UIManager:
def __init__(self, overlay_key, overlay_name, settings):
self.overlay = openvr.IVROverlay()
self.settings = settings
self.overlayUI = UIElement(
self.overlay,
overlay_key,
overlay_name,
self.settings,
)
self.fadeRatio = 1
self.lastUpdate = time.monotonic()
def update(self):
currTime = time.monotonic()
if self.settings['Fade_interval'] != 0:
self.evaluateTransparencyFade(self.lastUpdate, currTime)
def uiClear(self):
self.overlayUI.setImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
self.overlayUI.setTransparency(self.settings['Transparency'])
self.lastUpdate = time.monotonic()
def uiUpdate(self, img):
self.overlayUI.setImage(img)
self.overlayUI.setTransparency(self.settings['Transparency'])
self.lastUpdate = time.monotonic()
def evaluateTransparencyFade(self, lastUpdate, currentTime):
if (currentTime - lastUpdate) > self.settings['Fade_time']:
timeThroughInterval = currentTime - lastUpdate - self.settings['Fade_time']
self.fadeRatio = 1 - timeThroughInterval / self.settings['Fade_interval']
if self.fadeRatio < 0:
self.fadeRatio = 0
self.overlayUI.setTransparency(self.fadeRatio * self.settings['Transparency'])
def posUpdate(self):
self.overlayUI.updatePosition()
def setPosition(self, pos):
self.overlayUI.setPosition(pos)
def setDepth(self, depth):
self.overlayUI.setDepth(depth)
def setFadeTime(self, fade_time):
self.settings["Fade_time"] = fade_time
def setFadeInterval(self, fade_interval):
self.settings["Fade_interval"] = fade_interval
def setUiScaling(self, ui_scaling):
self.overlayUI.setUiScaling(ui_scaling)
def setTransparency(self, transparency):
self.settings["Transparency"] = transparency
self.overlayUI.setTransparency(self.fadeRatio * self.settings['Transparency'])
def getRightHandBaseMatrix():
x_pos = 0.0
y_pos = -0.06
z_pos = -0.14
x_rotation = -62.0
y_rotation = -154.0
z_rotation = -71.0
arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation)
return arr
class Overlay:
def __init__(self, x, y , depth, fade_time, fade_interval, transparency, ui_scaling):
def __init__(self, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, display_duration, fadeout_duration, opacity, ui_scaling):
self.initialized = False
settings = {
"Color": [1, 1, 1],
"Transparency": transparency,
"Normalized_icon_X_position": x,
"Normalized_icon_Y_position": y,
"Icon_plane_depth": depth,
"Fade_time": fade_time,
"Fade_interval": fade_interval,
"Ui_scaling": ui_scaling,
"color": [1, 1, 1],
"opacity": opacity,
"x_pos": x_pos,
"y_pos": y_pos,
"z_pos": z_pos,
"x_rotation": x_rotation,
"y_rotation": y_rotation,
"z_rotation": z_rotation,
"display_duration": display_duration,
"fadeout_duration": fadeout_duration,
"ui_scaling": ui_scaling,
}
self.settings = settings
self.system = None
self.overlay = None
self.handle = None
self.lastUpdate = time.monotonic()
self.thread_overlay = None
self.fadeRatio = 1
self.loop = True
def init(self):
try:
if checkSteamvrRunning() is True:
self.system = openvr.init(openvr.VRApplication_Background)
self.initialized = True
self.system = openvr.init(openvr.VRApplication_Background)
self.overlay = openvr.IVROverlay()
self.overlay_system = openvr.IVRSystem()
self.handle = self.overlay.createOverlay("Overlay_Speaker2log", "SOverlay_Speaker2log_UI")
self.overlay.showOverlay(self.handle)
self.initialized = True
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
self.updateColor(self.settings["color"])
self.updateOpacity(self.settings["opacity"])
self.updateUiScaling(self.settings["ui_scaling"])
self.updatePosition(
self.settings["x_pos"],
self.settings["y_pos"],
self.settings["z_pos"],
self.settings["x_rotation"],
self.settings["y_rotation"],
self.settings["z_rotation"],
)
except Exception as e:
print("Could not initialise OpenVR")
print(e)
print("Could not initialise OpenVR", e)
async def mainLoop(self):
while self.checkActive() is True:
startTime = time.monotonic()
self.uiManager.update()
sleepTime = (1 / 60) - (time.monotonic() - startTime)
if sleepTime > 0:
await asyncio.sleep(sleepTime)
async def initMain(self):
def updateImage(self, img):
if self.initialized is True:
self.uiManager = UIManager("Overlay_Speaker2log", "SOverlay_Speaker2log_UI", self.settings)
await self.mainLoop()
width, height = img.size
img = img.tobytes()
img = (ctypes.c_char * len(img)).from_buffer_copy(img)
self.overlay.setOverlayRaw(self.handle, img, width, height, 4)
self.updateOpacity(self.settings["opacity"])
self.lastUpdate = time.monotonic()
def startOverlay(self):
asyncio.run(self.initMain())
def clearImage(self):
if self.initialized is True:
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
def shutdown(self):
self.system = None
self.initialized = False
openvr.shutdown()
def updateColor(self, col):
"""
col is a 3-tuple representing (r, g, b)
"""
self.settings["color"] = col
if self.initialized is True:
r, g, b = self.settings["color"]
self.overlay.setOverlayColor(self.handle, r, g, b)
def updateOpacity(self, opacity, with_fade=False):
self.settings["opacity"] = opacity
if self.initialized is True:
if with_fade is True:
if self.fadeRatio > 0:
self.overlay.setOverlayAlpha(self.handle, self.fadeRatio * self.settings["opacity"])
else:
self.overlay.setOverlayAlpha(self.handle, self.settings["opacity"])
def updateUiScaling(self, ui_scaling):
self.settings["ui_scaling"] = ui_scaling
if self.initialized is True:
self.overlay.setOverlayWidthInMeters(self.handle, self.settings["ui_scaling"])
def updatePosition(self, x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation, tracker="HMD"):
"""
x_pos, y_pos, z_pos are floats representing the position of overlay
x_rotation, y_rotation, z_rotation are floats representing the rotation of overlay
tracker is a string representing the tracker to use ("HMD", "LeftHand", "RightHand")
"""
self.settings["x_pos"] = x_pos
self.settings["y_pos"] = y_pos
self.settings["z_pos"] = z_pos
self.settings["x_rotation"] = x_rotation
self.settings["y_rotation"] = y_rotation
self.settings["z_rotation"] = z_rotation
match tracker:
case "HMD":
base_matrix = getHMDBaseMatrix()
trackerIndex = openvr.k_unTrackedDeviceIndex_Hmd
case "LeftHand":
base_matrix = getLeftHandBaseMatrix()
trackerIndex = self.overlay_system.getTrackedDeviceIndexForControllerRole(openvr.TrackedControllerRole_LeftHand)
case "RightHand":
base_matrix = getRightHandBaseMatrix()
trackerIndex = self.overlay_system.getTrackedDeviceIndexForControllerRole(openvr.TrackedControllerRole_RightHand)
case _:
base_matrix = getHMDBaseMatrix()
trackerIndex = openvr.k_unTrackedDeviceIndex_Hmd
translation = (self.settings["x_pos"], self.settings["y_pos"], - self.settings["z_pos"])
rotation = (self.settings["x_rotation"], self.settings["y_rotation"], self.settings["z_rotation"])
transform = utils.transform_matrix(base_matrix, translation, rotation)
self.transform = mat34Id(transform)
if self.initialized is True:
self.overlay.setOverlayTransformTrackedDeviceRelative(
self.handle,
trackerIndex,
self.transform
)
def updateDisplayDuration(self, display_duration):
self.settings["display_duration"] = display_duration
def updateFadeoutDuration(self, fadeout_duration):
self.settings["fadeout_duration"] = fadeout_duration
def checkActive(self):
try:
@@ -200,7 +200,6 @@ class Overlay:
new_event = openvr.VREvent_t()
while self.system.pollNextEvent(new_event):
if new_event.eventType == openvr.VREvent_Quit:
self.shutdown()
return False
return True
except Exception as e:
@@ -208,49 +207,98 @@ class Overlay:
print(e)
return False
if __name__ == '__main__':
from overlay_image import OverlayImage
from threading import Thread, Event
class threadFnc(Thread):
def __init__(self, fnc, end_fnc=None, daemon=True, *args, **kwargs):
super(threadFnc, self).__init__(daemon=daemon, *args, **kwargs)
self.fnc = fnc
self.end_fnc = end_fnc
self._stop = Event()
def stop(self):
self._stop.set()
def stopped(self):
return self._stop.is_set()
def run(self):
while True:
if self.stopped():
if callable(self.end_fnc):
self.end_fnc()
return
self.fnc(*self._args, **self._kwargs)
def evaluateOpacityFade(self, lastUpdate, currentTime):
if (currentTime - lastUpdate) > self.settings["display_duration"]:
timeThroughInterval = currentTime - lastUpdate - self.settings["display_duration"]
self.fadeRatio = 1 - timeThroughInterval / self.settings["fadeout_duration"]
if self.fadeRatio < 0:
self.fadeRatio = 0
self.overlay.setOverlayAlpha(self.handle, self.fadeRatio * self.settings["opacity"])
overlay = Overlay()
overlay_image = OverlayImage()
def update(self):
currTime = time.monotonic()
if self.settings["fadeout_duration"] != 0:
self.evaluateOpacityFade(self.lastUpdate, currTime)
else:
self.updateOpacity(self.settings["opacity"])
if overlay.initialized is False:
overlay.init()
if overlay.initialized is True:
t = threadFnc(overlay.startOverlay)
t.start()
def mainloop(self):
self.loop = True
while self.checkActive() is True and self.loop is True:
startTime = time.monotonic()
self.update()
sleepTime = (1 / 16) - (time.monotonic() - startTime)
if sleepTime > 0:
time.sleep(sleepTime)
time.sleep(1)
img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "Hello,World!Goodbye", "Japanese", ui_type="sakura")
# img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", ui_type="sakura")
if overlay.initialized is True:
overlay.uiManager.uiUpdate(img)
time.sleep(10)
def main(self):
self.init()
if self.initialized is True:
self.mainloop()
img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "안녕하세요, 세계!안녕", "Korean")
if overlay.initialized is True:
overlay.uiManager.uiUpdate(img)
time.sleep(10)
def startOverlay(self):
self.thread_overlay = Thread(target=self.main)
self.thread_overlay.daemon = True
self.thread_overlay.start()
img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "你好世界!再见", "Chinese Simplified")
if overlay.initialized is True:
overlay.uiManager.uiUpdate(img)
time.sleep(10)
def shutdownOverlay(self):
if isinstance(self.thread_overlay, Thread):
self.loop = False
self.thread_overlay.join()
self.thread_overlay = None
if isinstance(self.overlay, openvr.IVROverlay) and isinstance(self.handle, int):
self.overlay.destroyOverlay(self.handle)
self.overlay = None
if isinstance(self.system, openvr.IVRSystem):
openvr.shutdown()
self.system = None
self.initialized = False
@staticmethod
def checkSteamvrRunning() -> bool:
_proc_name = "vrmonitor.exe" if os.name == "nt" else "vrmonitor"
return _proc_name in (p.name() for p in process_iter())
if __name__ == "__main__":
# from overlay_image import OverlayImage
# overlay_image = OverlayImage()
# overlay = Overlay(0, 0, 1, 1, 0, 1, 1)
# overlay.startOverlay()
# time.sleep(1)
# # Example usage
# img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "Hello,World!Goodbye", "Japanese")
# overlay.updateImage(img)
# time.sleep(100000)
# for i in range(100):
# print(i)
# overlay = Overlay(0, 0, 1, 1, 1, 1, 1)
# overlay.startOverlay()
# time.sleep(1)
# # Example usage
# img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "Hello,World!Goodbye", "Japanese", ui_type="sakura")
# overlay.updateImage(img)
# time.sleep(0.5)
# img = overlay_image.createOverlayImageShort("こんにちは、世界!さようなら", "Japanese", "Hello,World!Goodbye", "Japanese")
# overlay.updateImage(img)
# time.sleep(0.5)
# overlay.shutdownOverlay()
x_pos = 0
y_pos = 0
z_pos = 0
x_rotation = 0
y_rotation = 0
z_rotation = 0
base_matrix = getLeftHandBaseMatrix()
translation = (x_pos * z_pos, y_pos * z_pos, z_pos)
rotation = (x_rotation, y_rotation, z_rotation)
transform = utils.transform_matrix(base_matrix, translation, rotation)
transform = mat34Id(transform)
print(transform)

View File

@@ -23,7 +23,7 @@ class OverlayImage:
@staticmethod
def concatenateImagesVertically(img1: Image, img2: Image) -> Image:
dst = Image.new('RGBA', (img1.width, img1.height + img2.height))
dst = Image.new("RGBA", (img1.width, img1.height + img2.height))
dst.paste(img1, (0, 0))
dst.paste(img2, (0, img1.height))
return dst

View File

@@ -0,0 +1,87 @@
import numpy as np
def toHomogeneous(matrix):
homogeneous_matrix = np.vstack([matrix, [0, 0, 0, 1]])
return homogeneous_matrix
# 移動行列を生成する関数
def calcTranslationMatrix(translation):
tx, ty, tz = translation
return np.array([
[1, 0, 0, tx],
[0, 1, 0, ty],
[0, 0, 1, tz],
[0, 0, 0, 1]
])
# X軸周りの回転行列を生成する関数
def calcRotationMatrixX(angle):
c = np.cos(np.pi/180*angle)
s = np.sin(np.pi/180*angle)
return np.array([
[1, 0, 0, 0],
[0, c, -s, 0],
[0, s, c, 0],
[0, 0, 0, 1]
])
# Y軸周りの回転行列を生成する関数
def calcRotationMatrixY(angle):
c = np.cos(np.pi/180*angle)
s = np.sin(np.pi/180*angle)
return np.array([
[c, 0, s, 0],
[0, 1, 0, 0],
[-s, 0, c, 0],
[0, 0, 0, 1]
])
# Z軸周りの回転行列を生成する関数
def calcRotationMatrixZ(angle):
c = np.cos(np.pi/180*angle)
s = np.sin(np.pi/180*angle)
return np.array([
[c, -s, 0, 0],
[s, c, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
# 3x4行列の座標を基準として回転や移動を行う関数
def transform_matrix(base_matrix, translation, rotation):
homogeneous_base_matrix = toHomogeneous(base_matrix)
translation_matrix = calcTranslationMatrix(translation)
rotation_matrix_x = calcRotationMatrixX(rotation[0])
rotation_matrix_y = calcRotationMatrixY(rotation[1])
rotation_matrix_z = calcRotationMatrixZ(rotation[2])
rotation_matrix = np.dot(rotation_matrix_z, np.dot(rotation_matrix_y, rotation_matrix_x))
transformation_matrix = translation_matrix.copy()
transformation_matrix[:3, :3] = rotation_matrix[:3, :3]
result_matrix = np.dot(homogeneous_base_matrix, transformation_matrix)
return result_matrix[:3, :]
def euler_to_rotation_matrix(angles):
phi = angles[0] * np.pi / 180
theta = angles[1] * np.pi / 180
psi = angles[2]* np.pi / 180
R_x = np.array([[1, 0, 0],
[0, np.cos(phi), -np.sin(phi)],
[0, np.sin(phi), np.cos(phi)]])
R_y = np.array([[np.cos(theta), 0, np.sin(theta)],
[0, 1, 0],
[-np.sin(theta), 0, np.cos(theta)]])
R_z = np.array([[np.cos(psi), -np.sin(psi), 0],
[np.sin(psi), np.cos(psi), 0],
[0, 0, 1]])
return np.dot(R_z, np.dot(R_y, R_x))
if __name__ == "__main__":
base_matrix = np.array([
[1, 0, 0, 1],
[0, 1, 0, 1],
[0, 0, 1, 1]
])
translation = [1, 2, 3]
rotation = [0, 0, 90]
result_matrix = transform_matrix(base_matrix, translation, rotation)
print(result_matrix)

View File

@@ -24,7 +24,7 @@ class BaseRecorder:
def record_callback(_, audio):
audio_queue.put((audio.get_raw_data(), datetime.now()))
self.stop = self.recorder.listen_in_background(self.source, record_callback, phrase_time_limit=self.record_timeout)
self.stop, self.pause, self.resume = self.recorder.listen_in_background(self.source, record_callback, phrase_time_limit=self.record_timeout)
class SelectedMicRecorder(BaseRecorder):
def __init__(self, device, energy_threshold, dynamic_energy_threshold, record_timeout):
@@ -68,7 +68,7 @@ class BaseEnergyRecorder:
def recordCallback(_, energy):
energy_queue.put(energy)
self.stop = self.recorder.listen_energy_in_background(self.source, recordCallback)
self.stop, self.pause, self.resume = self.recorder.listen_energy_in_background(self.source, recordCallback)
class SelectedMicEnergyRecorder(BaseEnergyRecorder):
def __init__(self, device):
@@ -107,17 +107,18 @@ class BaseEnergyAndAudioRecorder:
with self.source:
self.recorder.adjust_for_ambient_noise(self.source)
def recordIntoQueue(self, audio_queue, energy_queue):
def recordIntoQueue(self, audio_queue, energy_queue=None):
def audioRecordCallback(_, audio):
audio_queue.put((audio.get_raw_data(), datetime.now()))
def energyRecordCallback(energy):
energy_queue.put(energy)
if isinstance(energy_queue, Queue):
self.stop = self.recorder.listen_energy_and_audio_in_background(self.source, audioRecordCallback, phrase_time_limit=self.record_timeout, callback_energy=energyRecordCallback)
else:
self.stop = self.recorder.listen_energy_and_audio_in_background(self.source, audioRecordCallback, phrase_time_limit=self.record_timeout)
self.stop, self.pause, self.resume = self.recorder.listen_energy_and_audio_in_background(
source=self.source,
callback=audioRecordCallback,
phrase_time_limit=self.record_timeout,
callback_energy=energyRecordCallback if energy_queue is not None else None)
class SelectedMicEnergyAndAudioRecorder(BaseEnergyAndAudioRecorder):
def __init__(self, device, energy_threshold, dynamic_energy_threshold, record_timeout):

View File

@@ -1,3 +1,4 @@
import time
from io import BytesIO
from threading import Event
import wave
@@ -38,6 +39,9 @@ class AudioTranscriber:
self.transcription_engine = "Whisper"
def transcribeAudioQueue(self, audio_queue, language, country):
if audio_queue.empty():
time.sleep(0.01)
return False
audio, time_spoken = audio_queue.get()
self.updateLastSampleAndPhraseStatus(audio, time_spoken)
@@ -75,6 +79,7 @@ class AudioTranscriber:
if text != '':
self.updateTranscript(text)
return True
def updateLastSampleAndPhraseStatus(self, data, time_spoken):
source_info = self.audio_sources

View File

@@ -1,4 +1,3 @@
import gc
import os
from deepl import Translator as deepl_Translator
from translators import translate_text as other_web_Translator
@@ -14,6 +13,7 @@ class Translator():
self.deepl_client = None
self.ctranslate2_translator = None
self.ctranslate2_tokenizer = None
self.is_loaded_ctranslate2_model = False
def authenticationDeepLAuthKey(self, authkey):
result = True
@@ -26,6 +26,7 @@ class Translator():
return result
def changeCTranslate2Model(self, path, model_type):
self.is_loaded_ctranslate2_model = False
directory_name = ctranslate2_weights[model_type]["directory_name"]
tokenizer = ctranslate2_weights[model_type]["tokenizer"]
weight_path = os.path.join(path, "weights", "ctranslate2", directory_name)
@@ -44,13 +45,24 @@ class Translator():
print("Error: changeCTranslate2Model()", e)
tokenizer_path = os.path.join("./weights", "ctranslate2", directory_name, "tokenizer")
self.ctranslate2_tokenizer = transformers.AutoTokenizer.from_pretrained(tokenizer, cache_dir=tokenizer_path)
self.is_loaded_ctranslate2_model = True
def clearCTranslate2Model(self):
del self.ctranslate2_translator
del self.ctranslate2_tokenizer
gc.collect()
self.ctranslate2_translator = None
self.ctranslate2_tokenizer = None
def isLoadedCTranslate2Model(self):
return self.is_loaded_ctranslate2_model
def translateCTranslate2(self, message, source_language, target_language):
result = False
if self.is_loaded_ctranslate2_model is True:
try:
self.ctranslate2_tokenizer.src_lang = source_language
source = self.ctranslate2_tokenizer.convert_ids_to_tokens(self.ctranslate2_tokenizer.encode(message))
target_prefix = [self.ctranslate2_tokenizer.lang_code_to_token[target_language]]
results = self.ctranslate2_translator.translate_batch([source], target_prefix=[target_prefix])
target = results[0].hypotheses[0][1:]
result = self.ctranslate2_tokenizer.decode(self.ctranslate2_tokenizer.convert_tokens_to_ids(target))
except Exception:
pass
return result
@staticmethod
def getLanguageCode(translator_name, target_country, source_language, target_language):
@@ -115,12 +127,11 @@ class Translator():
to_language=target_language,
)
case "CTranslate2":
self.ctranslate2_tokenizer.src_lang = source_language
source = self.ctranslate2_tokenizer.convert_ids_to_tokens(self.ctranslate2_tokenizer.encode(message))
target_prefix = [self.ctranslate2_tokenizer.lang_code_to_token[target_language]]
results = self.ctranslate2_translator.translate_batch([source], target_prefix=[target_prefix])
target = results[0].hypotheses[0][1:]
result = self.ctranslate2_tokenizer.decode(self.ctranslate2_tokenizer.convert_tokens_to_ids(target))
result = self.translateCTranslate2(
message=message,
source_language=source_language,
target_language=target_language,
)
except Exception:
import traceback
with open('error.log', 'a') as f:

View File

@@ -14,5 +14,5 @@ ctranslate2==4.1.0
faster-whisper==1.0.1
openvr==1.26.701
translators @ git+https://github.com/misyaguziya/translators@5.8.9
SpeechRecognition @ git+https://github.com/misyaguziya/custom_speech_recognition@3.10.2
SpeechRecognition @ git+https://github.com/misyaguziya/custom_speech_recognition@3.10.4
tinyoscquery @ git+https://github.com/cyberkitsune/tinyoscquery@0.1.2

283
view.py
View File

@@ -101,7 +101,7 @@ class View():
self.view_variable = SimpleNamespace(
# Common
# CALLBACK_ENABLE_EASTER_EGG=None,
CALLBACK_ENABLE_EASTER_EGG=None,
CALLBACK_RESTART_SOFTWARE=None,
CALLBACK_UPDATE_SOFTWARE=None,
@@ -140,57 +140,88 @@ class View():
# Overlay Settings
# VAR_OVERLAY_SETTINGS=StringVar(value="Overlay Settings"),
# CALLBACK_SET_OPEN_OVERLAY_SETTINGS_WINDOW=self._openVrSettingsWindow,
# VAR_TO_DEFAULT_OVERLAY_SETTINGS=StringVar(value=i18n.t("overlay_settings.restore_default_settings")),
# CALLBACK_SET_TO_DEFAULT_OVERLAY_SETTINGS=self._toDefaultOverlaySettings,
VAR_OVERLAY_SETTINGS=StringVar(value="Overlay (VR)"),
CALLBACK_SET_OPEN_OVERLAY_SETTINGS_WINDOW=self._openVrSettingsWindow,
VAR_TO_DEFAULT_OVERLAY_SETTINGS=StringVar(value=i18n.t("overlay_settings.restore_default_settings")),
CALLBACK_SET_TO_DEFAULT_OVERLAY_SETTINGS=self._toDefaultOverlaySettings,
VAR_OVERLAY_SMALL_LOG_STATE=StringVar(value=""),
# VAR_LABEL_OVERLAY_OPACITY=StringVar(value=i18n.t("overlay_settings.opacity")),
# SLIDER_RANGE_OVERLAY_OPACITY=(0.1, 1.0),
# NUMBER_OF_STEPS_OVERLAY_OPACITY=18,
# VAR_OVERLAY_OPACITY=DoubleVar(value=config.OVERLAY_SETTINGS["opacity"]),
# VAR_CURRENT_VALUE_OVERLAY_OPACITY=StringVar(value=floatToPctStr(config.OVERLAY_SETTINGS["opacity"])),
CALLBACK_SET_OPEN_VRC_MIC_MUTE_SYNC_SETTINGS_WINDOW=self._openVrcMicMuteSyncSettingsWindow,
VAR_VRC_MIC_MUTE_SYNC_SETTINGS=StringVar(value=i18n.t("config_window.vrc_mic_mute_sync.label")),
VAR_VRC_MIC_MUTE_SYNC_STATE=StringVar(value=""),
# VAR_LABEL_OVERLAY_UI_SCALING=StringVar(value=i18n.t("overlay_settings.ui_scaling")),
# SLIDER_RANGE_OVERLAY_UI_SCALING=(0.4, 2.0),
# NUMBER_OF_STEPS_OVERLAY_UI_SCALING=16,
# VAR_OVERLAY_UI_SCALING=DoubleVar(value=config.OVERLAY_SETTINGS["ui_scaling"]),
# VAR_CURRENT_VALUE_OVERLAY_UI_SCALING=StringVar(value=floatToPctStr(config.OVERLAY_SETTINGS["ui_scaling"])),
VAR_LABEL_OVERLAY_OPACITY=StringVar(value=i18n.t("overlay_settings.opacity")),
SLIDER_RANGE_OVERLAY_OPACITY=(0.1, 1.0),
NUMBER_OF_STEPS_OVERLAY_OPACITY=18,
VAR_OVERLAY_OPACITY=DoubleVar(value=config.OVERLAY_SETTINGS["opacity"]),
VAR_CURRENT_VALUE_OVERLAY_OPACITY=StringVar(value=floatToPctStr(config.OVERLAY_SETTINGS["opacity"])),
VAR_LABEL_OVERLAY_UI_SCALING=StringVar(value=i18n.t("overlay_settings.ui_scaling")),
SLIDER_RANGE_OVERLAY_UI_SCALING=(0.4, 2.0),
NUMBER_OF_STEPS_OVERLAY_UI_SCALING=16,
VAR_OVERLAY_UI_SCALING=DoubleVar(value=config.OVERLAY_SETTINGS["ui_scaling"]),
VAR_CURRENT_VALUE_OVERLAY_UI_SCALING=StringVar(value=floatToPctStr(config.OVERLAY_SETTINGS["ui_scaling"])),
# # CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS=None,
CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS=None,
# VAR_LABEL_OVERLAY_SMALL_LOG_X_POS=StringVar(value=i18n.t("overlay_settings.x_position")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_X_POS=(-0.5, 0.5),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_POS=100,
# VAR_OVERLAY_SMALL_LOG_X_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]),
# VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]),
VAR_LABEL_OVERLAY_SMALL_LOG_X_POS=StringVar(value=i18n.t("overlay_settings.x_position")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_X_POS=(-5, 5),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_POS=10000,
SLIDER_RANGE_OVERLAY_SMALL_LOG_X_POS=(-0.5, 0.5),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_POS=100,
VAR_OVERLAY_SMALL_LOG_X_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]),
# VAR_LABEL_OVERLAY_SMALL_LOG_Y_POS=StringVar(value=i18n.t("overlay_settings.y_position")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_POS=(-0.8, 0.8),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_POS=160,
# VAR_OVERLAY_SMALL_LOG_Y_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]),
# VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]),
VAR_LABEL_OVERLAY_SMALL_LOG_Y_POS=StringVar(value=i18n.t("overlay_settings.y_position")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_POS=(-5, 5),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_POS=10000,
SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_POS=(-0.8, 0.8),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_POS=160,
VAR_OVERLAY_SMALL_LOG_Y_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"]),
# VAR_LABEL_OVERLAY_SMALL_LOG_DEPTH=StringVar(value=i18n.t("overlay_settings.depth")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_DEPTH=(0.5, 1.5),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DEPTH=100,
# VAR_OVERLAY_SMALL_LOG_DEPTH=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["depth"]),
# VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["depth"]),
VAR_LABEL_OVERLAY_SMALL_LOG_Z_POS=StringVar(value=i18n.t("overlay_settings.z_position")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_POS=(-5, 5),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_POS=10000,
SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_POS=(-0.5, 1.5),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_POS=100,
VAR_OVERLAY_SMALL_LOG_Z_POS=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"]),
# VAR_LABEL_OVERLAY_SMALL_LOG_DISPLAY_DURATION=StringVar(value=i18n.t("overlay_settings.display_duration")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_DISPLAY_DURATION=(1, 60),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DISPLAY_DURATION=59,
# VAR_OVERLAY_SMALL_LOG_DISPLAY_DURATION=IntVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"]),
# VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DISPLAY_DURATION=StringVar(value=f"{config.OVERLAY_SMALL_LOG_SETTINGS['display_duration']} second(s)"),
VAR_LABEL_OVERLAY_SMALL_LOG_X_ROTATION=StringVar(value=i18n.t("overlay_settings.x_rotation")),
SLIDER_RANGE_OVERLAY_SMALL_LOG_X_ROTATION=(-180, 180),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_ROTATION=360,
VAR_OVERLAY_SMALL_LOG_X_ROTATION=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_ROTATION=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"]),
# VAR_LABEL_OVERLAY_SMALL_LOG_FADEOUT_DURATION=StringVar(value=i18n.t("overlay_settings.fadeout_duration")),
# SLIDER_RANGE_OVERLAY_SMALL_LOG_FADEOUT_DURATION=(0, 5),
# NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_FADEOUT_DURATION=5,
# VAR_OVERLAY_SMALL_LOG_FADEOUT_DURATION=IntVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"]),
# VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_FADEOUT_DURATION=StringVar(value=f"{config.OVERLAY_SMALL_LOG_SETTINGS['fadeout_duration']} second(s)"),
VAR_LABEL_OVERLAY_SMALL_LOG_Y_ROTATION=StringVar(value=i18n.t("overlay_settings.y_rotation")),
SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_ROTATION=(-180, 180),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_ROTATION=360,
VAR_OVERLAY_SMALL_LOG_Y_ROTATION=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_ROTATION=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"]),
VAR_LABEL_OVERLAY_SMALL_LOG_Z_ROTATION=StringVar(value=i18n.t("overlay_settings.z_rotation")),
SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_ROTATION=(-180, 180),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_ROTATION=360,
VAR_OVERLAY_SMALL_LOG_Z_ROTATION=DoubleVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_ROTATION=StringVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"]),
VAR_LABEL_OVERLAY_SMALL_LOG_DISPLAY_DURATION=StringVar(value=i18n.t("overlay_settings.display_duration")),
SLIDER_RANGE_OVERLAY_SMALL_LOG_DISPLAY_DURATION=(1, 60),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DISPLAY_DURATION=59,
VAR_OVERLAY_SMALL_LOG_DISPLAY_DURATION=IntVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DISPLAY_DURATION=StringVar(value=f"{config.OVERLAY_SMALL_LOG_SETTINGS['display_duration']} second(s)"),
VAR_LABEL_OVERLAY_SMALL_LOG_FADEOUT_DURATION=StringVar(value=i18n.t("overlay_settings.fadeout_duration")),
SLIDER_RANGE_OVERLAY_SMALL_LOG_FADEOUT_DURATION=(0, 5),
NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_FADEOUT_DURATION=5,
VAR_OVERLAY_SMALL_LOG_FADEOUT_DURATION=IntVar(value=config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"]),
VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_FADEOUT_DURATION=StringVar(value=f"{config.OVERLAY_SMALL_LOG_SETTINGS['fadeout_duration']} second(s)"),
@@ -478,13 +509,13 @@ class View():
VAR_WHISPER_WEIGHT_TYPE=StringVar(value=self.getSelectableWhisperWeightTypeDict()[config.WHISPER_WEIGHT_TYPE]),
# # VR Tab
# VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG=StringVar(value=i18n.t("config_window.enable_overlay_small_log.label")),
# VAR_DESC_ENABLE_OVERLAY_SMALL_LOG=None,
# # VAR_DESC_ENABLE_OVERLAY_SMALL_LOG=StringVar(value=i18n.t("config_window.enable_overlay_small_log.desc")),
# CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG=None,
# VAR_ENABLE_OVERLAY_SMALL_LOG=BooleanVar(value=config.ENABLE_OVERLAY_SMALL_LOG),
# VAR_OPEN_OVERLAY_SETTINGS_BUTTON=StringVar(value=i18n.t("config_window.enable_overlay_small_log.open_overlay_settings")),
# VR Tab
VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG=StringVar(value=i18n.t("config_window.enable_overlay_small_log.label")),
VAR_DESC_ENABLE_OVERLAY_SMALL_LOG=None,
# VAR_DESC_ENABLE_OVERLAY_SMALL_LOG=StringVar(value=i18n.t("config_window.enable_overlay_small_log.desc")),
CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG=None,
VAR_ENABLE_OVERLAY_SMALL_LOG=BooleanVar(value=config.ENABLE_OVERLAY_SMALL_LOG),
VAR_OPEN_OVERLAY_SETTINGS_BUTTON=StringVar(value=i18n.t("config_window.enable_overlay_small_log.open_overlay_settings")),
# Others Tab
@@ -519,6 +550,12 @@ class View():
VAR_ENABLE_AUTO_EXPORT_MESSAGE_LOGS=BooleanVar(value=config.ENABLE_LOGGER),
VAR_LABEL_ENABLE_VRC_MIC_MUTE_SYNC=StringVar(value=i18n.t("config_window.vrc_mic_mute_sync.label")),
VAR_DESC_ENABLE_VRC_MIC_MUTE_SYNC=StringVar(value=i18n.t("config_window.vrc_mic_mute_sync.desc")),
CALLBACK_SET_ENABLE_VRC_MIC_MUTE_SYNC=None,
VAR_ENABLE_VRC_MIC_MUTE_SYNC=BooleanVar(value=config.ENABLE_VRC_MIC_MUTE_SYNC),
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,
@@ -631,7 +668,7 @@ class View():
if common_registers is not None:
# self.view_variable.CALLBACK_ENABLE_EASTER_EGG=common_registers.get("callback_enable_easter_egg", None)
self.view_variable.CALLBACK_ENABLE_EASTER_EGG=common_registers.get("callback_enable_easter_egg", None)
self.view_variable.CALLBACK_UPDATE_SOFTWARE=common_registers.get("callback_update_software", None)
self.view_variable.CALLBACK_RESTART_SOFTWARE=common_registers.get("callback_restart_software", None)
@@ -756,11 +793,11 @@ class View():
# VR Tab
# VR Tab (Quick Settings)
# self.view_variable.CALLBACK_SET_OVERLAY_SETTINGS=config_window_registers.get("callback_set_overlay_settings", None)
self.view_variable.CALLBACK_SET_OVERLAY_SETTINGS=config_window_registers.get("callback_set_overlay_settings", None)
# self.view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG=config_window_registers.get("callback_set_enable_overlay_small_log", None)
# # VR Tab (Quick Settings)
# self.view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS=config_window_registers.get("callback_set_overlay_small_log_settings", None)
self.view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG=config_window_registers.get("callback_set_enable_overlay_small_log", None)
# VR Tab (Quick Settings)
self.view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS=config_window_registers.get("callback_set_overlay_small_log_settings", None)
# Others Tab
@@ -770,6 +807,7 @@ class View():
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_ENABLE_VRC_MIC_MUTE_SYNC=config_window_registers.get("callback_set_enable_vrc_mic_mute_sync", 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_SEND_MESSAGE_FORMAT=config_window_registers.get("callback_set_send_message_format", None)
@@ -801,6 +839,18 @@ class View():
self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.swap_button_label"))
self.useTranslationFeatureProcess("Disable")
if config.ENABLE_VRC_MIC_MUTE_SYNC is True:
self.setStateVrcMicMuteSync("enabled")
elif config.ENABLE_VRC_MIC_MUTE_SYNC is False:
self.setStateVrcMicMuteSync("disabled")
if config.ENABLE_OVERLAY_SMALL_LOG is True:
self.setStateOverlaySmallLog("enabled")
elif config.ENABLE_OVERLAY_SMALL_LOG is False:
self.setStateOverlaySmallLog("disabled")
if config.CHOICE_MIC_HOST == "NoHost":
self.view_variable.VAR_MIC_HOST.set("No Mic Host Detected")
@@ -858,21 +908,21 @@ class View():
# Set Easter Egg
# self.count = 0
# def clickedCounter(_e):
# if self.count < 2:
# self.count+=1
# print("Easter egg count:", self.count)
# else:
# print("Easter egg count:", self.count, "Easter egg has enabled.")
# callFunctionIfCallable(self.view_variable.CALLBACK_ENABLE_EASTER_EGG)
# print(config.OVERLAY_UI_TYPE)
self.count = 0
def clickedCounter(_e):
if self.count < 2:
self.count+=1
print("Easter egg count:", self.count)
else:
print("Easter egg count:", self.count, "Easter egg has enabled.")
callFunctionIfCallable(self.view_variable.CALLBACK_ENABLE_EASTER_EGG)
print(config.OVERLAY_UI_TYPE)
# vrct_gui.sidebar_logo.bind(
# "<ButtonRelease>",
# clickedCounter,
# "+"
# )
vrct_gui.sidebar_logo.bind(
"<ButtonRelease>",
clickedCounter,
"+"
)
# Insert sample conversation for testing.
@@ -1114,32 +1164,38 @@ class View():
}
# def _toDefaultOverlaySettings(self):
# INIT_OVERLAY_SETTINGS = {
# "opacity": 1.0,
# "ui_scaling": 1.0,
# }
# INIT_OVERLAY_SMALL_LOG_SETTINGS = {
# "x_pos": 0.0,
# "y_pos": -0.41,
# "depth": 1.0,
# "display_duration": 5,
# "fadeout_duration": 2,
# }
# for key in INIT_OVERLAY_SETTINGS.keys():
# callFunctionIfCallable(self.view_variable.CALLBACK_SET_OVERLAY_SETTINGS, INIT_OVERLAY_SETTINGS[key], key)
def _toDefaultOverlaySettings(self):
INIT_OVERLAY_SETTINGS = {
"opacity": 1.0,
"ui_scaling": 1.0,
}
INIT_OVERLAY_SMALL_LOG_SETTINGS = {
"x_pos": 0.0,
"y_pos": 0.0,
"z_pos": 0.0,
"x_rotation": 0.0,
"y_rotation": 0.0,
"z_rotation": 0.0,
"display_duration": 5,
"fadeout_duration": 2,
}
for key in INIT_OVERLAY_SETTINGS.keys():
callFunctionIfCallable(self.view_variable.CALLBACK_SET_OVERLAY_SETTINGS, INIT_OVERLAY_SETTINGS[key], key)
# for key in INIT_OVERLAY_SMALL_LOG_SETTINGS.keys():
# callFunctionIfCallable(self.view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, INIT_OVERLAY_SMALL_LOG_SETTINGS[key], key)
for key in INIT_OVERLAY_SMALL_LOG_SETTINGS.keys():
callFunctionIfCallable(self.view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, INIT_OVERLAY_SMALL_LOG_SETTINGS[key], key)
# self.setLatestConfigVariable("OverlayOpacity")
# self.setLatestConfigVariable("OverlayUiScaling")
self.setLatestConfigVariable("OverlayOpacity")
self.setLatestConfigVariable("OverlayUiScaling")
# self.setLatestConfigVariable("OverlaySmallLogXPos")
# self.setLatestConfigVariable("OverlaySmallLogYPos")
# self.setLatestConfigVariable("OverlaySmallLogDepth")
# self.setLatestConfigVariable("OverlaySmallLogDisplayDuration")
# self.setLatestConfigVariable("OverlaySmallLogFadeoutDuration")
self.setLatestConfigVariable("OverlaySmallLogXPos")
self.setLatestConfigVariable("OverlaySmallLogYPos")
self.setLatestConfigVariable("OverlaySmallLogZPos")
self.setLatestConfigVariable("OverlaySmallLogXRotation")
self.setLatestConfigVariable("OverlaySmallLogYRotation")
self.setLatestConfigVariable("OverlaySmallLogZRotation")
self.setLatestConfigVariable("OverlaySmallLogDisplayDuration")
self.setLatestConfigVariable("OverlaySmallLogFadeoutDuration")
# Open Webpage Functions
def openWebPage_Booth(self):
@@ -1274,6 +1330,26 @@ class View():
dropdown_menu_values=translation_dict,
)
def setStateVrcMicMuteSync(self, state:str):
if state == "enabled":
self.view_variable.VAR_VRC_MIC_MUTE_SYNC_STATE.set(i18n.t("main_window.state_text_enabled"))
vrct_gui.vrc_mic_mute_sync_settings_state_label.configure(text_color=self.settings.main.ctm.TOP_BAR_BUTTON_STATE_TEXT_ENABLED_COLOR)
elif state == "disabled":
self.view_variable.VAR_VRC_MIC_MUTE_SYNC_STATE.set(i18n.t("main_window.state_text_disabled"))
vrct_gui.vrc_mic_mute_sync_settings_state_label.configure(text_color=self.settings.main.ctm.TOP_BAR_BUTTON_STATE_TEXT_DISABLED_COLOR)
vrct_gui.config_window.after(200, vrct_gui.config_window.lift)
def setStateOverlaySmallLog(self, state:str):
if state == "enabled":
self.view_variable.VAR_OVERLAY_SMALL_LOG_STATE.set(i18n.t("main_window.state_text_enabled"))
vrct_gui.overlay_settings_state_label.configure(text_color=self.settings.main.ctm.TOP_BAR_BUTTON_STATE_TEXT_ENABLED_COLOR)
elif state == "disabled":
self.view_variable.VAR_OVERLAY_SMALL_LOG_STATE.set(i18n.t("main_window.state_text_disabled"))
vrct_gui.overlay_settings_state_label.configure(text_color=self.settings.main.ctm.TOP_BAR_BUTTON_STATE_TEXT_DISABLED_COLOR)
vrct_gui.config_window.after(200, vrct_gui.config_window.lift)
# Config Window
def enableConfigWindowCompactMode(self):
@@ -1734,7 +1810,10 @@ class View():
vrct_gui._closeConfigWindow()
def _openVrSettingsWindow(self):
vrct_gui.quick_settings_window.show()
vrct_gui.quick_settings_window.show(target="overlay")
def _openVrcMicMuteSyncSettingsWindow(self):
vrct_gui.quick_settings_window.show(target="vrc_mic_mute_sync")
# Window Control (Main Window Cover)
def _openTheCoverOfMainWindow(self):
@@ -1877,9 +1956,21 @@ class View():
self.view_variable.VAR_OVERLAY_SMALL_LOG_Y_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"])
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["y_pos"])
case "OverlaySmallLogDepth":
self.view_variable.VAR_OVERLAY_SMALL_LOG_DEPTH.set(config.OVERLAY_SMALL_LOG_SETTINGS["depth"])
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH.set(config.OVERLAY_SMALL_LOG_SETTINGS["depth"])
case "OverlaySmallLogZPos":
self.view_variable.VAR_OVERLAY_SMALL_LOG_Z_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"])
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["z_pos"])
case "OverlaySmallLogXRotation":
self.view_variable.VAR_OVERLAY_SMALL_LOG_X_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"])
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["x_rotation"])
case "OverlaySmallLogYRotation":
self.view_variable.VAR_OVERLAY_SMALL_LOG_Y_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"])
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["y_rotation"])
case "OverlaySmallLogZRotation":
self.view_variable.VAR_OVERLAY_SMALL_LOG_Z_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"])
self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_ROTATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["z_rotation"])
case "OverlaySmallLogDisplayDuration":
self.view_variable.VAR_OVERLAY_SMALL_LOG_DISPLAY_DURATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"])
@@ -1894,8 +1985,8 @@ class View():
# Print To Textbox.
# def printToTextbox_enableEasterEgg(self):
# self._printToTextbox_Info(i18n.t("main_window.textbox_system_message.enabled_easter_egg"))
def printToTextbox_enableEasterEgg(self):
self._printToTextbox_Info(i18n.t("main_window.textbox_system_message.enabled_easter_egg"))
def printToTextbox_enableTranslation(self):
self._printToTextbox_Info(i18n.t("main_window.textbox_system_message.enabled_translation"))

View File

@@ -31,28 +31,30 @@ class _PrintToTextbox():
self.textbox_font_size__main_text_font = None
self.all_textbox_widgets = [self.vrct_gui.textbox_all, self.vrct_gui.textbox_system, self.vrct_gui.textbox_sent, self.vrct_gui.textbox_received]
# self.all_textbox_widgets = [self.vrct_gui.textbox_all, self.vrct_gui.textbox_system, self.vrct_gui.textbox_sent, self.vrct_gui.textbox_received]
self.all_textbox_widgets = [self.vrct_gui.textbox_all]
self.setTagsSettings(self.init_scaling)
def printToTextbox(self, target_type, original_message=None, translated_message=None, to_print_to_textbox_all:bool=True):
self._printEachTextbox(
target_textbox=self._getTargetTextboxWidget(target_type),
print_type=target_type,
original_message=original_message,
translated_message=translated_message,
)
# [Deprecated] Print to textbox to only all-tab. sent received system tabs are deprecated.
# self._printEachTextbox(
# target_textbox=self._getTargetTextboxWidget(target_type),
# print_type=target_type,
# original_message=original_message,
# translated_message=translated_message,
# )
# To automatically print the same log to the textbox_all widget as well.
if to_print_to_textbox_all is True:
self._printEachTextbox(
target_textbox=self._getTargetTextboxWidget("ALL"),
print_type=target_type,
original_message=original_message,
translated_message=translated_message,
)
# if to_print_to_textbox_all is True:
self._printEachTextbox(
target_textbox=self._getTargetTextboxWidget("ALL"),
print_type=target_type,
original_message=original_message,
translated_message=translated_message,
)
def setTagsSettings(self, custom_font_size_scale:float=1.0):
# Calculate Textbox's ui size by default size * textbox_ui_scale
@@ -156,12 +158,12 @@ class _PrintToTextbox():
match (target_type):
case "ALL":
target_textbox = self.vrct_gui.textbox_all
case "SYSTEM":
target_textbox = self.vrct_gui.textbox_system
case "SENT":
target_textbox = self.vrct_gui.textbox_sent
case "RECEIVED":
target_textbox = self.vrct_gui.textbox_received
# case "SYSTEM":
# target_textbox = self.vrct_gui.textbox_system
# case "SENT":
# target_textbox = self.vrct_gui.textbox_sent
# case "RECEIVED":
# target_textbox = self.vrct_gui.textbox_received
case (_):
raise ValueError(f"No matching case for target_type: {target_type}")

View File

@@ -1,7 +1,7 @@
from customtkinter import CTkFont, CTkFrame, CTkLabel
def _createSettingBoxContainer(config_window, settings, view_variable, setting_box_container_settings):
def _createSettingBoxContainer(config_window, settings, view_variable, setting_box_container_settings, bottom_margin):
def createSectionTitle(container_widget, var_section_title):
@@ -22,7 +22,7 @@ def _createSettingBoxContainer(config_window, settings, view_variable, setting_b
# Setting box container
setting_box_container_widget = CTkFrame(config_window.main_setting_box_bg_wrapper, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
setattr(config_window, setting_box_container_settings["setting_box_container_attr_name"], setting_box_container_widget)
setting_box_container_widget.grid(row=0, pady=settings.uism.SB__BOTTOM_MARGIN)
setting_box_container_widget.grid(row=0, pady=bottom_margin)
setting_box_container_widget.grid_remove()

View File

@@ -52,7 +52,7 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl
config_window.main_setting_box_bg_wrapper = CTkFrame(config_window.main_setting_box_scrollable_container, corner_radius=0, width=0, height=0, fg_color=settings.ctm.MAIN_BG_COLOR)
config_window.main_setting_box_bg_wrapper.grid(row=0, column=0, pady=settings.uism.SB__BOTTOM_MARGIN, sticky="n")
config_window.main_setting_box_bg_wrapper.grid(row=0, column=0, pady=0, sticky="n")
@@ -104,21 +104,21 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl
]
},
},
# {
# "side_menu_tab_attr_name": "side_menu_tab_vr",
# "label_attr_name": "label_vr",
# "selected_mark_attr_name": "selected_mark_vr",
# "textvariable": view_variable.VAR_SIDE_MENU_LABEL_VR,
# "setting_box_container_settings": {
# "setting_box_container_attr_name": "setting_box_container_vr",
# "setting_boxes": [
# {
# "var_section_title": None,
# "setting_box": createSettingBox_Vr
# }
# ]
# },
# },
{
"side_menu_tab_attr_name": "side_menu_tab_vr",
"label_attr_name": "label_vr",
"selected_mark_attr_name": "selected_mark_vr",
"textvariable": view_variable.VAR_SIDE_MENU_LABEL_VR,
"setting_box_container_settings": {
"setting_box_container_attr_name": "setting_box_container_vr",
"setting_boxes": [
{
"var_section_title": None,
"setting_box": createSettingBox_Vr
}
]
},
},
{
"side_menu_tab_attr_name": "side_menu_tab_others",
"label_attr_name": "label_others",
@@ -187,12 +187,13 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings, view_variabl
side_menu_row+=1
bottom_margin = 0 if sm_and_sbc_setting["setting_box_container_settings"]["setting_box_container_attr_name"] == "setting_box_container_about_vrct" else settings.uism.SB__BOTTOM_MARGIN
_createSettingBoxContainer(
config_window=config_window,
settings=settings,
view_variable=view_variable,
setting_box_container_settings=sm_and_sbc_setting["setting_box_container_settings"],
bottom_margin=bottom_margin,
)

View File

@@ -11,13 +11,14 @@ poster_showcase_worlds_settings = [
{
"author_name": "miu_jepang",
"data": [
{ "image_file_name": "ippaidou.png", "x_post_num": None },
{ "image_file_name": "ippaidou.png", "x_post_num": "1787801976354513319" },
{ "image_file_name": "nihongokurabu.png", "x_post_num": "1779004631936614893" },
{ "image_file_name": "language_exchange_tervern.png", "x_post_num": "1779749425923150317" },
{ "image_file_name": "japanese_culture_osenbeito.png", "x_post_num": None },
{ "image_file_name": "silakan_datang_ke_rumahku.png", "x_post_num": None },
{ "image_file_name": "japanese_culture_osenbeito.png", "x_post_num": "1788522972409721137" },
{ "image_file_name": "silakan_datang_ke_rumahku.png", "x_post_num": "1788522607631056941" },
{ "image_file_name": "uj_club.png", "x_post_num": "1780791654196388201" },
{ "image_file_name": "sushi_stand_guruguru.png", "x_post_num": None },
{ "image_file_name": "sushi_stand_guruguru.png", "x_post_num": "1788523302404952218" },
{ "image_file_name": "sushi_guru_annex.png", "x_post_num": None },
]
},
@@ -76,7 +77,7 @@ poster_showcase_worlds_settings = [
{
"author_name": "chakamoto",
"data": [
{ "image_file_name": "coffee_keisyoku_chakachaka.png", "x_post_num": None },
{ "image_file_name": "chakachaka_multipurpose_room.png", "x_post_num": None },
]
},
@@ -84,7 +85,7 @@ poster_showcase_worlds_settings = [
{
"author_name": "yolm",
"data": [
{ "image_file_name": "cafe_cian.png", "x_post_num": None },
{ "image_file_name": "cafe_cian.png", "x_post_num": "1787802552907739504" },
]
},
@@ -108,7 +109,7 @@ poster_showcase_worlds_settings = [
{
"author_name": "1ban_meno",
"data": [
{ "image_file_name": "bar_asagao.png", "x_post_num": None },
{ "image_file_name": "bar_asagao.png", "x_post_num": "1788523857642758370" },
]
},
@@ -119,4 +120,29 @@ poster_showcase_worlds_settings = [
{ "image_file_name": "monogatari_meetup.png", "x_post_num": "1781538415789674976" },
]
},
# tommie_500
{
"author_name": "tommie_500",
"data": [
{ "image_file_name": "stretch_club_starting_from_minus.png", "x_post_num": None },
]
},
# MiMi_Sorahana # VRC日韓交流会 (KRJPEX.1355)
{
"author_name": "tommie_500",
"data": [
{ "image_file_name": "kr_jp_exchange.png", "x_post_num": None },
]
},
# Einアイン
{
"author_name": "ein",
"data": [
{ "image_file_name": "smokerz_guild_v2.png", "x_post_num": None },
]
},
]

View File

@@ -346,6 +346,9 @@ def createSettingBox_AboutVrct(setting_box_wrapper, config_window, settings, vie
goal_angle = 180
elif index == 2:
start_angle = 180
goal_angle = 270
elif index == 3:
start_angle = 270
goal_angle = 360
return(start_angle, goal_angle)
@@ -611,4 +614,4 @@ def createSettingBox_AboutVrct(setting_box_wrapper, config_window, settings, vie
vrchat_disclaimer_label = settings.about_vrct.embedImageCTkLabel(vrchat_disclaimer_contents_wrapper, "vrchat_disclaimer.png")
vrchat_disclaimer_label.grid(column=0, row=0, padx=0, pady=(about_vrct_uism.VRCHAT_DISCLAIMER_SECTION_TOP_PADDING, 0), sticky="nsew")
vrchat_disclaimer_label.grid(column=0, row=0, padx=0, pady=about_vrct_uism.VRCHAT_DISCLAIMER_SECTION_PADY, sticky="nsew")

View File

@@ -18,9 +18,6 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v
def checkboxSendMessageButtonTypeCallback():
callFunctionIfCallable(view_variable.CALLBACK_SET_SEND_MESSAGE_BUTTON_TYPE, view_variable.VAR_SEND_MESSAGE_BUTTON_TYPE.get())
def checkboxNoticeXsoverlayCallback(checkbox_box_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY, checkbox_box_widget.get())
def checkboxAutoExportMessageLogsCallback(checkbox_box_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_AUTO_EXPORT_MESSAGE_LOGS, checkbox_box_widget.get())
@@ -28,6 +25,9 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v
def buttonAutoExportMessageLogsCallback():
callFunctionIfCallable(view_variable.CALLBACK_OPEN_FILEPATH_LOGS)
def checkboxVrcMuteSyncCallback(checkbox_box_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_VRC_MIC_MUTE_SYNC, checkbox_box_widget.get())
def checkboxEnableSendMessageToVrcCallback(checkbox_box_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_SEND_MESSAGE_TO_VRC, checkbox_box_widget.get())
@@ -64,15 +64,6 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v
config_window.sb__send_message_button_type.grid(row=row)
row+=1
config_window.sb__notice_xsoverlay = createSettingBoxCheckbox(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_NOTICE_XSOVERLAY,
for_var_desc_text=view_variable.VAR_DESC_ENABLE_NOTICE_XSOVERLAY,
checkbox_attr_name="sb__checkbox_notice_xsoverlay",
command=lambda: checkboxNoticeXsoverlayCallback(config_window.sb__checkbox_notice_xsoverlay),
variable=view_variable.VAR_ENABLE_NOTICE_XSOVERLAY,
)
config_window.sb__notice_xsoverlay.grid(row=row)
row+=1
config_window.sb__auto_export_message_logs = createSettingBoxAutoExportMessageLogs(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_AUTO_EXPORT_MESSAGE_LOGS,
@@ -86,6 +77,17 @@ def createSettingBox_Others(setting_box_wrapper, config_window, settings, view_v
row+=1
config_window.sb__vrc_mic_mute_sync = createSettingBoxCheckbox(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_VRC_MIC_MUTE_SYNC,
for_var_desc_text=view_variable.VAR_DESC_ENABLE_VRC_MIC_MUTE_SYNC,
checkbox_attr_name="sb__checkbox_vrc_mic_mute_sync",
command=lambda: checkboxVrcMuteSyncCallback(config_window.sb__checkbox_vrc_mic_mute_sync),
variable=view_variable.VAR_ENABLE_VRC_MIC_MUTE_SYNC,
)
config_window.sb__vrc_mic_mute_sync.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,

View File

@@ -11,10 +11,13 @@ def createSettingBox_Vr(setting_box_wrapper, config_window, settings, view_varia
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG, switch_widget.get())
def buttonOpenOverlaySettingsWindow(_e):
print(_e)
callFunctionIfCallable(view_variable.CALLBACK_SET_OPEN_OVERLAY_SETTINGS_WINDOW)
def checkboxNoticeXsoverlayCallback(checkbox_box_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_NOTICE_XSOVERLAY, checkbox_box_widget.get())
row=0
config_window.sb__enable_overlay_small_log = createSettingBox_Overlay(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG,
@@ -26,4 +29,15 @@ def createSettingBox_Vr(setting_box_wrapper, config_window, settings, view_varia
label_button_clicked_command=buttonOpenOverlaySettingsWindow,
)
config_window.sb__enable_overlay_small_log.grid(row=row)
row+=1
config_window.sb__notice_xsoverlay = createSettingBoxCheckbox(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_NOTICE_XSOVERLAY,
for_var_desc_text=view_variable.VAR_DESC_ENABLE_NOTICE_XSOVERLAY,
checkbox_attr_name="sb__checkbox_notice_xsoverlay",
command=lambda: checkboxNoticeXsoverlayCallback(config_window.sb__checkbox_notice_xsoverlay),
variable=view_variable.VAR_ENABLE_NOTICE_XSOVERLAY,
)
config_window.sb__notice_xsoverlay.grid(row=row, pady=0)
row+=1

View File

@@ -48,59 +48,114 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable):
# start from 3
main_topbar_column=3
# # Overlay Settings Button
# vrct_gui.overlay_settings_container = CTkFrame(
# vrct_gui.main_topbar_container,
# corner_radius=settings.uism.UPDATE_AVAILABLE_BUTTON_CORNER_RADIUS,
# fg_color=settings.ctm.MAIN_BG_COLOR,
# cursor="hand2",
# )
# vrct_gui.overlay_settings_container.grid(row=0, column=main_topbar_column, padx=settings.uism.UPDATE_AVAILABLE_BUTTON_PADX, pady=settings.uism.TOP_BAR_BUTTON_PADY, sticky="nsw")
# # vrct_gui.overlay_settings_container.grid_remove()
# VRChat Mic Mute Sync Settings Button
vrct_gui.vrc_mic_mute_sync_settings_container = CTkFrame(
vrct_gui.main_topbar_container,
corner_radius=settings.uism.UPDATE_AVAILABLE_BUTTON_CORNER_RADIUS,
fg_color=settings.ctm.MAIN_BG_COLOR,
cursor="hand2",
)
vrct_gui.vrc_mic_mute_sync_settings_container.grid(row=0, column=main_topbar_column, padx=settings.uism.UPDATE_AVAILABLE_BUTTON_PADX, pady=settings.uism.TOP_BAR_BUTTON_PADY, sticky="nsw")
vrct_gui.vrc_mic_mute_sync_settings_container.grid_rowconfigure((0,3), weight=1)
vrct_gui.vrc_mic_mute_sync_settings_label = CTkLabel(
vrct_gui.vrc_mic_mute_sync_settings_container,
textvariable=view_variable.VAR_VRC_MIC_MUTE_SYNC_SETTINGS,
height=0,
corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.QUICK_SETTINGS_BUTTON_FONT_SIZE, weight="normal"),
anchor="e",
text_color=settings.ctm.TOP_BAR_BUTTON_TEXT_COLOR,
# text_color=settings.ctm.UPDATE_AVAILABLE_BUTTON_TEXT_COLOR,
)
# This "right padx +1" is for fixing a bug that sticks out from the frame. I don't know why that happens...
vrct_gui.vrc_mic_mute_sync_settings_label.grid(row=1, column=1, padx=(0,settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX+1), pady=0)
# vrct_gui.overlay_settings_container.grid_rowconfigure((0,2), weight=1)
# vrct_gui.overlay_settings_icon = CTkLabel(
# vrct_gui.overlay_settings_container,
# text=None,
# corner_radius=0,
# height=0,
# image=CTkImage(settings.image_file.CONFIGURATION_ICON_DISABLED, size=settings.uism.UPDATE_AVAILABLE_BUTTON_SIZE)
# )
# vrct_gui.overlay_settings_icon.grid(row=1, column=0, padx=(settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX, settings.uism.UPDATE_AVAILABLE_PADX_BETWEEN_LABEL_AND_ICON), pady=0)
vrct_gui.vrc_mic_mute_sync_settings_state_label = CTkLabel(
vrct_gui.vrc_mic_mute_sync_settings_container,
textvariable=view_variable.VAR_VRC_MIC_MUTE_SYNC_STATE,
height=0,
corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.QUICK_SETTINGS_BUTTON_STATE_FONT_SIZE, weight="normal"),
anchor="e",
text_color=settings.ctm.TOP_BAR_BUTTON_TEXT_COLOR,
# text_color=settings.ctm.UPDATE_AVAILABLE_BUTTON_TEXT_COLOR,
)
# This "right padx +1" is for fixing a bug that sticks out from the frame. I don't know why that happens...
vrct_gui.vrc_mic_mute_sync_settings_state_label.grid(row=2, column=1, padx=(0,settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX+1), pady=0)
# vrct_gui.overlay_settings_label = CTkLabel(
# vrct_gui.overlay_settings_container,
# textvariable=view_variable.VAR_OVERLAY_SETTINGS,
# height=0,
# corner_radius=0,
# font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.UPDATE_AVAILABLE_BUTTON_FONT_SIZE, weight="normal"),
# anchor="e",
# text_color=settings.ctm.TOP_BAR_BUTTON_TEXT_COLOR,
# # text_color=settings.ctm.UPDATE_AVAILABLE_BUTTON_TEXT_COLOR,
# )
# # This "right padx +1" is for fixing a bug that sticks out from the frame. I don't know why that happens...
# vrct_gui.overlay_settings_label.grid(row=1, column=1, padx=(0,settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX+1), pady=0)
# bindButtonFunctionAndColor(
# target_widgets=[
# vrct_gui.overlay_settings_container,
# vrct_gui.overlay_settings_label,
# vrct_gui.overlay_settings_icon,
# ],
# enter_color=settings.ctm.TOP_BAR_BUTTON_HOVERED_BG_COLOR,
# leave_color=settings.ctm.TOP_BAR_BUTTON_BG_COLOR,
# clicked_color=settings.ctm.TOP_BAR_BUTTON_CLICKED_BG_COLOR,
# buttonReleasedFunction=lambda e: callFunctionIfCallable(view_variable.CALLBACK_SET_OPEN_OVERLAY_SETTINGS_WINDOW),
# )
bindButtonFunctionAndColor(
target_widgets=[
vrct_gui.vrc_mic_mute_sync_settings_container,
vrct_gui.vrc_mic_mute_sync_settings_label,
vrct_gui.vrc_mic_mute_sync_settings_state_label,
],
enter_color=settings.ctm.TOP_BAR_BUTTON_HOVERED_BG_COLOR,
leave_color=settings.ctm.TOP_BAR_BUTTON_BG_COLOR,
clicked_color=settings.ctm.TOP_BAR_BUTTON_CLICKED_BG_COLOR,
buttonReleasedFunction=lambda e: callFunctionIfCallable(view_variable.CALLBACK_SET_OPEN_VRC_MIC_MUTE_SYNC_SETTINGS_WINDOW),
)
# main_topbar_column+=1
main_topbar_column+=1
# Overlay Settings Button
vrct_gui.overlay_settings_container = CTkFrame(
vrct_gui.main_topbar_container,
corner_radius=settings.uism.UPDATE_AVAILABLE_BUTTON_CORNER_RADIUS,
fg_color=settings.ctm.MAIN_BG_COLOR,
cursor="hand2",
)
vrct_gui.overlay_settings_container.grid(row=0, column=main_topbar_column, padx=settings.uism.UPDATE_AVAILABLE_BUTTON_PADX, pady=settings.uism.TOP_BAR_BUTTON_PADY, sticky="nsw")
vrct_gui.overlay_settings_container.grid_rowconfigure((0,3), weight=1)
vrct_gui.overlay_settings_label = CTkLabel(
vrct_gui.overlay_settings_container,
textvariable=view_variable.VAR_OVERLAY_SETTINGS,
height=0,
corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.QUICK_SETTINGS_BUTTON_FONT_SIZE, weight="normal"),
anchor="e",
text_color=settings.ctm.TOP_BAR_BUTTON_TEXT_COLOR,
# text_color=settings.ctm.UPDATE_AVAILABLE_BUTTON_TEXT_COLOR,
)
# This "right padx +1" is for fixing a bug that sticks out from the frame. I don't know why that happens...
vrct_gui.overlay_settings_label.grid(row=1, column=1, padx=(0,settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX+1), pady=0)
vrct_gui.overlay_settings_state_label = CTkLabel(
vrct_gui.overlay_settings_container,
textvariable=view_variable.VAR_OVERLAY_SMALL_LOG_STATE,
height=0,
corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.QUICK_SETTINGS_BUTTON_STATE_FONT_SIZE, weight="normal"),
anchor="e",
text_color=settings.ctm.TOP_BAR_BUTTON_TEXT_COLOR,
)
# This "right padx +1" is for fixing a bug that sticks out from the frame. I don't know why that happens...
vrct_gui.overlay_settings_state_label.grid(row=2, column=1, padx=(0,settings.uism.UPDATE_AVAILABLE_BUTTON_IPADX+1), pady=0)
bindButtonFunctionAndColor(
target_widgets=[
vrct_gui.overlay_settings_container,
vrct_gui.overlay_settings_label,
vrct_gui.overlay_settings_state_label,
],
enter_color=settings.ctm.TOP_BAR_BUTTON_HOVERED_BG_COLOR,
leave_color=settings.ctm.TOP_BAR_BUTTON_BG_COLOR,
clicked_color=settings.ctm.TOP_BAR_BUTTON_CLICKED_BG_COLOR,
buttonReleasedFunction=lambda e: callFunctionIfCallable(view_variable.CALLBACK_SET_OPEN_OVERLAY_SETTINGS_WINDOW),
)
main_topbar_column+=1
# Update Available Button
vrct_gui.update_available_container = CTkFrame(
vrct_gui.main_topbar_container,

View File

@@ -5,53 +5,53 @@ from ...ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButton
def createTextbox(settings, main_window, view_variable):
def switchTextbox(target_textbox_attr_name):
main_window.current_active_textbox.grid_remove()
main_window.current_active_textbox = getattr(main_window, target_textbox_attr_name)
main_window.current_active_textbox.grid()
# def switchTextbox(target_textbox_attr_name):
# main_window.current_active_textbox.grid_remove()
# main_window.current_active_textbox = getattr(main_window, target_textbox_attr_name)
# main_window.current_active_textbox.grid()
def switchToTextboxAll(e):
target_active_widget = getattr(main_window, "textbox_tab_all")
switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_all")
# def switchToTextboxAll(e):
# target_active_widget = getattr(main_window, "textbox_tab_all")
# switchTextboxTabFunction(target_active_widget)
# switchTextbox("textbox_all")
def switchToTextboxSent(e):
target_active_widget = getattr(main_window, "textbox_tab_sent")
switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_sent")
# def switchToTextboxSent(e):
# target_active_widget = getattr(main_window, "textbox_tab_sent")
# switchTextboxTabFunction(target_active_widget)
# switchTextbox("textbox_sent")
def switchToTextboxReceived(e):
target_active_widget = getattr(main_window, "textbox_tab_received")
switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_received")
# def switchToTextboxReceived(e):
# target_active_widget = getattr(main_window, "textbox_tab_received")
# switchTextboxTabFunction(target_active_widget)
# switchTextbox("textbox_received")
def switchToTextboxSystem(e):
target_active_widget = getattr(main_window, "textbox_tab_system")
switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_system")
# def switchToTextboxSystem(e):
# target_active_widget = getattr(main_window, "textbox_tab_system")
# switchTextboxTabFunction(target_active_widget)
# switchTextbox("textbox_system")
def switchTextboxTabFunction(target_active_widget):
switchActiveAndPassiveTextboxTabsColor(target_active_widget)
switchActiveTabAndPassiveTab(target_active_widget, main_window.current_active_textbox_tab, main_window.current_active_textbox_tab.passive_function, settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
main_window.current_active_textbox_tab = target_active_widget
# def switchTextboxTabFunction(target_active_widget):
# switchActiveAndPassiveTextboxTabsColor(target_active_widget)
# switchActiveTabAndPassiveTab(target_active_widget, main_window.current_active_textbox_tab, main_window.current_active_textbox_tab.passive_function, settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
# main_window.current_active_textbox_tab = target_active_widget
def switchActiveAndPassiveTextboxTabsColor(target_active_widget):
textbox_tabs = [
getattr(main_window, "textbox_tab_all"),
getattr(main_window, "textbox_tab_sent"),
getattr(main_window, "textbox_tab_received"),
getattr(main_window, "textbox_tab_system")
]
# def switchActiveAndPassiveTextboxTabsColor(target_active_widget):
# textbox_tabs = [
# getattr(main_window, "textbox_tab_all"),
# getattr(main_window, "textbox_tab_sent"),
# getattr(main_window, "textbox_tab_received"),
# getattr(main_window, "textbox_tab_system")
# ]
switchTabsColor(
target_widget=target_active_widget,
tab_buttons=textbox_tabs,
active_bg_color=settings.ctm.TEXTBOX_BG_COLOR,
active_text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR,
passive_bg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
passive_text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR
)
# switchTabsColor(
# target_widget=target_active_widget,
# tab_buttons=textbox_tabs,
# active_bg_color=settings.ctm.TEXTBOX_BG_COLOR,
# active_text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR,
# passive_bg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
# passive_text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR
# )
@@ -64,100 +64,101 @@ def createTextbox(settings, main_window, view_variable):
main_window.main_textbox_container.grid_columnconfigure(0,weight=1)
main_window.main_textbox_container.grid_rowconfigure(0,weight=1)
main_window.textbox_switch_tabs_container = CTkFrame(main_window.main_topbar_center_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
main_window.textbox_switch_tabs_container.place(relx=0.07, rely=1.15, anchor="sw")
# main_window.textbox_switch_tabs_container = CTkFrame(main_window.main_topbar_center_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
# main_window.textbox_switch_tabs_container.place(relx=0.07, rely=1.15, anchor="sw")
main_window.textbox_switch_tabs_container.grid_columnconfigure((0,1,2,3), weight=1, uniform="textbox_tabs")
# main_window.textbox_switch_tabs_container.grid_columnconfigure((0,1,2,3), weight=1, uniform="textbox_tabs")
textbox_settings = [
{
"textbox_tab_attr_name": "textbox_tab_all",
"command": switchToTextboxAll,
"textbox_attr_name": "textbox_all",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_ALL
},
{
"textbox_tab_attr_name": "textbox_tab_sent",
"command": switchToTextboxSent,
"textbox_attr_name": "textbox_sent",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_SENT
},
{
"textbox_tab_attr_name": "textbox_tab_received",
"command": switchToTextboxReceived,
"textbox_attr_name": "textbox_received",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_RECEIVED
},
{
"textbox_tab_attr_name": "textbox_tab_system",
"command": switchToTextboxSystem,
"textbox_attr_name": "textbox_system",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_SYSTEM
},
]
# textbox_settings = [
# {
# "textbox_tab_attr_name": "textbox_tab_all",
# "command": switchToTextboxAll,
# "textbox_attr_name": "textbox_all",
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_ALL
# },
# {
# "textbox_tab_attr_name": "textbox_tab_sent",
# "command": switchToTextboxSent,
# "textbox_attr_name": "textbox_sent",
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_SENT
# },
# {
# "textbox_tab_attr_name": "textbox_tab_received",
# "command": switchToTextboxReceived,
# "textbox_attr_name": "textbox_received",
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_RECEIVED
# },
# {
# "textbox_tab_attr_name": "textbox_tab_system",
# "command": switchToTextboxSystem,
# "textbox_attr_name": "textbox_system",
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_SYSTEM
# },
# ]
column=0
for textbox_setting in textbox_settings:
setattr(main_window, textbox_setting["textbox_tab_attr_name"],
CTkFrame(
main_window.textbox_switch_tabs_container,
corner_radius=settings.uism.TEXTBOX_TAB_CORNER_RADIUS,
fg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
cursor="hand2",
width=0,
height=0
)
)
target_widget = getattr(main_window, textbox_setting["textbox_tab_attr_name"])
target_widget.grid(row=0, column=column, pady=0, padx=(0,2), sticky="ew")
# column=0
# for textbox_setting in textbox_settings:
# setattr(main_window, textbox_setting["textbox_tab_attr_name"],
# CTkFrame(
# main_window.textbox_switch_tabs_container,
# corner_radius=settings.uism.TEXTBOX_TAB_CORNER_RADIUS,
# fg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
# cursor="hand2",
# width=0,
# height=0
# )
# )
# target_widget = getattr(main_window, textbox_setting["textbox_tab_attr_name"])
# target_widget.grid(row=0, column=column, pady=0, padx=(0,2), sticky="ew")
target_widget.grid_columnconfigure((0,2), weight=1)
setattr(main_window, "label_widget", CTkLabel(
target_widget,
textvariable=textbox_setting["textvariable"],
corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_TAB_FONT_SIZE, weight="normal"),
height=0,
width=0,
anchor="center",
text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR,
))
label_widget = getattr(main_window, "label_widget")
label_widget.grid(row=0, column=1, pady=settings.uism.TEXTBOX_TAB_PADY, padx=settings.uism.TEXTBOX_TAB_PADX)
# target_widget.grid_columnconfigure((0,2), weight=1)
# setattr(main_window, "label_widget", CTkLabel(
# target_widget,
# textvariable=textbox_setting["textvariable"],
# corner_radius=0,
# font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_TAB_FONT_SIZE, weight="normal"),
# height=0,
# width=0,
# anchor="center",
# text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR,
# ))
# label_widget = getattr(main_window, "label_widget")
# label_widget.grid(row=0, column=1, pady=settings.uism.TEXTBOX_TAB_PADY, padx=settings.uism.TEXTBOX_TAB_PADX)
bindEnterAndLeaveColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
bindButtonPressColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
# bindEnterAndLeaveColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
# bindButtonPressColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
target_widget.passive_function = textbox_setting["command"]
bindButtonReleaseFunction([target_widget, label_widget], textbox_setting["command"])
# target_widget.passive_function = textbox_setting["command"]
# bindButtonReleaseFunction([target_widget, label_widget], textbox_setting["command"])
setattr(main_window, textbox_setting["textbox_attr_name"], CTkTextbox(
main_window.main_textbox_container,
corner_radius=settings.uism.TEXTBOX_CORNER_RADIUS,
fg_color=settings.ctm.TEXTBOX_BG_COLOR,
text_color="lime", # Textbox's text_color is set when printing. so this is for prevent from non-setting text_color like the gloves used in food factories are blue.
wrap="word",
height=0,
))
textbox_widget = getattr(main_window, textbox_setting["textbox_attr_name"])
textbox_widget.grid(row=0, column=0, padx=settings.uism.TEXTBOX_PADX, pady=0, sticky="nsew")
textbox_widget.grid_remove()
textbox_widget.configure(state="disabled")
main_window.textbox_all = CTkTextbox(
main_window.main_textbox_container,
corner_radius=settings.uism.TEXTBOX_CORNER_RADIUS,
fg_color=settings.ctm.TEXTBOX_BG_COLOR,
text_color="lime", # Textbox's text_color is set when printing. so this is for prevent from non-setting text_color like the gloves used in food factories are blue.
wrap="word",
height=0,
)
# main_window.textbox_all = getattr(main_window, textbox_setting["textbox_attr_name"])
main_window.textbox_all.grid(row=0, column=0, padx=settings.uism.TEXTBOX_PADX, pady=0, sticky="nsew")
main_window.textbox_all.grid_remove()
main_window.textbox_all.configure(state="disabled")
column+=1
# column+=1
# Set default active textbox tab
main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all")
setDefaultActiveTab(
active_tab_widget=main_window.current_active_textbox_tab,
active_bg_color=settings.ctm.TEXTBOX_TAB_BG_ACTIVE_COLOR,
active_text_color=settings.ctm.TEXTBOX_TAB_TEXT_ACTIVE_COLOR
)
# main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all")
# setDefaultActiveTab(
# active_tab_widget=main_window.current_active_textbox_tab,
# active_bg_color=settings.ctm.TEXTBOX_TAB_BG_ACTIVE_COLOR,
# active_text_color=settings.ctm.TEXTBOX_TAB_TEXT_ACTIVE_COLOR
# )
main_window.current_active_textbox = getattr(main_window, "textbox_all")
main_window.current_active_textbox.grid()
# main_window.current_active_textbox = getattr(main_window, "textbox_all")
# main_window.current_active_textbox.grid()
main_window.textbox_all.grid()

View File

@@ -1,6 +1,6 @@
from utils import callFunctionIfCallable, floatToPctStr
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider
from customtkinter import CTkToplevel, CTkFrame
from ..ui_utils import getImagePath, setGeometryToCenterOfScreen, fadeInAnimation, createLabelButton
from ._CreateQuickSettingBox import _CreateQuickSettingBox
@@ -19,19 +19,23 @@ class QuickSettingsWindow(CTkToplevel):
self.configure(fg_color=self.settings.ctm.SB__BG_COLOR)
BG_HEX_COLOR = "#292a2d"
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1, minsize=400)
self.grid_rowconfigure(0, weight=1)
self.qsw_background = CTkFrame(self, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR)
self.qsw_background.grid(row=0, column=0, pady=(0,18), sticky="nsew")
self.qsw_background.grid_columnconfigure(0, weight=1)
self.qsw_setting_box = CTkFrame(self.qsw_background, corner_radius=0, fg_color=BG_HEX_COLOR)
self.qsw_setting_box.grid(row=0, column=0, sticky="nsew")
self.qsw_setting_box.grid_columnconfigure(0, weight=1)
self.qsw_background.grid(row=0, column=0, pady=0, sticky="ew")
self.qsw_background.grid_columnconfigure(0, weight=1, minsize=self.settings.uism.QSB__MIN_WIDTH)
cqsb = _CreateQuickSettingBox(self.qsw_setting_box, vrct_gui, settings, view_variable)
self.qsw_background__overlay = CTkFrame(self.qsw_background, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR)
self.qsw_background__overlay.grid(row=0, column=0, pady=self.settings.uism.QSB__BOX_PADY, sticky="ew")
self.qsw_background__overlay.grid_columnconfigure(0, weight=1)
self.qsw_setting_box__overlay = CTkFrame(self.qsw_background__overlay, corner_radius=0, fg_color=BG_HEX_COLOR)
self.qsw_setting_box__overlay.grid(row=0, column=0, sticky="ew")
self.qsw_setting_box__overlay.grid_columnconfigure(0, weight=1)
cqsb = _CreateQuickSettingBox(self.qsw_setting_box__overlay, vrct_gui, settings, view_variable)
createSettingBoxSlider = cqsb.createSettingBoxSlider
createSettingBoxSwitch = cqsb.createSettingBoxSwitch
@@ -41,20 +45,20 @@ class QuickSettingsWindow(CTkToplevel):
# Overlay General Settings
row=0
def switchCallback(switch_widget):
def overlaySmallLogSwitchCallback(switch_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_OVERLAY_SMALL_LOG, switch_widget.get())
self.qsb__enable_overlay_small_log = createSettingBoxSwitch(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_OVERLAY_SMALL_LOG,
switch_attr_name="qsb__enable_overlay_small_log_switch",
command=lambda: switchCallback(vrct_gui.qsb__enable_overlay_small_log_switch),
command=lambda: overlaySmallLogSwitchCallback(vrct_gui.qsb__enable_overlay_small_log_switch),
variable=view_variable.VAR_ENABLE_OVERLAY_SMALL_LOG,
)
self.qsb__enable_overlay_small_log.grid(row=row)
row+=1
def sliderCallback(e):
def overlayOpacitySliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SETTINGS, value, "opacity")
view_variable.VAR_CURRENT_VALUE_OVERLAY_OPACITY.set(floatToPctStr(value))
@@ -65,14 +69,14 @@ class QuickSettingsWindow(CTkToplevel):
slider_attr_name="qsb__overlay_opacity_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_OPACITY,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_OPACITY,
command=sliderCallback,
command=overlayOpacitySliderCallback,
variable=view_variable.VAR_OVERLAY_OPACITY,
)
self.qsb__overlay_opacity.grid(row=row)
row+=1
def sliderCallback(e):
def overlayUiScalingSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SETTINGS, value, "ui_scaling")
view_variable.VAR_CURRENT_VALUE_OVERLAY_UI_SCALING.set(floatToPctStr(value))
@@ -83,7 +87,7 @@ class QuickSettingsWindow(CTkToplevel):
slider_attr_name="qsb__overlay_ui_scaling_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_UI_SCALING,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_UI_SCALING,
command=sliderCallback,
command=overlayUiScalingSliderCallback,
variable=view_variable.VAR_OVERLAY_UI_SCALING,
)
self.qsb__overlay_ui_scaling.grid(row=row)
@@ -107,7 +111,7 @@ class QuickSettingsWindow(CTkToplevel):
row+=1
def sliderCallback(e):
def overlaySmallLogSettingsXPosSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "x_pos")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_POS.set(str(value))
@@ -118,14 +122,14 @@ class QuickSettingsWindow(CTkToplevel):
slider_attr_name="qsb__overlay_small_log_settings_x_pos_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_X_POS,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_POS,
command=sliderCallback,
command=overlaySmallLogSettingsXPosSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_X_POS,
)
self.qsb__overlay_small_log_settings_x_pos.grid(row=row)
row+=1
def sliderCallback(e):
def overlaySmallLogSettingsYPosSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "y_pos")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_POS.set(str(value))
@@ -136,32 +140,90 @@ class QuickSettingsWindow(CTkToplevel):
slider_attr_name="qsb__overlay_small_log_settings_y_pos_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_POS,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_POS,
command=sliderCallback,
command=overlaySmallLogSettingsYPosSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_Y_POS,
)
self.qsb__overlay_small_log_settings_y_pos.grid(row=row)
row+=1
def sliderCallback(e):
def overlaySmallLogSettingsZPosSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "depth")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH.set(str(value))
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "z_pos")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS.set(str(value))
self.qsb__overlay_small_log_settings_depth = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_DEPTH,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DEPTH,
slider_attr_name="qsb__overlay_small_log_settings_depth_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_DEPTH,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DEPTH,
command=sliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_DEPTH,
self.qsb__overlay_small_log_settings_z_pos = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_Z_POS,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_POS,
slider_attr_name="qsb__overlay_small_log_settings_z_pos_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_POS,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_POS,
command=overlaySmallLogSettingsZPosSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_Z_POS,
)
self.qsb__overlay_small_log_settings_depth.grid(row=row)
self.qsb__overlay_small_log_settings_z_pos.grid(row=row)
row+=1
def sliderCallback(e):
def overlaySmallLogSettingsXRotationSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "x_rotation")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_ROTATION.set(str(value))
self.qsb__overlay_small_log_settings_x_rotation = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_X_ROTATION,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_ROTATION,
slider_attr_name="qsb__overlay_small_log_settings_x_rotation_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_X_ROTATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_X_ROTATION,
command=overlaySmallLogSettingsXRotationSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_X_ROTATION,
)
self.qsb__overlay_small_log_settings_x_rotation.grid(row=row)
row+=1
def overlaySmallLogSettingsYRotationSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "y_rotation")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_ROTATION.set(str(value))
self.qsb__overlay_small_log_settings_y_rotation = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_Y_ROTATION,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Y_ROTATION,
slider_attr_name="qsb__overlay_small_log_settings_y_rotation_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_ROTATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_ROTATION,
command=overlaySmallLogSettingsYRotationSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_Y_ROTATION,
)
self.qsb__overlay_small_log_settings_y_rotation.grid(row=row)
row+=1
def overlaySmallLogSettingsZRotationSliderCallback(e):
value = round(e,2)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "z_rotation")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_ROTATION.set(str(value))
self.qsb__overlay_small_log_settings_z_rotation = createSettingBoxSlider(
for_var_label_text=view_variable.VAR_LABEL_OVERLAY_SMALL_LOG_Z_ROTATION,
for_var_current_value=view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_Z_ROTATION,
slider_attr_name="qsb__overlay_small_log_settings_z_rotation_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_Z_ROTATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Z_ROTATION,
command=overlaySmallLogSettingsZRotationSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_Z_ROTATION,
)
self.qsb__overlay_small_log_settings_z_rotation.grid(row=row)
row+=1
def overlaySmallLogSettingsDisplayDurationSliderCallback(e):
value = int(e)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "display_duration")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DISPLAY_DURATION.set(f"{value} second(s)")
@@ -172,7 +234,7 @@ class QuickSettingsWindow(CTkToplevel):
slider_attr_name="qsb__overlay_small_log_settings_display_duration_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
command=sliderCallback,
command=overlaySmallLogSettingsDisplayDurationSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_DISPLAY_DURATION,
)
self.qsb__overlay_small_log_settings_display_duration.grid(row=row)
@@ -180,7 +242,7 @@ class QuickSettingsWindow(CTkToplevel):
row+=1
def sliderCallback(e):
def overlaySmallLogSettingsFadeoutDurationSliderCallback(e):
value = int(e)
callFunctionIfCallable(view_variable.CALLBACK_SET_OVERLAY_SMALL_LOG_SETTINGS, value, "fadeout_duration")
view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_FADEOUT_DURATION.set(f"{value} second(s)")
@@ -191,7 +253,7 @@ class QuickSettingsWindow(CTkToplevel):
slider_attr_name="qsb__overlay_small_log_settings_fadeout_duration_slider",
slider_range=view_variable.SLIDER_RANGE_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
slider_number_of_steps=view_variable.NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
command=sliderCallback,
command=overlaySmallLogSettingsFadeoutDurationSliderCallback,
variable=view_variable.VAR_OVERLAY_SMALL_LOG_FADEOUT_DURATION,
)
self.qsb__overlay_small_log_settings_fadeout_duration.grid(row=row)
@@ -204,7 +266,7 @@ class QuickSettingsWindow(CTkToplevel):
self.qsw_setting_box_bottom = CTkFrame(self.qsw_background, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR)
self.qsw_setting_box_bottom = CTkFrame(self.qsw_background__overlay, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR)
self.qsw_setting_box_bottom.grid(row=1, column=0, sticky="nsew")
self.qsw_setting_box_bottom.grid_columnconfigure((0,2), weight=1)
@@ -236,9 +298,67 @@ class QuickSettingsWindow(CTkToplevel):
)
restore_default_settings_button.grid(row=0, column=0, pady=self.settings.uism.QSB__RESTORE_DEFAULT_SETTINGS_BUTTON_PADY)
self.qsw_background__overlay.grid_remove()
# VRChat mic mute sync
self.qsw_background__vrc_mic_mute_sync = CTkFrame(self.qsw_background, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR)
self.qsw_background__vrc_mic_mute_sync.grid(row=0, column=0, pady=self.settings.uism.QSB__BOX_PADY, sticky="ew")
self.qsw_background__vrc_mic_mute_sync.grid_columnconfigure(0, weight=1)
self.qsw_setting_box__vrc_mic_mute_sync = CTkFrame(self.qsw_background__vrc_mic_mute_sync, corner_radius=0, fg_color=BG_HEX_COLOR)
self.qsw_setting_box__vrc_mic_mute_sync.grid(row=0, column=0, sticky="ew")
self.qsw_setting_box__vrc_mic_mute_sync.grid_columnconfigure(0, weight=1)
cqsb = _CreateQuickSettingBox(self.qsw_setting_box__vrc_mic_mute_sync, vrct_gui, settings, view_variable)
createSettingBoxSlider = cqsb.createSettingBoxSlider
createSettingBoxSwitch = cqsb.createSettingBoxSwitch
row=0
def enableVrcMicMuteSyncSwitchCallback(switch_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_ENABLE_VRC_MIC_MUTE_SYNC, switch_widget.get())
self.qsb__enable_vrc_mic_mute_sync = createSettingBoxSwitch(
for_var_label_text=view_variable.VAR_LABEL_ENABLE_VRC_MIC_MUTE_SYNC,
switch_attr_name="qsb__enable_vrc_mic_mute_sync_switch",
command=lambda: enableVrcMicMuteSyncSwitchCallback(vrct_gui.qsb__enable_vrc_mic_mute_sync_switch),
variable=view_variable.VAR_ENABLE_VRC_MIC_MUTE_SYNC,
)
self.qsb__enable_vrc_mic_mute_sync.grid(row=row)
self.qsw_background__vrc_mic_mute_sync.grid_remove()
def show(self, target:str):
if target == "overlay":
self.qsw_background__vrc_mic_mute_sync.grid_remove()
self.qsw_background__overlay.grid()
elif target == "vrc_mic_mute_sync":
self.qsw_background__overlay.grid_remove()
self.qsw_background__vrc_mic_mute_sync.grid()
def show(self):
self.attributes("-alpha", 0)
self.deiconify()
self.qsw_background.update()
self.geometry("{}x{}".format(self.qsw_background.winfo_width(), self.qsw_background.winfo_height()))
setGeometryToCenterOfScreen(root_widget=self)
fadeInAnimation(self, steps=5, interval=0.02)

View File

@@ -1,9 +1,5 @@
from typing import Union
from utils import callFunctionIfCallable
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider, CTkFont, CTkSwitch
from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation
from customtkinter import CTkLabel, CTkFrame, CTkSlider, CTkFont, CTkSwitch
class _CreateQuickSettingBox():
def __init__(self, parent_frame, vrct_gui, settings, view_variable):
@@ -13,13 +9,6 @@ class _CreateQuickSettingBox():
self.parent_frame = parent_frame
def _createSettingBoxFrame(self, for_var_label_text=None, for_var_current_value=None):
setting_box_frame = CTkFrame(self.parent_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0)
@@ -63,10 +52,6 @@ class _CreateQuickSettingBox():
# Items
setting_box_item_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.settings.ctm.SB__BG_COLOR)
setting_box_item_frame.grid(row=1, column=0, padx=0, sticky="nsew")
@@ -81,16 +66,6 @@ class _CreateQuickSettingBox():
def createSettingBoxSlider(
self,
for_var_label_text,

View File

@@ -221,7 +221,7 @@ class SplashWindow(CTkToplevel):
)
self.weight_download_progressbar_widget.configure(progress_color=progress_color)
self.weight_download_progressbar_widget.set(progress)
self.update_idletasks()
self.update()
def showSplash(self):

View File

@@ -1,7 +1,7 @@
from types import SimpleNamespace
from ..ui_utils import calculateUiSize, getImageFileFromUiUtils_AboutVrct, bindButtonReleaseFunction, createButtonWithImage, bindButtonFunctionAndColor
from customtkinter import CTkFrame, CTkLabel, CTkImage, CTkFont
from ..ui_utils import calculateUiSize, getImageFileFromUiUtils_AboutVrct, bindButtonFunctionAndColor
from customtkinter import CTkFrame, CTkLabel, CTkImage
IMAGE_STANDARD_SCALING = 2
class AboutVrctManager():
@@ -17,7 +17,7 @@ class AboutVrctManager():
self.uism.SECTION_BOTTOM_PADY = self._calculateUiSize(22)
self.uism.PROJECT_LINKS_SECTION_BOTTOM_PADDING = self._calculateUiSize(18) # Exception pady
self.uism.VRCHAT_DISCLAIMER_SECTION_TOP_PADDING = self._calculateUiSize(80) # Exception pady
self.uism.VRCHAT_DISCLAIMER_SECTION_PADY = (self._calculateUiSize(80), self._calculateUiSize(20)) # Exception pady
self.uism.THE_DEVELOPERS_SECTION_TITLE_BOTTOM_PADY = self._calculateUiSize(8)
self.uism.DEVS_CONTACTS_Y1 = self._calculateUiSize(118)

View File

@@ -111,6 +111,8 @@ def _darkTheme(base_color):
TOP_BAR_BUTTON_HOVERED_BG_COLOR = base_color.DARK_850_COLOR,
TOP_BAR_BUTTON_CLICKED_BG_COLOR = base_color.DARK_900_COLOR,
TOP_BAR_BUTTON_TEXT_COLOR = base_color.DARK_BASIC_TEXT_COLOR,
TOP_BAR_BUTTON_STATE_TEXT_ENABLED_COLOR = base_color.PRIMARY_300_COLOR,
TOP_BAR_BUTTON_STATE_TEXT_DISABLED_COLOR = base_color.DARK_600_COLOR,
UPDATE_AVAILABLE_BUTTON_BG_COLOR = base_color.DARK_888_COLOR,
UPDATE_AVAILABLE_BUTTON_HOVERED_BG_COLOR = base_color.DARK_850_COLOR,

View File

@@ -111,6 +111,8 @@ def _lightTheme(base_color):
TOP_BAR_BUTTON_HOVERED_BG_COLOR = base_color.LIGHT_300_COLOR,
TOP_BAR_BUTTON_CLICKED_BG_COLOR = base_color.LIGHT_350_COLOR,
TOP_BAR_BUTTON_TEXT_COLOR = base_color.LIGHT_BASIC_TEXT_COLOR,
TOP_BAR_BUTTON_STATE_TEXT_ENABLED_COLOR = base_color.PRIMARY_400_COLOR,
TOP_BAR_BUTTON_STATE_TEXT_DISABLED_COLOR = base_color.LIGHT_600_COLOR,
UPDATE_AVAILABLE_BUTTON_TEXT_COLOR = base_color.PRIMARY_400_COLOR,
),

View File

@@ -123,6 +123,13 @@ class UiScalingManager():
self.main.TOP_BAR_BUTTON_PADY = (self._calculateUiSize(6),0)
self.main.QUICK_SETTINGS_BUTTON_FONT_SIZE = self._calculateUiSize(12)
self.main.QUICK_SETTINGS_BUTTON_STATE_FONT_SIZE = self._calculateUiSize(10)
self.main.UPDATE_AVAILABLE_BUTTON_CORNER_RADIUS = self._calculateUiSize(6)
self.main.UPDATE_AVAILABLE_BUTTON_SIZE = (self._calculateUiSize(18), self._calculateUiSize(18))
self.main.UPDATE_AVAILABLE_BUTTON_FONT_SIZE = self._calculateUiSize(12)
@@ -195,6 +202,8 @@ class UiScalingManager():
# Quick Settings Box
self.config_window.QSB__MIN_WIDTH = self._calculateUiSize(400)
self.config_window.QSB__BOX_PADY = (0, self._calculateUiSize(18))
self.config_window.QSB__IPADX = self._calculateUiSize(20)
self.config_window.QSB__IPADY = (self._calculateUiSize(14), self._calculateUiSize(8))
self.config_window.QSB__LABEL_BOTTOM_PADY = self._calculateUiSize(6)
@@ -255,7 +264,7 @@ class UiScalingManager():
self.config_window.SB__IPADX = self._calculateUiSize(20)
self.config_window.SB__IPADY = self._calculateUiSize(12)
self.config_window.SB__BOTTOM_MARGIN = (0, self._calculateUiSize(60))
self.config_window.SB__BOTTOM_MARGIN = (0, self._calculateUiSize(120))
self.config_window.SB__FAKE_BOTTOM_BORDER_SIZE = (0, self._calculateUiSize(1, is_allowed_odd=True))
self.config_window.SB__SECTION_TITLE_FONT_SIZE = self._calculateUiSize(20)

View File

@@ -14,7 +14,7 @@ from ._PrintToTextbox import _PrintToTextbox
from .main_window import createMainWindowWidgets
from .config_window import ConfigWindow
# from .quick_settings_window import QuickSettingsWindow
from .quick_settings_window import QuickSettingsWindow
from .ui_utils import setDefaultActiveTab, setGeometryToCenterOfScreen, fadeInAnimation
from utils import callFunctionIfCallable
@@ -131,12 +131,11 @@ class VRCT_GUI(CTk):
view_variable=self._view_variable
)
# self.quick_settings_window = QuickSettingsWindow(
# vrct_gui=self,
# settings=self.settings.config_window,
# view_variable=self._view_variable
# )
# self.quick_settings_window.show()
self.quick_settings_window = QuickSettingsWindow(
vrct_gui=self,
settings=self.settings.config_window,
view_variable=self._view_variable
)
self.selectable_languages_window = _CreateSelectableLanguagesWindow(
vrct_gui=self,