2019-11-25 06:29:25 +00:00
|
|
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
2018-09-11 06:15:31 +00:00
|
|
|
|
2022-05-17 05:47:42 +00:00
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
2023-09-19 09:49:49 +00:00
|
|
|
import net.minecraft.client.gui.GuiGraphics;
|
2023-03-31 05:22:58 +00:00
|
|
|
import net.minecraft.client.gui.components.AbstractButton;
|
|
|
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
|
|
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
2022-08-03 05:46:33 +00:00
|
|
|
import net.minecraft.network.chat.Component;
|
2018-09-11 06:15:31 +00:00
|
|
|
|
2023-03-31 05:22:58 +00:00
|
|
|
public class ItemSelectionButton extends AbstractButton {
|
|
|
|
|
|
|
|
TBMButtonPress onPress;
|
2019-10-21 07:13:11 +00:00
|
|
|
private int itemStackID;
|
2018-09-11 06:15:31 +00:00
|
|
|
|
2023-03-31 05:22:58 +00:00
|
|
|
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, TBMButtonPress onPress) {
|
|
|
|
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
|
|
|
this.onPress = onPress;
|
2018-09-11 06:15:31 +00:00
|
|
|
this.itemStackID = itemStackID;
|
|
|
|
}
|
2020-11-12 08:10:01 +00:00
|
|
|
|
2019-10-21 07:13:11 +00:00
|
|
|
public int getID() {
|
2020-11-12 08:10:01 +00:00
|
|
|
return itemStackID;
|
2018-09-11 06:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-09-19 09:49:49 +00:00
|
|
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
|
2021-05-21 05:44:31 +00:00
|
|
|
if (visible) {
|
2020-11-12 08:10:01 +00:00
|
|
|
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
|
|
|
|
if (hovered) {
|
2023-09-19 09:49:49 +00:00
|
|
|
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
|
2019-10-21 07:13:11 +00:00
|
|
|
} else {
|
2023-09-19 09:49:49 +00:00
|
|
|
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
|
2018-09-11 06:15:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-12 08:10:01 +00:00
|
|
|
|
2023-03-31 05:22:58 +00:00
|
|
|
@Override
|
|
|
|
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
|
|
|
|
p_259858_.add(NarratedElementType.HINT, "Item " + this.itemStackID);
|
2020-11-12 08:10:01 +00:00
|
|
|
}
|
|
|
|
|
2023-03-31 05:22:58 +00:00
|
|
|
@Override
|
|
|
|
public void onPress() {
|
|
|
|
onPress.onPress(this);
|
2020-11-12 08:10:01 +00:00
|
|
|
}
|
2021-05-21 05:44:31 +00:00
|
|
|
}
|