3535/**
3636 * Alternative research UI that visualizes the research dependency graph.
3737 *
38- * Compact layout (340x250) matching ResearchTableScreen:
39- * Left column (~100px): Drive, Cube, cost grid, buckets, idea chip, fluid gauge
40- * Right area: Graph viewport with zoom/pan
41- * Bottom: Player inventory + hotbar (centered)
38+ * Uses same layout dimensions as ResearchTableScreen (470x260) to match menu slot positions.
39+ * Upper panel: Graph viewport with zoom/pan
40+ * Lower section: Machine panel (Drive, Cube, Costs, etc.) + Player inventory
4241 */
4342public class ResearchTreeScreen extends AbstractContainerScreen <ResearchTableMenu > {
4443
@@ -57,11 +56,11 @@ public class ResearchTreeScreen extends AbstractContainerScreen<ResearchTableMen
5756 private static final int LAYER_X_GAP = 178 ;
5857 private static final int LAYER_Y_GAP = 64 ;
5958
60- // Graph viewport (right of the left column )
61- private static final int GRAPH_X = 108 ;
62- private static final int GRAPH_Y = 32 ;
63- private static final int GRAPH_W = 228 ;
64- private static final int GRAPH_H = 114 ;
59+ // Graph viewport (uses same upper panel area as list view )
60+ private static final int GRAPH_X = ResearchTableMenu . UPPER_PANEL_X + 8 ;
61+ private static final int GRAPH_Y = ResearchTableMenu . UPPER_PANEL_Y + 24 ;
62+ private static final int GRAPH_W = ResearchTableMenu . UPPER_PANEL_W - 16 ;
63+ private static final int GRAPH_H = ResearchTableMenu . UPPER_PANEL_H - 28 ;
6564
6665 private enum EdgeStyle {
6766 SINGLE ,
@@ -112,34 +111,39 @@ private record Dependency(ResourceLocation sourceId, EdgeStyle style) {}
112111
113112 public ResearchTreeScreen (ResearchTableMenu menu , Inventory playerInv , Component title ) {
114113 super (menu , playerInv , title );
115- this .imageWidth = 340 ;
116- this .imageHeight = 250 ;
117- this .inventoryLabelX = 89 ;
118- this .inventoryLabelY = 153 ;
114+ this .imageWidth = ResearchTableMenu . GUI_WIDTH ;
115+ this .imageHeight = ResearchTableMenu . GUI_HEIGHT ;
116+ this .inventoryLabelX = ResearchTableMenu . PLAYER_INV_X ;
117+ this .inventoryLabelY = ResearchTableMenu . PLAYER_INV_Y - 10 ;
119118 }
120119
121120 @ Override
122121 protected void init () {
123122 super .init ();
124123
124+ // Buttons positioned in upper panel controls area
125+ int btnY = topPos + ResearchTableMenu .TREE_BTN_Y ;
126+
125127 this .startButton = addRenderableWidget (Button .builder (Component .literal ("Start" ), b -> onStartResearch ())
126- .bounds (leftPos + 10 , topPos + 112 , 40 , 14 )
128+ .bounds (leftPos + ResearchTableMenu .START_BTN_X , topPos + ResearchTableMenu .BUTTON_Y ,
129+ ResearchTableMenu .BUTTON_W , ResearchTableMenu .BUTTON_H )
127130 .build ());
128131
129132 this .listButton = addRenderableWidget (Button .builder (Component .literal ("List" ), b -> openListView ())
130- .bounds (leftPos + 54 , topPos + 112 , 40 , 14 )
133+ .bounds (leftPos + ResearchTableMenu .LIST_BTN_X , btnY ,
134+ ResearchTableMenu .LIST_BTN_W , ResearchTableMenu .LIST_BTN_H )
131135 .build ());
132136
133137 this .fitButton = addRenderableWidget (Button .builder (Component .literal ("Fit" ), b -> fitGraphToViewport ())
134- .bounds (leftPos + 10 , topPos + 130 , 30 , 14 )
138+ .bounds (leftPos + ResearchTableMenu . SEARCH_X , btnY , 30 , 16 )
135139 .build ());
136140
137141 this .zoomOutButton = addRenderableWidget (Button .builder (Component .literal ("-" ), b -> adjustZoom (-0.12f ))
138- .bounds (leftPos + 44 , topPos + 130 , 18 , 14 )
142+ .bounds (leftPos + ResearchTableMenu . SEARCH_X + 34 , btnY , 20 , 16 )
139143 .build ());
140144
141145 this .zoomInButton = addRenderableWidget (Button .builder (Component .literal ("+" ), b -> adjustZoom (0.12f ))
142- .bounds (leftPos + 66 , topPos + 130 , 18 , 14 )
146+ .bounds (leftPos + ResearchTableMenu . SEARCH_X + 58 , btnY , 20 , 16 )
143147 .build ());
144148
145149 buildGraph ();
@@ -411,15 +415,19 @@ protected void renderBg(GuiGraphics g, float partialTick, int mouseX, int mouseY
411415 g .fill (x + imageWidth - 1 , y , x + imageWidth , y + imageHeight , PANEL_DARK );
412416 g .fill (x , y + imageHeight - 1 , x + imageWidth , y + imageHeight , PANEL_DARK );
413417
414- // Main top panel
415- drawPanel (g , x + 4 , y + 14 , 332 , 140 );
416- // Bottom inventory panel
417- drawPanel (g , x + 4 , y + 156 , 332 , 90 );
418+ // Upper panel (contains graph)
419+ drawPanel (g , x + ResearchTableMenu .UPPER_PANEL_X , y + ResearchTableMenu .UPPER_PANEL_Y ,
420+ ResearchTableMenu .UPPER_PANEL_W , ResearchTableMenu .UPPER_PANEL_H );
421+
422+ // Machine panel area
423+ drawPanel (g , x + ResearchTableMenu .MACHINE_PANEL_X , y + ResearchTableMenu .MACHINE_PANEL_Y ,
424+ ResearchTableMenu .MACHINE_PANEL_W , 80 );
418425
419- // Left machine column sub-panel
420- drawPanel (g , x + 6 , y + 16 , 100 , 136 );
426+ // Player inventory panel
427+ drawPanel (g , x + ResearchTableMenu .PLAYER_INV_X - 8 , y + ResearchTableMenu .PLAYER_INV_Y - 10 ,
428+ 178 , 90 );
421429
422- // Slot backgrounds in left column
430+ // Slot backgrounds for machine panel
423431 drawSlotBg (g , x + ResearchTableMenu .DRIVE_X , y + ResearchTableMenu .DRIVE_Y );
424432 drawSlotBg (g , x + ResearchTableMenu .CUBE_X , y + ResearchTableMenu .CUBE_Y );
425433 for (int row = 0 ; row < 2 ; row ++) {
@@ -430,7 +438,8 @@ protected void renderBg(GuiGraphics g, float partialTick, int mouseX, int mouseY
430438 drawSlotBg (g , x + ResearchTableMenu .BUCKET_IN_X , y + ResearchTableMenu .BUCKET_IN_Y );
431439 drawSlotBg (g , x + ResearchTableMenu .BUCKET_OUT_X , y + ResearchTableMenu .BUCKET_OUT_Y );
432440 drawSlotBg (g , x + ResearchTableMenu .IDEA_CHIP_X , y + ResearchTableMenu .IDEA_CHIP_Y );
433- drawFluidGauge (g , x + 92 , y + 26 , 12 , 54 );
441+ drawFluidGauge (g , x + ResearchTableMenu .FLUID_GAUGE_X , y + ResearchTableMenu .FLUID_GAUGE_Y ,
442+ ResearchTableMenu .FLUID_GAUGE_W , ResearchTableMenu .FLUID_GAUGE_H );
434443
435444 // Player inventory slot backgrounds
436445 for (int row = 0 ; row < 3 ; row ++) {
@@ -442,9 +451,6 @@ protected void renderBg(GuiGraphics g, float partialTick, int mouseX, int mouseY
442451 drawSlotBg (g , x + ResearchTableMenu .HOTBAR_X + col * 18 , y + ResearchTableMenu .HOTBAR_Y );
443452 }
444453
445- // Header strip
446- g .fill (x + 6 , y + 16 , x + 106 , y + 26 , 0xFF1C2030 );
447-
448454 // Graph viewport
449455 int gx = x + GRAPH_X ;
450456 int gy = y + GRAPH_Y ;
@@ -732,18 +738,30 @@ private void renderNodeTooltip(GuiGraphics graphics, NodeBox node, int mouseX, i
732738 protected void renderLabels (GuiGraphics graphics , int mouseX , int mouseY ) {
733739 graphics .drawString (this .font , this .title , this .titleLabelX , this .titleLabelY , 0xFF202020 , false );
734740 graphics .drawString (this .font , this .playerInventoryTitle , this .inventoryLabelX , this .inventoryLabelY , 0xFFE6EAF5 , false );
735- graphics .drawString (this .font , "Tree View | scroll=zoom, R-drag=pan" , 6 , 18 , 0xFFE5E7EB , false );
736- graphics .drawString (this .font , "AND" , 108 , 20 , EDGE_AND , false );
737- graphics .drawString (this .font , "OR" , 132 , 20 , EDGE_OR , false );
738- graphics .drawString (this .font , "S" , 148 , 20 , EDGE_SINGLE , false );
739- graphics .drawString (this .font , "Drive" , 8 , 16 , 0xFFD3D7E5 , false );
740- graphics .drawString (this .font , "Cube" , 8 , 56 , 0xFFD3D7E5 , false );
741- graphics .drawString (this .font , "Costs" , 36 , 16 , 0xFFD3D7E5 , false );
742- graphics .drawString (this .font , "Idea" , 70 , 58 , 0xFFD3D7E5 , false );
743- graphics .drawString (this .font , "Fl." , 92 , 16 , 0xFFD3D7E5 , false );
741+
742+ // Tree view controls info
743+ graphics .drawString (this .font , "Tree View | scroll=zoom, R-drag=pan" ,
744+ ResearchTableMenu .SEARCH_X + 84 , ResearchTableMenu .SEARCH_Y , 0xFFE5E7EB , false );
745+
746+ // Edge legend
747+ graphics .drawString (this .font , "AND" , GRAPH_X + GRAPH_W - 70 , ResearchTableMenu .SEARCH_Y , EDGE_AND , false );
748+ graphics .drawString (this .font , "OR" , GRAPH_X + GRAPH_W - 46 , ResearchTableMenu .SEARCH_Y , EDGE_OR , false );
749+ graphics .drawString (this .font , "S" , GRAPH_X + GRAPH_W - 22 , ResearchTableMenu .SEARCH_Y , EDGE_SINGLE , false );
750+
751+ // Slot labels in machine panel
752+ int labelY = ResearchTableMenu .LABEL_Y ;
753+ graphics .drawString (this .font , "Dr" , ResearchTableMenu .DRIVE_X + 2 , labelY , 0xFFD3D7E5 , false );
754+ graphics .drawString (this .font , "Cb" , ResearchTableMenu .CUBE_X + 2 , labelY , 0xFFD3D7E5 , false );
755+ graphics .drawString (this .font , "Id" , ResearchTableMenu .IDEA_CHIP_X + 2 , labelY , 0xFFD3D7E5 , false );
756+ graphics .drawString (this .font , "Costs" , ResearchTableMenu .COST_X , labelY , 0xFFD3D7E5 , false );
757+ graphics .drawString (this .font , "Fl" , ResearchTableMenu .FLUID_GAUGE_X + 3 , labelY , 0xFFD3D7E5 , false );
758+ graphics .drawString (this .font , "I/O" , ResearchTableMenu .BUCKET_IN_X , labelY , 0xFFD3D7E5 , false );
759+
744760 if (menu .isResearching ()) {
745- graphics .drawString (this .font , "\u25CF Researching" , 10 , 148 , 0xFF77DD77 , false );
761+ graphics .drawString (this .font , "\u25CF Researching" ,
762+ ResearchTableMenu .MACHINE_PANEL_X + 4 , ResearchTableMenu .BUTTON_Y + 18 , 0xFF77DD77 , false );
746763 }
747- graphics .drawString (this .font , Math .round (zoom * 100f ) + "%" , 88 , 132 , 0xFFD9DDE7 , false );
764+ graphics .drawString (this .font , Math .round (zoom * 100f ) + "%" ,
765+ ResearchTableMenu .SEARCH_X + 82 , ResearchTableMenu .TREE_BTN_Y , 0xFFD9DDE7 , false );
748766 }
749767}
0 commit comments