基本信息
| 属性 |
值 |
| 源码类 |
lumien.custommainmenu.configuration.elements.Button(继承 Element) |
| 渲染类 |
lumien.custommainmenu.gui.GuiCustomButton(继承原版 GuiButton) |
| 配置位置 |
顶层 buttons 对象下的每个键(GuiConfig.loadButtons,GuiConfig.java:229) |
| 元素名 |
JSON 键名本身,写入 Button.name(GuiConfig.java:236) |
可配置项
| 字段 |
必填 |
类型 |
默认值 |
说明 |
text |
是 |
文本 |
— |
常态显示文本,接受任意文本来源(见文本来源) |
posX / posY |
是 |
int |
— |
相对锚点的像素偏移 |
width / height |
是 |
int |
— |
同时作为 imageWidth/imageHeight 初值(Button.java:38-39) |
alignment |
否 |
字符串 |
button |
锚点,默认 (0.5, 0.25) |
texture |
否 |
贴图 |
null |
竖排三态精灵图;null 时用原版按钮贴图 |
imageWidth / imageHeight |
否 |
int |
= width/height |
自定义贴图里单帧的尺寸 |
normalTextColor |
否 |
int |
14737632(0xE0E0E0) |
常态字色 |
hoverTextColor |
否 |
int |
16777120(0xFFFFA0) |
悬停字色 |
shadow |
否 |
bool |
true |
文字是否带阴影 |
hoverText |
否 |
文本 |
= text |
悬停文本 |
tooltip |
否 |
文本 |
null |
悬停提示框,按 \n 分行 |
pressSound / hoverSound |
否 |
资源名 |
null |
点击/悬停音效 |
action |
否 |
对象 |
null |
点击行为,见动作类型 |
wrappedButton |
否 |
int |
-1 |
包裹原版按钮,见包裹原版按钮 |
两种渲染路径
| 条件 |
贴图来源 |
截取位置 |
设了 texture |
该贴图 |
源图 (0, (k-1)×imageHeight),尺寸 width×height,即竖排 3 帧(GuiCustomButton.java:74-82) |
未设 texture |
原版 GuiButton.buttonTextures |
y = 46 + k×20,左右各半拼接(GuiCustomButton.java:85-92) |
k 来自原版 getHoverState()(0 常态 / 1 悬停 / 2 禁用)。特例:元素名恰好为 language 且未设 texture 时,直接画原版语言按钮精灵(y=106,悬停则 +height)并提前返回,不画文字(GuiCustomButton.java:46-57)。默认配置里的 language 按钮正是这样用的(text 为空串)。
字色优先级
GuiCustomButton.java:95-102:显式 packedFGColour > 禁用态 10526880 > 悬停态 hoverTextColor > normalTextColor。
交互
- 普通按钮在
GuiCustom.initGui 里从 ID 6000 起递增分配(GuiCustom.java:121-128);actionPerformed 仅在 id >= 6000 时执行 action.perform(...)(GuiCustom.java:523-526)。
- 点击音效:设了
pressSound 就播它,否则退回原版按钮音(GuiCustomButton.java:181-188);悬停音效只在首次进入悬停时播一次(GuiCustomButton.java:63-66)。
- 提示框走原版悬停框样式,由
LogicUtil.getTooltip 逐行做占位符替换(LogicUtil.java:11-16)。
相关条目