@@ -59,6 +59,7 @@ public final class ChestSearchScreen extends Screen
5959 private int scrollThumbTop = 0 ;
6060 private int scrollThumbHeight = 0 ;
6161 private double scrollMaxOffset = 0.0 ;
62+ private int contentWidth = 340 ;
6263
6364 // persist temp waypoints across screen instances
6465 private static final class TempWp
@@ -122,6 +123,23 @@ private static String makeEntryKey(ChestEntry entry)
122123 + formatBlockPos (max );
123124 }
124125
126+ private int getContentWidth ()
127+ {
128+ int max = Math .max (0 , this .width - 4 );
129+ int width = contentWidth ;
130+ if (width < 340 )
131+ width = 340 ;
132+ if (width > max )
133+ width = max ;
134+ return width ;
135+ }
136+
137+ private int getContentLeft ()
138+ {
139+ int width = getContentWidth ();
140+ return (this .width - width ) / 2 ;
141+ }
142+
125143 public static boolean isWaypointActive (String dimension , BlockPos pos )
126144 {
127145 String key = makePosKey (dimension , pos );
@@ -577,7 +595,7 @@ private void rebuildRowButtons()
577595 }
578596 rowButtons .clear ();
579597
580- int x = this . width / 2 - 150 ;
598+ int x = getContentLeft () ;
581599 int resultsTop = getResultsTop ();
582600 int y = resultsTop - (int )Math .round (scrollOffset );
583601 int visibleTop = resultsTop ;
@@ -708,7 +726,7 @@ private void rebuildRowButtons()
708726 .create (Component .literal ("ESP active" )));
709727 }
710728 // position esp and wp buttons to the right side of the result box
711- int boxRight = x + 340 ;
729+ int boxRight = x + getContentWidth () ;
712730 int wpWidth = 56 ;
713731 int espWidth = isLootManager ? 0 : 40 ;
714732 int deleteWidth = 56 ;
@@ -1004,8 +1022,37 @@ public void render(GuiGraphics context, int mouseX, int mouseY, float delta)
10041022 int sfY = 18 ;
10051023 context .fill (sfX - 2 , sfY - 2 , sfX + 222 , sfY + 22 , 0xFF333333 );
10061024 int summaryY = sfY + 24 ;
1025+ int shown = results == null ? 0 : results .size ();
1026+ String limiter = limitedResults
1027+ ? " (showing first " + WurstClient .INSTANCE .getHax ().chestSearchHack
1028+ .getMaxSearchResults () + ")"
1029+ : "" ;
1030+ java .util .ArrayList <String > summaryExtras = new java .util .ArrayList <>();
1031+ if (radiusFilterActive && radiusLimitBlocks < Integer .MAX_VALUE )
1032+ summaryExtras .add ("radius <= " + radiusLimitBlocks + " blocks" );
1033+ if (radiusFilterActive && radiusFilteredOut > 0 )
1034+ summaryExtras .add (radiusFilteredOut + " outside radius" );
1035+ String summaryExtra = summaryExtras .isEmpty () ? ""
1036+ : " (" + String .join (", " , summaryExtras ) + ")" ;
1037+ String matchLabel =
1038+ currentQuery .isEmpty () ? "Listed items" : "Matching items" ;
1039+ String summary = "Showing " + shown + "/" + totalMatches + limiter
1040+ + summaryExtra + " - " + matchLabel + ": " + totalMatchingItems
1041+ + " - Tracking " + totalChestsLogged + " chests, "
1042+ + totalItemsLogged + " items" ;
1043+ int summaryPadding = 8 ;
1044+ int summaryWidth = this .font .width (summary ) + summaryPadding * 2 ;
1045+ if (summaryWidth > this .width - 4 )
1046+ summaryWidth = this .width - 4 ;
1047+ int desiredWidth = Math .max (340 , summaryWidth );
1048+ if (desiredWidth != contentWidth )
1049+ {
1050+ contentWidth = desiredWidth ;
1051+ clampScroll ();
1052+ rebuildRowButtons ();
1053+ }
10071054 // draw result panels BEFORE super.render so buttons draw on top
1008- int x = this . width / 2 - 150 ;
1055+ int x = getContentLeft () ;
10091056 int visibleTop = getResultsTop ();
10101057 int visibleBottom = getVisibleBottom ();
10111058 int visibleHeight = Math .max (0 , visibleBottom - visibleTop );
@@ -1032,7 +1079,7 @@ else if(scrollOffset > maxScroll)
10321079 int y = visibleTop - (int )Math .round (scrollOffset );
10331080
10341081 int trackWidth = 8 ;
1035- int trackX = x + 340 + 6 ;
1082+ int trackX = x + getContentWidth () + 6 ;
10361083 int buttonWidth =
10371084 scrollUpButton != null ? scrollUpButton .getWidth () : 44 ;
10381085 int buttonHeight =
@@ -1118,10 +1165,11 @@ else if(scrollOffset > maxScroll)
11181165 if (y > visibleBottom )
11191166 break ;
11201167 int bgColor = pinnedEntry ? 0x80423210 : 0x80202020 ;
1121- context .fill (x - 6 , y , x + 340 , y + boxHeight , bgColor );
1168+ context .fill (x - 6 , y , x + getContentWidth (), y + boxHeight ,
1169+ bgColor );
11221170 int headerY = y + 6 ;
11231171 String locationLabel = formatLocationLabel (e , dim );
1124- int boxRight = x + 340 ;
1172+ int boxRight = x + getContentWidth () ;
11251173 // compute available width for location text (leave space for
11261174 // buttons)
11271175 int wpWidth = 56 ;
@@ -1330,28 +1378,6 @@ else if(scrollOffset > maxScroll)
13301378 }
13311379 // now draw children (buttons etc.) on top
13321380 super .render (context , mouseX , mouseY , delta );
1333- int shown = results == null ? 0 : results .size ();
1334- String limiter = limitedResults
1335- ? " (showing first " + WurstClient .INSTANCE .getHax ().chestSearchHack
1336- .getMaxSearchResults () + ")"
1337- : "" ;
1338- java .util .ArrayList <String > summaryExtras = new java .util .ArrayList <>();
1339- if (radiusFilterActive && radiusLimitBlocks < Integer .MAX_VALUE )
1340- summaryExtras .add ("radius <= " + radiusLimitBlocks + " blocks" );
1341- if (radiusFilterActive && radiusFilteredOut > 0 )
1342- summaryExtras .add (radiusFilteredOut + " outside radius" );
1343- String extra = summaryExtras .isEmpty () ? ""
1344- : " (" + String .join (", " , summaryExtras ) + ")" ;
1345- String matchLabel =
1346- currentQuery .isEmpty () ? "Listed items" : "Matching items" ;
1347- String summary =
1348- "Showing " + shown + "/" + totalMatches + limiter + extra + " - "
1349- + matchLabel + ": " + totalMatchingItems + " - Tracking "
1350- + totalChestsLogged + " chests, " + totalItemsLogged + " items" ;
1351- int summaryPadding = 8 ;
1352- int summaryWidth = this .font .width (summary ) + summaryPadding * 2 ;
1353- if (summaryWidth > this .width - 4 )
1354- summaryWidth = this .width - 4 ;
13551381 int summaryHalf = summaryWidth / 2 ;
13561382 int summaryCenter = this .width / 2 ;
13571383 int summaryLeft = Math .max (0 , summaryCenter - summaryHalf );
0 commit comments