use of cc.hyperium.mods.chromahud.api.Dimension in project Hyperium by HyperiumClient.
the class GeneralConfigGui method handleMouseInput.
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
ScaledResolution current = ResolutionUtil.current();
int i = Mouse.getEventDWheel();
List<DisplayElement> elements = ChromaHUDApi.getInstance().getElements();
if (elements.size() > 0) {
if (i < 0) {
if (currentElement == null) {
currentElement = elements.get(0);
} else {
int i1 = elements.indexOf(currentElement);
i1++;
if (i1 > elements.size() - 1)
i1 = 0;
currentElement = elements.get(i1);
}
} else if (i > 0) {
if (currentElement == null) {
currentElement = elements.get(0);
} else {
int i1 = elements.indexOf(currentElement);
i1--;
if (i1 < 0)
i1 = elements.size() - 1;
currentElement = elements.get(i1);
}
}
}
boolean isOver = false;
for (GuiButton button : buttonList) {
if (button.isMouseOver())
isOver = true;
}
if (!mouseDown && Mouse.isButtonDown(0) && !isOver) {
// Mouse pushed down. Calculate current element
int clickX = Mouse.getX() / current.getScaleFactor();
int clickY = Mouse.getY() / current.getScaleFactor();
boolean found = false;
for (DisplayElement element : mod.getDisplayElements()) {
Dimension dimension = element.getDimensions();
double displayXLoc = current.getScaledWidth_double() * element.getXloc();
if (element.isRightSided())
displayXLoc -= element.getDimensions().getWidth();
double displayYLoc = current.getScaledHeight_double() - current.getScaledHeight_double() * element.getYloc();
if (clickX > displayXLoc && clickX < displayXLoc + dimension.getWidth() && clickY < displayYLoc && clickY > displayYLoc - dimension.getHeight()) {
// Open gui
if (currentElement != null && currentElement == element && pastClick) {
// Safely nuke the fields and deactivate the chroma effect
element.setSelected(false);
currentElement = null;
mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new DisplayElementConfig(element, mod));
return;
}
currentElement = element;
element.setSelected(true);
found = true;
break;
}
}
if (!found) {
if (currentElement != null)
currentElement.setSelected(false);
currentElement = null;
}
}
mouseDown = Mouse.isButtonDown(0);
if (mouseDown) {
pastClick = true;
dTick = 5;
}
}
use of cc.hyperium.mods.chromahud.api.Dimension in project Hyperium by HyperiumClient.
the class AddItemsGui method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
mouseLock = mouseLock && Mouse.isButtonDown(0);
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(target);
if (adding) {
Color defaultColor = new Color(255, 255, 255, 100);
int cursorY = 50 + offset;
drawCenteredString(mc.fontRendererObj, "Click Explore to see examples!", current.getScaledWidth() / 2, cursorY - 30, Color.RED.getRGB());
List<ChromaHUDParser> parsers = ChromaHUDApi.getInstance().getParsers();
for (ChromaHUDParser parser : parsers) {
Map<String, String> names = parser.getNames();
for (Map.Entry<String, String> entry : names.entrySet()) {
String s = entry.getKey();
String text1 = entry.getValue() + "";
drawRect(current.getScaledWidth() / 2 - 80, cursorY, current.getScaledWidth() / 2 + 80, cursorY + 20, defaultColor.getRGB());
int j = Color.RED.getRGB();
int width = 160;
int height = 20;
mc.fontRendererObj.drawString(text1, ((current.getScaledWidth() >> 1) - 80 + (width >> 1) - (mc.fontRendererObj.getStringWidth(text1) >> 1)), cursorY + ((height - 8) >> 1), j, false);
int i = ResolutionUtil.current().getScaledHeight() - (Mouse.getY() / current.getScaleFactor());
if (Mouse.isButtonDown(0) && !mouseLock)
if (i >= cursorY && i <= cursorY + 23) {
int i1 = Mouse.getX() / current.getScaleFactor();
if (i1 >= current.getScaledWidth() / 2 - 80 && i1 <= current.getScaledWidth() / 2 + 80) {
DisplayItem item = ChromaHUDApi.getInstance().parse(s, 0, new JsonHolder().put("type", s));
element.getDisplayItems().add(item);
element.adjustOrdinal();
mc.displayGuiScreen(new EditItemsGui(element, mod));
}
}
cursorY += 23;
}
}
} else {
int cursorY = 50 + offset;
List<ChromaHUDParser> parsers = ChromaHUDApi.getInstance().getParsers();
for (ChromaHUDParser parser : parsers) {
ChromaHUDDescription description = parser.description();
String text = "Items in " + description.getName() + ".";
mc.fontRendererObj.drawString(text, (current.getScaledWidth() - mc.fontRendererObj.getStringWidth(text)) >> 1, cursorY, Color.RED.getRGB(), true);
cursorY += 30;
Map<String, String> names = parser.getNames();
for (Map.Entry<String, String> entry : names.entrySet()) {
String s = entry.getKey();
String text1 = entry.getValue() + ": ";
DisplayElement displayElement = find(s);
if (displayElement == null) {
String text2 = "ERROR LOCATING DISPLAY ELEMENT " + s;
mc.fontRendererObj.drawString(text2, (current.getScaledWidth() - mc.fontRendererObj.getStringWidth(text2)) >> 1, cursorY, Color.RED.getRGB(), true);
cursorY += 15;
continue;
}
Dimension dimensions = displayElement.getDimensions();
int stringWidth = mc.fontRendererObj.getStringWidth(text1);
double totalWidth = dimensions.getWidth() + stringWidth;
double left = (current.getScaledWidth_double() - totalWidth) / 2;
double startDraw = left + stringWidth;
displayElement.setXloc(startDraw / current.getScaledWidth_double());
displayElement.setYloc(((double) cursorY) / current.getScaledHeight_double());
displayElement.drawForConfig();
mc.fontRendererObj.drawString(text1, (float) ((current.getScaledWidth() - totalWidth) / 2), cursorY, Color.RED.getRGB(), true);
cursorY += dimensions.getHeight() + 5;
}
}
}
ElementRenderer.endDrawing(target);
}
Aggregations