-
-
Notifications
You must be signed in to change notification settings - Fork 509
/
TranslationButton.java
43 lines (36 loc) · 1.67 KB
/
TranslationButton.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package mekanism.client.gui.element.button;
import java.util.function.Supplier;
import mekanism.api.text.EnumColor;
import mekanism.api.text.ILangEntry;
import mekanism.client.gui.IGuiWrapper;
import mekanism.client.render.MekanismRenderer;
import net.minecraft.client.gui.GuiGraphics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TranslationButton extends MekanismButton {
@Nullable
private final Supplier<EnumColor> colorSupplier;
public TranslationButton(IGuiWrapper gui, int x, int y, int width, int height, ILangEntry translationHelper, @NotNull Runnable onPress) {
this(gui, x, y, width, height, translationHelper, onPress, null, null);
}
public TranslationButton(IGuiWrapper gui, int x, int y, int width, int height, ILangEntry translationHelper, @NotNull Runnable onPress, @Nullable IHoverable onHover,
@Nullable Supplier<EnumColor> colorSupplier) {
super(gui, x, y, width, height, translationHelper.translate(), onPress, onHover);
this.colorSupplier = colorSupplier;
}
@Override
public void drawBackground(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
if (colorSupplier == null) {
MekanismRenderer.resetColor(guiGraphics);
super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks);
return;
}
MekanismRenderer.color(guiGraphics, colorSupplier.get());
super.drawBackground(guiGraphics, mouseX, mouseY, partialTicks);
MekanismRenderer.resetColor(guiGraphics);
}
@Override
protected boolean resetColorBeforeRender() {
return false;
}
}