From a43f089adb2aa48fbec19fd170572a8f9cb28450 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 27 Apr 2024 00:46:41 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20Overlay=20Settings:=20=E5=88=9D?= =?UTF-8?q?=E6=9C=9F=E5=80=A4=E3=81=AB=E6=88=BB=E3=81=99=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=81=A8=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82=20y=5Fpos=E3=81=AE=E8=A8=AD=E5=AE=9A=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=AF=84=E5=9B=B2=E3=82=92=E5=A2=97=E3=82=84=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82=20padding=E8=AA=BF=E6=95=B4=E3=81=AA?= =?UTF-8?q?=E3=81=A9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en.yml | 4 ++ locales/ja.yml | 4 ++ view.py | 69 +++++++++++++++++-- .../main_window/createMainWindowWidgets.py | 4 +- .../QuickSettingsWindow.py | 54 +++++++++++++-- .../_CreateQuickSettingBox.py | 6 +- vrct_gui/ui_managers/UiScalingManager.py | 10 +++ 7 files changed, 137 insertions(+), 14 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 9718045e..cdb3434f 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -66,6 +66,10 @@ selectable_language_window: go_back_button: Go Back +overlay_settings: + restore_default_settings: Restore Default Settings + + config_window: config_title: Settings compact_mode: Compact Mode diff --git a/locales/ja.yml b/locales/ja.yml index e89bfdba..e2dd5db9 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -65,6 +65,10 @@ selectable_language_window: go_back_button: 戻る +overlay_settings: + restore_default_settings: 初期値に戻す + + config_window: config_title: 設定 compact_mode: コンパクトモード diff --git a/view.py b/view.py index f7a4af37..874bab47 100644 --- a/view.py +++ b/view.py @@ -140,8 +140,10 @@ class View(): # Overlay Settings - VAR_VR_SETTINGS=StringVar(value="Overlay Settings"), - CALLBACK_SET_CALLBACK_OPEN_VR_SETTINGS_WINDOW=self._openVrSettingsWindow, + 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_LABEL_OVERLAY_OPACITY=StringVar(value="Opacity"), @@ -167,8 +169,8 @@ class View(): 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="Y_position"), - SLIDER_RANGE_OVERLAY_SMALL_LOG_Y_POS=(-0.5, 0.5), - NUMBER_OF_STEPS_OVERLAY_SMALL_LOG_Y_POS=100, + 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"]), @@ -1110,6 +1112,34 @@ class View(): DICT_DATA["large-v3"]: callI18n("large-v3", "2.87GB"), } + + 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) + + 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("OverlaySmallLogXPos") + self.setLatestConfigVariable("OverlaySmallLogYPos") + self.setLatestConfigVariable("OverlaySmallLogDepth") + self.setLatestConfigVariable("OverlaySmallLogDisplayDuration") + self.setLatestConfigVariable("OverlaySmallLogFadeoutDuration") + # Open Webpage Functions def openWebPage_Booth(self): self.openWebPage(config.BOOTH_URL) @@ -1827,6 +1857,37 @@ class View(): case "ReceivedMessageFormatWithT": self.setReceivedMessageFormatWithT_EntryWidgets(config.RECEIVED_MESSAGE_FORMAT_WITH_T) + + + case "OverlayOpacity": + self.view_variable.VAR_OVERLAY_OPACITY.set(config.OVERLAY_SETTINGS["opacity"]) + self.view_variable.VAR_CURRENT_VALUE_OVERLAY_OPACITY.set(floatToPctStr(config.OVERLAY_SETTINGS["opacity"])) + + case "OverlayUiScaling": + self.view_variable.VAR_OVERLAY_UI_SCALING.set(config.OVERLAY_SETTINGS["ui_scaling"]) + self.view_variable.VAR_CURRENT_VALUE_OVERLAY_UI_SCALING.set(floatToPctStr(config.OVERLAY_SETTINGS["ui_scaling"])) + + + case "OverlaySmallLogXPos": + self.view_variable.VAR_OVERLAY_SMALL_LOG_X_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]) + self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_X_POS.set(config.OVERLAY_SMALL_LOG_SETTINGS["x_pos"]) + + case "OverlaySmallLogYPos": + 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 "OverlaySmallLogDisplayDuration": + self.view_variable.VAR_OVERLAY_SMALL_LOG_DISPLAY_DURATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["display_duration"]) + self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_DISPLAY_DURATION.set(f"{config.OVERLAY_SMALL_LOG_SETTINGS['display_duration']} second(s)") + + case "OverlaySmallLogFadeoutDuration": + self.view_variable.VAR_OVERLAY_SMALL_LOG_FADEOUT_DURATION.set(config.OVERLAY_SMALL_LOG_SETTINGS["fadeout_duration"]) + self.view_variable.VAR_CURRENT_VALUE_OVERLAY_SMALL_LOG_FADEOUT_DURATION.set(f"{config.OVERLAY_SMALL_LOG_SETTINGS['fadeout_duration']} second(s)") + case _: raise ValueError(f"No matching case for target_name: {target_name}") diff --git a/vrct_gui/main_window/createMainWindowWidgets.py b/vrct_gui/main_window/createMainWindowWidgets.py index 110e9cd1..447dfb1d 100644 --- a/vrct_gui/main_window/createMainWindowWidgets.py +++ b/vrct_gui/main_window/createMainWindowWidgets.py @@ -73,7 +73,7 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable): vrct_gui.overlay_settings_label = CTkLabel( vrct_gui.overlay_settings_container, - textvariable=view_variable.VAR_VR_SETTINGS, + 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"), @@ -94,7 +94,7 @@ def createMainWindowWidgets(vrct_gui, settings, view_variable): 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_CALLBACK_OPEN_VR_SETTINGS_WINDOW), + buttonReleasedFunction=lambda e: callFunctionIfCallable(view_variable.CALLBACK_SET_OPEN_OVERLAY_SETTINGS_WINDOW), ) diff --git a/vrct_gui/quick_settings_window/QuickSettingsWindow.py b/vrct_gui/quick_settings_window/QuickSettingsWindow.py index 08d7ff6b..8ea84cbb 100644 --- a/vrct_gui/quick_settings_window/QuickSettingsWindow.py +++ b/vrct_gui/quick_settings_window/QuickSettingsWindow.py @@ -1,7 +1,7 @@ from utils import callFunctionIfCallable, floatToPctStr from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame, CTkSlider -from ..ui_utils import getImagePath, setGeometryToCenterOfScreen, fadeInAnimation +from ..ui_utils import getImagePath, setGeometryToCenterOfScreen, fadeInAnimation, createLabelButton from ._CreateQuickSettingBox import _CreateQuickSettingBox @@ -9,7 +9,6 @@ class QuickSettingsWindow(CTkToplevel): def __init__(self, vrct_gui, settings, view_variable): super().__init__() self.withdraw() - self.configure(fg_color="#292a2d") self.title("Overlay Settings") self.protocol("WM_DELETE_WINDOW", self.withdraw) self.after(200, lambda: self.iconbitmap(getImagePath("vrct_logo_mark_black.ico"))) @@ -17,17 +16,22 @@ class QuickSettingsWindow(CTkToplevel): self.settings = settings + self.configure(fg_color=self.settings.ctm.SB__BG_COLOR) BG_HEX_COLOR = "#292a2d" self.grid_columnconfigure(0, weight=1, minsize=400) self.grid_rowconfigure(0, weight=1) - self.qsw_background = CTkFrame(self, corner_radius=0, fg_color=BG_HEX_COLOR) - self.qsw_background.grid(sticky="nsew") + 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) - cqsb = _CreateQuickSettingBox(self.qsw_background, vrct_gui, settings, view_variable) + + cqsb = _CreateQuickSettingBox(self.qsw_setting_box, vrct_gui, settings, view_variable) createSettingBoxSlider = cqsb.createSettingBoxSlider createSettingBoxSwitch = cqsb.createSettingBoxSwitch @@ -197,6 +201,46 @@ 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.grid(row=1, column=0, sticky="nsew") + + self.qsw_setting_box_bottom.grid_columnconfigure((0,2), weight=1) + self.qsw_setting_box_bottom.grid_rowconfigure((0,2), weight=1) + + self.qsw_setting_box_bottom_restore_default_button = CTkFrame(self.qsw_setting_box_bottom, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR) + self.qsw_setting_box_bottom_restore_default_button.grid(row=1, column=1, sticky="nsew") + + + def toDefaultOverlaySettingsCallback(_e): + callFunctionIfCallable(view_variable.CALLBACK_SET_TO_DEFAULT_OVERLAY_SETTINGS) + + + + (restore_default_settings_button, label_button_label_widget) = createLabelButton( + parent_widget=self.qsw_setting_box_bottom_restore_default_button, + label_button_bg_color=self.settings.ctm.SB__BUTTON_COLOR, + label_button_hovered_bg_color=self.settings.ctm.SB__BUTTON_HOVERED_COLOR, + label_button_clicked_bg_color=self.settings.ctm.SB__BUTTON_CLICKED_COLOR, + label_button_ipadx=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IPADX, + label_button_ipady=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IPADY, + variable=view_variable.VAR_TO_DEFAULT_OVERLAY_SETTINGS, + font_family=self.settings.FONT_FAMILY, + font_size=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_LABEL_FONT_SIZE, + text_color=self.settings.ctm.LABELS_TEXT_COLOR, + label_button_clicked_command=toDefaultOverlaySettingsCallback, + + label_button_position="center", + + # image_file=image_file, + image_size=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IMG_SIZE, + label_button_padx_between_img=self.settings.uism.SB__AUTHKEY_WEBPAGE_PADX_BETWEEN_LABEL_AND_ICON, + ) + restore_default_settings_button.grid(row=0, column=0, pady=self.settings.uism.QSB__RESTORE_DEFAULT_SETTINGS_BUTTON_PADY) + + def show(self): self.attributes("-alpha", 0) self.deiconify() diff --git a/vrct_gui/quick_settings_window/_CreateQuickSettingBox.py b/vrct_gui/quick_settings_window/_CreateQuickSettingBox.py index 2a4ec2d1..e2bbe271 100644 --- a/vrct_gui/quick_settings_window/_CreateQuickSettingBox.py +++ b/vrct_gui/quick_settings_window/_CreateQuickSettingBox.py @@ -23,18 +23,18 @@ class _CreateQuickSettingBox(): 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) - setting_box_frame.grid(row=0, column=0, sticky="ew") + setting_box_frame.grid(row=0, column=0, pady=(0,1), sticky="ew") setting_box_frame.grid_columnconfigure(0, weight=1) setting_box_frame_wrapper = CTkFrame(setting_box_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) - setting_box_frame_wrapper.grid(row=0, column=0, padx=self.settings.uism.SB__IPADX, pady=self.settings.uism.SB__IPADY, sticky="nsew") + setting_box_frame_wrapper.grid(row=0, column=0, padx=self.settings.uism.QSB__IPADX, pady=self.settings.uism.QSB__IPADY, sticky="nsew") setting_box_frame_wrapper.grid_columnconfigure(0, weight=1) # Labels setting_box_labels_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) - setting_box_labels_frame.grid(row=0, column=0, padx=0, pady=0, sticky="nsew") + setting_box_labels_frame.grid(row=0, column=0, padx=0, pady=(0,self.settings.uism.QSB__LABEL_BOTTOM_PADY), sticky="nsew") setting_box_labels_frame.grid_rowconfigure((0,2), weight=1) setting_box_labels_frame.grid_columnconfigure(1, weight=1) diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index 55ad0c43..ad868054 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -192,6 +192,16 @@ class UiScalingManager(): # Dropdown Menu Window self.dropdown_menu_window.MARGIN_WIDTH = self._calculateUiSize(16) + + + # Quick Settings Box + self.config_window.QSB__IPADX = self._calculateUiSize(20) + self.config_window.QSB__IPADY = (self._calculateUiSize(12), self._calculateUiSize(8)) + self.config_window.QSB__LABEL_BOTTOM_PADY = self._calculateUiSize(6) + self.config_window.QSB__RESTORE_DEFAULT_SETTINGS_BUTTON_PADY = (self._calculateUiSize(40),0) + + + # Config Window self.config_window.DEFAULT_WIDTH = self._calculateUiSize(1080) self.config_window.DEFAULT_HEIGHT = self._calculateUiSize(680)