11package me .contaria .seedqueue .gui .wall ;
22
33import me .contaria .speedrunapi .util .TextUtil ;
4+ import net .minecraft .client .font .TextRenderer ;
45import net .minecraft .client .toast .Toast ;
56import net .minecraft .client .toast .ToastManager ;
67import net .minecraft .client .util .math .MatrixStack ;
8+ import net .minecraft .text .StringRenderable ;
79import net .minecraft .text .Text ;
810import net .minecraft .util .Util ;
911
12+ import java .util .List ;
13+
1014public class SeedQueueBenchmarkToast implements Toast {
1115 private final SeedQueueWallScreen wall ;
1216 private final Text title ;
@@ -21,10 +25,6 @@ public SeedQueueBenchmarkToast(SeedQueueWallScreen wall) {
2125
2226 @ Override
2327 public Visibility draw (MatrixStack matrices , ToastManager manager , long startTime ) {
24- manager .getGame ().getTextureManager ().bindTexture (TOASTS_TEX );
25- manager .drawTexture (matrices , 0 , 0 , 0 , 0 , this .getWidth (), this .getHeight ());
26- manager .getGame ().textRenderer .draw (matrices , this .title , 7.0f , 7.0f , 0xFFFF00 | 0xFF000000 );
27-
2828 this .finished |= !this .wall .isBenchmarking ();
2929
3030 if (this .finished && !this .fadeOut && !this .wall .showFinishedBenchmarkResults ) {
@@ -33,7 +33,40 @@ public Visibility draw(MatrixStack matrices, ToastManager manager, long startTim
3333
3434 double time = (this .finished ? this .wall .benchmarkFinish : Util .getMeasuringTimeMs ()) - this .wall .benchmarkStart ;
3535 double rps = Math .round (this .wall .benchmarkedSeeds / (time / 10000.0 )) / 10.0 ;
36- manager .getGame ().textRenderer .draw (matrices , TextUtil .translatable ("seedqueue.menu.benchmark.result" , this .wall .benchmarkedSeeds , Math .round (time / 1000.0 ), rps ), 7.0f , 18.0f , -1 );
36+
37+ TextRenderer textRenderer = manager .getGame ().textRenderer ;
38+
39+ StringRenderable full = TextUtil .translatable (
40+ "seedqueue.menu.benchmark.result" ,
41+ this .wall .benchmarkedSeeds ,
42+ Math .round (time / 1000.0 ),
43+ rps
44+ );
45+
46+ List <StringRenderable > lines = textRenderer .wrapLines (full , this .getWidth () - 12 );
47+
48+ manager .getGame ().getTextureManager ().bindTexture (TOASTS_TEX );
49+
50+ // Top of the toast texture
51+ manager .drawTexture (matrices , 0 , 0 , 0 , 0 , this .getWidth (), 16 );
52+
53+ // Center
54+ int textureY = 16 ;
55+ for (int i = 0 ; i < lines .size (); i ++) {
56+ manager .drawTexture (matrices , 0 , textureY , 0 , 16 , this .getWidth (), textRenderer .fontHeight + 2 );
57+ textureY += textRenderer .fontHeight + 2 ;
58+ }
59+
60+ // Bottom
61+ manager .drawTexture (matrices , 0 , textureY , 0 , 28 , this .getWidth (), 4 );
62+
63+ textRenderer .draw (matrices , this .title , 7.0f , 7.0f , 0xFFFF00 | 0xFF000000 );
64+
65+ float currentY = 18.0f ;
66+ for (StringRenderable line : lines ) {
67+ textRenderer .draw (matrices , line , 7.0f , currentY , -1 );
68+ currentY += textRenderer .fontHeight + 2 ;
69+ }
3770
3871 return this .fadeOut ? Visibility .HIDE : Visibility .SHOW ;
3972 }
0 commit comments