use of cc.hyperium.mods.chromahud.api.ButtonConfig in project Hyperium by HyperiumClient.
the class ChromaHUD method registerConfigElements.
private void registerConfigElements() {
ChromaHUDApi.getInstance().registerButtonConfig("COORDS", new ButtonConfig((guiButton, displayItem) -> {
CordsDisplay displayItem1 = (CordsDisplay) displayItem;
displayItem1.state = displayItem1.state == 1 ? 0 : 1;
guiButton.displayString = ChatColor.RED.toString() + "Make " + (((CordsDisplay) displayItem).state == 1 ? "Horizontal" : "Vertical");
}, new GuiButton(0, 0, 0, "Coords State"), (guiButton, displayItem) -> guiButton.displayString = ChatColor.RED.toString() + "Make " + (((CordsDisplay) displayItem).state == 1 ? "Horizontal" : "Vertical")));
ChromaHUDApi.getInstance().registerButtonConfig("COORDS", new ButtonConfig((guiButton, displayItem) -> {
CordsDisplay displayItem1 = (CordsDisplay) displayItem;
displayItem1.precision += 1;
if (displayItem1.precision > 4)
displayItem1.precision = 0;
int next = displayItem1.precision + 1;
if (next > 4)
next = 0;
guiButton.displayString = ChatColor.RED.toString() + "Change to " + next + " decimal" + (next != 1 ? "s" : "");
}, new GuiButton(0, 0, 0, "Coords Precision"), (guiButton, displayItem) -> {
int next = ((CordsDisplay) displayItem).precision + 1;
if (next > 4)
next = 0;
guiButton.displayString = ChatColor.RED.toString() + "Change to " + next + " decimal" + (next != 1 ? "s" : "");
}));
ChromaHUDApi.getInstance().registerButtonConfig("POTION", new ButtonConfig((guiButton, displayItem) -> {
PotionEffects potionEffects = (PotionEffects) displayItem;
potionEffects.togglePotionIcon();
guiButton.displayString = ChatColor.RED + "Toggle Potion Icon";
}, new GuiButton(0, 0, 0, "Potion Icons"), (guiButton, displayItem) -> guiButton.displayString = ChatColor.RED.toString() + "Toggle Potion Icon"));
ChromaHUDApi.getInstance().registerButtonConfig("DIRECTION", new ButtonConfig((guiButton, displayItem) -> {
DirectionHUD directionHUD = (DirectionHUD) displayItem;
directionHUD.toggleShortDirection();
guiButton.displayString = ChatColor.RED + "Toggle Short Direction";
}, new GuiButton(0, 0, 0, "Short Directions"), ((guiButton, displayItem) -> guiButton.displayString = ChatColor.RED + "Toggle Short Direction")));
ChromaHUDApi.getInstance().registerButtonConfig("ARMOUR_HUD", new ButtonConfig((guiButton, displayItem) -> {
ArmourHud item = (ArmourHud) displayItem;
item.toggleDurability();
guiButton.displayString = ChatColor.RED.toString() + "Toggle Durability";
}, new GuiButton(0, 0, 0, "Armour Hud Durability"), (guiButton, displayItem) -> guiButton.displayString = ChatColor.RED.toString() + "Toggle Durability"));
ChromaHUDApi.getInstance().registerButtonConfig("ARMOUR_HUD", new ButtonConfig((guiButton, displayItem) -> {
ArmourHud item = (ArmourHud) displayItem;
item.toggleHand();
guiButton.displayString = ChatColor.RED.toString() + "Toggle Held Item";
}, new GuiButton(0, 0, 0, "Armour Hud Hand"), (guiButton, displayItem) -> guiButton.displayString = ChatColor.RED.toString() + "Toggle Held Item"));
ChromaHUDApi.getInstance().registerButtonConfig("ARMOUR_HUD", new ButtonConfig((guiButton, displayItem) -> {
ArmourHud item = (ArmourHud) displayItem;
item.setArmourOnTop(!item.isArmourOnTop());
guiButton.displayString = ChatColor.RED.toString() + "Toggle Armour On Top";
}, new GuiButton(0, 0, 0, "Armour Hud Hand"), (guiButton, displayItem) -> guiButton.displayString = ChatColor.RED.toString() + "Toggle Armour On Top"));
GuiTextField textTextField = new GuiTextField(1, Minecraft.getMinecraft().fontRendererObj, 0, 0, 200, 20);
ChromaHUDApi.getInstance().registerTextConfig("TEXT", new TextConfig((guiTextField, displayItem) -> ((TextItem) displayItem).setText(guiTextField.getText()), textTextField, (guiTextField, displayItem) -> guiTextField.setText(((TextItem) displayItem).getText())));
ChromaHUDApi.getInstance().registerTextConfig("TIME", new TextConfig((guiTextField, displayItem) -> ((TimeHud) displayItem).setFormat(guiTextField.getText()), textTextField, (guiTextField, displayItem) -> guiTextField.setText(((TimeHud) displayItem).getFormat())));
ChromaHUDApi.getInstance().registerStringConfig("TIME", new StringConfig("Accepted Formats\n" + "YY - Year\n" + "MM - Month\n" + "dd - Day\n" + "HH - Hour\n" + "mm - Minute\n" + "ss - Second\n" + "For more options, Google \"Date Format\""));
ChromaHUDApi.getInstance().registerButtonConfig("SCOREBOARD", new ButtonConfig((guiButton, displayItem) -> displayItem.getData().put("numbers", !displayItem.getData().optBoolean("numbers")), new GuiButton(0, 0, 0, "Toggle Number"), (guiButton, displayItem) -> {
}));
ChromaHUDApi.getInstance().registerTextConfig("SPRINT_STATUS", new TextConfig((guiTextField, displayItem) -> ((ToggleSprintStatus) displayItem).setSprintEnabledText(guiTextField.getText()), textTextField, (guiTextField, displayItem) -> guiTextField.setText(((ToggleSprintStatus) displayItem).getStatusText())));
ChromaHUDApi.getInstance().registerButtonConfig("COINS", new ButtonConfig((guiButton, displayItem) -> {
JsonHolder data = displayItem.getData();
int state = data.optInt("state");
state++;
if (state < 0 || state > 2) {
state = 0;
}
data.put("state", state);
}, new GuiButton(0, 0, 0, "Toggle Number"), (guiButton, displayItem) -> {
JsonHolder data = displayItem.getData();
int state = data.optInt("state");
if (state < 0 || state > 2)
state = 0;
if (state == 0)
guiButton.displayString = "Daily Coins";
if (state == 1)
guiButton.displayString = "Monthly Coins";
if (state == 2)
guiButton.displayString = "Lifetime Coins";
}));
}
use of cc.hyperium.mods.chromahud.api.ButtonConfig in project Hyperium by HyperiumClient.
the class EditItemsGui method mouseClicked.
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
if (modifying != null) {
List<ButtonConfig> configs = ChromaHUDApi.getInstance().getButtonConfigs(modifying.getType());
if (configs != null && !configs.isEmpty()) {
for (ButtonConfig config : configs) {
GuiButton button = config.getButton();
if (button.mousePressed(mc, mouseX, mouseY)) {
config.getAction().accept(button, modifying);
return;
}
}
}
List<TextConfig> textConfigs = ChromaHUDApi.getInstance().getTextConfigs(modifying.getType());
if (textConfigs != null && !textConfigs.isEmpty()) {
for (TextConfig config : textConfigs) {
GuiTextField textField = config.getTextField();
textField.mouseClicked(mouseX, mouseY, mouseButton);
if (textField.isFocused()) {
return;
}
}
}
}
super.mouseClicked(mouseX, mouseY, mouseButton);
if (mouseButton == 0) {
DisplayItem item1 = null;
// Check X range first since it is easy
ScaledResolution current = ResolutionUtil.current();
int xCenter = current.getScaledWidth() / 2;
if (mouseX >= xCenter - 80 && mouseX <= xCenter + 80) {
// now some super janky code
int yPosition = 40;
for (DisplayItem displayItem : element.getDisplayItems()) {
if (mouseY >= yPosition && mouseY <= yPosition + 20) {
item1 = displayItem;
break;
}
// Adjust for 3 pixel gap
yPosition += 23;
}
}
for (GuiButton guiButton : super.buttonList) {
if (guiButton.isMouseOver())
return;
}
modifying = item1;
if (modifying != null) {
ChromaHUDApi.getInstance().getTextConfigs(modifying.getType()).forEach((config) -> config.getLoad().accept(config.getTextField(), modifying));
ChromaHUDApi.getInstance().getButtonConfigs(modifying.getType()).forEach((button) -> button.getLoad().accept(button.getButton(), modifying));
ChromaHUDApi.getInstance().getStringConfigs(modifying.getType()).forEach((button) -> button.getLoad().accept(modifying));
}
}
}
use of cc.hyperium.mods.chromahud.api.ButtonConfig in project Hyperium by HyperiumClient.
the class EditItemsGui method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
ScaledResolution current = ResolutionUtil.current();
drawRect(0, 0, current.getScaledWidth(), current.getScaledHeight(), new Color(0, 0, 0, 150).getRGB());
super.drawScreen(mouseX, mouseY, partialTicks);
ElementRenderer.startDrawing(element);
element.renderEditView();
ElementRenderer.endDrawing(element);
int xPosition = ResolutionUtil.current().getScaledWidth() / 2 - 80;
int yPosition = 40;
int width = 160;
int height = 20;
Color defaultColor = new Color(255, 255, 255, 100);
Color otherColor = new Color(255, 255, 255, 150);
for (DisplayItem displayItem : element.getDisplayItems()) {
FontRenderer fontrenderer = mc.fontRendererObj;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
boolean hovered = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height;
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, modifying != null && modifying.getOrdinal() == displayItem.getOrdinal() || hovered ? otherColor.getRGB() : defaultColor.getRGB());
int j = Color.RED.getRGB();
String displayString = ChromaHUDApi.getInstance().getName(displayItem.getType());
fontrenderer.drawString(displayString, (xPosition + (width >> 1) - (fontrenderer.getStringWidth(displayString) >> 1)), yPosition + ((height - 8) >> 1), j, false);
yPosition += 23;
}
if (modifying != null) {
List<ButtonConfig> configs = ChromaHUDApi.getInstance().getButtonConfigs(modifying.getType());
xPosition = 3;
yPosition = 5 + 21 * 4;
if (configs != null && !configs.isEmpty()) {
for (ButtonConfig config : configs) {
GuiButton button = config.getButton();
button.xPosition = xPosition;
button.yPosition = yPosition;
button.drawButton(mc, mouseX, mouseY);
yPosition += 23;
}
}
List<TextConfig> textConfigs = ChromaHUDApi.getInstance().getTextConfigs(modifying.getType());
if (textConfigs != null && !textConfigs.isEmpty()) {
for (TextConfig config : textConfigs) {
GuiTextField textField = config.getTextField();
textField.xPosition = xPosition;
textField.yPosition = yPosition;
textField.drawTextBox();
yPosition += 23;
config.getAction().accept(textField, modifying);
}
}
int rightBound = (int) (ResolutionUtil.current().getScaledWidth_double() / 2 - 90);
List<StringConfig> stringConfigs = ChromaHUDApi.getInstance().getStringConfigs(modifying.getType());
if (stringConfigs != null && !stringConfigs.isEmpty()) {
for (StringConfig config : stringConfigs) {
config.getDraw().accept(modifying);
String draw = config.getString();
List<String> lines = new ArrayList<>();
String[] split = draw.split(" ");
FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
StringBuilder currentLine = new StringBuilder();
for (String s : split) {
if (!s.contains("\n")) {
if (fontRendererObj.getStringWidth(" " + currentLine.toString()) + fontRendererObj.getStringWidth(s) + xPosition < rightBound - 10)
currentLine.append(" ").append(s);
else {
lines.add(currentLine.toString());
currentLine = new StringBuilder();
currentLine.append(s);
}
} else {
String[] split1 = s.split("\n");
Iterator<String> iterator = Arrays.asList(split1).iterator();
while (iterator.hasNext()) {
currentLine.append(" ").append(iterator.next());
if (iterator.hasNext()) {
lines.add(currentLine.toString());
currentLine = new StringBuilder();
}
}
}
}
lines.add(currentLine.toString());
yPosition += 10;
for (String string : lines) {
Minecraft.getMinecraft().fontRendererObj.drawString(string, xPosition, yPosition, Color.RED.getRGB());
yPosition += 10;
}
}
}
}
}
Aggregations