[Update] 使用ディスプレイサイズの大きさ(高さ)より、VRCT起動時のウィンドウの方が大きい場合の対応。UI Scalingを20%下げて再起動するかどうかの確認モーダルを表示。

それにともない確認モーダルの汎用化。
さらにそれに伴い計算の都合上UI Scalingが40%から200%で10%刻みに対応(選択できるように)しました。
This commit is contained in:
Sakamoto Shiina
2023-10-18 18:46:10 +09:00
parent 5abfe3c20b
commit 7cc7b5a7c3
9 changed files with 121 additions and 33 deletions

75
view.py
View File

@@ -10,7 +10,7 @@ from languages import selectable_languages
from customtkinter import StringVar, IntVar, BooleanVar, END as CTK_END, get_appearance_mode
from vrct_gui.ui_managers import ColorThemeManager, ImageFileManager, UiScalingManager
from vrct_gui import vrct_gui
from utils import callFunctionIfCallable
from utils import callFunctionIfCallable, generatePercentageStringsList
from config import config
@@ -83,7 +83,17 @@ class View():
self.view_variable = SimpleNamespace(
# Common
CALLBACK_RESTART_SOFTWARE=None,
CALLBACK_UPDATE_SOFTWARE=None,
CALLBACK_WHEN_DETECT_WINDOW_OVERED_SIZE=self._showDisplayOverUiSizeConfirmationModal,
# Confirmation Modal
CALLBACK_HIDE_CONFIRMATION_MODAL=None,
CALLBACK_ACCEPTED_CONFIRMATION_MODAL=None,
CALLBACK_DENIED_CONFIRMATION_MODAL=None,
VAR_MESSAGE_CONFIRMATION_MODAL=StringVar(value=""),
VAR_LABEL_CONFIRMATION_MODAL_DENY_BUTTON=StringVar(value=""),
VAR_LABEL_CONFIRMATION_MODAL_ACCEPT_BUTTON=StringVar(value=""),
# Open Config Window
CALLBACK_CLICKED_OPEN_CONFIG_WINDOW_BUTTON=self._openConfigWindow,
@@ -94,17 +104,9 @@ class View():
# Open Help and Information Page
CALLBACK_CLICKED_HELP_AND_INFO=self.openWebPage_VrctDocuments,
# For Update Software
# Open Update Confirmation Modal
CALLBACK_CLICKED_UPDATE_AVAILABLE=self._showUpdateSoftwareConfirmationModal,
CALLBACK_UPDATE_SOFTWARE=None,
CALLBACK_ACCEPT_UPDATE=self._startUpdateSoftware,
CALLBACK_DENY_UPDATE=self._deniedUpdateSoftware,
CALLBACK_HIDE_UPDATE_CONFIRMATION_MODAL=self._hideUpdateSoftwareConfirmationModal,
VAR_MESSAGE_CONFIRMATION_MODAL=StringVar(value=""),
VAR_LABEL_CONFIRMATION_MODAL_DENY_BUTTON=StringVar(value=""),
VAR_LABEL_CONFIRMATION_MODAL_ACCEPT_BUTTON=StringVar(value=""),
# Main Window
@@ -203,7 +205,7 @@ class View():
VAR_LABEL_UI_SCALING=StringVar(value=i18n.t("config_window.ui_size.label")),
VAR_DESC_UI_SCALING=None,
LIST_UI_SCALING=["40%", "60%", "80%", "90%", "100%", "110%", "120%", "150%", "200%"],
LIST_UI_SCALING=generatePercentageStringsList(start=40,end=200, step=10),
CALLBACK_SET_UI_SCALING=None,
VAR_UI_SCALING=StringVar(value=config.UI_SCALING),
@@ -566,24 +568,64 @@ class View():
def foregroundOff():
vrct_gui.attributes("-topmost", False)
def _showUpdateSoftwareConfirmationModal(self):
def _showDisplayOverUiSizeConfirmationModal(self):
self.foregroundOffIfForegroundEnabled()
self.view_variable.VAR_LABEL_MAIN_WINDOW_COVER_MESSAGE.set("")
vrct_gui.main_window_cover.show()
self.view_variable.CALLBACK_HIDE_CONFIRMATION_MODAL=self._hideConfirmationModal
self.view_variable.CALLBACK_ACCEPTED_CONFIRMATION_MODAL=self._adjustUiSizeAndRestart
self.view_variable.CALLBACK_DENIED_CONFIRMATION_MODAL=self._hideConfirmationModal
self.view_variable.VAR_MESSAGE_CONFIRMATION_MODAL.set(i18n.t("main_window.confirmation_message.detected_over_ui_size", current_ui_size=config.UI_SCALING))
self.view_variable.VAR_LABEL_CONFIRMATION_MODAL_DENY_BUTTON.set(i18n.t("main_window.confirmation_message.deny_adjust_ui_size"))
self.view_variable.VAR_LABEL_CONFIRMATION_MODAL_ACCEPT_BUTTON.set(i18n.t("main_window.confirmation_message.accept_adjust_ui_size"))
vrct_gui.update_confirmation_modal.show(hide_title_bar=False, close_when_focusout=False)
def _adjustUiSizeAndRestart(self):
current_percentage = int(config.UI_SCALING.replace("%",""))
target_percentage = current_percentage - 20
if target_percentage >= 40 and str(target_percentage) + "%" in self.view_variable.LIST_UI_SCALING:
index = self.view_variable.LIST_UI_SCALING.index(str(target_percentage) + "%")
callFunctionIfCallable(self.view_variable.CALLBACK_SET_UI_SCALING, self.view_variable.LIST_UI_SCALING[index])
callFunctionIfCallable(self.view_variable.CALLBACK_RESTART_SOFTWARE)
# ※Below 40% of the UI size is not supported, and we cannot handle it at this time.
def _showUpdateSoftwareConfirmationModal(self):
self.foregroundOffIfForegroundEnabled()
self.view_variable.VAR_LABEL_MAIN_WINDOW_COVER_MESSAGE.set("")
vrct_gui.main_window_cover.show()
self.view_variable.CALLBACK_HIDE_CONFIRMATION_MODAL=self._hideConfirmationModal
self.view_variable.CALLBACK_ACCEPTED_CONFIRMATION_MODAL=self._startUpdateSoftware
self.view_variable.CALLBACK_DENIED_CONFIRMATION_MODAL=self._hideConfirmationModal
self.view_variable.VAR_MESSAGE_CONFIRMATION_MODAL.set(i18n.t("main_window.confirmation_message.update_software"))
self.view_variable.VAR_LABEL_CONFIRMATION_MODAL_DENY_BUTTON.set(i18n.t("main_window.confirmation_message.deny_update_software"))
self.view_variable.VAR_LABEL_CONFIRMATION_MODAL_ACCEPT_BUTTON.set(i18n.t("main_window.confirmation_message.accept_update_software"))
vrct_gui.update_confirmation_modal.show()
vrct_gui.update_confirmation_modal.focus_set()
def _hideUpdateSoftwareConfirmationModal(self):
self._deniedUpdateSoftware()
def _hideConfirmationModal(self):
vrct_gui.update_confirmation_modal.hide()
vrct_gui.main_window_cover.hide()
self.foregroundOnIfForegroundEnabled()
# def _deniedUpdateSoftware(self):
# self._hideConfirmationModal()
def _startUpdateSoftware(self):
self.view_variable.VAR_MESSAGE_CONFIRMATION_MODAL.set(i18n.t("main_window.confirmation_message.updating"))
@@ -592,9 +634,6 @@ class View():
vrct_gui.update_confirmation_modal.update()
callFunctionIfCallable(self.view_variable.CALLBACK_UPDATE_SOFTWARE)
def _deniedUpdateSoftware(self):
vrct_gui.update_confirmation_modal.hide()
vrct_gui.main_window_cover.hide()
def _openConfigWindow(self):