mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Add support for left/right alignment of HUD; improve contrast by using a light color (#5385)
This commit is contained in:
1 parent
8a468d0c78
commit
f828afb786
2 files changed
+21
-5
No files matched your search
@@ -12,6 +12,7 @@ import mekanism.client.render.particle.EntityJetpackSmokeFX;
|
||||
import mekanism.client.render.particle.EntityScubaBubbleFX;
|
||||
import mekanism.common.ColourRGBA;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.item.ItemConfigurator.ConfiguratorMode;
|
||||
import mekanism.common.item.ItemFlamethrower;
|
||||
@@ -102,21 +103,21 @@ public class RenderTickHandler {
|
||||
|
||||
ScaledResolution scaledresolution = new ScaledResolution(mc);
|
||||
|
||||
int x = scaledresolution.getScaledWidth();
|
||||
int y = scaledresolution.getScaledHeight();
|
||||
boolean alignLeft = MekanismConfig.current().client.alignHUDLeft.val();
|
||||
|
||||
if (stack.getItem() instanceof ItemJetpack) {
|
||||
ItemJetpack jetpack = (ItemJetpack) stack.getItem();
|
||||
|
||||
font.drawStringWithShadow("Mode: " + jetpack.getMode(stack).getName(), 1, y - 20, 0x404040);
|
||||
font.drawStringWithShadow("Hydrogen: " + jetpack.getStored(stack), 1, y - 11, 0x404040);
|
||||
drawString(scaledresolution, "Mode: " + jetpack.getMode(stack).getName(), alignLeft,y - 20, 0xc8c8c8);
|
||||
drawString(scaledresolution, "Hydrogen: " + jetpack.getStored(stack), alignLeft, y - 11, 0xc8c8c8);
|
||||
} else if (stack.getItem() instanceof ItemScubaTank) {
|
||||
ItemScubaTank scubaTank = (ItemScubaTank) stack.getItem();
|
||||
String state = (scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On"
|
||||
: EnumColor.DARK_RED + "Off");
|
||||
|
||||
font.drawStringWithShadow("Mode: " + state, 1, y - 20, 0x404040);
|
||||
font.drawStringWithShadow("Oxygen: " + scubaTank.getStored(stack), 1, y - 11, 0x404040);
|
||||
drawString(scaledresolution, "Mode: " + state, alignLeft, y - 20, 0xc8c8c8);
|
||||
drawString(scaledresolution, "Oxygen: " + scubaTank.getStored(stack), alignLeft, y - 11, 0xc8c8c8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,4 +260,16 @@ public class RenderTickHandler {
|
||||
|
||||
mc.effectRenderer.addEffect(fx);
|
||||
}
|
||||
|
||||
private void drawString(ScaledResolution res, String s, boolean leftSide, int y, int color) {
|
||||
FontRenderer font = mc.fontRenderer;
|
||||
|
||||
// Note that we always offset by 2 pixels when left or right aligned
|
||||
if (leftSide) {
|
||||
font.drawStringWithShadow(s, 2, y, color);
|
||||
} else {
|
||||
int width = font.getStringWidth(s) + 2;
|
||||
font.drawStringWithShadow(s, res.getScaledWidth() - width, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,9 @@ public class ClientConfig extends BaseConfig {
|
||||
true,
|
||||
"Set to false to prevent particle spam when loading multiblocks (notification message will still display).");
|
||||
|
||||
public final BooleanOption alignHUDLeft = new BooleanOption(this, "client", "AlignHUDLeft",
|
||||
true, "Align HUD with left (if true) or right (if false)");
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf config) {
|
||||
throw new UnsupportedOperationException("Client config shouldn't be synced");
|
||||
|
||||
Reference in new issue
Block a user