aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-05-14 22:58:56 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-05-24 19:51:46 -0400
commit7bf3958477c179185f9532cebffc36f218aa3bd8 (patch)
tree375325e936948bf088de79c049fd26d91ccb9e24 /src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java
parente9bd404a36ce3a69e62e97986d42e7f3635ab67d (diff)
downloadSkyblocker-7bf3958477c179185f9532cebffc36f218aa3bd8.tar.gz
Skyblocker-7bf3958477c179185f9532cebffc36f218aa3bd8.tar.bz2
Skyblocker-7bf3958477c179185f9532cebffc36f218aa3bd8.zip
Port waypoints config screens
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java
new file mode 100644
index 00000000..932bc144
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java
@@ -0,0 +1,65 @@
+package de.hysky.skyblocker.skyblock.waypoint;
+
+import com.google.common.collect.Multimap;
+import com.google.common.collect.MultimapBuilder;
+import de.hysky.skyblocker.utils.Location;
+import de.hysky.skyblocker.utils.Utils;
+import de.hysky.skyblocker.utils.waypoint.NamedWaypoint;
+import de.hysky.skyblocker.utils.waypoint.WaypointCategory;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.text.Text;
+
+import java.util.Arrays;
+
+public abstract class AbstractWaypointsScreen<T extends Screen> extends Screen {
+ protected final T parent;
+ protected final Multimap<String, WaypointCategory> waypoints;
+ protected String island;
+ protected WaypointsListWidget waypointsListWidget;
+ protected DropdownWidget<Location> islandWidget;
+
+ public AbstractWaypointsScreen(Text title, T parent) {
+ this(title, parent, MultimapBuilder.hashKeys().arrayListValues().build());
+ }
+
+ public AbstractWaypointsScreen(Text title, T parent, Multimap<String, WaypointCategory> waypoints) {
+ this(title, parent, waypoints, Utils.getLocationRaw());
+ }
+
+ public AbstractWaypointsScreen(Text title, T parent, Multimap<String, WaypointCategory> waypoints, String island) {
+ super(title);
+ this.parent = parent;
+ this.waypoints = waypoints;
+ this.island = island;
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+ waypointsListWidget = addDrawableChild(new WaypointsListWidget(client, this, width, height - 96, 32, 24));
+ islandWidget = addDrawableChild(new DropdownWidget<>(client, width - 160, 8, 150, Arrays.asList(Location.values()), this::islandChanged, Location.from(island)));
+ }
+
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ if (islandWidget.mouseClicked(mouseX, mouseY, button)) {
+ return true;
+ }
+ boolean mouseClicked = super.mouseClicked(mouseX, mouseY, button);
+ updateButtons();
+ return mouseClicked;
+ }
+
+ protected void islandChanged(Location location) {
+ island = location.id();
+ waypointsListWidget.setIsland(island);
+ }
+
+ protected abstract boolean isEnabled(NamedWaypoint waypoint);
+
+ protected abstract void enabledChanged(NamedWaypoint waypoint, boolean enabled);
+
+ protected void updateButtons() {
+ waypointsListWidget.updateButtons();
+ }
+}