@@ -30,19 +30,24 @@ public final class WaypointEditScreen extends Screen
3030 // removed unused: private final boolean isNew;
3131 // cached layout positions
3232 private int fieldsBaseX ;
33+ private int fieldsWidth ;
34+ private boolean narrow ;
3335 private int yName ;
3436 private int yXYZ ;
3537 // removed unused: private int yDim;
3638 private int yToggles ;
3739 // removed unused: private int yIcon;
3840 private int yColor ;
41+ private int xXYZ1 , xXYZ2 , xXYZ3 ;
42+ private int yXField , yYField , yZField ;
3943
4044 private TextFieldWidget nameField ;
4145 private TextFieldWidget xField ;
4246 private TextFieldWidget yField ;
4347 private TextFieldWidget zField ;
4448 private ButtonWidget colorButton ;
4549 private ColorSetting colorSetting ;
50+ private int alphaPercent = 100 ; // 1..100 persisted across picker
4651 // Draft values to preserve user input across color picker navigation
4752 private String draftName ;
4853 private String draftX ;
@@ -76,13 +81,17 @@ public WaypointEditScreen(Screen prev, WaypointsManager manager,
7681 @ Override
7782 protected void init ()
7883 {
79- int x = width / 2 - 150 ;
84+ int cw = Math .max (220 , Math .min (this .width - 40 , 360 ));
85+ narrow = cw < 340 ;
86+ narrow = cw < 340 ;
87+ int x = this .width / 2 - cw / 2 ;
8088 int y = 36 ;
8189 fieldsBaseX = x ;
90+ fieldsWidth = cw ;
8291
8392 // Name
8493 yName = y ;
85- nameField = new TextFieldWidget (client .textRenderer , x , y , 300 , 20 ,
94+ nameField = new TextFieldWidget (client .textRenderer , x , y , cw , 20 ,
8695 Text .literal ("" ));
8796 String baseName = waypoint .getName () == null ? "" : waypoint .getName ();
8897 nameField .setText (draftName != null ? draftName : baseName );
@@ -91,22 +100,31 @@ protected void init()
91100 // increased gap to avoid XYZ labels overlapping name field
92101 y += 44 ;
93102
94- // Position fields
103+ // Position fields (responsive)
95104 BlockPos p = waypoint .getPos ();
96105 yXYZ = y ;
97- xField = new TextFieldWidget (client .textRenderer , x , y , 95 , 20 ,
106+ int gap = 8 ;
107+ int colW = (cw - gap * 2 ) / 3 ;
108+ xXYZ1 = x ;
109+ xXYZ2 = x + colW + gap ;
110+ xXYZ3 = x + (colW + gap ) * 2 ;
111+ xField = new TextFieldWidget (client .textRenderer , xXYZ1 , y , colW , 20 ,
98112 Text .literal ("" ));
99113 xField .setText (draftX != null ? draftX : Integer .toString (p .getX ()));
100114 addDrawableChild (xField );
101- yField = new TextFieldWidget (client .textRenderer , x + 102 , y , 95 , 20 ,
102- Text .literal ("" ));
115+ yField = new TextFieldWidget (client .textRenderer , xXYZ2 ,
116+ narrow ? y + 28 : y , colW , 20 , Text .literal ("" ));
103117 yField .setText (draftY != null ? draftY : Integer .toString (p .getY ()));
104118 addDrawableChild (yField );
105- zField = new TextFieldWidget (client .textRenderer , x + 204 , y , 96 , 20 ,
106- Text .literal ("" ));
119+ zField = new TextFieldWidget (client .textRenderer , xXYZ3 ,
120+ narrow ? y + 56 : y , colW , 20 , Text .literal ("" ));
107121 zField .setText (draftZ != null ? draftZ : Integer .toString (p .getZ ()));
108122 addDrawableChild (zField );
109- y += 28 ;
123+ // Track individual field Y for labels
124+ yXField = y ;
125+ yYField = narrow ? y + 28 : y ;
126+ yZField = narrow ? y + 56 : y ;
127+ y += narrow ? 84 : 28 ;
110128
111129 // Dimension cycle
112130 // removed yDim tracking
@@ -123,18 +141,20 @@ protected void init()
123141 dimIndex = (dimIndex + 1 ) % dims .length ;
124142 b .setMessage (
125143 Text .literal ("Dimension: " + dims [dimIndex ].name ()));
126- }).dimensions (x , y , 300 , 20 ).build ();
144+ }).dimensions (x , y , cw , 20 ).build ();
127145 addDrawableChild (dimButton );
128146 y += 28 ;
129147
130148 // Opposite toggle
131149 yToggles = y ;
150+ int halfGap = 10 ;
151+ int halfW = (cw - halfGap ) / 2 ;
132152 oppositeButton = ButtonWidget .builder (
133153 Text .literal (buttonLabel ("Opposite" , waypoint .isOpposite ())), b -> {
134154 waypoint .setOpposite (!waypoint .isOpposite ());
135155 b .setMessage (Text
136156 .literal (buttonLabel ("Opposite" , waypoint .isOpposite ())));
137- }).dimensions (x , y , 145 , 20 ).build ();
157+ }).dimensions (x , y , halfW , 20 ).build ();
138158 addDrawableChild (oppositeButton );
139159
140160 // Visible toggle
@@ -145,7 +165,7 @@ protected void init()
145165 b .setMessage (Text
146166 .literal (buttonLabel ("Visible" , waypoint .isVisible ())));
147167 })
148- .dimensions (x + 155 , y , 145 , 20 ).build ();
168+ .dimensions (x + halfW + halfGap , y , halfW , 20 ).build ();
149169 addDrawableChild (visibleButton );
150170 y += 28 ;
151171
@@ -159,7 +179,7 @@ protected void init()
159179 b .setMessage (
160180 Text .literal (buttonLabel ("Lines" , waypoint .isLines ())));
161181 })
162- .dimensions (x , y , 300 , 20 ).build ();
182+ .dimensions (x , y , cw , 20 ).build ();
163183 addDrawableChild (linesButton );
164184 y += 28 ;
165185
@@ -179,7 +199,7 @@ protected void init()
179199 .builder (Text .literal ("Icon: " + ICONS [iconIndex ]), b -> {
180200 iconIndex = (iconIndex + 1 ) % ICONS .length ;
181201 b .setMessage (Text .literal ("Icon: " + ICONS [iconIndex ]));
182- }).dimensions (x , y , 300 , 20 ).build ();
202+ }).dimensions (x , y , cw , 20 ).build ();
183203 addDrawableChild (iconButton );
184204 y += 28 ;
185205 // extra spacing before color row
@@ -192,6 +212,14 @@ protected void init()
192212 if (colorSetting == null )
193213 colorSetting = new ColorSetting ("Waypoint Color" , new Color (
194214 (waypoint .getColor () & 0x00FFFFFF ) | 0xFF000000 , true ));
215+ // Initialize alpha from waypoint once
216+ if (alphaPercent == 100 )
217+ {
218+ int a = (waypoint .getColor () >>> 24 ) & 0xFF ;
219+ if (a > 0 )
220+ alphaPercent = Math .max (1 ,
221+ Math .min (100 , (int )Math .round (a / 255.0 * 100 )));
222+ }
195223 colorButton = ButtonWidget .builder (
196224 Text .literal (
197225 "Pick color (#" + toHex6 (colorSetting .getColorI ()) + ")" ),
@@ -203,25 +231,64 @@ protected void init()
203231 draftY = yField .getText ();
204232 draftZ = zField .getText ();
205233 client .setScreen (new EditColorScreen (this , colorSetting ));
206- }).dimensions (x , y , 300 - 24 , 20 ).build ();
234+ }).dimensions (x , y , cw - 24 , 20 ).build ();
207235 addDrawableChild (colorButton );
208236 y += 28 ;
209237
238+ // Transparency slider (1%..100%)
239+ addDrawableChild (
240+ new net .minecraft .client .gui .widget .SliderWidget (x , y , fieldsWidth ,
241+ 20 , Text .literal ("Transparency: " + alphaPercent + "%" ),
242+ (alphaPercent - 1 ) / 99.0 )
243+ {
244+ @ Override
245+ protected void updateMessage ()
246+ {
247+ int val = 1 + (int )Math .round (value * 99.0 );
248+ alphaPercent = Math .max (1 , Math .min (100 , val ));
249+ setMessage (
250+ Text .literal ("Transparency: " + alphaPercent + "%" ));
251+ }
252+
253+ @ Override
254+ protected void applyValue ()
255+ {
256+ int val = 1 + (int )Math .round (value * 99.0 );
257+ alphaPercent = Math .max (1 , Math .min (100 , val ));
258+ }
259+ });
260+ y += 28 ;
261+
210262 // Buttons
211263 addDrawableChild (ButtonWidget
212264 .builder (Text .literal ("Use player pos" ), b -> usePlayerPos ())
213- .dimensions (x , y , 145 , 20 ).build ());
265+ .dimensions (x , y , halfW , 20 ).build ());
214266 addDrawableChild (
215267 ButtonWidget .builder (Text .literal ("Delete" ), b -> doDelete ())
216- .dimensions (x + 155 , y , 145 , 20 ).build ());
268+ .dimensions (x + halfW + halfGap , y , halfW , 20 ).build ());
217269 y += 28 ;
218270
219271 addDrawableChild (
220272 ButtonWidget .builder (Text .literal ("Save" ), b -> saveAndBack ())
221- .dimensions (x , height - 52 , 145 , 20 ).build ());
273+ .dimensions (x , height - 52 , halfW , 20 ).build ());
222274 addDrawableChild (ButtonWidget
223275 .builder (Text .literal ("Cancel" ), b -> client .setScreen (prev ))
224- .dimensions (x + 155 , height - 52 , 145 , 20 ).build ());
276+ .dimensions (x + halfW + halfGap , height - 52 , halfW , 20 ).build ());
277+ }
278+
279+ @ Override
280+ public void resize (net .minecraft .client .MinecraftClient client , int width ,
281+ int height )
282+ {
283+ // Preserve current edits before re-initializing layout for new size
284+ if (nameField != null )
285+ {
286+ draftName = nameField .getText ();
287+ draftX = xField .getText ();
288+ draftY = yField .getText ();
289+ draftZ = zField .getText ();
290+ }
291+ init (client , width , height );
225292 }
226293
227294 private static String buttonLabel (String name , boolean on )
@@ -268,8 +335,10 @@ private void saveAndBack()
268335 // Icon
269336 waypoint .setIcon (ICONS [iconIndex ]);
270337
271- // Color
272- waypoint .setColor (colorSetting .getColorI ());
338+ // Color + transparency
339+ int saveAlpha = (int )Math
340+ .round (Math .max (1 , Math .min (100 , alphaPercent )) / 100.0 * 255 );
341+ waypoint .setColor (colorSetting .getColorI (saveAlpha ));
273342
274343 manager .addOrUpdate (waypoint );
275344 if (listScreen != null )
@@ -301,18 +370,20 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta)
301370 int x = fieldsBaseX ;
302371 context .drawText (client .textRenderer , "Name" , x , yName - 18 ,
303372 Colors .LIGHT_GRAY , false );
304- context .drawText (client .textRenderer , "X" , x , yXYZ - 18 ,
305- Colors .LIGHT_GRAY , false );
306- context .drawText (client .textRenderer , "Y" , x + 102 , yXYZ - 18 ,
307- Colors .LIGHT_GRAY , false );
308- context .drawText (client .textRenderer , "Z" , x + 204 , yXYZ - 18 ,
373+ context .drawText (client .textRenderer , "X" , xXYZ1 , yXYZ - 18 ,
309374 Colors .LIGHT_GRAY , false );
375+ context .drawText (client .textRenderer , "Y" , xXYZ2 ,
376+ (narrow ? yYField : yXYZ ) - 18 , Colors .LIGHT_GRAY , false );
377+ context .drawText (client .textRenderer , "Z" , xXYZ3 ,
378+ (narrow ? yZField : yXYZ ) - 18 , Colors .LIGHT_GRAY , false );
310379 // removed explicit "Color" text label to avoid redundancy and crowding
311380
312381 // Color preview box
313- int boxX = x + 300 - 20 ;
382+ int boxX = x + fieldsWidth - 20 ;
314383 int boxY = yColor ;
315- int color = colorSetting .getColorI ();
384+ int alpha = (int )Math
385+ .round (Math .max (1 , Math .min (100 , alphaPercent )) / 100.0 * 255 );
386+ int color = colorSetting .getColorI (alpha );
316387 context .fill (boxX - 1 , boxY - 1 , boxX + 18 , boxY + 18 , Colors .GRAY );
317388 context .fill (boxX , boxY , boxX + 16 , boxY + 16 , color );
318389
0 commit comments