commit
9a5a1fb246
|
@ -114,23 +114,9 @@ public final class BlocksComponent extends HudComponent {
|
|||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(fluidStill.toString());
|
||||
}
|
||||
|
||||
final int fluidColor = fluid.getColor();
|
||||
final float r = (float)(fluidColor >> 16 & 255) / 255.0F;
|
||||
final float g = (float)(fluidColor >> 8 & 255) / 255.0F;
|
||||
final float b = (float)(fluidColor & 255) / 255.0F;
|
||||
GlStateManager.color(r, g, b, 1.0f);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
final Tessellator tessellator = Tessellator.getInstance();
|
||||
final BufferBuilder bufferBuilder = tessellator.getBuffer();
|
||||
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
RenderUtil.glColor(fluid.getColor());
|
||||
// Note that fluids are a full quad; extra padding is added so that you can see the background to check whether the block is selected or not
|
||||
bufferBuilder.pos((double)(rectX + 1), (double)(rectY + 15), 0d).tex((double)sprite.getMinU(), (double)sprite.getMaxV()).endVertex();
|
||||
bufferBuilder.pos((double)(rectX + 15), (double)(rectY + 15), 0d).tex((double)sprite.getMaxU(), (double)sprite.getMaxV()).endVertex();
|
||||
bufferBuilder.pos((double)(rectX + 15), (double)(rectY + 1), 0d).tex((double)sprite.getMaxU(), (double)sprite.getMinV()).endVertex();
|
||||
bufferBuilder.pos((double)(rectX + 1), (double)(rectY + 1), 0d).tex((double)sprite.getMinU(), (double)sprite.getMinV()).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
RenderUtil.drawTexture(rectX + 1, rectY + 1, 14, 14, sprite.getMinU(), sprite.getMinV(), sprite.getMaxU(), sprite.getMaxV());
|
||||
} else {
|
||||
final ItemStack itemStack = new ItemStack(block);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(itemStack, (int) renderPaddingX + (int) this.getX() + xOffset, (int) renderPaddingY + (int) this.getY() + yOffset);
|
||||
|
@ -162,8 +148,8 @@ public final class BlocksComponent extends HudComponent {
|
|||
public void mouseClick(int mouseX, int mouseY, int button) {
|
||||
super.mouseClick(mouseX, mouseY, button);
|
||||
|
||||
if (this.searchBox.displayValue.equals("..."))
|
||||
this.searchBox.displayValue = "";
|
||||
if (this.searchBox.getText().equals("..."))
|
||||
this.searchBox.setText("");
|
||||
|
||||
this.searchBox.mouseClick(mouseX, mouseY, button);
|
||||
}
|
||||
|
@ -212,7 +198,7 @@ public final class BlocksComponent extends HudComponent {
|
|||
super.keyTyped(typedChar, keyCode);
|
||||
this.searchBox.keyTyped(typedChar, keyCode);
|
||||
|
||||
if (this.searchBox.displayValue.equals("") && this.displayedBlocks.size() != 0) {
|
||||
if (this.searchBox.getText().equals("") && this.displayedBlocks.size() != 0) {
|
||||
this.displayedBlocks.clear();
|
||||
this.displayedBlocks.addAll(this.blocks);
|
||||
} else {
|
||||
|
@ -220,9 +206,9 @@ public final class BlocksComponent extends HudComponent {
|
|||
}
|
||||
|
||||
for (Block block : this.blocks) {
|
||||
if (CharUtils.isAsciiNumeric(typedChar) && NumberUtils.isDigits(this.searchBox.displayValue)) {
|
||||
if (CharUtils.isAsciiNumeric(typedChar) && NumberUtils.isDigits(this.searchBox.getText())) {
|
||||
final int blockID = Block.getIdFromBlock(block);
|
||||
if (blockID == Integer.parseInt(this.searchBox.displayValue)) {
|
||||
if (blockID == Integer.parseInt(this.searchBox.getText())) {
|
||||
if (!this.displayedBlocks.contains(block)) {
|
||||
this.displayedBlocks.add(block);
|
||||
}
|
||||
|
@ -230,7 +216,7 @@ public final class BlocksComponent extends HudComponent {
|
|||
} else {
|
||||
final ResourceLocation registryName = block.getRegistryName();
|
||||
if (registryName != null) {
|
||||
if (registryName.toString().contains(this.searchBox.displayValue)) {
|
||||
if (registryName.toString().contains(this.searchBox.getText())) {
|
||||
if (!this.displayedBlocks.contains(block)) {
|
||||
this.displayedBlocks.add(block);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ public class ColorComponent extends TextComponent {
|
|||
|
||||
private Color currentColor;
|
||||
|
||||
private static final int BORDER = 1;
|
||||
private static final int TEXT_BLOCK_PADDING = 1;
|
||||
// space occupied from left to right: border, color box, spacing, text, spacing, check, spacing, gear, border
|
||||
private static final int COLOR_SIZE = 7;
|
||||
private static final int GEAR_WIDTH = 8;
|
||||
|
||||
private String customDisplayValue;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class ColorComponent extends TextComponent {
|
|||
public ColorComponent(String name, int defaultColor) {
|
||||
super(name, String.valueOf(defaultColor), false);
|
||||
this.currentColor = new Color(defaultColor);
|
||||
this.displayValue = "#" + Integer.toHexString(this.currentColor.getRGB()).toLowerCase().substring(2);
|
||||
this.setText("#" + Integer.toHexString(this.currentColor.getRGB()).toLowerCase().substring(2));
|
||||
this.gearTexture = new Texture("gear_wheel.png");
|
||||
this.gearTextureEnabled = new Texture("gear_wheel-enabled.png");
|
||||
|
||||
|
@ -38,63 +38,33 @@ public class ColorComponent extends TextComponent {
|
|||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
//super.render(mouseX, mouseY, partialTicks);
|
||||
/*if (this.focused) {
|
||||
this.setH(50);
|
||||
} else {
|
||||
this.setH(9);
|
||||
}*/
|
||||
|
||||
if (isMouseInside(mouseX, mouseY))
|
||||
RenderUtil.drawGradientRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x30909090, 0x00101010);
|
||||
|
||||
// draw bg rect
|
||||
RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW() - (this.focused ? 20 : 10), this.getY() + this.getH(), 0x45303030);
|
||||
|
||||
// draw color rect
|
||||
RenderUtil.drawRect(this.getX() + BORDER, this.getY() + BORDER, this.getX() + BORDER + COLOR_SIZE, this.getY() + BORDER + COLOR_SIZE, ColorUtil.changeAlpha(this.currentColor.getRGB(), 0xFF));
|
||||
|
||||
// draw name / display value
|
||||
String displayedName = this.getName();
|
||||
// draw text component, reserving space for gear and color rectangle
|
||||
// only show color hex value if focused, else, show value's name
|
||||
String displayedName = null;
|
||||
if (this.focused) {
|
||||
displayedName = this.displayValue;
|
||||
displayedName = "";
|
||||
} else if (customDisplayValue != null) {
|
||||
displayedName = customDisplayValue;
|
||||
} else if (this.getDisplayName() != null) {
|
||||
displayedName = this.getDisplayName();
|
||||
}
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(displayedName, (int) this.getX() + BORDER + COLOR_SIZE + BORDER, (int) this.getY() + BORDER, this.focused ? 0xFFFFFFFF : 0xFFAAAAAA);
|
||||
|
||||
// draw bg rect behind right button
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - (this.focused ? 20 : 10), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x45202020);
|
||||
|
||||
if (this.focused) {
|
||||
if (!this.selectedText.equals("")) {
|
||||
RenderUtil.drawRect(this.getX() + BORDER + COLOR_SIZE + BORDER, this.getY(), this.getX() + BORDER + COLOR_SIZE + BORDER + Minecraft.getMinecraft().fontRenderer.getStringWidth(this.displayValue), this.getY() + this.getH(), 0x45FFFFFF);
|
||||
}
|
||||
|
||||
float blockX = this.getX() + BORDER + Minecraft.getMinecraft().fontRenderer.getStringWidth(this.displayValue) + COLOR_SIZE + BORDER + TEXT_BLOCK_PADDING;
|
||||
float blockY = this.getY() + TEXT_BLOCK_PADDING;
|
||||
int blockWidth = 2;
|
||||
int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2;
|
||||
RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF);
|
||||
|
||||
// draw gear
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - 10, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010);
|
||||
this.gearTextureEnabled.bind();
|
||||
this.gearTextureEnabled.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
||||
|
||||
// check
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - 20, this.getY(), this.getX() + this.getW() - 10, this.getY() + this.getH(), 0xFF101010);
|
||||
this.checkTexture.bind();
|
||||
this.checkTexture.render(this.getX() + this.getW() - 19, this.getY() + 0.5f, 8, 8);
|
||||
|
||||
// handle holding backspace
|
||||
this.handleBackspacing();
|
||||
} else {
|
||||
// draw gear
|
||||
displayedName = this.getName();
|
||||
}
|
||||
|
||||
this.renderReserved(mouseX, mouseY, partialTicks, displayedName, this.focused, SPACING + COLOR_SIZE, SPACING + GEAR_WIDTH + SPACING);
|
||||
|
||||
// draw color rect
|
||||
RenderUtil.drawRect(this.getX() + BORDER, this.getY() + BORDER, this.getX() + BORDER + COLOR_SIZE, this.getY() + BORDER + COLOR_SIZE, ColorUtil.changeAlpha(this.currentColor.getRGB(), 0xFF));
|
||||
|
||||
// draw gear
|
||||
final float gearOffset = this.getX() + this.getW() - BORDER - GEAR_WIDTH;
|
||||
if (this.focused) {
|
||||
RenderUtil.drawRect(gearOffset - SPACING, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010);
|
||||
this.gearTextureEnabled.bind();
|
||||
this.gearTextureEnabled.render(gearOffset, this.getY() + ICON_V_OFFSET, GEAR_WIDTH, GEAR_WIDTH);
|
||||
} else {
|
||||
this.gearTexture.bind();
|
||||
this.gearTexture.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
||||
this.gearTexture.render(gearOffset, this.getY() + ICON_V_OFFSET, GEAR_WIDTH, GEAR_WIDTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,8 +76,9 @@ public class ColorComponent extends TextComponent {
|
|||
return;
|
||||
|
||||
if (button == 0) {
|
||||
// check for clicking check
|
||||
if (mouseX >= this.getX() + this.getW() - 20 && mouseX <= this.getX() + this.getW() - 10 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) {
|
||||
// check for clicking check check, spacing, gear, border
|
||||
final float right = this.getX() + this.getW() - BORDER - GEAR_WIDTH - SPACING;
|
||||
if (mouseX >= right - CHECK_WIDTH && mouseX <= right && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) {
|
||||
this.enterPressed();
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +87,7 @@ public class ColorComponent extends TextComponent {
|
|||
@Override
|
||||
protected void enterPressed() {
|
||||
try {
|
||||
int newColor = (int) Long.parseLong(this.displayValue.replaceAll("#", ""), 16);
|
||||
int newColor = (int) Long.parseLong(this.getText().replaceAll("#", ""), 16);
|
||||
this.currentColor = new Color(newColor);
|
||||
} catch (NumberFormatException e) {
|
||||
Seppuku.INSTANCE.logChat(this.getName() + ": Invalid color format. Correct format example: \"ff0000\" for red.");
|
||||
|
|
|
@ -122,8 +122,8 @@ public final class ItemsComponent extends HudComponent {
|
|||
public void mouseClick(int mouseX, int mouseY, int button) {
|
||||
super.mouseClick(mouseX, mouseY, button);
|
||||
|
||||
if (this.searchBox.displayValue.equals("..."))
|
||||
this.searchBox.displayValue = "";
|
||||
if (this.searchBox.getText().equals("..."))
|
||||
this.searchBox.setText("");
|
||||
|
||||
this.searchBox.mouseClick(mouseX, mouseY, button);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public final class ItemsComponent extends HudComponent {
|
|||
super.keyTyped(typedChar, keyCode);
|
||||
this.searchBox.keyTyped(typedChar, keyCode);
|
||||
|
||||
if (this.searchBox.displayValue.equals("") && this.displayedItems.size() != 0) {
|
||||
if (this.searchBox.getText().equals("") && this.displayedItems.size() != 0) {
|
||||
this.displayedItems.clear();
|
||||
this.displayedItems.addAll(this.items);
|
||||
} else {
|
||||
|
@ -180,9 +180,9 @@ public final class ItemsComponent extends HudComponent {
|
|||
}
|
||||
|
||||
for (Item item : this.items) {
|
||||
if (CharUtils.isAsciiNumeric(typedChar) && NumberUtils.isDigits(this.searchBox.displayValue)) {
|
||||
if (CharUtils.isAsciiNumeric(typedChar) && NumberUtils.isDigits(this.searchBox.getText())) {
|
||||
final int itemID = Item.getIdFromItem(item);
|
||||
if (itemID == Integer.parseInt(this.searchBox.displayValue)) {
|
||||
if (itemID == Integer.parseInt(this.searchBox.getText())) {
|
||||
if (!this.displayedItems.contains(item)) {
|
||||
this.displayedItems.add(item);
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public final class ItemsComponent extends HudComponent {
|
|||
} else {
|
||||
final ResourceLocation registryName = item.getRegistryName();
|
||||
if (registryName != null) {
|
||||
if (registryName.toString().contains(this.searchBox.displayValue)) {
|
||||
if (registryName.toString().contains(this.searchBox.getText())) {
|
||||
if (!this.displayedItems.contains(item)) {
|
||||
this.displayedItems.add(item);
|
||||
}
|
||||
|
|
|
@ -219,15 +219,15 @@ public final class SliderComponent extends HudComponent {
|
|||
public void onComponentEvent() {
|
||||
try {
|
||||
if (value.getValue() instanceof Integer) {
|
||||
value.setValue(Integer.parseInt(valueNumberText.displayValue));
|
||||
value.setValue(Integer.parseInt(valueNumberText.getText()));
|
||||
} else if (value.getValue() instanceof Double) {
|
||||
value.setValue(Double.parseDouble(valueNumberText.displayValue));
|
||||
value.setValue(Double.parseDouble(valueNumberText.getText()));
|
||||
} else if (value.getValue() instanceof Float) {
|
||||
value.setValue(Float.parseFloat(valueNumberText.displayValue));
|
||||
value.setValue(Float.parseFloat(valueNumberText.getText()));
|
||||
} else if (value.getValue() instanceof Long) {
|
||||
value.setValue(Long.parseLong(valueNumberText.displayValue));
|
||||
value.setValue(Long.parseLong(valueNumberText.getText()));
|
||||
} else if (value.getValue() instanceof Byte) {
|
||||
value.setValue(Byte.parseByte(valueNumberText.displayValue));
|
||||
value.setValue(Byte.parseByte(valueNumberText.getText()));
|
||||
}
|
||||
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save module configs
|
||||
} catch (NumberFormatException e) {
|
||||
|
|
|
@ -3,13 +3,14 @@ package me.rigamortis.seppuku.api.gui.hud.component;
|
|||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.texture.Texture;
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
import me.rigamortis.seppuku.api.util.Timer;
|
||||
import me.rigamortis.seppuku.api.util.StringUtil;
|
||||
import me.rigamortis.seppuku.impl.gui.hud.component.ColorsComponent;
|
||||
import me.rigamortis.seppuku.impl.gui.hud.component.module.ModuleListComponent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -18,7 +19,7 @@ import java.util.logging.Level;
|
|||
*/
|
||||
public class TextComponent extends HudComponent {
|
||||
|
||||
public String displayValue, selectedText;
|
||||
private String displayValue;
|
||||
public boolean focused;
|
||||
public boolean digitOnly;
|
||||
public ComponentListener returnListener;
|
||||
|
@ -26,66 +27,110 @@ public class TextComponent extends HudComponent {
|
|||
|
||||
protected Texture checkTexture;
|
||||
|
||||
protected Timer backspaceTimer = new Timer(), backspaceWaitTimer = new Timer();
|
||||
protected boolean doBackspacing = false;
|
||||
|
||||
private int textCursor = 0;
|
||||
private int textCursorOffset = 0;
|
||||
private int selectCursor = 0;
|
||||
private int selectCursorOffset = 0;
|
||||
private int shiftLength = 0;
|
||||
private boolean dirty = false;
|
||||
|
||||
private static final int CHECK_WIDTH = 10;
|
||||
private static final int BLOCK_WIDTH = 2;
|
||||
// space occupied from left to right: border, text, spacing, check, border
|
||||
protected static final int BORDER = 1;
|
||||
protected static final int SPACING = 1;
|
||||
protected static final int SHIFT_GAP = 8;
|
||||
protected static final int CHECK_WIDTH = 8;
|
||||
protected static final int BLOCK_WIDTH = 2;
|
||||
protected static final float ICON_V_OFFSET = 0.5f;
|
||||
|
||||
public TextComponent(String name, String displayValue, boolean digitOnly) {
|
||||
super(name);
|
||||
|
||||
this.displayValue = displayValue;
|
||||
this.selectedText = "";
|
||||
this.focused = false;
|
||||
this.digitOnly = digitOnly;
|
||||
|
||||
this.checkTexture = new Texture("check.png");
|
||||
}
|
||||
|
||||
protected void renderReserved(int mouseX, int mouseY, float partialTicks, String renderName, boolean renderValue, float reservedLeft, float reservedRight) {
|
||||
// calculate dimensions that can be used given reserved left/right
|
||||
final float left = this.getX() + reservedLeft;
|
||||
final float right = this.getX() + this.getW() - reservedRight;
|
||||
|
||||
// draw gradient if component has mouse hovering
|
||||
if (this.isMouseInside(mouseX, mouseY))
|
||||
RenderUtil.drawGradientRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x30909090, 0x00101010);
|
||||
|
||||
// draw background
|
||||
RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x45303030);
|
||||
|
||||
// update text shift and cursor offsets if needed
|
||||
String displayValueText = renderName;
|
||||
if (renderValue) {
|
||||
displayValueText += this.displayValue;
|
||||
}
|
||||
|
||||
if (this.focused && renderValue) {
|
||||
if (this.dirty) {
|
||||
this.dirty = false;
|
||||
final String beforeTextCursor = displayValueText.substring(0, renderName.length() + this.textCursor);
|
||||
this.textCursorOffset = Minecraft.getMinecraft().fontRenderer.getStringWidth(beforeTextCursor);
|
||||
|
||||
if (this.selectCursor == this.textCursor) {
|
||||
this.selectCursorOffset = this.textCursorOffset;
|
||||
} else {
|
||||
final String beforeSelectCursor = displayValueText.substring(0, renderName.length() + this.selectCursor);
|
||||
this.selectCursorOffset = Minecraft.getMinecraft().fontRenderer.getStringWidth(beforeSelectCursor);
|
||||
}
|
||||
|
||||
// shift gap is the minimum amount of space to leave after the
|
||||
// text cursor (block) so the user can see that there is more
|
||||
// text to the right
|
||||
final int shiftStart = Math.round(right - left) - CHECK_WIDTH - SPACING - BLOCK_WIDTH - BORDER * 2 - SHIFT_GAP;
|
||||
if (this.textCursorOffset > shiftStart) {
|
||||
this.shiftLength = this.textCursorOffset - shiftStart;
|
||||
} else {
|
||||
this.shiftLength = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.shiftLength = 0;
|
||||
}
|
||||
|
||||
// draw text
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(displayValueText, (int) left + BORDER - this.shiftLength, (int) this.getY() + BORDER, this.focused ? 0xFFFFFFFF : 0xFFAAAAAA);
|
||||
|
||||
if (this.focused && renderValue) {
|
||||
// draw text selection background
|
||||
if (this.textCursor != this.selectCursor) {
|
||||
final int start = Math.min(this.textCursorOffset, this.selectCursorOffset);
|
||||
final int end = Math.max(this.textCursorOffset, this.selectCursorOffset);
|
||||
RenderUtil.drawRect(left + start - this.shiftLength, this.getY(), left + end - this.shiftLength, this.getY() + this.getH(), 0x45FFFFFF);
|
||||
}
|
||||
|
||||
// draw text cursor (block)
|
||||
float blockX = left + BORDER + this.textCursorOffset - this.shiftLength;
|
||||
float blockY = this.getY() + BORDER;
|
||||
final int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - BORDER * 2;
|
||||
RenderUtil.drawRect(blockX, blockY, blockX + BLOCK_WIDTH, blockY + blockHeight, 0xFFFFFFFF);
|
||||
|
||||
// draw checkbox
|
||||
RenderUtil.drawRect(right - CHECK_WIDTH - BORDER - SPACING, this.getY(), right, this.getY() + this.getH(), 0xFF101010);
|
||||
this.checkTexture.bind();
|
||||
this.checkTexture.render(right - CHECK_WIDTH - BORDER, this.getY() + ICON_V_OFFSET, CHECK_WIDTH, CHECK_WIDTH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
if (isMouseInside(mouseX, mouseY))
|
||||
RenderUtil.drawGradientRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x30909090, 0x00101010);
|
||||
|
||||
RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x45303030);
|
||||
|
||||
String renderName = this.getName();
|
||||
if (this.getDisplayName() != null) {
|
||||
renderName = this.getDisplayName();
|
||||
}
|
||||
|
||||
final String displayValueText = renderName + ": " + this.displayValue;
|
||||
this.shiftLength = 0;
|
||||
if (this.focused) {
|
||||
if (Minecraft.getMinecraft().fontRenderer.getStringWidth(displayValueText) > (this.getW() - CHECK_WIDTH - BLOCK_WIDTH - 2))
|
||||
this.shiftLength += Math.abs(Minecraft.getMinecraft().fontRenderer.getStringWidth(displayValueText) - (this.getW() - CHECK_WIDTH - BLOCK_WIDTH - 2));
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(displayValueText, (int) this.getX() + 1 - this.shiftLength, (int) this.getY() + 1, this.focused ? 0xFFFFFFFF : 0xFFAAAAAA);
|
||||
|
||||
if (this.focused) {
|
||||
if (!this.selectedText.equals("")) {
|
||||
RenderUtil.drawRect(this.getX() + Minecraft.getMinecraft().fontRenderer.getStringWidth(renderName + ": ") - this.shiftLength, this.getY(), this.getX() + Minecraft.getMinecraft().fontRenderer.getStringWidth(displayValueText), this.getY() + this.getH(), 0x45FFFFFF);
|
||||
}
|
||||
|
||||
float blockX = this.getX() + 1 - this.shiftLength + Minecraft.getMinecraft().fontRenderer.getStringWidth(renderName + ": " + this.displayValue);
|
||||
float blockY = this.getY() + 1;
|
||||
final int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2;
|
||||
RenderUtil.drawRect(blockX, blockY, blockX + BLOCK_WIDTH, blockY + blockHeight, 0xFFFFFFFF);
|
||||
|
||||
// check
|
||||
RenderUtil.drawRect(this.getX() + this.getW() - CHECK_WIDTH, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010);
|
||||
this.checkTexture.bind();
|
||||
this.checkTexture.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8);
|
||||
|
||||
// handle holding backspace
|
||||
this.handleBackspacing();
|
||||
}
|
||||
this.renderReserved(mouseX, mouseY, partialTicks, renderName + ": ", true, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,24 +185,29 @@ public class TextComponent extends HudComponent {
|
|||
textListener.onKeyTyped(keyCode);
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
|
||||
final boolean ctrlDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
||||
if (ctrlDown) {
|
||||
switch (keyCode) {
|
||||
case Keyboard.KEY_A:
|
||||
this.selectedText = this.displayValue;
|
||||
this.selectAll();
|
||||
return;
|
||||
case Keyboard.KEY_V:
|
||||
if (!this.digitOnly) {
|
||||
this.displayValue += this.getClipBoard();
|
||||
} else if (this.getClipBoard().matches("[0-9]+") /* is a number */) {
|
||||
this.displayValue += this.getClipBoard();
|
||||
}
|
||||
this.insertText(this.getClipBoard());
|
||||
return;
|
||||
case Keyboard.KEY_X:
|
||||
if (this.setClipBoard(this.getSelection())) {
|
||||
this.onRemoveSelectedText();
|
||||
}
|
||||
return;
|
||||
case Keyboard.KEY_C:
|
||||
this.setClipBoard(this.getSelection());
|
||||
return;
|
||||
}
|
||||
|
||||
return; // dont do anything else or you will get special characters typed
|
||||
}
|
||||
|
||||
final boolean shiftDown = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
switch (keyCode) {
|
||||
case Keyboard.KEY_ESCAPE:
|
||||
this.focused = false;
|
||||
|
@ -165,30 +215,28 @@ public class TextComponent extends HudComponent {
|
|||
case Keyboard.KEY_RETURN:
|
||||
this.enterPressed();
|
||||
return;
|
||||
//case Keyboard.KEY_SPACE:
|
||||
// if (!this.digitOnly) {
|
||||
// this.displayValue += ' ';
|
||||
// }
|
||||
// break;
|
||||
case Keyboard.KEY_BACK:
|
||||
case Keyboard.KEY_DELETE:
|
||||
this.backspaceWaitTimer.reset();
|
||||
this.doBackspacing = true;
|
||||
if (this.displayValue.length() > 0) {
|
||||
if (!this.onRemoveSelectedText()) {
|
||||
this.displayValue = this.displayValue.substring(0, this.displayValue.length() - 1);
|
||||
}
|
||||
}
|
||||
final int delta = (keyCode == Keyboard.KEY_DELETE) ? 1 : -1;
|
||||
this.deleteText(delta);
|
||||
return;
|
||||
case Keyboard.KEY_CLEAR:
|
||||
if (this.displayValue.length() > 0) {
|
||||
this.displayValue = "";
|
||||
}
|
||||
this.setText("");
|
||||
return;
|
||||
case Keyboard.KEY_LEFT:
|
||||
this.setTextCursor(this.textCursor - 1, shiftDown);
|
||||
return;
|
||||
case Keyboard.KEY_RIGHT:
|
||||
this.setTextCursor(this.textCursor + 1, shiftDown);
|
||||
return;
|
||||
case Keyboard.KEY_UP:
|
||||
case Keyboard.KEY_HOME:
|
||||
this.setTextCursor(0, shiftDown);
|
||||
return;
|
||||
case Keyboard.KEY_DOWN:
|
||||
case Keyboard.KEY_END:
|
||||
this.setTextCursor(this.displayValue.length(), shiftDown);
|
||||
return;
|
||||
case Keyboard.KEY_LSHIFT:
|
||||
case Keyboard.KEY_RSHIFT:
|
||||
case Keyboard.KEY_LCONTROL:
|
||||
|
@ -200,24 +248,11 @@ public class TextComponent extends HudComponent {
|
|||
case Keyboard.KEY_RMENU:
|
||||
case Keyboard.KEY_LMETA:
|
||||
return;
|
||||
case Keyboard.KEY_PERIOD:
|
||||
if (this.digitOnly) {
|
||||
this.displayValue += typedChar;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (digitOnly && !Character.isDigit(typedChar))
|
||||
return;
|
||||
|
||||
this.onRemoveSelectedText();
|
||||
|
||||
//if (!digitOnly && !Character.isLetterOrDigit(typedChar))
|
||||
// return;
|
||||
|
||||
this.displayValue += typedChar;
|
||||
this.insertText(typedChar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +261,6 @@ public class TextComponent extends HudComponent {
|
|||
if (returnListener != null)
|
||||
returnListener.onComponentEvent();
|
||||
|
||||
this.shiftLength = 0;
|
||||
this.focused = false;
|
||||
}
|
||||
|
||||
|
@ -239,27 +273,20 @@ public class TextComponent extends HudComponent {
|
|||
}
|
||||
|
||||
protected boolean onRemoveSelectedText() {
|
||||
if (!this.selectedText.equals("")) {
|
||||
this.displayValue = "";
|
||||
this.selectedText = "";
|
||||
return true;
|
||||
if (this.textCursor == this.selectCursor) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
this.deleteText(this.textCursor, this.selectCursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void handleBackspacing() {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_BACK) || Keyboard.isKeyDown(Keyboard.KEY_DELETE)) {
|
||||
if (this.doBackspacing && this.backspaceWaitTimer.passed(600)) {
|
||||
if (this.backspaceTimer.passed(75)) {
|
||||
if (this.displayValue.length() > 0) {
|
||||
this.displayValue = this.displayValue.substring(0, this.displayValue.length() - 1);
|
||||
}
|
||||
this.backspaceTimer.reset();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.doBackspacing = false;
|
||||
@Override
|
||||
public void setW(float w) {
|
||||
if (this.getW() != w) {
|
||||
this.dirty = true;
|
||||
}
|
||||
super.setW(w);
|
||||
}
|
||||
|
||||
public String getClipBoard() {
|
||||
|
@ -271,8 +298,109 @@ public class TextComponent extends HudComponent {
|
|||
return "";
|
||||
}
|
||||
|
||||
public boolean setClipBoard(String s) {
|
||||
try {
|
||||
final StringSelection sel = new StringSelection(s);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
|
||||
} catch (Exception e) {
|
||||
Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Error setting clipboard while using " + this.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getSelection() {
|
||||
if (!this.focused || this.textCursor == this.selectCursor) {
|
||||
// textCursor or selectCursor may be invalid if not focused
|
||||
return "";
|
||||
}
|
||||
|
||||
if(this.textCursor > this.selectCursor) {
|
||||
return this.displayValue.substring(this.selectCursor, this.textCursor);
|
||||
} else {
|
||||
return this.displayValue.substring(this.textCursor, this.selectCursor);
|
||||
}
|
||||
}
|
||||
|
||||
public void focus() {
|
||||
this.textCursor = this.selectCursor = this.displayValue.length();
|
||||
this.focused = true;
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public void setTextCursor(int pos, boolean shiftDown) {
|
||||
if (pos <= 0) {
|
||||
pos = 0;
|
||||
} else if(pos > this.displayValue.length()) {
|
||||
pos = this.displayValue.length();
|
||||
}
|
||||
|
||||
final int selectPos = shiftDown ? this.selectCursor : pos;
|
||||
if (this.textCursor != pos || this.selectCursor != selectPos) {
|
||||
this.textCursor = pos;
|
||||
this.selectCursor = selectPos;
|
||||
this.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void insertText(char character) {
|
||||
this.insertText(String.valueOf(character));
|
||||
}
|
||||
|
||||
public void insertText(String str) {
|
||||
if (this.digitOnly && !str.matches("[0-9.]+") /* is a number */) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onRemoveSelectedText();
|
||||
|
||||
this.displayValue = StringUtil.insertAt(this.displayValue, str, this.textCursor);
|
||||
this.setTextCursor(this.textCursor + str.length(), false);
|
||||
}
|
||||
|
||||
public void deleteText(int start, int end) {
|
||||
// sanitise range
|
||||
start = Math.min(Math.max(start, 0), this.displayValue.length());
|
||||
end = Math.min(Math.max(end, 0), this.displayValue.length());
|
||||
if (start == end) {
|
||||
return;
|
||||
} else if(start > end) {
|
||||
final int temp = start;
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
|
||||
this.displayValue = StringUtil.removeRange(this.displayValue, start, end);
|
||||
this.setTextCursor(start, false);
|
||||
}
|
||||
|
||||
public void deleteText(int delta) {
|
||||
if (delta == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.onRemoveSelectedText()) {
|
||||
this.deleteText(this.textCursor, this.textCursor + delta);
|
||||
}
|
||||
}
|
||||
|
||||
public void selectAll() {
|
||||
this.textCursor = this.displayValue.length();
|
||||
this.selectCursor = 0;
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.displayValue;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.displayValue = text;
|
||||
this.selectCursor = this.textCursor = text.length();
|
||||
if (this.focused) {
|
||||
this.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public interface TextComponentListener {
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.rigamortis.seppuku.api.util;
|
|||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import org.lwjgl.util.vector.Matrix4f;
|
||||
import org.lwjgl.util.vector.Vector4f;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
@ -319,11 +320,13 @@ public final class GLUProjection {
|
|||
} else {
|
||||
pitch = -Math.toDegrees(Math.atan2(nuv.cross(uv).length(), nuv.dot(uv)));
|
||||
}
|
||||
this.lookVec = this.getRotationVector(yaw, pitch);
|
||||
//Get modelview matrix and invert it
|
||||
Matrix4f modelviewMatrix = new Matrix4f();
|
||||
modelviewMatrix.load(this.modelview.asReadOnlyBuffer());
|
||||
modelviewMatrix.invert();
|
||||
//Get look vector (forward) from modelview matrix
|
||||
Vector4f forward = Matrix4f.transform(modelviewMatrix, new Vector4f(0, 0, -1, 0), null);
|
||||
this.lookVec = new Vector3D(forward.x, forward.y, forward.z).snormalize();
|
||||
//Get frustum position
|
||||
this.frustumPos = new Vector3D(modelviewMatrix.m30, modelviewMatrix.m31, modelviewMatrix.m32);
|
||||
this.frustum = this.getFrustum(this.frustumPos.x, this.frustumPos.y, this.frustumPos.z, yaw, pitch, fov, 1.0F, displayWidth / displayHeight);
|
||||
|
@ -579,6 +582,15 @@ public final class GLUProjection {
|
|||
return this.lookVec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the camera position (frustumPos) updated with {@link GLUProjection#updateMatrices(IntBuffer, FloatBuffer, FloatBuffer, double, double)}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Vector3D getCamPos() {
|
||||
return this.frustumPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rotated vector with the given yaw and pitch.
|
||||
*
|
||||
|
|
|
@ -36,7 +36,7 @@ public final class RenderUtil {
|
|||
GLUProjection.getInstance().updateMatrices(VIEWPORT, MODELVIEW, PROJECTION, (float) res.getScaledWidth() / (float) Minecraft.getMinecraft().displayWidth, (float) res.getScaledHeight() / (float) Minecraft.getMinecraft().displayHeight);
|
||||
}
|
||||
|
||||
public static void drawRect(float x, float y, float w, float h, int color) {
|
||||
public static void drawRect(float left, float top, float right, float bottom, int color) {
|
||||
float alpha = (float) (color >> 24 & 255) / 255.0F;
|
||||
float red = (float) (color >> 16 & 255) / 255.0F;
|
||||
float green = (float) (color >> 8 & 255) / 255.0F;
|
||||
|
@ -47,10 +47,10 @@ public final class RenderUtil {
|
|||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
bufferbuilder.pos(x, h, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(w, h, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(w, y, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(x, y, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(left, bottom, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(right, bottom, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(right, top, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
bufferbuilder.pos(left, top, 0.0D).color(red, green, blue, alpha).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
|
@ -636,13 +636,7 @@ public final class RenderUtil {
|
|||
}
|
||||
|
||||
public static void drawSphere(float radius, int slices, int stacks, int color) {
|
||||
final float alpha = (color >> 24 & 0xFF) / 255.0F;
|
||||
final float red = (color >> 16 & 0xFF) / 255.0F;
|
||||
final float green = (color >> 8 & 0xFF) / 255.0F;
|
||||
final float blue = (color & 0xFF) / 255.0F;
|
||||
|
||||
glColor4f(red, green, blue, alpha);
|
||||
|
||||
glColor(color);
|
||||
new Sphere().draw(radius, slices, stacks);
|
||||
}
|
||||
|
||||
|
@ -718,7 +712,7 @@ public final class RenderUtil {
|
|||
float red = (hex >> 16 & 0xFF) / 255.0F;
|
||||
float green = (hex >> 8 & 0xFF) / 255.0F;
|
||||
float blue = (hex & 0xFF) / 255.0F;
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
GlStateManager.color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public static void glColor(int redRGB, int greenRGB, int blueRGB, int alphaRGB) {
|
||||
|
@ -726,7 +720,7 @@ public final class RenderUtil {
|
|||
float green = 0.003921569F * greenRGB;
|
||||
float blue = 0.003921569F * blueRGB;
|
||||
float alpha = 0.003921569F * alphaRGB;
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
GlStateManager.color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public static void begin2D() {
|
||||
|
|
|
@ -141,4 +141,51 @@ public final class StringUtil {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a string inside another string at a given position. Does not check
|
||||
* for bounds and therefore may throw.
|
||||
* @param original The original string, where the insertion string will be put
|
||||
* @param insertion The string to insert
|
||||
* @param position Where to insert the string at
|
||||
* @returns the final string
|
||||
*/
|
||||
public static String insertAt(String original, String insertion, int position) {
|
||||
return new StringBuilder(original.length() + insertion.length())
|
||||
.append(original, 0, position)
|
||||
.append(insertion)
|
||||
.append(original,position, original.length())
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a character inside another string at a given position. Does not
|
||||
* check for bounds and therefore may throw.
|
||||
* @param original The original string, where the insertion string will be put
|
||||
* @param insertion The character to insert
|
||||
* @param position Where to insert the character at
|
||||
* @returns the final string
|
||||
*/
|
||||
public static String insertAt(String original, char insertion, int position) {
|
||||
return new StringBuilder(original.length() + 1)
|
||||
.append(original, 0, position)
|
||||
.append(insertion)
|
||||
.append(original,position, original.length())
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a range of characters in a string. Does not check for bounds and
|
||||
* therefore may throw.
|
||||
* @param s The string to manipulate
|
||||
* @param start The start of the range
|
||||
* @param end The end of the range (exclusive; character at this position not removed)
|
||||
* @returns the final string
|
||||
*/
|
||||
public static String removeRange(String s, int start, int end) {
|
||||
return new StringBuilder(s.length() + start - end)
|
||||
.append(s, 0, start)
|
||||
.append(s, end, s.length())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public final class GuiHudEditor extends GuiScreen {
|
|||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
this.particlesComponent = (ParticlesComponent) Seppuku.INSTANCE.getHudManager().findComponent(ParticlesComponent.class);
|
||||
if (particlesComponent != null) {
|
||||
if (particlesComponent.isVisible()) {
|
||||
|
@ -185,6 +187,7 @@ public final class GuiHudEditor extends GuiScreen {
|
|||
@Override
|
||||
public void onGuiClosed() {
|
||||
//Seppuku.INSTANCE.getConfigManager().saveAll();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
|
||||
final HudEditorModule hudEditorModule = (HudEditorModule) Seppuku.INSTANCE.getModuleManager().find(HudEditorModule.class);
|
||||
if (hudEditorModule != null) {
|
||||
|
|
|
@ -374,7 +374,7 @@ public final class ColorsComponent extends ResizableHudComponent {
|
|||
this.selectedColor = colorAtMouseClick.getRGB();
|
||||
this.currentColorComponent.setCurrentColor(colorAtMouseClick);
|
||||
this.currentColorComponent.returnListener.onComponentEvent();
|
||||
this.currentColorComponent.displayValue = "#" + Integer.toHexString(this.selectedColor).toLowerCase().substring(2);
|
||||
this.currentColorComponent.setText("#" + Integer.toHexString(this.selectedColor).toLowerCase().substring(2));
|
||||
this.lastSpectrumMouseX = mouseX;
|
||||
this.lastSpectrumMouseY = mouseY;
|
||||
} else {
|
||||
|
|
|
@ -464,7 +464,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
|
|||
public void onKeyTyped(int keyCode) {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
module.setKey("NONE");
|
||||
keybindText.displayValue = "none";
|
||||
keybindText.setText("none");
|
||||
keybindText.focused = false;
|
||||
// re-open the hud editor
|
||||
final HudEditorModule hudEditorModule = (HudEditorModule) Seppuku.INSTANCE.getModuleManager().find(HudEditorModule.class);
|
||||
|
@ -474,7 +474,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
|
|||
} else {
|
||||
String newKey = Keyboard.getKeyName(keyCode);
|
||||
module.setKey(newKey);
|
||||
keybindText.displayValue = newKey.length() == 1 /* is letter */ ? newKey.substring(1) : newKey.toLowerCase();
|
||||
keybindText.setText(newKey.length() == 1 /* is letter */ ? newKey.substring(1) : newKey.toLowerCase());
|
||||
keybindText.focused = false;
|
||||
}
|
||||
}
|
||||
|
@ -574,8 +574,8 @@ public final class ModuleListComponent extends ResizableHudComponent {
|
|||
valueText.returnListener = new ComponentListener() {
|
||||
@Override
|
||||
public void onComponentEvent() {
|
||||
if (value.getEnum(valueText.displayValue) != -1) {
|
||||
value.setEnumValue(valueText.displayValue);
|
||||
if (value.getEnum(valueText.getText()) != -1) {
|
||||
value.setEnumValue(valueText.getText());
|
||||
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save configs
|
||||
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));
|
||||
} else {
|
||||
|
@ -596,8 +596,8 @@ public final class ModuleListComponent extends ResizableHudComponent {
|
|||
valueText.returnListener = new ComponentListener() {
|
||||
@Override
|
||||
public void onComponentEvent() {
|
||||
if (valueText.displayValue.length() > 0) {
|
||||
value.setValue(valueText.displayValue);
|
||||
if (valueText.getText().length() > 0) {
|
||||
value.setValue(valueText.getText());
|
||||
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save configs
|
||||
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));
|
||||
} else {
|
||||
|
@ -640,7 +640,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
|
|||
@Override
|
||||
public void onComponentEvent() {
|
||||
final Regex regex = (Regex) value.getValue();
|
||||
regex.setPatternString(valueText.displayValue);
|
||||
regex.setPatternString(valueText.getText());
|
||||
if(regex.getPattern() == null)
|
||||
Seppuku.INSTANCE.logfChat("%s - %s: Invalid or empty regular expression; no input will match with pattern.", module.getDisplayName(), value.getName());
|
||||
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save configs
|
||||
|
|
|
@ -69,10 +69,6 @@ public final class CommandsModule extends Module {
|
|||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.player != null) {
|
||||
if (mc.currentScreen instanceof GuiChat) {
|
||||
if (event.getKeyCode() == 15) { // tab
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
final int prefixLength = this.prefix.getValue().length();
|
||||
String input = ((GuiChat) mc.currentScreen).inputField.getText();
|
||||
|
||||
|
@ -81,6 +77,10 @@ public final class CommandsModule extends Module {
|
|||
}
|
||||
|
||||
if (input.startsWith(this.prefix.getValue())) {
|
||||
if (event.getKeyCode() == 15) { // tab
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (input.length() > prefixLength) {
|
||||
input = input.substring(prefixLength);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,10 @@ public final class AutoWalkModule extends Module {
|
|||
public final Value<String> baritoneCommand = new Value<>("Command", new String[]{"Com", "C", "Text"}, "The message you want to send to communicate with baritone. (include prefix!)", "#explore");
|
||||
public final Value<String> baritoneCancelCommand = new Value<>("Cancel", new String[]{"BaritoneCancel", "Cancel", "Stop", "Text"}, "The cancel baritone command to send when disabled. (include prefix!)", "#cancel");
|
||||
public final Value<Float> waitTime = new Value<Float>("MsgDelay", new String[]{"MessageDelay", "CommandDelay", "Delay", "Wait", "Time", "md", "d"}, "Delay(ms) between sending baritone commands when standing.", 3000.0f, 0.0f, 8000.0f, 100.0f);
|
||||
public final Value<Float> standingTime = new Value<Float>("StandingTime", new String[]{"SDelay", "StandingT", "StandingWait", "StandingW", "SWait", "st"}, "Time(ms) needed to count as standing still. Prevents re-pathing when rubberbanding", 250.0f, 0.0f, 4000.0f, 50.0f);
|
||||
|
||||
private final Timer sendCommandTimer = new Timer();
|
||||
private final Timer movementTimer = new Timer();
|
||||
|
||||
public AutoWalkModule() {
|
||||
super("AutoWalk", new String[]{"AutomaticWalk"}, "Automatically presses the forward key or sends commands to baritone.", "NONE", -1, ModuleType.MOVEMENT);
|
||||
|
@ -95,8 +97,13 @@ public final class AutoWalkModule extends Module {
|
|||
}
|
||||
|
||||
if (this.useBaritone.getValue()) {
|
||||
boolean isStanding = Minecraft.getMinecraft().player.motionX == 0 && Minecraft.getMinecraft().player.motionZ == 0;
|
||||
if (isStanding && this.sendCommandTimer.passed(this.waitTime.getValue())) {
|
||||
boolean isStanding = true; // you could probably remove this flag now that there's a standing time check
|
||||
if (Minecraft.getMinecraft().player.motionX != 0 || Minecraft.getMinecraft().player.motionZ != 0) {
|
||||
this.movementTimer.reset();
|
||||
isStanding = false;
|
||||
}
|
||||
|
||||
if (isStanding && this.movementTimer.passed(this.standingTime.getValue()) && this.sendCommandTimer.passed(this.waitTime.getValue())) {
|
||||
this.sendCommandTimer.reset();
|
||||
this.sendBaritoneCommand();
|
||||
}
|
||||
|
|
|
@ -57,8 +57,6 @@ public final class PortalFinderModule extends Module {
|
|||
|
||||
private final List<Vec3d> portals = new CopyOnWriteArrayList<>();
|
||||
|
||||
private static final int COLOR = 0xFFFFFFFF;
|
||||
|
||||
public PortalFinderModule() {
|
||||
super("PortalFinder", new String[]{"PortalFinder", "PFinder"}, "Highlights nearby portals.", "NONE", -1, Module.ModuleType.RENDER);
|
||||
}
|
||||
|
@ -79,7 +77,7 @@ public final class PortalFinderModule extends Module {
|
|||
|
||||
// Line
|
||||
if (this.tracer.getValue()) {
|
||||
RenderUtil.drawLine((float) projection.getX(), (float) projection.getY(), event.getScaledResolution().getScaledWidth() / 2.0f, event.getScaledResolution().getScaledHeight() / 2.0f, this.width.getValue(), ColorUtil.changeAlpha(new Color(this.color.getValue().getRed() / 255.0f, this.color.getValue().getGreen() / 255.0f, this.color.getValue().getBlue() / 255.0f).getRGB(), this.alpha.getValue()));
|
||||
RenderUtil.drawLine((float) projection.getX(), (float) projection.getY(), event.getScaledResolution().getScaledWidth() / 2.0f, event.getScaledResolution().getScaledHeight() / 2.0f, this.width.getValue(), ColorUtil.changeAlpha(this.color.getValue().getRGB(), this.alpha.getValue()));
|
||||
}
|
||||
|
||||
// Info
|
||||
|
@ -103,15 +101,14 @@ public final class PortalFinderModule extends Module {
|
|||
RenderUtil.begin3D();
|
||||
for (Vec3d portal : this.portals) {
|
||||
GlStateManager.pushMatrix();
|
||||
final boolean bobbing = mc.gameSettings.viewBobbing;
|
||||
mc.gameSettings.viewBobbing = false;
|
||||
mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
|
||||
|
||||
final Vec3d forward = new Vec3d(0, 0, 1).rotatePitch(-(float) Math.toRadians(Minecraft.getMinecraft().player.rotationPitch)).rotateYaw(-(float) Math.toRadians(Minecraft.getMinecraft().player.rotationYaw));
|
||||
|
||||
// Line
|
||||
if (this.tracer.getValue()) {
|
||||
RenderUtil.drawLine3D(forward.x, forward.y + mc.player.getEyeHeight(), forward.z, portal.x - mc.getRenderManager().renderPosX, portal.y - mc.getRenderManager().renderPosY, portal.z - mc.getRenderManager().renderPosZ, this.width.getValue(), ColorUtil.changeAlpha(new Color(this.color.getValue().getRed() / 255.0f, this.color.getValue().getGreen() / 255.0f, this.color.getValue().getBlue() / 255.0f).getRGB(), this.alpha.getValue()));
|
||||
// need to update modelview matrix or it freaks out when rendering another tracer, not sure why though
|
||||
// XXX this is done in other places, ctrl+shift+f to other files
|
||||
RenderUtil.updateModelViewProjectionMatrix();
|
||||
final GLUProjection.Vector3D forward = GLUProjection.getInstance().getLookVector().sadd(GLUProjection.getInstance().getCamPos());
|
||||
RenderUtil.drawLine3D(forward.x, forward.y, forward.z, portal.x - mc.getRenderManager().renderPosX, portal.y - mc.getRenderManager().renderPosY, portal.z - mc.getRenderManager().renderPosZ, this.width.getValue(), ColorUtil.changeAlpha(this.color.getValue().getRGB(), this.alpha.getValue()));
|
||||
}
|
||||
|
||||
// Info
|
||||
|
@ -122,8 +119,6 @@ public final class PortalFinderModule extends Module {
|
|||
GlStateManager.enableDepth();
|
||||
}
|
||||
|
||||
mc.gameSettings.viewBobbing = bobbing;
|
||||
mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
RenderUtil.end3D();
|
||||
|
|
|
@ -16,6 +16,8 @@ import net.minecraft.util.math.Vec3d;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Author Seth
|
||||
* 5/17/2019 @ 8:45 PM.
|
||||
|
@ -30,6 +32,11 @@ public final class StorageESPModule extends Module {
|
|||
|
||||
public final Value<Boolean> nametag = new Value<Boolean>("Nametag", new String[]{"Nametag", "Tag", "Tags", "Ntag", "name", "names"}, "Renders the name of the drawn storage object.", false);
|
||||
public final Value<Integer> opacity = new Value<Integer>("Opacity", new String[]{"Opacity", "Transparency", "Alpha"}, "Opacity of the rendered esp.", 128, 0, 255, 1);
|
||||
public final Value<Boolean> tracer = new Value<Boolean>("Tracer", new String[]{"TracerLine", "trace", "line"}, "Display a tracer line to each storage object.", false);
|
||||
public final Value<Color> tracerColor = new Value<Color>("TracerColor", new String[]{"TracerColor", "TColor", "TC"}, "Edit the storage object tracer color.", new Color(0, 0, 255));
|
||||
public final Value<Boolean> tracerStorageColor = new Value<Boolean>("TracerStorageColor", new String[]{"TracerStorageColor", "TStorageColor", "TSColor", "TStorageC", "TSC"}, "Use the storage object's color as the tracer color.", false);
|
||||
public final Value<Float> tracerWidth = new Value<Float>("TracerWidth", new String[]{"TracerWidth", "TWidth", "TW"}, "Pixel width of each tracer-line.", 0.5f, 0.1f, 5.0f, 0.1f);
|
||||
public final Value<Integer> tracerAlpha = new Value<Integer>("TracerAlpha", new String[]{"TracerAlpha", "TAlpha", "TA", "TracerOpacity", "TOpacity", "TO"}, "Alpha value for each drawn line.", 255, 1, 255, 1);
|
||||
|
||||
private final ICamera camera = new Frustum();
|
||||
|
||||
|
@ -51,8 +58,9 @@ public final class StorageESPModule extends Module {
|
|||
final float[] bounds = this.convertBounds(bb, event.getScaledResolution().getScaledWidth(), event.getScaledResolution().getScaledHeight());
|
||||
if (bounds != null) {
|
||||
if (this.mode.getValue() == Mode.TWO_D) { // 2D
|
||||
// Box
|
||||
RenderUtil.drawOutlineRect(bounds[0], bounds[1], bounds[2], bounds[3], 1.5f, ColorUtil.changeAlpha(0xAA000000, this.opacity.getValue()));
|
||||
RenderUtil.drawOutlineRect(bounds[0] - 0.5f, bounds[1] - 0.5f, bounds[2] + 0.5f, bounds[3] + 0.5f, 0.5f, ColorUtil.changeAlpha(this.getColor(te), this.opacity.getValue()));
|
||||
RenderUtil.drawOutlineRect(bounds[0] - 0.5f, bounds[1] - 0.5f, bounds[2] + 0.5f, bounds[3] + 0.5f, 0.5f, this.getBoxColor(te));
|
||||
}
|
||||
|
||||
if (this.nametag.getValue()) {
|
||||
|
@ -62,6 +70,12 @@ public final class StorageESPModule extends Module {
|
|||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
// Line
|
||||
if (this.tracer.getValue()) {
|
||||
final GLUProjection.Projection projection = GLUProjection.getInstance().project((bb.minX + bb.maxX) / 2, (bb.minY + bb.maxY) / 2, (bb.minZ + bb.maxZ) / 2, GLUProjection.ClampMode.NONE, true);
|
||||
RenderUtil.drawLine((float) projection.getX(), (float) projection.getY(), event.getScaledResolution().getScaledWidth() / 2.0f, event.getScaledResolution().getScaledHeight() / 2.0f, this.tracerWidth.getValue(), this.getTracerColor(te));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,8 +95,18 @@ public final class StorageESPModule extends Module {
|
|||
if (this.isTileStorage(te)) {
|
||||
final AxisAlignedBB bb = this.boundingBoxForEnt(te);
|
||||
if (bb != null) {
|
||||
//RenderUtil.drawFilledBox(bb, ColorUtil.changeAlpha(this.getColor(te), this.opacity.getValue()));
|
||||
//RenderUtil.drawBoundingBox(bb, 1.5f, ColorUtil.changeAlpha(this.getColor(te), this.opacity.getValue()));
|
||||
// Line
|
||||
if (this.tracer.getValue()) {
|
||||
// need to update modelview matrix or it freaks out when rendering another tracer, not sure why though
|
||||
// XXX this is done in other places, ctrl+shift+f to other files
|
||||
RenderUtil.updateModelViewProjectionMatrix();
|
||||
final GLUProjection.Vector3D forward = GLUProjection.getInstance().getLookVector().sadd(GLUProjection.getInstance().getCamPos());
|
||||
RenderUtil.drawLine3D(forward.x, forward.y, forward.z, (bb.minX + bb.maxX) / 2, (bb.minY + bb.maxY) / 2, (bb.minZ + bb.maxZ) / 2, this.tracerWidth.getValue(), this.getTracerColor(te));
|
||||
}
|
||||
|
||||
// Box
|
||||
//RenderUtil.drawFilledBox(bb, this.getBoxColor(te));
|
||||
//RenderUtil.drawBoundingBox(bb, 1.5f, this.getBoxColor(te));
|
||||
camera.setPosition(mc.getRenderViewEntity().posX, mc.getRenderViewEntity().posY, mc.getRenderViewEntity().posZ);
|
||||
|
||||
if (camera.isBoundingBoxInFrustum(new AxisAlignedBB(bb.minX + mc.getRenderManager().viewerPosX,
|
||||
|
@ -91,8 +115,9 @@ public final class StorageESPModule extends Module {
|
|||
bb.maxX + mc.getRenderManager().viewerPosX,
|
||||
bb.maxY + mc.getRenderManager().viewerPosY,
|
||||
bb.maxZ + mc.getRenderManager().viewerPosZ))) {
|
||||
RenderUtil.drawFilledBox(bb, ColorUtil.changeAlpha(this.getColor(te), this.opacity.getValue()));
|
||||
RenderUtil.drawBoundingBox(bb, 1.5f, ColorUtil.changeAlpha(this.getColor(te), this.opacity.getValue()));
|
||||
final int colorWithAlpha = this.getBoxColor(te);
|
||||
RenderUtil.drawFilledBox(bb, colorWithAlpha);
|
||||
RenderUtil.drawBoundingBox(bb, 1.5f, colorWithAlpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +214,7 @@ public final class StorageESPModule extends Module {
|
|||
}
|
||||
|
||||
|
||||
private int getColor(TileEntity te) {
|
||||
private int getBaseColor(TileEntity te) {
|
||||
if (te instanceof TileEntityChest) {
|
||||
return 0xFFFFC417;
|
||||
}
|
||||
|
@ -218,6 +243,21 @@ public final class StorageESPModule extends Module {
|
|||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
private int getBoxColor(TileEntity te) {
|
||||
return ColorUtil.changeAlpha(this.getBaseColor(te), this.opacity.getValue());
|
||||
}
|
||||
|
||||
private int getTracerColor(TileEntity te) {
|
||||
int baseColor;
|
||||
if (this.tracerStorageColor.getValue()) {
|
||||
baseColor = this.getBaseColor(te);
|
||||
} else {
|
||||
baseColor = this.tracerColor.getValue().getRGB();
|
||||
}
|
||||
|
||||
return ColorUtil.changeAlpha(baseColor, this.tracerAlpha.getValue());
|
||||
}
|
||||
|
||||
private float[] convertBounds(AxisAlignedBB bb, int width, int height) {
|
||||
float x = -1;
|
||||
float y = -1;
|
||||
|
|
|
@ -4,6 +4,7 @@ import me.rigamortis.seppuku.Seppuku;
|
|||
import me.rigamortis.seppuku.api.event.render.EventRender2D;
|
||||
import me.rigamortis.seppuku.api.event.render.EventRender3D;
|
||||
import me.rigamortis.seppuku.api.module.Module;
|
||||
import me.rigamortis.seppuku.api.util.ColorUtil;
|
||||
import me.rigamortis.seppuku.api.util.GLUProjection;
|
||||
import me.rigamortis.seppuku.api.util.MathUtil;
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
|
@ -51,6 +52,7 @@ public final class TracersModule extends Module {
|
|||
}
|
||||
|
||||
public final Value<Float> width = new Value<Float>("Width", new String[]{"Wid"}, "Pixel width of each tracer-line.", 0.5f, 0.0f, 5.0f, 0.1f);
|
||||
public final Value<Integer> alpha = new Value<Integer>("Alpha", new String[]{"Alpha", "A", "Opacity", "Op"}, "Alpha value for each drawn line.", 255, 1, 255, 1);
|
||||
|
||||
public TracersModule() {
|
||||
super("Tracers", new String[]{"Trace", "Tracer", "Snapline", "Snaplines"}, "Draws a line to entities", "NONE", -1, ModuleType.RENDER);
|
||||
|
@ -88,13 +90,11 @@ public final class TracersModule extends Module {
|
|||
if (e != null) {
|
||||
if (this.checkFilter(e)) {
|
||||
final Vec3d pos = MathUtil.interpolateEntity(e, event.getPartialTicks()).subtract(mc.getRenderManager().renderPosX, mc.getRenderManager().renderPosY, mc.getRenderManager().renderPosZ);
|
||||
final boolean bobbing = mc.gameSettings.viewBobbing;
|
||||
mc.gameSettings.viewBobbing = false;
|
||||
mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
|
||||
final Vec3d forward = new Vec3d(0, 0, 1).rotatePitch(-(float) Math.toRadians(Minecraft.getMinecraft().player.rotationPitch)).rotateYaw(-(float) Math.toRadians(Minecraft.getMinecraft().player.rotationYaw));
|
||||
RenderUtil.drawLine3D(forward.x, forward.y + mc.player.getEyeHeight(), forward.z, pos.x, pos.y, pos.z, this.width.getValue(), this.getColor(e));
|
||||
mc.gameSettings.viewBobbing = bobbing;
|
||||
mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
|
||||
// need to update modelview matrix or it freaks out when rendering another tracer, not sure why though
|
||||
// XXX this is done in other places, ctrl+shift+f to other files
|
||||
RenderUtil.updateModelViewProjectionMatrix();
|
||||
final GLUProjection.Vector3D forward = GLUProjection.getInstance().getLookVector().sadd(GLUProjection.getInstance().getCamPos());
|
||||
RenderUtil.drawLine3D(forward.x, forward.y, forward.z, pos.x, pos.y, pos.z, this.width.getValue(), this.getColor(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public final class TracersModule extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ColorUtil.changeAlpha(ret, this.alpha.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue