Skip to content

Commit

Permalink
Merge pull request #654 from viciscat/fancier-bars
Browse files Browse the repository at this point in the history
Fancier bars
  • Loading branch information
kevinthegreat1 authored Apr 21, 2024
2 parents 95fa171 + c43370d commit 01b4ff4
Show file tree
Hide file tree
Showing 27 changed files with 1,891 additions and 261 deletions.
2 changes: 2 additions & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import de.hysky.skyblocker.skyblock.end.EnderNodes;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.entity.MobBoundingBoxes;
import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars;
import de.hysky.skyblocker.skyblock.garden.FarmingHud;
import de.hysky.skyblocker.skyblock.garden.LowerSensitivity;
import de.hysky.skyblocker.skyblock.garden.VisitorHelper;
Expand Down Expand Up @@ -172,6 +173,7 @@ public void onInitializeClient() {
Debug.init();
Kuudra.init();
RenderHelper.init();
FancyStatusBars.init();
containerSolverManager.init();
statusBarTracker.init();
BeaconHighlighter.init();
Expand Down
37 changes: 15 additions & 22 deletions src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,41 +305,34 @@ public static class Bars {
@SerialEntry
public boolean enableBars = true;

// Kept in for backwards compatibility, remove if needed
@SerialEntry
public BarPositions barPositions = new BarPositions();
public OldBarPositions barPositions = new OldBarPositions();
}

public static class BarPositions {
/**
* Backwards compat
*/
public static class OldBarPositions {
@SerialEntry
public BarPosition healthBarPosition = BarPosition.LAYER1;
public OldBarPosition healthBarPosition = OldBarPosition.LAYER1;

@SerialEntry
public BarPosition manaBarPosition = BarPosition.LAYER1;
public OldBarPosition manaBarPosition = OldBarPosition.LAYER1;

@SerialEntry
public BarPosition defenceBarPosition = BarPosition.LAYER1;
public OldBarPosition defenceBarPosition = OldBarPosition.LAYER1;

@SerialEntry
public BarPosition experienceBarPosition = BarPosition.LAYER1;
public OldBarPosition experienceBarPosition = OldBarPosition.LAYER1;

}

public enum BarPosition {
LAYER1, LAYER2, RIGHT, NONE;

@Override
public String toString() {
return I18n.translate("text.autoconfig.skyblocker.option.general.bars.barpositions." + name());
}

public int toInt() {
return switch (this) {
case LAYER1 -> 0;
case LAYER2 -> 1;
case RIGHT -> 2;
case NONE -> -1;
};
}
/**
* Backwards compat
*/
public enum OldBarPosition {
LAYER1, LAYER2, RIGHT, NONE
}

public static class Experiments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.skyblock.fancybars.StatusBarsConfigScreen;
import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen;
import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen;
import de.hysky.skyblocker.utils.waypoint.Waypoint;
Expand Down Expand Up @@ -158,33 +159,10 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.bars.enableBars = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<SkyblockerConfig.BarPosition>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.bars.barpositions.healthBarPosition"))
.binding(defaults.general.bars.barPositions.healthBarPosition,
() -> config.general.bars.barPositions.healthBarPosition,
newValue -> config.general.bars.barPositions.healthBarPosition = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<SkyblockerConfig.BarPosition>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.bars.barpositions.manaBarPosition"))
.binding(defaults.general.bars.barPositions.manaBarPosition,
() -> config.general.bars.barPositions.manaBarPosition,
newValue -> config.general.bars.barPositions.manaBarPosition = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<SkyblockerConfig.BarPosition>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.bars.barpositions.defenceBarPosition"))
.binding(defaults.general.bars.barPositions.defenceBarPosition,
() -> config.general.bars.barPositions.defenceBarPosition,
newValue -> config.general.bars.barPositions.defenceBarPosition = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<SkyblockerConfig.BarPosition>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.bars.barpositions.experienceBarPosition"))
.binding(defaults.general.bars.barPositions.experienceBarPosition,
() -> config.general.bars.barPositions.experienceBarPosition,
newValue -> config.general.bars.barPositions.experienceBarPosition = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.option(ButtonOption.createBuilder()
.name(Text.translatable("skyblocker.bars.config.openScreen"))
.text(Text.translatable("text.skyblocker.open"))
.action((screen, opt) -> MinecraftClient.getInstance().setScreen(new StatusBarsConfigScreen()))
.build())
.build())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.mojang.blaze3d.systems.RenderSystem;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.FancyStatusBars;
import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars;
import de.hysky.skyblocker.skyblock.dungeon.DungeonMap;
import de.hysky.skyblocker.skyblock.dungeon.DungeonScore;
import de.hysky.skyblocker.skyblock.dungeon.DungeonScoreHUD;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/de/hysky/skyblocker/mixin/WindowMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.hysky.skyblocker.mixin;

import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars;
import net.minecraft.client.util.Window;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Window.class)
public class WindowMixin {
@Inject(method = "setScaleFactor", at = @At("TAIL"))
public void skyblocker$onScaleFactorChange(double scaleFactor, CallbackInfo ci) {
FancyStatusBars.updatePositions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.gui.tooltip.TooltipPositioner;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

Expand All @@ -14,4 +15,7 @@ public interface DrawContextInvoker {

@Invoker
void invokeDrawTooltip(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner);

@Invoker
void invokeDrawTexturedQuad(Identifier texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, float red, float green, float blue, float alpha);
}
191 changes: 0 additions & 191 deletions src/main/java/de/hysky/skyblocker/skyblock/FancyStatusBars.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ protected void init() {
super.init();
layout = DirectionalLayoutWidget.vertical();
layout.spacing(8).getMainPositioner().alignHorizontalCenter();
textFieldWidget = new TextFieldWidget(textRenderer, 120, 15, Text.empty()) {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (!super.keyPressed(keyCode, scanCode, modifiers)) {
if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
done(null);
return true;
}
} else return true;
return false;
}
};
textFieldWidget = new EnterConfirmTextFieldWidget(textRenderer, 120, 15, Text.empty(), () -> done(null));
textFieldWidget.setTextPredicate(this::isStringGood);
layout.add(new TextWidget(Text.literal("- Set Bid -").fillStyle(Style.EMPTY.withBold(true)), textRenderer));
layout.add(textFieldWidget);
Expand Down
Loading

0 comments on commit 01b4ff4

Please sign in to comment.