From 98feea5d7db98f6b4b84e18bfda755e61d104ce9 Mon Sep 17 00:00:00 2001 From: moesnow <11678347+moesnow@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:48:23 +0800 Subject: [PATCH] fix: resolution --- assets/docs/Changelog.md | 1 + utils/registry/star_rail_setting.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/docs/Changelog.md b/assets/docs/Changelog.md index 27357e0a..b4bf5b56 100644 --- a/assets/docs/Changelog.md +++ b/assets/docs/Changelog.md @@ -13,6 +13,7 @@ - 多个红点导致模拟宇宙领取每周奖励失败 - 快速解锁教学动画导致虚构叙事异常 - 主页三月七背景在高缩放率下模糊的问题 +- 某启动器修改分辨率注册表项后会导致注册表读取错误 ## v2.0.4 diff --git a/utils/registry/star_rail_setting.py b/utils/registry/star_rail_setting.py index a839fa7c..333bbdca 100644 --- a/utils/registry/star_rail_setting.py +++ b/utils/registry/star_rail_setting.py @@ -22,11 +22,13 @@ def get_game_resolution() -> Optional[Tuple[int, int, bool]]: value = read_registry_value(winreg.HKEY_CURRENT_USER, registry_key_path, resolution_value_name) if value: data_dict = json.loads(value.decode('utf-8').strip('\x00')) + # Convert keys to lower case to ensure case-insensitivity + data_dict = {k.lower(): v for k, v in data_dict.items()} - # Validate data format - if 'width' in data_dict and 'height' in data_dict and 'isFullScreen' in data_dict: - if isinstance(data_dict['width'], int) and isinstance(data_dict['height'], int) and isinstance(data_dict['isFullScreen'], bool): - return data_dict['width'], data_dict['height'], data_dict['isFullScreen'] + # Validate data format with case-insensitive keys + if 'width' in data_dict and 'height' in data_dict and 'isfullscreen' in data_dict: + if isinstance(data_dict['width'], int) and isinstance(data_dict['height'], int) and isinstance(data_dict['isfullscreen'], bool): + return data_dict['width'], data_dict['height'], data_dict['isfullscreen'] else: raise ValueError("Registry data is invalid: width, height, and isFullScreen must be of type int, int, and bool respectively.") else: