Skip to content

Commit

Permalink
🔖 SpruceUI v1.3.4-1.14.4: Add visibility attribute to Huds.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Jan 31, 2020
2 parents bc36436 + 3c32933 commit 2e19ce6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.7.4+build.177

# Mod Properties
mod_version = 1.3.3-1.14.4
mod_version = 1.3.4-1.14.4
maven_group = me.lambdaurora
archives_base_name = spruceui

Expand Down
25 changes: 23 additions & 2 deletions src/main/java/me/lambdaurora/spruceui/hud/Hud.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
* Represents a HUD.
*
* @author LambdAurora
* @version 1.3.3
* @version 1.3.4
* @since 1.2.0
*/
public abstract class Hud extends DrawableHelper implements Identifiable
{
protected final Identifier identifier;
protected final List<HudComponent> components = new ArrayList<>();
protected boolean enabled = true;
private boolean enabled = true;
protected boolean visible = true;

public Hud(@NotNull Identifier identifier)
{
Expand Down Expand Up @@ -66,6 +67,26 @@ public void setEnabled(boolean enabled)
}
}

/**
* Returns whether the HUD is visible or not.
*
* @return True if the HUD is visible, else false.
*/
public boolean isVisible()
{
return this.visible;
}

/**
* Sets whether the HUD is visible or not.
*
* @param visible True if the HUD is visible, else false.
*/
public void setVisible(boolean visible)
{
this.visible = visible;
}

public void init(@NotNull MinecraftClient client, int screenWidth, int screenHeight)
{
this.components.clear();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/me/lambdaurora/spruceui/hud/HudManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Represents the HUD manager.
*
* @author LambdAurora
* @version 1.3.1
* @version 1.3.4
* @since 1.2.0
*/
public class HudManager
Expand All @@ -33,14 +33,14 @@ public class HudManager
public void initialize()
{
HudRenderCallback.EVENT.register(tickDelta -> HUDS.forEach((id, hud) -> {
if (hud.isEnabled())
if (hud.isEnabled() && hud.isVisible())
hud.render(tickDelta);
}));
ClientTickCallback.EVENT.register(client -> {
if (!canRenderHuds(client))
return;
HUDS.forEach((id, hud) -> {
if (hud.isEnabled() && hud.hasTicks())
if (hud.isEnabled() && hud.isVisible() && hud.hasTicks())
hud.tick();
});
});
Expand Down

0 comments on commit 2e19ce6

Please sign in to comment.