[Update] Overlay Settings:

初期値に戻すボタンと機能を追加。
y_posの設定可能範囲を増やした。
padding調整など。
This commit is contained in:
Sakamoto Shiina
2024-04-27 00:46:41 +09:00
parent 0026102f45
commit a43f089adb
7 changed files with 137 additions and 14 deletions

View File

@@ -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

View File

@@ -65,6 +65,10 @@ selectable_language_window:
go_back_button: 戻る
overlay_settings:
restore_default_settings: 初期値に戻す
config_window:
config_title: 設定
compact_mode: コンパクトモード

69
view.py
View File

@@ -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}")

View File

@@ -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),
)

View File

@@ -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()

View File

@@ -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)

View File

@@ -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)