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
44
45
|
package net.justlearning.arslaan3102.arslaansmagichax.screens;
import net.justlearning.arslaan3102.arslaansmagichax.modules.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import java.awt.Color;
public class ClickGUIModuleButton {
public Module module;
public ClickGUIFrame parent;
public int offset;
public ClickGUIModuleButton(Module module, ClickGUIFrame parent, int offset) {
this.module = module;
this.parent = parent;
this.offset = offset;
}
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
int alpha = isHovered(mouseX, mouseY) ? 230 : 160;
context.fill(parent.x, parent.y + offset, parent.x + parent.width, parent.y + offset + parent.height, new Color(30, 30, 47, alpha).getRGB());
String text = module.getName();
int textX = parent.x + 5;
int textY = parent.y + offset + (parent.height - parent.mc.textRenderer.fontHeight) / 2;
int textColor = module.isEnabled() ? new Color(252, 210, 77, 255).getRGB() : Color.white.getRGB();
context.drawTextWithShadow(parent.mc.textRenderer, Text.literal(text), textX, textY, textColor);
}
public void mouseClicked(double mouseX, double mouseY, int button) {
if (isHovered(mouseX, mouseY) && button == 0) {
module.toggle();
}
}
public boolean isHovered(double mouseX, double mouseY) {
return mouseX > parent.x && mouseX < parent.x + parent.width && mouseY > parent.y + offset && mouseY < parent.y + offset + parent.height;
}
}
|