better cloak selector
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
package org.auraclient.auraclient.menus;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.auraclient.auraclient.AuraClient;
|
||||||
|
import org.auraclient.auraclient.ui.AuraUi;
|
||||||
|
import org.auraclient.auraclient.ui.ImageButton;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class CloakSelector extends AuraUi {
|
||||||
|
public CloakSelector() {
|
||||||
|
super(Text.of("UI"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ui(DrawContext context) {
|
||||||
|
int padding = 0;
|
||||||
|
for (int i = 0; i < AuraClient.list.size(); i++) {
|
||||||
|
ImageButton img = new ImageButton(Identifier.of("minecraft", "textures/block/deepslate.png"), (32 * i) + padding, 0, 32, 32);
|
||||||
|
img.textureHeight = 16;
|
||||||
|
img.textureWidth = 16;
|
||||||
|
String cloak = AuraClient.list.get(i);
|
||||||
|
img.onClick = () -> {
|
||||||
|
AuraClient.cape = cloak;
|
||||||
|
};
|
||||||
|
widgets.add(img);
|
||||||
|
|
||||||
|
padding += 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package org.auraclient.auraclient.menus;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.auraclient.auraclient.AuraClient;
|
|
||||||
import org.auraclient.auraclient.ui.AuraUi;
|
import org.auraclient.auraclient.ui.AuraUi;
|
||||||
import org.auraclient.auraclient.ui.Button;
|
import org.auraclient.auraclient.ui.Button;
|
||||||
|
|
||||||
@@ -14,12 +13,7 @@ public class MainMenu extends AuraUi {
|
|||||||
@Override
|
@Override
|
||||||
public void ui(DrawContext context) {
|
public void ui(DrawContext context) {
|
||||||
widgets.add(new Button("Cloaks", (context.getScaledWindowWidth() - 50) / 2, (context.getScaledWindowHeight() - 20) / 2, 50, 20, () -> {
|
widgets.add(new Button("Cloaks", (context.getScaledWindowWidth() - 50) / 2, (context.getScaledWindowHeight() - 20) / 2, 50, 20, () -> {
|
||||||
if (AuraClient.list.indexOf(AuraClient.cape) + 1 == AuraClient.list.size()) {
|
client.setScreen(new CloakSelector());
|
||||||
AuraClient.cape = AuraClient.list.get(0);
|
|
||||||
AuraClient.capeCacheIdentifier = null;
|
|
||||||
} else {
|
|
||||||
AuraClient.cape = AuraClient.list.get(AuraClient.list.indexOf(AuraClient.cape) + 1);
|
|
||||||
};
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,16 @@ public abstract class AuraWidget {
|
|||||||
public int y2;
|
public int y2;
|
||||||
public MinecraftClient client;
|
public MinecraftClient client;
|
||||||
|
|
||||||
public static int background = 0x5F000000;
|
public int background = 0x5F000000;
|
||||||
public static int foreground = 0xFFFFFFFF;
|
public int foreground = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
AuraWidget(int x, int y, int width, int height) {
|
||||||
|
x1 = x;
|
||||||
|
y1 = y;
|
||||||
|
|
||||||
|
x2 = x + width;
|
||||||
|
y2 = y + height;
|
||||||
|
}
|
||||||
|
|
||||||
void render(DrawContext context, boolean hover) {}
|
void render(DrawContext context, boolean hover) {}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,7 @@ import net.minecraft.client.gui.DrawContext;
|
|||||||
|
|
||||||
public class Box extends AuraWidget {
|
public class Box extends AuraWidget {
|
||||||
public Box(int x, int y, int width, int height) {
|
public Box(int x, int y, int width, int height) {
|
||||||
x1 = x;
|
super(x, y, width, height);
|
||||||
y1 = y;
|
|
||||||
|
|
||||||
x2 = x + width;
|
|
||||||
y2 = y + height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(DrawContext context, boolean hover) {
|
public void render(DrawContext context, boolean hover) {
|
||||||
|
|||||||
@@ -5,21 +5,15 @@ import net.minecraft.client.gui.DrawContext;
|
|||||||
public class Button extends AuraWidget {
|
public class Button extends AuraWidget {
|
||||||
public Runnable onClick;
|
public Runnable onClick;
|
||||||
public String text;
|
public String text;
|
||||||
public static int hoverBorder = 0xFFFFFFFF;
|
public int hoverBorder = 0xFFFFFFFF;
|
||||||
|
|
||||||
public Button(String button_text, int x, int y, int width, int height, Runnable on_click) {
|
public Button(String button_text, int x, int y, int width, int height, Runnable on_click) {
|
||||||
x1 = x;
|
super(x, y, width, height);
|
||||||
y1 = y;
|
|
||||||
|
|
||||||
x2 = x + width;
|
|
||||||
y2 = y + height;
|
|
||||||
|
|
||||||
onClick = on_click;
|
onClick = on_click;
|
||||||
text = button_text;
|
text = button_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(DrawContext context, boolean hover) {
|
public void render(DrawContext context, boolean hover) {
|
||||||
|
|
||||||
context.fill(x1, y1, x2, y2, background);
|
context.fill(x1, y1, x2, y2, background);
|
||||||
|
|
||||||
context.drawText(client.textRenderer, text, (((x2 - x1) - client.textRenderer.getWidth(text)) / 2) + x1, (((y2 - y1) - 6) / 2) + y1, foreground, false);
|
context.drawText(client.textRenderer, text, (((x2 - x1) - client.textRenderer.getWidth(text)) / 2) + x1, (((y2 - y1) - 6) / 2) + y1, foreground, false);
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.auraclient.auraclient.ui;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class ImageButton extends AuraWidget {
|
||||||
|
private final Identifier sprite;
|
||||||
|
public int hoverBorder = 0xFFFFFFFF;
|
||||||
|
public int textureWidth;
|
||||||
|
public int textureHeight;
|
||||||
|
public Runnable onClick;
|
||||||
|
|
||||||
|
public ImageButton(Identifier sprite_, int x, int y, int width, int height) {
|
||||||
|
super(x, y, width, height);
|
||||||
|
this.sprite = sprite_;
|
||||||
|
this.textureWidth = width;
|
||||||
|
this.textureHeight = height;
|
||||||
|
this.onClick = () -> {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageButton(Identifier sprite_, int x, int y, int width, int height, int textureWidth, int textureHeight) {
|
||||||
|
super(x, y, width, height);
|
||||||
|
this.sprite = sprite_;
|
||||||
|
this.textureWidth = textureWidth;
|
||||||
|
this.textureHeight = textureHeight;
|
||||||
|
this.onClick = () -> {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(DrawContext context, boolean hover) {
|
||||||
|
int width = x2 - x1;
|
||||||
|
int height = y2 - y1;
|
||||||
|
|
||||||
|
context.drawTexture(RenderLayer::getGuiTextured, sprite, x1, y1, 0, 0, width, height, width, height);
|
||||||
|
|
||||||
|
if (hover) {
|
||||||
|
context.drawBorder(x1 - 1, y1 - 1, x2 - x1 + 2, y2 - y1 + 2, hoverBorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void mouseClicked() {
|
||||||
|
onClick.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user