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
46
47
48
49
50
51
52
53
54
55
56
|
package com.arslaancodes.arslaansmagichax.screens.clickgui.setting;
import com.arslaancodes.arslaansmagichax.modules.settings.ModeSetting;
import com.arslaancodes.arslaansmagichax.modules.settings.Setting;
import com.arslaancodes.arslaansmagichax.screens.clickgui.ModuleButton;
import java.awt.*;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.network.chat.Component;
public class ModeBox extends Component {
private ModeSetting modeSetting = (ModeSetting) setting;
public ModeBox(Setting setting, ModuleButton parent, int offset) {
super(setting, parent, offset);
this.modeSetting = (ModeSetting) setting;
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
String displayText = modeSetting.getName() + ": " + modeSetting.getMode();
int textWidth = mc.font.width(displayText);
int padding = 5;
int boxWidth = Math.max(parent.parent.width, textWidth + padding * 2);
int alpha = isHovered(mouseX, mouseY) ? 230 : 160;
context.fill(
parent.parent.x,
parent.parent.y + parent.offset + offset,
parent.parent.x + boxWidth,
parent.parent.y + parent.offset + offset + parent.parent.height,
new Color(30, 30, 47, alpha).getRGB()
);
context.drawString(
mc.font,
Component.literal(displayText),
parent.parent.x + padding, // left padding
parent.parent.y + parent.offset + offset + (parent.parent.height - mc.font.lineHeight) / 2,
Color.white.getRGB()
);
}
@Override
public void mouseClicked(double mouseX, double mouseY, int button) {
if (isHovered(mouseX, mouseY) && button == 0) {
modeSetting.cycle();
}
}
@Override
public void mouseReleased(double mouseX, double mouseY, int button) {
super.mouseReleased(mouseX, mouseY, button);
}
}
|