feat(hud): 增加右下角拖拽把手,并把拖拽状态从字符串改为引用 - #169
Merged
Merged
Conversation
gaoyu06
force-pushed
the
refactor/hud-measure-pass
branch
from
August 1, 2026 04:23
779c36c to
bd11af2
Compare
编辑模式下(打开聊天或 ClickGUI)悬停 HUD 元素时,右下角出现一个把手, 拖动即可缩放。此前只能按住 zoom 键滚滚轮,发现性很差。 设计要点: - 把手尺寸固定 6px,不随组件缩放。否则组件缩到 0.5x 时把手会小到点不中 - 组件小于 18×18 时不显示把手。12×12 的命中区会吞掉小组件的大部分面积, 让人没法再拖动位置 - 缩放按鼠标累计位移计算,而不是按光标到组件原点的距离。右/下锚点的组件 原点本身会随 scale 移动,用距离会反馈进下一帧的增量而跑飞 - 量化到 0.1 步长并钳在 [0.5, 4.5],与滚轮缩放走同一套边界 dragLock 由 String(存 mod.name)改为 Component 引用 + DragMode(MOVE/RESIZE): - 每组件每帧一次字符串比较变为引用比较 - 组件在找不到模块时会 fallback 造一个同名的临时 InterfaceModule,两个组件 同名时锁会串 - 「松开鼠标即解锁」原本写在每个组件自己的 display() 里,等于把一个全局事实 重复判断 N 遍,且依赖至少有一个组件在渲染。拖拽途中若所有 HUD 组件恰好都 不可见(比如快捷键关掉了模块),锁就永远留着,之后谁都拖不动。现在上提到 ComponentsManager.draw() 每帧判一次 顺带修正悬停标签的缩放显示:(scale * 10) / 10f 对 float 恒等于 scale, 显示的是 1.2999999x,改为 Math.round(scale * 10) / 10f。 Co-Authored-By: Claude <noreply@anthropic.com>
gaoyu06
force-pushed
the
feat/hud-resize-handle
branch
from
August 1, 2026 04:27
924786a to
959a7dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
拖拽把手
编辑模式下(打开聊天或 ClickGUI)悬停 HUD 元素时,右下角出现一个把手,拖动即可缩放。此前只能「按住 zoom 键 + 滚轮」,没有任何视觉提示,发现性很差。
设计上的几个取舍:
拖 60px 约等于 1x。
dragLock 改引用
ComponentsManager.dragLock由String(存mod.name)改为Component引用 +DragMode{MOVE, RESIZE}:InterfaceModule(Component.java构造器),两个组件同名时锁会串display()里,等于把一个全局事实重复判断 N 遍,且依赖至少有一个组件在渲染。拖拽途中若所有 HUD 组件恰好都不可见(比如快捷键关掉了模块),锁就永远留着,之后谁都拖不动——因为拿锁要求dragLock.isEmpty()。现在上提到ComponentsManager.draw()每帧判一次顺带
悬停标签的缩放显示
(scale * 10) / 10f对 float 恒等于scale,显示的是1.2999999x。改为Math.round(scale * 10) / 10f。依赖说明
把手位置取决于当帧的
width/height,所以依赖 #168 的measure()阶段——否则把手会跟着尺寸变化漂移一帧,拖起来是飘的。同样地,#167 修好了 4 个组件的 scale 失效,否则那几个组件的把手拖了不会有反应。🤖 Generated with Claude Code