Skip to content

Commit

Permalink
Skill Progress Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterCheezeCake committed Sep 15, 2024
1 parent ec395e5 commit e956e34
Show file tree
Hide file tree
Showing 11 changed files with 463 additions and 372 deletions.
3 changes: 2 additions & 1 deletion src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public void onInitialize() {
// This fixes config not actually loading on initial startup... for some reason
CONFIG.getScreen(null);

HUDS.add(new SkillHUD());
HUDS.add(SkillHUDManager.INSTANCE.SKILL_HUD);
HUDS.add(SkillHUDManager.INSTANCE.SKILL_BAR);

HUDS.add(new SpeedHUD());
HUDS.add(new DefenseHUD());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SkyblockTweaksConfig {
.setPath(FabricLoader.getInstance().getConfigDir().resolve("skyblocktweaks-config.json"))
.build())
.build();
// TODO: Fix this, it's a mess right now
public ConfigImpl config;
public YetAnotherConfigLib YACLInstance = YetAnotherConfigLib.create(HANDLER,
(defaults, configThing, builder) -> {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/wtf/cheeze/sbt/config/categories/Huds.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public class Huds {
public FpsHUD.Config fps = new FpsHUD.Config();

@SerialEntry
public SkillHUD.Config skills = new SkillHUD.Config();
public SkillHUDManager.SkillHUD.Config skills = new SkillHUDManager.SkillHUD.Config();

@SerialEntry
public SkillHUDManager.SkillBar.Config skillBar = new SkillHUDManager.SkillBar.Config();

@SerialEntry
public TickerHUD.Config ticker = new TickerHUD.Config();
Expand All @@ -79,7 +82,8 @@ public static ConfigCategory getCategory(ConfigImpl defaults, ConfigImpl config)
return ConfigCategory.createBuilder()
.name(Text.literal("HUDs"))
.tooltip(Text.literal("Settings for various HUDs"))
.group(SkillHUD.Config.getGroup(defaults, config))
.group(SkillHUDManager.SkillHUD.Config.getGroup(defaults, config))
.group(SkillHUDManager.SkillBar.Config.getGroup(defaults, config))
.group(HealthHUD.Config.getGroup(defaults, config))
.group(HealthBar.Config.getGroup(defaults, config))
.group(ManaHUD.Config.getGroup(defaults, config))
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/wtf/cheeze/sbt/features/huds/DrillFuelBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public DrillFuelBar() {
() -> SkyblockTweaks.CONFIG.config.huds.drillFuelBar.scale,
() -> SkyblockTweaks.CONFIG.config.huds.drillFuelBar.anchor,
() -> SkyblockTweaks.CONFIG.config.huds.drillFuelBar.color,
() -> SkyblockTweaks.DATA.maxDrillFuel,
() -> SkyblockTweaks.DATA.drillFuel,
() -> SkyblockTweaks.DATA.drillFuel / SkyblockTweaks.DATA.maxDrillFuel,
x -> SkyblockTweaks.CONFIG.config.huds.drillFuelBar.x = (float) x,
y -> SkyblockTweaks.CONFIG.config.huds.drillFuelBar.y = (float) y,
scale -> SkyblockTweaks.CONFIG.config.huds.drillFuelBar.scale = (float) scale,
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/wtf/cheeze/sbt/features/huds/HealthBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ public HealthBar() {
() -> SkyblockTweaks.CONFIG.config.huds.healthBar.scale,
() -> SkyblockTweaks.CONFIG.config.huds.healthBar.anchor,
() -> SkyblockTweaks.DATA.health > SkyblockTweaks.DATA.maxHealth ? SkyblockTweaks.CONFIG.config.huds.healthBar.colorAbsorption : SkyblockTweaks.CONFIG.config.huds.healthBar.color,
() -> SkyblockTweaks.DATA.maxHealth,
() -> SkyblockTweaks.DATA.health,
() -> SkyblockTweaks.DATA.health / SkyblockTweaks.DATA.maxHealth,
x -> SkyblockTweaks.CONFIG.config.huds.healthBar.x = (float) x,
y -> SkyblockTweaks.CONFIG.config.huds.healthBar.y = (float) y,
scale -> SkyblockTweaks.CONFIG.config.huds.healthBar.scale = (float) scale,
anchor ->SkyblockTweaks.CONFIG.config.huds.healthBar.anchor= anchor

);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/wtf/cheeze/sbt/features/huds/ManaBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public ManaBar() {
() -> SkyblockTweaks.CONFIG.config.huds.manaBar.scale,
() -> SkyblockTweaks.CONFIG.config.huds.manaBar.anchor,
() -> SkyblockTweaks.CONFIG.config.huds.manaBar.color,
() -> SkyblockTweaks.DATA.maxMana,
() -> SkyblockTweaks.DATA.mana,
() -> SkyblockTweaks.DATA.mana / SkyblockTweaks.DATA.maxMana,
x -> SkyblockTweaks.CONFIG.config.huds.manaBar.x = (float) x,
y -> SkyblockTweaks.CONFIG.config.huds.manaBar.y = (float) y,
scale -> SkyblockTweaks.CONFIG.config.huds.manaBar.scale = (float) scale,
Expand Down
348 changes: 0 additions & 348 deletions src/main/java/wtf/cheeze/sbt/features/huds/SkillHUD.java

This file was deleted.

440 changes: 440 additions & 0 deletions src/main/java/wtf/cheeze/sbt/features/huds/SkillHUDManager.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import wtf.cheeze.sbt.SkyblockTweaks;
import wtf.cheeze.sbt.config.ConfigImpl;
import wtf.cheeze.sbt.config.SkyblockTweaksConfig;
import wtf.cheeze.sbt.features.huds.SkillHUD;
import wtf.cheeze.sbt.features.huds.SkillHUDManager;
import wtf.cheeze.sbt.utils.NumberUtils;
import wtf.cheeze.sbt.utils.TextUtils;

Expand Down Expand Up @@ -138,10 +138,10 @@ public static ActionBarData extractDataAndRunTransformation(String actionBarText
String[] xp = matcher.group(3).split("/");
data.totalXP = NumberUtils.parseFloatWithKorM(xp[1]);
data.nextLevelXP = NumberUtils.parseFloatWithKorM(xp[0]);
((SkillHUD) SkyblockTweaks.HUDS.getFirst()).update(data.skillType, data.gainedXP, data.totalXP, data.nextLevelXP);
SkillHUDManager.INSTANCE.update(data.skillType, data.gainedXP, data.totalXP, data.nextLevelXP);
} else {
data.skillPercentage = Float.parseFloat(matcher.group(3).replace("%", ""));
((SkillHUD) SkyblockTweaks.HUDS.getFirst()).update(data.skillType, data.gainedXP, data.skillPercentage);
SkillHUDManager.INSTANCE.update(data.skillType, data.gainedXP, data.skillPercentage);
}
}
if (!SkyblockTweaks.CONFIG.config.actionBarFilters.hideSkill) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/wtf/cheeze/sbt/utils/hud/BarHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public void render(DrawContext context, boolean fromHudScreen, boolean hovered)
if (bounds.scale == 1.0f) {
context.setShaderColor(colors.red, colors.green, colors.blue, 1.0f);
context.drawTexture(UNFILLED, bounds.x, bounds.y, 0, 0, BAR_WIDTH, BAR_HEIGHT, BAR_WIDTH, BAR_HEIGHT);
context.drawTexture(FILLED, bounds.x, bounds.y, 0, 0, calculateFill((float) INFO.getFillNum.get(), (float) INFO.getMaxNum.get()), BAR_HEIGHT, BAR_WIDTH, BAR_HEIGHT);
context.drawTexture(FILLED, bounds.x, bounds.y, 0, 0, calculateFill((float) INFO.getFill.get()), BAR_HEIGHT, BAR_WIDTH, BAR_HEIGHT);
context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
} else {
RenderUtils.beginScale(context, bounds.scale);
context.setShaderColor(colors.red, colors.green, colors.blue, 1.0f);
context.drawTexture(UNFILLED, (int)(bounds.x/bounds.scale), (int)(bounds.y/bounds.scale), 0, 0, BAR_WIDTH, BAR_HEIGHT, BAR_WIDTH, BAR_HEIGHT);
context.drawTexture(FILLED, (int)(bounds.x/bounds.scale), (int)(bounds.y/bounds.scale), 0, 0, calculateFill((float) INFO.getFillNum.get(), (float) INFO.getMaxNum.get()), BAR_HEIGHT, BAR_WIDTH, BAR_HEIGHT);
context.drawTexture(FILLED, (int)(bounds.x/bounds.scale), (int)(bounds.y/bounds.scale), 0, 0, calculateFill((float) INFO.getFill.get()), BAR_HEIGHT, BAR_WIDTH, BAR_HEIGHT);
context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderUtils.endScale(context);
}
Expand Down Expand Up @@ -87,9 +87,9 @@ public BoundsRelative getCurrentBoundsRelative() {

}
}
private static int calculateFill(float current, float max) {
if (current >= max) return BAR_WIDTH;
var i = (int) (current / max * BAR_WIDTH);
private static int calculateFill(float percent) {
if (percent >= 1.0f) return BAR_WIDTH;
var i = (int) (percent * BAR_WIDTH);
return i;
}

Expand Down
9 changes: 3 additions & 6 deletions src/main/java/wtf/cheeze/sbt/utils/hud/HudInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public class HudInformation {
public Supplier<HUD.AnchorPoint> getAnchorPoint;

@Nullable
public Supplier<Float> getMaxNum;
@Nullable
public Supplier<Float> getFillNum;
public Supplier<Float> getFill;

@Nullable
public Supplier<Integer> getColor;
Expand All @@ -54,14 +52,13 @@ public HudInformation(Supplier<Float> xSupplier, Supplier<Float> ySupplier, Supp
this.setScale = scaleConsumer;
this.setAnchorPoint = anchorPointConsumer;
}
public HudInformation(Supplier<Float> xSupplier, Supplier<Float> ySupplier, Supplier<Float> scaleSupplier, Supplier<HUD.AnchorPoint> anchorPointSupplier, Supplier<Integer> colorSupplier, Supplier<Float> maxNumSupplier, Supplier<Float> fillNumSupplier, Consumer<Float> xConsumer, Consumer<Float> yConsumer, Consumer<Float> scaleConsumer, Consumer<HUD.AnchorPoint> anchorPointConsumer) {
public HudInformation(Supplier<Float> xSupplier, Supplier<Float> ySupplier, Supplier<Float> scaleSupplier, Supplier<HUD.AnchorPoint> anchorPointSupplier, Supplier<Integer> colorSupplier, Supplier<Float> fillSupplier, Consumer<Float> xConsumer, Consumer<Float> yConsumer, Consumer<Float> scaleConsumer, Consumer<HUD.AnchorPoint> anchorPointConsumer) {
this.getX = xSupplier;
this.getY = ySupplier;
this.getScale = scaleSupplier;
this.getAnchorPoint = anchorPointSupplier;

this.getMaxNum = maxNumSupplier;
this.getFillNum = fillNumSupplier;
this.getFill = fillSupplier;
this.getColor = colorSupplier;

this.setX = xConsumer;
Expand Down

0 comments on commit e956e34

Please sign in to comment.