aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/bscv/modules/HudModule.java
blob: eff3c2db00928374ed6b3e0af9957ce5766416ff (plain) (blame)
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
package ftbsc.bscv.modules;

import ftbsc.bscv.ICommons;
import ftbsc.bscv.tools.Anchor;
import ftbsc.bscv.tools.Setting;
import net.minecraftforge.common.ForgeConfigSpec;

public abstract class HudModule extends AbstractModule {

   public final ForgeConfigSpec.ConfigValue<Integer> x;
   public final ForgeConfigSpec.ConfigValue<Integer> y;
   public final ForgeConfigSpec.ConfigValue<Double>  scale;
   public final ForgeConfigSpec.ConfigValue<Anchor>  anchor;

   @Override
   public String getGroup() {
      return "HUD";
   }

   // TODO there should be a way for HUD mods to specify their defaults for x/y and anchor settings

   protected HudModule() {
      super();
      this.x = Setting.Number.builder()
         .name("x")
         .comment("horizontal offset")
         .fallback(0)
         .build(this);

      this.y = Setting.Number.builder()
         .name("y")
         .comment("vertical offset")
         .fallback(0)
         .build(this);

      this.scale = Setting.Decimal.builder()
         .name("scale")
         .comment("scale of element")
         .fallback(1.0)
         .build(this);

      this.anchor = Setting.Switch.builder(Anchor.class)
         .name("anchor")
         .comment("origin point for coordinates")
         .fallback(Anchor.TOPLEFT)
         .build(this);
   }

   protected String affixed(String in, Object... args) {
      Anchor anchor = this.anchor.get();
      String prefix = anchor.isLeft() ? "> " : "";
      String postfix = anchor.isRight() ? " <" : "";
      return String.format(prefix + in + postfix, args);
   }

   protected boolean shouldHide() {
      return ICommons.MC.options.renderDebug;
   }
}