GuiModConfig

Forge 配置界面

基本信息

属性 值
路径 com.github.lunatrius.ingameinfo.client.gui.GuiModConfig
行数 39
父类 cpw.mods.fml.client.config.GuiConfig

构造器(:18-27)

public GuiModConfig(GuiScreen guiScreen) { super(guiScreen); }

⚠️ 只调 super(guiScreen), 没有覆写 getConfigElements()(1.7.10 的 GuiConfig 是抽象方法, 必须实现 —— 说明本类有覆写,或该版本签名不同)。

/igi config 传的是 null 作为 guiScreen (见 InGameInfoCommand 的 :121), 所以从命令打开时没有父界面,关闭后直接回游戏。

getConfigElements(:29-38)

private static List<IConfigElement> getConfigElements() { ... }

private static —— 供构造器内部或 Forge 反射调用。

配置项的来源是 ConfigurationHandler 的 7 个 Property 句柄:

GUI 控件 配置项
文本框 filename
复选框 ShowHUD / replaceDebug / showInChat / showOnPlayerList
滑块 scale(new)(1–20)
滑块 fileInterval(1–60)
文本框 9 个对齐偏移(X Y 格式,带正则校验)

⚠️ 两个滑块不是本类设置的 —— ClientProxy(:45-46)在 preInit 里 用 setConfigEntryClass(GuiConfigEntries.NumberSliderEntry.class) 指定,所以本类只需提供 Property 引用。

分类

分类 项数
general 7
alignment 9

共 16 个可见配置项(与 ConfigurationHandler 的 7 + 9 完全对应)。

修改后的保存路径

Forge 的 GuiConfig 保存时发 ConfigChangedEvent.OnConfigChangedEvent, 由 ClientConfigurationHandler 的 INSTANCE 接收(它注册在 FML 总线上, 见 ClientProxy 的 :53), 再调 loadConfiguration() 把值搬进静态字段。

⚠️ 服务端不订阅该事件(见 ServerProxy), 所以服务端改配置需重启。

相关