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
57
58
59
60
61
62
63
64
65
66
67
68
|
package de.hysky.skyblocker.skyblock.dwarven;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud.Commission;
import de.hysky.skyblocker.skyblock.tabhud.widget.hud.HudCommsWidget;
import de.hysky.skyblocker.utils.render.RenderHelper;
import it.unimi.dsi.fastutil.ints.IntIntPair;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
import java.awt.*;
import java.util.List;
public class DwarvenHudConfigScreen extends Screen {
private static final List<DwarvenHud.Commission> CFG_COMMS = List.of(new Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%"));
private int hudX = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.x;
private int hudY = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.y;
private final Screen parent;
protected DwarvenHudConfigScreen() {
this(null);
}
public DwarvenHudConfigScreen(Screen parent) {
super(Text.of("Dwarven HUD Config"));
this.parent = parent;
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
renderBackground(context, mouseX, mouseY, delta);
DwarvenHud.render(HudCommsWidget.INSTANCE_CFG, context, hudX, hudY, List.of(new DwarvenHud.Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%")));
context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
IntIntPair dims = DwarvenHud.getDimForConfig(CFG_COMMS);
if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + 200, hudY + 40) && button == 0) {
hudX = (int) Math.max(Math.min(mouseX - (double) dims.leftInt() / 2, this.width - dims.leftInt()), 0);
hudY = (int) Math.max(Math.min(mouseY - (double) dims.rightInt() / 2, this.height - dims.rightInt()), 0);
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 1) {
IntIntPair dims = DwarvenHud.getDimForConfig(CFG_COMMS);
hudX = this.width / 2 - dims.leftInt();
hudY = this.height / 2 - dims.rightInt();
}
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void close() {
SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.x = hudX;
SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.y = hudY;
SkyblockerConfigManager.save();
client.setScreen(parent);
}
}
|