Tooltip.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package monkey.lumpy.horse.stats.vanilla.gui;
  2. import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
  3. import io.github.cottonmc.cotton.gui.widget.WBox;
  4. import io.github.cottonmc.cotton.gui.widget.WLabel;
  5. import io.github.cottonmc.cotton.gui.widget.data.Axis;
  6. import me.shedaniel.autoconfig.AutoConfig;
  7. import me.shedaniel.math.Color;
  8. import monkey.lumpy.horse.stats.vanilla.config.ModConfig;
  9. import net.minecraft.text.LiteralText;
  10. public class Tooltip extends LightweightGuiDescription {
  11. private ModConfig config;
  12. public Tooltip(double speed, double jump, double health) {
  13. config = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
  14. WBox root = new WBox(Axis.VERTICAL);
  15. setRootPanel(root);
  16. root.setSpacing(-8);
  17. // Coloring
  18. Color jumpColor = config.getNeutralColor();
  19. Color speedColor = config.getNeutralColor();
  20. Color hearthColor = config.getNeutralColor();
  21. if(config == null || config.useColors()) {
  22. if(jump > config.getGoodHorseJumpValue()) {jumpColor = config.getGoodColor();;}
  23. else if (jump < config.getBadHorseJumpValue()) {jumpColor = config.getBadColor();};
  24. if(speed > config.getGoodHorseSpeedValue()) {speedColor = config.getGoodColor();}
  25. else if (speed < config.getBadHorseSpeedValue()) {speedColor = config.getBadColor();};
  26. if(health> config.getGoodHorseHeartsValue()) {hearthColor = config.getGoodColor();}
  27. else if (health < config.getBadHorseHeartsValue()) {hearthColor = config.getBadColor();};
  28. }
  29. WBox speedBox = new WBox(Axis.HORIZONTAL);
  30. WLabel speedSymbol = new WLabel(new LiteralText("➟"), speedColor.hashCode());
  31. WLabel speedLabel = new WLabel(new LiteralText("" + speed), speedColor.hashCode());
  32. // WLabel speedRange = new WLabel(new LiteralText("(4.8-14.5)"), normalColor);
  33. // speedSymbol.setVerticalAlignment(VerticalAlignment.CENTER);
  34. speedBox.add(speedSymbol);
  35. speedBox.add(speedLabel);
  36. // speedBox.add(speedRange);
  37. WBox jumpBox = new WBox(Axis.HORIZONTAL);
  38. WLabel jumpSymbol = new WLabel(new LiteralText("⇮"), jumpColor.hashCode());
  39. WLabel jumpLabel = new WLabel(new LiteralText("" + jump), jumpColor.hashCode());
  40. // WLabel jumpRange = new WLabel(new LiteralText("(1-5.1)"), normalColor);
  41. // jumpSymbol.setVerticalAlignment(VerticalAlignment.CENTER);
  42. jumpBox.add(jumpSymbol);
  43. jumpBox.add(jumpLabel);
  44. // jumpBox.add(jumpRange);
  45. WBox healthBox = new WBox(Axis.HORIZONTAL);
  46. WLabel healthSymbol = new WLabel(new LiteralText("♥"), hearthColor.hashCode());
  47. WLabel healthLabel = new WLabel(new LiteralText("" + health), hearthColor.hashCode());
  48. // WLabel healthRange = new WLabel(new LiteralText("(15-30)"), normalColor);
  49. // healthSymbol.setVerticalAlignment(VerticalAlignment.CENTER);
  50. healthBox.add(healthSymbol);
  51. healthBox.add(healthLabel);
  52. // healthBox.add(healthRange);
  53. root.add(speedBox);
  54. root.add(jumpBox);
  55. root.add(healthBox);
  56. root.validate(this);
  57. }
  58. }