UI 元素需要等比例缩放(1:1 纵横比),修复宽屏下红蓝球被横向拉成椭圆形 #136
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题描述
参考截图:https://screenshot-v2.corp.google.com/0surpevfmm1i0 、https://screenshot-v2.corp.google.com/12hbrk7d7cgj0
在 16:9 等宽屏显示器上,HUD 红球、蓝球、技能图标、面板及悬浮框因为非等比拉伸(横向放大比例大于纵向)变成了椭圆形。
根因分析
src/ui/hud-manager.ts第 586 行使用了非等比缩放:在 1920×1080 视口下,
scaleX = 2.4而scaleY = 1.8(横向被多拉伸了 33.3%),导致原本 80×80 的正圆生命/法力球被拉伸为 192×144 的横向椭圆。解决方案
uiScale = Math.min(cssW / 800, cssH / 600)。offsetX = (cssW - 800 * uiScale) / 2,offsetY = cssH - 600 * uiScale),同步更新鼠标命中转换clientToLogical(clientX, clientY),确保红蓝球、技能框、装备格、面板与悬浮框在任意分辨率下严格保持 1:1 原版正圆与正方形比例。验证通过并已随提交
14443c6修复关单改动方案:
src/ui/hud-manager.ts中的computeHudLayout,统一采用uiScale = Math.min(cssWidth / 800, cssHeight / 600)计算等比缩放因子,水平居中边距设为(cssWidth - 800 * uiScale) / 2。验证结果: