Research Table GUI

基本信息

属性 值
入口 TableBlockMixin 重定向 GUI ID 10 → TRT GUI ID 0
工厂 ResearchTableGuiFactory(object,integration/table/gui/)
容器 PortContainer(六边形架构的装配点)
底图尺寸 310 × 245(CopyButtonActiveTexture.kt:11 Scale(310, 245))

⚠️ 源码缺陷:官方描述的「可缩放」无实现

mcmod.info 声称 “Makes thaumcraft research table ui resizable”,但源码中没有任何 resize / 用户缩放机制。

GUI 尺寸是从贴图常量推导出来的常量(layout/ResearchTableLayout.kt:8-12):

val guiScale =
    Scale(
        width = ResearchTableInventoryTexture.scale.width,
        height =
            ResearchTableInventoryTexture.inventoryOrigin.y + PlayerInventoryTexture.scale.height)

两处输入都是贴图定义的固定像素尺寸,没有任何配置项、按键或滚轮能改变它。

ResearchTweaksConfig 的全部 2 项配置(allowCombiningSameAspect、researchTableSortingOrder)都与缩放无关。

结论:GTNH 中玩家看到的是一个固定尺寸的替换界面,不是可缩放的。把它写成「可自由缩放」是采信了 mcmod.info 的宣传语而非源码。

界面组件构成

ResearchTableGuiFactory.create() 组装的组件树(:34-55):

组件 作用
background(ResearchTableInventoryTexture) 研究台底图
background(PlayerInventoryTexture) 玩家背包区
ParchmentUIComponent 羊皮纸区(六边形网格底衬)
AspectHexMapUIComponent 六边形网格显示
AspectHexMapEditorUIComponent 六边形网格编辑
CopyButtonUIComponent 研究笔记复制按钮
AspectDragAndDropUIComponent ×2 左/右元素面板
UsageHintUIComponent 使用提示按钮
ScribeToolsNotificationUIComponent 书写工具提示
KnowledgeNotificationUIComponent 知识状态提示

六边形网格

参数 值 证据
六边形边长 HexTexture.SIZE_PIXELS ResearchTableGuiFactory.kt:75
符文槽上限 runeLimit = 16 ResearchTableGuiFactory.kt:78
网格原点 ResearchArea.bounds.origin :76
网格中心 ResearchArea.centerOrigin :75

网格布局由 HexLayoutResearchNoteDataAdapter 适配器提供,实现 HexLayout<AspectHex>。

槽位坐标

槽位 坐标 行号
书写工具槽 Vector2D(x = 91, y = 10) ResearchTableInventoryTexture.kt:16
研究笔记槽 Vector2D(x = 235, y = 10) ResearchTableInventoryTexture.kt:17
背包区原点 inventoryOrigin ResearchTableInventoryTexture.kt

自研 GUI 框架

TRT 不使用 Vanilla IGui 体系,而是自建一套声明式组件框架(common/gui/,共 30 个文件):

分类 代表文件
组件基类 UIComponent、ClickableUIComponent、TickingUIComponent
拖放 DragAndDropUIComponent、DraggableSourceUIComponent、DropDestinationUIComponent
布局 Layout、GridLayout、HexLayout
渲染 AspectRenderer、TextureRenderer、TooltipRenderer
特效 LineParticle、OrbParticle
组合根 ComposableContainerGui(gui { … } DSL)

采用六边形架构(端口与适配器分离):

层 包
领域模型 domain/model/(AspectPallet、AspectTree、ResearchProcess、ResearcherKnowledge)
领域端口 domain/ports/required/(AspectCombiner、AspectPool、KnowledgeBase、PlayerInventory、ResearchNotes、ScribeTools)
适配器 integration/adapters/(6 个 *Adapter)

PortContainer 是唯一装配点,构造 6 个适配器并注入 AspectPallet 等模型。

容器

ResearchTableContainerFactory.create() 接收 playerInventory、table、scribeToolsSlotOrigin、notesSlotOrigin、inventoryUiOrigin(PortContainer.kt:20-27)——槽位坐标由 GUI 层传入容器层,实现 GUI 与逻辑解耦。

代理初始化

@SidedProxy(ThaumcraftResearchTweaks.kt:26-30):

端 实现类
客户端 ClientSingletonInitializer
服务端 ServerSingletonInitializer

onInit 中调用 singletonInitializer.initialize()(:37),并在同一处理器注册 GUI handler(:34-35)。

⚠️ @Mod.EventHandler fun onInit 接收的是 FMLLoadCompleteEvent,不是常规的 FMLInitializationEvent(:32-33)。方法名 onInit 与事件类型不一致——是刻意在加载完成后才注册 GUI,还是笔误,源码无注释说明。

相关条目