From 2df3bb4611c1c7db2202797708ccf5f039489c7b Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Tue, 7 May 2024 17:37:49 +0700 Subject: [PATCH] Add "Default opacity" setting for touch controller --- src/assets/css/number-stepper.styl | 9 +++++++++ src/assets/css/stream-settings.styl | 7 ------- src/modules/patcher.ts | 13 +++++++++++++ src/modules/ui/global-settings.ts | 1 + src/utils/preferences.ts | 15 +++++++++++++++ src/utils/translation.ts | 17 +++++++++++++++++ 6 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/assets/css/number-stepper.styl b/src/assets/css/number-stepper.styl index d6759b4..2d6b5ce 100644 --- a/src/assets/css/number-stepper.styl +++ b/src/assets/css/number-stepper.styl @@ -1,4 +1,6 @@ .bx-number-stepper { + text-align: center; + span { display: inline-block; width: 40px; @@ -35,6 +37,13 @@ } } + input[type="range"] { + display: block; + margin: 12px auto 2px; + width: 180px; + color: #959595 !important; + } + input[type=range]:disabled, button:disabled { display: none; } diff --git a/src/assets/css/stream-settings.styl b/src/assets/css/stream-settings.styl index 1f066cd..b42b355 100644 --- a/src/assets/css/stream-settings.styl +++ b/src/assets/css/stream-settings.styl @@ -86,13 +86,6 @@ white-space: nowrap; } } - - input[type="range"] { - display: block; - margin: 12px auto 2px; - width: 180px; - color: #959595 !important; - } } diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index 2c7f792..59f2620 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -484,6 +484,18 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar}); str = str.replace(text, text + newCode); return str; }, + + patchTouchControlDefaultOpacity(str: string) { + const text = 'opacityMultiplier:1'; + if (!str.includes(text)) { + return false; + } + + const opacity = (getPref(PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY) / 100).toFixed(1); + const newCode = `opacityMultiplier: ${opacity}`; + str = str.replace(text, newCode); + return str; + }, }; let PATCH_ORDERS: PatchArray = [ @@ -534,6 +546,7 @@ let PLAYING_PATCH_ORDERS: PatchArray = [ STATES.hasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all' && 'exposeTouchLayoutManager', STATES.hasTouchSupport && (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'off' || getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) && 'disableTakRenderer', + STATES.hasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY) !== 100 && 'patchTouchControlDefaultOpacity', BX_FLAGS.EnableXcloudLogging && 'enableConsoleLogging', diff --git a/src/modules/ui/global-settings.ts b/src/modules/ui/global-settings.ts index e4e1f0b..d3eec15 100644 --- a/src/modules/ui/global-settings.ts +++ b/src/modules/ui/global-settings.ts @@ -58,6 +58,7 @@ const SETTINGS_UI = { items: [ PrefKey.STREAM_TOUCH_CONTROLLER, PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF, + PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY, PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD, PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM, ], diff --git a/src/utils/preferences.ts b/src/utils/preferences.ts index ba96203..d86c1da 100644 --- a/src/utils/preferences.ts +++ b/src/utils/preferences.ts @@ -27,6 +27,7 @@ export enum PrefKey { STREAM_TOUCH_CONTROLLER = 'stream_touch_controller', STREAM_TOUCH_CONTROLLER_AUTO_OFF = 'stream_touch_controller_auto_off', + STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY = 'stream_touch_controller_default_opacity', STREAM_TOUCH_CONTROLLER_STYLE_STANDARD = 'stream_touch_controller_style_standard', STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM = 'stream_touch_controller_style_custom', @@ -277,6 +278,20 @@ export class Preferences { default: false, unsupported: !STATES.hasTouchSupport, }, + [PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY]: { + type: SettingElementType.NUMBER_STEPPER, + label: t('tc-default-opacity'), + default: 100, + min: 10, + max: 100, + steps: 10, + params: { + suffix: '%', + ticks: 10, + hideSlider: true, + }, + unsupported: !STATES.hasTouchSupport, + }, [PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: { label: t('tc-standard-layout-style'), default: 'default', diff --git a/src/utils/translation.ts b/src/utils/translation.ts index 6573018..4877fd3 100644 --- a/src/utils/translation.ts +++ b/src/utils/translation.ts @@ -2754,6 +2754,23 @@ const Texts = { "Màu của bố cục tùy chọn", "特殊游戏按钮样式", ], + "tc-default-opacity": [ + , + , + "Default opacity", + , + , + , + , + , + , + , + , + , + , + "Độ mờ mặc định", + , + ], "tc-muted-colors": [ "Matte Farben", "Warna redup",