blob: 44a06c99e0f9f94837fe3583ddc63deccb3aa635 (
plain)
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
69
70
|
package de.hysky.skyblocker.skyblock.tabhud.widget.hud;
import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud.Commission;
import de.hysky.skyblocker.skyblock.tabhud.util.Colors;
import de.hysky.skyblocker.skyblock.tabhud.util.Ico;
import de.hysky.skyblocker.skyblock.tabhud.widget.Widget;
import de.hysky.skyblocker.skyblock.tabhud.widget.component.Component;
import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent;
import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.List;
// this widget shows the status of the king's commissions.
// (dwarven mines and crystal hollows)
// USE ONLY WITH THE DWARVEN HUD!
public class HudCommsWidget extends Widget {
private static final MutableText TITLE = Text.literal("Commissions").formatted(Formatting.DARK_AQUA, Formatting.BOLD);
private List<Commission> commissions;
private boolean isFancy;
// disgusting hack to get around text renderer issues.
// the ctor eventually tries to get the font's height, which doesn't work
// when called before the client window is created (roughly).
// the rebdering god 2 from the fabricord explained that detail, thanks!
public static final HudCommsWidget INSTANCE = new HudCommsWidget();
public static final HudCommsWidget INSTANCE_CFG = new HudCommsWidget();
// another repulsive hack to make this widget-like hud element work with the new widget class
// DON'T USE WITH THE WIDGET SYSTEM, ONLY USE FOR DWARVENHUD!
public HudCommsWidget() {
super(TITLE, Formatting.DARK_AQUA.getColorValue());
}
public void updateData(List<Commission> commissions, boolean isFancy) {
this.commissions = commissions;
this.isFancy = isFancy;
}
@Override
public void updateContent() {
for (Commission comm : commissions) {
Text c = Text.literal(comm.commission());
float p = 100f;
if (!comm.progression().contains("DONE")) {
p = Float.parseFloat(comm.progression().substring(0, comm.progression().length() - 1));
}
Component comp;
if (isFancy) {
comp = new ProgressComponent(Ico.BOOK, c, p, Colors.pcntToCol(p));
} else {
comp = new PlainTextComponent(
Text.literal(comm.commission() + ": ").append(
Text.literal(comm.progression()).withColor(Colors.pcntToCol(p))
)
);
}
this.addComponent(comp);
}
}
}
|