Skip to content

Commit 9f3bda6

Browse files
committed
Fixed waypoint manager bug, added top/bottom buttons
1 parent 8b1948a commit 9f3bda6

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

src/main/java/net/wurstclient/clickgui/screens/WaypointEditScreen.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public final class WaypointEditScreen extends Screen
5656

5757
private int dimIndex;
5858
private ButtonWidget dimButton;
59+
// Draft storage for dimension selection when navigating to child screens
60+
private Integer draftDimIndex;
5961

6062
private static final String[] ICON_KEYS =
6163
new String[]{"square", "circle", "triangle", "star", "diamond", "skull",
@@ -150,6 +152,13 @@ protected void init()
150152
dimIndex = i;
151153
break;
152154
}
155+
// If we have a draft index (from opening a child screen), restore
156+
// it
157+
if(draftDimIndex != null)
158+
{
159+
dimIndex = draftDimIndex;
160+
draftDimIndex = null;
161+
}
153162
dimButton = ButtonWidget
154163
.builder(Text.literal("Dimension: " + dims[dimIndex].name()),
155164
b -> {
@@ -249,6 +258,9 @@ protected void init()
249258
draftX = xField.getText();
250259
draftY = yField.getText();
251260
draftZ = zField.getText();
261+
// Preserve selected dimension index so it isn't lost when
262+
// the child color screen re-initializes this screen.
263+
draftDimIndex = dimIndex;
252264
client.setScreen(new EditColorScreen(this, colorSetting));
253265
}).dimensions(x, y, cw - 24, 20).build();
254266
addDrawableChild(colorButton);
@@ -309,6 +321,8 @@ public void resize(net.minecraft.client.MinecraftClient client, int width,
309321
draftX = xField.getText();
310322
draftY = yField.getText();
311323
draftZ = zField.getText();
324+
// Preserve dimension selection across resize/child screens
325+
draftDimIndex = dimIndex;
312326
}
313327
init(client, width, height);
314328
}

src/main/java/net/wurstclient/clickgui/screens/WaypointsScreen.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,23 @@ protected void init()
196196
// Scroll buttons (▲ / ▼) positioned just to the right of the 300px list
197197
// area
198198
int arrowX = x + 305; // a little to the right of the list
199+
// "Top" button above the up-arrow that jumps directly to the top
200+
addDrawableChild(ButtonWidget.builder(Text.literal("▲▲"), b -> {
201+
scrollToTop();
202+
}).dimensions(arrowX + 20, Math.max(0, viewportTop - 24), 20, 20)
203+
.build());
204+
// Up arrow (move up by a few rows)
199205
addDrawableChild(ButtonWidget.builder(Text.literal("▲"), b -> {
200206
scrollBy(-ROW_HEIGHT * 3);
201-
}).dimensions(arrowX, viewportTop, 20, 20).build());
207+
}).dimensions(arrowX + 20, viewportTop, 20, 20).build());
208+
// Down arrow (move down by a few rows)
202209
addDrawableChild(ButtonWidget.builder(Text.literal("▼"), b -> {
203210
scrollBy(ROW_HEIGHT * 3);
204-
}).dimensions(arrowX, viewportBottom - 20, 20, 20).build());
211+
}).dimensions(arrowX + 20, viewportBottom - 20, 20, 20).build());
212+
// "Bottom" button below the down-arrow that jumps directly to bottom
213+
addDrawableChild(ButtonWidget.builder(Text.literal("▼▼"), b -> {
214+
scrollToBottom();
215+
}).dimensions(arrowX + 20, viewportBottom, 20, 20).build());
205216

206217
addDrawableChild(ButtonWidget
207218
.builder(Text.literal("Back"), b -> client.setScreen(prev))
@@ -405,4 +416,17 @@ void saveNow()
405416
{
406417
manager.save(resolveWorldId());
407418
}
419+
420+
private void scrollToTop()
421+
{
422+
scroll = 0;
423+
}
424+
425+
private void scrollToBottom()
426+
{
427+
int contentHeight = rows.size() * ROW_HEIGHT;
428+
int maxScroll =
429+
Math.max(0, contentHeight - (viewportBottom - viewportTop));
430+
scroll = maxScroll;
431+
}
408432
}

0 commit comments

Comments
 (0)