mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Swap the hud to the other side for people who play left handed
This commit is contained in:
parent
295c28cfac
commit
c33f961f81
3 changed files with 32 additions and 4 deletions
|
@ -20,7 +20,7 @@ class ManaRingSlot extends Slot {
|
|||
private static final double TWO_PI = Math.PI * 2;
|
||||
|
||||
public ManaRingSlot(UHud uHud, AbilitySlot normalSlot, AbilitySlot backupSlot, int x, int y) {
|
||||
super(uHud, normalSlot, backupSlot, x, y, 8, 49, 33, 43, 42);
|
||||
super(uHud, normalSlot, backupSlot, x, y, 8, UHud.PRIMARY_SLOT_SIZE, 33, 43, 42);
|
||||
background(0, 5);
|
||||
foreground(0, 59);
|
||||
}
|
||||
|
|
|
@ -62,9 +62,21 @@ class Slot {
|
|||
return this;
|
||||
}
|
||||
|
||||
int getX() {
|
||||
if (uHud.xDirection < 0) {
|
||||
return UHud.PRIMARY_SLOT_SIZE - size - x;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
void renderBackground(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) {
|
||||
matrices.push();
|
||||
matrices.translate(x, y, 0);
|
||||
matrices.translate(getX(), getY(), 0);
|
||||
|
||||
float cooldown = abilities.getStat(bSwap ? bSlot : aSlot).getFillProgress();
|
||||
|
||||
|
@ -101,7 +113,16 @@ class Slot {
|
|||
Text label = KeyBindingsHandler.INSTANCE.getBinding(aSlot).getBoundKeyLocalizedText();
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(x + labelX, y + labelY, 0);
|
||||
|
||||
int x = getX();
|
||||
if (uHud.xDirection > 0) {
|
||||
x += labelX;
|
||||
} else {
|
||||
x += labelX - size/3;
|
||||
x -= uHud.client.textRenderer.getWidth(label)/2;
|
||||
}
|
||||
|
||||
matrices.translate(x, getY() + labelY, 0);
|
||||
matrices.scale(0.5F, 0.5F, 0.5F);
|
||||
|
||||
UHud.drawTextWithShadow(matrices, uHud.font, label, 0, 0, 0xFFFFFF);
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.client.gui.hud.InGameHud;
|
|||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
|
@ -30,6 +31,8 @@ public class UHud extends DrawableHelper {
|
|||
|
||||
public static final Identifier HUD_TEXTURE = new Identifier("unicopia", "textures/gui/hud.png");
|
||||
|
||||
public static final int PRIMARY_SLOT_SIZE = 49;
|
||||
|
||||
public TextRenderer font;
|
||||
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
@ -44,6 +47,8 @@ public class UHud extends DrawableHelper {
|
|||
private Text message;
|
||||
private int messageTime;
|
||||
|
||||
int xDirection;
|
||||
|
||||
public void render(InGameHud hud, MatrixStack matrices, float tickDelta) {
|
||||
|
||||
if (client.player == null || client.player.isSpectator()) {
|
||||
|
@ -52,11 +57,13 @@ public class UHud extends DrawableHelper {
|
|||
|
||||
font = client.textRenderer;
|
||||
|
||||
xDirection = client.player.getMainArm() == Arm.LEFT ? -1 : 1;
|
||||
|
||||
int scaledWidth = client.getWindow().getScaledWidth();
|
||||
int scaledHeight = client.getWindow().getScaledHeight();
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(104 + (scaledWidth - 50) / 2, scaledHeight - 50, 0);
|
||||
matrices.translate(((scaledWidth - 50) / 2) + (104 * xDirection), scaledHeight - 50, 0);
|
||||
|
||||
Pony pony = Pony.of(client.player);
|
||||
AbilityDispatcher abilities = pony.getAbilities();
|
||||
|
|
Loading…
Reference in a new issue