Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more config options for better control over the UI #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion src/main/java/net/torocraft/torohud/conf/HealthBarGuiConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,58 @@ public enum Skin {NONE, BASIC}
@Name("Show 3D Model of Entity")
public static boolean showEntityModel = true; // config.getBoolean("Show 3D Model of Entity", Configuration.CATEGORY_CLIENT, true, "Shows a 3D model of the entity being targeted");

// Health Config
@Name("Hide Health Number")
@Comment("Hide the health number")
public static boolean hideHealthNo = false;

@Name("Health Number X Offset")
public static int healthNoXOffset = 0;

@Name("Health Number Y Offset")
public static int healthNoYOffset = 0;

@Name("Health Bar X Offset")
public static int healthXOffset = 0;

@Name("Health Bar Y Offset")
public static int healthYOffset = 0;

@Name("Health Bar Scale")
public static float healthScale = 1f;

// Nameplate Config
@Name("Hide Nameplate")
public static boolean hideName = false;

@Name("Nameplate X Offset")
public static int nameXOffset = 0;

@Name("Nameplate Y Offset")
public static int nameYOffset = 0;

@Name("Nameplate Scale")
public static float nameScale = 1f;

// Armor Config
@Name("Hide Armor")
public static boolean hideArmor = false;

@Name("Armor X Offset")
public static int armorXOffset = 0;

@Name("Armor Y Offset")
public static int armorYOffset = 0;

// Potion Config
@Name("Potion X Offset")
public static int potionXOffset = 0;

@Name("Potion Y Offset")
public static int potionYOffset = 0;


// Overall GUI Config
@Name("Disable GUI")
public static boolean disableGui = false;

Expand All @@ -32,7 +84,6 @@ public enum Skin {NONE, BASIC}

@Name("Y Offset")
public static int yOffset = 0;

@Name("GUI Position")
public static GuiAnchor guiPosition = GuiAnchor.TOP_LEFT;

Expand Down
38 changes: 28 additions & 10 deletions src/main/java/net/torocraft/torohud/display/BarDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.torocraft.torohud.gui.HealthBars;
import net.torocraft.torohud.conf.HealthBarGuiConf;

public class BarDisplay extends AbstractEntityDisplay implements IDisplay {

Expand Down Expand Up @@ -43,21 +44,38 @@ public void render() {
String health = (int) Math.ceil(entity.getHealth()) + "/" + (int) entity.getMaxHealth();

GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
HealthBars.drawEntityHealthBarInGui(gui, entity, barX, barY);

mc.fontRenderer.drawStringWithShadow(name, barX, y + 2, 16777215);
barX += mc.fontRenderer.getStringWidth(name) + 5;
GlStateManager.pushMatrix();
GlStateManager.scale(HealthBarGuiConf.healthScale, HealthBarGuiConf.healthScale, HealthBarGuiConf.healthScale);
HealthBars.drawEntityHealthBarInGui(gui, entity, barX + HealthBarGuiConf.healthXOffset, barY + HealthBarGuiConf.healthXOffset);
GlStateManager.popMatrix();

if(!HealthBarGuiConf.hideName)
{
GlStateManager.pushMatrix();
GlStateManager.scale(HealthBarGuiConf.nameScale, HealthBarGuiConf.nameScale, HealthBarGuiConf.nameScale);
mc.fontRenderer.drawStringWithShadow(name, barX + HealthBarGuiConf.nameXOffset, y + 2 + HealthBarGuiConf.nameYOffset, 16777215);
GlStateManager.popMatrix();

barX += mc.fontRenderer.getStringWidth(name) + 5 + HealthBarGuiConf.nameXOffset;
}

renderHeartIcon(barX, y + 1);
barX += 10;
if(!HealthBarGuiConf.hideHealthNo)
{
renderHeartIcon(barX + HealthBarGuiConf.healthNoXOffset, y + 1 + HealthBarGuiConf.healthNoYOffset);
barX += 10 + HealthBarGuiConf.healthNoXOffset;

mc.fontRenderer.drawStringWithShadow(health, barX, y + 2, 0xe0e0e0);
barX += mc.fontRenderer.getStringWidth(health) + 5;
mc.fontRenderer.drawStringWithShadow(health, barX, y + 2, 0xe0e0e0);
barX += mc.fontRenderer.getStringWidth(health) + 5;
}

renderArmorIcon(barX, y + 1);
barX += 10;
if(!HealthBarGuiConf.hideArmor)
{
renderArmorIcon(barX + HealthBarGuiConf.armorXOffset, y + 1 + HealthBarGuiConf.armorYOffset);
barX += 10 + HealthBarGuiConf.armorXOffset;

mc.fontRenderer.drawStringWithShadow(entity.getTotalArmorValue() + "", barX, y + 2, 0xe0e0e0);
mc.fontRenderer.drawStringWithShadow(entity.getTotalArmorValue() + "", barX, y + 2, 0xe0e0e0);
}
}

private void renderArmorIcon(int x, int y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.torocraft.torohud.network.MessageEntityStatsResponse;
import net.torocraft.torohud.conf.HealthBarGuiConf;

public class PotionDisplay extends AbstractEntityDisplay implements IDisplay {

Expand Down Expand Up @@ -62,8 +63,8 @@ private void drawEffects() {
}

int index = 0;
int x = this.x + X_OFFSET;
int y = this.y + Y_OFFSET;
int x = this.x + X_OFFSET + HealthBarGuiConf.potionXOffset;
int y = this.y + Y_OFFSET + HealthBarGuiConf.potionYOffset;

for (PotionEffect potion : Ordering.natural().sortedCopy(potions)) {

Expand Down