Skip to content

Commit c9b88a3

Browse files
feat: delete all landing blocks button (#54)
1 parent 01d007d commit c9b88a3

1 file changed

Lines changed: 67 additions & 1 deletion

File tree

common/src/main/java/io/github/kurrycat/mpkmod/gui/screens/LandingBlockGuiScreen.java

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Renderer2D;
66
import io.github.kurrycat.mpkmod.compatibility.MCClasses.WorldInteraction;
77
import io.github.kurrycat.mpkmod.gui.ComponentScreen;
8-
import io.github.kurrycat.mpkmod.gui.components.Button;
98
import io.github.kurrycat.mpkmod.gui.components.*;
9+
import io.github.kurrycat.mpkmod.gui.components.Button;
1010
import io.github.kurrycat.mpkmod.gui.interfaces.KeyInputListener;
1111
import io.github.kurrycat.mpkmod.gui.interfaces.MouseInputListener;
1212
import io.github.kurrycat.mpkmod.landingblock.LandingBlock;
@@ -22,6 +22,7 @@ public class LandingBlockGuiScreen extends ComponentScreen {
2222
public static Color lbListColorBg = new Color(31, 31, 31, 150);
2323

2424
private LBList lbList;
25+
private DeletePane deletePane;
2526

2627
public static List<Vector3D> calculateLBOffsets() {
2728
List<Vector3D> returnOffsets = new ArrayList<>();
@@ -47,6 +48,15 @@ public void onGuiInit() {
4748
new Vector2D(3 / 5D, 0.9)
4849
);
4950
addChild(lbList, PERCENT.ALL, Anchor.TOP_CENTER);
51+
lbList.topCover.addChild(
52+
new Button(
53+
"Delete All",
54+
new Vector2D(20, 1),
55+
new Vector2D(50, 11),
56+
mouseButton -> this.openPane(deletePane)
57+
),
58+
PERCENT.NONE, Anchor.CENTER_RIGHT
59+
);
5060
lbList.topCover.addChild(
5161
new Button(
5262
"x",
@@ -56,6 +66,9 @@ public void onGuiInit() {
5666
),
5767
PERCENT.NONE, Anchor.CENTER_RIGHT
5868
);
69+
70+
deletePane = new DeletePane();
71+
passPositionTo(deletePane, PERCENT.ALL, Anchor.CENTER);
5972
}
6073

6174
@Override
@@ -263,4 +276,57 @@ public boolean handleKeyInput(int keyCode, int scanCode, int modifiers, boolean
263276
);
264277
}
265278
}
279+
280+
public static class DeletePane extends Pane<LandingBlockGuiScreen> {
281+
282+
public DeletePane() {
283+
super(Vector2D.ZERO, new Vector2D(0.4, 0.4));
284+
285+
addChild(
286+
new TextRectangle(
287+
new Vector2D(0, 10),
288+
new Vector2D(100, 40),
289+
"Are you sure you want to",
290+
null,
291+
Color.WHITE
292+
),
293+
PERCENT.NONE, Anchor.TOP_CENTER
294+
);
295+
296+
addChild(
297+
new TextRectangle(
298+
new Vector2D(0, 20),
299+
new Vector2D(100, 40),
300+
"delete all landing blocks?",
301+
null,
302+
Color.WHITE
303+
),
304+
PERCENT.NONE, Anchor.TOP_CENTER
305+
);
306+
307+
addChild(
308+
new Button(
309+
"Cancel",
310+
new Vector2D(20, 10),
311+
new Vector2D(60, 17),
312+
mouseButton -> this.close()
313+
),
314+
PERCENT.NONE, Anchor.BOTTOM_LEFT
315+
);
316+
317+
addChild(
318+
new Button(
319+
"Confirm",
320+
new Vector2D(20, 10),
321+
new Vector2D(60, 17),
322+
mouseButton -> {
323+
this.paneHolder.lbList.items.clear();
324+
LandingBlockGuiScreen.lbs.clear();
325+
this.close();
326+
}
327+
),
328+
PERCENT.NONE, Anchor.BOTTOM_RIGHT
329+
);
330+
}
331+
}
266332
}

0 commit comments

Comments
 (0)