Skip to content

Commit

Permalink
Merge pull request #26 from legoraft/dev
Browse files Browse the repository at this point in the history
added toggle and config option to completely toggle armorhud
  • Loading branch information
legoraft authored Oct 26, 2023
2 parents a1f7f61 + eef70b3 commit 11c79c3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ jobs:
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: build/libs/
name: armorhud-mod
path: build/libs/*.jar
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

jar {
Expand Down
3 changes: 3 additions & 0 deletions src/client/java/com/armorhud/config.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ public class config {

public static boolean BETTER_MOUNT_HUD = false;
public static boolean DOUBLE_HOTBAR = false;
public static boolean ARMOR_HUD = true;

private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("armorhud.properties");

public void write(Properties properties) {
properties.setProperty("better_mount_hud", Boolean.toString(BETTER_MOUNT_HUD));
properties.setProperty("double_hotbar", Boolean.toString(DOUBLE_HOTBAR));
properties.setProperty("armor_hud", Boolean.toString(ARMOR_HUD));
}

public void read(Properties properties) {
BETTER_MOUNT_HUD = Boolean.parseBoolean(properties.getProperty("better_mount_hud"));
DOUBLE_HOTBAR = Boolean.parseBoolean(properties.getProperty("double_hotbar"));
ARMOR_HUD = Boolean.parseBoolean(properties.getProperty("armor_hud"));
}

public void save() {
Expand Down
4 changes: 3 additions & 1 deletion src/client/java/com/armorhud/configScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ public class configScreen extends SpruceScreen {

private final SpruceOption doubleHotbarToggle;
private final SpruceOption betterMountHudToggle;
private final SpruceOption armorHudToggle;

public configScreen(@Nullable Screen parent) {
super(Text.literal("Armorhud test GUI"));
this.parent = parent;

this.doubleHotbarToggle = new SpruceBooleanOption("Double hotbar", () -> config.DOUBLE_HOTBAR, newValue -> config.DOUBLE_HOTBAR = newValue, Text.literal("Toggles double hotbar config"));
this.betterMountHudToggle = new SpruceBooleanOption("Better mount HUD", () -> config.BETTER_MOUNT_HUD, newValue -> config.BETTER_MOUNT_HUD = newValue, Text.literal("Toggles the better mount hud config"));
this.armorHudToggle = new SpruceBooleanOption("Armor visible", () -> config.ARMOR_HUD, newValue -> config.ARMOR_HUD = newValue, Text.literal("Toggles the armorhud on or off"));
}

@Override
protected void init() {
super.init();

SpruceOptionListWidget list = new SpruceOptionListWidget(Position.of(0, 34), this.width, this.height - 69);
list.addOptionEntry(this.doubleHotbarToggle, null);
list.addOptionEntry(this.armorHudToggle, this.doubleHotbarToggle);
list.addOptionEntry(this.betterMountHudToggle, null);

this.addDrawableChild(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public abstract class armorHudMixin {
@Inject(at = @At("TAIL"), method = "renderHotbar")

private void renderHud(float tickDelta, DrawContext context, CallbackInfo ci) {
if(!config.ARMOR_HUD) { return; }

assert client.player != null;

Expand Down

0 comments on commit 11c79c3

Please sign in to comment.