aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java
diff options
context:
space:
mode:
authorVeritasDL <121319869+VeritasDL@users.noreply.github.com>2024-05-14 18:06:55 -0400
committerVeritasDL <121319869+VeritasDL@users.noreply.github.com>2024-05-14 19:16:00 -0400
commit713c5c215622f1448d1bbd8e1d47effe34d47a00 (patch)
tree4761d6615fa2e6a326cdd0fd3d82264b7312eaad /src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java
parentdf8cd71d04ae9d64240472912ff929724047302f (diff)
downloadSkyblocker-713c5c215622f1448d1bbd8e1d47effe34d47a00.tar.gz
Skyblocker-713c5c215622f1448d1bbd8e1d47effe34d47a00.tar.bz2
Skyblocker-713c5c215622f1448d1bbd8e1d47effe34d47a00.zip
Machinika: Museum
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java68
1 files changed, 47 insertions, 21 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java
index 7db78590..516aed32 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java
@@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor;
import de.hysky.skyblocker.utils.scheduler.MessageScheduler;
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
@@ -25,18 +26,24 @@ public class QuickNavButton extends ClickableWidget {
/**
* Checks if the current tab is a top tab based on its index.
+ *
* @return true if the index is less than 6, false otherwise.
*/
private boolean isTopTab() {
- return index < 6;
+ if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) {
+ return index < 6;
+ } else {
+ return index < 7;
+ }
}
/**
* Constructs a new QuickNavButton with the given parameters.
- * @param index the index of the button.
+ *
+ * @param index the index of the button.
* @param toggled the toggled state of the button.
* @param command the command to execute when the button is clicked.
- * @param icon the icon to display on the button.
+ * @param icon the icon to display on the button.
*/
public QuickNavButton(int index, boolean toggled, String command, ItemStack icon) {
super(0, 0, 26, 32, Text.empty());
@@ -49,18 +56,24 @@ public class QuickNavButton extends ClickableWidget {
private void updateCoordinates() {
Screen screen = MinecraftClient.getInstance().currentScreen;
if (screen instanceof HandledScreen<?> handledScreen) {
- int x = ((HandledScreenAccessor)handledScreen).getX();
- int y = ((HandledScreenAccessor)handledScreen).getY();
- int h = ((HandledScreenAccessor)handledScreen).getBackgroundHeight();
+ int x = ((HandledScreenAccessor) handledScreen).getX();
+ int y = ((HandledScreenAccessor) handledScreen).getY();
+ int h = ((HandledScreenAccessor) handledScreen).getBackgroundHeight();
if (h > 166) --h; // why is this even a thing
- this.setX(x + this.index % 6 * 26 + 4);
- this.setY(this.index < 6 ? y - 26 : y + h - 4);
+ if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) {
+ this.setX(x + this.index % 6 * 26 + 4);
+ this.setY(this.index < 6 ? y - 26 : y + h - 4);
+ } else {
+ this.setX(x + this.index % 7 * 25);
+ this.setY(this.index < 7 ? y - 25 : y + h - 4);
+ }
}
}
/**
* Handles click events. If the button is not currently toggled,
* it sets the toggled state to true and sends a message with the command after cooldown.
+ *
* @param mouseX the x-coordinate of the mouse click
* @param mouseY the y-coordinate of the mouse click
*/
@@ -78,9 +91,10 @@ public class QuickNavButton extends ClickableWidget {
* The method first updates the coordinates of the button,
* then calculates appropriate values for rendering based on its current state,
* and finally draws both the background and icon of the button on screen.
+ *
* @param context the context in which to render the button
- * @param mouseX the x-coordinate of the mouse cursor
- * @param mouseY the y-coordinate of the mouse cursor
+ * @param mouseX the x-coordinate of the mouse cursor
+ * @param mouseY the y-coordinate of the mouse cursor
*/
@Override
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
@@ -94,19 +108,31 @@ public class QuickNavButton extends ClickableWidget {
// Render the button texture
int y = this.getY();
- if (this.toggled) {
- if (this.index < 6) y -= 2;
- } else {
- y += (this.index >= 6) ? 4 : -2;
- }
- int height = this.height - ((this.toggled ) ? 0 : 4);
+ if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) {
+ if (this.toggled) {
+ if (this.index < 6) y -= 2;
+ } else {
+ y += (this.index >= 6) ? 4 : -2;
+ }
+ int height = this.height - ((this.toggled) ? 0 : 4);
- context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height);
-
- // Render the button icon
- int yOffset = !this.toggled && this.index < 6 ? 1 : 0;
- context.drawItem(this.icon, this.getX() + 5, this.getY() + 6 + yOffset);
+ context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height);
+ // Render the button icon
+ int yOffset = !this.toggled && this.index < 6 ? 1 : 0;
+ context.drawItem(this.icon, this.getX() + 5, this.getY() + 6 + yOffset);
+ } else {
+ if (this.toggled) {
+ if (this.index < 7) y -= 2;
+ } else {
+ y += (this.index >= 7) ? 4 : -2;
+ }
+ int height = this.height - ((this.toggled) ? 0 : 4);
+ context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width - 1, height);
+ // Render the button icon
+ int yOffset = !this.toggled && this.index < 7 ? 1 : 0;
+ context.drawItem(this.icon, this.getX() + 4, this.getY() + 6 + yOffset);
+ }
RenderSystem.enableDepthTest();
}