forked from SkyblockerMod/Skyblocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SkyblockerMod#713 from kevinthegreat1/waypoint
Waypoints
- Loading branch information
Showing
24 changed files
with
1,278 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/de/hysky/skyblocker/mixins/accessors/CheckboxWidgetAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.hysky.skyblocker.mixins.accessors; | ||
|
||
import net.minecraft.client.gui.widget.CheckboxWidget; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(CheckboxWidget.class) | ||
public interface CheckboxWidgetAccessor { | ||
@Accessor | ||
void setChecked(boolean checked); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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, height - 8, 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; | ||
} | ||
|
||
@Override | ||
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) { | ||
if (islandWidget.isMouseOver(mouseX, mouseY) && islandWidget.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount)) { | ||
return true; | ||
} | ||
return super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount); | ||
} | ||
|
||
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(); | ||
} | ||
} |
Oops, something went wrong.