@@ -200,12 +200,12 @@ private int getSearchHeight()
200200
201201 private float getRightSettingsWidthScale ()
202202 {
203- return Math .max (0.2F , cfg ().getSettingsWidth ());
203+ return Math .max (0.05F , cfg ().getSettingsWidth ());
204204 }
205205
206206 private float getRightSettingsHeightScale ()
207207 {
208- return Math .max (0.2F , cfg ().getSettingsHeight ());
208+ return Math .max (0.05F , cfg ().getSettingsHeight ());
209209 }
210210
211211 private int scaleRightSettingWidth (int value )
@@ -218,6 +218,13 @@ private int scaleRightSettingHeight(int value)
218218 return Math .max (1 , Math .round (value * getRightSettingsHeightScale ()));
219219 }
220220
221+ private int getMinimumReadableUiRowHeight ()
222+ {
223+ Font font = minecraft != null ? minecraft .font : null ;
224+ int textH = font == null ? 9 : Math .max (1 , scaledFontHeight (font ));
225+ return Math .max (10 , textH + 2 );
226+ }
227+
221228 private int getSettingsValueColumnWidth (int rowX1 , int rowX2 )
222229 {
223230 int min = scaleRightSettingWidth (120 );
@@ -348,7 +355,7 @@ public void render(GuiGraphics context, int mouseX, int mouseY,
348355 hoverTooltip = "" ;
349356 syncFontManager ();
350357 int bg =
351- withAlpha (cfg ().getBackgroundColor (), cfg ().getUiOpacity () * 0.86F );
358+ withAlpha (cfg ().getBackgroundColor (), cfg ().getBackgroundOpacity () );
352359 int panel = withAlpha (cfg ().getPanelColor (), cfg ().getUiOpacity ());
353360
354361 context .fill (0 , 0 , width , height , bg );
@@ -362,13 +369,49 @@ public void render(GuiGraphics context, int mouseX, int mouseY,
362369
363370 if (searchBox != null )
364371 {
365- searchBox .setTextColor (cfg ().getTextColor ());
366- searchBox .render (context , mouseX , mouseY , partialTicks );
372+ renderSearchBoxText (context );
367373 }
368374
369375 renderTooltip (context );
370376 }
371377
378+ private void renderSearchBoxText (GuiGraphics context )
379+ {
380+ if (searchBox == null )
381+ return ;
382+
383+ Font font = minecraft .font ;
384+ int x1 = searchBox .getX ();
385+ int y1 = searchBox .getY ();
386+ int x2 = x1 + searchBox .getWidth ();
387+ int y2 = y1 + searchBox .getHeight ();
388+ int padX =
389+ Math .max (6 , Math .round (4F * Math .max (0.25F , cfg ().getFontScale ())));
390+ int textY = centeredTextY (font , y1 , y2 );
391+ int maxTextW = Math .max (1 , (x2 - x1 ) - padX * 2 );
392+
393+ String value = searchBox .getValue ();
394+ boolean focused = searchBox .isFocused ();
395+ boolean empty = value == null || value .isBlank ();
396+ String baseText =
397+ empty && !focused ? "search" : (value == null ? "" : value );
398+ String drawText = trimToWidth (font , baseText , maxTextW );
399+ int textColor = empty && !focused ? cfg ().getMutedTextColor ()
400+ : cfg ().getTextColor ();
401+
402+ drawStringScaled (context , font , drawText , x1 + padX , textY , textColor ,
403+ false );
404+
405+ if (focused && (minecraft .gui .getGuiTicks () / 6 ) % 2 == 0 )
406+ {
407+ int caretX = x1 + padX + scaledFontWidth (font , drawText );
408+ int caretTop = textY ;
409+ int caretBottom = textY + Math .max (1 , scaledFontHeight (font ));
410+ context .fill (caretX , caretTop , caretX + 1 , caretBottom ,
411+ withAlpha (cfg ().getTextColor (), cfg ().getUiOpacity ()));
412+ }
413+ }
414+
372415 private void renderHeader (GuiGraphics context )
373416 {
374417 Font font = minecraft .font ;
@@ -668,7 +711,6 @@ private void renderSettingRow(GuiGraphics context, Font font, int mouseX,
668711
669712 if (!valueText .isEmpty ())
670713 {
671- valueText = trimToWidth (font , valueText , valueBoxW - valuePad * 2 );
672714 int valuePadY = getPillPadding (font , y2 - y1 );
673715 int valueY1 = y1 + valuePadY ;
674716 int valueY2 = y2 - valuePadY ;
@@ -705,8 +747,8 @@ && cfg().isFillColorValuesEnabled())
705747 context .fill (valueX1 , valueY1 , valueX2 , valueY2 ,
706748 getValueBadgeColor (row .setting (), valueText ));
707749 }
708- drawCenteredStringScaledInBox (context , font , valueText , valueX1 ,
709- valueY1 , valueX2 , valueY2 , valueTextColor );
750+ drawMarqueeStringScaledInBox (context , font , valueText , valueX1 ,
751+ valueY1 , valueX2 , valueY2 , valueTextColor , valuePad );
710752
711753 if (row .setting () instanceof ColorSetting color
712754 && !cfg ().isFillColorValuesEnabled ())
@@ -743,6 +785,8 @@ private void renderUiSettingsPanel(GuiGraphics context, int mouseX,
743785 int y = uiMenuY + 24 ;
744786 y = renderUiSlider (context , font , "UI opacity" ,
745787 cfg ().getUiOpacitySetting (), y , mouseX , mouseY );
788+ y = renderUiSlider (context , font , "Background opacity" ,
789+ cfg ().getBackgroundOpacitySetting (), y , mouseX , mouseY );
746790 y = renderUiSlider (context , font , "Settings width" ,
747791 cfg ().getSettingsWidthSetting (), y , mouseX , mouseY );
748792 y = renderUiSlider (context , font , "Settings height" ,
@@ -796,7 +840,8 @@ private void renderUiSettingsPanel(GuiGraphics context, int mouseX,
796840 private int renderUiSlider (GuiGraphics context , Font font , String label ,
797841 SliderSetting slider , int y , int mouseX , int mouseY )
798842 {
799- int rowH = scaleRightSettingHeight (14 );
843+ int rowH = Math .max (getMinimumReadableUiRowHeight (),
844+ scaleRightSettingHeight (14 ));
800845 int x1 = uiMenuX + 8 ;
801846 int x2 = uiMenuX + uiMenuW - 8 ;
802847 int trackX1 = uiMenuX + scaleRightSettingWidth (144 );
@@ -820,7 +865,8 @@ private int renderUiSlider(GuiGraphics context, Font font, String label,
820865 private int renderUiToggle (GuiGraphics context , Font font , String label ,
821866 CheckboxSetting setting , int y , int mouseX , int mouseY )
822867 {
823- int rowH = scaleRightSettingHeight (14 );
868+ int rowH = Math .max (getMinimumReadableUiRowHeight (),
869+ scaleRightSettingHeight (14 ));
824870 int x1 = uiMenuX + 8 ;
825871 int x2 = uiMenuX + uiMenuW - 8 ;
826872 boolean hovered = isInside (mouseX , mouseY , x1 , y , x2 , y + rowH );
@@ -846,7 +892,8 @@ private int renderUiToggle(GuiGraphics context, Font font, String label,
846892 private int renderUiColor (GuiGraphics context , Font font , String label ,
847893 ColorSetting color , int y , int mouseX , int mouseY )
848894 {
849- int rowH = scaleRightSettingHeight (13 );
895+ int rowH = Math .max (getMinimumReadableUiRowHeight (),
896+ scaleRightSettingHeight (13 ));
850897 int x1 = uiMenuX + 8 ;
851898 int x2 = uiMenuX + uiMenuW - 8 ;
852899 boolean hovered = isInside (mouseX , mouseY , x1 , y , x2 , y + rowH );
@@ -874,6 +921,8 @@ private boolean handleUiSettingsClick(double mouseX, double mouseY,
874921 int y = uiMenuY + 24 ;
875922 y = handleUiSliderClick (cfg ().getUiOpacitySetting (), mouseX , mouseY , y ,
876923 button );
924+ y = handleUiSliderClick (cfg ().getBackgroundOpacitySetting (), mouseX ,
925+ mouseY , y , button );
877926 y = handleUiSliderClick (cfg ().getSettingsWidthSetting (), mouseX , mouseY ,
878927 y , button );
879928 y = handleUiSliderClick (cfg ().getSettingsHeightSetting (), mouseX ,
@@ -927,7 +976,8 @@ private boolean handleUiSettingsClick(double mouseX, double mouseY,
927976 private int handleUiSliderClick (SliderSetting slider , double mouseX ,
928977 double mouseY , int y , int button )
929978 {
930- int rowH = scaleRightSettingHeight (14 );
979+ int rowH = Math .max (getMinimumReadableUiRowHeight (),
980+ scaleRightSettingHeight (14 ));
931981 int x1 = uiMenuX + 8 ;
932982 int x2 = uiMenuX + uiMenuW - 8 ;
933983 int trackX1 = uiMenuX + scaleRightSettingWidth (144 );
@@ -950,7 +1000,8 @@ private int handleUiSliderClick(SliderSetting slider, double mouseX,
9501000 private int handleUiColorClick (ColorSetting setting , double mouseX ,
9511001 double mouseY , int y )
9521002 {
953- int rowH = scaleRightSettingHeight (13 );
1003+ int rowH = Math .max (getMinimumReadableUiRowHeight (),
1004+ scaleRightSettingHeight (13 ));
9541005 int x1 = uiMenuX + 8 ;
9551006 int x2 = uiMenuX + uiMenuW - 8 ;
9561007 if (isInside (mouseX , mouseY , x1 , y , x2 , y + rowH ))
@@ -961,7 +1012,8 @@ private int handleUiColorClick(ColorSetting setting, double mouseX,
9611012 private int handleUiToggleClick (CheckboxSetting setting , double mouseX ,
9621013 double mouseY , int y )
9631014 {
964- int rowH = scaleRightSettingHeight (14 );
1015+ int rowH = Math .max (getMinimumReadableUiRowHeight (),
1016+ scaleRightSettingHeight (14 ));
9651017 int x1 = uiMenuX + 8 ;
9661018 int x2 = uiMenuX + uiMenuW - 8 ;
9671019 if (isInside (mouseX , mouseY , x1 , y , x2 , y + rowH ))
@@ -1406,8 +1458,11 @@ private List<Feature> getFilteredFeatures()
14061458 features .add (performanceOverlay );
14071459 }
14081460
1409- features .sort (Comparator .comparing (Feature ::getName ,
1410- String .CASE_INSENSITIVE_ORDER ));
1461+ if (globalSearch )
1462+ features .sort (buildSearchComparator (query ));
1463+ else
1464+ features .sort (Comparator .comparing (Feature ::getName ,
1465+ String .CASE_INSENSITIVE_ORDER ));
14111466 return features ;
14121467 }
14131468
@@ -1470,11 +1525,39 @@ && matchesSearch(performanceOverlay, query))
14701525 entries .add (new DisplayEntry (performanceOverlay , false ));
14711526 }
14721527
1473- entries .sort (Comparator .comparing (entry -> entry .feature ().getName (),
1474- String .CASE_INSENSITIVE_ORDER ));
1528+ Comparator <Feature > comparator = buildSearchComparator (query );
1529+ entries .sort (Comparator
1530+ .comparing ((DisplayEntry entry ) -> entry .feature (), comparator ));
14751531 return entries ;
14761532 }
14771533
1534+ private Comparator <Feature > buildSearchComparator (String query )
1535+ {
1536+ Comparator <String > indexComparator = (a , b ) -> {
1537+ int index1 = indexOfQuery (a , query );
1538+ int index2 = indexOfQuery (b , query );
1539+ if (index1 == index2 )
1540+ return 0 ;
1541+ if (index1 == -1 )
1542+ return 1 ;
1543+ if (index2 == -1 )
1544+ return -1 ;
1545+ return index1 - index2 ;
1546+ };
1547+
1548+ return Comparator .comparing (Feature ::getName , indexComparator )
1549+ .thenComparing (Feature ::getSearchTags , indexComparator )
1550+ .thenComparing (Feature ::getDescription , indexComparator )
1551+ .thenComparing (Feature ::getName , String .CASE_INSENSITIVE_ORDER );
1552+ }
1553+
1554+ private int indexOfQuery (String text , String query )
1555+ {
1556+ if (text == null || query == null )
1557+ return -1 ;
1558+ return text .toLowerCase (Locale .ROOT ).indexOf (query );
1559+ }
1560+
14781561 private List <DisplayEntry > getEnabledCategoryEntries ()
14791562 {
14801563 String query = searchText == null ? ""
@@ -1620,7 +1703,7 @@ private void appendSettingRows(List<SettingRow> rows, Feature owner,
16201703 ? Math .max (4 ,
16211704 Math .round (cfg ().getRowHeight ()
16221705 * getRightSettingsHeightScale () / 2F ))
1623- : Math .max (12 , Math .round (
1706+ : Math .max (cfg (). getMinimumRowHeight () , Math .round (
16241707 cfg ().getRowHeight () * getRightSettingsHeightScale ()));
16251708 rows .add (new SettingRow (owner , setting , depth , h ));
16261709
@@ -1805,6 +1888,7 @@ private String normalizeDisplayValue(String value)
18051888 private boolean isStyleSlider (SliderSetting slider )
18061889 {
18071890 return slider == cfg ().getUiOpacitySetting ()
1891+ || slider == cfg ().getBackgroundOpacitySetting ()
18081892 || slider == cfg ().getTooltipOpacitySetting ()
18091893 || slider == cfg ().getSettingsWidthSetting ()
18101894 || slider == cfg ().getSettingsHeightSetting ()
@@ -2006,6 +2090,43 @@ private void drawCenteredStringScaledInBox(GuiGraphics context, Font font,
20062090 drawStringScaled (context , font , text , x , y , color , false );
20072091 }
20082092
2093+ private void drawMarqueeStringScaledInBox (GuiGraphics context , Font font ,
2094+ String text , int x1 , int y1 , int x2 , int y2 , int color , int padX )
2095+ {
2096+ if (text == null || text .isEmpty ())
2097+ return ;
2098+
2099+ int innerX1 = x1 + Math .max (0 , padX );
2100+ int innerX2 = x2 - Math .max (0 , padX );
2101+ if (innerX2 <= innerX1 )
2102+ return ;
2103+
2104+ int innerW = innerX2 - innerX1 ;
2105+ int textW = Math .max (1 , scaledFontWidth (font , text ));
2106+ int textH = Math .max (1 , scaledFontHeight (font ));
2107+ int y = Math .round ((y1 + y2 ) * 0.5F - textH * 0.5F );
2108+
2109+ if (textW <= innerW )
2110+ {
2111+ int x = Math .round ((x1 + x2 ) * 0.5F - textW * 0.5F );
2112+ drawStringScaled (context , font , text , x , y , color , false );
2113+ return ;
2114+ }
2115+
2116+ int overflow = textW - innerW ;
2117+ int ticks = minecraft != null && minecraft .gui != null
2118+ ? minecraft .gui .getGuiTicks ()
2119+ : (int )(System .currentTimeMillis () / 50L );
2120+ float cycle = 220F ;
2121+ float phase = (ticks % (int )cycle ) / cycle ;
2122+ float pingPong = phase <= 0.5F ? phase * 2F : (1F - phase ) * 2F ;
2123+ int x = innerX1 - Math .round (overflow * pingPong );
2124+
2125+ context .enableScissor (innerX1 , y1 , innerX2 , y2 );
2126+ drawStringScaled (context , font , text , x , y , color , false );
2127+ context .disableScissor ();
2128+ }
2129+
20092130 @ Override
20102131 public void renderBackground (GuiGraphics context , int mouseX , int mouseY ,
20112132 float deltaTicks )
0 commit comments